akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace ITP1_11_C {
    class Dice {
        private int[] _dice;
        
        public Dice(int[] dice) {
            _dice = dice;
        }

        public bool IsSame(int[] arr) {
            if (!IsSetTop(arr[0]))
                return false;
            string dir = "ENENEN";
            string turn = "RRRR";
            foreach (var d in dir) {
                foreach (var t in turn) {
                    if (_dice.SequenceEqual(arr))
                        return true;
                    Move(t);
                }
                Move(d);
            }
            return false;
        }

        private bool IsSetTop(int top) {
            if (_dice[0] == top)
                return true;
            string dir = "NNNEEE";
            foreach (var d in dir) {
                Move(d);
                if (_dice[0] == top)
                    return true;
            }
            return false;
        }

        public void Move(string dir) {
            foreach (var d in dir) {
                Move(d);
            }
        }

        public void Move(char dir) {
            switch (dir) {
                case 'E':
                    Replace(0, 3, 5, 2);
                    break;
                case 'W':
                    Replace(0, 2, 5, 3);
                    break;
                case 'N':
                    Replace(0, 1, 5, 4);
                    break;
                case 'S':
                    Replace(0, 4, 5, 1);
                    break;
                case 'R':
                    Replace(1, 3, 4, 2);
                    break;
            }
        }

        private void Replace(int a, int b, int c, int d) {
            int temp = _dice[a];
            _dice[a] = _dice[b];
            _dice[b] = _dice[c];
            _dice[c] = _dice[d];
            _dice[d] = temp;
        }
    }

    class Program {
        static void Main(string[] args) {
            int[] d1 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int[] d2 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            Dice dice = new Dice(d1);
            Console.WriteLine(dice.IsSame(d2) ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 9876
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  ll N;
  cin>>N;
  ll ans=1;
  ll X=1,Y=1;
  ll mod=1e9+7;
  rep(i,N){
    ans=ans*10%mod;
    X=X*9%mod;
    Y=Y*8%mod;
  }
  ans=(ans+mod-X)%mod;
  ans=(ans+mod-X)%mod;
  ans=(ans+Y)%mod;
  cout<<ans<<endl;
}


Measured memory_bytes: 3460
#include "bits/stdc++.h"
using namespace std;

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int32_t main() {
    //ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<int> cnt(n + 1);
    for (int i = 1; i <= k; i++) {
        int d, s;
        cin >> d;
        for (int j = 0; j < d; j++) {
            cin >> s;
            cnt[s]++;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += cnt[i] == 0;
    }
    cout << ans;
}


Measured memory_bytes: 3636
#include <iostream>

int main()
{
    int a, b;
    char op;
    std::cin >> a >> op >> b;
    if (op == '+')
    {
        std::cout << a + b;
    }
    else
    {
        std::cout << a - b;
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 256
// ███▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓╬╬╬╬╬╬▓█
// ███▓███████▓▓╬╬╬╬╬╬╬╬╬╬╬╬▓███▓▓▓▓█▓╬╬╬▓█
// ███████▓█████▓▓╬╬╬╬╬╬╬╬▓███▓╬╬╬╬╬╬╬▓╬╬▓█
// ████▓▓▓▓╬╬▓█████╬╬╬╬╬╬███▓╬╬╬╬╬╬╬╬╬╬╬╬╬█
// ███▓▓▓▓╬╬╬╬╬╬▓██╬╬╬╬╬╬▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ████▓▓▓╬╬╬╬╬╬╬▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ███▓█▓███████▓▓███▓╬╬╬╬╬╬▓███████▓╬╬╬╬▓█
// ████████████████▓█▓╬╬╬╬╬▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬█
// ███▓▓▓▓▓▓▓╬╬▓▓▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ████▓▓▓╬╬╬╬▓▓▓▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ███▓█▓▓▓▓▓▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// █████▓▓▓▓▓▓▓▓█▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// █████▓▓▓▓▓▓▓██▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// █████▓▓▓▓▓████▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// ████▓█▓▓▓▓██▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// ████▓▓███▓▓▓▓▓▓▓██▓╬╬╬╬╬╬╬╬╬╬╬╬█▓╬▓╬╬▓██
// █████▓███▓▓▓▓▓▓▓▓████▓▓╬╬╬╬╬╬╬█▓╬╬╬╬╬▓██
// █████▓▓█▓███▓▓▓████╬▓█▓▓╬╬╬▓▓█▓╬╬╬╬╬╬███
// ██████▓██▓███████▓╬╬╬▓▓╬▓▓██▓╬╬╬╬╬╬╬▓███
// ███████▓██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬████
// ███████▓▓██▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓████
// ████████▓▓▓█████▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█████
// █████████▓▓▓█▓▓▓▓▓███▓╬╬╬╬╬╬╬╬╬╬╬▓██████
// ██████████▓▓▓█▓▓▓╬▓██╬╬╬╬╬╬╬╬╬╬╬▓███████
// ███████████▓▓█▓▓▓▓███▓╬╬╬╬╬╬╬╬╬▓████████
// ██████████████▓▓▓███▓▓╬╬╬╬╬╬╬╬██████████
// ███████████████▓▓▓██▓▓╬╬╬╬╬╬▓███████████
//#include "grader.h"
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <cassert>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define read(FILENAME) assert(freopen((FILENAME + ".in").c_str(), "r", stdin))
#define write(FILENAME) assert(freopen((FILENAME + ".out").c_str(), "w", stdout))
#define files(FILENAME) read(FILENAME), write(FILENAME)
using namespace std;
template <typename A, typename B> void chkmin(A &x, B y) {if (x > y) x = y;}
template <typename A, typename B> void chkmax(A &x, B y) {if (x < y) x = y;}
     
typedef pair <int, int> point;
     
const string FILENAME = "input";
const int MAXN = 1e5, p = 1e9 + 7;

long long d;

long long powx[20];
int kalc[2][20];

bool check(long long A, long long B, long long C) {
	A += B;
	A %= C;
	if (A < 0) 
	 	A += C;
	 return A == 0;
}

long long res(long long d, long long cnt, int L, int R) {
	if (R == L) return cnt * (long long)(d == 0) * 10;
	if (R < L) return cnt * (long long)(d == 0);
	long long ans = 0;
	long long q = powx[R] - powx[L];
	for (int i = -9; i <= 9; ++i) {
		if (check(d, q * i, powx[L + 1])) {
			ans += res(d + q * i, cnt * kalc[L != 0][10 - i], L + 1, R - 1);
		}
	}
	return ans;
}

int main() {
	//read(FILENAME);
	ios::sync_with_stdio(0);
	cin >> d;
	for (int i = 0; i < 10; ++i) {
		for (int j = 0; j < 10; ++j) {
			if (j != 0) ++kalc[0][10 + i - j];
			++kalc[1][10 + i - j];
		}
	}
	powx[0] = 1;
	for (int i = 0; i < 18; ++i) {
		powx[i + 1] = powx[i] * 10;
	}
	long long ans = 0;
	for (int len = 1; len <= 18; ++len) {
		ans += res(d, 1, 0, len - 1);
	}
	cout << ans << endl;
}








Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll N, C;
    cin >> N >> C;
    vector<vector<ll>> D(C, vector<ll>(C));
    vector<vector<ll>> color(N, vector<ll>(N));
    loop(i, C) loop(j, C) cin >> D[i][j];
    loop(i, N)
    {
        loop(j, N)
        {
            cin >> color[i][j];
            color[i][j]--;
        }
    }
    vector<vector<ll>> count(3, vector<ll>(C));
    loop(i, N)
    {
        loop(j, N)
        {
            count[(i + j) % 3][color[i][j]]++;
        }
    }
    ll ans = 1e18;
    loop(i, C)
    {
        loop(j, C)
        {
            loop(k, C)
            {
                if (i == j || j == k || k == i)
                    continue;
                //あまり0のマスをi,1のマスをj,2のマスをkにする
                ll preans = 0;
                loop(l, C) preans += count[0][l] * D[l][i];
                loop(l, C) preans += count[1][l] * D[l][j];
                loop(l, C) preans += count[2][l] * D[l][k];
                ans = min(ans, preans);
            }
        }
    }
    putout(ans);
    return 0;
}


Measured memory_bytes: 5556
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define all(v) v.begin(),v.end()
#define fio() ios::sync_with_stdio(0);cin.tie(0);
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define fornn(i,a,n) for(ll i=a;i<=n;i++)
#define pb push_back
#define MAXN 100005LL
#define INF LONG_MAX
#define MOD 1e9+7LL
inline void solve(){
	ll n;
	cin>>n;
	ll val[n][3],dp[n][3];
	for(ll i=0;i<n;i++){
		for(ll j=0;j<3;j++)
			cin>>val[i][j];
	}
	dp[0][0]=val[0][0];
	dp[0][1]=val[0][1];
	dp[0][2]=val[0][2];
	for(ll i=1;i<n;i++){
		dp[i][0]=val[i][0]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=val[i][1]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=val[i][2]+max(dp[i-1][0],dp[i-1][1]);
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}
int main(){
	fio();
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 8344
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}

ll solve(ll N, vector<ll>& A){
    vector<ll> S(N);
    map<ll,ll> ct;
    ll ans = 0;
    S[0] = A[0];
    ct[S[0]]++;
    if(!S[0]) ans++;
    rep1(i,N-1){
        S[i] = S[i-1] + A[i];
        if(!S[i]) ans++;
        ans += ct[S[i]];
        ct[S[i]]++;
    }
    return ans;
}

int main(){
    ll N; cin >> N;
    vector<ll> A(N); rep(i,N) cin >> A[i];
    pr(solve(N,A));
    return 0;
}


Measured memory_bytes: 15872
while True:
  try:
    ss = input()
    ans1 = ans2 = 0
    for i in range(len(ss) - 2):
      if ss[i] == 'J' and ss[i + 1] == 'O' and ss[i + 2] == "I":
        ans1 += 1
      elif ss[i] == 'I' and ss[i + 1] == 'O' and ss[i + 2] == "I":
        ans2 += 1
    print(ans1)
    print(ans2)
  except EOFError:
    break




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

int main() {
    int n, m;
    cin >> n >> m;
    vector <int> d(n), c(m);
    rep (i, n) cin >> d[i];
    rep (i, m) cin >> c[i];

    const int INF = 1000000000;
    vector <vector <int>> dp(m + 2, vector <int> (n + 1, INF));

    dp[0][0] = 0;
    rep (i, m + 1) rep (j, n) if (dp[i][j] != INF) {
        dp[i + 1][j]     = min(dp[i + 1][j],     dp[i][j]);
        dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + d[j] * c[i]);
    }

    int ans = INF;
    rep (i, m + 1) ans = min(ans, dp[i][n]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5964
#include<stdio.h>
int main(void)
{
	int n,s[100],i=0;
	while(scanf("%d",&s[i])!=EOF){
		if(s[i]==0){
			i--;
			printf("%d\n",s[i]);
		}
		else {
			i++;
		}
	}
	return 0;
}

Measured memory_bytes: 1028
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <queue>

#define MAXCHAR 255
#define ll long long

using namespace std;
const ll dividend = 1000000007;
const ll limit = pow(10, 18);
const ll bigNum = pow(10, 9);

ll funcComb(int n, int k) 
{
	ll output = 1;
	int sum = n + k;
	vector<int> dividends;
	for (int i = 0; i < k; i++)
	{
		dividends.push_back(k - i);
	}
	for (int i = 0; i < k; i++)
	{
		output *= sum - i;
		for (auto it = dividends.begin(); it != dividends.end(); it++)
		{
			if (*it == 0)
				continue;
			if (output % *it == 0)
			{
				output /= *it;
				*it = 0;
			}
		}
		if (output > dividend)
		{
			output %= dividend;
		}
	}

	return output;
}

vector<bool> outputs;

int main()
{
	int x;
	cin >> x;
	if (x >= 30)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

int main(){
    int a,b;
    int total=0,num=0,row=0;
        
    while(scanf("%d,%d",&a,&b)!=EOF){
        total=total+a*b;
        num=num+b;
        row++;
    }   
    int ans=(int)(num/(double)row+0.5); 
    printf("%d\n%d\n",total,ans);
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	string s; cin >> s;
	int b[26] = {};
	rep(i, 0, s.size()) {
		b[s[i] - 'a']++;
	}
	rep(i, 0, 26)
	{
		if (b[i] % 2 == 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    string S;
    cin >> S;
    if (S == "Sunny") cout << "Cloudy" << endl;
    else if (S == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

int main(){
    int fre[100] = {0};
    int n, max = 0;
    while (cin >> n){
        fre[n-1]++;
        if (max < fre[n-1]) max = fre[n-1];
    }
    REP(i, 100) 
        if (fre[i] == max) cout << i+1 << endl;
}


Measured memory_bytes: 3048
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005


int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);

        int a,b,c;
        cin >> a >> b >> c;
        int x=b/a;
        int ans=min(c,x);
        cout << ans << '\n';
        
        

}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    int N;
    while (cin >> N) {
        map<int,int> cnt;
        FOR(i,0,N) {
            int a; cin >> a;
            cnt[a]++;
        }
        vector<LL> x;
        FOR_ALLR(i,cnt) if (i->second >= 2) {
            const int a = i->first;
            x.push_back(a);
        }
        LL ans = 0;
        if (x.size() >= 2) 
            ans = x[0]*x[1];
        FOR_ALL(i,x) if (cnt[*i] >= 4)
            ans = max(ans, (*i) * (*i));
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 4992
from itertools import permutations
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
moto = list(range(1, n+1))
dic = list(permutations(moto))

a = dic.index(p)
b = dic.index(q)
print(abs(a-b))

Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#include <math.h> /* M_PI */
#define INF 2147483647
int main()
{
    ll n, x;
    cin >> n >> x;
    vector<ll> A(n);
    rep(i, n)
    {
        cin >> A[i];
    }
    ll count = 0;
    rep(i, n)
    {
        if (i == 0)
        {
            if (A[i] > x)
            {
                count += A[i] - x;
                A[i] = x;
                continue;
            }
            continue;
        }
        if (A[i] + A[i - 1] > x)
        {
            count += A[i] + A[i - 1] - x;
            A[i] = x - A[i - 1];
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
int main(){
  long long n,x,ans=0;
  scanf("%lld", &n);
  scanf("%lld", &x);
  
  ans = n;
  long long t=x, p,q= n-x,ikkk;
  while(t){
    p = q / t;
    ans += (p * t * 2);
    p = q;
    q = t;
    ikkk=t;
    t = p % t;
    //  printf("%lld:%lld:%lld\n",ans,q,t);                                     
}
  ans = ans - ikkk;
  printf("%lld\n", ans);
  return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
 
void dfs(int x,LL y,int a[]) {
    if(a[0] > 0 || y > x) {
        return;
    }
    if(y == x) {
        a[0]++;
        return;
    }
    dfs(x,y+1,a);
    dfs(x,y+2,a);
    dfs(x,y+3,a);
    dfs(x,y+4,a);
    dfs(x,y+5,a);
}
 
int main() {
    int x;
    cin >> x;
    VI dp(1000000,0);
    dp[0] = 1;
    int a[6] = {100,101,102,103,104,105};

    for(int i = 0;i<=1000000;i++) {
        for(int j = 0;j<6;j++) {
            if(dp[i] == 1) {
                dp[i+a[j]] = 1;
            }
        }
    }

    if(dp[x]== 1) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 4224
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("Ofast")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int l;
	scanf("%d", &l);
	stack<int> st;
	set<int> a;
	rep(i, l) {
		int c;
		scanf("%d", &c);
		if (c < 0) {
			if(st.empty()) {
				printf("%d\n", i + 1);
				return 0;
			}
			if (st.top() != -c) {
				printf("%d\n", i + 1);
				return 0;
			}
			else {
				st.pop();
				a.erase(-c);
			}
		}
		else {
			if (a.find(c) != a.end()) {
				printf("%d\n", i + 1);
				return 0;
			}
			else {
				st.push(c);
				a.insert(c);
			}
		}
	}
	puts("OK");

	Please AC;
}


Measured memory_bytes: 3192
import java.io.*;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		String str;
		Double wgt;
		Scanner in = new Scanner(System.in);
//		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		while ( in.hasNext() ) {
			wgt = in.nextDouble();
			System.out.println(rank(wgt));
		}
	}
	
	public static String rank( double weight ) {
		String[] date = {"light fly" , "fly" , "bantam", "feather" , "light" ,
						"light welter" , "welter" , "light middle" , "middle" ,
						"light heavy" , "heavy"};
		int index = 0;
		if ( weight <= 48.00 ) index = 0; 
		else if ( weight > 48.00 && weight <= 51.00 ) index = 1; 
		else if ( weight > 51.00 && weight <= 54.00 ) index = 2; 
		else if ( weight > 54.00 && weight <= 57.00 ) index = 3; 
		else if ( weight > 57.00 && weight <= 60.00 ) index = 4; 
		else if ( weight > 60.00 && weight <= 64.00 ) index = 5; 
		else if ( weight > 64.00 && weight <= 69.00 ) index = 6; 
		else if ( weight > 69.00 && weight <= 75.00 ) index = 7;
		else if ( weight > 75.00 && weight <= 81.00 ) index = 8; 
		else if ( weight > 81.00 && weight <= 91.00 ) index = 9;
		else if ( weight > 91.00 ) index = 10;
		return date[index];
	}
}

Measured memory_bytes: 0
n, m = map(int, input().split())

if n == 1 and m == 1:
    print(1)
elif n == 1 and m != 1:
    print(m - 2)
elif m == 1 and n != 1:
    print(n - 2)
else:
    print((n - 2) * (m - 2))


Measured memory_bytes: 2940
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int teamnum = sc.nextInt(); //チーム数
		int teamscore[] = new int[teamnum+1];//勝ち点収納用配列
		for(int i=0;i<teamnum*(teamnum-1)/2;i++){ //試合数繰り返す。
			int team1=sc.nextInt();
			int team2=sc.nextInt();
			int score1=sc.nextInt();
			int score2=sc.nextInt();
				if(score1>score2){
					teamscore[team1] += 3;
				}
				else if(score1<score2){
					teamscore[team2] += 3;
				}
				else{
					teamscore[team1] += 1;
					teamscore[team2] += 1;
				}
		}
		for(int i=1;i<=teamnum;i++){
			int count=1;
			for(int j=1;j<=teamnum;j++){
				if(teamscore[i]<teamscore[j]){
					count++;
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 42156
c=[0,2,5,5,4,5,6,3,7,6];N=gets.split[0].to_i;A=gets.split.map &:to_i;d=[0]+A.map{};0.upto(N){|i|d[i]&&A.each{|x|d[t=i+c[x]]=[d[t]?d[t]:0,d[i]*10+x].max}};p d[N]

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

int main(){
	int x, a, b;
	cin >> x >> a >> b;
	if(-a + b > x) cout << "dangerous" << endl;
	else if(-a + b <= 0) cout << "delicious" << endl;
	else cout << "safe" << endl;
	
}


Measured memory_bytes: 256
from itertools import accumulate
n, k = map(int, input().split())
a = list(map(int, input().split()))

for _ in range(k):
    newa = [0 for _ in range(n)]
    for i in range(n):
        l = max(0, i - a[i])
        r = min(n - 1, i + a[i])
        newa[l] += 1
        if r + 1 < n:
            newa[r + 1] -= 1
    a = list(accumulate(newa))
    if all(i == n for i in a):
        break
print(*a)

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

#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lowbit(x) (x & -x)
typedef long long ll;
using namespace std;
const int MAX = 0x7ffffff;
int t;

void slove()
{
	int n , m , k;
	cin >> n >> m >> k;
	vector<ll> a(n + 1) , b(m + 1),suma(n + 1) , sumb(m + 1);
	for(int i = 1;i <= n;i ++)cin >> a[i];
	for(int i = 1;i <= m;i ++)cin >> b[i];
	for(int i = 1;i <= n;i ++)
		suma[i] = suma[i-1] + a[i];
	for(int i = 1;i <= m;i ++)
		sumb[i] = sumb[i-1] + b[i];
	ll ans = 0 , j = m;
	for(int i = 0;i <= n;i ++)
	{
		if(k < suma[i])break;
		ll l = 0, r = m;
		ll val = k - suma[i];
		while(l < r)
		{
			int mid = l + r + 1 >> 1;
			if(sumb[mid] <= val)l = mid;
			else r = mid - 1;
		}
		if(l <= r)
			ans = max(ans, l + (ll)i);
		else ans = max(ans , (ll)i );
	}
	cout << ans << endl;
}
int main()
{
	SIS;
	slove();
}

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

ll n,a,b;
int main(void)
{
	cin>>n>>a>>b;
	ll ret=0;
	ll prev;
	cin>>prev;
	for (int i = 1; i < n; i++) {
		int t;
		cin>>t;
		if((t-prev)*a>=b)ret+=b;
		else ret+=(t-prev)*a;
		prev=t;
	}
	cout<<ret<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
long long a[5][4][11];
int main(){
	int i,j,z;
	int n,b,f,r,v;
	memset(a,0,sizeof(a));
	cin>>n;
	for(i=0;i<n;i++){
		cin>>b>>f>>r>>v;
		a[b][f][r]+=v;
	}
	for(i=1;i<=4;i++){
		for(j=1;j<=3;j++){
			for(z=1;z<=10;z++){
				cout<<" "<<a[i][j][z];
			}
			cout<<endl;
		}
		if(i==4)break;
		cout<<"####################"<<endl;
	}
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

int main() {
    fastio;
    int n, flag = 1;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        if (floor(i * 1.08) == n) flag = 0,cout << i;
    }
    if (flag) cout << ":(";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long n;
	cin>>n;
	n--;
	string s = "";
	while(n>=26)
	{
		s += n%26+'a';	
		n /= 26;
		--n;
	}
	s += n+'a';
	reverse(s.begin(),s.end());
	cout<<s;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
#define max(a,b) ((a > b)? a:b)
int main()
{
	int a, b, c, d,i = 0, num;
	cin >> d;
	while (i < d) {
		cin >> a >> b >> c;
		num = max(a, max(b,c));
		if (num == a) {
			if (a * a == b * b + c * c) {
				cout << "YES" << endl; }
			else { cout << "NO" << endl; }
		}
		else if (num == b) {
			if (b * b == a * a + c * c) {
				cout << "YES" << endl;	}
			else { cout << "NO" << endl; }
		}
		else if (num == c) {
			if (c * c == a * a + b * b) {
				cout << "YES" << endl;	}
			else { cout << "NO" << endl; }
		}
		else { cout << "NO" << endl; }
		i++;
	}
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long h, ans=1, s=2;
    cin >> h;
    h=h/2;
    while(h>0){
        h=h/2;
        ans=ans+s;
        s=s*2;
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int T = sc.nextInt();
    	int A = sc.nextInt();
    	double near = Double.MAX_VALUE;
    	int num = 0;
    	for (int i = 0; i < N; i++) {
    		double tmp = (T - sc.nextInt() * 0.006) - A;
    		if (Math.abs(tmp) < near) {
    			near = Math.abs(tmp);
    			num = i + 1;
    		}
    	}
    	System.out.println(num);
    }
}

Measured memory_bytes: 22612
#include<iostream>
#include<algorithm>
using namespace std;
/*
void swap(int &a,int &b){
	int tmp=a;
	a=b;
	b=tmp;
}*/


int partition(int A[],int p,int r){
	
	int x=A[r-1];
	int i=p-1;


	for(int j=p;j<r;j++){
		if(A[j]<=x){
			i++;
		if(i>=0&&j>=0)
		swap(A[i],A[j]);	
		}
		//swap(A[i],A[r-1]);
	}

	//swap(A[i],A[r-1]);
	return i;

}



int main(){
	int tmp[1000000];
	int n;
	cin>>n;

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

	int q;

	q=partition(tmp,0,n);
	
	for(int i=0;i<n;i++){
		
		if(i==q){
			cout<<"["<<tmp[i]<<"]";
		}
		
		else cout<<tmp[i];

		if(i==n-1)cout<<endl;
		else cout<<" ";
	}

	return 0;
}

Measured memory_bytes: 1556
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, 0, N) {
        cin >> A[i];
    }
    rep(i, 0, N) {
        if (A[i] % 2 == 0 && A[i] % 3 && A[i] % 5) {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
{-
 - `chebyshev n' returns the number of primes between n+1 and 2n.
 - e.g.:
 -   chebyshev 10 == 4    -- 11, 13, 17, 19
 -   chebyshev 13 == 3    -- 17, 19, 23
 -}

import Control.Monad  -- when

chebyshev :: Int -> Int
chebyshev n = length [x | x<-[n + 1 .. 2 * n], prime x]
 
prime :: Int -> Bool
prime n | n >= 2 = [x | x<-fs, n`mod`x == 0] == []
  where fs = takeWhile (\x->x*x <= n) ([2] ++ [3,5..])
                         -- x*x is faster than x^2

main :: IO ()
main = do n <- readLn
          when (n /= 0) $ do
            print (chebyshev n)
            main

Measured memory_bytes: 4196
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}


int main() {
    int n; cin >> n;
    for (int i=1;i<=9;++i) {
        if (n % i == 0 && n / i <= 9) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

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

const int MOD = (int)1e9 + 7;
const int N = (int)1e4 + 3;

int d, mniej[N][103], pref[N];
string k;

signed main() {
  init_ios();
  cin >> k >> d;
  int n = k.size();
  pref[0] = (int)(k[0]-'0');
  for (int i = 0; i < pref[0]; ++i)
    mniej[0][i%d] = (mniej[0][i%d]+1)%MOD;
  for (int i = 1; i < n; ++i) {
    int cy = (int)(k[i]-'0');
    pref[i] = cy;
    if (i > 0)
      pref[i] = (pref[i]+pref[i-1])%d;
    for (int j = 0; j <= 9; ++j) {
      for (int re = 0; re < d; ++re) {
        int now = (j+re)%d;
        mniej[i][now] = (mniej[i][now]+mniej[i-1][re])%MOD;
      }
    }
    for (int j = 0; j < cy; ++j) {
      int now = (j+pref[i-1])%d;
      mniej[i][now] = (mniej[i][now]+1)%MOD;
    }
  }
  int res = mniej[n-1][0]-1;
  if (res < 0)
    res += MOD;
  if (pref[n-1]%d == 0)
    res = (res+1)%MOD;
  cout<<res<<"\n";
}

Measured memory_bytes: 8448
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    rep(i, 0, N) {
        cin >> A[i] >> B[i];
    }
    sort(all(A));
    sort(all(B));
    if (N % 2) {
        cout << B[N / 2] - A[N / 2] + 1 << endl;
    } else {
        cout << B[N / 2 - 1] + B[N / 2] - A[N / 2 - 1] - A[N / 2] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 6340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18,MOD = 1e9 + 7;
const int INT_INF = 1e9,INT_MOD=1e9+7;
#define rep(i, N) for(int i = 0; i < N; i++)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
signed main(){
    ll n;cin>>n;
    ll sum=0;
    rep(i,n+1){
        if(i%3!=0 and i%5!=0) sum+=i;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

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

int h,w,ey,ex;
char room[10][11];
struct S{
	int y,x,nc,np;
	pi c[3],p[3];
	bool operator<(const S &r)const
	{
		if(y!=r.y)return y<r.y;
		if(x!=r.x)return x<r.x;
		if(nc!=r.nc)return nc<r.nc;
		rep(i,nc)if(c[i]!=r.c[i])return c[i]<r.c[i];
		if(np!=r.np)return np<r.np;
		rep(i,np)if(p[i]!=r.p[i])return p[i]<r.p[i];
		return 0;
	}
};
int solve(S s)
{
	set<S> V; V.insert(s);
	deque<pair<int,S> >Q; Q.pb(mp(0,s));
	
	while(!Q.empty())
	{
		int cc=Q.front().first;
		s=Q.front().second; Q.pop_front();
		
		if(s.y==ey&&s.x==ex)return cc;
		
		//move
		rep(d,4)
		{
			S ns=s;
			ns.y=s.y+dy[d],ns.x=s.x+dx[d];
			if(room[ns.y][ns.x]=='#')continue;
			rep(i,s.nc)if(mp(ns.y,ns.x)==s.c[i])goto FAIL;
			rep(i,s.np)if(mp(ns.y,ns.x)==s.p[i])goto FAIL;
			
			if(V.count(ns))continue;
			V.insert(ns); Q.pb(mp(cc+1,ns));
			FAIL:;
		}
		//push
		rep(d,4)
		{
			S ns=s;
			int ny=s.y+dy[d],nx=s.x+dx[d],c=0;
			for(;c<s.nc;c++)if(mp(ny,nx)==s.c[c])break;
			if(c==s.nc)continue;
			
			int cy=ny,cx=nx,p=-1;
			while(1)
			{
				ny+=dy[d]; nx+=dx[d];
				if(room[ny][nx]=='#')break;
				rep(i,s.nc)if(mp(ny,nx)==s.c[i])goto END;
				rep(i,s.np)if(mp(ny,nx)==s.p[i])
				{
					p=i; goto END;
				}
				cy=ny; cx=nx;
			}
			END:
			if(p!=-1)
			{
				for(int i=c;i<s.nc-1;i++)ns.c[i]=ns.c[i+1];
				for(int i=p;i<s.np-1;i++)ns.p[i]=ns.p[i+1];
				ns.nc--; ns.np--;
				
				if(!V.count(ns))V.insert(ns),Q.push_front(mp(cc,ns));
			}
			else if(mp(cy,cx)!=s.c[c])
			{
				ns.c[c]=mp(cy,cx);
				if(!V.count(ns))V.insert(ns),Q.push_front(mp(cc,ns));
			}
		}
	}
	return -1;
}
int main()
{
	while(scanf("%d%d",&h,&w),h)
	{
		S s; s.nc=s.np=0;
		rep(i,h)
		{
			scanf("%s",room[i]);
			rep(j,w)
			{
				char &c=room[i][j];
				if(c=='c')s.c[s.nc++]=mp(i,j),c='.';
				else if(c=='w')s.p[s.np++]=mp(i,j),c='.';
				else if(c=='@')s.y=i,s.x=j,c='.';
				else if(c=='E')ey=i,ex=j,c='.';
			}
		}
		printf("%d\n",solve(s));
	}
	return 0;
}

Measured memory_bytes: 7108
n,k=map(int,input().split())
P=list(map(int,input().split()))

S=[0]*(n+1)
for i in range(n):
    S[i+1]=S[i]+P[i]

a=0
for i in range(k,n+1):
    a=max(a,S[i]-S[i-k])
print((a+k)/2)

Measured memory_bytes: 71792
# -*- Coding: utf-8 -*-
#from dateutil.relativedelta import relativedelta
#import datetime
#import itertools#これは色々使える組み込み関数みたいなやつ
#import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#print(0)
N =2
month, date = [0]*N, [0]*N#N個の空のリストを作成
#l = list(range(N))#範囲がNのリストを作成する


for i in range(N):
  month[i], date[i] = map(int, input().split())

if date[1]==1:
    print(1)
else:
    print(0)

Measured memory_bytes: 2940
from collections import deque

if __name__ == '__main__':
    n = int(input())
    dll = deque()
    for _ in range(n):
        command = input().split()
        if command[0] == 'insert':
            dll.appendleft(command[1])
        elif command[0] == 'delete':
            try:
                dll.remove(command[1])
            except ValueError:
                pass
        elif command[0] == 'deleteFirst':
            dll.popleft()
        elif command[0] == 'deleteLast':
            dll.pop()
    print(*dll)


Measured memory_bytes: 69732
import java.math.BigDecimal

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ")

    var preh = BigDecimal.ONE
    var pret = BigDecimal(a[n])

    val down = arrayOfNulls<BigDecimal>(n+1)
    val up = arrayOfNulls<BigDecimal>(n+1)

    down[0] = preh
    up[n] = pret
    for (i in 1 .. n) {
        val ah = BigDecimal(a[i-1])
        val at = BigDecimal(a[n-i])

        preh =  (preh - ah) * BigDecimal(2)
        down[i] = preh
        up[n-i] = pret + at
        pret += at
    }
    if (preh <= BigDecimal.ZERO || down[n]!! < up[n]!!) {
        println(-1)
    } else {
        var ans = BigDecimal.ZERO
        for (i in 0..n) {
            if (down[i]!! <  up[i]!!) {
                ans += down[i]!!
            } else {
                ans += up[i]!!
            }
        }
        println(ans)
    }
}


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

int main()
{
	int i,N,K,Q,A;
  	cin>>N>>K>>Q; int players[N];
  	for(i=0;i<N;i++) players[i]=0;
    for(i=0;i<Q;i++)
    {
      cin>>A; players[A-1]+=1;
    }
  	for(i=0;i<N;i++)
    {
      if(players[i]<=Q-K) cout<<"No"<<endl;
      else cout<<"Yes"<<endl;
    }
  return 0;
}


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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}
long long lopow(ll a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a ;
        n >>= 1;
    }
    return res;
}

        
//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;

int main(){
  int X;cin>>X;
  if(X>=30)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;	
}






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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);

    rep(i, N){
        int a;
        cin >> a;
        A.push_back(a);
    }

    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());

    int Alice = 0;
    int Bob = 0;

    rep(i, N) {
        if (i % 2 == 0) {
            Alice += A.at(i);
        }
        else {
            Bob += A.at(i);
        }
    }

    cout << Alice - Bob << endl;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
   
// g++ -std=c++11 prac.cpp 
int main(){
    ll x,y,z,n,m=0,k,h,w,sum=0,ans=1,Max=-1e9,count=0,Min=1e9+1;
    string s,t,u1,u2;
    bool ok=false;
    cin >> n >> s;
    VI alpha(26);
    rep(i,n){ alpha[s[i]-'a']++; }
    rep(i,26){
        if(alpha[i]>0)
            ans = (ans * (alpha[i]+1)) % mod;
    }
    cout << (ans-1)%mod << endl;
    return 0;
}

Measured memory_bytes: 512
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
ll n,a,b,c,d[100];
ll y[100];

bool C(ll x){
	for(ll i=0;i<n;i++) y[i]=d[i]-x*b;
	ll res=c-a*x;
	sort(y,y+n);
	ll i=n-1;
	while(y[i]>=0){
		res+=y[i];
		i--;
	}
	return res>=0;
}


int main()
{
	scanf("%lld%lld%lld%lld",&n,&a,&b,&c);
	for(ll i=0;i<n;i++) scanf("%lld",&d[i]);
	ll lb=0;
	ll ub=0xffffffff;
	ll mid;
	while(ub-lb>1){
		mid=(ub+lb)/2;
		if(C(mid)){
			lb=mid;
		}
		else{
			ub=mid;
		}
	}
	printf("%lld\n",lb);
}

Measured memory_bytes: 3252