akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}
 
int a[100000];
 
int main(){
	int n,in;
	cin >> n;
	REP(i,n){
		cin >> in;
		
		if(n%2 == in%2){
			cout << 0 << endl;
			return 0;
		}
		if(in==0 && a[in] >= 1){
			cout << 0 << endl;
			return 0;
		}
		if(a[in] >= 2){
			cout << 0 << endl;
			return 0;
		}else{
			a[in]++;
		}
		
	}
	
	const ll mod = 1000000007;
	ll ans = 1;
	REP(i,n/2){
		ans = (ans*2)%mod;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int N = 1e4+5;
const int maxn = 1e9+5;
const dd eps = 1e-6;
const ll mod = 1e9+7;
int n;
string s;

int main(){
  // freopen("input.txt","r",stdin);
  cin>>n>>s;
  if(n&1) cout<<"No"<<endl;
  else{
    string s1 = s.substr(0,n>>1);
    string s2 = s.substr(n>>1,n>>1);
    if(s1 == s2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
s = []
for _ in range(N):
    line = input()
    s.append(line)

M = int(input())
t = []
for _ in range(M):
    line = input()
    t.append(line)

words = set(s)
ans = 0

for w in words:
    tmp = 0
    for si in s:
        if w == si:
            tmp += 1
    for ti in t:
        if w == ti:
            tmp -= 1
    ans = max(ans, tmp)
print(ans)


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    string s; cin >> s;
    rep(i,s.size()){
        if(i==3)cout << '8';
        else cout << s[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
//Name: Exit Survey
//Level: 1
//Category: やるだけ
//Note: 

/**
 * がんばる。
 */
#include <iostream>

using namespace std;

bool solve(bool first) {
    int N;
    if(!(cin >> N)) return false;
    if(!N) return false;

    long long sum = 0;
    for(int i = 0; i < N; ++i) {
        int v;
        cin >> v;
        sum += v;
    }
    cout << sum / N << endl;
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    bool first = true;
    while(solve(first)) {
        first = false;
    }
    return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ll mod=1e9+7;
const ld PI = 2 * acos(0.0);
ll m(ll a){ return (a+mod)%mod;}
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
	if(b==0)
		return 1;
	ll d=power(a,b/2,m);
	d=(d*d)%m;
	if(b&1)
		d=(d*a)%m;
	return d;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	string s;cin>>s;
	cout<<(s=="ABC"?"ARC":"ABC")<<endl;	
	return 0;
}

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

using namespace std;
//DP用
template<class T> inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF = 1LL << 60;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int ans;
    ans = c-(a-b);
    if(ans < 0) {
        ans = 0;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
def isStorage(max_shelf):
	i,cur_shelf,num = 0,0,1
	while i < n:
		if num > m:
			return False
		if cur_shelf + book[i] > max_shelf:
			num += 1
			cur_shelf = 0
		else:
			cur_shelf += book[i]
			i += 1
	else:
		return True
			
while 1:
	m,n = map(int,raw_input().split())
	if m==0: break
	book = [int(raw_input()) for i in range(n)]
	max_shelf = len = sum(book)
	while len:
		len /= 2
		max_shelf -= len if isStorage(max_shelf) else -len
	max_shelf += 6
	while isStorage(max_shelf-1):
		max_shelf -= 1
	print max_shelf

Measured memory_bytes: 4240
#include<stdio.h>

int main()
{
    int P;
    int Q;
    int R;
    scanf("%d",&P);
    scanf("%d",&Q);
    scanf("%d",&R);
  int totalX = P+Q;
  int totalY= Q+R;
  int totalZ = R+P;
    if(totalX > totalY){
        if(totalY > totalZ){
            printf("%d",totalZ);
        }else {
            printf("%d",totalY);
        }
    }else{
        if(totalX >totalZ){
            printf("%d",totalZ);
        }else{
            printf("%d",totalX);
        }
    }


}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
	int H,N,i;
  scanf("%d%d",&H,&N);
  int A[N];
  for(i=0;i<N;i++){
  	scanf("%d",&A[i]);
  }
	
  for(i=0;i<N;i++){
  	H-=A[i];
  }

  if(H<=0) printf("Yes");
  
  else printf("No");

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int n,d;
int a[12][12];
int main()
{
    scanf("%d%d",&n,&d);
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=d; j++)
        {
            scanf("%d",&a[i][j]);
        }
    }
    int ans=0;
    for(int k=1; k<n; k++)
    {
        for(int i=k+1; i<=n; i++)
        {
            int x=0;
            for(int j=1; j<=d; j++)
            {
                x+=pow(a[k][j]-a[i][j],2);
            }
            int t=sqrt(x);
            if(t*t==x)
                ans++;
        }
    }

    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a,b;
    cin >> a >> b;
    ll ans = a-(2*b);
    if (0 >= ans)ans = 0;
    cout << ans << endl;
    
    
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int n;
int t[15][15];

void rec(int y,int x,int cnt){

  t[y][x]=cnt;
    if(cnt==n*n)return;
  /*
  cout<<y<<" "<<x<<endl;
  for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	cout<<t[i][j]<<" ";
      }
      cout<<endl;
    }
  */


  int ny=(y+1)%n,nx=(x+1)%n;
  while(t[ny][nx]!=0){
    ny++;
    nx--;
    if(ny==n){
      ny=0;
    }
    if(nx<0){
      nx+=n;
    }
  }
  rec(ny,nx,cnt+1);
}
int main(){
  while(cin>>n){
    if(n==0)break;

    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	t[i][j]=0;
    
    rec(n/2+1,n/2,1);

    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	//cout<<t[i][j]<<" ";
	//if(j)cout<<' ';
	printf("%4d",t[i][j]);

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

Measured memory_bytes: 1192
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

int main()
{
	int a[3];
	for (int i = 0;i < 3;i++) scanf("%d",&a[i]);
	sort(a,a+3);
	int ans = 0;
	for (int i = 1;i < 3;i++)
	{
		ans += a[i] - a[i-1];
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
# from sys import exit
A, B = [int(n) for n in input().split()]


def calc_xor_2_N(N):
    if(N % 2 == 1):
        if (N // 2 + 1) % 2 == 0:
            return 1
        else:
            return 0
    else:
        return calc_xor_2_N(N-1) ^ N


print(calc_xor_2_N(A-1) ^ calc_xor_2_N(B))


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

ll esq[200005], dir[200005], val[200005];
ll tree[800005], lazy[800005];
vector<ii> adj[200005];

ll left(ll u){return (u << 1);}
ll right(ll u){return (u << 1) + 1;}

void push(ll u, ll L, ll R){
    if(lazy[u]) tree[u] += lazy[u];
    if(L != R){
        lazy[left(u)] += lazy[u];
        lazy[right(u)] += lazy[u];
    }
    lazy[u] = 0;
}

void update(ll u, ll L, ll R, ll i, ll j, ll x){
    push(u, L, R);
    if(R < i || L > j) return;
    if(L >= i and R <= j){
        lazy[u] += x;
        push(u, L, R);
        return;
    }
    ll mid = (L+R)/2;
    update(left(u), L, mid, i, j, x);
    update(right(u), mid+1, R, i, j, x);
    tree[u] = max(tree[left(u)], tree[right(u)]);
}

ll query(ll u, ll L, ll R, ll i, ll j){
    push(u, L, R);
    if(R < i || L > j) return -1e18;
    if(L >= i and R <= j) return tree[u];
    ll mid = (L+R)/2;
    ll r1 = query(left(u), L, mid, i, j);
    ll r2 = query(right(u), mid+1, R, i, j);
    return max(r1,r2);
}

int main(){
    ll n, m; cin >> n >> m;
    for(ll i = 0; i < m; i++){
        cin >> esq[i] >> dir[i] >> val[i];
        adj[dir[i]].push_back({esq[i], val[i]});
    }
    //update(1, 1, n, 1, n, -1e7);
    for(ll i = 1; i <= n; i++){
        ll x = query(1, 1, n, 1, n);
        //cout << i << " = " << x << endl;
        update(1, 1, n, i, i, x);
        //prllf("update %d %d %d %d %d %d\n", 1, 1, n, i, i, x);
        for(ii par : adj[i]){
            update(1, 1, n, par.first, i, par.second);
            //prllf("update %d %d %d %d %d %d\n", 1, 1, n, par.first, i, par.second);
        }
    }
    cout << max(0LL, query(1, 1, n, 1, n)) << endl;
    return 0;
}

Measured memory_bytes: 28416
# A - Task Scheduling Problem
a1,a2,a3=list(map(int,input().split()))
b=[]
b.append(abs(a1-a2))
b.append(abs(a2-a3))
b.append(abs(a1-a3))
m=max(b)
b.remove(m)
print(sum(b))




Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] num = new int[5];
		for (int i = 0; i < num.length; i++) {
			num[i] = scan.nextInt();
		}
		scan.close();

		for (int j = 0; j < num.length; j++) {
			if (num[j] == 0) {
				System.out.println(j + 1);
			}
		}
	}
}

Measured memory_bytes: 35756
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;

#define LL long long
#define DB double
#define MAXN 100
#define MOD 1000000007
#define Pr pair<int,int>
#define X first
#define Y second
#define INF 1000000000000000000
#define mem(x,v) memset(x,v,sizeof(x))

LL read(){
	LL x=0,F=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*F;
}

int add(int a,int b){return (a+b>=MOD)?a+b-MOD:a+b;}
int dec(int a,int b){return (a-b<0)?a-b+MOD:a-b;}
int mul(int a,int b){return (1LL*a*b)%MOD;}
int fst_pow(int a,int b){
	int res=1;
	while(b){
		if(b&1)res=mul(res,a);
		a=mul(a,a),b>>=1;
	}
	return res;
}

int n,m;
int sx,sy;
char s[MAXN+5][MAXN+5];
short dp[MAXN+5][MAXN+5][MAXN+5][MAXN+5],a[MAXN+5][MAXN+5],b[MAXN+5][MAXN+5];
void upd(short &x,short y){x=max(x,y);}

int main(){
	n=read(),m=read();
	for(int i=1;i<=n;i++){
		scanf("%s",s[i]+1);
		for(int j=1;j<=m;j++){
			if(s[i][j]=='E')sx=i,sy=j;
			a[i][j]=a[i][j-1]+(s[i][j]=='o');
			b[i][j]=b[i-1][j]+(s[i][j]=='o');
		}
	}
	int L=sy-1,U=sx-1,R=m-sy,D=n-sx;
	for(int u=0;u<=U;u++)
		for(int d=0;d<=D;d++)
			for(int l=0;l<=L;l++)
				for(int r=0;r<=R;r++){
					int pl=max(sy-l,r+1),pr=min(sy+r,m-l);
					upd(dp[u+1][d][l][r],dp[u][d][l][r]+((sx-u-1>=d+1&&pl<=pr)?a[sx-u-1][pr]-a[sx-u-1][pl-1]:0));
					upd(dp[u][d+1][l][r],dp[u][d][l][r]+((sx+d+1<=n-u&&pl<=pr)?a[sx+d+1][pr]-a[sx+d+1][pl-1]:0));
					pl=max(sx-u,d+1),pr=min(sx+d,n-u);
					upd(dp[u][d][l+1][r],dp[u][d][l][r]+((sy-l-1>=r+1&&pl<=pr)?b[pr][sy-l-1]-b[pl-1][sy-l-1]:0));
					upd(dp[u][d][l][r+1],dp[u][d][l][r]+((sy+r+1<=m-l&&pl<=pr)?b[pr][sy+r+1]-b[pl-1][sy+r+1]:0));
				}
	printf("%d\n",dp[U][D][L][R]);
}

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

int main(){
  int N,ans=0;
  cin>>N;
  vector<int> ar(N);
  for(int i=0;i<N;i++){
    cin>>ar[i];
  }
  
  
  int jibunh=0,flg=1;
  for(int i=0;i<N;i++){
    jibunh=ar[i];
    flg=1;
          for(int j=0;j<i;j++){
                  if (jibunh<ar[j]){
                    flg=0;
                    break;
                  }
          }
    ans+=flg;
  }
  
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  ll a,b,x;
  cin>>a>>b>>x;
  ll ans = b/x+1;
  if(a>0)ans -= (a-1)/x+1;
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  int a,b;
  cin >> a>>b;
  int N;
  cin >> N;
  vector<int> c;
  for(int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    for(int j = 0; j < tmp; j++){
      c.push_back(i+1);
    }
  }
  vector<vector<int>> v(a);
  int height = 0;
  for(int i = 0; i < a*b; i++){
    if(i % b < b -1){
      v.at(height).push_back(c[i]);
    } else { 
      v.at(height).push_back(c[i]);
      height++;
    }
  }
  
  for(int i = 0; i < a; i++){
    if(i % 2 == 0){
      for(int j = 0; j < v.at(i).size(); j++){
        if(j == v.at(i).size()-1){
          cout << v.at(i).at(j) << endl;
        } else {
          cout << v.at(i).at(j) << " ";
        }
      }
    } else {
      reverse(v.at(i).begin(), v.at(i).end());
      for(int j = 0; j < v.at(i).size(); j++){
        if(j == v.at(i).size()-1){
          cout << v.at(i).at(j) << endl;
        } else {
          cout << v.at(i).at(j) << " ";
        }
      }
    } 
  }
}

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

typedef long long ll;

int main(){
	int Q;
	scanf("%d",&Q);
	for(;Q>0;Q--){
		ll A,B,C,D;
		scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
		
		string ret = "";
		if(A == B){
			for(int i = C ; i <= D ; i ++){
				if(i&1)ret += "A";
				else ret += "B";
			}
		}
		else {
			ll d,x;
			if(A > B){
				d = (A+B)/(B+1);
				if(A > B*d){
					for(int i = C ; i <= D ; i ++){
						if(i%(d+1))ret += "A";
						else ret += "B";
					}
					goto out;
				}
			}
			else {
				d = (A+B)/(A+1);
				if(d*A <= B){
					for(int i = C ; i <= D ; i ++){
						if((A+B-i+1)%(d+1))ret += "B";
						else ret += "A";
					}
					goto out;
				}
			}
			x = (d*A-B)/(d*d-1);
			ll y = (B-x)/d;
			for(int i = C ; i <= D ; i ++){
				if(i <= x*(d+1)){
					if(i%(d+1))ret += "A";
					else ret += "B";
				}
				else if(A+B-i+1 <= y*(d+1)){
					if((A+B-i+1)%(d+1))ret += "B";
					else ret += "A";
				}
				else {
					if(i-x*(d+1) <= A-d*x-y)ret += "A";
					else ret += "B";
				}
			}
		}
		out:;
		cout << ret << endl;
	}
}



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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

int v[MAXN];

void solve(){
	int n, a, b;
	cin >> n >> a >> b;
	REP(i, 0, n) {
		cin >> v[i];
	}
	int ans = abs(v[n - 1] - b);
	if (n > 1) {
		int tmp = abs(v[n - 1] - v[n - 2]);
		ans = max(ans, tmp);
	}
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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;

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  rep(i,N) cin >> H.at(i);
  sort(H.begin(), H.end());
  K = min(N,K);
  ll ans = 0;
  rep(i,K){
    H.pop_back();
  }
  rep(i,H.size()) ans += H.at(i);
  cout << ans << endl;
  return 0;
}


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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;
using namespace std;

ll N;
string s,t;

bool f(ll &lx, ll &ux, char inc, char dec, ll W, ll x) {
  char none = 'x';
  string ss, tt;
  ss = s;
  tt = t;
  rep(i,0,ss.size()) {
    if (ss[i] != inc && ss[i] != dec)
      ss[i] = none;
    if (tt[i] != inc && tt[i] != dec)
      tt[i] = none;
  }
  for (int i=N-1; i>=0; i--) {
    if (t[i] == dec) ux = min(ux+(ll)1, W);
    if (t[i] == inc) lx = max(lx-(ll)1, (ll)1);

    if (s[i] == dec) lx++;
    if (s[i] == inc) ux--;

    if (lx > ux)
      return false;

    lx = max(lx, (ll)1);
    ux = min(ux, W);
  }

  if (x < lx || x > ux)
    return false;

  return true;
}

signed main() {
  ll H, W, y, x;
  cin>>H>>W>>N>>y>>x>>s>>t;

  ll lx = 1, ux = W; // 駒が残るための範囲
  ll ly = 1, uy = H;
  bool ok1 = f(lx, ux, 'R', 'L', W, x);
  bool ok2 = f(ly, uy, 'D', 'U', H, y);

  if (!ok1 || !ok2)
    cout<<"NO"<<endl;
  else
    cout<<"YES"<<endl;

  //cout<<lx<<"-"<<ux<<endl;
  //cout<<ly<<"-"<<uy<<endl;
  return 0;
}


Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (int)(n); i++)
 
int main() {
    string s,t;
    cin>>s>>t;
    if ((t.size()==s.size()+1) and (t.substr(0,t.size()-1)==s)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3560
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

long long quickpow(long long b, int e)
{
	return e ? ((e & 1 ? b : 1)*quickpow(((b%MOD)*(b%MOD)) % MOD, e >> 1)) % MOD : 1;
}

long long fun(long long x)
{
	long long ret = 1;

	for (long long i = x; i > 0; i--) {
		ret *= i;
		ret %= MOD;
	}
	return ret;
}

long long gun(long long x, long long y)
{
	long long ret = 1;
	for (long long i = x; i > x - y; i--) {
		ret *= i;
		ret %= MOD;
	}
	return ret;
}

long long n, a, b, ans;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> a >> b;
	ans = quickpow(2, n);
	ans--;
	if (ans < 0) ans += MOD;
	ans -= (gun(n, a) * quickpow(fun(a), MOD - 2)) % MOD;
	if (ans < 0) ans += MOD;
	ans -= (gun(n, b) * quickpow(fun(b), MOD - 2)) % MOD;
	if (ans < 0) ans += MOD;
	cout << ans << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int n,a,b,ans=0;
int x[200000];
signed main(){
    cin>>n>>a>>b;
    rep(i,n)cin>>x[i];
    rep(i,n-1){
        int d=x[i+1]-x[i];
        int p=min(a*d,b);
        ans+=p;
    }
    cout<<ans<<endl;
    return 0;
}



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

int main(){
  int n;
  cin >> n;
  vector<int> num(100000);
  int a;
  for(int i=0;i<n;i++){
    cin >> a;
    num[a-1]++;
  }
  int ans=0,amari=0;
  for(int i=0;i<100000;i++){
    if(num[i]){
      ans++;
      amari+=num[i]-1;
    }
  }
  cout << ((amari%2)?ans-1:ans) << endl;
  return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	ll x, y, z, k;

	cin>>x>>y>>z>>k;

	vll a(x), b(y), c(z), ab(x*y);

	rep(i, x) cin>>a[i];

	rep(i, y) cin>>b[i];

	rep(i, z) cin>>c[i];

	rep(i, x){
		rep(j, y){
			ab[i*y+j]=a[i]+b[j];
		}
	}
	sort(all(ab)); reverse(all(ab));

	ll num=min(k, x*y);
	vll sum(num*z);

	rep(i, num){
		rep(j, z){
			sum[i*z+j]=ab[i]+c[j];
		}
	}

	sort(all(sum)); reverse(all(sum));

	rep(i, k) cout<<sum[i]<<endl;
}


Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
int n,a[1000005],p,vis[3];
char s[1000005];
int main()
{
    cin>>n;scanf("%s",s+1);
	for(int i=1;i<n;i++)a[i]=abs(s[i]-s[i+1]),vis[a[i]]=1;
	if(!vis[1])for(int i=1;i<n;i++) a[i]/=2;
	else for(int i=1;i<n;i++)a[i]%=2;int S=n-2;
	for(int i=0;i<n-1;i++)if((S&i)==i)p+=a[i+1];
	int op=p%2;if(!vis[1])if(op)op=2;cout<<op<<"\n";
	return 0;
}


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

int main() {
    long long ans = 0;
    int N, M;
    cin >> N >> M;
    multiset<long long> A;
    for(size_t i = 0; i < N; i++) {
        long long a;
        cin >> a;
        A.insert(a);
    }
    for(int i = 0; i < M; i++) {
        auto itr = A.end();
        itr--;
        long long a = *itr;
        A.erase(itr);
        A.insert(a / 2);
    }
    // ans = accumulate(A.begin(), A.end(), 0);
    for(long long a : A) {
        // cout << a << " ";
        ans += a;
    }
    // cout << endl;
    cout << ans << endl;
}

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

using namespace std;

int n, m;
vector<vector<int>> graph;
vector<bool> check;
int visitcount;
int result;

void visit(int i)
{
	if (check[i]) return;
	check[i] = true;
	visitcount++;
	if (visitcount == n) result++;
	else for (auto&& ii : graph[i]) visit(ii);
	visitcount--;
	check[i] = false;
}

int main()
{
	cin >> n >> m;
	graph = vector<vector<int>>(n);
	check = vector<bool>(n, false);
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		a--; b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	visit(0);
	cout << result << endl;
	return 0;
}


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

int main(){
  int N,Y,a=-1,b=-1,c=-1;
  cin >> N >> Y;
  Y /= 1000;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N;j++){
      if(Y==10*i+5*j+(N-i-j)&& 0<=N-i-j){
        a = i;
        b = j;
        c = N-i-j;
      }
    }
  }
    cout << a <<' '<< b <<' '<< c << endl;
}


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

int main() {
	int K, S;
	cin >> K >> S;
	int res = 0;
	for (int i = 0; i <= K; i++) {
		for (int j = 0; j <= K; j++) {
			if (S-i-j >= 0 && S-i-j <= K) res++;
		}
	}
	cout << res << endl;
	return 0;
}

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

class Dice{
private:
  int d[6];

public:
  void input();
  void rotation(char c);
  void output();
};

int main(){
  Dice dice;
  string s;

  dice.input();
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    dice.rotation(s[i]);
  }
  dice.output();
}

void Dice::input(){
  for(int i = 0; i < 6; i++){
    cin >> d[i];
  }
}

void Dice::rotation(char c){
  int tmp;
  if(c == 'N'){
    tmp = d[0]; d[0] = d[1]; d[1] = d[5]; d[5] = d[4]; d[4] = tmp;
  }else if(c == 'S'){
    tmp = d[0]; d[0] = d[4]; d[4] = d[5]; d[5] = d[1]; d[1] = tmp;
  }else if(c == 'W'){
    tmp = d[0]; d[0] = d[2]; d[2] = d[5]; d[5] = d[3]; d[3] = tmp;
  }else if(c == 'E'){
    tmp = d[0]; d[0] = d[3]; d[3] = d[5]; d[5] = d[2]; d[2] = tmp;
  }
}

void Dice::output(){
  cout << d[0] << endl;
}

Measured memory_bytes: 3204
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static int n;
    static int[] val, par, rank, min, num;
    static boolean[] use;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        int m = sc.nextInt();
        val = new int[n];
        par = new int[n];
        rank = new int[n];
        min = new int[n];
        use = new boolean[n];
        num = new int[n];
        long ans = 0;
        int ntree = 0;
        int none = 0;
        int neda = 0;

        for(int i=0; i<n; i++){
            val[i] = sc.nextInt();
            par[i] = i;
            rank[i] = 0;
            min[i] = i;
            use[i] = false;
            num[i] = 1;
        }

        for(int i=0; i<m; i++){
            int mx = sc.nextInt();
            int my = sc.nextInt();
            unite(mx, my);
        }

        for(int i=0; i<n; i++){
            find(i);
        }

        for(int i=0; i<n; i++){
            if(val[i] < val[min[find(i)]]) min[find(i)] = i;
        }

        for(int i=0; i<n; i++){
            if(find(i) == i){
                ans += val[min[i]];
                use[min[i]] = true;
                ntree++;
                if(num[i] == 1){
                    none++;
                }else if(num[i] > 2){
                    neda += num[i] - 2;
                }
            }
        }

        if(none - 2 > neda){
            System.out.println("Impossible");
            return;
        }

        if(ntree == 1){
            System.out.println(0);
            return;
        }

        int[] rem = new int[n - ntree];
        int c = 0;
        for(int i=0; i<n; i++){
            if(!use[i]){
                rem[c] = val[i];
                c++;
            }
        }

        Arrays.sort(rem);

        for(int i=0; i<ntree-2; i++){
            ans += rem[i];
        }

        System.out.println(ans);
    }

    public static int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }

    public static void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;

        if(rank[x] < rank[y]){
            par[x] = y;
            num[find(y)] += num[x];
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
            num[find(x)] += num[y];        
        }        
    }

    public static boolean same(int x, int y){
        return find(x) == find(y);
    }
}

Measured memory_bytes: 96316
package main

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

var sc *bufio.Scanner

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

func intAbs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt()

	aArray := make([]int, n)
	for i := range aArray {
		aArray[i] = nextInt()
	}

	ans1 := 0
	sort.Sort(sort.IntSlice(aArray))
	aSlice := aArray[:]
	aLeft, aRight := aSlice[0], aSlice[0]
	aSlice = aSlice[1:]
	for {
		if len(aSlice) == 0 {
			break
		}
		ans1 += intAbs(aLeft - aSlice[len(aSlice)-1])
		aLeft = aSlice[len(aSlice)-1]
		aSlice = aSlice[:len(aSlice)-1]
		if len(aSlice) == 0 {
			break
		}
		ans1 += intAbs(aRight - aSlice[len(aSlice)-1])
		aRight = aSlice[len(aSlice)-1]
		aSlice = aSlice[:len(aSlice)-1]

		if len(aSlice) == 0 {
			break
		}
		ans1 += intAbs(aLeft - aSlice[0])
		aLeft = aSlice[0]
		aSlice = aSlice[1:]
		if len(aSlice) == 0 {
			break
		}
		ans1 += intAbs(aRight - aSlice[0])
		aRight = aSlice[0]
		aSlice = aSlice[1:]
	}

	ans2 := 0
	sort.Sort(sort.Reverse(sort.IntSlice(aArray)))
	aSlice = aArray[:]
	aLeft, aRight = aSlice[0], aSlice[0]
	aSlice = aSlice[1:]
	for {
		if len(aSlice) == 0 {
			break
		}
		ans2 += intAbs(aLeft - aSlice[len(aSlice)-1])
		aLeft = aSlice[len(aSlice)-1]
		aSlice = aSlice[:len(aSlice)-1]
		if len(aSlice) == 0 {
			break
		}
		ans2 += intAbs(aRight - aSlice[len(aSlice)-1])
		aRight = aSlice[len(aSlice)-1]
		aSlice = aSlice[:len(aSlice)-1]

		if len(aSlice) == 0 {
			break
		}
		ans2 += intAbs(aLeft - aSlice[0])
		aLeft = aSlice[0]
		aSlice = aSlice[1:]
		if len(aSlice) == 0 {
			break
		}
		ans2 += intAbs(aRight - aSlice[0])
		aRight = aSlice[0]
		aSlice = aSlice[1:]
	}

	switch {
	case ans1 > ans2:
		fmt.Println(ans1)
	default:
		fmt.Println(ans2)
	}
}


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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N, A, B;
    cin >> N >> A >> B;
    const auto& modpow = [](unsigned long a, unsigned long b = 1, unsigned long n = 1000000005) -> unsigned long {
        unsigned long r{b % MOD};
        a %= MOD;
        while(n){
            if(n & 1)(r *= a) %= MOD;
            (a *= a) %= MOD;
            n >>= 1;
        }
        return r;
    };
    const auto& comb = [&modpow](unsigned long a, unsigned long b) -> unsigned long {
        unsigned long d{1}, n{1};
        for(unsigned long i{0}; i < b; ++i){
            (n *= i + 1) %= MOD;
            (d *= a - i) %= MOD;
        }
        return modpow(n, MOD - d);
    };
    cout << (modpow(2, 1, N) - 1 + comb(N, A) + comb(N, B)) % MOD << endl;
    return 0;
}

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

using namespace std;

int main(void) {
    int A, B;
    int res = 0;
    cin >> A >> B;
    for (int i = 0; i < 2; i++) {
        if (A >= B) {
            res += A;
            A--;
        } else {
            res += B;
            B--;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define MAX 2000200
#define MIN -2000000300
typedef long ll;

int pindex;
ll Array[MAX];

int getParent(int i){
  return i/2;
}

int getLeft(int i){
  return 2*i;
}

int getRight(int i){
    return 2*i+1;
}


int heapIncreaseKey(int i,ll key){
  ll h;
  if(key < Array[i])return -1;
  Array[i] = key;
  while(i > 1 && Array[getParent(i)] < Array[i]){
    h = Array[i];
    Array[i] = Array[getParent(i)];
    Array[getParent(i)] = h;
    i = getParent(i);
  }
}

void maxHeapify(int i){
  ll l = getLeft(i);
  ll r = getRight(i);
  ll largest;
  ll h;
  if(l <= pindex && Array[l] > Array[i])largest=l;
  else largest=i;
  if(r<=pindex && Array[r] > Array[largest])largest = r;
  if(largest != i){
    h = Array[i];
    Array[i] = Array[largest];
    Array[largest] = h;
    maxHeapify(largest);
  } 
}


void Insert(ll key){ //maxHeapInsert
  ++pindex;
  Array[pindex] = MIN;
  heapIncreaseKey(pindex,key);
}

ll heapExtractMax(){
  ll max;
  if(pindex < 1)return -1;
  max = Array[1];
  Array[1] = Array[pindex];
  pindex--;
  maxHeapify(1);
  return max;
}




int main(){
  char op[1000];
  ll val;

  while(1){
    scanf("%s",op);
    if(strcmp(op,"insert") == 0){
      scanf("%ld",&val);
      Insert(val);
    }
    else if(strcmp(op,"extract") == 0){
      printf("%ld\n",heapExtractMax());
    }
    else if(strcmp(op,"end") == 0)break;
  }

  return 0;
}

Measured memory_bytes: 4336
import sys
from collections import Counter

input = sys.stdin.readline


def main():
    N = int(input())
    S = [None] * N
    for i in range(N):
        S[i] = input().rstrip()

    c = Counter(S)
    ans = len(c.keys())
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38712
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        s: Chars
    };
    match s
        .iter()
        .position(|&s_i| s_i == 'C')
        .and_then(|i_c| s.iter().skip(i_c + 1).position(|&s_i| s_i == 'F'))
    {
        None => println!("No"),
        Some(_) => println!("Yes"),
    };
}


Measured memory_bytes: 2108
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as B
main=print.solve.map(map(fst.fromJust.B.readInt).B.words).B.lines=<<B.getContents
solve([n]:xls)=fst.foldr f (0,maxBound).sortOn(uncurry(-))$map(\[x,l]->(x,l))xls
f(x,l)(i,p)=if x+l>p then (i,p) else (i+1,x-l)

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

int main(){
  int n;
  cin >> n;
  vector<int> p(n),q(n),v1(n),v2(n);
  for(int i = 0; i < n; i++){
    cin >> p.at(i);
    v1.at(i) = i+1;
    v2.at(i) = i+1;
  }
  for(int i = 0; i < n; i++){
    cin  >> q.at(i);
  }
  int pc=0,qc=0;
  sort(v1.begin(),v1.end());
  sort(v2.begin(),v2.end());
  do{
    if(v1!=p)pc++;
    else break;
  }while(next_permutation(v1.begin(),v1.end()));
  do{
    if(v2!=q)qc++;
    else break;
  }while(next_permutation(v2.begin(),v2.end()));
  int result = abs(pc-qc);
  cout << result << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
	double a, b, c, d;
	
	while (scanf("%lf %lf %lf %lf", &a, &b, &c, &d) && b >= -0.5){
		if (b > 180) b = b - 360;
		if (d > 180) d = d - 360;
		
		a = a * M_PI / 180;
		c = c * M_PI / 180; 
		printf("%d\n", (int)round(6378.1 * acos(sin(a) * sin(c) + cos(a) * cos(c) * cos((d - b) * M_PI / 180))));
	}
	return (0);
}

Measured memory_bytes: 1128
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	private boolean c(int[] a, int[] b, int D) {
		double dist = 0;

		for (int i = 0; i < D; i++) {
			dist += (a[i] - b[i]) * (a[i] - b[i]);
		}

		dist = Math.sqrt(dist);
		if (dist == (int) dist) {
			return true;
		} else {
			return false;
		}
	}

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int D = sc.nextInt();
		int[][] X = new int[N][];
		for (int i = 0; i < N; i++) {
			X[i] = nextIntArray(sc, D);
		}

		sc.close();

		int ans = 0;
		for (int i = 0; i < N - 1; i++) {
			for (int j = i + 1; j < N; j++) {
				if (c(X[i], X[j], D)) {
					ans++;
				}
			}
		}
		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 22612
#include <iostream>
#include <queue>

using namespace std;

const int MaxN = 1e5;
const int MaxM = 2e5;
int parent[MaxN];

int n, m;
vector <int> edges[MaxN];

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

    for (int i = 1; i <= m; ++i)
    {
        int x, y;
        cin >> x >> y;
        --x, --y;

        edges[x].push_back(y);
        edges[y].push_back(x);
    }

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

    int found = 0;
    queue<int> q;
    q.push(0);
    parent[0] = 0;
    
    while(!q.empty())
    {
        int x = q.front();
        q.pop();
        for (int to : edges[x])
        {
            if (parent[to] == -1)
            {
                parent[to] = x;
                q.push(to);
            }
        }
        ++found;
    }

    if (found != n)
    {
        cout << "No\n";
    }
    else
    {
        cout << "Yes\n";
        for (int i = 1; i < n; ++i)
        {
            cout << parent[i] + 1 << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 10388
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;
	getline(cin, s);
	for (int i = 0; i < s.length(); i++)
	{
		if(65 <= s[i] && s[i] <= 90)
			s[i] += 32;
		else if (97 <= s[i] && s[i] <= 122)
			s[i] -= 32;
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    rep(i, b){
        if (a * i % b == c) {
            YES;
            return 0;
        }
    }
    NO;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, l, r) for(int i = (l); i <= (r); i++)
#define per(i, r, l) for(int i = (r); i >= (l); i--)
#define mem(a, b) memset(a, b, sizeof a)

using namespace std;
const int N = 2e5 + 5, MI = 1e6;
int read() {
	static streambuf* in = cin.rdbuf();
	#define gc (p1 == p2 && (p2 = (p1 = buf) + in -> sgetn(buf, MI), p1 == p2) ? -1 : *p1++)
	static char buf[MI], *p1, *p2;
	int c = gc, r = 0;
	while(c < 48) c = gc;
	while(c > 47) r = (r << 3) + (r << 1) + (c & 15), c = gc;
	return r;
}
int n, h, mxh; long long ans;
int main() {
	#ifdef local
		freopen("in.txt", "r", stdin);
	#endif
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n >> mxh;
	while(--n) mxh = max(mxh, h = read()), ans += mxh - h;	
	return !(cout << ans);
}

Measured memory_bytes: 4556
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  int k;
  vi a(3);
  cin >> a[0] >> a[1] >> a[2] >> k;
  sort(ALL(a));
  int ans=a[0]+a[1]+a[2]*pow(2,k);
  cout << ans << endl;
  return 0;
}


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

int main() {
    int a, b, c, x;
    cin >> a >> b >> c >> x;

    int ans = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                if (500*i + 100*j + 50*k == x)
                    ans ++;
            }
            
        } 
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n):
  if l[i] == i + 1 and i == n-1:
    ans += 1
  if l[i] == i + 1 and not i == n-1:
    l[i], l[i+1] = l[i+1], l[i]
    ans += 1
print(ans)

Measured memory_bytes: 13880
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    x = kwargs["x"]
    k = kwargs["k"]
    d = kwargs["d"]
    if k * d <= abs(x):
        res = abs(x) - k * d
    else:
        res = abs(abs(x) % d - (k - abs(x) // d) % 2 * d)

    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    kwargs["x"], kwargs["k"], kwargs["d"] = [int(i) for i in cin]

    cout = main(kwargs)
    print(cout)

Measured memory_bytes: 30940
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
long long n,x,ans,a[200005],c[200005], d[200005];
map<long long, long long> b;
long long pd(long long x) {
    for (int i = 1; i <= n; ++i) {
        a[i] = 0;
    }
    b.clear();
    a[0]=n;
    b[n]=1;
    ans = 0;
    for (int i=1; i<=n; i++)
    {
        if (c[i]>=x)a[i]=a[i-1]+1;
        else a[i]=a[i-1]-1;
    }
    long long t = 0;
    for (int i=1; i<=n; i++)
    {
        if (a[i]>a[i-1])t-=b[a[i]];
        else t+=b[a[i-1]];
        b[a[i]]++;
        ans+=t;
    }
    return n * (n + 1) / 2 - ans;
}

int main()
{
    scanf("%lld", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%lld", &c[i]);
        d[i] = c[i];
    }
    sort(d + 1, d + 1 + n);
    int l = 1, r = n, rs = n;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (pd(d[mid]) >= (n * (n + 1) / 2 - 1) / 2) {
            rs = mid;
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }
    printf("%lld", d[rs]);
    return 0;
}

Measured memory_bytes: 10240
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
using namespace std;

int INF = 1e9 + 7;

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

    if (X == 3 || X == 5 || X == 7)cout << "YES"<<endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	p := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
	}
	sort.Ints(p)

	p[n-1] = p[n-1] / 2
	r := 0
	for i := 0; i < n; i++ {
		r += p[i]
	}
	fmt.Println(r)
}

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

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

using namespace std;

int n;
int t[100001];
int x[100001];
int y[100001];

int main(){
    cin >> n;
    for(int i = 1; i <= n; ++i){
        cin >> t[i] >> x[i] >> y[i];
    }

    rep(i, n){
        int dt = t[i + 1] - t[i];
        int dx = x[i + 1] - x[i];
        int dy = y[i + 1] - y[i];
        int dd = abs(dx) + abs(dy);
        if (!(dt >= dd && (dt - dd) % 2 == 0)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int MOD=1e9+7;

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

  string s;cin>>s;
  //0:w.1:e.2:s,3:
  int memo[4]={};
  for(int i=0;i<(int)s.length();i++){
      if(s[i]=='W') memo[0]++;
      if(s[i]=='E') memo[1]++;
      if(s[i]=='S') memo[2]++;
      if(s[i]=='N') memo[3]++;
  }
  bool flag=true;
  if(memo[0]*memo[1]==0&&memo[0]+memo[1]!=0) flag=false;
  if(memo[2]*memo[3]==0&&memo[2]+memo[3]!=0) flag=false; 
  if(flag){
      cout<<"Yes"<<endl;
      return 0;
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256