akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int N=500010;
//const int N=100;

struct node{
	int to,next,id;
};node edge[N*2];
int graph[N],tot;
int c[N],id[N];int vis[N];int sp[N];
int con[N];
int ID;
int rt1,rt2;

void addedge(int i,int x,int y,int id){
	edge[i].to=y;edge[i].next=graph[x];graph[x]=i;edge[i].id=id;
}

void dfs(int x){
	int i,y,id;
	for(i=graph[x];i;i=graph[x]){
		y=edge[i].to;id=edge[i].id;
		graph[x]=edge[i].next;
		if(vis[id])	continue;
		if(!sp[id]){c[x]--;c[y]++;}
		vis[id]=1;
		dfs(y);
	}
}

int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	int i,n,x;
	scanf("%d",&n);
	rep(i,1,n){
		scanf("%d",&x);
		if(x==-1){rt1=i;con[i]++;}
		else{
			ID++;
			tot++;addedge(tot,i,x,ID);
			tot++;addedge(tot,x,i,ID);
			con[i]++;con[x]++;
		}
	}
	rep(i,1,n)	if(con[i]&1){		
		ID++;sp[ID]=1;
		tot++;addedge(tot,i,i+n,ID);
		tot++;addedge(tot,i+n,i,ID);
	}
	rep(i,1,n){
		scanf("%d",&x);
		if(x==-1){rt2=i+n;con[i]++;}
		else{
			ID++;
			tot++;addedge(tot,i+n,x+n,ID);
			tot++;addedge(tot,x+n,i+n,ID);
			con[i]++;con[x]++;
		}
	}
	ID++;
	tot++;addedge(tot,rt1,rt2,ID);	
	tot++;addedge(tot,rt2,rt1,ID);
	rep(i,1,n)	if(con[i]&1)	{printf("IMPOSSIBLE\n");return 0;}
	printf("POSSIBLE\n");
	dfs(1);
	rep(i,1,n)	printf("%d ",c[i]);
	return 0;
}
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		

Measured memory_bytes: 23936
#include<bits/stdc++.h>
#ifndef LOCAL_PROJECT
#define cerr if(0)cerr
#endif
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
const int mn=2e5+10;
const ll inf=0x3f3f3f3f3f3f3f3f;
const ll mod=998244353;
#define mid ((l+r)>>1)
ll a[mn];
int main(){
#ifdef LOCAL_PROJECT
    freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
#else
    cin.tie(0);
    cin.sync_with_stdio(0);
#endif
    int n;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n,greater<ll>());
    ll ans=0;
    for(int i=1;i<n;i++)ans+=a[i/2];
    printf("%lld",ans);
}

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

const int INF = 1e9;

bool check(int a) {
    return 1 <= a && a <= 9;
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int A, B;
    cin >> A >> B;
    if (check(A) && check(B)) cout << A * B << endl;
    else cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 256
A, B, C = [int(_) for _ in input().split()]
 
def solve(A, B, C):
    result = 0
    if A == B == C and A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
        return -1
    while 1:
        if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
            return result
        A, B, C = A/2+B/2, B/2+C/2, C/2+A/2
        result += 1

print(solve(A, B, C))


Measured memory_bytes: 3060
#include<stdio.h>
  
#define MAX_DATASET 3000
#define MIN         0
#define MAX         10000
#define X 0
#define Y 1
#define IS_ERR(n) (n < MIN || n > MAX)
  
void swap(int *a, int *b)
{
    int c;
     c = *a;
    *a = *b;
    *b = c;
}
   
   
int main(void)
{
    int i, j, array[MAX_DATASET][2];
   
    for(i=0;i<MAX_DATASET;i++)
    {
        scanf("%d %d", &array[i][X], &array[i][Y]);
   
        if(IS_ERR(array[i][X]) || IS_ERR(array[i][Y]) )
        {
            return -1;
        }
   
        if(array[i][X] == 0 && array[i][Y] == 0)
        { 
            break;
        }
   
        if(array[i][X] > array[i][Y])
        {
           swap(&array[i][X], &array[i][Y]);
        }
    }
   
    for(j=0;j<i;j++)
    {
        printf("%d %d\n", array[j][X], array[j][Y]);
    }
   
    return 0;
}


Measured memory_bytes: 2060
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	map<int, int> mp;
	int cnt = 0;
	REP(i, n) {
		int a;
		cin >> a;
		mp[a]++;
	}
	for (auto a : mp) {
		if (a.second >= a.first)cnt += a.second - a.first;
		else cnt += a.second;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 4736
#include<iostream>
using namespace std;
int main(void){
    int H,W;
    while(1){
        cin >> H>> W;
        if(H==0&&W==0)break;
        for( int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if( (i+j)%2==0){
                cout << "#";
            }   else {
                cout << ".";
            }
        }
        cout << "\n";
        }
        cout << endl;
    }
    return 0;
}



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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define ins insert
#define er erase
#define bg begin()
#define ed end()
#define X first
#define Y second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define files(name) fin(name".in"); fout(name".out")
#define enter cout << "\n"
#define space cout << " "
#define endl "\n"
#define fi(st,n) for (int i = (st); i <= (n); ++i)
#define fj(st,n) for (int j = (st); j <= (n); ++j)
#define fk(st,n) for (int k = (st); k <= (n); ++k)
#define fq(st,n) for (int q = (st); q <= (n); ++q)
#define fw(st,n) for (int w = (st); w <= (n); ++w)
#define ff(i, st, n) for (int (i) = (st); (i) <= (n); ++(i))
#define ei(st,n) for (int i = (st); i >= (n); --i)
#define ej(st,n) for (int j = (st); j >= (n); --j)
#define ek(st,n) for (int k = (st); k >= (n); --k)
#define ef(i, st, n) for (int (i) = (st); (i) >= (n); --(i))
#define ri(st,n) for (int i = (st); i < (n); ++i)
#define rj(st,n) for (int j = (st); j < (n); ++j)
#define rk(st,n) for (int k = (st); k < (n); ++k)
#define rq(st,n) for (int q = (st); q < (n); ++q)
#define rf(i, st, n) for (int (i) = (st); (i) < (n); ++(i))
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define y1 dsklmlvmd

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int inf = (int)1e9;
const dbl eps = (dbl) 1e-8;
const int mod = (int) 1000000007;
const int maxn = (int) 1e5 + 5;
//const dbl M_PI = (dbl)2 * (dbl)acos(0);

//cout<<fixed<<setprecision(10);
//srand(time(0));

int n, m, T, a[maxn], khm, x, y, t[maxn], en[maxn], zp;
vector <int> vh, vc[maxn];

int main()
{
//    fin("t.in");
    sync;
    cin >> n >> m;
    cin >> T;
    fi(1, T) {
        cin >> a[i];
        vc[a[i]].pb(i);
    }
    fi(1, n) {
        en[i] = T;
    }
    vh.clear();
    khm = -1;
    ei(T, 1) {
        if (t[a[i]])
            continue;
        vh.pb(a[i]);
        t[a[i]] = i;
        x = n;
        ej((int)vc[a[i]].size() - 1, 0) {
            if (en[x] < vc[a[i]][j]) {
                continue;
            }
            en[x] = vc[a[i]][j] - 1;
            --x;
            if (x == 0)
                break;
        }
        if (khm == -1) {
            ej(x, 1) {
                en[j] = 0;
                khm = (int)vh.size() - 1;
                zp = i;
            }  
        }
    }
    if (khm != -1) {
        y = 0;
//        cout << khm << endl;
        ri(khm, vh.size()) {
            ++y;
            while (t[y] > zp) {
                ++y;
            }
            if (vh[i] != y) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}




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

char s[110];
int main(){
	scanf("%s",s);
	int n=strlen(s);
	for(int i=0;i<n/2;i++){
		if(  s[i]!=s[n/2-1-i]
		   ||s[i]!=s[n/2+1+i]
		   ||s[i]!=s[n-1-i]){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}

Measured memory_bytes: 128
N, M, Q = map(int, input().split())

# i 以下に一切含まれていない数 つまり、l以下
# l_list = {}

# # i 以下に全て含まれている数 つまり、r以上
# r_list = {}
# L = []
# R = []
X = [[0]*N for _ in range(N)]

for i in range(M):
    l, r = map(int, input().split())
    X[l-1][r-1] += 1
    # L.append(l)
    # R.append(r)

C = [[0]*N for i in range(N)]

for i in range(N):
    for j in range(N):
        if j == 0:
            C[i][j] = X[i][j]
        else:
            C[i][j] = C[i][j-1] + X[i][j]

check = []
for i in range(Q):
    p, q = map(int, input().split())
    check.append((p,q)) 

for p,q in check:
    ans = 0
    for i in range(p-1,q):
        if p-2 < 0:
            ans += C[i][q-1]
        else:
            ans += C[i][q-1] - C[i][p-2]

    print(ans)

Measured memory_bytes: 75544
# python 3.4.3
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# library
# -------------------------------------------------------------



# -------------------------------------------------------------
# main
# -------------------------------------------------------------

N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [tuple(map(int,input().split())) for _ in range(M)]

A.sort()
BC.sort(key = lambda x:x[1], reverse=True)

X = [0]*N
i = 0
for b,c in BC:
    for j in range(b):
        if i+j >= N:
            break
        X[i+j] = c
    i += b

ans = 0
for i in range(N):
    A[i] = max(A[i], X[i])
    ans += A[i]

print(ans)


Measured memory_bytes: 23276
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <cstring>
#define maxn 100005
using namespace std;

int n, m;
vector<int> users[maxn];
int root[maxn];

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

void merge(int u, int v) {
	u = par(u);
	v = par(v);
	if (u != v) {
		root[v] = u;
	}
}

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i++) {
		int k, x;
		scanf("%d", &k);
		for (int j = 0; j < k; j++) {
			scanf("%d", &x);
			users[x].push_back(i);
		}
	}
	for (int i = 1; i <= n; i++) {
		root[i] = i;
	}
	for (int j = 1; j <= m; j++) {
		for (int k = 1; k < users[j].size(); k++) {
			merge(users[j][0], users[j][k]);
		}
	}

	int sroot = par(1);
	for (int i = 2; i <= n; i++) if (sroot != par(i)) {
		printf("NO\n");
		return 0;
	}
	printf("YES\n");

	return 0;
}

Measured memory_bytes: 4608
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve(long long A, long long B){
    for(LL i=1; i<=100000; i++){
        if(floor(i*0.08)==A && floor(i*0.1)==B){
        cout<<i<<endl;return;}
    }
    cout<<-1<<endl;return;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  string wheathers[]={"Sunny","Cloudy","Rainy"};
  string w;
  cin>>w;
  int index=0;
  for(int i=0;i<3;i++){
    if(w==wheathers[i])index=i+1;
  }
  cout<<wheathers[index%3]<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline
n,k = map(int,input().split())
a = list(map(int,input().split()))
bit = [0]*41
for i in range(n):
        for j in range(41):
                if a[i] & 1<<j:
                        bit[j] += 1
ans = 0
ima = 0
dp = [[0]*2 for i in range(42)]
for i in range(40,-1,-1):
    if 1<<i > k:
      dp[i][1] += dp[i+1][1]+bit[i]*(1<<i)
      continue
    if 1 & k>>i:
        dp[i][0] = dp[i+1][1]+ bit[i]*(1<<i)
        dp[i][1] = dp[i+1][1]+(n-bit[i])*(1<<i)
    else:
        dp[i][1] = dp[i+1][1] + bit[i]*(1<<i)
    if dp[i+1][0]:
           dp[i][0] = max(dp[i][0],dp[i+1][0]+max(bit[i]*(1<<i),(n-bit[i])*(1<<i)))

dai = 0
for i in range(n):
  dai += k^a[i]
print(max(dp[0][0],dai))

Measured memory_bytes: 63192
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int n,m,l;

int main() {
  cin >>n >>m >>l;
  vector<vector<ll>> A(n, vector<ll>(m, 0)), B(m, vector<ll>(l, 0));
  rep(i, n) rep(j, m) cin >>A[i][j];
  rep(i, m) rep(j, l) cin >>B[i][j];
  vector<vector<ll>> C(n, vector<ll>(l, 0));
  rep(i, n){
    rep(j, l){
      rep(k, m){
        C[i][j] += A[i][k] * B[k][j];
      }
    }
  }
  rep(i, n){
    rep(j, l){
      cout <<C[i][j];
      if (j == l-1) cout <<endl;
      else cout <<" ";
    }
  }
}



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

#define task "A"
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define DEBUG(X) { cerr << #X << " = " << (X) << '\n'; }
#define PR(A, n) { cerr << #A << " = "; FOR(_, 1, n) cerr << A[_] << ' '; cerr << '\n'; }
#define sz(x) ((int)(x).size())
#define pb push_back
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));
#define next ackjalscjaowjico
#define prev ajcsoua0wucckjsl
#define y1 alkscj9u20cjeijc
#define left lajcljascjljl
#define right aucouasocjolkjl
#define y0 u9cqu3jioajc

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;
int n, res;
struct tem
{
    int n;
    pair<int, bool> p[15];
} qu[16];
bool kind[16];
int main()
{
	//freopen(task".in","r",stdin);
	//freopen(task".out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	cin >> n;
	rep(i, 0, n - 1)
	{
	    cin >> qu[i].n;
	    rep(j, 1, qu[i].n)
	    {
	        int x;
	        bool y;
	        cin >> x >> y;
	        x--;
	        qu[i].p[j] = {x, y};
	    }
	}
	bool ok;
	rep(x, 0, (1 << n) - 1)
	{
	    ok = 1;
	    rep(i, 0, n - 1) if (x & (1 << i)) kind[i] = 1;
	    else kind[i] = 0;
	    rep(i, 0, n - 1) if (kind[i])
        {
            rep(j, 1, qu[i].n)
            {
                //cout << qu[i].p[j].F << ' ' << qu[i].p[j].S << '\n';
                if (kind[qu[i].p[j].F] != qu[i].p[j].S) {ok = 0; break;}
            }

        }
	    if (ok) res = max(res, __builtin_popcount(x));
	}
	cout << res;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
const int N = 1e5+100;
#define ll long long
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+ c>=22) puts("bust");
    else puts("win");
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<climits>
using namespace std;
typedef long long int ll;
static const int MAX_M = 1000;
static const int MAX_N = 1000;

int M, N;
char field1[MAX_M + 1][MAX_N], field2[MAX_M + 1][MAX_N];
char field3[2][2];

int memo[3][MAX_M][MAX_N];
char ch[] = {'J', 'O', 'I'};
int dy[] = {0, 0, 1, 1};
int dx[] = {0, 1, 1, 0};

int main(){
	scanf("%d %d", &M, &N);
	for(int i = 0; i < M; i++){
		scanf("%s", field1[i]);
		strcpy(field2[i], field1[i]);
	}
	for(int i = 0; i < 2; i++) scanf("%s", field3[i]);

	int res = 0;
	for(int i = 0; i < M; i++){
		for(int j = 0; j < N; j++){
			int cy = i, cx = j;
			bool flag = true;
			for(int k = 0; k < 4; k++){
				int ny = cy + dy[k], nx = cx + dx[k];
				if(ny > M - 1 || nx > N - 1) flag = false;
				if(field1[ny][nx] != field3[dy[k]][dx[k]]) flag = false;
			}
			if(flag){
				res++;
				for(int k = 0; k < 4; k++){
					int ny = cy + dy[k], nx = cx + dx[k];
					if(field1[ny][nx] == 'J') memo[0][ny][nx]--;
					if(field1[ny][nx] == 'O') memo[1][ny][nx]--;
					if(field1[ny][nx] == 'I') memo[2][ny][nx]--;
				}
			}
		}
	}

	int max_diff = -2;
	for(int i = 0; i < M; i++){
		for(int j = 0; j < N; j++){
			int cy = i, cx = j;
			for(int k = 0; k < 3; k++){
				field2[i][j] = ch[k];
				for(int l = 0; l < 4; l++){
					int ny = cy - dy[l], nx = cx - dx[l];
					if(ny < 0|| nx < 0) continue;
					bool flag = true;
					for(int m = 0; m < 4; m++){
						int ny2 = ny + dy[m], nx2 = nx + dx[m];
						if(ny2 > M - 1 || nx2 > N - 1) flag = false;
						if(field2[ny2][nx2] != field3[dy[m]][dx[m]]) flag = false;
					}
					if(flag) memo[k][i][j]++;
				}
				max_diff = max(max_diff, memo[k][i][j]);
				field2[i][j] = field1[i][j];
			}
		}
	}
	res += max_diff;
	printf("%d\n", res);
	return 0;
}



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

int main(){
    int a,b;
    int cnt=0;
    cin>>a>>b;
  	for (int i=0 ;i<=a;i++){
    	for(int j=0;j<=a;j++){
         	int k=b-i-j;	
          if (i+j+k==b && k>=0 && k<=a){
            cnt+=1;
           // cout<<i<<j<<k<<endl;
          }
            
        
        }  
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for(int i = (s); i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
typedef long long ll;
const int INF = 1001001001;
const int mod = 1000000007;

int main() {
    int N;
    cin >> N;
    vector<int> v(N * 3);
    rep(i, 3 * N) cin >> v[i];

    sort(v.begin(), v.end(), greater<int>());
    int64_t ans = 0;
    for(int i = 0; i < N; i++) {
        ans += v[i * 2 + 1];
    }
    cout << ans << endl;
}

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

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<x && x<=b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

int H,W,N;
int sr,sc;
std::string s,t;

int main(){
    INIT;
    cin >> H >> W >> N;
    cin >> sr >> sc;
    cin >> s;
    cin >> t;

    int xl = sc;
    int xr = sc;
    int yu = sr;
    int yd = sr;
    REP(i,N) {
        if(s[i] == 'L') {
            if(!IN(0,xl-1,W)) {
                cout << "NO" << "\n";
                return 0;
            }
            xl--;
        } else
        if(s[i] == 'R') {
            if(!IN(0,xr+1,W)) {
                cout << "NO" << "\n";
                return 0;
            }
            xr++;
        } else
        if(s[i] == 'U') {
            if(!IN(0,yu-1,H)) {
                cout << "NO" << "\n";
                return 0;
            }
            yu--;
        } else
        if(s[i] == 'D') {
            if(!IN(0,yd+1,H)) {
                cout << "NO" << "\n";
                return 0;
            }
            yd++;
        }

        if(t[i] == 'L' && IN(0,xr-1,W)) xr--;
        else
        if(t[i] == 'R' && IN(0,xl+1,W)) xl++;
        else
        if(t[i] == 'U' && IN(0,yd-1,H)) yd--;
        else
        if(t[i] == 'D' && IN(0,yu+1,H)) yu++;
    }

    cout << "YES" << "\n";
}

Measured memory_bytes: 920
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))


typedef pair<char,lli> cip;

typedef string::iterator sta;

bool isnum(char c){
	return ('0'<=c && c<='9');
}

lli num(sta& s){
	lli res=0;
	while(isnum(*s)){
		res*=10; res+=(*s-'0');
		s++;
	}
	return res;
}

cip exprs(sta& s,lli p);

#include<cassert>

//6(55(44(255(YG))A)7(97(R))W9(U)PJ)G9(347(Y84(QSKVZ)JJ262(I779(UDOQ)RXSQV3(VTCY))W))4(B)NDJ 65420

cip expr(sta& s,lli p){
	//printf("%c %lld\n",*s,p);
	cip res;
	if(isnum(*s)){
		lli a=num(s);
		if(*s=='('){
			s++; 
			sta ns=s;
			cip pa=exprs(s,p);
			if(pa.fir!='0')res=pa;
			else{
				if(pa.sec*a>p){
					res=exprs(ns,p % pa.sec);
				}
				else res=cip('0',pa.sec*a);
			}
			s++;
		}
		else{
			if(a>p)res=cip(*s,0);
			else res=cip('0',a);
			s++;
		}
	}
	else{
		if(p==0)res=cip(*s,0);
		else res=cip('0',1);
		s++;
	}
	return res;
}

cip exprs(sta& s,lli p){
	cip res('0',0);
	lli nl=0;
	for(;;){
		if(*s==')' || *s=='$')break;
		cip a=expr(s,p);
		//printf("expr %c %d\n",a.fir,a.sec);
		if(a.fir!='0')return a;
		p-=a.sec;
		nl+=a.sec;
	}
	res.sec=nl;
	return res;
}

int n;
string s;

int main(void){
	for(;;){
		cin >> s >> n;
		if(n==0 && s[0]=='0' && s[1]=='\0')break;
		s += "$";
		sta ss=s.begin();
		cip pa=exprs(ss,n);
		printf("%c\n",pa.fir);
	}
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
signed main(){
    int n,k,a[100010],b[100010],ans=0;
    cin>>n>>k;
    rep(i,n)cin>>a[i]>>b[i];
    int K=k,sum=0;
    rep(i,n){
        bool flag=true;
        for(int j=0;j<30;j++){
            bool A=(K>>j)&1;
            bool B=(a[i]>>j)&1;
            if(A==false&&B==true)flag=false;
        }
        if(flag)sum+=b[i];
    }
    chmax(ans,sum);
    rep(p,30){
        if((k>>p)&1){
            K=k-(1<<p),sum=0;
            rep(i,n){
                bool flag=true;
                for(int j=p;j<30;j++){
                    bool A=(K>>j)&1;
                    bool B=(a[i]>>j)&1;
                    if(A==false&&B==true)flag=false;
                }
                if(flag)sum+=b[i];
            }
            chmax(ans,sum);
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

void main_()
{
    ll N, M;
    cin >> N >> M;

    auto ans = abs(N - 2) * abs(M - 2);
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();

        int wa = A + B;
        int sa = A - B;
        int seki = A * B;

        int max1 = Math.max(wa, sa);
        int max2 = Math.max(max1, seki);
        System.out.println(max2);
        sc.close();
    }
}

Measured memory_bytes: 23124
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            long a = Long.parseLong(in.next());
            long b = Long.parseLong(in.next());
            long c = Long.parseLong(in.next());
            long k = Long.parseLong(in.next());
            long ans = 0;
            long tmp = k;

            if (a > 0) {
                if (a >= k) ans += k;
                else ans += a;
                tmp -= a;
                a = a - k;
                k = tmp;
            }
            if (a <= 0 && b > 0 && k > 0) {
                tmp -= b;
                b = b - k;
                k = tmp;
            }
            if (a <= 0 && b <= 0 && c > 0 && k > 0) {
                ans -= k;
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 35856
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e15;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

const ll mod = 998244353;

int main(){
    ll N; cin >> N;
    string s; cin >> s;
    vl x(N);
    REP(i, N){
        if(s[i] == '.') x[i] = 0;
        else x[i] = 1;
    }
    
    vl vcnt0(N+1, 0), vcnt1(N+1, 0);
    ll cnt0 = 0, cnt1 = 0;
    REP(i, N){
        if(x[i] == 0){
            cnt0++;
        }
        else{
            cnt1++;
        }
        vcnt0[i+1] = cnt0;
        vcnt1[i+1] = cnt1;
    }
    
    ll ans = LINF;
    REP(i, N+1){
        ll w = vcnt0[N] - vcnt0[i];
        ll b = vcnt1[i];
        ans = min(ans, b+w);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5252
#include<stdio.h>
#include<string.h>
int main(void){
  int l,i;
  scanf("%d",&l);
  char str[l];
  if(l%2!=0){
    printf("No");
    return 0;
  }
  scanf("%s",str);
  for(i=0;i<(l/2);i++){
    if(str[i]!=str[l/2+i]){
      printf("No");
      return 0;
    }
  }
  printf("Yes");
  return 0;
}
    

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
  int i,b,f,r,v, n;
  int data[4][3][10] = {};
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    int b, f, r, v;
    scanf("%d %d %d %d", &b, &f, &r, &v);
    data[b-1][f-1][r-1] += v;
  }

for(b = 0; b < 4; b++) {
    for(f = 0; f < 3; f++) {
      for(r = 0; r < 10; r++) {
	printf(" %d", data[b][f][r]);
      }
      printf("\n");
    }
    if(b != 3) printf("####################\n");
  }
return (0);
}


Measured memory_bytes: 2076
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int N;
void dfs(int u,string s,vector<string> &v){
    if(s.size()==N){
        v.push_back(s);
        return;
    }
    REP(i,u+2){
        dfs(max(u,i),s+char('a'+i),v);
    }
}

int main(){
    cin>>N;
    vector<string> ans;
    dfs(0,"a",ans);
    sort(All(ans));
    for(auto s:ans) cout<<s<<endl;
}

Measured memory_bytes: 7796
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  int ans = (1900 * M + 100 * (N - M)) * pow(2, M);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
import Control.Monad
import Control.Applicative
import Data.List
import Data.Maybe (fromJust)

type Dice = [Int]

rot :: Dice -> Char -> Dice
rot d 'E' = [d!!3, d!!1, d!!0, d!!5, d!!4, d!!2]
rot d 'W' = [d!!2, d!!1, d!!5, d!!0, d!!4, d!!3]
rot d 'N' = [d!!1, d!!5, d!!2, d!!3, d!!0, d!!4]
rot d 'S' = [d!!4, d!!0, d!!2, d!!3, d!!5, d!!1]
rot _ _ = undefined

solve :: [[Int]] -> String
solve (diceA:diceB:_) =
    let es = cycle "E" in
    let ns = cycle "N" in
    let cmdSets =   [ take a es ++ take b ns ++ take c es ++ take d ns
                    | a<-[1..4], b<-[1..4], c<-[1..4], d<-[1..4]]
    in  
    solve' cmdSets
    where
    solve' [] = "No"
    solve' (cmd:cmds) =
        if (foldl' rot diceB cmd == diceA) then
            "Yes"
        else
            solve' cmds

main =
    putStrLn =<< solve . map (map read . words) . lines <$> getContents

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

out=1
for i in range(N):
    out=out*A[i]
    if out>10**18:
        out=-1
        break
    elif out==0:
        break

for i in range(N):
    if A[i]==0:
        out=0
        break
        
print(out)

Measured memory_bytes: 84580
// Problem : B - One Clue
// Contest : AtCoder - AtCoder Beginner Contest 137
// URL : https://atcoder.jp/contests/abc137/tasks/abc137_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <sstream>
#include <iterator>

using namespace std;

#define endl ("\n")
#define pi (3.141592653589)
#define mod 1000000007
#define int int64_t
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define rrep(i, n) for(int i=n-1;i>=0;i--)
#define rep(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;

int32_t main() 
{
    fast;
	int K, X;
	cin >> K >> X;
	for(int i = X-K+1; i < X+K; i++){
		cout << i << " ";
	}
	return 0;
}




Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N[3];
    REP(i, 3) cin >> N[i];
    sort(N, N + 3, greater<int>());
    cout << N[0] * 10 + N[1] + N[2] << endl;
    return 0;
}

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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)                                                             \
  sort(x.begin(), x.end());                                                    \
  x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y)                                                           \
  cerr << "(" << #x << ", " << #y << ") = "                                    \
       << "(" << x << ", " << y << ")" << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

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

  int x, n;
  cin >> x >> n;

  vector<int> v(n);
  rep(i, n) { cin >> v[i]; }

  int back = 101;

  for (int i = x; i <= 100; i++) {
    auto result = find(all(v), i);
    if (result == v.end()) {
      back = i;
      break;
    } else {
      continue;
    }
  }

  debug(back);

  int front = 0;

  for (int i = x; i >= 1; i--) {
    auto result = find(all(v), i);
    debug(i);
    if (result == v.end()) {
      front = i;
      break;
    } else {
      continue;
    }
  }
  debug(front);

  if(n == 0){
      cout << x << endl;
      return 0;
  }

  int res = abs(front - x) <= abs(back - x) ? front : back;

  cout << res << endl;

  return 0;
}

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

public final class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] in = br.readLine().split(" ");
		int n = Integer.parseInt(in[0]);
		int t = Integer.parseInt(in[1]);
		int[] arr = new int[n];
		in = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			arr[i] = Integer.parseInt(in[i]);
		}
		System.out.println(new Solver().solve(arr, t));
	}
}

class Solver {

	int solve(int[] a, int t) {
		int[] temp = new int[a.length];
		int min = a[0], maxCnt = 0;
		for (int i = 1; i < a.length; i++) {
			if (min > a[i - 1]) {
				min = a[i - 1];
			}
			temp[i] = (a[i] - min);
		}
		int max = Arrays.stream(temp).max().getAsInt();
		for (int i = 1; i < temp.length; i++) {
			if (temp[i] == max) {
				maxCnt++;
			}
		}
		return maxCnt;
	}
}


Measured memory_bytes: 40924
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitsf(n) __builtin_popcount(n)
ll power(ll x, ll y); 

const ll MOD = 1000000007;
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    ll n;
    cin >> n;
    cout << (n*(n-1))/2;
}
 
ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}


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

void judge(int &i, unordered_map<char, char> &map, string &S1, string &S2, string &ans) {
    if (map.count(S1.at(i)) == 1 && map[S1.at(i)] != S2.at(i)) {
        ans = "No";
    } else map[S1.at(i)] = S2.at(i);
}

int main() {
    int N, K;
    cin >> N >> K;
    ll mod0 = N / K;
    ll modhalf;
    if (K % 2 == 1) modhalf = 0;
    else {
        modhalf = mod0;
        if (N % K >= K / 2) ++modhalf;
    }
    ll ans = mod0*mod0*mod0 + modhalf*modhalf*modhalf;
    cout << ans << endl;
}


Measured memory_bytes: 3628
from itertools import groupby

N = int(input())
s = input()
S = input()
mod = 10 ** 9 + 7

s = [len(list(j)) for i, j in groupby(s)]

ans = 3 * s[0]

for i in range(1,len(s)):
    if s[i-1] == 1:
        ans *= 2
    elif s[i] == 2:
        ans *= 3
    ans %= mod

print(ans)

Measured memory_bytes: 9096
#include <bits/stdc++.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = 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; }
//ミョ(-ω- ?)
int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int turn = 1;
    while(a > 0 && c > 0){
        if(turn%2){
            c -= b;
        }else{
            a -= d;
        }
        turn++;
    }
    if(turn%2 == 0)cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

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

using namespace std;

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

constexpr const int INT_INF=0x3f3f3f3f; // 1061109567
constexpr const ll LL_INF=0x3f3f3f3f3f3f3f3f; // 4557430888798830399
constexpr const double EPS=1e-9;

// min, max
template <typename T> bool chmax(T& a, T b) {
    if(a<b){a=b;return true;}return false;
}
template <typename T> bool chmin(T& a, T b) {
    if (a>b){a=b;return true;}return false;
}

// INT
#define GCD(a, b) __gcd(a, b)
template <typename T> T LCM(T a, T b) {return a / GCD(a, b) * b;}
template <typename T> T EXTGCD(T a, T b, T& x, T& y) {
    T d = a;
    if (b != 0) {d=EXTGCD(b,a%b,y,x);y-=(a/b)*x;}
    else x=1,y=0;
    return d;
}
template <typename T> bool is_prime(T a) {
    for(int i=2;i*i<=a;i++)if(a%i==0)return true;
    return false;
}

// MOD
const ll MOD = 1000000000 + 7;
#define add(a, b) ((a % MOD) + (b % MOD)) % MOD
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define sub(a, b) ((a % MOD) + MOD - (b % MOD)) % MOD
template <typename T> T mod_inverse(T a, T mod, bool prime){ // if mod is prime, "prime" is true.
    if(prime){
        T tmp=mod-2,now=a,res=1;while(tmp){if(tmp&1)res=mul(res,now);now=mul(now,now);tmp>>=1;}
        return res;
    }else{T x,y;EXTGCD(a,mod,x,y);return (mod+x%mod)%mod;}
}
#define divide(a, b) ((a % MOD) * (mod_inverse(b, MOD, true))) % MOD

// llのとき、数値の最後に"L"を付ける癖をつけよう.

//
//
//  　　┓　　　┏
//  　＊┗┓　┏┛
//  　　　┫　┣　＊
//  　┏┳┻━┻┳┓
//  　┗┫　　　┣┛
//  ＊　┣　　━┃　＊        Merry Christmas!!
//  　┏┛　　〃┃
//  　┃●　　　┣━┳┓
//  　┗┻┳━━┛　┣┛
//  　＊　┃┏┓┣┓┃
//WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW

int n;
int cont[101];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    FILE *stream1;
    //FILE *stream2;
    stream1 = freopen("/home/aim_cpo/ドキュメント/competitive/CLionProject/competitive/in.txt", "r", stdin);
    //stream2 = freopen("out.txt", "w", stdout);
    if (stream1 == nullptr) return 0;
    //if (stream2 == NULL) return 0;
#endif
    cin >> n;
    for (int i = 2; i <= n; i++) {
        int now = i;
        for (int j = 2; j * j <= now; j++) {
            int cnt = 0;
            while (now % j == 0) {
                now /= j;
                cnt++;
            }
            cont[j] += cnt;
        }
        if (now != 1) cont[now]++;
    }
    int two = 0, four = 0, fourteen = 0, twenty_four = 0, seventy_four = 0;
    for (int i = 0; i <= 100; i++) {
        if (cont[i] >= 74) seventy_four++;
        if (cont[i] >= 24) twenty_four++;
        if (cont[i] >= 14) fourteen++;
        if (cont[i] >= 4) four++;
        if (cont[i] >= 2) two++;
    }
    ll ans = four * (four - 1) / 2 * (two - 2);
    ans += fourteen * (four - 1);
    ans += twenty_four * (two - 1);
    ans += seventy_four;
    cout << ans << endl;
#ifdef  LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif
    return 0;
}

Measured memory_bytes: 256
def main():
    n, m = (int(i) for i in input().split())
    h = [int(i) for i in input().split()]
    roads = [(int(i) - 1 for i in input().split()) for _ in range(m)]

    nbors = [[] for _ in range(n)]
    for a, b in roads:
        nbors[a].append(b)
        nbors[b].append(a)

    ngood = 0
    for o in range(n):
        if all(h[o] > h[nb] for nb in nbors[o]):
            ngood += 1

    print(ngood)

main()


Measured memory_bytes: 110416
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()



int main(void){
    int N,L;
    cin >> N >> L;
    int a;

    if(N == 2){
        if(L<0){
            a = L;
        }else{
            a = L + 1;
        }
    }else{
        if(L<1){
            if(N+L<=0){
                a = N*(N+1)/2 + (L-1)*N - (N+L-1);
            }else{
                a = N*(N+1)/2 + (L-1)*N;
            }
            
        }else{
            a = N*(N+1)/2 + (N-1)*(L-1) - 1;
        }
    }

    cout << a << endl;
	
    return 0;
}


Measured memory_bytes: 256