akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int INF = 1001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> rs(n), bs(n);
    for (int i = 0; i < n; i++)
    {
        int x, y;
        cin >> x >> y;
        rs[i].second = x;
        rs[i].first = y;
    }
    for (int i = 0; i < n; i++)
    {
        int x, y;
        cin >> x >> y;
        bs[i].first = x;
        bs[i].second = y;
    }
    sort(rs.begin(), rs.end());
    sort(bs.begin(), bs.end());
    reverse(rs.begin(), rs.end());
    vector<bool> used(n, false); // 赤の点が使用済みかを保存する

    int ans = 0;
    for (int i = 0; i < n; i++) // 青の点を順番に走査
    {
        for (int j = 0; j < n; j++) // 赤の点を順番に走査
        {
            if (!used[j] && bs[i].first > rs[j].second && bs[i].second > rs[j].first)
            {
                used[j] = true;
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll a,b,c;
	cin>>a>>b>>c;
	if(a%2&&b%2&&c%2){
		cout<<min(a*b,min(b*c,c*a));
	}else cout<<"0";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n;
    cin >> n;
    map<string, ll> mp;
    rep(i, n) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        ++mp[s];
    }
    ll ans = 0;
    for ( auto p : mp) {
        ans += p.second * ( p.second - 1 ) / 2LL;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11136
n, m  = (int(x) for x in input().split())
max_l = 0
min_r = 10000000
for i in range(0, m):
  a, b = (int(x) for x in input().split())
  if(max_l < a):
    max_l = a
  if(b < min_r):
    min_r = b

ret = min_r - max_l + 1
if ret < 0:
  ret = 0

print(ret)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define Vsort(a) sort(a.bigin(), a.end())
#define rep(i,n) for(int i = 0; i < (n); i++)
 
using namespace std;
using ll = long long;

int main(){
  int n;
  cin >> n;
  n = n % 10;
  if((n == 2)||(n == 4)||(n == 5)||(n == 7)||(n == 9)) cout << "hon";
  else if ((n == 0)||(n == 1)||(n == 6)||(n == 8)) cout << "pon";
  else cout << "bon";
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    int n;
    cin>>n;
    set<string> st;
    rep(i, n) {
        string s;
        cin>>s;
        st.insert(s);
    }
    cout<<st.size()<<endl;
}

Measured memory_bytes: 19288
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = 1e9;
const ll MOD = 1e9 + 7;

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




/******************************************************************************************/


int main() {

	

	string s;
	cin >> s;
	bool flag1 = true;
	bool flag2 = true;
	for (int i = 0; i < s.size(); i++)
	{
		if (i % 2 == 0) {
			//これが奇数番目
			if (s[i] == 'L') {
				flag1 = false;
			}
		}
		else
		{
			//偶数番目
			if (s[i] == 'R') {
				flag2 = false;
			}
		}
	}

	if (flag1 && flag2) {
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}





	return 0;
}


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

int main(){
    int A,B;
    int cnt=0;
    cin >> A >> B;
    
    int outlet=1;
    int ans=0;

    while(outlet<B){
        outlet--;
        outlet+=A;
        ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <deque>
using namespace std;

int main() {
	deque<int> A;
	int num_query; scanf("%d", &num_query);
	int command, arg1, arg2;
	for (int loop = 0; loop < num_query; loop++) {
		scanf("%d", &command);
		switch (command) {
		case 0:
			scanf("%d %d", &arg1, &arg2);
			if (arg1 == 0) {
                A.emplace_front(arg2);
            } else {
                A.emplace_back(arg2);
            }
			break;
		case 1:
			scanf("%d", &arg1);
			printf("%d\n", A[arg1]);
			break;
		case 2:
			scanf("%d", &arg1);
			if (arg1 == 0) {
				A.pop_front();
			} else {
				A.pop_back();
			}
			break;
    	}
	}
	return 0;
}


Measured memory_bytes: 4164
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

constexpr int INF = 1e9;
constexpr int MOD = INF + 7;
constexpr LL LLINF = 1e18;

const int MAX_N = 222;
const int MAX = 1e5 + 10;
int N;
int X;
int S[MAX_N];

LL dp[MAX_N][MAX];

int main(void) {
    cin >> N >> X;
    REP(i, N) cin >> S[i];
    sort(S, S + N);
    reverse(S, S + N);

    dp[0][X] = 1;
    REP(i, N) {
        REP(j, X + 1) {
            (dp[i + 1][j] += dp[i][j] * (N - 1 - i)) %= MOD;
            (dp[i + 1][j % S[i]] += dp[i][j]) %= MOD;
        }
    }

    LL ans = 0;
    REP(i, X + 1) {
        (ans += dp[N][i] * i) %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 157184
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;

bool next(bool[][] m, int x, int y){
	auto s = new bool[][](10+4, 10+4);
	foreach(i; -1..2){
		foreach(j; -1..2){
			s[x+i][y+j] = true;
		}
	}
	foreach(i; 0..10+4){
		s[i][0] = false;
		s[i][1] = false;
		s[i][12] = false;
		s[i][13] = false;
		s[0][i] = false;
		s[1][i] = false;
		s[12][i] = false;
		s[13][i] = false;
	}
	auto t = new bool[][](14,14);
	foreach(i; 2..12) {
		foreach(j; 2..12) {
			if(m[i][j]){
				t[i+2][j-1] = true;
				t[i+2][j] = true;
				t[i+2][j+1] = true;
				t[i-2][j-1] = true;
				t[i-2][j] = true;
				t[i-2][j+1] = true;
				t[i-1][j+2] = true;
				t[i][j+2] = true;
				t[i+1][j+2] = true;
				t[i-1][j-2] = true;
				t[i][j-2] = true;
				t[i+1][j-2] = true;
			}
		}
	}
	bool ret;
	foreach(i; 2..12) {
		foreach(j; 2..12) {
			m[i][j] = t[i][j] && s[i][j];
			ret |= m[i][j];
		}
	}
	return ret;
}

void main() {
	auto xy = map!(to!int)(readln().strip().split());
	while(xy[0]|xy[1]){
		auto m = new bool[][](10+4,10+4);
		m[xy[0]+2][xy[1]+2] = true;
		int n = to!int(readln().strip());
		auto s = map!(to!int)(readln().strip().split());
		bool f = true;
		foreach(i; 0..n){
			f &= next(m, s[i*2]+2, s[i*2+1]+2);
		}
		writeln(f?"OK":"NA");
		xy = map!(to!int)(readln().strip().split());
	}
}

Measured memory_bytes: 1092
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

N, L = [int(x) for x in stdin.readline().rstrip().split()]

# リンゴiの味は L+i-1
taste = []
for i in range(1, N+1):
    taste.append(L+i-1)

if 0 in taste:
    print(sum(taste))
    exit()

if abs(taste[0]) < abs(taste[-1]):
    print(sum(taste[1:]))
else:
    print(sum(taste[:N-1]))

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

int main(){
int N,L;
  cin>>N>>L;
  vector<string> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  for(int i=0;i<N;i++){
    cout<<vec.at(i);
  }
}
    

Measured memory_bytes: 256
#include<stdio.h>

// SUB ID: UG02-53-20-001

int main()
{
    int A, B, C;
    scanf("%d%d%d",&A,&B,&C);
    if (A==B){
        printf("%d",C);

    }
    else if (B==C)
        {
        printf("%d",A);
    }
    else printf("%d",B);



    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void){
  int a[10];
  int n,i,j,tmp,sum=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(a[i]>a[j]){
        tmp = a[i];
        a[i] = a[j];
        a[j] = tmp;
      }
    }
  }
  for(i=0;i<n-1;i++){
    sum += a[i];
  }
  if(a[n-1]<sum){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

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

#define all(c) (c).begin(),(c).end()
#define FOR(i, x, n) for(int i = x; i < (int)n; i++)
#define REP(i, n) FOR(i, 0, n)
#define debug(x) #x << "=" << (x) << "(L" << __LINE__ << ")"
#define show(x) cout << #x << "=" << x << endl
#define show2(x,y) cout << #x << "=" << x << "," << #y << "=" << y <<  endl
#define show3(x,y,z) cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z <<  endl
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;

const ld eps = 1e-9, pi = acos(-1.0);
const ld EPS = 1e-8;
const int INF = INT_MAX/2;
const ll LINF = LONG_MAX/2;
const int MOD = 1000000007;

template<class T> inline void amin(T &a, const T &b) { if (b<a) a=b; }
template<class T> inline void amax(T &a, const T &b) { if (a<b) a=b; }

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
    
    ll n;
    cin >> n;
    
    vector<ll> p(n);
    
    rep(i,n){
        ll t;
        cin >> p.at(i);
    }
    
	int ans = 0;
    //cout << fixed << setprecision(10);
    FOR(i,1,n-1){
        if((p[i-1]>=p[i] && p[i]>=p[i+1]) ||(p[i-1]<=p[i] && p[i]<=p[i+1])){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int n;
ll g=1,t[105];
int main(void){
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%lld",t+i);
    for(int i=0;i<n;i++){
        ll s=gcd(max(g,t[i]),min(g,t[i]));
        g=g/s*t[i];
    }
    printf("%lld\n",g);
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    int ans = (n - 1) / 2;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	for(int i=a;i<=b;i++){
		if(i%n==0){
			cout<<"OK\n";
			return 0;
		}
	} 
	cout<<"NG"<<endl;
} 

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

using namespace std;
using ll = long long;
int main() {
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    for (int i = k; i < n; ++i) {
        if(a[i]>a[i-k])cout<<"Yes\n";
        else cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
#define rep(i,b) for(i=0;i<b;++i)
#define repp(i,a,b) for(i=a;i<b;++i)
#define endl "\n"
//#define LLONG_MAX 99999999999999
typedef long long int lli;
int main(){
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    lli n,i,j,b,a,q,m;
    lli t=1;
    n=5;
    rep(i,n){
			cin>>a;
			if(a==0){
				b=i+1;
			}
    }
    cout<<b<<endl;


}



Measured memory_bytes: 3584
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


ll ma=1e15;




int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string a,b;
cin>>a>>b;
int n=a.size(),m=b.size();
int dp[n+1][m+1];
memset(dp,0,sizeof(dp));
int pa[n+1][m+1];
for(int i=n-1;i>=0;i--){
        for(int j=m-1;j>=0;j--){
            if(a[i]==b[j]){
                dp[i][j]=dp[i+1][j+1]+1;
                pa[i][j]=3;

            }
            else{
                if(dp[i+1][j]>dp[i][j+1]){
                    dp[i][j]=dp[i+1][j];
                    pa[i][j]=2;
                }
                else{
                    dp[i][j]=dp[i][j+1];
                    pa[i][j]=1;
                }
            }

        }

}
int i=0,j=0;
while(i<n && j<m){
    if(pa[i][j]==3){
        cout<<a[i];
        i++,j++;
    }
    else{
            int x=pa[i][j];
        i+=x/2,j+=x%2;
    }
}





}


Measured memory_bytes: 70656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            Console.WriteLine(1 / Console.ReadLine().Split(' ').Select(num => 1 / double.Parse(num)).Sum());
        }

    }
}

Measured memory_bytes: 28404
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#include <utility>
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1e9
typedef long long int ll;
using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;

    if(2*(k-1)+1<=n)  cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

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

void Main() {
    // input
    string s;
    cin >> s;


    // translate


    // output
    if (s[1] == 'B') {
        cout << "ARC" << endl;
    } else if (s[1] == 'R') {
        cout << "ABC" << endl;
    } else {
        cout << "Error" << endl;
    }

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()

ll power(ll b,ll e,ll m)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
} 

#define N 100010

void solve()
{
  ll n,m,h[N],ma[N];
  cin>>n>>m;
  rep(i,1,n+1)
  {
    cin>>h[i];
    ma[i]=0;
  }
  rep(i,0,m)
  {
    ll a,b;
    cin>>a>>b;
    ma[a]=max(ma[a],h[b]);
    ma[b]=max(ma[b],h[a]);
  }
  ll ans=0;
  rep(i,1,n+1)
  ans+=h[i]>ma[i];
  cout<<ans<<"\n";
}
int main()       
{
  fastio
  ll tt=1;
  while(tt--)
  {
    solve();
    cout<<"\n";
  }
  return 0;
}

Measured memory_bytes: 5060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll MAX_N=100;

ll N,a[MAX_N];

int main(){
  ll N;
  cin>>N;
  for(ll i=0;i<N;i++){
    cin>>a[i];
  }
  sort(a,a+N);
  cout<<a[N-1]-a[0]<<endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = input().split()
already = [False] * (10**5+1)
dup_count = 0
for a in A:
    a = int(a)
    if not already[a]:
        already[a] = True
    else:
        dup_count += 1

if dup_count % 2 == 0:
    print(N - dup_count)
else:
    print(N - dup_count - 1)


Measured memory_bytes: 51248
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pi pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pii(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
int no=0;
bool compare(int a,int b)
{   
	return (a%2==1)&&(b%2==0);
}
int main()
{
	ios;
	ll w,h,x,y;
	cin>>w>>h>>x>>y;
	cout<<fixed<<setprecision(9)<<(w*h)/double(2)<<" ";
	if(w%2==0&&h%2==0&&h/2==y&&w/2==x)
		 cout<<1;
    else 
        cout<<0;		
}


Measured memory_bytes: 256
#include <stdio.h>

typedef struct List {
	struct List *next;
	int v;
} list;

int main()
{
	int i, N, M, u, w, deg[2][601] = {};
	list *adj[601] = {}, *adj_inv[601] = {}, e[360001], *p;
	scanf("%d %d", &N, &M);
	for (i = 0; i < M; i++) {
		scanf("%d %d", &u, &w);
		e[i*2].v = w;
		e[i*2+1].v = u;
		e[i*2].next = adj[u];
		e[i*2+1].next = adj_inv[w];
		adj[u] = &(e[i*2]);
		adj_inv[w] = &(e[i*2+1]);
		deg[0][u]++;
		deg[1][u]++;
	}
	
	int q[601], head, tail;
	long double dp[601][601] = {};
	for (i = 1, tail = 0; i <= N; i++) if (deg[0][i] == 0) q[tail++] = i;
	for (head = 0; head < tail; head++) {
		u = q[head];
		if (deg[0][u] != 0) {
			for (p = adj[u]; p != NULL; p = p->next) {
				dp[u][u] += dp[p->v][p->v];
				for (i = 0; i < head; i++) dp[u][q[i]] += dp[p->v][q[i]] / deg[0][u];
			}
			dp[u][u] = dp[u][u] / deg[0][u] + 1.0;
		}
		
		for (p = adj_inv[u]; p != NULL; p = p->next) {
			deg[1][p->v]--;
			if (deg[1][p->v] == 0) q[tail++] = p->v;
		}
	}
	
	long double ans = dp[1][1], max, sum;
	if (deg[0][1] > 1) {
		for (p = adj[1], max = 0.0, sum = 0.0; p != NULL; p = p->next) {
			sum += dp[p->v][p->v];
			if (max < dp[p->v][p->v]) max = dp[p->v][p->v];
		}
		if (ans > (sum - max) / (deg[0][1] - 1) + 1.0) ans = (sum - max) / (deg[0][1] - 1) + 1.0;
	}
	for (head--; q[head] != 1; head--);
	for (head--; head >= 0; head--) {
		u = q[head];
		if (deg[0][u] > 1) {
			for (p = adj[u], max = 0.0, sum = 0.0; p != NULL; p = p->next) {
				sum += dp[p->v][p->v];
				if (max < dp[p->v][p->v]) max = dp[p->v][p->v];
			}
			if (ans > dp[1][1] - (dp[u][u] - (sum - max) / (deg[0][u] - 1) - 1.0) * dp[1][u] / dp[u][u]) ans = dp[1][1] - (dp[u][u] - (sum - max) / (deg[0][u] - 1) - 1.0) * dp[1][u] / dp[u][u];
		}
	}
	
	printf("%.7Lf\n", ans);
	fflush(stdout);
	return 0;
}

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

int main(){
	int S;
	cin>>S;
	int ante = S/100;
	int poste = S-(S/100)*100;
	if (ante>=1 && ante<=12 && poste>=1 && poste<=12){
	    cout<<"AMBIGUOUS"<<endl;
    }else if((ante>=13 || ante==0) && poste>=1 && poste<=12){
    	cout<<"YYMM"<<endl;
    }else if(ante>=1 && ante<=12 && (poste>=13 || poste==0)){
    	cout<<"MMYY"<<endl;
    }else{
    	cout<<"NA"<<endl;
    }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int check(string s, string t){
  vector<bool> used(s.size(), false);

  rep(i,s.size()){
    if(used[i]) continue;
    char sc = s[i];
    char tc = t[i];
    rep(j,s.size()){
      if(i==j) continue;
      if(used[j]) continue;
      char sb = s[j];
      char tb = t[j];
      if(sc == tb && tc == sb){
        used[i] = true;
        used[j] = true;
        break;
      }
    }
  }
  int cnt = 0;
  rep(i,s.size()){
    if(used[i]){
      cnt++;
    }
  }
  return cnt;
}


int main(){
  int H, W;
  cin >> H >> W;
  vector<string> v;
  rep(i,H){
    string s;
    cin >> s;
    v.push_back(s);
  }

  vector<vector<int>> w;
  rep(i,H){
    vector<int> tmp;
    rep(j,H){
      if(i==j) continue;
      int res = check(v[i],v[j]);
      if((W%2==0 && res == W) || (W%2==1 && res == W-1)){
        tmp.push_back(j);
      }

    }
    w.push_back(tmp);
  }

  vector<bool> used(H, false);
  vector<pair<int,int>> pr;
  rep(i,H){
    if(used[i]) continue;
    rep(j,w[i].size()){
      if(used[w[i][j]]) continue;
      pr.push_back(make_pair(i,w[i][j]));
      used[i] = true;
      used[w[i][j]] = true;
      break;
    }
  }
  int cnt = 0;
  rep(i,H){
    if(used[i]) cnt++;
  }

  if((H%2==0 && cnt != H) || (H%2==1 && cnt != H-1)){
    cout << "NO" << endl;
    return 0;
  }
  if(pr.size() == 0){
    cout << "YES" << endl;
    return 0;
  }

  vector<bool> used2(W,false);
  int base1 = pr[0].first;
  int base2 = pr[0].second;
  rep(j,W){
    if(used2[j]) continue;
    
    REP(k,j+1,W){
      if(v[base1][j] == v[base2][k] && v[base2][j] == v[base1][k]){
        bool flg = true;
        REP(l,1,pr.size()){
          int tr1 = pr[l].first;
          int tr2 = pr[l].second;
          if(v[tr1][j] == v[tr2][k] && v[tr2][j] == v[tr1][k]){
            ;//ok
          }else{
            flg = false;
          }
        }

        if(flg){
          used2[j] = true;
          used2[k] = true;
          break;
        }
      }
    }
  }
  cnt = 0;
  rep(i,W){
    if(used2[i]) cnt++;
  }

  if((W%2==0 && cnt != W) || (W%2==1 && cnt != W-1)){
    cout << "NO" << endl;
    return 0;
  }
  
  cout << "YES" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>

int main(){
    std::map<char, std::string> mp;
    std::cin >> mp['a'] >> mp['b'] >> mp['c'];

    char turn = 'a';
    char top;
    while(1){
       if(mp[turn].length() == 0)break; 

       top = turn;
       turn = mp[turn][0];
       mp[top].erase(mp[top].begin());
    }

    std::cout << (char)(turn - 32) << std::endl;
}


Measured memory_bytes: 256
def gcd(a,b)
  return a if b == 0
  gcd(b, a % b)
end

N = gets.strip.to_i
as = gets.strip.split.map(&:to_i)

from_left = [as[0]]
from_right = [as[-1]]

(N - 1).times do |i|
  from_left[i+1] = gcd(from_left[i], as[i+1])
  from_right[i+1] = gcd(from_right[i], as[-2-i])
end

max = [from_right[N-2], from_left[N-2]].max
1.upto(N-2) do |i|
  gcd_without_i = gcd(from_left[i-1], from_right[N-i-2])
  max = gcd_without_i if gcd_without_i > max
end
puts max


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  ll n, d1, d2;
  cin >> n;
  int num = 0;
  for(int i = 0; i < n; ++i)
  {
    cin >> d1 >> d2;
    if (d1 == d2) num++;
    else num = 0;
    if (num >= 3)
    {
      cout << "Yes";
      return;
    }
  }
  cout << "No";
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <functional>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
 
#define REP(i,b,n) for(int i=b;i<n;i++)
#define REPR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PB push_back
#define MP make_pair
 
using namespace std;
 
static const double PI = acos(-1.0);
static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> pii;   
 
int main(){
     
    string str;
    cin>>str;
     
    int cnt[512]={0};
     
    for(int i=0; i<str.size(); ++i){
         
        cnt[(int)(str[i])]++;
    }
     
    cout << min(cnt[(int)('K')], min(cnt[(int)('U')], min(cnt[(int)('P')], cnt[(int)('C')]))) << endl;
     
    return 0;   
}

Measured memory_bytes: 1188
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>
#include <random>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ld d, t, s;
    cin >> d >> t >> s;
    if(d / s <= t){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl; 
    }
}   

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
   int n,m;
   cin>>n>>m;
   vector<int>broken(n+1);
   rep(i,m){
       int a;
       cin>>a;
       broken[a]=1;
   }
   vector<int>dp(n+2);
   const int mod=1000000007;
   dp[n]=1;
   for(int i=n-1;i>=0;i--){
       if(broken[i]){
           dp[i]=0;
           continue;
       }
       dp[i]=(dp[i+1]+dp[i+2])% mod;
   }
   cout<<dp[0]<<endl;
   return 0;
}

Measured memory_bytes: 1024
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        mut a: [u64; n],
    }
    let mut check = vec![0; n];
    let mut tmp = 1u64;

    loop {
        check[(tmp - 1) as usize] = 1;
        tmp = a[(tmp - 1) as usize];
        if tmp == 2 {
            break;
        }
        if check[(tmp - 1) as usize] == 1 {
            println!("-1");
            return;
        }
    }
    println!("{}", check.iter().filter(|x| *x == &1).count())
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)

int main(void){
    double n;
    cin >> n;
    rep(i,50000){
        if (int(i*1.08) == n){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	int n, i;
	cin >> n >> i;
	cout << n - i + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0 && c>0)
    {
        c=c-b;
        if(c<=0)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
        a=a-d;
        if(a<=0)
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>

int H,A[500000];
void buildMaxHeap(void);
void maxHeapify(int);
int left(int);
int right(int);

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

  buildMaxHeap();

  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");

  return 0;
}


void buildMaxHeap(){
  int i,j;
  j = H/2;
  for(i=j;i!=0;i--){
    maxHeapify(i);
  }
}

void maxHeapify(int i){
  int l,r,largest,tmp;

  l = left(i);
  r = right(i);
  if(l <= H && A[l] > A[i]){
    largest = l;
  }
  else largest = i;
  if(r <= H && A[r] > A[largest]){
    largest = r;
  }
  if(largest != i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }
}
    
int left(int i){
  int a;
  a = 2*i; 
  return a;
}

int right(int i){
  int b;
  b = 2*i+1;
  return b;
}



Measured memory_bytes: 3692
//a
#include <iostream>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <functional>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
 
#define REP(i,b,n) for(int i=b;i<n;i++)
#define REPR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PB push_back
#define MP make_pair
 
using namespace std;
 
static const double PI = acos(-1.0);
static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> pii;   
     
int n, p[4];
int yard[5000][5000];
     
int main(){
     
    cin >> n;
     
    for(int i=0; i<4; ++i){
        cin >> p[i];
        p[i]--;
    }
     
    int tmp, res = INT_MAX;
     
    for(int w=n; w>0; --w){
         
        tmp = abs(p[0]/w - p[1]/w) +  abs(p[0]%w - p[1]%w) 
            + abs(p[2]/w - p[3]/w) +  abs(p[2]%w - p[3]%w);
         
        res = min(res, tmp);
    }
     
    cout << res << endl;
     
    return 0;   
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

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


int main(){
    int n;  cin >> n;
    vector<P> v1, v2;

    bool l0Exist = false, r0Exist = false;
    for(int i = 0; i < n; i++){
        string s;   cin >> s;
        int l = 0, r = 0;
        int lMax = 0, rMax = 0;
        for(int j = 0; j < s.length(); j++){
            if(s[j] == ')'){
                if(l > 0)   l--;
                else r++;
                rMax = max(r, rMax);
            }
            else{
                l++;
            }
        }

        l = 0; r = 0;
        for(int j = s.length()-1; j >= 0; j--){
            if(s[j] == '('){
                if(r > 0)   r--;
                else l++;
                lMax = max(l, lMax);
            }
            else{
                r++;
            }
        }

        if(lMax == 0 && rMax == 0){
            continue;
        }

        if(rMax > lMax){
            v1.emplace_back(P(lMax, rMax));
        }
        else{
            v2.emplace_back(P(rMax, lMax));
        }

        if(lMax == 0){
            l0Exist = true;
        }
        if(rMax == 0){
            r0Exist = true;
        }
    }

    if(v1.empty() && v2.empty()){
        cout << "Yes" << endl;
        return 0;
    }
    if(!l0Exist || !r0Exist){
        cout << "No" << endl;
        return 0;
    }

    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());

    int cuml = 0;
    for(auto x: v1){
        if(cuml < x.fs){
            cout << "No" << endl;
            return 0;
        }
        cuml += x.sc - x.fs;
    }

    int cumr = 0;
    for(auto x: v2){
        if(cumr < x.fs){
            cout << "No" << endl;
            return 0;
        }
        cumr += x.sc - x.fs;
    }

    if(cuml == cumr){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 11196
import java.util.Scanner;

class Main{
  public static void main(String[] arg){
    Scanner scan=new Scanner(System.in);
    int a=scan.nextInt();
    int b=scan.nextInt();
    int c=scan.nextInt();
    if(a+b+c>=22){
      System.out.println("bust");
    }else{
      System.out.println("win");
    }
  }
}

Measured memory_bytes: 21716
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
ll dp[2][4];
int now = 0;
int t[3];
ll p2[32];
bool use[100010];
void Sequence() {

	int n;
	cin >> n;
	ll a[100010];
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	ll r1 = 0;
	ll v = 0;
	int np = 1;
	for (size_t i = 0; i < n; i++)
	{
		v += a[i];
		if(np > 0 && v <= 0){
			r1 += abs(v) + 1;
			v = 1;
		}
		else if (np < 0 && v >= 0) {
			r1 += abs(v) + 1;
			v = -1;
		}
		np *= -1;
	}
	ll r2 = 0;
	np = -1;
	ll v2 = 0;
	for (size_t i = 0; i < n; i++)
	{
		v2 += a[i];
		if (np > 0 && v2 <= 0) {
			r2 += abs(v2) + 1;
			v2 = 1;
		}
		else if (np < 0 && v2 >= 0) {
			r2 += abs(v2) + 1;
			v2 = -1;
		}
		np *= -1;
	}
	cout << min(r1, r2) << endl;
}
int main() {
	Sequence();
	return 0;
}



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

int t,x,y,z;

int main() {
	cin >> x >> y >> z;
	for (int a = y; a <= z; a++) {
		if (a%x == 0) {
			cout << "OK\n";
			exit(0);
		}
	}
	cout << "NG\n";
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <stdio.h>
#include <cstdlib>
using namespace std;

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

Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        //２つの整数 a, b を読み込んで、a と b の大小関係を出力するプログラムを作成して下さい。 
        var x = Console.ReadLine().Split(' ');
        int a = int.Parse(x[0]);
        int b = int.Parse(x[1]);

        Console.WriteLine("a {0} b", a > b ? ">" : a < b ? "<": "==");
    }
}


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

using namespace std;

#define endl '\n'

typedef long long int64;
typedef pair<int64,int64> pii;
typedef vector<int> vi;

const double eps = 1e-9;
const int oo = 0x3f3f3f3f;
const int mod = 1000000007;

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

    int64 n, k;
    cin >> n >> k;

    vector<vector<pii>> nxt(1, vector<pii>(n));

    vector<int> value(n);

    for (int i = 0; i < n; ++i){
        cin >> value[i];
    }

    map<int,int> last;

    for (int j = 0; j < 2; ++j){
        for (int i = n - 1; i >= 0; --i){
            int &l = last[value[i]];

            int x = int(l <= i) + int(l == n - 1);
            int y = l == n - 1 ? 0 : l + 1;
            nxt[0][i] = pii(y, x);

            l = i;
        }
    }

    int LOG = 1;

    while (nxt.back()[0].second < k){
        nxt.push_back(vector<pii>(n));

        for (int i = 0; i < n; ++i){
            pii a = nxt[LOG - 1][i];
            pii b = nxt[LOG - 1][a.first];
            nxt[LOG][i] = pii(b.first, a.second + b.second);
        }

        LOG++;
    }

    int u = 0;

    for (int j = LOG - 1; j >= 0; --j){
        if (nxt[j][u].second < k){
            k -= nxt[j][u].second;
            u = nxt[j][u].first;
        }
    }

    assert(k == 1);

    vector<int> answer;
    set<int> inside;

    for (int i = u; i < n; ++i){
        if (inside.find(value[i]) == inside.end()){
            inside.insert(value[i]);
            answer.push_back(value[i]);
        } else {
            while (true){
                int last = answer.back();
                answer.pop_back();
                inside.erase(last);

                if (last == value[i])
                    break;
            }
        }
    }

    for (auto x : answer)
        cout << x << " ";

    cout << endl;


    return 0;
}

Measured memory_bytes: 187080
#include <stdio.h>

int min,n;
int m[100][100];
int p[100][2];

int matrix(void);

int main()
{
  int i;

  scanf("%d",&n);

  for(i = 1;i <= n;i++){
    scanf("%d %d",&p[i][0],&p[i][1]);
  }
  p[0][1] = p[1][0];

  printf("%d\n",matrix());

  return 0;
}

int matrix(void)
{
  int i,l,j,k,q;
  
  for(i = 1;i <= n;i++) m[i][i] = 0;
  for(l = 2;l <= n;l++){
    for(i = 1;i <= n-l+1;i++){
      j = i + l - 1;
      m[i][j] = 10000000;
      for(k = i;k < j;k++){
	q = m[i][k] + m[k+1][j] + (p[i-1][1]*p[k][1]*p[j][1]);
	if(m[i][j] > q) m[i][j] = q;
      }
    }
  }
  return m[1][j];
}

    



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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

void solve() {
	string sp, t; cin >> sp >> t;
	string s = "";
	if (t.size() > sp.size()) {
		cout << "UNRESTORABLE";
		return;
	}
	for (int i = 0; i < (int)(sp.size()-t.size()+1); ++i) {
		string cur = sp; bool f = true;
		for (int j = 0; j < (int)t.size(); ++j) {
			if (cur[i+j] == '?') {
				cur[i+j] = t[j];
			}
			if (cur[i+j] == t[j]) continue;
			f = false;
			break;
		}
		if (f) {
			for (char &c: cur) if (c == '?') c = 'a';
			if (s.size()) s = min(cur, s);
			else s = cur;
		}
	}
	if (s.size()) cout << s;
	else cout << "UNRESTORABLE";
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
def IsEven(n):
    return n % 2 == 0

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

if IsEven(B-A):
    # (A-B) / 2 とはお互いの距離の半分
    print((B-A) // 2)
else:
    ans = min((B+A-1) // 2, (2*N-A-B+1) // 2)
    print(ans)


Measured memory_bytes: 2940
import java.util.*;

public class Main {

    private long N;
    private long M;

    public void inputData() {
        Scanner sc = new Scanner(System.in);
        N = sc.nextLong();
        M = sc.nextLong();
    }

    public void printAnswer() {
        /*if (N == 1 && M == 1) {
            System.out.println(1);
        } else if (N == 1) {
            System.out.println(M - 2);
        } else if (M == 1) {
            System.out.println(N - 2);
        } else {
            System.out.println((N - 2) * (M - 2));
        }*/
        if (N > 1) {
            N -= 2;
        }
        if (M > 1) {
            M -= 2;
        }
        System.out.println(N * M);
    }

    public void run() {
        inputData();
        printAnswer();
    }

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

}


Measured memory_bytes: 21844
def parse_input(raw,format):
    raw=raw.split()
    format=format.split()

    ret={}
    rawpos=0
    for f in format:
        pass


def A(S):
    ret=700
    ret+=S.count("o")*100
    return ret

def B(N,X,m):
    ret=0
    X-=sum(m)
    ret+=len(m)

    ret+=int(X/min(m))

    return ret

import sys

inp = sys.stdin.read().split()
inp=[int(i) for i in inp]
print(B(inp[0], inp[1], inp[2:]))



Measured memory_bytes: 3064
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const double pi = 3.14159265;
const ll LLINF = 1LL << 50;
using namespace std;


int par[100005];
int rnk[100005];


void init(int n) {
    for (int i = 1; i <= n; i++) {
        par[i] = i;
        rnk[i] = 0;
    }
}


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


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

    if (rnk[x] < rnk[y]) {
        par[x] = y;
    }
    else {
        par[y] = x;
        if (rnk[x] == rnk[y])rnk[x]++;
    }
}


bool same(int x, int y) {
    return find(x) == find(y);
}


int main() {
    int n, m, p[100005];
    cin >> n >> m;
    init(n);
    for (int i = 1; i <= n; i++) cin >> p[i];
    for (int i = 0; i < m; i++) {
        int t, tt;
        cin >> t >> tt;
        unite(t, tt);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (same(i, p[i]))ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408