akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc093/tasks/arc094_a

#include <algorithm>
#include <cmath>
#include <iostream>
#include <regex>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

#define EPS (1e-7)
#define INF (1e9)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// long gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// long lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> v;
    int cnt = 0;
    v.resize(3);
    cin >> v[0] >> v[1] >> v[2];
    sort(ALL(v));

    // 小さい2つの数の差を2の倍数にする
    int tmp = v[1] - v[0];
    if (tmp % 2 != 0) {
        v[0]++;
        v[2]++;
        cnt++;
    }
    // 小さい2つの数を等しくする
    cnt += (v[1] - v[0]) / 2;

    // 3つの数を揃える
    cnt += v[2] - v[1];

    // cout << v[0] << v[1] << v[2] << endl;
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
using namespace std;
namespace Solve
{
	long long X,K,D;
	void work()
	{
		while(cin>>X>>K>>D)
		{
			if(abs(X)/D>=K) cout<<abs(X)-D*K<<endl;
			else
			{
				long long Left=abs(X)%D;
				long long Right=D-Left;
				if((K-abs(X)/D)&1) cout<<Right<<endl;
				else cout<<Left<<endl;
			}
		}
		return;
	}
}
int main()
{
	#ifdef LOCAL
	freopen("00test.in","r",stdin);
	freopen("00test.out","w",stdout);
	#endif
	Solve::work(); 
	return 0;
}

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

int main() {
    int N;
    ll x;
    cin >> N >> x;
    vector<ll> A(N);
    rep(i,N) cin >> A.at(i);
    ll ans = 0;
    if(A.at(0)>x){
        ans += A.at(0)-x;
        A.at(0) = x;
    }
    rep(i,N-1){
        if(A.at(i)+A.at(i+1)>x){
            ans += A.at(i+1)-(x-A.at(i));
            A.at(i+1) = x-A.at(i);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(void)
{
    string s;
    cin >> s;
    int w;
    cin >> w;

    for (int i = 0; i < s.size(); i += w) {
        printf("%c", s[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
def main():
    N,M = map(int,input().split())
    P,S = [],[]
    for _ in range(M):
        p,s = map(str,input().split())
        p = int(p)
        P.append(p)
        S.append(s)
    AC = [0 for i in range(N+1)]
    for i in range(M):
        if S[i]=="AC" and AC[P[i]]==0:
            AC[P[i]] += 1
        else:
            pass
    
    WA = [0 for i in range(N+1)]
    WA_flg = [ False for _ in range(N+1)]
    for i in range(M):
        if AC[P[i]]==0:
            pass
        else:
            if WA_flg[P[i]]==True:
                pass
            else:
                if S[i] == "AC":
                    WA_flg[P[i]]=True
                else:
                    WA[P[i]] += 1

    print(sum(AC),end=" ")
    print(sum(WA))

if __name__ == '__main__':
    main()

Measured memory_bytes: 69288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vl;
#define pll pair<ll, ll>
#define vpl vector<pll>
#define vb vector<bool>
#define PB push_back
#define MP make_pair
#define ln "\n"
#define forn(i,e) for(ll i=0; i<e; i++)
#define forsn(i,s,e) for(ll i=s; i<e; i++)
#define rforn(i,e) for(ll i=e; i>=0; i--)
#define rforsn(i,s,e) for(ll i=s; i>=e; i--)
#define vasort(v) sort(v.begin(), v.end())
#define vdsort(v) sort(v.begin(), v.end(),greater<ll>())
#define F first
#define S second

#define out1(x1) cout << x1 << ln
#define out2(x1,x2) cout << x1 << " " << x2 << ln
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << ln
#define out4(x1,x2,x3,x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << ln
#define out5(x1,x2,x3,x4,x5) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << ln
#define out6(x1,x2,x3,x4,x5,x6) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << " " << x6 << ln

#define in1(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4
#define in5(x1,x2,x3,x4,x5) cin >> x1 >> x2 >> x3 >> x4 >> x5
#define in6(x1,x2,x3,x4,x5,x6) cin >> x1 >> x2 >> x3 >> x4 >> x5 >> x6

#define mz(a)   memset(a,0,sizeof(a))
#define arrin(a,n) forn(i,n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << ln;
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

#define zoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main() {
    zoom;
    ll n;
    in1(n);
    vl v1,v2;
    forn(i,n){
        ll x,y;
        in2(x,y);
        v1.PB(x+y);
        v2.PB(x-y);
    }
    vasort(v1);
    vasort(v2);
    ll x1=v1[n-1]-v1[0];
    ll x2=v2[n-1]-v2[0];
    out1(max(x1,x2));
    return 0;
}


Measured memory_bytes: 6652
N = int(input())
a = list(map(int,(input().split())))
n1,n2,n4 = 0,0,0
for i in range(N):
    if a[i]%2 != 0:
        n1 += 1
    elif a[i]%4 == 2:
        n2 += 1
    else:
        n4 += 1

if n4*2 + 1 >= N:
    print("Yes")
else:
    if n4*2 + n2 >= N:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 62832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

int main(){
    ll n,ans=1;
    string s;
    cin >> n >> s;
    map<char,ll> mp;
    for(int i = 0;i < n;i ++){
        mp[s[i]] ++;
    }
    for(auto ite = mp.begin();ite != mp.end();++ite){
        ans *= ite->second?ite->second+1:1;
        ans %= mod;
    }
    cout << ans-1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define fore(i,a,b) for(int i=a,thxicesi=b; i<thxicesi;i++)
#define FIN ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define sz(s) int(s.size())
using namespace std;
typedef long long ll;
ll mod = ll(1e9)+7;
ll calcMin(ll k){
    ll ans =k*(k-1)/2;
    return ans%mod;
}
ll calcMax(ll n,ll k){
    ll ans = n*(n-1)/2;
    ans-= (n-k)*(n-k-1)/2;
    return ans%mod;
}
int main()
{FIN;
    ll n,k; cin>>n>>k;
    ll ans = 0;

    for(ll i = k; i<=n+1;i++){
        ans += (calcMax(n+1,i)-calcMin(i)+1+mod)%mod;
//        cout<<calcMax(n+1,i)<<" i\n";
        ans %= mod;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<complex>
#include<time.h>
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-7
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	vector<ll> a(n);
	REP(i,n) cin>>a[i];
	ll ans=0;
	REP(i,n) {
		while(a[i]%2==0) {
			ans++;
			a[i]/=2;
		}
	}
	cout<<ans<<endl;
}


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

int main() {
  int a = 0;
  char S[3];
  for(int i = 0; i < 3; i++){
    cin >> S[i];
  if(S[i] == 'R'){
    a++;
  }
 }
  if(S[1] == 'S' && a == 2){
    cout << 1 << endl;
  }else{
    cout << a << endl;
  }
    
  
}


Measured memory_bytes: 3596
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
//intは10桁、long longは18桁、doubleは308桁、long double は4932桁
int main()
{
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}

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

typedef long long int ll;
typedef pair<int,int> pi;
priority_queue<pi, vector<pi>, greater<pi> > pq; //min heap

ll mini(ll a,ll b){	return a<b?a:b;}
ll maxi(ll a,ll b){	return a>b?a:b;}
ll gcd(ll a,ll b){	if(b == 0)	return a;return gcd(b,a%b);}
ll binpow(ll n,ll x){	ll ans = 1;while(x){if(x & 1)	ans *= n;n *= n;x >>= 1;}return ans;}

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

    int n;
    cin>>n;
    vector<double> probs(n+1,0);
    for(int i=1;i<=n;++i)   cin>>probs[i];

    vector<double> dp(n+1,0);

    dp[0] = 1;
    for(int i=1;i<=n;++i){
        for(int j=i;j>=1;--j){
            dp[j] = dp[j-1]*probs[i] + dp[j]*(1-probs[i]);
        }
        dp[0] = dp[0]*(1-probs[i]);
    }

    double ans = 0;

    for(int i=(n+1)/2;i<=n;++i){
        ans += dp[i];
    }

    cout<<setprecision(10)<<ans<<"\n";

    return 0;
}

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

typedef pair<int,int> P;

int main(void){
    int h,w,d[50][50],dx[]={1,0,-1,0},dy[]={0,1,0,-1},INF,a=0;
    queue<P> q;
    string s[50];
    cin>>h>>w;
    INF = h*w;
    for(int i=0;i<h;i++){
        cin>>s[i];
        for(int j=0;j<w;j++){
            d[i][j]=INF;
            if(s[i][j]=='.')a++;
        }
    }
    
    q.push(P(0,0));
    d[0][0]=1;
    while(q.size()){
        P p=q.front();
        q.pop();
        for(int i=0;i<4;i++){
            int ny=p.first+dy[i],nx=p.second+dx[i];
            if(ny>=0&&ny<h&&nx>=0&&nx<w){
                if(s[ny][nx]=='.'&&d[ny][nx]==INF){
                    q.push(P(ny,nx));
                    d[ny][nx]=d[p.first][p.second]+1;
                }
            }
        }
    }
    if(d[h-1][w-1]==INF){
        cout<<-1<<endl;
    }else{
        cout<<a-d[h-1][w-1]<<endl;
    }
}


Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
        String[] rc=br.readLine().split(" ");
        int r=Integer.parseInt(rc[0]);
        int c=Integer.parseInt(rc[1]);
        int[][] h=new int[r][c];
        
        for(int i=0;i<r;i++){
        	String[] row=br.readLine().split(" ");
        	int s=0;
        	for(int j=0;j<c;j++){
        		h[i][j]=Integer.parseInt(row[j]);
        		sb.append(h[i][j]+" ");
        		s+=h[i][j];
        	}
        	sb.append(s+"\n");
        }
        int ts=0;
        for(int j=0;j<c;j++){
        	int s=0;
        	for(int i=0;i<r;i++){
        		s+=h[i][j];
        		ts+=h[i][j];
        	}
        	sb.append(s+" ");
        }
        sb.append(ts);
        System.out.println(sb);
	}
}

Measured memory_bytes: 25332
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define endl endl;cf
#define be begin()
#define sz size()
#define en end()
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0)
#define forn(i,a,b) for(ll i=1;i<=b;++i)
#define forr(i,a,b) for(ll i=0;i<b;++i)
#define rngx mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define cf cout.flush()
int main()
{
    ios;
    ll n;
    cin >> n ;
    vl  v;
    forn(i , 1 , n)
    {
        ll x;
        cin >> x;
        v.pb(x);
    }
    sort(all(v));
    ll N = v[n-1];
    if(N%2 == 1)
    {
        ll f1 = N/2 ;
        ll f2 = f1+1;
        ll ans1 = 3e18 , ans2 = 3e18;
        ll r1 = -1 ,r2 = -1;
        ll from = -1;
        for(ll i = 0 ; i< n ; ++i){
            if(v[i] > f1) {
                from = i;
                break;
            }
            else {
                ll diff = f1 - v[i];
                if(diff < ans1){
                    ans1 = diff ;
                    r1 = v[i];
                }
            }
        }
        r2= v[from];
        ll diff1 = f1 - r1;
        ll diff2 = r2 - f2;
        if(diff1 < diff2){
            cout << N << " " << r1 <<endl;
        }
        else cout << N << " " << r2 << endl;
        return 0;
    }
    else if(N%2 == 0)
    {
        ll f = N/2;
        ll ans1 = 3e18;
        ll r1 = -1;
        for(ll i = 0 ; i <n-1 ; ++i){
            ll diff = abs(v[i] - f);
            if(diff < ans1){
                ans1 = diff ;
                r1 = v[i];
            }
        }
        cout << N << " " << r1 <<endl;
        return 0 ;
    }
}



Measured memory_bytes: 1400
N = int(input())
S = list(map(int, input().split()))

j = 0
for i in range(N):
    key = S[i]
    j = i - 1
    while j>=0 and S[j] > key:
        S[j+1] = S[j]
        j-=1
    S[j+1] = key
    
    res = ""
    for i in range(N):
        res += str(S[i])
        if i < N-1:
            res += " "
    
    print(res)


Measured memory_bytes: 5592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
	public static void Main()
	{
		var n = int.Parse(ReadLine());
		var a = ReadLine().Split().Select(int.Parse).ToArray();
		var count = 0;
		for(int i = 0; i < a.Length - 2; i++)
		{
			for(int j = i + 1; j < a.Length - 1; j++)
			{
				for(int k = j + 1; k < a.Length; k++)
				{
					var max = Max(a[i], a[j]);
					max = Max(max, a[k]);
					if(max >= a[i] + a[j] || max >= a[i] + a[k] || max >= a[j] + a[k])
						continue;
					if(a[i] == a[j] || a[i] == a[k] || a[j] == a[k])
						continue;
					count++;
				}
			}
		}
		WriteLine(count);
	}
}


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

#define NIL -1
struct Node { int parent, left, right; };
Node T[1000000];
int n, D[1000000], H[1000000];

void setDepth(int u, int d) 
{
	if (u == NIL) return;
	D[u] = d;
	setDepth(T[u].left, d + 1);
	setDepth(T[u].right, d + 1);
}

int setHeight(int u)
{
	int h1, h2;
	h1 = h2 = 0;

	if (T[u].right != NIL) h2 = setHeight(T[u].right) + 1;

	if (T[u].left != NIL) h1 = setHeight(T[u].left) + 1;

	if (h1 > h2) return H[u] = h1;
	else return H[u] = h2;
}

int getSibling(int u)
{
	if (T[u].parent == NIL) return NIL;
	if (T[T[u].parent].left != u && T[T[u].parent].left != NIL) return T[T[u].parent].left;
	if (T[T[u].parent].right != u && T[T[u].parent].right != NIL) return T[T[u].parent].right;

	return NIL;
}

void print(int u)
{
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].parent << ", ";
	cout << "sibling = " << getSibling(u) << ", ";
	int deg = 0;
	if (T[u].left != NIL) deg++;
	if (T[u].right != NIL) deg++;
	cout << "degree = " << deg << ", ";
	cout << "depth = " << D[u] << ", ";
	cout << "height = " << H[u] << ", ";

	if (T[u].parent == NIL) cout << "root" << endl;
	else if (T[u].left == NIL && T[u].right == NIL) cout << "leaf" << endl;
	else cout << "internal node" << endl;
}

int main() 
{
	int id, left, right, root = 0;

	cin >> n;
	for (int i = 0; i < n; i++) T[i].parent = NIL;
	for (int i = 0; i < n; i++)
	{
		cin >> id >> left >> right;
		T[id].left = left;
		T[id].right = right;
		if (left != NIL) T[left].parent = id;
		if (right != NIL) T[right].parent = id;
	}

	for (int i = 0; i < n; i++)
	{
		if (T[i].parent == NIL) root = i;
	}

	setDepth(root, 0);
	setHeight(root);
	for (int i = 0; i < n; i++) print(i);

	return 0;
}

Measured memory_bytes: 3084
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

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

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {
	int n,k;
	cin>>n>>k;
	vi arr(n);
	for(int &i:arr)cin>>i;
	vi dp(n+1,INT_MAX);
	dp[0]=0;
	dp[1] = abs(arr[1]-arr[0]);
	for(int i=2;i<n;i++) {
		REP(j,1,k) {
			if(i-j<0)break;
			dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
		}
	}
	cout<<dp[n-1];
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3992
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
using namespace std;
typedef long long ll;
const int maxn = 105;

ll a[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  ll n;
  cin>>n;
  for(int i=0;i<5;i++)cin>>a[i];
  ll mi = a[0];
  int pos = 0;
  for(int i=1;i<5;i++)if(mi>a[i]){
    mi = a[i];
    pos = i;
  }
  ll ret = pos + (n+mi-1)/mi + (5-1-pos);
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
s = input()
s = list(map(int, s))

v = []
now = 1  # 現在見ている数
cnt = 0  # nowが並ぶ数
for ss in s:
    if ss == now:
        cnt += 1
    else:
        v.append(cnt)
        now = 1 - now  # 0と1を切り替える計算 now ^= 1
        cnt = 1  # ss分を計上
if cnt > 0:
    v.append(cnt)
# 1-0-1-0-1-0-1のように
# 1で終わる配列が欲しい
# 1-0-1-0のように0で終わっていたら、1を足す

# ※1の人数-0の人数-...の配列

if len(v) % 2 == 0: v.append(0)
# 1が0個という項を追加して、
# 1-0-1-0-1にする


# 1-0-1-...の1から始めるので、偶数番目だけ見る
lv = len(v)
left, right = 0, 0
# [left, right)
ans = 0
cur_total = 0
for i in range(0, lv, 2):
    nextLeft = i
    nextRight = min(2 * K + 1 + i, lv)
    while left < nextLeft:
        cur_total -= v[left]
        left += 1
    while right < nextRight:
        cur_total += v[right]
        right += 1
    ans = max(cur_total, ans)

print(ans)


Measured memory_bytes: 4768
#include <stdio.h>

   int main (void)
   {

   int min,max,n,R[200000];
   
   int i,j;
   
   scanf("%d",&n);
   for(i = 0; i < n; i++){
   	
   	scanf("%d",&R[i]);
   }
   	
   min = R[0];

   max = R[1] - R[0];

   for(j = 1; j < n;j++){
     if(max < R[j] - min){
       max = R[j] - min;
     }
     if(R[j] < min){
       min = R[j];
     }  
   }
     printf("%d\n",max);
   
   return 0; 

   }

Measured memory_bytes: 2636
#!/usr/bin/ruby

N = gets.chomp.to_i

table = []

0.upto(9){|i|
  table[i] =  Array.new(10, 0)
}

1.upto(N){|n|
  s = n.to_s[0].to_i
  e = n.to_s[-1].to_i

  # puts "#{n} : s:#{s} e:#{e}"

  table[s][e] += 1
}

#0.upto(9){|i|
#  puts table[i].join(" ")
#}

count = 0
0.upto(9){|s|
  0.upto(9){|e|
     count += table[s][e] * table[e][s]
  }
}

puts count


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

int main()
{
	char S[11];
	char T[11];
	
	scanf("%s", S);
	scanf("%s", T);
	
	int A,B;
	scanf("%d", &A);
	scanf("%d", &B);
	
	char U[10];
	scanf("%s", U);
	
	if(strcmp(U,S)==0) printf("%d %d", A-1,B);
	if(strcmp(U,T)==0) printf("%d %d", A,B-1);
	
	return 0;
}

Measured memory_bytes: 3224
quat, half, one, two = (int(x) for x in input().split())
n = int(input())

if 4 * quat < one:
    one = 4 * quat
if 2 * half < one:
    one = 2 * half
if 2 * one < two:
    print(one * n)
else:
    print(two * (n // 2) + one * (n % 2))

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


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int p,q,r;
  cin >> p>>q>>r;
  int m,n;
  if(p < q) {m = p;n=q;}
  else {m = q;n=p;}
  if(n < r) printf("%d\n", m+n);
  else printf("%d\n", m + r);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
#define ll long long
#define ld long double
#define ALL(x) begin(x),end(x)
     

int main() {
  ll n;
  cin >> n;
  
  vector<ll> a(n);
  a.clear();
  
  rep(i,n){
    ll num;
    cin >> num;
    if(a.empty()){
      a.push_back(num);
    }else{
      auto j = find(a.begin(),a.end(),num);
      if(j != a.end()) a.erase(a.begin()+distance(a.begin(),j));
      else a.push_back(num);
    }
  }
  cout << a.size() << endl;
}

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

public class Main {

	public static void main(String[] args) {

		//
		int taro_card_number = 0;
		String[] mark = { "spades", "heart", "clover", "diya" };
		String[] array_name = { "S", "H", "C", "D" };

		// // トランプの各マークの配列を作る//
		// for (String val : tramp) {
		// tramp val = new tramp();
		// }

		// トランプの各マークの配列を作る
		tramp spades = new tramp();
		spades.setMark("S");
		tramp.tramp_all.add(spades);

		tramp heart = new tramp();
		heart.setMark("H");
		tramp.tramp_all.add(heart);

		tramp clover = new tramp();
		clover.setMark("C");
		tramp.tramp_all.add(clover);

		tramp diya = new tramp();
		diya.setMark("D");
		tramp.tramp_all.add(diya);

		// テキスト入力
		Scanner sc = new Scanner(System.in);
		// タローが持っているカードの数
		while (sc.hasNext()) {
			taro_card_number = sc.nextInt();

			// ループ処理(カードの数だけ回す)
			for (int i = 0; i < taro_card_number; i++) {

				// 図柄
				String design = sc.next();
				// 数
				int number = sc.nextInt();

				for (tramp val : tramp.tramp_all) {

					// マークの指定に従い、数字を配列に格納
					if (design.equals(val.getMark())) {
						//
						int[] hoge = val.getCard();
						hoge[number - 1] = 1;
					}
				}

			}
			// //配列に入力情報が格納されたので、入力情報にないものをピックアップして出力

			// スペードから順にないものを出力
			for (tramp val : tramp.tramp_all) {
				// ないものをピックアップ
				for (int i = 0; i < 13; i++) {
					if (val.getCard()[i] == 0) {
						System.out.println(val.getMark()+ " " + (i + 1));
					}
				}
			}

		}
	}

}

// それぞれのマークについて扱う
class tramp {

	// マーク名
	private String mark = "";

	// 各マークのカードを作る
	private int[] card = new int[13];

	// 全部のカード
	public static ArrayList<tramp> tramp_all = new ArrayList<tramp>();

	// セッター
	public void setMark(String m) {
		mark = m;
		// tramp_all.add(m);
	}

	// ゲッター
	public String getMark() {
		return mark;
	}

	public int[] getCard() {
		return card;
	}

	// と数を取ってきて、配列に格納する
	public void set_property(int[] design, int number) {
		design[number - 1] = 1;
	}

}

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

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

int main()
{
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    sort(x.begin(), x.end());
    int min_cost = 1000000007;
    for (int p = x[0]; p <= x[x.size() - 1]; ++p)
    {
        int cost = 0;
        rep(i, n) cost += pow(x[i] - p, 2);
        min_cost = min(min_cost, cost);
    }
    cout << min_cost << endl;
    return 0;
}


Measured memory_bytes: 256
let words str =
  let len = String.length str in
  let buf = Buffer.create 10 in
  let rec loop cont = function
      i when i = len -> cont [Buffer.contents buf |> int_of_string]
    | i ->
      loop
        (match str.[i] with
         | ' ' ->
           let v = Buffer.contents buf |> int_of_string in
           Buffer.clear buf; (fun x -> cont (v::x))
         | c ->
           Buffer.add_char buf c; cont)
        (i+1)
  in loop (fun x -> x) 0

let bs x (a: int array) =
  let rec loop (i_min,i_max) =
    if i_min > i_max then false
    else
      let mid = (i_min+i_max)/2 in
      if a.(mid) = x then true
      else
        loop (if a.(mid) < x then mid+1,i_max else i_min,mid-1)
  in loop (0,(Array.length a) -1)

let () =
  let _ = read_int () in
  let s = read_line () |> words |> Array.of_list in
  let _ = read_int () in
  let t = read_line () |> words in
  List.fold_left (fun acc x -> if bs x s then acc+1 else acc) 0 t
  |> Printf.printf "%d\n"

Measured memory_bytes: 12128
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
	string S;
	cin >> S;
	string syear, smonth, sday;
	syear = S.substr(0, 4);
	smonth = S.substr(5,2);
	sday = S.substr(8, 2);
//	cout << syear <<" "<< smonth << " "<<sday << endl;
	int year, month, day;
	year = stoi(syear);
	day = stoi(sday);
	month = stoi(smonth);
	if (year < 2019) {
		cout << "Heisei";
	}
	else if (year > 2019) {
		cout << "TBD";
	}
	else {
		if (month <= 4)
			cout << "Heisei";
		else
			cout << "TBD";
	}
	
	return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};


int main(){

  int a,b;
  cin >> a >> b;
  cout << a*b - a - b + 1 << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;




@SuppressWarnings({"javadoc"})
public class Main
{

  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;
    String[]       in_str_split;

    int    in_H1;
    int    in_M1;
    int    in_H2;
    int    in_M2;
    int    in_K;
    int    in_index;

    int tmp;


    try
    {
      in_stream = new BufferedReader(new InputStreamReader(System.in));

      /*----------------
       * 引数
       *----------------*/
      in_str       = new String(in_stream.readLine());
      in_str_split = in_str.split(" ");

      in_index = 0;
      in_H1    = Integer.parseInt(in_str_split[in_index++]);
      in_M1    = Integer.parseInt(in_str_split[in_index++]);
      in_H2    = Integer.parseInt(in_str_split[in_index++]);
      in_M2    = Integer.parseInt(in_str_split[in_index++]);
      in_K     = Integer.parseInt(in_str_split[in_index++]);


      /*----------------
       * 計算
       *----------------*/
      tmp = ((in_H2 * 60) + in_M2) - ((in_H1 * 60) + in_M1) - in_K;

      System.out.println(String.valueOf(tmp));
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }



}





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

#define int ll

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

int32_t main() {
	int n, k;
	cin >> n >> k;
	vi a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		--a[i];
	}
	vi cycle;
	int p = 0;
	vi found(n);
	do {
		found[p] = 1;
		cycle.pb(p);
		p = a[p];
		//debug(p);
	}
	while(found[p] != 1);
	//debug(p);
	//cycle.pb(p);
	int siz = sz(cycle);
	if(k < siz) {
		cout << cycle[k] + 1 << '\n';
		return 0;
	}
	else {
		int tail = 0;
		vi c;
		int pos = 0;
		while(cycle[pos] != p) {
			tail++;
			pos++;
		}
		while(pos < sz(cycle)) {
			c.pb(cycle[pos]);
			pos++;
		}
		// for(int x : cycle)
		// 	cout << x << '\n';
		// cout << '\n';
		k -= tail;
	//	debug(k, tail, sz(c));
		siz = sz(c);
		k %= siz;
		//debug(k);
		cout << c[k] + 1 << '\n';
	}
}


Measured memory_bytes: 10660
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> v(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	int begin = 1, end = *max_element(v.begin(), v.end());
	while (begin < end) {
		// cout << begin << " " << end << endl;
		int m = (begin + end) / 2;
		long long int kk = 0;
		for (int i = 0; i < n; i++) {
			kk += v[i] / m + (v[i] % m > 0 ? 1 : 0) - 1;
		}
		if (kk <= k) {
			end = m;
		} else {
			begin = m + 1;
		}
	}
	cout << begin << endl;
}


Measured memory_bytes: 4040
S = str(input())
T = str(input())
length =len(S)
listS=list(S)
listT=list(T)
num = len(T)
res = 0
for i in range(length):
    if (listS[num-1] != listT[num-1]):
        res +=1
    num -=1
print(res)

Measured memory_bytes: 12492
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t a,b,n;
  cin >> a >> b >> n;
  int64_t x=min(n,b-1);
  int64_t ans=(int64_t)a*x/b-a*(int64_t)(x/b);
  cout << ans << endl;
}

Measured memory_bytes: 3636
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	private static FastScanner sc = new FastScanner();
	static Node[] V;
	static int time = 1;

	public static void main(String[] args) {
		int n = sc.nextInt();	
		
		V = new Node[n];
		for(int i=0; i<n; i++) {
			sc.nextInt();
			int k = sc.nextInt();
			int[] adj = new int[k];
			for(int j=0; j<k; j++) {
				adj[j] = sc.nextInt() - 1;
			}
			V[i] = new Node(adj);
		}
		
		for(int i=0; i<n; i++) {
			V[i].depthFirstSearch();
		}
		
		StringBuilder ans = new StringBuilder();
		for(int i=0; i<n; i++) {
			ans.append(i+1);
			ans.append(" ");
			ans.append(V[i].d);
			ans.append(" ");
			ans.append(V[i].f);
			ans.append("\n");
		}
		System.out.print(ans);
	}

	static class Node {	
		int d = -1;
		int f = -1;
		int[] adj;
		
		Node(int[] adj) {
			this.adj = adj;
		}
		
		public void depthFirstSearch() {
			if(d == -1) {
				d = time;
				time++;
			}
			for(int i=0; i<adj.length; i++) {
				if(V[adj[i]].d == -1) {
					V[adj[i]].depthFirstSearch();
				}
			}
			if(f == -1) {
				f = time;
				time++;
			}
		}
	}

	static class FastScanner {
	    private final InputStream in = System.in;
	    private final byte[] buffer = new byte[1024];
	    private int ptr = 0;
	    private int buflen = 0;
	    private boolean hasNextByte() {
	        if (ptr < buflen) {
	            return true;
	        }else{
	            ptr = 0;
	            try {
	                buflen = in.read(buffer);
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            if (buflen <= 0) {
	                return false;
	            }
	        }
	        return true;
	    }
	    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
	    public String next() {
	        if (!hasNext()) throw new NoSuchElementException();
	        StringBuilder sb = new StringBuilder();
	        int b = readByte();
	        while(isPrintableChar(b)) {
	            sb.appendCodePoint(b);
	            b = readByte();
	        }
	        return sb.toString();
	    }
	    public long nextLong() {
	        return Long.parseLong(next());
	    }
	    public int nextInt(){
	    	return Integer.parseInt(next());
	    }
	}
}

Measured memory_bytes: 24376
h, w = map(int, input().split())
C = [list(map(int, input().split())) for i in range(10)]
A = [list(map(int, input().split())) for i in range(h)]

# C[i][j]はiをjにするのに必要なコスト
# warshal-floyd
for k in range(10):
    for i in range(10):
        for j in range(10):
            C[i][j] = min(C[i][j], C[i][k] + C[k][j])
ans = 0
for i in range(h):
    for j in range(w):
        if A[i][j] == -1:
            ans += 0
        else:
            ans += C[A[i][j]][1]
print(ans)


Measured memory_bytes: 3444
#include<iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main()
{
	double a, b, angleC;
	cin >> a >> b >> angleC;
	angleC = angleC * 3.1415926 / 180;
	double area = a * b * sin(angleC) * 0.5;
	double c = sqrt(a * a + b * b - 2 * a * b * cos(angleC));
	cout << fixed << setprecision(8) << area << " " << a + b + c << " " << b * sin(angleC);

	return 0;
}


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

//Function Macros:
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main()
{
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> key;
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        int s = 0;
        rep(j, b)
        {
            int c;
            cin >> c;
            --c;
            s |= 1 << c; //和集合を取るため
        }
        key.emplace_back(s, a);
    }

    vector<int> dp(1 << n, INF); //2^nをとる
    dp[0] = 0;
    rep(s, 1 << n)
    {
        rep(i, m)
        {
            int t = s | key[i].first;
            int cost = dp[s] + key[i].second;
            dp[t] = min(dp[t], cost);
        }
    }
    int ans = dp.back();
    if (ans == INF)
        ans = -1;
    cout << ans << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 256
num=int(input())
ox=input()
ans=0
while True:
    if len(ox)<=1:
        break
    a=ox.find("OX",0,2)
    b=ox.find("XO",0,2)
    if a==0 or b==0:
        ox=ox[2:]
        ans+=1
    else:
        ox=ox[1:]

print(ans)


Measured memory_bytes: 5800
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] a = new int[n];
			int max = IntStream.range(0, n).map(i -> a[i] = scanner.nextInt()).max().getAsInt();
			System.out.println(max - Arrays.stream(a).min().getAsInt());
		}
	}
}


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

signed main(){
    int a,b,c,k,ans=0;
    cin>>a>>b>>c>>k;
    
    if(k>=a){
        ans+=a;
        k-=a;
    }
    else
        ans+=k;
        
    if(k>=b)
        k-=b;
    else{
        cout<<ans<<"\n";
        return 0;
    }
        
    ans-=k;
    cout<<ans<<"\n";
    return 0;
}


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

int main()
{
  int N;
  cin >> N;
  string s;
  string t;

  cin >> s;
  cin >> t;

  string sub;
  int kasa=0;
  for(int i=0; i < N; i++){
    sub = s.substr(i, N-i);
    if(sub == t.substr(0, N-i)){
      kasa = N-i;
      break;
    }
  }
  int ans = N + N - kasa;

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n, d[3003][3003] = {};
string s;
int main() {
    cin >> n >> s;
    for (int i = 0; i < n; i++) d[0][i] = 1;
    for (int i = 1; i < n; i++) {
        int a = 0;
        if (s[i - 1] == '<') {
            for (int j = 0; j < n - i; j++) {
                a = (a + d[i - 1][j]) % 1000000007;
                d[i][j] = (d[i][j] + a) % 1000000007;
            }
        } else {
            for (int j = n - i - 1; j >= 0; j--) {
                a = (a + d[i - 1][j + 1]) % 1000000007;
                d[i][j] = (d[i][j] + a) % 1000000007;
            }
        }
    }
    cout << d[n - 1][0] << '\n';
}


Measured memory_bytes: 35200
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef stack<ll> ST;
typedef queue<ll> QUE;
typedef priority_queue<ll> PQ;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    int N,M; scanf("%d %d",&N,&M);
    vector<bool> vis(N+1,false); vis[1]=true;
    vec n(N+1,1);
    rep(i,M){
        int x,y; scanf("%d %d",&x,&y);
        n[x]--;n[y]++;
        if(vis[x]){
            vis[y]=true;
            if(n[x]==0) vis[x]=false;
        }
    }
    int ans=0;
    FOR(i,1,N+1){
        if(vis[i]) ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;
int h[100005];
int d[100005];
int dp(int i, int n);

int main()
{
  memset(d,-1,sizeof d);
  int n;
  cin >> n;
  for(int i = 1; i <= n; i++) cin >> h[i];
  cout << dp(1, n) << endl;
}

int dp(int i, int n)
{
  //cout << i << endl;
  if(i == n) return 0;
  if(d[i] != -1) return d[i];
  if(i == n - 1)
  {
    d[i] = dp(i + 1, n) + abs(h[i + 1] - h[i]);
    return d[i];
  }
  d[i] = min(dp(i + 1, n) + abs(h[i + 1] - h[i]), dp(i + 2, n) + abs(h[i + 2] - h[i]));
  return d[i];
}

Measured memory_bytes: 3328
#include<stdio.h>
int main(void){
    int x,h,m,s;
    
    scanf("%d",&x);
    h=x/3600;
    m=(x%3600)/60;
    s=x%60;
    
    printf("%d:%d:%d\n",h,m,s);
    
    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
using namespace std;
int main(void){
    int a, b, N, s[100]={}, f[100]={}, i, x=0;
    cin >> a >> b >> N;
    for(i=0; i<N; i++){
        cin >> s[i] >> f[i];
        if(b > s[i] && a < f[i]){
            x=1;
            break;
        }
    }
    if(x == 1) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}



Measured memory_bytes: 3108
#!/usr/bin/env python3

n = int(input())
a = list(map(int, input().split()))

def rank(n):
    if 1 <= n <= 399:
        return 'gray'
    elif 400 <= n <= 799:
        return 'brown'
    elif 800 <= n <= 1199:
        return 'green'
    elif 1200 <= n <= 1599:
        return 'skyblue'
    elif 1600 <= n <= 1999:
        return 'blue'
    elif 2000 <= n <= 2399:
        return 'yellow'
    elif 2400 <= n <= 2799:
        return 'orange'
    elif 2800 <= n <= 3199:
        return 'red'
    else:
        return 'others'

colors = [rank(a[i]) for i in range(n)]
numother = colors.count('others')
colors = set(colors)

if 'others' in colors:
    colors.remove('others')
    minimum = len(colors)
    tmp = minimum
    if minimum == 0:
        minimum = 1 
    maximum = tmp + numother
else:
    minimum = len(colors)
    maximum = minimum

print(minimum, maximum)


Measured memory_bytes: 9064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Word
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		int W = parseInt(br.readLine());

		System.out.println(W * 32);
	}
}

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

using namespace std;
typedef long long ll;
int n;
const int maxN = (int)1e5 + 100;
multiset < int > g[maxN];
int m;
int deg[maxN];
void bad() {
    cout << "No";
    exit(0);
}
int main() {
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int x, y;
        cin >> x >> y;
        g[x].insert(y);
        g[y].insert(x);
        deg[x]++;
        deg[y]++;
    }
    queue < int > q;
    for (int i = 1; i <= n; i++) {
        if (deg[i] % 2 != 0) {
            bad();
        }
        if (deg[i] == 2) {
            q.push(i);
        }
    }
    int need = 3;
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        if (deg[v] == 0) continue;
        vector < int > all;
        for (int x : g[v]) all.push_back(x);
        if (all[0] == all[1]) {
            need--;
            for (int i = 0; i < 2; i++) {
                g[all[0]].erase(g[all[0]].find(v));
                g[v].erase(g[v].find(all[0]));
                deg[all[0]]--;
                deg[v]--;
            }
            g[v].clear();
            if (deg[all[0]] == 2) {
                q.push(v);
            }
        }
        else {
            for (int i = 0; i < 2; i++) {
                g[all[i]].erase(g[all[i]].find(v));
                deg[v]--;
                g[all[i]].insert(all[i ^ 1]);
            }
        }
        g[v].clear();
    }
    if (need <= 0) {
        cout << "Yes";
        return 0;
    }
    int cnt = 0;
    int ed = 0;
    for (int i = 1; i <= n; i++) {
        if (deg[i] != 0) {
            cnt++;
            ed += deg[i];
        }
    }
    if (ed / 4 >= need) {
        cout << "Yes";
        return 0;
    }
    bad();
    return 0;
}

Measured memory_bytes: 15104
N = int(input())
li = list(map(int,input().split()))
lia = li[:]
lia.sort()
index1 = int(N/2)
index2 = int((N-2)/2)
ave1 = lia[index2]
ave2 = lia[index1]
for i in range(N) :
    if li[i] <= ave1 :
        print(ave2)
    else :
        print(ave1)

Measured memory_bytes: 25220
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,r,c,tl[100111],tr[100111],ord[100111];
int getid(int x,int y)
{
	if(x==0)return y+1;
	if(y==c)return x+c+1;
	if(x==r)return c-y+r+c+1;
	if(y==0)return r+c+c+r-x+1;
	return 0;
}
vector<int> v;
int ri[200111],bit[200111];
void add(int x){for(;x<200111;x+=x&-x)bit[x]++;}
int query(int x){int ret=0;for(;x>0;x-=x&-x)ret+=bit[x];return ret;}
int main()
{
	v.pb(0);
	int nn;
	get3(r,c,nn);
/*	for(int i=0;i<=r;i++)
	{
		for(int j=0;j<=c;j++)
		{
			printf("%04d ",getid(i,j));
		}
		puts("");
	}
*/	for(int i=1;i<=nn;i++)
	{
		int x,y,xx,yy;get2(x,y);get2(xx,yy);
		tl[n+1]=getid(x,y);tr[n+1]=getid(xx,yy);
		if(tl[n+1]&&tr[n+1])
		{
			n++;
			if(tl[n]>tr[n])swap(tl[n],tr[n]);
			v.pb(tl[n]);v.pb(tr[n]);
			ord[n]=n;
		}
	}
	sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end());
	for(int i=1;i<(int)v.size();i++)ri[i]=i;
	for(int i=1;i<=n;i++)
	{
		tl[i]=lower_bound(v.begin(),v.end(),tl[i])-v.begin();
		tr[i]=lower_bound(v.begin(),v.end(),tr[i])-v.begin();
		ri[tl[i]]=max(ri[tl[i]],tr[i]);
	}
	for(int i=1;i<(int)v.size();i++)
	{
		int cnt=query(ri[i])-query(i);
		if(cnt)
		{
			puts("NO");
			return 0;
		}
		add(ri[i]);
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include<bitset>

using namespace std;
#define loop(i,n) for(int i = 0; i < (n); ++i)
#define loops(i,f,n) for(int i = (f); i < (n); ++i)
#define INF 9999999
#define lint long long int
#define VEC vector<int>
#define VEC2 vector<vector<int>>

int main()
{
	int h, w;
	while (cin >> h >> w)
	{
		if (h*w)
		{
			loop(i, h)
			{
				loop(j, w)
				{
					if(i==0||j==0||i==h-1||j==w-1)cout << "#";
					else cout << ".";
				}
				cout << endl;
			}
			cout << endl;
		}
		else break;
	}
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> a(3);
  for(int i=0;i<3;i++){
    int b;
    cin >> b;
    a.at(i) = b;
  }
  sort(a.begin(),a.end());
  cout << a.at(2) - a.at(0) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> B(N - 1);
  for(int i = 0;i < N - 1;i++){
    cin >> B.at(i);
  }
  vector<int> A(N);
  A.at(0) = B.at(0);
  for(int i = 1;i < N - 1;i++){
    A.at(i) = min(B.at(i - 1),B.at(i));
  }
  A.at(N - 1) = B.at(N - 2);
  long long ans = 0;
  for(int i = 0;i < N;i++){
    ans += A.at(i);
  }
  cout << ans << endl;
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int x[n];
    for(int i = 0; i < n; i++)
    {
        cin >> x[i];
    }
    int ans = 1e9;
    for(int i = 0; i <= 100; i++)
    {
        int curr_ans = 0;
        for(int j = 0; j < n; j++)
        {
            curr_ans += (x[j] - i) * (x[j] - i);
        }
        ans = min(ans, curr_ans);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int N;	
	while(cin >> N, N){
		int m[21][21] = {0};
		for(int i = 0; i < N; ++i){
			int x, y; 
			cin >> x >> y;
			++m[x][y];	
		}
		int px = 10, py = 10;
		int M;
		cin >> M;
		int ans = m[px][py];
		for(int i = 0; i < M; ++i){
			char d; int l;
			cin >> d >> l;
			int dx = d == 'E' ? 1 : d == 'W' ? -1 : 0;
			int dy = d == 'N' ? 1 : d == 'S' ? -1 : 0;
			for(int j = 0; j < l; ++j){
				px += dx, py += dy;
				ans += m[px][py];
				m[px][py] = 0;	
			}
		}
		if (ans == N) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 3076