akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////
//

int main(){

    ll n,m,k;
    L3(n,m,k);
    ll x = k/n;
    cout<<(m*x)<<endl; 

    return 0;
}

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

template <typename T> T load() { T r; cin >> r; return r; }
template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    auto n = load<int>();
    auto init = array<int, 4>{0,0,0,0};
    for (auto i=0; i<n; ++i) {
        auto x = load<int>();
        ++init[x];
    }
    auto dyn = vector<vector<vector<long double>>>(n+1, vector<vector<long double>>(n+1, vector<long double>(n+1, 0.0l)));
    for (auto d=0; d<=n; ++d) {
        for (auto c=0; c+d<=n; ++c) {
            for (auto b=0; b+c+d<=n; ++b) {
                auto a = n - (b+c+d);
                if (a == n) continue;
                dyn[b][c][d] += 1;
                if (b > 0) dyn[b][c][d] += 1.0l * b / n * dyn[b-1][c][d];
                if (c > 0) dyn[b][c][d] += 1.0l * c / n * dyn[b+1][c-1][d];
                if (d > 0) dyn[b][c][d] += 1.0l * d / n * dyn[b][c+1][d-1];
                dyn[b][c][d] /= 1 - 1.0l * a / n;
            }
        }
    }
    cout << fixed << setprecision(12) << dyn[init[1]][init[2]][init[3]] << '\n';
}


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

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

    for (int i = 0; i < 3; i++) {
        if (s[i] == s[i + 1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll a,b,c; cin >> a >> b >> c;
  if(a==b) cout << c << endl;
  else if(b==c) cout << a << endl;
  else cout << b << endl;
}

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

int main() {
	int N;
	cin >> N;
	vector<long long> A(N);
	vector<int> B(1000001, 0);
	for (int i = 0; i < N; i++) cin >> A[i], B[A[i]]++;
	int ANS = 0;
	for (int i = 0; i < N; i++) {
		bool check = true;
		B[A[i]]--;
		for (int j = 1; j * j <= A[i]; j++) {
			if (A[i] % j == 0) {
				if (B[j] != 0) check = false;
				if (B[A[i] / j] != 0) check = false;
			}
		}
		B[A[i]]++;
		if (check) ANS++;
	}
	cout << ANS << endl;
}

Measured memory_bytes: 8744
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<climits>
#include<bitset>
#define int long long
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
inline int read(){
    int f=1,ans=0;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
    return f*ans;
}
const int MAXN=2e5+11;
int N,S1[MAXN],S2[MAXN],ans;
signed main(){
    N=read();for(int i=1;i<=N;i++){int x=read();S1[i]=S1[i-1]^x,S2[i]=S2[i-1]+x;}
    for(int i=1;i<=N;i++){
        int l=1,r=i,res;
        while(l<=r){
            int mid=(l+r)>>1;
            if((S1[i]^S1[mid-1])==(S2[i]-S2[mid-1])) res=mid,r=mid-1;
            else l=mid+1;
        }ans+=(i-res+1);
    }printf("%lld\n",ans);return 0;
}


Measured memory_bytes: 6348
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
typedef priority_queue<p> pq;
typedef priority_queue<p, vector<p>, greater<p>> gpq;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string s;
    cin >> s;

    int ans = INF;

    REP(i, s.size() - 2)
    {
        string s_sub = s.substr(i, 3);
        int v = (s_sub[0] - '0') * 100 + (s_sub[1] - '0') * 10 + (s_sub[2] - '0');
        chmin(ans, abs(753 - v));
    }

    cout << ans << endl;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template<typename T>
ostream& operator << (ostream& os, vector<T> v)
{
  os << "(";
  each (i, v) os << i << ",";
  os << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int L;
  while (cin >> L) {
    int x = 0;
    for (int i = 0; (1 << i) <= L; ++i) {
      if (L & (1 << i)) {
        x = i;
      }
    }

    vector<tuple<int, int, int>> es;
    for (int i = 0; i < x; ++i) {
      es.push_back(make_tuple(i, i + 1, 1 << (x - i - 1)));
      es.push_back(make_tuple(i, i + 1, 0));
    }

    int y = 1 << x;
    for (int i = 0; i < x; ++i) {
      if (L & (1 << i)) {
        es.push_back(make_tuple(0, x - i, y));
        y += 1 << i;
      }
    }

    set<int> v;
    each (e, es) {
      v.insert(get<0>(e));
      v.insert(get<1>(e));
    }
    cout << v.size() << ' ' << es.size() << endl;
    each (e, es) {
      cout << get<0>(e) + 1 << ' ' << get<1>(e) + 1 << ' ' << get<2>(e) << endl;
      assert(get<0>(e) < get<1>(e));
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
d = int(input())
*C, = map(int, input().split())
S = [list(map(int, input().split())) for i in range(d)]
X = []
L = [-1 for j in range(26)]
for i in range(d):
    max_diff = 0
    best_j = 0
    for j in range(26):
        memo = L[j]
        L[j] = i
        diff = S[i][j] - sum([C[jj] * (i - L[jj]) for jj in range(26)])
        if diff > max_diff:
            max_diff = diff
            best_j = j
        L[j] = memo
    L[best_j] = i
    X.append(best_j)
for x in X:
    print(x + 1)


Measured memory_bytes: 74512
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


const int maxn = (int) 1e5 + 10;

int a[maxn], q[maxn];

int n;
int m;
long long k;

int read() {
  if (scanf("%d", &n) < 1) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  scanf("%d%lld", &m, &k);
  return 1;
}

pair<int, int> go[maxn];

int used[maxn];

int ans[maxn];

void solve() {
  for (int i = 0; i < n - 1; ++i) {
    go[i] = mp(i, 0);
  }

  for (int i = 0; i < m; ++i) {
    int x;
    scanf("%d", &x);
    x -= 2;
    assert(0 <= x && x < n - 1);
    swap(go[x], go[x + 1]);
  }
  /*for (int i = 0; i < n - 1; ++i) {
    eprintf("(%d,%d)\n", go[i].first, go[i].second);
  }*/
  
  for (int i = 0; i < n - 1; ++i) {
    used[i] = 0;
  }
  for (int i = 0; i < n - 1; ++i) {
    if (used[i]) {
      continue;
    }
    vector<int> vs;
    for (int x = i; !used[x]; x = go[x].first) {
      vs.pb(x);
      used[x] = 1;
    }
    int rem = k % (2 * sz(vs));

    int xr = 0;
    for (int i = 0, j = 0, jr = 0; i < sz(vs); ++i) {
      while (j < i + rem) {
        xr ^= go[vs[jr]].second;
        if (++jr == sz(vs)) {
          jr = 0;
        }
        ++j;
      }
      //eprintf("%d -> %d (%d)\n", vs[i], vs[jr], xr);
      ans[vs[i]] = a[vs[jr] + 1] - a[vs[jr]];
      if (xr) {
        ans[vs[i]] = -ans[vs[i]];
      }
      //eprintf("ans[%d] = %d\n", vs[i], ans[vs[i]]);
      xr ^= go[vs[i]].second;
    }
  }
  long long val = a[0];
  for (int i = 0; i < n; ++i) {
    printf("%lld\n", val);
    val += ans[i];
  }
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 3440
#include <iostream>
#include <stack>

int main(void){
    int num;
    std::stack<int> st;
    while(std::cin >> num){
        if(num == 0){
            std::cout << st.top() << std::endl;
            st.pop();
        } else {
            st.push(num);
        }
    }
}

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

int main(int argc, char const *argv[]) {
  int a, b;
  cin >> a >> b;
  if (a>b) {
    cout << 2*a-1 << '\n';
  }
  else if (a<b) {
    cout << 2*b-1 << '\n';
  }
  else{
    cout << 2*a << '\n';
  }
}

Measured memory_bytes: 256
a, b, k = map(int, raw_input().split())
if (b - a + 1)/2 >= k:
	for i in range(a, a + k):
		print i
	for i in range(b - k + 1,b + 1):
		print i
else :
	for i in range(a, b + 1):
		print i

Measured memory_bytes: 2568
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
#define loop(i,n) for(int i = 0; i < (n); i++)
#define loops(i,f,n) for(int i = (f); i < (n); i++)
#define INF 9999999

int main()
{
	int n;
	cin >> n;
	vector<int> cards(n);
	loop(i, n)cin >> cards[i];
	sort(cards.begin(), cards.end());
	int ans = 0;
	loop(i, n)
	{
		if (i % 2 == 0)ans += cards[i];
		else ans -= cards[i];
	}
	cout << abs(ans) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <queue>
#define INF 0x3f3f3f
using namespace std;
struct edge
{
    int from,to,cost;
};
int V[100],E[100],dis[100][100],N;
edge edges[100];
void floyd()
{
    int i,j,k;
    for(k=0;k<N;k++)
        for(i=0;i<N;i++)
            for(j=0;j<N;j++)
                dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
}
int main()
{
    int n,i,j,k,a,b,c,ans,big;
    while(scanf("%d",&n)&&n)
    {
        ans=0;
        N=0;
        for(k=0;k<100;k++)
            for(i=0;i<100;i++)
                {
                    dis[k][i]=INF;
                    if(k==i)
                        dis[k][i]=0;
                }
        for(i=0;i<n;i++)
        {
            scanf("%d %d %d",&a,&b,&c);
            dis[a][b]=c;
            dis[b][a]=c;
            N=max(N,a);
            N=max(N,b);
        }
        N++;
        floyd();
        int x[100]={0};
        for(i=0;i<N;i++)
        {
            for(j=0;j<N;j++)
                x[i]+=dis[i][j];
        }
        int pos = min_element(x,x+N)-x;
        cout<<pos<<" "<<x[pos]<<endl;
    }

    return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

typedef long long ll;
ll m = 1e9 + 7;
ll comb[100001] = { 0 };
ll comb_inv[100001] = { 0 };

ll binpow(ll a, ll b)
{
  if (b == 0)
    return 1;
  else if (b % 2 == 1)
    return a * binpow(a, b - 1) % m;
  else {
    ll tmp = binpow(a, b / 2);
    return tmp * tmp % m;
  }
}


void init_table(ll n)
{
  ll x = 1;
  comb[0] = 1;
  comb_inv[0] = 1;

  for (ll i = 1; i <= n + 1; i++) {
    x = x * i % m;
    comb[i] = x;
    comb_inv[i] = binpow(comb[i], m - 2);
  }
}

ll combination(ll n, ll r)
{
  if (n < r)
    return 0;

  if (r == 0 || n == r)
    return 1;

  return (((comb[n] * comb_inv[r]) % m) * comb_inv[n - r]) % m;
}

int main()
{
  ll n;
  ll ds, de, dn, d;
  ll a[100001];
  int b[100001] = { 0 };

  std::cin >> n;

  init_table(n);

  for (ll i = 0; i < n + 1; i++) {
    std::cin >> a[i];
    if (b[a[i]] == 0)
      b[a[i]] = 1;
    else {
      de = i;
      dn = a[i];
    }
  }

  for (ll i = 0; i < n + 1; i++) {
    if (a[i] == dn) {
      ds = i;
      d = de - ds;
      break;
    }
  }

  for (ll i = 0; i < n + 1; i++) {
    std::cout << (combination(n + 1, i + 1) - combination(n + 1 - (d + 1), i) + m) % m << std::endl;
  }

  return 0;
}


Measured memory_bytes: 3968
N,M,C=list(map(int,input().split()))
B=list(map(int,input().split()))

cnt=0
for _ in range(N):
    A=[int(a) for a in input().split()]
    sum=0
    for j in range(M):
        sum+=A[j]*B[j]
    if sum+C > 0:
        cnt+=1

print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=205,P=1e9+7,L=62;

int mul(int a,int b){ return 1ll*a*b%P; }
//int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }
int gcd(int a,int b){ return !b?a:gcd(b,a%b); }

int n,T;
ll a[N],pr[L+2],bk[L+2],ans;
char s[N];
void add(ll *b,ll x){
	dec(i,L,0){
		if((x>>i)&1){
			if(b[i])x^=b[i];
			else {b[i]=x; break; }
		}
	}
}
bool test(ll *b,ll x){
	dec(i,L,0)if((x>>i)&1){
		x^=b[i];
	}
	return x==0;
}
bool equal(ll *b1,ll *b2){
	dec(i,L,0)if(b1[i]){
		if(!test(b2,b1[i]))return false;
	}
	return true;
}

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("d.in","r",stdin); 
#endif
	read(T); 
	while(T--){
		read(n); 
		rep(i,1,n)read(a[i]); 
		scanf("%s",s+1); 
		ans=0;
		mem(bk,0);
		dec(i,n,1){
			if(s[i]=='0')add(bk,a[i]);
			else ans|=!test(bk,a[i]);
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,M;
  
  int p=0,q=0;
    
  cin >> N >> M;
  p=1;
  q=4*M;
  
  vector<int> A(N);
  for(int i=0;i<N;i++) {
    cin >> A.at(i);}
  int sum=0;
  for(int i=0;i<N;i++) {
    sum+=A.at(i);}
  int x=0;
  for(int i=0;i<N;i++) {
    if(A.at(i)*q>=sum) {
      x+=1;}
    else {
      x+=0;}}
    if(x>=M) {
      cout << "Yes" << endl;}
    else {
      cout << "No" << endl;}
  }
    
    
  
      
    
    



Measured memory_bytes: 256
N,M= map(int,input().split())
list=[[False for i in range(N)] for j in range(N)]
for i in range (M):
    a,b=map(int,input().split())
    list[a-1][b-1]=True
    list[b-1][a-1]=True
count = 0
flag = [False for i in range(N)]
flag[0]=True

def depth_search (now,flag):
    global count
    tmp_flag = []
    tmp_flag += flag
    tmp_flag[now] = True
    if(False in tmp_flag):
        for i in range(1,N):
            if(list[now][i] and not tmp_flag[i]):
                depth_search(i,tmp_flag)
    else:
        count += 1

for i in range(1,N):
    if(list[0][i]):
        depth_search(i,flag)
print(count)


Measured memory_bytes: 3064
package main

import (
        "fmt"
)

func solution(n, t, a int, h []int) int {
        lo := 1 << 31
        out := 0
        for i := range h {
                ave := 1000*t - (h[i] * 6)
                diff := abs(1000*a - ave)
                if lo > diff {
                        out = i
                        lo = diff
                }

        }
        return out + 1
}

func abs(x int) int {
        if x < 0 {
                return -x
        }
        return x
}

func main() {
        var n, t, a int
        fmt.Scan(&n, &t, &a)
        h := make([]int, n)
        for i := range h {
                fmt.Scan(&h[i])
        }
        fmt.Println(solution(n, t, a, h))
}

Measured memory_bytes: 512
using System;
class ProgramA
    {
        static void Main(string[] args)
        {
            
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int a = int.Parse(input[1]);
            int b = int.Parse(input[2]);

            int c = a*n;


            if (c <= b)
                Console.WriteLine(c);
            else
                Console.WriteLine(b);
    
        }
    }

Measured memory_bytes: 13140
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>


const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	lint N, H;
	cin >> N >> H;

	vector<lint> a(N), b(N);
	for (int i = 0; i < N; i++) cin >> a[i] >> b[i];

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	lint sum = 0;
	auto x = lower_bound(b.begin(), b.end(), a.back());
	for (auto itr = b.end(); itr != x; itr--) {
		sum += *(itr - 1);
		if (sum >= H) {
			cout << b.end() - itr + 1 << "\n";
			return 0;
		}
	}

	H -= sum;
	cout << (b.end() - x) + (H - 1) / a.back() + 1 << "\n"; 

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll N; cin >> N;
    map<string, ll> m;
    for (int i = 0; i < N; ++i) {
        string s; cin >> s;
        if (m.count(s)) {
            m[s]++;
        }
        else {
            m[s] = 1;
        }
    }
    cout << m.size() << endl;
}

Measured memory_bytes: 19184
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.println(sc.nextInt() * sc.nextInt());
		//System.out.println(n);
		
		
	}

}

Measured memory_bytes: 27056
#include<bits/stdc++.h>
#include<atcoder/all>
#define int long long
using namespace std;
using namespace atcoder;
signed main(){
  int N,M;
  cin>>N>>M;
  dsu D(N);
  while(M--){
    int a,b;
    cin>>a>>b;
    D.merge(a-1,b-1);
  }
  cout<<D.groups().size()-1<<endl;
}

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

using namespace std;

int N;
vector<int> vec;

int main()
{
    int k, x, summ = 0;
    cin >> N >> k;
    for(int i = 0; i < N; i++)
    {
        cin >> x;
        vec.push_back(x);
    }
    sort(vec.begin(), vec.end());

    for(int i = 0; i < k; i++)
    {
        summ += vec[i];
    }
    cout << summ << endl;

    return 0;
}

Measured memory_bytes: 3592
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
      int[]po=new int[]{1,4,8,16,32,64,128,256,512,9,27,81,243,729,25,125,100,625,36,216,49,343,1000,121,144,169,196,225,289,324,361,400,441,484,529,576,676,784,841,900,961,1001};
		Arrays.sort(po);
      int n=sc.nextInt();
      int i=0;
      for(i=0;po[i]<=n;i++){}
      System.out.println(po[i-1]);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());

  vector<int> ps;
  vector<int> ns;
  ps.push_back(A[N - 1]);
  ns.push_back(A[0]);
  for (int i = 1; i < N - 1; ++i) {
    if (A[i] > 0) ps.push_back(A[i]);
    else ns.push_back(A[i]);
  }

  int ans = 0;
  for (auto p : ps) ans += p;
  for (auto n : ns) ans -= n;
  cout << ans << endl;

  int tmp = ns[0];
  for (int i = 1; i < ps.size(); ++i) {
    cout << tmp << " " << ps[i] << endl;
    tmp = tmp - ps[i];
  }
  cout << ps[0] << " " << tmp << endl;
  tmp = ps[0] - tmp;
  for (int i = 1; i < ns.size(); ++i) {
    cout << tmp << " " << ns[i] << endl;
    tmp = tmp - ns[i];
  }
  
  return 0;
}


Measured memory_bytes: 2808
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);

		int A=sc.nextInt();
		int B=sc.nextInt();
		int max=0;
		if(A>B) {
			max=A+A-1;
		}else if(B>A) {
			max=B+B-1;
		}else if(A==B) {
			max=A+B;
		}

		System.out.println(max);
	}
}


Measured memory_bytes: 24020
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll knap(ll w[],ll v[],ll W,ll n,vector<vector<ll>>&dp)
{
	if (n==0||W==0)
	{
		return 0;
	}
	if(dp[n-1][W]==-1)
	{
    	if(w[n-1]<=W)
    	{
    		return dp[n-1][W]=max(v[n-1]+knap(w,v,W-w[n-1],n-1,dp),knap(w,v,W,n-1,dp));
    	}
    	else
    	{
    		return dp[n-1][W]=knap(w,v,W,n-1,dp);
    	}
	}
	else
	{
		return dp[n-1][W];
	}

}
int main()
{
	ll n,W;
	cin>>n>>W;
	ll w[n],v[n];
	for(int i=0;i<n;i++)
	{
		cin>>w[i]>>v[i];
	}
	//vector<ll>dp(W+1,-1);
	//dp[0]=0;
	//ll dp[n][W+1];
	vector<vector<ll>>dp(n,vector<ll>(W+1,-1));
	//cout<<dp[W]<<endl;
	cout<<knap(w,v,W,n,dp)<<endl;

	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
const ll mod = 1e9 + 7;
const int inf = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	ll T, A, Tmax= 0,Amax=0;
	rep(i, N) {
		cin >> T >> A;
		Tmax = max(T, Tmax);
		Amax = max(A, Amax);
		ll x = max((Tmax%T == 0 ? Tmax / T : Tmax / T + 1), (Amax%A == 0 ? Amax / A : Amax / A + 1));
		Tmax = x*T;
		Amax = x*A;
	}
	cout << Tmax + Amax << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列配列の入力
            string[] inputStrArray = Console.ReadLine().Split(' ');
            string s = inputStrArray[0];
            string t = inputStrArray[1];

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long a = inputLongArray[0];
            long b = inputLongArray[1];

            // 文字列の入力
            string u = Console.ReadLine();

            if(s == u)
            {
                Console.WriteLine($"{a - 1} {b}");
            }
            else
            {
                Console.WriteLine($"{a} {b - 1}");
            }

            Console.Out.Flush();
        }
    }
}


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

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

int main(){
  int n,x;
  cin >> n >> x;
  vector<int> l(n);
  rep(i,n){
    cin >> l[i];
  }
  int ans = 1;
  int p = 0;
  rep(i,n){
    p += l[i];
    if(p<=x)ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);

		String a = s.next();
		String b = s.next();
		String c = s.next();

		String ans1 = a.toUpperCase();
		String ans2 = b.toUpperCase();
		String ans3 = c.toUpperCase();
		System.out.print(ans1.charAt(0));
		System.out.print(ans2.charAt(0));
		System.out.print(ans3.charAt(0));

	}

}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;

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

const int MOD = 1000000007;
const int N = 100005;
const double PI =4*atan(1);

ll a[105];
bool dp[N];
bool vis[N];
ll n,k;

bool dfs(ll cur){
	if(vis[cur])return dp[cur];
	vis[cur]=1;
	for(int i=0;i<n;i++){
		if(a[i]>cur)continue;
		if(dfs(cur-a[i])==0)return dp[cur]=1;
	}
//	cout <<cur << " "<< "troll"<< endl;
	return dp[cur]=false;
}


int main(){
    ios::sync_with_stdio(0);
    //freopen("baklava.in","r",stdin);
    cin.tie(0);
    cout.tie(0);
    //start
    memset(vis,0,sizeof(vis));
    cin >> n >> k;
    for(int i=0;i<n;i++){
    	cin >> a[i];
    }
    bool cond=dfs(k);
    if(cond)cout << "First";
    else cout << "Second";
	
    return 0;
}


Measured memory_bytes: 3584
object Main extends App {
  val input = io.Source.stdin.getLines.toSeq.head.split(' ').map(_.toLong)
  val a=input(0)
  val b=input(1)
  val c=input(2)
  private def func():String={
  	var i=0;
  	while(i < a*b){
      if((b*i+c) % a == 0) return "YES"
      i += 1
  	}
    "NO"
  }
  println(func())
}


Measured memory_bytes: 27312
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut prev = 1 << 30;
    let mut ans = 0;
    for i in 0..n - 1 {
        let b = read::<usize>();
        ans += std::cmp::min(prev, b);
        prev = b;
    }
    ans += prev;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  ll a[N];
  ll ans = 0;
  ll num[100001];
  for (int i = 0; i <= 100000; i++) {
    num[i] = 0;
  }
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    if (a[i] > 100000) {
      ans++;
    } else {
      num[a[i]]++;
    }
  }
  for (int i = 1; i <= 100000; i++) {
    if (num[i] < i) {
      ans += num[i];
    } else {
      ans += num[i] - i;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5180
//##Moh_K_Imar .......
//27/08/2020  ...  8.05
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
   ll a;
   cin>>a;
   cout<<a+(a*a)+(a*a*a)<<endl;

   return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
using plli=pair<ll,int>;
using vplli=vector<pair<ll,int>>;
using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int l,r,d;
    cin>>l>>r>>d;
    int cnt=0;
    rep(i,l,r+1){
        if(i%d==0)cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}




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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;

int main(){
  string s;
  cin >> s;
  ll cntBC = 0, cntA = 0;
  ll ans = 0;
  for(int i = s.length()-1; i >= 0; i--){
    if(cntBC && cntA && s[i]!= 'A'){
      //cout << cntA+cntBC-1 << " " << i << endl;
      ans+= cntA*cntBC;
      cntA = 0;
    }
    if(i-1 >= 0 && s[i] == 'C' && s[i-1] == 'B'){
      cntBC++;
      i--;
    }
    else if(s[i] == 'A' && cntBC){
      cntA++;
    }
    else{
      cntA = cntBC = 0;
    }
  }
  if(cntA && cntBC){
    ans += cntA * cntBC;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
S = input()
ans = 0
bc = 0
reset = set(['AC','BA','BB','CC'])
for i in range(len(S) + 1):

    if S[len(S) - i - 2 : len(S) - i] == 'BC':
        bc += 1
    elif S[len(S) - i - 2 : len(S) - i] in reset:
        bc = 0
    if len(S) - i - 2 >= 0 and S[len(S) - i - 2] == 'A':
        ans += bc
print(ans)

Measured memory_bytes: 3500
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-10;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
long long st[310][310];
long long C[1050][1050];
long long dp[310][310];
long long M;
long long pw(long long a,long long b){
	a%=M;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%M;
		a=a*a%M;
		b/=2;
	}
	return ret%M;
}
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	scanf("%lld",&M);
	a++;
	b--;
	C[0][0]=1;
	for(int i=0;i<1010;i++){
		for(int j=0;j<=i;j++){
			C[i+1][j]=(C[i+1][j]+C[i][j])%M;
			C[i+1][j+1]=(C[i+1][j+1]+C[i][j])%M;
		}
	}
	st[0][0]=1;
	for(int i=1;i<310;i++){
		for(int j=1;j<310;j++){
			st[i][j]=(st[i-1][j-1]+j*st[i-1][j])%M;

		}
	}
	dp[0][a]=1;
	for(int i=0;i<b;i++){
		for(int j=1;j<=a;j++){
			if(!dp[i][j])continue;
		//	printf("%d %d: %lld\n",i,j,dp[i][j]);
			for(int k=1;k<=j;k++){
				dp[i+1][k]=(dp[i+1][k]+dp[i][j]*st[j][k])%M;
			}
		}
	}
	long long ret=0;
	for(int i=1;i<=a;i++)ret=(ret+dp[b][i])%M;
	printf("%lld\n",ret);
}


Measured memory_bytes: 9344
#!/usr/bin/env perl
use 5.10.0;
use utf8;
use strict;
use warnings;
use open qw( :utf8 :std );
use Data::Dumper;

chomp( my $n = readline );
my %got;
my $count = 0;

while ( <> ) {
    chomp( my $line = $_ );
    $count++
        if !( $got{ $line }++ );
}

say $count;

exit;



Measured memory_bytes: 32268
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n,a[5000],b,i,bmax,j;
    while(1){
        scanf("%d",&n);
        if(n==0)
            return 0;
        b=0;
        bmax=-9999999;
        for(i=0;i<n;i++){
            scanf("%d",&a[i]);
        }
        for(i=0;i<n;i++){
            for(j=i;j<n;j++){
                b+=a[j];
                if(bmax<b)
                    bmax=b;
                //printf("b:%d bmax:%d\n",b,bmax);
            }
            b=0;
            
            
        }
        
        
        printf("%d\n",bmax);
    }
    
    return 0;
}

Measured memory_bytes: 620
#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int mod(int a, int b) {
	return abs(a - (a / b) * b);
}

int main() {
	int N;
	string ans;

	cin >> N;

	int rest;
	while (abs(N) > 0) {
		rest = mod(N, -2);
		ans = to_string(rest) + ans;
		N = (N - rest) / (-2);
	}

	if (ans.size() == 0) cout << 0 << endl;
	else cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        if(x == 1 || x == 2) {
            System.out.println(1);
        } else if(x == 1000) {
            System.out.println(1000);
        } else {
            for(int i = x; i >= 1; i--) {
                if(isPower(i)) {
                    System.out.println(i);
                    break;
                }
            }
        }

    }

    public static boolean isPower(int n) {
        if(n == 1) {
            return false;
        } else {
            for(int i = 2; Math.pow(n, 1.0/i) >= 2.0; i++) {
                double d = Math.pow(n, 1.0/i);
                if(d - Math.floor(d) < 0.00001)
                    return true;
            }
        }

        return false;
    }
}

Measured memory_bytes: 22868
#include<stdio.h>

int main(){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(b<d){
        d=b;
    }
    if(a>c){
        c=a;
    }
    a=0;
    if(d-c>0) a=d-c;
    printf("%d",a);
}

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

int main(){
	int n,ans=0;cin>>n;
	int a[21],b[21],c[20];
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
	    scanf("%d",&b[i]);
	    ans+=b[i];
	}
	for(int i=1;i<=n-1;i++)scanf("%d",&c[i]);
	for(int i=1;i<=n-1;i++)if(a[i]+1==a[i+1])ans+=c[a[i]];
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
A=[list(map(int,list(input().split()))) for i in range(n)]
b=[list(map(int,list(input().split()))) for i in range(m)]

for i in range(n):
    ans = 0
    for j in range(m):
        ans += A[i][j] * b[j][0]
    print(ans)




Measured memory_bytes: 6028
def check(w_list, k, P):
    tmp = 0
    tmp_k = 1
    if max(w_list) > P:
        return False
    for w in w_list:
        tmp += w
        if tmp > P:
            tmp_k += 1
            tmp = w
    if tmp_k <= k:
        return True
    else:
        return False


def binary_search(w_list, k, l, r):
    while(r - l > 1):
        c = (l + r) // 2
        # print(c)
        # print(check(w_list, k, c))
        if check(w_list, k, c):
            r = c
        else:
            l = c

    return r


n, k = map(int, input().split())
w_list = []
for _ in range(n):
    w_list.append(int(input()))

max_P = n * 10000

min_P = binary_search(w_list, k, 0, max_P)

print(min_P)



Measured memory_bytes: 9552
let rec ( *@ ) a b = (a * b) mod 1000000007
let rec mod_pow a n =
  if n <= 0 then 1
  else if n mod 2 = 1 then a *@ mod_pow a (n-1)
  else let h = mod_pow a (n/2) in h *@ h
let () =
  let n = Scanf.scanf "%d" (fun x -> x) in
  let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
  Array.sort (-) a;
  let z = n mod 2 in
  let res =
    a
    |> Array.mapi (fun i e -> (i + z) / 2 * 2 + 1 - z = e)
    |> Array.fold_left (&&) true
  in
  Printf.printf "%d\n" (if res then mod_pow 2 (n / 2) else 0)

Measured memory_bytes: 6016
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vl lucas(100, -1);
    lucas[0]            = 2;
    lucas[1]            = 1;
    function<ll(int)> l = [&](int n) {
        if (lucas[n] != -1)
            return lucas[n];
        return lucas[n] = l(n - 1) + l(n - 2);
    };
    cout << l(n) << "\n";
    return 0;
}

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

int main() {
  string S;
  cin >> S;

  if (S[2] == S[3] && S[4] == S[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

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

int x[256], y[256];

int main() {
    for(;;) {
        int n;
        scanf("%d", &n);
        if(n==0) return 0;
        rep(i, n-1) {
            int k, d;
            scanf("%d%d", &k, &d);
            x[i+1] = x[k]+dx[d];
            y[i+1] = y[k]+dy[d];
        }
        const int w = *max_element(x, x+n)-*min_element(x, x+n);
        const int h = *max_element(y, y+n)-*min_element(y, y+n);
        printf("%d %d\n", w+1, h+1);
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pow(a,b) (ll)(pow(a,b)+0.5);

//#define min(a,b)  ((a)<=(b)?(a):(b));
// #define aass(x)   x>=0?x:-x;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
 ll i,n;
string s;
cin>>n>>s;
for(i=0;i<s.length();i++)
{
    if(s[i]+n%26>90)s[i]=s[i]+n%26-26;

else s[i]+=n%26;
}
for(i=0;i<s.length();i++)cout<<s[i];

return 0;

}

Measured memory_bytes: 256
n = int(input())

from decimal import Decimal
A = []
B = []
for _ in range(n):
    a, b = map(Decimal, input().split())
    A.append(a)
    B.append(b)



A = sorted(A)
B = sorted(B)



if n % 2 == 1:
    am = A[n // 2]
    bm = B[n // 2]
else:
    am = (A[n//2] + A[n//2-1]) / 2
    bm = (B[n//2] + B[n//2-1]) / 2



if n % 2 == 1:
    print(bm - am + 1)
else:
    print(int((bm - am) * 2 + 1))



Measured memory_bytes: 59724
from heapq import heappush, heappop

H,W,T,Q = map(int,input().split())

pint = [[0]*(W+1) for _ in range(H+1)]

class Bit2D:
    def __init__(self,H,W):
        self.bit = [[0]*(W+1) for _ in range(H+1)]
    def add(self,a,b,Z):
        x = a
        while x<=H:
            y = b
            yl = self.bit[x]
            while y<=W:
                yl[y]+=Z
                y+=y&-y
            x+=x&-x
    def s_sum(self,a,b):
        ret = 0
        x = a
        while x>0:
            y = b
            yl = self.bit[x]
            while y>0:
                ret+=yl[y]
                y-=y&-y
            x-=x&-x
        return ret

    def ssum(self,x1,y1,x2,y2):
        return self.s_sum(x2,y2) - self.s_sum(x1-1,y2) - self.s_sum(x2,y1-1) + self.s_sum(x1-1,y1-1)
    
    def pprint(self):
        for i in self.bit:
            print(i)
    
    def psum(self,x1,y1,x2,y2):
        return [self.s_sum(x2,y2) , self.s_sum(x1-1,y2) , self.s_sum(x2,y1-1) , self.s_sum(x1-1,y1-1)]

q = []
Yet = Bit2D(H,W)
Fin = Bit2D(H,W)
for i in range(Q):
    t,c,*pos=map(int,input().split())
    while q and q[0][0] <= t:
        _,x,y= heappop(q)
        Yet.add(x,y,-1)
        Fin.add(x,y,1)
        pint[x][y] = 2
    
    if c == 0:
        h,w = pos
        pint[h][w] = 1
        Yet.add(h,w,1)
        heappush(q,(t+T,h,w))
    elif c == 1:
        h,w = pos
        if pint[h][w] == 2:
            Fin.add(h,w,-1)
            pint[h][w] = 0
    else:
        h1,w1,h2,w2 = pos

        print(Fin.ssum(h1,w1,h2,w2),Yet.ssum(h1,w1,h2,w2))



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

int main() {
    string a;
    cin >> a ;
    vector <int> s(26);
    
    for(int i=0;i<a.length();i++){
        s[a[i]-'a']+=1;
    }
    bool jugh=true;
    for (int i=0;i<26;i++){
        if (s[i]%2!=0){
            jugh=false ;
        }
    }
    if (jugh){
        cout << "Yes" ;
    }else{
        cout << "No";
    }
    return 0;
}

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

int main()
{
	int h,w;
	cin >> h >> w;
	vector<string> s(h);
	for(int i =0;i<h;i++)cin>>s[i];
	int cnt = 0;
	for(auto i:s)
	for(auto j:i)
	{
		if(j=='#')cnt++;
	}
	if(cnt==h+w-1&&s[0][0]=='#'&&s[h-1][w-1]=='#')
	{
		cout<<"Possible"<<endl;
	}
	else
	{
		cout<<"Impossible"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <assert.h>
#include <cmath>

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

    double a,b,x;
    std::cin >> a >> b >> x;

    //more than 45 degree
    double tanA = 0.0;
    if(x >= a*a*b/2){
    //vol = a*a*b - a*a/2 * a * tanA
        tanA = ( a * a * b - x) * 2 / (a * a * a); 
    }
    else{ //less than 45 degree
    //vol = a*b*1/2 * b/tanA
        tanA = a * b * b / 2 / x;
    }

    constexpr double PI = 3.14159265;
    double res = std::atan(tanA) * 180 / PI;
    std::cout << std::setprecision(12) << res;

    return 0;
}


Measured memory_bytes: 256
using System;

namespace AtCoder20200322
{
    class Program
    {
        static void Main(string[] args)
        {
            // TheNumberOfEvenPairs();
            MaxVolume();
        }
        
        public static void TheNumberOfEvenPairs()
        {
            String[] inputs = Console.ReadLine().Split(' ');
            int n = int.Parse(inputs[0]);
            int m = int.Parse(inputs[1]);

            int sum = nCm(n, 2) + nCm(m, 2);
            Console.WriteLine(sum);
        }

        public static int nCm(int n, int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * nCm(n - 1, m - 1) / m;
        }

        public static void MaxVolume()
        {
            double l = double.Parse(Console.ReadLine());
            double vol = Math.Pow(l, 3) / (double)27;
            Console.WriteLine(vol);
        }
    }
}


Measured memory_bytes: 13268
import math
import sys
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    aList = list(map(int, readline().rstrip().split()))
    ans = 1

    if 0 in aList:
        print(0)
        return

    for a in aList:
        ans *= a
        if ans > 10 ** 18:
            ans = -1
            break
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 22520
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main{
    public static void main(String[] args) throws IOException{
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            StringBuilder sb = new StringBuilder();
            int[] counter = new int[26];
            String line; 
            //line = br.readLine();
            char ch = 'a';
            //char[] c = line.toCharArray();
            while((line = br.readLine())!=null){
                char[] c = line.toCharArray();
                for(int i = 0; i < c.length; i++){
                    if( c[i] >= 'A' && c[i] <= 'z' ){
                        if( Character.isUpperCase(c[i]) ){
                            c[i] = Character.toLowerCase(c[i]);
                        }
                        int num = c[i] - 'a';
                        counter[num]++;
                    }
                }
            }
             
            for(int i = 0; i < counter.length; i++){
                System.out.println( ch++ + " : " + counter[i]);
            }
        }catch(IOException e){
            System.out.println(e);
        }
    }
}


Measured memory_bytes: 24456