akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int a, b;
  double h, m;
  cin >> a >> b >> h >> m;
  if(h == 0 && m == 0) {
    cout << abs(a-b) << endl;
    return 0;
  }
  double x = m/60;
  double y = (60*h+m)/720;
  double ans = sqrt(a*a + b*b - 2*a*b*cos(abs(x-y)*2*M_PI));
  printf("%0.12f\n", ans);
}


Measured memory_bytes: 4164
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

signed main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  int mx = 0;
  rep(i, N) {
    cin >> A[i];
    chmax(mx, A[i]);
  }

  if (K > mx) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }

  int GCD = A[0];
  rep(i, N) {
    GCD = gcd(GCD, A[i]);
  }

  if (K % GCD == 0) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int calc(int x, int y, int z) {
  return (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x);
}

int main() {
  int n;
  cin >> n;
  vector<int> ans(10 * n);
  for (int x = 1; x * x <= n; ++x) {
    for (int y = 1; y * y <= n; ++y) {
      for (int z = 1; z * z <= n; ++z) {
        ans[calc(x, y, z)]++;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,k; cin>>a>>b>>k;
  vector<int> v;
  for(int i=0; i<k; i++){
    if(a+i<=b) v.push_back(a+i);
    if(a<=b-i) v.push_back(b-i);
  }
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  for(int i:v) cout<<i<<endl;
}

Measured memory_bytes: 256
N = int(input())
ab = sorted([[int(x) for x in input().split()] for i in range(N)], key=lambda x:x[1])
fin = 1
if ab[0][0] > ab[0][1]:
    fin = 0
else:
    for i in range(1,N):
        ab[i][0] = ab[i-1][0] + ab[i][0]
        if ab[i][0] > ab[i][1]:
            fin = 0
            break

print("Yes" if fin else "No")

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    string n;
    cin >> n;
    int len = n.length();
    for(int i = 0; i < len; i++)
    {
        if(n[i] == '9')
        {
            cout << 1;
        }
        else
        {
            cout << 9;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    x = int(input())
    for a in range(-1000, 1001):
        for b in range(-1000, 1001):
            if a ** 5 - b ** 5 == x:
                print(a, b)
                return
resolve()

Measured memory_bytes: 64532
#include <fstream>

int main()
{
  int C1, C2, C3, counter;
  while ( scanf("%d %d %d", &C1,&C2,&C3) != EOF ) {
    counter = 0;
    for (int i = 1; i < 11; i++) {
      if ( (i != C1 && i != C2 && i != C3) && (C1 + C2 + i <= 20) ) {
        counter++;
      }
    }
    if (counter < 4) {
        printf("NO\n");
    } else {
        printf("YES\n");
    }
  }
  return 0;
}

Measured memory_bytes: 2612
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> P;
typedef pair<lint, lint> PL;

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    lint K, A, B; cin >> K >> A >> B;

    if(A+2>=B || K<=A-1) {cout << K + 1 << endl; return 0;}
    else cout << A + (K-A+1) / 2 * (B-A) + (K-A+1) % 2 << endl;
    return 0;
}

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




int main()
{
	int n;
	cin >> n;
	vector<int>p(n);
	for(int i; i < n; i++)cin >> p[i];
	int ans = 0;
	for(int i = 1; i < n-1; i++)
	{
		if((p[i-1] < p[i]) && (p[i] < p[i + 1])) ans++;
		else if((p[i-1] > p[i]) && (p[i] > p[i + 1])) ans++;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;

struct maya {
    ll b, ka, t, w, ki;
};

struct we {
    ll y, m, d;
};

ll year2d(ll x);
ll west2d(we x);
ll maya2d(maya x);
ll is_uru(ll y);

ll month_table[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
ll maya_table[] = {1, 20, 20 * 18, 20 * 20 * 18, 20 * 20 * 20 * 18};
ll maya_mod[]   = {20, 20 * 18, 20 * 20, 20 * 20 * 18, 13};

ll west_origin;

int main()
{
    ll d;
    ll a;
    maya m;
    we w;

    west_origin = west2d((we){2012, 12, 21});

    while (scanf("%lld", &a) != 0) {
        if (a < 13) {
            m.b = a;
            scanf(". %lld . %lld . %lld . %lld",
                  &m.ka, &m.t, &m.w, &m.ki);

            d = maya2d(m) + west_origin;

            //year
            ll valid = 0;
            ll invalid = 100000000ll;

            while (invalid - valid > 1) {
                ll mid = (valid + invalid) / 2;

                if (year2d(mid) < d) {
                    valid = mid;
                }
                else {
                    invalid = mid;
                }
            }

            bool f = is_uru(valid);
            if (f) {
                month_table[2]++;
            }

            d -= year2d(valid);
            ll sum = 0;
            ll i = 1;
            while (sum + month_table[i] < d) {
                sum += month_table[i];
                i++;
            }

            printf("%lld.%lld.%lld\n", valid, i, d - sum);

            if (f) {
                month_table[2]--;
            }
        }
        else {
            w.y = a;
            scanf(". %lld . %lld", &w.m, &w.d);

            d = west2d(w) - west_origin;

            int f = 0;
            for (int i = 4; i >= 0; i--) {
                if (f) putchar('.');
                printf("%lld", d / maya_table[i] % maya_mod[i]);
                d %= maya_table[i];
                f = 1;
            }
            putchar('\n');
        }
    }

    return 0;
}

ll year2d(ll year)
{
    year--;
    return year * 365 + year / 4  - year / 100 + year / 400;
}

ll west2d(we x)
{
    ll ans = 0;

    ans += year2d(x.y);

    if (is_uru(x.y)) {
        month_table[2]++;
    }

    for (int i = 1; i < x.m; i++) {
        ans += month_table[i];
    }

    ans += x.d;

    if (is_uru(x.y)) {
        month_table[2]--;
    }

    return ans;
}

ll maya2d(maya x)
{
    int ans = 0;

    ans += x.ki * maya_table[0];
    ans += x.w  * maya_table[1];
    ans += x.t  * maya_table[2];
    ans += x.ka * maya_table[3];
    ans += x.b  * maya_table[4];

    return ans;
}

ll is_uru(ll y)
{
    if (y % 4 == 0 && y % 100 != 0) {
        return true;
    }
    else if (y % 100 == 0 && y % 400 == 0) {
        return true;
    }

    return false;
}



Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
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;
}

signed main()
{
    int A[5];
    int tmp = 10;
    int ans = 0;
    REP(i, 5)
    {
        cin >> A[i];
        if (A[i] % 10 > 0)
        {
            chmin(tmp, A[i] % 10);
            ans += A[i] - A[i] % 10 + 10;
        }
        else
        {
            ans += A[i];
        }
    }

    if (tmp > 0)
    {
        ans += tmp;
        ans -= 10;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from itertools import combinations
import sys
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a2=list()
b2=list()

if n==1:
    print(0)
    sys.exit()
    
for i in range(n):
    if i%2:
        b2.append(a[i])
        a2.append(b[i])
    else:
        a2.append(a[i])
        b2.append(b[i])

ans=10**9
for idx in combinations(range(0,n), (n+1)//2):
    a3=list()
    b3=list()
    flag=True
    for i in range(n):
        if i in idx:
            a3.append([a2[i], i])
        else:
            b3.append([b2[i], i])
    a3.sort(key=lambda x:x[0])
    b3.sort(key=lambda x:x[0])

    for i in range(len(b3)-1):
        if a3[i][0]>b3[i][0] or a3[i+1][0]<b3[i][0]:
            flag=False
    if len(a3)>len(b3):
        if a3[-1][0]<b3[-1][0] or a3[-2][0]>b3[-1][0]:
            flag=False
    elif a3[-1][0]>b3[-1][0]:
        flag=False

    if flag:
        ansidx = list()
        for i in range(len(b3)):
            ansidx.append(a3[i][1])
            ansidx.append(b3[i][1])
        if len(a3)>len(b3):
            ansidx.append(a3[-1][1])

        swap=0
        for i in range(n):
            for j in range(i,n):
                if ansidx[i]>ansidx[j]:
                    swap+=1
        ans= min(ans, swap)

if ans==10**9:
    print('-1')
else:
    print(ans)

            





Measured memory_bytes: 49880
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e14;
typedef std::pair<int,int> P;
struct edge{ int to,cost; };
#define VMAX 100000
//bool cmp(P a,P b){ return a.second < b.second;}

ll N,M,W,ans=0;
ll w[110],v[110];
vector<ll> X[4];
int main(){
	std::ios_base::sync_with_stdio(false);
	cin>>N>>W;
	REP(i,N){
		cin>>w[i]>>v[i];
		X[w[i]-w[0]].push_back(v[i]);
	}
	REP(i,4)if(!X[i].empty())sort(ALL(X[i]),greater<ll>());
	REP(i,X[0].size()+1){
		ll a;
		if(i==0)a=0;
		else a+=X[0][i-1];
		REP(j,X[1].size()+1){
			ll b;
			if(j==0)b=0;
			else b+=X[1][j-1];
			REP(k,X[2].size()+1){
				ll c;
				if(k==0)c=0;
				else c+=X[2][k-1];
				REP(m,X[3].size()+1){
					ll d;
					if(m==0)d=0;
					else d+=X[3][m-1];
					if(i*w[0]+j*(w[0]+1)+k*(w[0]+2)+m*(w[0]+3)<=W){
						ans=max(ans,a+b+c+d);
					}
				}
			}
		}
	}

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

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,c;
    scanf("%d %d %d\n",&a,&b,&c);
    
	int count=0;
    for(int i=a;i<=b;i++){
        if(c%i==0)count++;
    }
    
    printf("%d\n",count);
    
    
    return 0;
}


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

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define nfor(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

template<typename A, typename B> inline ostream& operator<< (ostream& out, const pair<A, B>& p) { return out << "(" << p.x << ", " << p.y << ")"; }
template<typename T> inline ostream& operator<< (ostream& out, const vector<T>& a) { out << "["; forn(i, sz(a)) { if (i) out << ','; out << ' ' << a[i]; } return out << " ]"; } 
template<typename T> inline ostream& operator<< (ostream& out, const set<T>& a) { return out << vector<T>(all(a)); }
template<typename X, typename Y> inline ostream& operator<< (ostream& out, const map<X, Y>& a) { return out << vector<pair<X, Y>>(all(a)); }
template<typename T> inline ostream& operator<< (ostream& out, pair<T*, int> a) { return out << vector<T>(a.x, a.x + a.y); }

inline ld gett() { return ld(clock()) / CLOCKS_PER_SEC; }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;

#ifdef SU1
#define LOG
#endif

const int N = int(1e5) + 5;
int n;
char s[N];

bool read() {
	if (scanf("%s", s) != 1)
		return false;
	return true;
}

void solve() {
	n = (int) strlen(s);
	int cg = (n + 1) / 2;
	int res = 0;
	forn(i, n) {
		if (i < cg)
			res -= (s[i] == 'p');
		else
			res += (s[i] == 'g');
	}
	cout << res << endl;
}

int main() {
#ifdef SU1
    assert(freopen("input.txt", "rt", stdin));
    //assert(freopen("output.txt", "wt", stdout));
#endif
    
    cout << setprecision(10) << fixed;
    cerr << setprecision(5) << fixed;

    while (read()) {
		ld stime = gett();
		solve();
		cerr << "Time: " << gett() - stime << endl;
		//break;
	}
	
    return 0;
}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

int N;
int big = 0;
multiset<int>S;

int main() {
	cin >> N;
	for (int i = 0; i < (1 << N); ++i) {
		int elm;
		cin >> elm;
		S.insert(elm);
		big = max(big, elm);
	}
	vector<int>T;
	T.push_back(big);
	S.erase(S.find(big));
	for (int i = 0; i < N; ++i) {
		vector<int>uT;
		for (int elm : T) {
			auto itr = S.lower_bound(elm);
			if (itr == S.begin()) {
				cout << "No" << endl;
				return 0;
			}
			--itr;
			uT.push_back(*itr);
			S.erase(itr);
		}
		for (int elm : uT)T.push_back(elm);
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 13960
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class B
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var WAB = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var (W, A, B) = (WAB[0], WAB[1], WAB[2]);
            Console.WriteLine(Math.Max(0, Math.Max(B - (A + W), A - (B + W))));
        }
    }
}


Measured memory_bytes: 28040
#include<stdio.h>
int main(void)
{
  int n,m;
  scanf("%d%d",&n,&m);
  int ac[n+1],wa[n+1];
  for(int i=1;i<=n;i++){
    ac[i]=0;
    wa[i]=0;
  }
  for(int i=0;i<m;i++){
    char tmp2[3];
    int tmp1;
    scanf("%d%s",&tmp1,tmp2);
    if(tmp2[0]=='A') ac[tmp1]++;
    else if(tmp2[0]=='W'){
      if(ac[tmp1]==0) wa[tmp1]++;
    }
  }
  int ans=0,penalty=0;
  for(int i=1;i<=n;i++){
    if(ac[i]>0){
      ans++;
      penalty+=wa[i];
    }
  }
  printf("%d %d",ans,penalty);
  return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	if (D == 25) {
		cout << "Christmas" << endl;
	}
	else if (D == 24) {
		cout << "Christmas Eve" << endl;
	}
	else if (D == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	else if (D == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}
	

	
}


Measured memory_bytes: 3536
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	bool y = false;
	in(int, N);
	loop(i, N) {
		char c;
		cin >> c;
		if (c == 'Y')
			y = true;
	}
	out(y ? "Four" : "Three");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	int n;
  	string s;
  	map<string,int> di;
  	cin>>n;
  	rep(i,n){
      cin>>s;
      if(s[0]=='i'){
        	cin>>s;
        	di.insert(make_pair(s,i));
      }
      else{
        	cin>>s;
        	if(di.find(s)!=di.end() ){
              	cout<<"yes"<<'\n';
            }
        	else{
              	cout<<"no"<<'\n';
            }
      }
    }
    return(0);
}


Measured memory_bytes: 34492
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String[] nk = scanner.nextLine().split(" ");
		int n = Integer.parseInt(nk[0]);
		List<Integer> as = Arrays.asList(scanner.nextLine().split(" ")).stream().map(x -> Integer.parseInt(x))
				.collect(Collectors.toList());

		Map<Integer, Integer> m = new HashMap<>();
		for (int i = 0; i < as.size(); i++) {
			m.put(i + 1, as.get(i));
		}

		List<Map.Entry<Integer, Integer>> l = new ArrayList<Map.Entry<Integer, Integer>>(m.entrySet());
		l.sort((a, b) -> a.getValue() - b.getValue());

		for (Map.Entry<Integer, Integer> v : l) {
			System.out.print(v.getKey() + " ");
		}
	}
}

Measured memory_bytes: 60460
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();

        final int[][] table = new int[n][n];
        for (int i = 0; i < n; i++) {
            final String s = scanner.next();
            for (int j = 0; j < n; j++) {
                table[i][j] = s.charAt(j) - 'a';
            }
        }

        System.out.println(countGood(table, n) * n);
    }

    private static int countGood(final int[][] table, final int length) {
        int counter = 0;
        for (int c = 0; c < length; c++) {
            boolean flag = true;
            for (int i = 0; i < length && flag; i++) {
                for (int j = i + 1; j < length; j++) {
                    if (table[i][j] != table[j][i]) {
                        flag = false;
                        break;
                    }
                }
            }
            if (flag) {
                counter++;
            }

            final int[] copy = new int[length];
            System.arraycopy(table[0], 0, copy, 0, length);
            for (int i = 1; i < length; i++) {
                System.arraycopy(table[i], 0, table[i - 1], 0, length);
            }
            System.arraycopy(copy, 0, table[length - 1], 0, length);
        }
        return counter;
    }
}


Measured memory_bytes: 28876
#include <stdio.h>

int main()
{
	int h, w, n, temp = 0, ctr = 0;
	scanf("%d %d %d", &h, &w, &n);
	while(n > temp)
	{
		if(w >= h)
		{
			temp+=w;
			ctr++;
		} else if(w <= h)
		{
			temp+=h;
			ctr++;
		}
	}
	printf("%d", ctr);
	return 0;
}

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



public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();

		int len = str.length();

		if(str.charAt(0) != 'A'){
			System.out.println("WA");
			return;
		}

		if(str.charAt(1) == 'C'){
			System.out.println("WA");
			return;
		}

		int numOfc = 0;

		for(int i = 2; i < len - 1; i++){
			if(str.charAt(i) == 'C'){
				numOfc++;
			}
		}

		if(numOfc != 1){
//			System.out.println("numofc" + numOfc);
			System.out.println("WA");
			return;
		}

		int lower = 0;
		for(int i = 0; i < len; i++){
			if(Character.isLowerCase(str.charAt(i))){
				lower++;
			}
		}

		if(lower != len - 2){
//			System.out.println("lower "+lower);
			System.out.println("WA");
			return;
		}

		System.out.println("AC");
	}

}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

vector<bool> prime_table(int n) {
  vector<bool> prime(n + 1, true);
  if (n >= 0) prime[0] = false;
  if (n >= 1) prime[1] = false;
  for (int i = 2; i * i <= n; i++) {
    if (!prime[i]) continue;
    for (int j = i * 2; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}

int main(){
  int q;
  cin>>q;
  vector<bool>prime=prime_table(100009);
  vector<int>s(100009);
  rep2(i,1,100008){
    s[i]=s[i-1];
    if(i%2==0)continue;
    if(prime[i]&&prime[(i+1)/2]){
      s[i]++;
    }
  }
  rep(i,q){
    int l,r;
    cin>>l>>r;
    cout<<s[r]-s[l-1]<<endl;
  }
  return(0);
}


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

using namespace std;

int n, m;
char M[505][505];

int main()
{
    cin>>n>>m;
    for (int i=1; i<=n; i++)
    {
        for (int j=1; j<=m; j++)
            cin>>M[i][j];
    }
    int ok=1;
    for (int i=0; i<=n; i++)
    {
        M[i][0]='.';
        M[i][m+1]='.';
    }
    for (int i=0; i<=m; i++)
    {
        M[0][i]='.';
        M[n+1][0]='.';
    }
    for (int i=1; i<=n; i++)
    {
        for (int j=1; j<=m; j++)
        {
            if (M[i][j]=='#' && M[i][j+1]=='.' && M[i][j-1]=='.' && M[i+1][j]=='.'  && M[i-1][j]=='.')
                ok=0;
        }
    }
    if (ok)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int n = Integer.parseInt(sc.nextLine());
	static Map<String, Integer> pd = new TreeMap <String, Integer>();
	static int max_length = 0;

	public static void main(String[] args) {

		product();
		dispData();

	}

	private static void dispData() {

		for (int i = 1; i <= max_length; i++) {
			for (String name : pd.keySet()) {
				int num = pd.get(name);
				if (name.length() == i) {
					System.out.printf("%s %d\n", name, num);
				}

			}
		}



	}

	private static void product() {

		for (int i = 0; i < n; i++) {
			String or = sc.nextLine();
			String[] or_d = or.split(" ");
			String name = or_d[0];
			int num = Integer.parseInt(or_d[1]);

				if ( pd.containsKey(name) ) {
					pd.put(name, pd.get(or_d[0]) + num );
				} else {
					pd.put(name, num );
				}

			max_length = Math.max(name.length(), max_length);
		}

	}



}


Measured memory_bytes: 65164
#include<stdio.h>
int main(){
  int n,m,p,x[1000],i,sum;
  while(1){
    sum=0;
    scanf("%d%d%d",&n,&m,&p);
    if((n==0)&&(m==0)&&(p==0))
      break;
    for(i=0;i<n;i++){
      scanf("%d",&x[i]);
      sum=sum+x[i];
    }
    if(x[m-1]==0)
      printf("0\n");
    else
      printf("%d\n",(sum*100*(100-p)/100)/x[m-1]);
  }
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  
  int size = s.size() - 1;
  char fin = s[size];
  
  if(fin == 's') cout << s + "es" << endl;
  else cout << s + "s" << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
	int n, k, flag;
	int b[1000], sr;
	int i, j;
	
	while (scanf("%d %d", &n, &k), n != 0 || k != 0){
		
		for (i = 0; i < k; i++){
			scanf("%d", &b[i]);
		}
		for (i = 0; i < n; i++){
			for (j = 0; j < k; j++){
				scanf("%d", &sr);
				b[j] -= sr;
			}
		}
		
		for (i = 0; i < k; i++){
			if (b[i] < 0){
				break;
			}
		}
		if (i == k){
			printf("Yes\n");
		}
		else {
			printf("No\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 588
n = int(input())
L = [int(i) for i in input().split()]
c = sum(int(i) for i in input().split())
C = [int(i) for i in input().split()]
for i in range(len(L)-1):
  if L[i]+1 == L[i+1]:
    c += C[L[i]-1]
print(c)

Measured memory_bytes: 3060
N = int(input())
A = []
B = []
a_max = -float("inf")
a_min = float("inf")
b_max = -float("inf")
b_min = float("inf")
for _ in range(N):
    x, y = map(int, input().split())
    a_max = max(a_max, x-y)
    a_min = min(a_min, x-y)
    b_max = max(b_max, x+y)
    b_min = min(b_min, x+y)
print(max(a_max-a_min, b_max-b_min))
    


Measured memory_bytes: 69756
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int c[][]=new int[3][3];
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                c[i][j]=sc.nextInt();
            }
        }
        int a=0;
        int aa=c[0][0]+c[0][1]-c[1][0]-c[1][1];
        int ab=c[0][0]+c[0][2]-c[1][0]-c[1][2];
        int ac=c[0][1]+c[0][2]-c[1][1]-c[1][2];
        if((aa==ab)&&(ab==ac)){
            a=1;
        }
        int b=0;
        int ba=c[1][0]+c[1][1]-c[2][0]-c[2][1];
        int bb=c[1][0]+c[1][2]-c[2][0]-c[2][2];
        int bc=c[1][1]+c[1][2]-c[2][1]-c[2][2];
        if((ba==bb)&&(bb==bc)){
            b=1;
        }
        int d=0;
        int da=c[0][0]+c[1][0]-c[0][1]-c[1][1];
        int db=c[0][0]+c[2][0]-c[0][1]-c[2][1];
        int dc=c[1][0]+c[2][0]-c[1][1]-c[2][1];
        if((da==db)&&(db==dc)){
            d=1;
        }
        int f=0;
        int fa=c[0][1]+c[1][1]-c[0][2]-c[1][2];
        int fb=c[0][1]+c[2][1]-c[0][2]-c[2][2];
        int fc=c[1][1]+c[2][1]-c[1][2]-c[2][2];
        if((fa==fb)&&(fb==fc)){
            f=1;
        }
        if((a==1)&&(b==1)&&(d==1)&&(f==1)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }







        }
        
     
    }


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

int main() {
  int h,w,k;
  cin >> h >> w >> k;

  vector<vector<int>> c(h, vector<int>(w));
  char tmp;
  int num=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> tmp;
      if(tmp=='.')c[i][j]=0;
      else {
	c[i][j]=1;
	num++;
      }
    }
  }

  if(num<k){
    cout << 0 << endl;
    return 0;
  }
  
  int ans=0;
  for(int x=0;x<pow(2,h);x++){
    for(int y=0;y<pow(2,w);y++){
      int cnt=0;
      int xflag;
      int yflag;
      int tx = x;
      for(int i=0;i<h;i++){
	if(tx/pow(2,h-i-1)>=1){
	  xflag=1;
	  tx -= pow(2,h-i-1);
	}
	else xflag=0;
	int ty = y;
	for(int j=0;j<w;j++){
	  if(ty/pow(2,w-j-1)>=1){
	    yflag=1;
	    ty -= pow(2,w-j-1);
	  }
	  else yflag=0;
	  if(xflag!=1 && yflag!=1)
	    if(c[i][j]==1)cnt++;
	}
      }
      // cout << cnt << endl;
      if(cnt==k)ans++;
    }
  }

  // cout << endl;
  // int cnt=0;
  // int xflag;
  // int yflag;
  // int tx = 3;
  // for(int i=0;i<h;i++){
  //   if(tx/pow(2,h-i-1)>=1){
  //     xflag=1;
  //     tx -= pow(2,h-i-1);
  //     cout << tx << endl;
  //   }
  //   else xflag=0;
  //   int ty = 0;
  //   for(int j=0;j<w;j++){
  //     if(ty/pow(2,w-j-1)==1){
  // 	yflag=1;
  // 	ty -= pow(2,w-j-1);
  //     }
  //     else yflag=0;
  //     if(xflag!=1 && yflag!=1)if(c[i][j]==1){cnt++; cout << yflag <<"Y ";}
  //   }
  //   cout << endl;
  // }
  // cout << cnt << endl;
  // cout << endl;

  // cout << pow(2,0) << " " << 3/pow(2,1) << endl;
  
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 4104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
typedef long long ll;

int main(){
    ll X,A,B;
    cin>>X>>A>>B;
    ll n = (X-A)/B;
    ll ans = X-(A+B*n);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  l64 a[n];
  bool iszero = true;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] >= n) iszero = false;
  }
  if (iszero) {
    cout << 0 << endl;
    return 0;
  }
  u64 now_best;
  for (int j = 0; j < n; ++j) {
    l64 db = -1, dt = (10000000000000000+1000)+1;
    u64 cur = (db+dt)/2;
    while (dt-db != 1) {
      u64 over = 0;
      for (int i = 0; i < n; ++i) {
        if (a[i] + (cur*n+j) > n-1) {
          over += ((a[i] + (cur*n+j) - n) / (n+1)) + 1;
        }
      }
      if (over <= (cur*n+j)) {
        dt = cur;
      } else {
        db = cur;
      }
      cur = (dt+db)/2;
    }
    if (j == 0 || dt*n+j < now_best) {
      now_best = dt*n+j;
    }
  }
  cout << now_best << endl;
  return 0;
}


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

typedef long long int ll;
typedef unsigned long long int ull;

ll power(ll x,ll y,ll p){ll r=1; x=x%p; while(y){ if(y&1) r= r*x%p; y=y>>1; x=x*x%p; } return r; }
/*  
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;*/

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

int csrand(int l=0, int r=1e9)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

#define PR(x) cout<<#x<<" : "<<x<<"\n";
#define PR1(x,y) cout<<#x<<" : "<<x<<"  |  "<<#y<<" : "<<y<<"\n";
#define PR2(x,y,z) cout<<#x<<" : "<<x<<"  |  "<<#y<<" : "<<y<<"  |  "<<#z<<" : "<<z<<"\n";
#define ED cout<<'\n';

#define IO              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FILEIO          freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define all(v)          v.begin(),v.end()
#define endl            '\n'
#define fr1(j,n)        for(int j=0;j<n;j++)
#define fr(n)           for(int i=0;i<n;i++)
#define PB              push_back
#define pii             pair<int,int>
#define pll             pair<long long int,long long int>
#define F               first       
#define S               second 
#define mod             1000000007
#define trav(x,y)       for(auto x:y)

const int N=2e5+99;


int32_t main()
{       
    IO

    string s;
    cin>>s;

    ll ans=0;
    ll n=s.length();

    int k=-1;
    if(s[0]=='>')
    {

        while(k+1<n && s[k+1]=='>')k++;
        ll sz2=k+1;
        ll add=(sz2*(sz2+1))/2LL;;
        ans+=add;
    }


    for(int i=k+1;i<n;i++)
    {
        int j=i;
        while(j+1<n && s[j+1]=='<')j++;
        int k=j;

        while(k+1<n && s[k+1]=='>')k++;

        ll sz1=j-i+1;
        ll sz2=k-j;
        
        if(sz1<=sz2) sz1--;
        else sz2--;
        sz1=max(sz1,0LL);
        sz2=max(sz2,0LL);

        ll add=(sz1*(sz1+1))/2LL + (sz2*(sz2+1))/2LL;
        // PR1(sz1,sz2)
        // PR(add)
        ans= ans + add;
        i=k;
    }
    cout<<ans<<endl;


}


Measured memory_bytes: 1172
#include <iostream>
#include <cstring>
#include <cstdlib>

using namespace std;

long long pow_2_of(int i) {
  long long ret_val = 1;
  for ( ; i > 0; i--) {
    ret_val *= 2;
  }
  return ret_val;
}

  // // 再帰式
  // sum_until(i)
  //   = "s[i] までの合計値"
  //   = (sum_until[i-1] + (2^{i-1} * s[i])
  //      + sum_until[i-2] + (2^{i-2} * (10 * s[i-1] + s[i]))
  //      + sum_until[i-3] + (2^{i-3} * (100 * s[i-2] + s[i-1] + s[i]))
  //      + ... + 10^{i} * s[0] + 10^{i-1} * s[1] + ... + s[i]);

long long sum_until[10];
void rec(int i, const long long *s) {
  int j;
  int k;
  // 末端処理
  if (i == 0) {
    sum_until[i] = s[i];
    return;
  }
  for (j = 1; j <= i; j++) {
    sum_until[i] += sum_until[i-j];
    long long temp = 0;
    for (k = 1; k <= j; k++) {
      temp = 10 * temp + s[i-j+k];
    }
    sum_until[i] += pow_2_of(i-j) * temp;
  }
  long long temp = 0;
  for (k = 0; k <= i; k++) {
    temp = 10 * temp + s[k];
  }
  sum_until[i] += temp;
  return;
}

int main(int argc, char *argv[])
{
  char S[11];
  long long s[10];

  cin >> S;

  int i;
  for (i = 0; i < strlen(S); i++) {
    s[i] = S[i] - '0';
  }

  // 初期化
  for (i = 0; i < strlen(S); i++) {
    sum_until[i] = 0;
  }

  // 計算(ボトムアップ)
  for (i = 0; i < strlen(S); i++) {
    rec(i, s);
  }

  cout << sum_until[strlen(S)-1] << endl;
  // cout << sum_until[0] << endl;
  // cout << sum_until[1] << endl;
  // cout << sum_until[2] << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn dfs(
    vv: &Vec<Vec<(usize, usize)>>,
    sv: usize,
    ev: usize,
    pv: usize,
    rv: &mut Vec<usize>,
) -> bool {
    if sv == ev {
        return true;
    }
    for &v in &vv[sv] {
        if v.0 == pv {
            continue;
        };
        if dfs(vv, v.0, ev, sv, rv) {
            rv.push(v.1);
            return true;
        }
    }
    return false;
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();

    // input
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut abv = vec![(0usize, 0usize); n - 1];
    for i in 0..n - 1 {
        abv[i].0 = read(&mut stdin_lock, &mut buf, b' ');
        abv[i].1 = read(&mut stdin_lock, &mut buf, b'\n');
    }
    let m: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut uvv = vec![(0usize, 0usize); m];
    for i in 0..m {
        uvv[i].0 = read(&mut stdin_lock, &mut buf, b' ');
        uvv[i].1 = read(&mut stdin_lock, &mut buf, b'\n');
    }

    let mut vv = vec![Vec::new(); n + 1];
    for i in 0..n - 1 {
        let (a, b) = abv[i];
        vv[a].push((b, i));
        vv[b].push((a, i));
    }

    let mut mv = vec![0u64; m];
    for i in 0..m {
        let (u, v) = uvv[i];
        let mut rv = Vec::new();
        if dfs(&vv, u, v, u, &mut rv) {
            for e in rv {
                mv[i] |= 1u64 << e;
            }
        }
    }

    let mut ans = 0u64;
    for i in 0u64..(1u64 << m) {
        let mut mask = 0u64;
        for j in 0..m {
            if (i >> j) & 1 == 1 {
                mask |= mv[j];
            }
        }
        let c = 1u64 << ((n - 1) as u32 - mask.count_ones());
        if i.count_ones() % 2 == 0 {
            ans += c;
        } else {
            ans -= c;
        };
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
int a[100005];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int c;
        cin>>c;
        a[c]=i;
    }
    for(int i=1;i<=n;i++)
        cout<<a[i]+1<<' ';
}


Measured memory_bytes: 1280
/* _________________________________________________________________________________________________
  |                                                                                                 |
  |                             Author      : Aditya Ahuja                                          |
  |                             Date        : Sun,  4th Aug 2019                                    |
  |_________________________________________________________________________________________________|
*/
 
#include<bits/stdc++.h>
using namespace std;

// #define int long long

#define pb          push_back
#define F           first
#define S           second
#define endl        "\n"
#define rep(i,a,b)  for(int i = a; i < (int)b; i++)
#define req(i,a,b)  for(int i = (int)b - 1; i >= a; i--)
#define all(a)      (a).begin(),(a).end()
#define ret(x)      {cout << x << endl; return;}
#define sz(x)       (int)x.size()
#define type(x)     typeid(x).name()

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

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

#ifdef LOCAL
	#define wa(x)       cerr << (#x) << " --- " << (x) << endl
	#define pvi(v)      {for(auto it:v) cerr << it << " "; cerr << endl;}
	#define line1	    cerr << "---------------------------" << endl;
#else
	#define wa //
	#define line1 //
	#define pvi //
	#define printf //
#endif

void solve();
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout << fixed << setprecision(10);

	int t=1; 
	// cin>>t;
	while(t--) solve();
	return 0;
}

//___________________________________________________________________________________________________

void solve() {

	int n,k;
	cin >> n >> k;

	vi a(n);
	rep(i,0,n) cin >> a[i];
	sort(all(a));

	vi dp(k+1,0);
	// dp[i] : would player 1 win if there were i stones in the pile?

	rep(i,0,a[0]) dp[i] = 0;

	rep(i,a[0],k+1){
		rep(j,0,n){
			if(i-a[j] >= 0 && dp[i-a[j]] == 0) dp[i] = 1;
		}
	}

	if(dp[k]) cout << "First" << endl;
	else cout << "Second" << endl;
}


Measured memory_bytes: 640
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

template<class T> inline bool chmax(T &a, T b) {
    if (a < b) a = b; return true;
    return false;
}

void solve(long long N, std::string S){
    int p = 0, m = 0;
    int maxi = -10000;
    int num = 0;
    REP(i, S.size()) {
        if (S[i] == 'I') {
            num++;
            chmax(maxi, num);
        }
        else num--;
    }
    if (maxi >= 0) cout << maxi << '\n';
    else cout << 0 << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    cin >> N;
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    A_asc = sorted(A)
    m1 = A_asc[-1]
    m2 = A_asc[-2]

    if m1 == m2:
        print('\n'.join([str(m1) for _ in range(N)]))
    else:
        for a in A:
            if a != m1:
                print(m1)
            else:
                print(m2)


if __name__ == "__main__":
    main()

Measured memory_bytes: 27680
/*input
2 2 
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

void solve(){
    int a,b;cin >> a >> b;
    RE(i,1000){
      if((i*8)/100 == a and i/10 == b ){
        cout << i;
        return;
      }
    }
    cout << -1;

}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        List<Long> a = new ArrayList<>();
        IntStream.range(0, N).forEach( b -> a.add(scan.nextLong()));
        long sum = a.stream().mapToLong(Long::valueOf).sum();
        long snuke = a.get(0);
        long min = Math.abs(sum - 2 * snuke);
        for (int i = 1; i < N-1; i++) {
            long tmp = a.get(i);
            long tmpScore =  Math.abs(sum - 2 * snuke - 2 * tmp);
            if(min > tmpScore) {
                min = tmpScore;
            }
            snuke += tmp;
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 94776