akhauriyash/Code-Regression huggingface dataset:
function main()
  
  N = parse(Int,readline())
  K = parse(Int,readline())
  x = map(x -> parse(Int,x), split(readline()))
  
  ans = 0
  
  for i in 1:N
    
    ans += min(2x[i],2abs(K-x[i]))

  end
  
  println(ans)
  
end

main()

Measured memory_bytes: 111104
//Think simple yet elegant.
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll  long long
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
const ll maxn=2e5+10;
const ll mod=1e9+7;
 
int main() {
  	fast;
  	int s,w;
  	cin>>s>>w;
  	if(w>=s)
  		cout<<"unsafe";
  	else
  		cout<<"safe";
}
  	


Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

const int K_MAX = 5005;

int N, K;
vector<int> A;
vector<bitset<K_MAX>> prefix, suffix;

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

    cin >> N >> K;
    A.resize(N);

    for (int &a : A)
        cin >> a;

    prefix.assign(N + 1, {});
    suffix.assign(N + 1, {});
    prefix[0][0] = suffix[N][0] = 1;

    for (int i = 0; i < N; i++)
        prefix[i + 1] = prefix[i] | prefix[i] << A[i];

    for (int i = N - 1; i >= 0; i--)
        suffix[i] = suffix[i + 1] | suffix[i + 1] << A[i];

    bitset<K_MAX> low_bitset;
    int unnecessary = 0;

    for (int i = 0; i < N; i++) {
        bool necessary = false;
        vector<int> prefix_sums(K + 1, 0);

        for (int k = 0; k < K; k++)
            prefix_sums[k + 1] = prefix_sums[k] + prefix[i][k];

        for (int right = 0; right < K; right++)
            if (suffix[i + 1][right] && prefix_sums[K - right] - prefix_sums[max(K - right - A[i], 0)] > 0) {
                necessary = true;
                break;
            }

        if (!necessary)
            unnecessary++;
    }

    cout << unnecessary << '\n';
}


Measured memory_bytes: 6528
import itertools
n,m,q=[int(i) for i in input().split()]
l=[[int(i) for i in input().split()]for i in range(q)]
a=itertools.combinations_with_replacement(range(1,m+1), n)
print(max([sum([i[3] for i in l if j[i[0]-1]+i[2]==j[i[1]-1]])for j in a]))

Measured memory_bytes: 12628
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    
    for (int i=1; i<10; i++){
      for (int j=1; j<10; j++){
        if (i*j == n) {
          System.out.println("Yes");
          return;
        }
      }
    }
    System.out.println("No");
  }
}


Measured memory_bytes: 22484
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main (){
	while(1){
	int N,M;
	cin>>N>>M;
	if(N==0 && M==0){
		break;
	}
	int ans=0;
	int a[M+5],b[M+5];
	int dat[550]={};
	dat[1]=1;
	for(int i=0;i<M;i++){
		cin>>a[i]>>b[i];
		if(dat[a[i]]==1){
			if(dat[b[i]]==0){
				dat[b[i]]=2;
				ans++;
			}
		}
		if(dat[b[i]]==1){
			if(dat[a[i]]==0){
				dat[a[i]]=2;
				ans++;
			}
		}
	}
	for(int i=0;i<M;i++){
		if(dat[a[i]]==2){
			if(dat[b[i]]==0){
				dat[b[i]]=3;
				ans++;
			}
		}
		if(dat[b[i]]==2){
			if(dat[a[i]]==0){
				dat[a[i]]=3;
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	}
	return 0;
}

	

Measured memory_bytes: 1240
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		ArrayList<Integer> listA = new ArrayList<>();
		ArrayList<Integer> listB = new ArrayList<>();
		
		for(int i=0;i<N;i++) {
			listA.add(sc.nextInt());
		}
		for(int i=0;i<N;i++) {
			listB.add(sc.nextInt());
		}
		int countA=1;
		int countB=1;
		for(int i=0;i<N;i++) {
			countA+=(countorder(listA.get(0),listA)-1)*factor(N-i-1);
			listA.remove(0);
		}
		for(int i=0;i<N;i++) {
			countB+=(countorder(listB.get(0),listB)-1)*factor(N-i-1);
			listB.remove(0);
		}
		System.out.println(Math.abs(countA-countB));
	}
	
	
	static int factor(int n) {
		if(n==0) {
			return 1;
		}else {
			return n*factor(n-1);
		}
	}
	
	static int countorder(int a,ArrayList<Integer> list) {
		int count=1;
		for(int i=0;i<list.size();i++) {
			if(list.get(i)<a) {
				count++;
			}
		}
		return count;
	}
}

Measured memory_bytes: 21076
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

template<typename T>
T gcd(T a, T b) {
	if( a < b ) swap(a, b);
	if( b == 0 ) return a;
	
	T r;
	while( r = a % b ) {
		a = b;
		b = r;
	}

	return b;	
}

int main(void) {
	int n, X;
	cin >> n >> X;
	
	vector<int> diff(n);
	for(int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		diff[i] = abs(X - a);
	}
	
	int ans = diff[0];
	for(int i = 1; i < n; ++i) {
		ans = gcd(ans, diff[i]);
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {

    string s; cin >> s;
    for( int i = 0 ; i < s.size() ; ++i ){
        if( s[i] == 'C' ){
            for( int j = i+1 ; j < s.size() ; ++j ){
                if( s[j] == 'F' ){
                    cout << "Yes\n";
                    return 0;
                }
            }
        }
    }
    cout << "No\n";
}


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

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

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


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

  map<int,int> mp;

  int cnt=0;
  REP(i,N){
    int a;
    cin >> a;
    if(a/400 < 8){
      mp[a/400]++; 
    }else{
      cnt++;
    }
  }

  cout << max(1,(int)mp.size()) << " " << mp.size()+cnt << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>

using namespace std; 

int main(void) {
	int u,noe,nov;
	cin >> nov;
	vector< vector< pair<int,int> > > el(nov);
	for (int i = 0; i < nov; ++i) {
		cin >> u >> noe;
		el[u] = vector< pair<int,int> >(noe);
		for (int j = 0; j < noe; ++j) {
			cin >> el[u][j].first;
			cin >> el[u][j].second;
		}
	}

	vector<int> res(nov,(1 << 28));
	res[0] = 0;
	pair<int,int> now,next;
	priority_queue< pair<int,int> > q;
	q.push({0,0});
	while (!q.empty()) {
		now = q.top();
		q.pop();
		for (int i = 0; i < el[now.second].size(); ++i) {
			next = el[now.second][i];
			if (res[next.first] > now.first+next.second) {
				res[next.first] = now.first+next.second;
				q.push({res[next.first],next.first});
			}
		}
	}

	for (int i = 0; i < nov; ++i) {
		cout << i << " ";
		cout << res[i] << endl;
	}

	return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

struct Point
{
  i64 a, b, c, d;
};

i64 N, M, Q;
vector<Point> t;

i64 dfs(i64 s, i64 b, vector<i64> now)
{
  i64 ret = 0;
  if (s == N)
  {
    for (i64 i = 0; i < Q; i++)
      if (now[t[i].b] - now[t[i].a] == t[i].c)
        ret += t[i].d;
    return ret;
  }
  now.push_back(0);
  for (i64 i = b; i <= M; i++)
  {
    now[s] = i;
    ret = max(ret, dfs(s + 1, i, now));
  }
  return ret;
}

int main()
{
  cin >> N >> M >> Q;
  t.resize(Q);
  for (i64 i = 0; i < Q; i++)
  {
    i64 a, b, c, d;
    cin >> a >> b >> c >> d;
    a--;
    b--;
    t[i] = {a, b, c, d};
  }
  cout << dfs(0, 1, vector<i64>()) << endl;
  return 0;
}


Measured memory_bytes: 3632
def next_math(n):
    turn60 = 0.5 + 3 ** 0.5 * 0.5j
    n_next = [n[0]]
    for i in range(1, len(n)):
        s = (n[i - 1] * 2 + n[i]) / 3
        t = (n[i - 1] + n[i] * 2) / 3
        u = (t - s) * turn60 + s
        n_next +=[s, u, t, n[i]]
    return n_next

p1 = 0 + 0j
p2 = 100 + 0j
math = [p1, p2]

n = int(input())
for i in range(n):
    math = next_math(math)

for z in math:
    print("{:.8f} {:.8f}".format(z.real, z.imag))


Measured memory_bytes: 5740
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;
typedef bitset<101> b100;

const int MOD = 998244353;

int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}

int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}

unordered_map<b100, int> dp[101];
unordered_map<b100, int> dp2[101];

b100 subbit(b100 &bit, int l, int r)
{
	b100 res; res.reset();
	for(int i=l;i<=r;i++)
	{
		res.set(i-l,bit[i]);
	}
	return res;
}

int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}

vi divi[111];
int solve1(b100 bit, int n);
int solve2(b100 bit, int n);

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	for(int i=1;i<=110;i++)
	{
		for(int j=i;j<=110;j+=i)
		{
			divi[j].pb(i);
		}
	}
	string s;
	cin>>s;
	int n=s.length();
	b100 B; B.reset();
	for(int i=0;i<n;i++)
	{
		B.set(i,s[i]-'0');
	}
	int ans = solve2(B,n);
	cout<<ans<<'\n';
}

int solve1(b100 bit, int n)
{
	if(n==0) return 0;
	if(dp[n].find(bit)!=dp[n].end()) return dp[n][bit];
	int ans = 0;
	if(n==1)
	{
		if(bit[0]) ans=2;
		else ans=1;
	}
	for(int d:divi[n])
	{
		if(d==1) continue;
		//divide into d parts, length n/d per part
		b100 z; z.set();
		for(int i=0;i<n;i+=n/d)
		{
			b100 tmp = subbit(bit, i, i + n/d - 1);
			z&=tmp;
		}
		ans = add(ans, solve2(z,n/d));
	}
	//cerr<<"SOLVE 1 : "<<bit.to_string()<<' '<<n<<' '<<ans<<'\n';
	return (dp[n][bit]=ans);
}

int solve2(b100 bit, int n)
{
	if(dp2[n].find(bit)!=dp2[n].end()) return dp2[n][bit];
	int ans = 0;
	for(int mid=0;mid<=n-1;mid++)
	{
		//[0, mid], [mid+1,n-1]
		b100 B1 = subbit(bit,0,mid);
		b100 B2 = subbit(bit,mid+1,n-1);
		if(mid<n-1) ans = add(ans, mult(solve1(B1, mid+1), solve2(B2, n - (mid + 1))));
		else ans = add(ans, solve1(B1, n));
	}
	//cerr<<"SOLVE 2 : "<<bit.to_string()<<' '<<n<<' '<<ans<<'\n';
	return (dp2[n][bit]=ans);
}


Measured memory_bytes: 6400
//https://qiita.com/drken/items/ace3142967c4f01d42e9 の写経

#include <iostream>
using namespace std;

const int MAX_N = 110000;

int dp[MAX_N]; // dp[i] が i についての答え

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

    // 初期化
    for (int i = 0; i < MAX_N; ++i) dp[i] = N; // INF の気持ち
    dp[0] = 0;

    // 貰う DP --- dp[n] に遷移を集める
    for (int n = 1; n <= N; ++n) {
        for (int pow6 = 1; pow6 <= n; pow6 *= 6) {
            dp[n] = min(dp[n], dp[n - pow6] + 1);
        }
        for (int pow9 = 1; pow9 <= n; pow9 *= 9) {
            dp[n] = min(dp[n], dp[n - pow9] + 1);
        }
    }

    cout << dp[N] << endl;
}

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

#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 rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll s;
  scanf("%lld",&s);
  ll ans=inf;
  while(s>=100) {
    ans=min(ans, abs(753-(s%1000)));
    s/=10;
  }
  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=10e9+7;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}

int main(void){
    ll a;
    string s;
    cin>>a>>s;
    if(a>=3200) cout<<s<<endl;
    else cout<<"red"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <list>
//#include <unordered_map>
//#include <unordered_set>
#include <iterator>
#include <cmath>
#include <string>

using namespace std;

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

#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define ins insert
#define iter ::iterator
#define upb upper_bound
#define lwb lower_bound
#define INF32 10e9
#define INF64 10e18

#define sz(v) v.size()
#define aloc(i, a, n) i *a = new i[n]
#define print(a) if(DEBUG) cout << a << endl;
#define print2(a,b) if(DEBUG) cout << a << ' ' << b << endl;
#define print3(a,b,c) if(DEBUG) cout << a << ' ' << b << ' ' << c << endl;
#define print4(a,b,c,d) if(DEBUG) cout << a << ' ' << b << ' ' << c << ' ' << d << endl;


#define for0(i,a) for(ll i = 0; i < a; i++)
#define fori(i,a,b) for(ll i = a; i < b; ++i)
#define rfor0(i,a) for(ll i = a; i >= 0; --i)
#define rfor(i,a,b) for(ll i = a; i >= b; --i)

#define DEBUG true
//##############################################################################

void solve(){
	int n;
	cin >> n;
	cout << (n/500) * 1000 + ((n%500)/5) * 5 << endl;
}

int main(){
	int Q = 1;
	//cin >> Q;
	for0(q,Q) solve();

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include<vector>
#include<iostream>
#include<set>
#include<map>
#include<algorithm>
using namespace std;


long long int divide(long long int h,long long w){
	if(h %2 == 0){
		return (h/2)*w;
	}
	if(w %2 == 0){
		return (w/2)*h;
	}
	
	long long int mi = min(h,w);
	long long int ma = max(h,w);
	return (ma/2)*mi;
	
}

long long int calcRes(long long int rect1,long long int rect2,long long int rect3){
	long long int ma = max(rect1,max(rect2,rect3));
	long long int mi = min(rect1,min(rect2,rect3));
	
	return ma - mi;
}

int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if(b-a == c-b) cout << "YES" <<endl;
	else cout << "NO" <<endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<climits>
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> 
#include<ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define f first
#define s second
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vi vector<int>
#define vll vector<ll>
#define endl '\n'
#define SIZE 1000002
#define w(t) int t;cin>>t;while(t--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define value_at_idx find_by_order
#define idx order_of_key
#define MOD 1000000007
#define inf INT_MAX
#define Maxheap(T) priority_queue<T>
#define Minheap(T) priority_queue<T,vector<T>,greater<T>>
#define mem(name,value) memset(name,value,sizeof(name))
#define pi 3.14159265358979323846
#define IOS ios::sync_with_stdio(0);cin.tie(0);
typedef long long int ll;
using namespace std;
using namespace __gnu_pbds;
const int p1 = 31;

int main() { IOS
   
    //Use long long
  	
  	ll n ;
  	cin>>n;
  	ll x = n%1000;
  	if(x == 0)
  		cout<<x;
  	else 
  	{
  		cout<< 1000 - x ;
  	}

    return 0;
  	
  	
   
            
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 200010;
const int MAXK = 110;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int a, b;
    cin >> a >> b;
    int now = 1, cnt = 0;;
    while (now < b) {
        now = now - 1 + a;
        cnt++;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int main(){
    int N, C; cin >> N >> C;
    vector<vector<int>> D(C, vector<int>(C));
    rep(i,C){
        rep(j,C){
            cin >> D[i][j];
        }
    }

    vector<vector<int>> c(N,vector<int>(N));
    rep(i,N){
        rep(j,N){
            cin >> c[i][j];
            c[i][j]--;
        }
    }

    vector<vector<ll>> sum(3, vector<ll>(C,0));
    rep(i,C){
        rep(j,N){
            rep(k,N){
                int x = j+1;
                int y = k+1;
                sum[(x+y)%3][i] += D[c[j][k]][i];
            }
        }
    }

    ll ans = INF;
    rep(i,C){
        rep(j,C){
            if (i == j) continue;
            rep(k,C){
                if (i == k) continue;
                if (j == k) continue;
                ans = min(ans, sum[0][i]+sum[1][j]+sum[2][k]);
            }
        }
    }

    cout << ans << endl;



}


Measured memory_bytes: 4544
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2331>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

int solve(){
    int res = 0;
    int N; cin >> N;
    vector<int> imos(100010,0);
    for(int i = 0; i < N;i++){
        int a,b; cin >> a >> b;
        imos[a]++; imos[b+1]--;
    }
    for(int i = 1; i <= N+1;i++){
        imos[i] += imos[i-1];
        
        if(imos[i] >= i-1) res = i-1;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}



Measured memory_bytes: 3360
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int main(){
    ll t=1;
    //cin>>t;
    while(t--){
        int a,b;
        cin>>a>>b;
        if(a==1&&b==2)
            cout<<"3\n";
        if(a==2&&b==1)
            cout<<"3\n";
        if(a==3&&b==1)
            cout<<"2\n";
        if(a==1&&b==3)
            cout<<"2\n";
        if(a==3&&b==2)
            cout<<"1\n";
        if(a==2&&b==3)
            cout<<"1\n";
    }
    return 0;
}


Measured memory_bytes: 3596
def mach_akiba(s, i):
    if len(s) == 9 or i > len(s):
        if s == "AKIHABARA":
            return True
        return False

    return mach_akiba(s, i+1) or mach_akiba(s[:i]+"A"+s[i:], i+1)


def main():
    s = input()

    if len(s) > 9:
        print("NO")
    elif mach_akiba(s, 0):
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()


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

int main(int argc, char const *argv[]) {
  int i;
  char card[3][101];
  int turn=0;//a-0 b-1 c-2
  int piv[3]={-1,-1,-1};

  for(i=0;i<3;i++)memset(card[i], '\0', 101);

  scanf("%s", card[0]);
  scanf("%s", card[1]);
  scanf("%s", card[2]);

//i < strlen(card[0]) + 1 + strlen(card[1]) + 1 +  strlen(card[2]) + 1
  for(i=0;; i++){
      piv[turn]++;
      if( card[turn][piv[turn]] == '\0')break;

    if(card[turn][piv[turn]] == 'a'){
      turn = 0;
    }else if(card[turn][piv[turn]] == 'b'){
      turn = 1;
    }else if(card[turn][piv[turn]] == 'c'){
      turn = 2;
    }
  }

  printf("%c\n", turn + 65 );
  return 0;
}


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

AB = [tuple(map(int,input().split())) for _ in range(M)]
tree = [[] for _ in range(N+1)]

for ab in AB:
    tree[ab[0]].append([ab[1]])
    tree[ab[1]].append([ab[0]])

tree.pop(0)
for t in tree:
    print(len(t))


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

bool is_prime(ll n) {
    if (n == 1) {
        return false;
    }

    ll i = 2;
    // This will loop from 2 to int(sqrt(x))
    while (i*i <= n) {
        // Check if i divides x without leaving a remainder
        if (n % i == 0) {
            // This means that n has a factor in between 2 and sqrt(n)
            // So it is not a prime number
            return false;
        }
        i += 1;
    }
    // If we did not find any factor in the above loop,
    // then n is a prime number
    return true;
}

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll A,B;

    cin >> A >> B;

    ll m = min(A,B);
    ll count = 0;

    set<ll> primes;
    for(ll i = 1; i*i <=m; i++){
        if(m%i == 0){
            if( i == 1 || is_prime(i) ){
                primes.insert(i);
            }
            if( is_prime(m/i) ){
                primes.insert(m/i);
            }
        }
    }

    ll x = max(A,B);
    for(auto p : primes){
        if( x%p == 0 ){
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N = I()
A = LI()


from math import gcd

g = 0  # Aiたちの最大公約数
for i in range(N):
    g = gcd(g,A[i])

if g != 1:
    print('not coprime')
    exit()


# osa_k法

B = [0]*(10**6+1)  # B[i] = iの最小の素因数
for i in range(2,10**3+1):
    if B[i] == 0:
        for j in range(i,10**6+1,i):
            if B[j] == 0:
                B[j] = i
for i in range(10**3+1,10**6+1):
    if B[i] == 0:
        B[i] = i


C = [0]*(10**6+1)  # C[i] = 1 ⇔ Aの中に素因数iを持つものが存在する
for i in range(N):
    a = A[i]
    while a != 1:
        b = B[a]
        if C[b] == 1:
            print('setwise coprime')
            exit()
        else:
            C[b] = 1
            while a % b == 0:
                a //= b

print('pairwise coprime')

# 計算量 O(A*loglogA+N*logA) ?
# A = max(Ai)


Measured memory_bytes: 197888
/*
By Tianyi Chen. All rights reserved.
Date: 2016-07-31
*/
#include<bits/stdc++.h>
using namespace std;
int n;int64_t l,a[100001],len[100001];
int root[100001],nx[100001],pv[100001];bool used[100001];
bool cf,cb;
vector<int>stk;
int findroot(int i) {
 return root[i]?root[i]=findroot(root[i]):i;
}
int mg(int i,int j) {
 i=findroot(i);j=findroot(j);
 if (i!=j)root[i]=j;
 return j;
}
priority_queue<pair<int64_t,int>>q;
list<pair<int64_t,int>>wq;
int main() {
 scanf("%d",&n);scanf("%lld",&l);
 for(int i=1;i<=n;++i)scanf("%lld",a+i),len[i]=a[i],q.emplace(a[i],i);
 for(int i=1;i<=n;++i) {
  if (i>1)pv[i]=i-1;
  if (i<n)nx[i]=i+1;
 }
 while (q.size()) {
  int i=q.top().second;q.pop();
  i=findroot(i);
  cf=cb=0;
  cb=nx[i]&&len[findroot(i)]+len[findroot(nx[i])]>=l;
  cf=pv[i]&&len[findroot(i)]+len[findroot(pv[i])]>=l;
  if (cf) {
   stk.push_back(pv[i]);
   used[pv[i]]=1;
   len[findroot(i)]+=len[findroot(pv[i])];
   mg(pv[i],i);
   int pvi=pv[i],nxi=nx[i];
   pv[i]=pv[pvi];
   q.emplace(len[findroot(i)],findroot(i));
   continue;
  }
  if (cb) {
   stk.push_back(i);
   used[i]=1;
   len[findroot(nx[i])]+=len[findroot(i)];
   mg(i,nx[i]);
   int pvi=pv[i],nxi=nx[i];
   pv[nxi]=pv[i];
   q.emplace(len[nxi],findroot(nxi));
   continue;
  }
 }
 if(stk.size()<n-1)return puts("Impossible"),0;
 puts("Possible");
 stk.erase(unique(stk.begin(),stk.end()),stk.end());
 while (stk.size())printf("%d\n",stk.back()),stk.pop_back();
}

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

using namespace std;
using boost::adaptors::reversed;
using boost::irange;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

static ll my_modulus = 1e9 + 7;

ll add(ll a, ll b){return (a + b) % my_modulus;}
ll mul(ll a, ll b){return ((a % my_modulus) * (b % my_modulus)) % my_modulus;}

int main() {
    string S;
    cin >> S;
//    ステートは未完成，Aだけ完成，AB完成，ABC完成のいずれか
    ll none{1}, A{0}, AB{0}, ABC{0};
    for (ll i = 0; i < S.size(); i++){
        ll none_org = none;
        ll A_org = A;
        ll AB_org = AB;
        ll ABC_org = ABC;
        char c = S.at(i);
        if (c == 'A'){
            A = add(A_org, none_org);
        } else if (c == 'B'){
            AB = add(AB_org, A_org);
        } else if (c == 'C'){
            ABC = add(ABC_org, AB_org);
        } else {
            none = mul(none_org, 3ll);
            A = add(mul(A_org, 3ll), none_org);
            AB = add(mul(AB_org, 3ll), A_org);
            ABC = add(mul(ABC_org, 3ll), AB_org);
        }
    }
    cout << ABC << endl;
    return 0;
}

Measured memory_bytes: 512
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest
import math

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    a,b,h,m=map(int, readline().rstrip().split())
    xxx=abs((((h+m/60)/12)*360)-((m/60)*360))
    xxx=min(xxx,360-xxx)
    rad=math.radians(xxx)
    cc=a*a+b*b-2*a*b*math.cos(rad)
    print(math.sqrt(cc))
    
    #arr=list(map(int, readline().rstrip().split()))
    #n=int(readline())
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------


Measured memory_bytes: 16492
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>

using namespace std;
int main(){
	int n;
	string s;
	cin >> n;
	s = to_string(n);
	if (s[0] == s[1] && s[1] == s[2])
		cout << "Yes" << endl;
	else if (s[1] == s[2] && s[2] == s[3])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;

}

Measured memory_bytes: 256
def main():
    S = input()
    
    for i in range(len(S) - 1) :
        S_ = S[:-(i+1)]
        if len(S_) % 2 == 0 :
            if S_[:len(S_)//2] == S_[len(S_)//2:] :
                print(len(S_))
                break
main()

Measured memory_bytes: 2940
import Data.Maybe
import Data.List

main :: IO ()
main = do
  input <- getContents
  putStrLn $ trim (solve (trim input))

--処理
solve :: String -> String
solve s | s `elem` ["a", "i", "u", "e", "o"] = "vowel"
        | otherwise                          = "consonant"

trimHead :: String -> String
trimHead = dropWhile (\s -> isJust (elemIndex s [' ', '\t', '\n', '\r']))

trim :: String -> String
trim = reverse . trimHead . reverse . trimHead

Measured memory_bytes: 380
#include<stdio.h>
#define A 100
int main(){

  int n,a[A],i,flag,count=0,change;

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    scanf("%d",&a[i]);
  }
  
  flag = 1;
  while(flag){
      flag = 0;
      for(i = n-1;i > 0;i--){
	if(a[i] < a[i-1]){
	  change = a[i-1];
	  a[i-1] = a[i];
	  a[i] = change;
	  count++;
	  flag = 1;
	}
      }
    }
      for(i = 0;i < n-1;i++){
	printf("%d ",a[i]);
      }
      printf("%d\n%d\n",a[n-1],count);
     
      return 0;
    }

Measured memory_bytes: 600
N=int(input())
cnt=0
for i in range(1,10):
    for k in range(1,10):
        a=0
        b=0
        for n in range(1,N+1):
            r=n%10
            l=n//(10**(len(str(n))-1))
            if k==r and i==l:
                a+=1
            if i==r and k==l:
                b+=1
        cnt+=a*b
print(cnt)

Measured memory_bytes: 43100
class Tree:
    def __init__(self):
        self.root = None

    def insert(self, key):
        z = Node(key)
        y = None  # x?????????????´????????????°
        # z???parent???????´?
        x = self.root
        while x:
            y = x
            if z.key < x.key:
                x = x.left
            else:
                x = x.right
        z.parent = y
        # z??????????????´??????????´?
        if y is None:
            self.root = z
        elif z.key < y.key:
            y.left = z
        else:
            y.right = z

    def find(self, key):
        x = self.root
        while x and key != x.key:
            if key < x.key:
                x = x.left
            else:
                x = x.right
        return x

    def show(self):
        print(" ", end="")
        print(*list(map(str, self.root.inwalk())))
        print(" ", end="")
        print(*list(map(str, self.root.prewalk())))


class Node:
    def __init__(self, key):
        self.key = key
        self.parent = self.left = self.right = None

    def prewalk(self):
        nodeList = [self.key]
        if self.left:
            nodeList += self.left.prewalk()
        if self.right:
            nodeList += self.right.prewalk()
        return nodeList

    def inwalk(self):
        nodeList = []
        if self.left:
            nodeList += self.left.inwalk()
        nodeList += [self.key]
        if self.right:
            nodeList += self.right.inwalk()
        return nodeList


tree = Tree()
n = int(input())
for i in range(n):
    cmd = list(input().split())
    if cmd[0] == 'insert':
        tree.insert(int(cmd[1]))
    elif cmd[0] == 'find':
        if tree.find(int(cmd[1])):
            print("yes")
        else:
            print("no")
    elif cmd[0] == 'print':
        tree.show()

Measured memory_bytes: 156548
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;


     signed main(){
string s;
cin>>s;
for(int i=s.size()-1;i>=0;i--){
     if(s[i]=='?')s[i]='D';
     
    
}
cout<<s<<endl;


 }

 


 






    





      

        


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

using namespace std;

int main() {
    int A, B, C, temp;
    cin >> A >> B >> C;

    temp = B;
    B = A;
    A = temp;

    temp = C;
    C = A;
    A = temp;
    cout << A << " " << B << " " << C << endl;


}


Measured memory_bytes: 3488
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i = n;i >= 0;--i)
#define FOR(i,m,n) for(int i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
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 gcd(int a,int b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

int main(void)
{
    int n;
    cin >> n;
    vector<int> p(n);
    REP(i,n) cin >> p[i];
    vector<int> sorted = p;
    sort(all(sorted));

    int cnt = 0;
    REP(i,n){
        if(p[i] != sorted[i]){
            cnt++;
        }
    }

    if(cnt == 2 || cnt == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n,m,l=map(int,input().split())
A,B=[],[]
C=[[0 for x in range(l)] for y in range(n)]
for a in range(n):
    A.append([int(x) for x in input().split()])
for b in range(m):
    B.append([int(x) for x in input().split()])
for c in range(m):
    for d in range(n):
        for e in range(l):
            C[d][e]+=A[d][c]*B[c][e]
for h in C:
    print(" ".join(map(str,h)))


Measured memory_bytes: 6828
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; 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 f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; 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 f * x;
}

const int INF = 0x3f3f3f3f;

int n, m;
char s[103];
string t;

int main()
{
	//File("");
	double l;
	cin >> l;
	double a = l / 3.0;
	printf("%.12lf\n", a * a * a);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

long long min(long long a,long long b){
  if(a < b){
    return a;
  }
  return b;
}

int main(void){
  long N,A,B;
  scanf("%ld%ld%ld",&N,&A,&B);

  long long pX,X;
  long long ans = 0;
  scanf("%lld",&pX);
  for(int i = 0;i < N-1;i++){
    scanf("%lld",&X);
    ans += min((X-pX)*A,B);
    pX = X;
  }

  printf("%lld\n",ans);

  return 0;
}

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

ll choose2(ll n){
    return n*(n-1)/2;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    for(int i = 0;i < n;i++){
        a[i]--;
    }
    vector<int> cnt(n);
    for(int i = 0;i < n;i++){
        cnt[a[i]]++;
    }
    ll total = 0;
    for(int i = 0;i < n;i++){
        total += choose2(cnt[i]);
    }
    for(int i = 0;i < n;i++){
        ll ans = total;
        ans -= choose2(cnt[a[i]]);
        ans += choose2(cnt[a[i]]-1);
        cout << ans << endl;
    }
}

Measured memory_bytes: 4096
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

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

int sz[200];
P stone[200][20];
int dp[200][20][200];
int main(){
	int n, m;

	while(cin >> n >> m && (n || m)){
		fill(sz, sz + 200, 0);
		fill(&dp[0][0][0], &dp[199][19][199] + 1, INF);
		dp[0][0][m] = 0;
		int res = INF;
		sz[0] = sz[n+1] = sz[n+2] = 1;
		rep(i, n){
			cin >> sz[i+1];
			rep(j, sz[i+1]){
				int x, r;
				cin >> x >> r;
				stone[i+1][j] = P(x, r);
			}
		}

		rep2(i, 1, n + 3){
			rep(j, sz[i]){
				rep(k, m + 1){
					rep(l, sz[i-1]){
						int cost = (i > n || i == 1) ? 0 :
							abs(stone[i][j].first - stone[i-1][l].first)
							 * (stone[i][j].second + stone[i-1][l].second);
						dp[i][j][k] = min(dp[i-1][l][k] + cost, dp[i][j][k]);
					}
				
					rep(l, sz[i-2]){
						int cost = (i <= 2 || n < i) ? 0 : 
							abs(stone[i][j].first - stone[i-2][l].first) * (stone[i][j].second + stone[i-2][l].second);
						dp[i][j][k] = (i == 1) ? 0 : min(dp[i-2][l][k+1] + cost, dp[i][j][k]); 				
					}
				}
			}
		}
		rep2(i, n+1, n+3)rep(j, m+1) res = min(res, dp[i][0][j]);
		cout << res << endl;
	}

	return 0;
}

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


int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    string s;
    cin>>s;
    int n=s.size();
    if (s[n - 1] == '2' || s[n - 1] == '4' || s[n - 1] == '5' || s[n - 1] == '7' || s[n - 1] == '9')
    {
        cout<<"hon"<<endl;
    }
    if (s[n - 1] == '0' || s[n - 1] == '1' || s[n - 1] == '6' || s[n - 1] == '8'){
        cout<<"pon"<<endl;
    }
    if(s[n-1]=='3'){
        cout<<"bon"<<endl;
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  for (int i = 0, a, sum = 0; i < N && cin >> a; i++)
    V.at(i) = sum += a;

  long long cnt1 = 0;
  for (int i = 0, j = 0; i < N; i++) {
    int tmp = V.at(i) + j;
    if (!(i % 2) && tmp >= 0) cnt1 += abs(-1 - tmp), j += -1 - tmp;
    if (i % 2 && tmp <= 0) cnt1 += 1 - tmp, j += 1 - tmp;
  }

  long long cnt2 = 0;
  for (int i = 0, j = 0; i < N; i++) {
    int tmp = V.at(i) + j;
    if (i % 2 && tmp >= 0) cnt2 += abs(-1 - tmp), j += -1 - tmp;
    if (!(i % 2) && tmp <= 0) cnt2 += 1 - tmp, j += 1 - tmp;
  }

  cout << min(cnt1, cnt2) << "\n";
}

Measured memory_bytes: 640
#include <vector>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <bitset>
#include <fstream>
using namespace std;
const int MAXN = 4e5;
const int INF = 1e9 + 1;
vector<int> t_max(MAXN);

void build(vector<int>& a, int v, int tl, int tr) {
    if (tl == tr) t_max[v] = a[tl];
    else {
        int tm = (tl + tr) / 2;
        build(a, v * 2, tl, tm);
        build(a, v * 2 + 1, tm + 1, tr);
        t_max[v] = max(t_max[v * 2], t_max[v * 2 + 1]);
    }
}
int max_t(int v, int tl, int tr, int l, int r) {
    if (l > r) return -INF;
    if (l == tl && r == tr) return t_max[v];
    else {
        int tm = (tl + tr) / 2;
        return max(max_t(v * 2, tl, tm, l, min(r, tm)), max_t(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
    }
}



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

    int n, t;
    cin >> n >> t;
    vector<int> numbers(n);
    for (int i = 0; i < n; ++i) {
        cin >> numbers[i];
    }
    build(numbers, 1, 0, n - 1);
    int max_nmb = 0;
    int cnt = 0;
    for (int i = 0; i < n - 1; ++i) {
        int tmp = max_t(1, 0, n - 1, i + 1, n - 1) - numbers[i];
        if (tmp == max_nmb) ++cnt;
        else {
            if (tmp > max_nmb) {
                cnt = 1;
                max_nmb = tmp; 
            } else continue;
        }
    }
    cout << cnt << endl;


    return 0;
}

Measured memory_bytes: 2176
n, m = map(int, input().split())
heights = list(map(int, input().split()))

isGood = [True] * n

for i in range(m):
    a, b = map(int, input().split())
    if heights[a-1] > heights[b-1] :
        isGood[b-1] = False
    elif heights[b-1] > heights[a-1] :  
        isGood[a-1] = False
    else :  
        isGood[a-1] = False
        isGood[b-1] = False
    
print (isGood.count(True))


Measured memory_bytes: 20096
#include<stdio.h>
int main(void){
    int i;
    char S[4];
    int count=0;

    for(i=0;i<4;i++){
        scanf("%c",&S[i]);
    }

    for(i=0;i<4;i++){
        if(S[i] == '+'){
            count++;
        }else{
            count--;
        }
    }

    printf("%d",count);


    return 0;
}

Measured memory_bytes: 128
#include <iostream>

int main(){

    int N,M,X;
    std::cin >>N>>M>>X;
    int A[M];
    for(int i=0;i<M;i++){
        std::cin>>A[i];
    }
    
    int B[N];
    for(int i=0;i<N+1;i++){
        B[i] = 0;
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            if(i == A[j]){
            B[i] = 1;
            }
        }
    }
    B[N] = 0;
    int c,C;
    c = 0;
    C = 0;
    for(int i=0;i<X;i++){
        c += B[i];
    }
    for(int i=X;i<N;i++){
        C += B[i];
    }
    if(c>=C){
        std::cout << C<< std::endl;
    }
    else{std::cout << c<< std::endl;}

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws java.lang.Exception
    {		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int x =Integer.parseInt(st.nextToken()),y=Integer.parseInt(st.nextToken());
		System.out.println(y%2==0 && y>=2*x && y<=4*x? "Yes":"No" );
	}
}

Measured memory_bytes: 32616
a, b = gets.split.map(&:to_i)
ans  = []
size = b - a + 1

if size % 2 == 0
  if size % 4 == 0
    ans << 0
  else
    ans << 1
  end
else
  if (size % 4 == 1 && a % 2 == 0) || (size % 4 == 3 && a % 2 == 1)
    ans << 0
  else
    ans << 1
  end
end


d = 2
while d <= b
  a1 = a % (d * 2)
  b1 = b % (d * 2)
  ans.unshift((((d - a1) % d) * ((a1 / d) % 2) + ((b1 % d) + 1) * ((b1 / d) % 2)) % 2)
  d *= 2
end

puts ans.join.to_i(2)


Measured memory_bytes: 1788
package main

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

var r = bufio.NewReader(os.Stdin)
var x int = 0

func main() {
    for i := 1; i!=0; {
      x++
	  fmt.Fscan(r, &i)
	  if i==0 {
		break
	}
      fmt.Printf("Case %v: %v\n",x,i)
    }
}


Measured memory_bytes: 1424
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  int n,a;
  cin>>n;
  bool f=true;
  for(int i=0;i<n;i++){
    cin>>a;
    if(a%2==1){
      f=!f;
    }
  }
  cout<<(f?"YES":"NO");
}

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

int find(int i,vector<int>& uf){
  if(uf[i]<0) return i;
  if(uf[uf[i]]<0) return uf[i];
  else return uf[i]=find(uf[i],uf);
}


void union_(int a,int b,vector<int>& uf){
  a=find(a,uf); b=find(b,uf);
  if(a==b) return;
  if(uf[a]>uf[b]) swap(a,b);
  uf[a]+=uf[b];
  uf[b]=a;
}

int main(){
  int n,m; cin >>n >>m;
  vector<int> v(n);
  for(auto& x: v) {cin >>x; x--;}
  vector<vector<int>> adj(n);
  vector<int> uf(n,-1);
  rep(i,m){
    int a,b; cin >>a >>b; a--; b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
    union_(a,b,uf);
  }
  int cnt=0;
  rep(i,n) cnt+=(find(i,uf)==find(v[i],uf));
  print(cnt);
}


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

#define N 1000010 

using namespace std;

typedef long long ll;

char *p1, *p2, buf[100000];

#define nc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1 ++ )

int rd() {
	int x = 0, f = 1;
	char c = nc();
	while (c < 48) {
		if (c == '-')
			f = -1;
		c = nc();
	}
	while (c > 47) {
		x = (((x << 2) + x) << 1) + (c ^ 48), c = nc();
	}
	return x * f;
}

ll m;

int n;

ll a[N];

ll bfr[N], ans;

void solve() {
	bfr[0] = 0;
	for (int i = 1; i <= n; i ++ ) {
		bfr[i] = bfr[i - 1] + a[i];
	}
	for (int i = 1; i <= n; i ++ ) {
		ll mdl;
		if (i & 1) {
			int x = (i - 1) >> 1;
			mdl = ((ll)m * x - (bfr[n] - bfr[n - x])) * 2 + a[n - x] + (bfr[n - x - 1] - bfr[n - x - x - 1]) * 2;
		}
		else {
			int x = i >> 1;
			mdl = (m * (x - 1) - (bfr[n] - bfr[n - x + 1])) * 2 + ((ll)m - a[n - x + 1]) + (bfr[n - x] - bfr[n - x - x]) * 2;
		}
		ans = max(ans, mdl);
	}
}

int main() {
	m = rd(), n = rd();
	for (int i = 1; i <= n; i ++ ) {
		a[i] = rd();
	}
	solve();
	for (int i = 1; i <= n; i ++ ) {
		a[i] = m - a[i];
	}
	reverse(a + 1, a + n + 1);
	solve();
	cout << ans << endl ;
	return 0;
}

Measured memory_bytes: 6016
N = int(input())
P = list(map(int, input().split()))
R = list(range(N))
L = list(range(N))
I = [-1] * (N+1)
for i, p in enumerate(P):
    I[p] = i

ans = 0
for n, idx in enumerate(I[1:], 1):
    l = idx-1
    if l>=0:
        l = L[l]
    r = idx+1
    if r<N:
        r = R[r]
    L[r-1] = l
    R[l+1] = r

    if l>=0:
        l2 = l-1
        if l2>=0:
            l2 = L[l2]
        ans += n * (l-l2) * (r-idx)
    if r<N:
        r2 = r+1
        if r2<N:
            r2 = R[r2]
        ans += n * (idx-l) * (r2-r)
print(ans)


Measured memory_bytes: 20196
#define _CRT_SECURE_NO_WARNINGS
#define TASK "complex"
#pragma comment(linker, "/STACK:2010886400")
#include <cstdio>
#include <iostream>
#include <iomanip> 
#include <cmath>
#include <chrono>
#include <cstdlib>
#include <cstring>
#include <assert.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <random>
#include <complex>
using namespace std;

const int MOD = 1000000007;
const int INF = 1000000001;
const long double EPS = 1e-9;
const int HASH_POW = 29;
const long double PI = acos(-1.0);
mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

long long nextLong(long long l, long long r) {
	uniform_int_distribution <long long> foo(l, r);
	return foo(rnd);
}

double nextDouble(double l, double r) {
	uniform_real_distribution <double> foo(l, r);
	return foo(rnd);
}

double workTime() {
	return double(clock()) / CLOCKS_PER_SEC;
}

void myReturn(int code = 0) {
#ifdef MYDEBUG
	cout << "\nTime = " << fixed << setprecision(3) << workTime() << endl;
#endif
	exit(code);
}

int n, sz = 0, nxt[200010][2];
long long depth[200010];
long long l;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifdef MYDEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	/*freopen(TASK".in", "r", stdin);
	freopen(TASK".out", "w", stdout);*/
	/*freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);*/
#endif

	cin >> n >> l;
	memset(nxt, -1, sizeof nxt);
	depth[0] = l + 1;
	while (n-- > 0) {
		string s;
		cin >> s;
		int v = 0;
		for (int i = 0; i < s.length(); ++i) {
			if (nxt[v][s[i] - '0'] == -1) {
				++sz;
				depth[sz] = depth[v] - 1;
				nxt[v][s[i] - '0'] = sz;
			}
			v = nxt[v][s[i] - '0'];
		}
	}

	long long ans = 0;
	for (int i = 0; i < sz; ++i) {
		if ((nxt[i][0] == -1) ^ (nxt[i][1] == -1)) {
			long long foo = depth[i] - 1;
			int val = 0;
			while (foo % 2 == 0) {
				++val;
				foo >>= 1;
			}
			ans ^= (1ll << val);
		}
	}
	cout << (ans ? "Alice\n" : "Bob\n");

	myReturn();
}

Measured memory_bytes: 2796