akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;


int N;
int A[10001];

//---------- 素因数分解 ----------
vector<pair<int, int>> prime_fact(ll n) //a0^b0 * a1^b1 * ...
{
	vector<pair<int, int>> list;
	ll a = n;
	for (int i = 2; i * i <= n; i++)
	{
		int cnt = 0;
		while (a % i == 0) 
		{
			cnt++;
			a /= i;
		}
		if (cnt > 0)
		{
			list.push_back(make_pair(i, cnt));
		}
	}
	if (a != 1) 
	{
		list.push_back(make_pair(a, 1));
	}
	return list;
}


int prime_max[1000010];

//---------- 1000000007 ----------
const int MOD = 1000000007;
int add(int a, int b)
{
	return (a + b) % MOD;
}
int sub(int a, int b)
{
	return (a + MOD - b) % MOD;
}
int mul(int a, int b)
{
	return (a * b) % MOD;
}
int pow(int x, int n)
{
	if (n == 0) return 1;
	ll res = pow((x * x) % MOD, n / 2);
	if (n & 1) res = (res * x) % MOD;
	return res;
}
int divide(int a, int b)
{
	return mul(a, pow(b, MOD - 2));
}


signed main()
{
	cin >> N;
	REP(i, N) cin >> A[i];

	for (int i = 0; i < N; i++)
	{
		auto fact = prime_fact(A[i]);
		for (pair<int, int> p : fact)
		{
			prime_max[p.first] = max(prime_max[p.first], p.second);
		}
	}

	int sum = 1;
	for (int i = 0; i <= 1000000; i++)
	{
		int m = 1;
		for (int j = 0; j < prime_max[i]; j++)
		{
			m = mul(m, i);
		}
		sum = mul(sum, m);
	}


	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		ans = add(ans, divide(sum, A[i]));
	}
	cout << ans << endl;
}


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

int main() {
    int a, b, c, x, y, ans;
    cin >> a >> b >> c >> x >> y;
    
    ans = a*x + b*y;
    ans = min(ans, c*x*2 + b * max(y-x, 0));
    ans = min(ans, c*y*2 + a * max(x-y, 0));
    
    cout << ans << endl;
    
    return (0);
}


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

int main() {
  int n, k;
  cin >> n >> k;
  int ans;
  for(int i = 0; i < n; i++) {
    if(i == 0) {
      ans = k;
    } else {
      ans *= (k - 1);
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const ll inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

class Seg {
private:
    ll size;
    vector<ll> data;
public:
    ll get(ll l, ll r, ll n, ll L, ll R) {
        if (r <= L || R <= l) return 0;
        if (L <= l && r <= R) return data[n];
        ll m = (l + r) / 2;
        return max(get(l, m, n*2+1, L, R), get(m, r, n*2+2, L, R));
    }
    ll get(ll l, ll r) {
        return get(0, size, 0, l, r);
    }
    void update(ll pos, ll val) {
        pos += size-1;
        data[pos] = val;
        while (1) {
            if (pos == 0) break;
            pos = (pos-1)/2;
            data[pos] = max(data[pos*2+1], data[pos*2+2]);
        }
    }
    Seg(ll n) {
        for (size = 1; size < n; size <<= 1);
        data = vector<ll>(size*2-1, 0);
    }
};

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll n; cin >> n;
    vector<ll> v(n); cin >> v;
    Seg seg(n);
    vector<ll> rv(n);
    REP(i, n) {
        --v[i];
        rv[v[i]] = i;
    }
    REP(i, n) {
        ll val = seg.get(0, rv[i])+(i+1);
        // cout << seg.get(0, rv[i]) << " " << val << endl;
        seg.update(rv[i], val);
    }
    ll ans = (ll)n * (n+1) / 2;
    ans -= seg.get(0, n);
    cout << ans << endl;
}

Measured memory_bytes: 6524
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <fstream>
#include <string>
#include <sstream>



using namespace std;

char acgt[4] = { 'A','C','G','T' };


bool isACGT(char a) {
	for (int i = 0; i < 4; i++) {
		if (a == acgt[i]) {
			return true;
		}
	}
	return false;
}

int main() {
	string s;
	cin >> s;
	int cnt = 0;
	int cntmax = 0;
	for (int i = 0; i < s.size(); i++) {
		if (isACGT(s[i])) {
			cnt++;
			if (cntmax < cnt) cntmax = cnt;
		}
		else {
			cnt = 0;
		}
	}
	cout << cntmax << endl;
}


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

using namespace std;

const int MOD = 1000 * 1000 * 1000 + 7;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<long long> A(N);
	for (auto &x : A) {
		cin >> x;
	}

	vector<long long> fac(N + 1);
	vector<long long> finv(N + 1);
	vector<long long> inv(N + 1);

	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i <= N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}

	auto comb = [&](int n, int k) -> long long {
		if (n < k) {
			return 0;
		}
		if (n < 0 || k < 0) {
			return 0;
		}
		return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
	};

	long long ans = 0;

	sort(A.rbegin(), A.rend());
	for (int i = 0; i < N; ++i) {
		long long t = comb(N - 1 - i, K - 1);
		t = (t * A[i]) % MOD;
		ans = (ans + t) % MOD;
	}

	sort(A.begin(), A.end());
	for (int i = 0; i < N; ++i) {
		long long t = comb(N - 1 - i, K - 1);
		t = (t * A[i]) % MOD;
		ans = (ans + MOD - t) % MOD;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3328
#include<cstdio>
#include<cmath>
using namespace std;
static const double pi = 2.0 * acos(0.0);

double m, t;

int main(){
	scanf("%lf %lf", &m, &t);
	double res = 0.0;
	for(double ct = 0.0; ct < t; ct += 0.01){
		double theta = 0.5 * pi + pi / 60.0 * ct;
		double z = 1900.0 * sin(theta);
		double x2 = 1900.0 * cos(theta);
		double theta2 = -pi / 180.0 * m + pi / 2.0 - 2.0 * pi * ct / (2500000.0 / 60.0);
		double y = x2 * sin(theta2);
		double x = x2 * cos(theta2);
		if(y < 0.0) continue;
		double L = 380000.0;
		double l = 1800.0;
		double r_ = L * l / sqrt(L * L - l * l);
		double r = r_ * (1.0 + y / 380000.0);
		if(sqrt(z * z + x * x) < r) res += 0.01;
	}
	printf("%.3lf\n", res);
	return 0;
}



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

int main(){
    int a,b,c,d; cin>>a>>b>>c>>d;
    string ans="No";
    int ac=abs(a-c),ab=abs(a-b),bc=abs(b-c);
    if(ac<=d) ans="Yes";
    else{
        if(ab<=d and bc<=d) ans="Yes";
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
# include <stdio.h>
int a[103], b[103];
int main()
{
    int p1=0, p2=0, m=100;
    long long n;
    scanf("%lld",&n);
    ++n;
    while(n > 1)
    {
        if(n&1) a[++p1] = m--, --n;
        else b[++p2] = m--, n>>=1;
    }
    printf("%d\n",p1+p2<<1);
    for(int i=1; i<=p1; ++i)
        printf("%d ",a[i]);
    for(int i=p2; i>=1; --i)
        printf("%d ",b[i]);
    for(int i=101-p1-p2; i<=100; ++i)
        printf("%d ",i);
    puts("");
    return 0;
}

Measured memory_bytes: 128
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
constexpr ll R=2e5+69, INF=2e9+6969;

int n,rep[R],ile[R],X[R],t[R],c[R],Y[R];

int Find(int a)
{
	if(a != rep[a]) rep[a] = Find(rep[a]);
	return rep[a];
}
void Union(int a, int b)
{
	a = Find(a);
	b = Find(b);
	if(ile[a] < ile[b]) swap(a,b);
	if(c[a] > c[b]) c[a] = c[b];
	ile[a] += ile[b];
	rep[b] = a;
}

stack <PII> s;

int main()
{
	scanf("%d", &n);
	for(int i=1;i<=n;++i)
	{
		int a,b;
		scanf("%d%d", &a, &b);
		t[a] = i;
		Y[b] = i;
		X[a] = b;
		c[i] = b;
		ile[i] = 1;
		rep[i] = i;
	}
	s.push(mp(INF,0));
	for(int i=1;i<=n;++i)
	{
		while(s.top().fi < X[i])
		{
			if(Find(s.top().se) != Find(t[i]))
			{
				Union(s.top().se , t[i]);
				//  printf("Un: %d %d\n", s.top().se, t[i]);
			}
			s.pop();
		}
		s.push(mp(c[Find(t[i])],Find(t[i])));
	}
	for(int i=1;i<=n;++i)
	{
		//  printf("%d: %d %d\n", i, ile[Find(i)], rep[Find(i)]);
		printf("%d\n", ile[Find(i)]);
	}
	return 0;
}


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

#define mp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, l;
  cin >> n >> l;
  vector<string> vs(n);
  for (auto &e : vs)
    cin >> e;
  sort(vs.begin(), vs.end());
  for (auto &e : vs)
    cout << e;
  cout << '\n';
}


Measured memory_bytes: 256
MOD = 10 ** 9 + 7
N, K = map(int, input().split())
ruiMin = [0] * (N + 1)
ruiMax = [((N + 1) * N) // 2] * (N + 1)

for i in range(1, N + 1):
    ruiMin[i] = ruiMin[i - 1] + i

for i in range(1, N + 1):
    ruiMax[-i - 1] = ruiMax[-i] - (i - 1)
ans = 0
for i in range(K - 1, N + 1):
    ans += ruiMax[i] - ruiMin[i] + 1
    ans %= MOD
print(ans)

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

void fnInput(vector<int>& rvnNum)
{
  string sNum;
  cin >> sNum;

  for (int i = 0; i < rvnNum.size(); i++)
    rvnNum[i] = sNum[i] - '0';
}

void fnBitFullSch(const vector<int>& cnrvnNum, vector<string>& rvsOpe)
{
  for (int i = 0; i < (1 << 3); i++)
  {
    int nSum = cnrvnNum[0];
    for (int j = 0; j < 3; j++)
      if (i & (1 << j))
      {
        rvsOpe[j] = "+";
        nSum += cnrvnNum[j + 1];
      }
      else
      {
        rvsOpe[j] = "-";
        nSum -= cnrvnNum[j + 1];
      }

    if (nSum == 7)  break;
  }
}
    
void fnResult(const vector<int>& cnrvnNum, const vector<string>& cnrvsOpe)
{
  cout << cnrvnNum[0];
  for (int j = 0; j < 3; j++)
    cout << cnrvsOpe[j] <<  cnrvnNum[j + 1];

  cout << "=7" << endl;
}

int main()
{
  vector<int> vnNum(4);
  vector<string> vsOpe(3);
  
  fnInput(vnNum);
  fnBitFullSch(vnNum, vsOpe);
  fnResult(vnNum, vsOpe);

  return 0;
}

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

int main()
{
	int a, b, c;
	
	cin >> a >> b >> c;
	
	int ans=b/a;
	
	if (ans>=c)
	{
		cout << c;
	}
	else 
		cout << ans;
		
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
int P = 2501;

template <typename T> class Dijkstra {
private:
  using ll = long long;
  using pp = pair<int, ll>;
public:
  ll INF_DIST = std::numeric_limits<ll>::max() / 2;
private:
  int start = 0;
  int siz = 0;
  void calc (const vector<vector<pair<int, T>>>& g) {
    dist.resize(siz);
    fill(dist.begin(), dist.end(), INF_DIST);
    dist[start] = 0;
    priority_queue<pp, vector<pp>, greater<pp>> que;
    que.emplace(0, start);
    while (que.size()) {
      pp cur = que.top();
      que.pop();
      int idx = cur.second;
      T d = cur.first;
      if (d > dist[idx]) continue;
      for (auto& nxt : g[idx]) {
        int j = nxt.first;
        T d2 = dist[idx] + nxt.second;
        if (d2 <  dist[j]) {
          dist[j] = d2;
          que.emplace(dist[j], j);
        }
      }
    }
  }
public:
  Dijkstra (const vector<vector<pair<int, T>>>& g, int st, int n = -1) : start(st) {if (n < 0) siz = (int) g.size(); calc(g); }
  Dijkstra (const vector<pair<int, T>> in[], int st, int n) : start(st), siz(n) {
    vector<vector<pair<int, T>>> g(n);
    for (int i = 0; i < n; ++i) for (int j = 0; j < (int) in[i].size(); j++) g[i].push_back(in[i][j]);
    calc(g);
  }
  vector<ll> dist;
  vector<ll> get() {return dist;}
};

signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m, s;
  cin >> n >> m >> s;
  s = min(s, 2500);
  vector<vector<pair<int, long long>>> g(P * n);
  for (int i = 0; i < m; i++) {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    u--;
    v--;
    int uu = P * u;
    int vv = P * v;
    for (int j = a; j <= 2500; j++) {
      g[uu + j].emplace_back(vv + (j - a), b);
      g[vv + j].emplace_back(uu + (j - a), b);
    }
  }
  for (int i = 0; i < n; i++) {
    int c, d;
    cin >> c >> d;
    int ii = P * i;
    for (int j = 0; j <= 2500; j++) {
      g[ii + j].emplace_back(ii + min(2500, j + c), d);
    }
  }
  Dijkstra d(g, s);
  for (int i = 1; i < n; i++) {
    long long ans = 1LL << 60;
    for (int j = 0; j <= 2500; j++) {
      ans = min(ans, d.dist[i * P + j]);
    }
    cout << ans << '\n';
  }
  return 0;
}


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

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)

#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000

using namespace std;
typedef long long ll;

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

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;

vector <int> new_members;
int kotae;
int a;
int b;

int score( int a, int b )
{
	if ( a > b )
		return a - b;
	else
		return b - a;
}

void solve( int n )
{
	if ( n == new_members.size() )
	{
		kotae = min( kotae, score( a, b ) );
		return;
	}

	a += new_members[n];
	solve( n + 1 );
	a -= new_members[n];

	b += new_members[n];
	solve( n + 1 );
	b -= new_members[n];

}

int main( void )
{
	int n;
	while ( cin >> n && n )
	{
		int a = 0;
		int b = 0;

		new_members = vector <int>();
		for ( int i = 0; i < n; i++ )
		{
			int new_member;
			cin >> new_member;
			new_members.push_back( new_member );
		}

		kotae = INT_MAX;
		a = 0;
		b = 0;
		solve( 0 );

		cout << kotae << endl;

	}

	return 0;
}

Measured memory_bytes: 904
//Do what you can't.

import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main  {
  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter w = new PrintWriter(System.out);
    long a = in.nextLong(), b = in.nextLong(), c = in.nextLong();
    if (c % 2 == 0 || a%2==0 || b%2==0)
      w.println(0);
    else
      w.println(Math.min(a*b,Math.min(a*c,b*c)));
    w.close();
  }

  static class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar, snumChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int snext() {
      if (snumChars == -1)
        throw new InputMismatchException();
      if (curChar >= snumChars) {
        curChar = 0;
        try {
          snumChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (snumChars <= 0)
          return -1;
      }
      return buf[curChar++];
    }

    public int nextInt() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9')
          throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public long nextLong() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      long res = 0;
      do {
        if (c < '0' || c > '9')
          throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public int[] nextIntArray(int n) {
      int a[] = new int[n];
      for (int i = 0; i < n; i++) {
        a[i] = nextInt();
      }
      return a;
    }

    public String readString() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isSpaceChar(c));
      return res.toString();
    }

    public String nextLine() {
      int c = snext();
      while (isSpaceChar(c))
        c = snext();
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isEndOfLine(c));
      return res.toString();
    }

    public boolean isSpaceChar(int c) {
      if (filter != null)
        return filter.isSpaceChar(c);
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private boolean isEndOfLine(int c) {
      return c == '\n' || c == '\r' || c == -1;
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);
    }
  }
}


Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

#define sz(x) int(x.size())
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main() {
  string s, t;
  cin >> s >> t;
  vector<vector<int> > is(26);

  int n = sz(s);
  int m = sz(t);
  for (int i = 0; i < n; i++) is[s[i] - 'a'].push_back(i);
  for (int i = 0; i < n; i++) is[s[i] - 'a'].push_back(i + n);

  ll ans = 0;
  int p = 0;
  rep(i, m) {
    int c = t[i] - 'a';
    if (sz(is[c]) == 0) {
      puts("-1");
      return 0;
    }
    p = *lower_bound(is[c].begin(), is[c].end(), p)+1;
    if (p >= n) {
      p -= n;
      ans += n;
    }
  }
  ans += p;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1724
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        //入力を受け取る
        int M1 = sc.nextInt();
        int D1 = sc.nextInt();
        int M2 = sc.nextInt();
        int D2 = sc.nextInt();

        answer(M1,M2);
    }

    public static void answer(int A, int B){
    	if(A==B){
    		System.out.println(0);
    	}else{
    		System.out.println(1);
    		}
        }
    }

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

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

    while (true) {
        int H, W;
        cin >> H >> W;
        if (H == 0 && W == 0)
            break;

        // top
        rep(i, W) cout << "#";
        cout << "\n";

        // middle
        rep(i, H - 2) {
            cout << "#";
            rep(j, W - 2) cout << ".";
            cout << "#\n";
        }

        // bottom
        rep(i, W) cout << "#";
        cout << "\n\n";
    }
    return 0;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

int main(){
	long long a, b;
	cin >> a >> b;
	if(a == 1 and b == 1){
		cout << 1 << endl;
	}else if(a == 1 or b == 1){
		cout << max(a,b) - 2 << endl;
	}else if(a == 2 or b == 2){
		cout << 0 << endl;
	}else{
		cout << a * b - 2 * a - 2 * b + 4 << endl;
	}
}


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

int main() {
  int N, X;
  cin >> N >> X;
  int m[N];
  int lower = numeric_limits<int>::max();
  for (int i = 0; i < N; ++i) {
    cin >> m[i];
    X -= m[i];
    if (lower > m[i]) lower = m[i];
  }
  cout << N + X / lower << '\n';
  return 0;
}


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

using namespace std;

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;

	for(int i = 1; i < n; i++){
		int cnt = 0;
		for(char c = 'a'; c <= 'z'; c++){
			bool left = false, right = false;
			for(int j = 0; j < i; j++)
					if(s[j] == c)	left = true;
			for(int j = i; j < n; j++)
					if(s[j] == c) right = true;

			if(left && right)	cnt++;
		}

		if(cnt > ans) ans = cnt;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int DP[1005][(1<<12)];

int main() {
  int N, M;
  cin>>N>>M;
  for(int i=0;i<M;++i) {
    for(int j=0;j<(1<<N);++j) {
      DP[i][j] = inf;
    }
  }
  int a[M], b[M];
  vector<vector<int> > c(M);
  int tmp;
  for(int i=0;i<M;++i) {
    cin>>a[i]>>b[i];
    for(int j=0;j<b[i];++j) {
      cin>>tmp;
      tmp--;
      c[i].push_back(tmp);
    }
  }
  tmp = 0;
  for(int i=0;i<c[0].size();++i) {
    tmp += (1<<c[0][i]);
  }
  DP[0][0] = 0;
  DP[0][tmp] = a[0];
  for(int i=0;i<M-1;++i) {
    for(int j=0;j<(1<<N);++j) {
      if(DP[i][j]<inf) {
        DP[i+1][j] = min(DP[i+1][j], DP[i][j]);
        tmp = j;
        for(int k=0;k<c[i+1].size();++k) {
          if((tmp&(1<<c[i+1][k]))==0) tmp += (1<<c[i+1][k]);
        }
        DP[i+1][tmp] = min(DP[i+1][tmp], DP[i][j]+a[i+1]);
      }
    }
  }
  if(DP[M-1][(1<<N)-1]==inf) cout<<-1<<endl;
  else cout<<DP[M-1][(1<<N)-1]<<endl;
}



Measured memory_bytes: 19744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    string s;
    cin>>s;
    int ans=0;
    rep(i,s.size()){
        if(i%2==0){
            if(s[i]=='p') ans--;
        }
        else{
            if(s[i]=='g') ans++;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3760
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpll vector<pll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(x) x.begin(),x.end()
#define mod 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	vector<vll> g(n);
	vpll e;
	for(ll i=1;i<n;i++){
		ll x,y;
		cin>>x>>y;
		x--;
		y--;
		g[x].pb(y);
		g[y].pb(x);
		e.pb({x,y});
	}
	ll k=0;
	map<pll,ll> m;
	vll c(n,0);
	queue<ll> q;
	vector<bool> v(n,false);
	q.push(0);
	v[0]=true;
	while(!q.empty()){
		ll vx=q.front();
		q.pop();
		if(k<g[vx].size()){
			k=g[vx].size();
		}
		ll cur=1;
		for(ll u:g[vx]){
			if(v[u]){
				continue;
			}
			if(cur==c[vx]){
				cur++;
			}
			c[u]=m[{u,vx}]=m[{vx,u}]=cur++;
			v[u]=true;
			q.push(u);
		}
	}
	cout<<k<<"\n";
	for(auto x:e){
		cout<<m[x]<<"\n";
	}
}

Measured memory_bytes: 21488
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;
lint a[51],b[51];
lint count(lint L,lint X){
  // cerr<<"called "<<L<<" "<<X<<endl;
  if(L==0)return X;
  if(X==a[L])return b[L];
  else if(X>a[L-1]+2)return b[L-1]+1+count(L-1,X-a[L-1]-2);
  else if(X==a[L-1]+2)return b[L-1]+1;
  else if(X==a[L-1]+1)return b[L-1];
  else if(X>1)return count(L-1,X-1);
  else return 0;
}

int main(){
  lint N,X;
  cin>>N>>X;
  a[0]=1;
  b[0]=1;
  FOR(i,1,51){
    a[i]=a[i-1]*2+3;
    b[i]=b[i-1]*2+1;
  }
  cout<<count(N,X)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
int n;
string s;
set<string>k;
int main()
{
	cin>>n;
	rep(i,n)
	{
		cin>>s;
		k.insert(s);
	}
	re(k.size())
	return 0;}

Measured memory_bytes: 19260
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<ll> dp(5000);
using P = pair<int, vector<int>>;
ll INF = 1e12;
int n;
vector<vector<P>> key(12);
ll rec(int s)
{
    if(dp[s] >= 0)
    {
        return dp[s];
    }
    if(s == (1 << n) - 1)
    {
        return dp[s] = 0;
    }
    ll res = INF;
    for(int u = 0; u < n; u++)
    {
        if(!(s >> u & 1))
        {
            for(int k = 0; k < key[u].size(); k++)
            {
                P p = key[u][k];
                int cond = s;
                for(int x = 0; x < p.second.size(); x++)
                {
                    cond |= 1 << p.second[x];
                }
                res = min(res, rec(cond | 1 << u) + p.first);
            }
        }
    }
    return dp[s] = res;
}
int main()
{
    int m;
    cin >> n >> m;
    vector<int> a(m);
    vector<int> b(m);
    vector<vector<int>> c(m);
    for(int i = 0; i < m; i++)
    {
        cin >> a[i] >> b[i];
        for(int j = 0; j < b[i]; j++)
        {
            int d;
            cin >> d;
            d--;
            c[i].push_back(d);
        }
        for(int j = 0; j < b[i]; j++)
        {
            vector<int> tmp;
            for(int k = 0; k < b[i]; k++)
            {
                if(k != j) tmp.push_back(c[i][k]);
            }
            key[c[i][j]].push_back(P(a[i], tmp));
        }
    }
    for(int i = 0; i < 5000; i++)
    {
      dp[i] = -1;
    }
    ll ans = rec(0);
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <cmath>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }


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

    int N, K;
    cin >> N >> K;

    if(N % K == 0){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    int x,y,men,seki;  
    public void yatary() {
        Scanner sc = new Scanner(System.in);
        x = sc.nextInt();
        y = sc.nextInt();
        men = x + x + y + y;
        seki = x * y;
        System.out.println(seki + " " + men);   
    }
    public static void main(String[] args){
    new Main().yatary();
    }
}

Measured memory_bytes: 17156
N=int(input())
test_case=[input() for _ in range(N)]
a=test_case.count('AC')
b=test_case.count('WA')
c=test_case.count('TLE')
d=test_case.count('RE')
print('AC x '+ str(a))
print('WA x '+ str(b))
print('TLE x '+str(c))
print('RE x '+str(d))


Measured memory_bytes: 16072
import numpy as np
N, M, C=map(int, input().split(' '))
B = list(map(int, input().split(' ')))
b = np.array(B)
A = []
for i in range(N):
    A.append(list(map(int, input().split(' '))))
a = np.array(A)
z = np.sum(a*b, axis=1) + C
print(np.sum(z>0))

Measured memory_bytes: 12396
line = list(map(int,input().split(" ")))
n = line[0]
x = line[1]
donut = {}
for i in range(n):
  donut[i] = int(input())
  x -= donut[i]           #１個ずつｎ個作った
  
min_do = min(donut.values())
how_many = x // min_do
answer = n + how_many
print(answer)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

using pi = pair<int,int>;

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

int main() {
  int h,w;
  cin >> h >> w;
  ll d[h][w];
  queue<pi> que;
  
  string s[h];
  rep(i, h) cin >> s[i];

  rep(i, h) rep(j, w) {
    d[i][j] = INF;
    if (s[i][j] == '#') {
      que.push(make_pair(i,j));
      d[i][j] = 0;
    }
  }

  ll cnt = 0;
  while (!que.empty()) {
    pi p = que.front();
    que.pop();
    for (int i = 0; i < 4; ++i) {
      int nx = dx[i] + p.second, ny = dy[i] + p.first;
      if (nx >= 0 and ny >= 0 and nx < w and ny < h and d[ny][nx] == INF and d[p.first][p.second] + 1 < d[ny][nx]) {
        if (ny == 3 and nx == 5) {
          
        }
        d[ny][nx] = d[p.first][p.second] + 1;
        que.push(make_pair(ny, nx));
      }
    }
    cnt += 1;
  }
  
  ll mmax = -1;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      // cout << d[i][j] << " ";
      mmax = max(mmax, d[i][j]);
    }
    // END;
  }

  cout << mmax << endl;
}


Measured memory_bytes: 17296
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
	cin >> A;
	int ans = 1;
	for(int i=2;i<50;i++){
		int curr = i;
		while(curr <= A){
			if(curr != i) ans = max(ans, curr);
			curr *= i;
		}
	}
	cout << ans;
}



Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int N, K;
vector<int> E[100010];
ll ans = 1;

void dfs(int cur, int pre, int cand) {
   ans *= cand;
   ans %= MOD;
   cand = K - 1 - (pre != -1);
   for (auto e : E[cur]) {
      if (e != pre) {
         dfs(e, cur, cand);
         cand--;
      }
   }
}
int main() {
   cin >> N >> K;
   int a, b;
   for (int i = 0; i < N - 1; i++) {
      cin >> a >> b;
      a--;
      b--;
      E[a].push_back(b);
      E[b].push_back(a);
   }
   dfs(0, -1, K);
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 9216
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
        t: chars,
    }
    let mut idx = 0;
    let mut found = false;
    for i in 0..(s.len() - t.len() + 1) {
        if s[i..s.len()].iter().zip(t.iter())
                 .all(|(a,b)| *a=='?' || a==b) {
            idx = i;
            found = true;
        }
    }
    if !found {
        println!("UNRESTORABLE");
        return;
    }
    let mut s = s;
    for i in 0..t.len() {
        s[idx+i] = t[i];
    }
    let s = s.iter().map(|c| if *c == '?' {'a'} else {*c}).collect::<String>();
    println!("{}", s);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstring>

using namespace std;

int main(void)
{
    int l,i;
    string s;
    cin>>s;
    l=s.size();
    for(i=0;i<l;i++)
    {
        if(i%2==0)
        {
            if(s[i]=='R'||s[i]=='U'||s[i]=='D')
                continue;
            else
                break;
        }
        else
        {
            if(s[i]=='L'||s[i]=='U'||s[i]=='D')
                continue;
            else
                break;
        }
    }
    if(i==l)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
import sys


class Dice:
    def __init__(self, labels):
        self.labels = labels

    def north(self):
        self.change([2, 6, 3, 4, 1, 5])

    def south(self):
        self.change([5, 1, 3, 4, 6, 2])

    def east(self):
        self.change([4, 2, 1, 6, 5, 3])

    def west(self):
        self.change([3, 2, 6, 1, 5, 4])

    def change(self, convert):
        result = []
        for i in range(6):
            result.append(self.labels[convert[i] - 1])

        self.labels = result

directions = 'EEEESEEEESEEEESEEEESNWSEEEESSEEEE'

dice1 = Dice(list(map(int, input().split())))
dice2 = Dice(list(map(int, input().split())))

for direction in directions:
    if direction == 'N':
        dice1.north()
    if direction == 'S':
        dice1.south()
    if direction == 'E':
        dice1.east()
    if direction == 'W':
        dice1.west()

    if dice1.labels == dice2.labels:
        print('Yes')
        sys.exit(0)

print('No')

Measured memory_bytes: 7792
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    a: usize,
    b: usize
    }
    let c = if a <= 5 { 0 } else if a > 12
    { b } else { b / 2 };
    println!("{}", c)
}


Measured memory_bytes: 2120
if __name__ == '__main__':
    n = int(input())
    lst = [int(input()) for x in range(n)]
    max_lst = []
    tmpmax = 0
    for i in range(1, n + 1):
        tmpmax = max(tmpmax, lst[-i])
        max_lst.append(tmpmax)
    maxA = -(10 ** 9 + 1)
    for i in range(n - 1):
        maxA = max(maxA, max_lst[-i-2] - lst[i])
    print(maxA)


Measured memory_bytes: 15004
#coding:utf-8
import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    A,B = LMIIS()
    #A:1.08 B:1.1
    from math import ceil,floor
    # print(A/0.08,B/0.1)
    # print(ceil(A/0.08),ceil(B/0.1))
    
    A_min = ceil(A/0.08)
    A_max = ceil((A+1)/0.08)-1
    B_min = ceil(B/0.1)
    B_max = ceil((B+1)/0.1)-1
    # print(A_min,A_max,B_min,B_max)
    if A_max < B_min or B_max < A_min:
        print(-1)
    else:
        print(max(A_min,B_min))
    
    # print(A_min,A_max,B_min,B_max)
    # for i in range(1,100000):
    #     if floor(i *0.08) == A and floor(i *0.1) == B:
    #         print(i)
    #         return
    # print(-1)

    

if __name__ == '__main__':
    main()

Measured memory_bytes: 38432
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long int ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PLL, int> PLLI;
typedef pair <PLL, PLL> PP;
typedef pair <PII, int> PPI;
typedef pair <ll, int> PLI;
typedef unsigned int ui;
const int mod = 1e9+7;
const int inf = 1e9+9;
const ll MOD = 1e9+696969;
const long long INF = 1e18+3;

int odl[1000100][2], n;
vector <int> v[1000100];

void dfs(int x, int par, int type)
{
	for (auto u : v[x])
		if (u != par)
		{
			odl[u][type] = odl[x][type] + 1;
			dfs(u, x, type);
		}
}

int main()
{
	boost;
	cin >> n;
	FOR(i, 2, n) {
		int a, b;
		cin >> a >> b;
		v[a].pb(b);
		v[b].pb(a);
	}
	
	dfs(1, 1, 0);
	dfs(n, n, 1);
	
	int resA = 0, resB = 0;
	FOR(i, 1, n)
		if (odl[i][0] <= odl[i][1]) ++resA;
		else ++resB;

	if (resA > resB) cout << "Fennec";
	else cout << "Snuke";
}


Measured memory_bytes: 35712
package main

import (
	"container/heap"
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	pq := make(PriorityQueue, n)
	var a int
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		pq[i] = &Item{number: a, count: 1}
	}
	heap.Init(&pq)

	var b, c int
	for i := 0; i < m; i++ {
		fmt.Scan(&b, &c)
		heap.Push(&pq, &Item{number: c, count: b})
	}

	ans := 0
	total := 0
	for pq.Len() > 0 && total < n {
		item := heap.Pop(&pq).(*Item)
		cnt := item.count
		if n < total+cnt {
			cnt = n - total
		}
		ans += item.number * cnt
		total += cnt
	}

	fmt.Println(ans)
}

// An Item is something we manage in a priority queue.
type Item struct {
	number int
	count  int
	// index  int // The index of the item in the heap.
}

// PriorityQueue .
type PriorityQueue []*Item

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Less(i, j int) bool {
	// We want Pop to give us the highest, not lowest, priority so we use greater than here.
	return pq[i].number > pq[j].number
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	// pq[i].index = i
	// pq[j].index = j
}

// Push .
func (pq *PriorityQueue) Push(x interface{}) {
	// n := len(*pq)
	item := x.(*Item)
	// item.index = n
	*pq = append(*pq, item)
}

// Pop .
func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil // avoid memory leak
	// item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}


Measured memory_bytes: 11520
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P) :
 P = sorted(P)
 phU = []
 phU.append(P[0])
 phU.append(P[1])
 for p in P[2:] :
  phU.append(p)
  if isCLKWISE(phU) : continue
  while(True):
   del phU[-2]
   try:
    if isCLKWISE(phU) : break
   except IndexError : break
 phL = []
 phL.append(P[-1])
 phL.append(P[-2])
 for p in P[-3::-1] :
  phL.append(p)
  if isCLKWISE(phL) : continue
  while(True) :
   del phL[-2]
   try:
    if isCLKWISE(phL) : break
   except IndexError : break
 ph = phU + phL[1:-1]
 return ph
  
n = range(int(input()))
P = [[int(x) for x in input().split()] for _ in n]
P = ConvexHullScan(P)
P.reverse()
print(len(P))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(P)])[2]
for p in P[idx:] + P[:idx] : print(p[0],p[1])

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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int n, k;
	cin >> n >> k;
	vi arr(n);
	M00(i, n) cin >> arr[i];
	sort(all(arr));
	int sum = 0;
	M00(i, k) sum += arr[i];
	cout << sum << endl;
}


Measured memory_bytes: 3668
import sys
input = sys.stdin.readline
na = input()
n = ['8'] * 3
for i in range(3) :
    n[i] = na[i]
for i in range(3) :
    if n[i] == '1' :
        n[i] = '9'
        continue
    elif n[i] == '9' :
        n[i] = '1'
N = 0
for i in range(3) :
    k = int(n[i])
    N += k * 10 ** (2-i)
print(N)

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

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

vector<edge> graph[1500];
int dist[1500][1500];
int N, R, maxDist;
bool ans[1500];

void dijkstra(int start)
{
    priority_queue<P, vector<P>, greater<P>> que;
    vector<bool> visited(N, false);
    dist[start][start] = 0;
    que.push({0, start});

    while (!que.empty())
    {
        int d, now;
        tie(d, now) = que.top();
        que.pop();

        if (visited[now])
            continue;

        visited[now] = true;

        for (auto e : graph[now])
        {
            if (dist[start][e.to] <= d + e.cost)
                continue;

            dist[start][e.to] = dist[start][now] + e.cost;
            que.push(P(d + e.cost, e.to));
        }
    }
}

void solve(int start)
{
    queue<int> que;
    vector<int> _visited(N, false);

    rep(i, N) if(dist[start][i] == maxDist) que.push(i);
    
    while(!que.empty())
    {
        int now = que.front();
        que.pop();

        if(_visited[now]) continue;

        _visited[now] = true;
        ans[now] = false;

        for(auto e : graph[now])
        {
            if(dist[start][e.to] == dist[start][now] - e.cost)
            {
                que.push(e.to);
            }
        }
    }

    return;
}

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

    rep(i, R)
    {
        int s, t, d;
        cin >> s >> t >> d;

        s--;
        t--;

        graph[s].push_back({t, d});
        graph[t].push_back({s, d});
    }

    rep(i, N) ans[i] = true;

    rep(i, N) rep(j, N) dist[i][j] = iINF;

    rep(i, N) dijkstra(i);
    rep(i, N) rep(j, N) maxDist = max(maxDist, dist[i][j]);

    vector<int> output;

    rep(i, N) solve(i);

    rep(i, N) if(ans[i]) output.push_back(i + 1);

    cout << output.size() << endl;

    rep(i, output.size()) cout << output[i] << endl;

    return 0;
}


Measured memory_bytes: 12116
#include <stdio.h>

int main(void){
	int N,K;
	scanf("%d %d",&N,&K);
	char S[N+1];
	scanf("%s",S);

	K = K-1;
	if(S[K]>64 && S[K]<91){S[K]+=32;}
	else if(S[K]>96 && S[K]<122){ S[K]-=32;}
	printf("%s\n",S );
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<int> a(m+1);
	rep(i,n){
		int k;cin >> k;
		rep(j,k){
			int b;cin >> b;
			a.at(b)++;
		}
	}
	int ans=0;
	rep(i,m+1) if(a.at(i)==n) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;
int H, W, N;
int ans[1000][1000];

signed main()
{
    cin >> H >> W;
    cin >> N;
    vector<int> a(N);
    rep(i, N) { cin >> a[i]; }
    vector<int> b(H * W);
    int cnt = 0;
    rep(i, N)
    {
        rep(j, a[i])
        {
            b[cnt] = i + 1;
            cnt++;
        }
    }
    vector<vector<int>> c(H, vector<int>(W));
    rep(i, H)
    {
        rep(j, W)
        {
            c[i][j] = b[i * W + j];
        }
    }
    rep(i, H)
    {
        if (i % 2) {
            reverse(c[i].begin(), c[i].end());
        }
    }
    rep(i, H)
    {
        rep(j, W)
        {
            cout << c[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
N = int(input())
P = list(map(int, input().split()))

cnt = 0
pre_m = P[0]
for i in range(1, N+1) :
   
    m = min(P[i-1:i])
    if pre_m > m :
        pre_m = m
    else :
        m = pre_m

    if P[i-1] == m :
        cnt = cnt + 1

print(cnt)


Measured memory_bytes: 24744
#include <bits/stdc++.h>
#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++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;

int main()
{
  ll num, n, ans = 0;
  cin >> num >> n;
  while (num > 0) {
    ans++;
    num /= n;
  }
  cout << ans << endl;
  return 0;       
}

Measured memory_bytes: 3508