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

const int U = 0;
const int L = 1;
const int D = 2;
const int R = 3;

int H, W, N ;
int sr, sc  ;
string _S, _T ;
vector<int> S, T;

bool isin(int r, int c){
  return 0 <= r && r < H && 0 <= c && c < W;
}

int main(void){
  cin >> H >> W >> N ; 
  cin >> sr >> sc    ; 
  cin >> _S >> _T      ; 
  sr--; sc--;
  S.resize(N); T.resize(N);

  for(int i = 0; i < N; i++){
    if( _S[i] == 'U') S[i] = U;
    else if(_S[i] == 'L') S[i] = L;
    else if(_S[i] == 'D') S[i] = D;
    else if(_S[i] == 'R') S[i] = R;

    if( _T[i] == 'U') T[i] = U;
    else if(_T[i] == 'L') T[i] = L;
    else if(_T[i] == 'D') T[i] = D;
    else if(_T[i] == 'R') T[i] = R;
  }

  int lend = 0, rend = W-1;
  int uend = 0, dend = H-1;
  int r = sr, c = sc;
  for(int i = N-1; i >= 0; i--){
    if(T[i] == U){
      dend = min(dend+1, H-1);
    }else if(T[i] == D){
      uend = max(uend-1, 0);
    }else if(T[i] == L){
      rend = min(rend+1, W-1);
    }else{
      lend = max(lend-1, 0);
    }

    if((lend > rend) || (uend > dend)){
      cout << "NO" << endl;
      return 0;
    }

    if(S[i] == U){
      uend++;
    }else if(S[i] == D){
      dend--;
    }else if(S[i] == L){
      lend++;
    }else{
      rend--;
    }

    if((lend > rend) || (uend > dend)){
      cout << "NO" << endl;
      return 0;
    }
  }

  if(lend <= sc && sc <= rend &&
     uend <= sr && sr <= dend){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 2312
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

// 0-indexed
template <class T, class Op = T (*) (T, T)>
struct Segtree {
  int n;
  vector<T> dat;
  Op op;
  T unit;
  Segtree(int al, Op op, T unit): op(op), unit(unit) {
    n = 1;
    while(n < al) {
      n *= 2;
    }
    dat = vector<T>(2 * n - 1, unit);
  }
  Segtree(const vector<T> &arr, Op op, T unit): op(op), unit(unit) {
    int al = arr.size();
    n = 1;
    while(n < al) {
      n *= 2;
    }
    dat = vector<T>(2 * n - 1, unit);
    copy(arr.begin(), arr.end(), dat.begin() + n - 1);
    for(int i=n-2; i >= 0; i--) {
      dat[i] = op(dat[i * 2 + 1], dat[i * 2 + 2]);
    }
  }
  void update(int k, T x) {
    k += n - 1;
    dat[k] = x;
    while(k > 0) {
      k = (k - 1) / 2;
      dat[k] = op(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }
  // accumlate [a, b)
  T accum(int a, int b, int k = 0, int l = 0, int r = -1) {
    if(r < 0) r = n;
    if(r <= a || b <= l) return unit;
    if(a <= l && r <= b) return dat[k];
    T vl = accum(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = accum(a, b, k * 2 + 2, (l + r) / 2, r);
    return op(vl, vr);
  }
};

struct interval {
  int a, b;
  int min;
};

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<vector<PI>> as(2, vector<PI>(N/2));
  REP(i,0,N) {
    int a;
    cin >> a;
    as[i % 2][i/2] = {a, i};
  }
  auto op = [](PI x, PI y){return x.first < y.first ? x : y;};
  vector<Segtree<PI, decltype(op)>> tree;
  transform(as.begin(), as.end(), back_inserter(tree),
            [&](const vector<PI> &v){return Segtree<PI, decltype(op)>(v, op, {INT_MAX, -1});});
  auto gt = [](const interval &i1, const interval &i2){
    return i1.min > i2.min;
  };
  priority_queue<interval, vector<interval>, decltype(gt)> que(gt);
  VI ans;
  que.push({0, N, 0});
  while(!que.empty()) {
    interval iv = que.top();
    que.pop();
    PI v1 = tree[iv.a%2].accum(iv.a/2, iv.b/2);
    ans.push_back(v1.first);
    PI v2 = tree[(iv.a+1)%2].accum((v1.second+1)/2, (iv.b+1)/2);
    ans.push_back(v2.first);
    if(iv.a < v1.second) {
      PI m = tree[iv.a%2].accum(iv.a/2, v1.second/2);
      que.push({iv.a, v1.second, m.first});
    }
    if(v1.second + 1 < v2.second) {
      PI m = tree[v2.second%2].accum((v1.second+1)/2, v2.second/2);
      que.push({v1.second+1, v2.second, m.first});
    }
    if(v2.second + 1 < iv.b) {
      PI m = tree[iv.b%2].accum((v2.second+1)/2, iv.b/2);
      que.push({v2.second+1, iv.b, m.first});
    }
  }
  FOR(a,ans) {
    cout << a << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 9584
h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(list(input()))

for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            c = 0
            for k in range(max(i-1, 0), min(i+1, h-1)+1):
                for l in range(max(j-1, 0), min(j+1, w-1)+1):
                    if s[k][l] == '#':
                        c += 1
            s[i][j] = str(c)

for row in s:
    print(''.join(row))

Measured memory_bytes: 3188
N = int(input())

t0, x0, y0 = 0, 0, 0
for _ in range(N):
    t, x, y = map(int, input().split())
    dt = t - t0
    dx = x - x0
    dy = y - y0
    dxy = abs(dx) + abs(dy)  #; print(dt, dx, dy, dxy) 
    isEvenOdd = (dt%2 == 0 and dxy%2 == 0) or (dt%2 != 0 and dxy%2 != 0)
    if isEvenOdd and dxy <= dt :
        t0, x0, y0 = t, x, y
    else:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 3064
main = do
    [n,y] <- map read . words <$> getLine
    let ans = [[a, b, c] | a <- [0 .. n],
                           b <- [0 .. n-a],
                           let c = n - a - b,
                           10000 * a + 5000 * b + 1000 * c == y ]
    putStrLn $ unwords $ map show $ if null ans then [-1, -1, -1] else head ans


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#include<unordered_map>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll ans = 0;
int main() {
	cin >> A >> B >> C >> D;
	if ((abs(A - B) <= D && abs(B - C) <= D)||abs(A-C)<=D)cout << "Yes";
	else cout << "No" << endl;
}

Measured memory_bytes: 256
def main():
    K = int(input())
    pw = 1
    n = 0
    for k in range(K):
        n += pw * 7
        n %= K
        if n == 0:
            print(k + 1)
            return
        pw *= 10
        pw %= K
    print(-1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9168
#include <stdio.h>

long long N;

int dfs(long long i){
  //printf("i=%lld\n",i);
  if(i>N) return 0;
  //自分が条件を満たすか調べる
  int count;
  int is_ok; //自身が満たすなら1,満たさないなら0.
  int count3=0,count5=0,count7=0;
  long long j;
  j=i;
  while(j!=0){
    if(j%10==3) count3++;
    else if(j%10==5) count5++;
    else if(j%10==7) count7++;
    j=j/10;
  }

  if(count3>0 && count5>0 && count7>0) is_ok=1;
  else is_ok=0;

  count=dfs(10*i+3)+dfs(10*i+5)+dfs(10*i+7)+is_ok;
  return count;
}

int main(){
  long long NN;
  scanf("%lld",&NN);
  N=NN;
  int count;
  count=dfs(0);

  printf("%d\n",count);
}


Measured memory_bytes: 128
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <stdio.h>
#include <math.h>
#include <utility>
#include <algorithm>
#include <sstream>

using namespace std;

int main() {
	int r,d, x;
	cin >> r >> d >> x;
	for (int i = 0; i < 10; i++) {
		x=r*x - d;
		cout << x<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int n;
   cin >> n;
   vector<int> a(n + 1);
   rep(i, 0, n) {
      cin >> a[i];
      a[n] ^= a[i];
   }
   rep(i, 0, n) {
      int ans = a[n] ^ a[i];
      printf("%d%c", ans, i == n - 1 ? '\n' : ' ');
   }
   return 0;
}

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

#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>

using namespace std;


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


int power(int a,int n)
{
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return a*power(a*a,n/2);
    return power(a*a,n/2);
}
const int md = 998244353;
const int inf = (int) 1e18;

/*int inverse(int x){

    return power(x,mod-2)%mod;//little fermat....
}*/


signed main()
{
    showoff;
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;
    s = '$'+s;
    s = s+'$';
    FOR(i,a+1,c)if(s[i] == '#' && s[i+1] == '#'){cout << "No";return 0;}
    FOR(i,b+1,d)if(s[i] == '#' && s[i+1] == '#'){cout << "No";return 0;}
    if(max(a,b) > min(c,d) || (a < b && c > b && c < d) || (b < a && d > a && d < c)){cout << "Yes";return 0;}
    if(a > b && c < d){
        bool fo = 0;
        FOR(i,a,c+1){
            if(s[i] == '#')continue;
            if(s[i+1] != '#' && s[i-1] != '#' && i-1 > b && i+1 < d)fo = 1;
        }
        if(fo)cout << "Yes";
        else cout << "No";
        return 0;
    }
    if(b > a && d < c){
        bool fo = 0;
        FOR(i,b,d+1){
            if(s[i] == '#')continue;
            if(s[i+1] != '#' && s[i-1] != '#' && i-1 > a && i+1 < c)fo = 1;
        }
        if(fo)cout << "Yes";
        else cout << "No";
        return 0;
    }
    cout << "Yes\n";
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...   

Measured memory_bytes: 720
#include <iostream>
using namespace std;
int main() {
	int date;
	cin >> date;

	if (date == 25) {
		cout << "Christmas" << endl;
	}
	
	if (date == 24) {
		cout << "Christmas Eve" << endl;
	}

	if (date == 23) {
		cout << "Christmas Eve Eve" << endl;
	}

	if (date == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
typedef vector <int> IVEC;

int seive(IVEC &A, int n){
	IVEC num(n+1,1);
	num[0]=0;
	num[1]=0;
	int count=1, limit=int(sqrt(n));
	for (int i=3; i<=n; i+=2)
		if (num[i]){
			count++;
			if (i<=limit)
				for (int j=3*i; j<=n; j+=2*i) num[j]=0;
		}

	A.resize(count);
	A[0] = 2;
	int j=1;
	for (int i=3; i<=n; i+=2)
		if (num[i]==1) A[j++]=i;
	return 0;
}

int main(void){
	IVEC primes;
	int max_num=10000;
	seive(primes, max_num);

	int n, n0, lim, count;
	cin >> n;
	count = n;
	for (int i=0; i<n; i++){
		cin >> n0;
		lim = int(sqrt(n0));
		for (int j=0; j<(int)primes.size(); j++){
			int tmp=primes[j];
			if (tmp *tmp > n0)break;
			if (n0 % tmp == 0){
				count--;
				break;
			}
		}
	}
		cout<<count<<endl;
		return 0;
}

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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

typedef long long ll;
typedef pair<int, int> point;



int main() {
  int n; ll a, b, c, d;

  cin >> n >> a >> b >> c >> d;

  REP(i, n) {
    ll mn = a - d * i + c * (n - i - 1);
    ll mx = a - c * i + d * (n - i - 1);

    if(b <= mx && b >= mn) {
      cout << "YES";
      return 0;
    }
  }

  cout << "NO";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

signed main()
{
   int h, w; cin >> h >> w;
   V<V<char>> a(h, V<char>(w));
   for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
         cin >> a[i][j];
      }
   }

   V<V<int>> dp(h, V<int>(w));
   dp[0][0] = 1;
   for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
         if (i+1 < h && a[i+1][j] == '.') {
            (dp[i+1][j] += dp[i][j]) %= MOD;
         }
         if (j+1 < w && a[i][j+1] == '.') {
            (dp[i][j+1] += dp[i][j]) %= MOD;
         }
      }
   }
   cout << dp[h-1][w-1] << endl;

   return 0;
}


Measured memory_bytes: 9088
x,y=map(int,input().split())

n=0
if (x,y)==(1,1):
  print(1000000)
  exit()

if x==1:
  n+=300000

if x==2:
  n+=200000

if x==3:
  n+=100000

if y==1:
  n+=300000

if y==2:
  n+=200000

if y==3:
  n+=100000

print(n)


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

void solve(long long X, long long N, std::set<long long> p)
{
    ll m = INT_MAX;
    ll ans = X;

    for (ll i = 0; i <= 101; i++)
    {
        if (p.count(i) == 0)
        {
            if (m > abs(X - i))
            {
                m = abs(X - i);
                ans = i;
            }
        }
    }
    cout << ans << endl;
}
signed main()
{
    long long X;
    scanf("%lld", &X);
    long long N;
    scanf("%lld", &N);
    std::set<long long> p;
    for (int i = 0; i < N; i++)
    {
        ll a;
        scanf("%lld", &a);
        p.insert(a);
    }
    solve(X, N, p);
    return 0;
}


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

string r, s;

bool solve(int curr){
    //cout << r << ' ' << curr << '\n';
    if(curr == s.size()){
        return true;
    }
    r.clear();
    for(int i=curr ; i < curr+5  && i < s.size(); i++){
        r.push_back(s[i]);
    }
    if(r == "dream" || r == "erase"){
        bool subans = solve(curr+5);
        if(subans){
            return true;
        }
    }
    r.clear();
    for(int i=curr ; i < curr+7 && i < s.size() ; i++){
        r.push_back(s[i]);
    }
    if(r == "dreamer"){
        bool subans = solve(curr+7);
        if(subans){
            return true;
        }
    }
    r.clear();
    for(int i=curr ; i < curr+6  && i < s.size() ; i++){
        r.push_back(s[i]);
    }
    if(r == "eraser"){
        bool subans = solve(curr+6);
        if(subans){
            return true;
        }
    }
    r.clear();
    return false;
}

int main(){
    cin >> s;
    if(solve(0)){
        cout << "YES";
    } else {
        cout << "NO";
    }
    return 0;
}


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

using namespace std;

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;

#define rep(i,a,b) for(int i =(a);i<(int)(b);i++)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

typedef long long ll;

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

    int idx =-1; 
    int ans =0;
    char h= 'A';
    rep(i, 0, 3){
       char c; 
       cin>>c; 
       if(c== 'R'){
            
           if(h == c){
               ans++;
           }
           else{
               ans = 1;
               h =c;
           }
       }
       else{
           h = 'A';
       }

    }

    cout<<ans<<endl;



    return 0 ;
}



Measured memory_bytes: 3648
#include <stdio.h>
int main (){
    int heya[5][4][11];
    int j,h,i,k,n,g,f,d;
    int tou,kai,room,hito;
    scanf("%d",&n);
    for(j=1; j<=4; j++){
        for(h=1; h<=3; h++){
            for(i=1; i<=10; i++){
                heya[j][h][i]=0;
        }
    }
    }
    for(k=1; k<=n; k++){
        scanf("%d %d %d %d",&tou,&kai,&room,&hito);
         heya[tou][kai][room]=heya[tou][kai][room]+hito;      }

    for(g=1; g<=4; g++){
        for(f=1; f<=3; f++){
            for(d=1; d<=10; d++){
                printf(" %d",heya[g][f][d]);
        }   /*if(g==4&&f==3){break;}*/   printf("\n");
    }if(g==4){break;}printf("####################\n");
    }

return 0;}

Measured memory_bytes: 1776
A, B = [int(v) for v in input().split()]

def prime_factorize(n):
    a = set([1])
    while n % 2 == 0:
        a.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.add(n)
    return a
s1 = prime_factorize(A)
s2 = prime_factorize(B)
s3 = s1 & s2
print(len(s3))


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <queue>
#include <unordered_map> 
#include <iomanip>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
//#define int long long


//booooooooooooost
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/multiprecision/cpp_dec_float.hpp>
//namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100)



LL inv_mod(LL a, LL m)
{
	LL b, x, u, q, tmp;

	b = m; x = 1; u = 0;
	while (b > 0) {
		q = a / b;
		tmp = u; u = x - q * u; x = tmp;
		tmp = b; b = a - q * b; a = tmp;
	}

	return (x < 0) ? m + x : x;
}




signed main() {

	int N;
	vector<int> a;
	cin >> N;
	REP(i, N) {
		int tmp;
		cin >> tmp;
		a.PSB(tmp - 1);
	}
	int ans = 0;
	REP(i, N) {
		if (a[a[i]] == i) ++ans;
	}
	cout << ans / 2 << endl;




	return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  int a[55],b[55],c[55],d[55];
  cin>>n>>m;
  for(int i=0;i<n;i++)cin>>a[i]>>b[i];
  for(int i=0;i<m;i++)cin>>c[i]>>d[i];
  for(int i=0;i<n;i++){
    int ans;
    int min=1e9;
    for(int j=0;j<m;j++){
      int t=abs(a[i]-c[j])+abs(b[i]-d[j]);
      if(t<min){
	min=t;
	ans=j+1;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

        int n = in.nextInt(), q = in.nextInt();
        UnionFind unionFind = new UnionFind(n);
        for (int i = 0; i < q; i++) {
            int cmd = in.nextInt(),
                    x = in.nextInt(),
                    y = in.nextInt();
            if (cmd == 0) {
                unionFind.union(x, y);
            }else {
                System.out.println(unionFind.same(x, y) ? 1 : 0);
            }
        }
    }
}

class UnionFind {
    int[] parent;
    int[] depth;

    UnionFind(int n) {
        parent = new int[n];
        depth = new int[n];
        Arrays.fill(parent, -1);
    }

    private int root(int p) {
        while (parent[p] != -1) {
            p = parent[p];
        }
        return p;
    }

    void union(int p, int q) {
        int rp = root(p), rq = root(q);

        if (rp == rq) {
            return;
        }

        if (depth[rp] >= depth[rq]) {
            parent[rq] = rp;
            depth[rp] = Math.max(depth[rp], depth[rq] + 1);
        } else {
            parent[rp] = rq;
//            depth[rq] = Math.max(depth[rq], depth[rp] + 1);
        }
    }

    boolean same(int p, int q) {
        return root(p) == root(q);

    }
}


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

#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pf push_front
#define pb2 pop_back
#define pf2 pop_front
#define line printf("\n")
#define pq priority_queue
#define rep(k,i,j) for(int k = (int)i;k<(int)j;k++)
#define repd(k,i,j) for(int k = (int)i;k>=(int)j;k--)
#define ll long long
#define ALL(a) a.begin(),a.end()
#define vi vector<int>

using namespace std;

double EPS = 1e-9;
int INF = 1e9+7;;
long long INFLL = 1e17;
double pi = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

clock_t first_attempt = clock();
inline void cek_time(){
	clock_t cur = clock()- first_attempt;
	cerr<<"TIME : "<<(double) cur/CLOCKS_PER_SEC<<endl;
}
inline void OPEN (string s) {
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
}

//end of template

string s;
int n;
vector<int> loc[30];

int next(int pos,int ch){
	int i = lower_bound(ALL(loc[ch]),pos) - loc[ch].begin();
	return loc[ch][i];
}

int DP[200005];
int dp(int pos){
	if(pos>n)return 0;
	int &ret = DP[pos];
	if(ret!=-1)return ret;
	
	ret = INF;
	rep(k,0,26){
		ret = min(ret,dp(next(pos,k)+1) + 1);
	}
	
	return ret;
}

string ans;
void bt(int pos){
	if(pos>=n)return;
	int ret = dp(pos);
	
	rep(k,0,26){
		if(ret==dp(next(pos,k)+1) + 1){
			ans += 'a' + k;
			bt(next(pos,k)+1);
			break;
		}
		
	}
	
	return;
}
int main(){
	cin>>s;
	n= s.size();
	rep(k,0,n)s[k] -= 'a',loc[s[k]].pb(k);
	rep(k,0,30)loc[k].pb(INF);
	
	memset(DP,-1,sizeof DP);
	
	bt(0);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2436
import math


def main():
    N = int(input())
    CSF = [[int(x) for x in input().split()] for _ in range(N-1)]
    tt = []

    for j in range(N-1):
        t = CSF[j][1] + CSF[j][0]
        for i in range(j+1, N-1):
            if t >= CSF[i][1]:
                n = (t - CSF[i][1]) / CSF[i][2]
                t = CSF[i][1] + CSF[i][2] * math.ceil(n)
                t += CSF[i][0]
            else:
                t = CSF[i][1] + CSF[i][0]

        tt.append(t)

    tt.append(0)
    for t in tt:
        print(t)


main()


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

int main() {
  int n;
  cin >> n;
  vector<long long> l(n);
  for (int i = 0; i < n; ++i) {
    cin >> l[i];
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      for (int k = j; k < n; ++k) {
        vector<long long> v = {l[i], l[j], l[k]};
        sort(v.begin(), v.end());
        if ((l[i] != l[j] && l[j] != l[k] && l[k] != l[i]) &&
            v[0] + v[1] > v[2]) {
          ++ans;
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
N = int(input())
A = list(map(int, input().split()))
M = 10**6 + 1

counts = [0 for _ in range(M)]
for a in A:
  counts[a] += 1

integers = [1 for _ in range(M)]
integers[0] = 0
integers[1] = 0
max_count = 0
for i in range(M):
  if integers[i] >= 1:
    count = 0
    for j in range(i,M,i):
      count += counts[j]
      integers[j] = 0
    max_count = max(max_count,count)

if max_count == N:
  answer = 'not coprime'
elif max_count >= 2:
  answer = 'setwise coprime'
else:
  answer = 'pairwise coprime'

print(answer)

Measured memory_bytes: 217464
#include <iostream>
using namespace std;
                                                                                                
  
int main(){
                                                                                                
   
    int a, b;
         
    cin >> a >> b;
   
    if( a + b >= 10 ) cout << "error" << endl;
   
    else cout << a + b << endl;


    return 0;
                                                          
}

Measured memory_bytes: 256
//////////////////////////
/*      _        ____   */
/*  U  /"\  u U /"___|  */
/*   \/ _ \/  \| | u    */
/*   / ___ \   | |/__   */
/*  /_/   \_\   \____|  */
/*   \\    >>  _// \\   */
/*  (__)  (__)(__)(__)  */
/*  Compro by NULL_CT©  */
//////////////////////////
/*STL Libs*/
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

/*Boost*/
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define REP(I, LIM) for (int I = 0; I < (LIM); I++)
#define ALL(LIST) (LIST.begin()), (LIST.end())

using namespace std;
using bint = boost::multiprecision::cpp_int;
using bdouble = boost::multiprecision::cpp_dec_float_100;

constexpr int MOD = 10000007;

vector<long> divisor(long n) {
  vector<long> head, tail;
  for (long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      head.push_back(i);
      if (i * i != n)
        tail.push_back(n / i);
    }
  }
  head.insert(head.end(), tail.rbegin(), tail.rend());
  return (head);
}

void execute();

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  // cout<<fixed<<setprecision(20);

  execute();

  return (0);
}

void execute(){
  int n,k;
  cin>>n>>k;

  int cnt=0;
  REP(i,n){
    int h;
    cin>>h;
    if(k <= h)
      cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3228
uses math; 
const
    inf = 2000000000;
var
    i, j, n, k : longint;
    h, dp : array[1..100005] of longint;

begin
    readln(n, k);
    for i := 1 to n do
    begin
        read(h[i]);
        dp[i] := inf;
    end;
    dp[1] := 0;
    for i := 2 to n do
    for j := max(1, i - k) to i - 1 do dp[i] := min(dp[i], dp[j] + abs(h[i] - h[j]));
    writeln(dp[n]);
end.

Measured memory_bytes: 1324
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vivi;
typedef vector<ll> vll;
typedef vector<vll> vllvll;
typedef pair<int, int> Pi;
typedef queue<Pi> QPi;
typedef pair<ll, ll> Pll;
typedef queue<Pll> QPll;
using Graph = vector<vector<int>>;
const int mod = 1000000007;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;

int main() {
  char n[3];
  cin >> n;
  string ans="No";
  REP(i,3) {
    if(n[i]=='7') ans="Yes";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, k, a[N];
bool check(int x) {
    long long cuts = 0;
    for(int i = 1; i <= n; ++i) {
        cuts += (a[i] - 1) / x;
    }
    return cuts <= k;
}
int main() {
    scanf("%d%d", &n, &k);
    for(int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
    }
    int l = 1, r = 1e9, ans = 1e9;
    while(r >= l) {
        int m = l + r >> 1;
        if(check(m)) {
            r = m - 1;
            ans = m;
        } else {
            l = m + 1;
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 4512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*Coding Space*/
int main(){
  int a,b; cin >> a >> b;
  if(a <= 8 && b <= 8){
    cout << "Yay!" << endl;
  }else{
    cout << ":(" << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
typedef long long i64;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 3e5+5;
int n, L, x[N], t[N], l[N], r[N], ans, res, top, pos, del[N];
int main()
{
    n = read(), L = read(), ans = n+1, pos = n;
    for(int i = 1; i <= n; ++i) x[i] = read();
    for(int i = 1; i <= n; ++i) t[i] = read(), ans += t[i]/(2*L), t[i] %= 2*L;
    for(int i = 1; i <= n; ++i) 
    {
        if(!t[i]) del[i] = 1, --ans;
        else l[i] = t[i] <= 2*(L-x[i]), r[i] = t[i] <= 2*x[i], del[i] = !l[i]&&!r[i];
    }
    ans -= l[n];
    for(int i = 1; i < n; ++i)
    {
        if(del[i]) continue;
        if(!l[i]) pos = i, i = n; else r[i]?++top:(top?--top,--ans:0);
    }
    res += top, top = 0; 
    for(int i = n-1; i >= pos; --i)
    {
        if(del[i]) continue;
        if(!r[i]) break; else l[i]?++top:(top?--top,--ans:0);
    }
    res += top, top = 0, ans -= res>>1; printf("%lld\n", 2ll*L*ans);
    return 0;
}

Measured memory_bytes: 6016
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
 
int main() {
	int n;
	int x[1000],y[1000];
	double p1, p2, p3, pp;
	cin >> n;
 
	for(int i = 0; i < n; i++){
		cin >> x[i];
	}
	for(int i = 0; i < n; i++){
		cin >> y[i];
	}
 
	//p=1?????¨???
	p1 = 0.0;
	for(int j = 0; j < n; j++){
		p1 += fabs(x[j]-y[j]);
	}
	cout << setprecision(10) << p1 << " ";
 
	//p=2?????¨???
	p2 = 0.0;
	for(int j = 0; j < n; j++){
		p2 += pow(fabs(x[j]-y[j]),2.0);
	}
	cout << setprecision(10) << sqrt(p2) << " ";
 
	//p=3?????¨???
	p3 = 0.0;
	for(int j = 0; j < n; j++){
		p3 += pow(fabs(x[j]-y[j]),3.0);
	}
	cout << setprecision(10) << pow(p3,1.0/3) << " ";
 
	//p=???????????¨???
	pp = 0.0;
	double marg,max;
	max = 0.0;
	for(int j = 0; j < n; j++){
		marg = fabs(x[j]-y[j]);
		if(max <= marg)max = marg;
	}
	cout << setprecision(10) << max << endl;
 
	return 0;
}

Measured memory_bytes: 3424
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <utility>
using namespace std;

using P = pair<int, int>;

vector<int> graph[200000];
array<bool, 200000> used;

int main() {
    int N, M;
    cin >> N >> M;
    int u, v;
    for (int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;

        A--; B--;
        graph[A].push_back(B);
        graph[B].push_back(A);

        u = A;
        v = B;
    }

    used.fill(false);

    deque<int> path;
    queue<P> que;
    que.push(make_pair(u, 1));
    used[u] = true;
    que.push(make_pair(v, -1));
    used[v] = true;

    path.push_front(u + 1);
    path.push_back(v + 1);

    while (!que.empty()) {
        auto res = que.front(); que.pop();
        // cout << "(" << res.first + 1 << ", " << res.second << ")" << endl;

        for (int to : graph[res.first]) {
            if (used[to]) {
                continue;
            }
            que.push(make_pair(to, res.second));
            used[to] = true;

            if (res.second > 0) {
                path.push_front(to + 1);
            } else {
                path.push_back(to + 1);
            }
            // cerr << "now..." << res.first + 1 << endl;
            break;
        }
    }
    cout << path.size() << endl;
    cout << path.front();
    path.pop_front();

    while (!path.empty()) {
        cout << " " << path.front();
        path.pop_front();
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s[5]=='1' || s[6]>'4')
    {
        cout<<"TBD"<<endl;
    }
    else
        cout<<"Heisei"<<endl;
}

Measured memory_bytes: 3580
#include <stdio.h>

int main()
{
	double w;

	while(scanf("%lf", &w) != EOF){
		if(w <= 48) printf("light fly\n");
		else if(w <= 51) printf("fly\n");
		else if(w <= 54) printf("bantam\n");
		else if(w <= 57) printf("feather\n");
		else if(w <= 60) printf("light\n");
		else if(w <= 64) printf("light welter\n");
		else if(w <= 69) printf("welter\n");
		else if(w <= 75) printf("light middle\n");
		else if(w <= 81) printf("middle\n");
		else if(w <= 91) printf("light heavy\n");
		else if(w > 91) printf("heavy\n");
	}
	
	return 0;
}

Measured memory_bytes: 608
n = int(input())
a = list(map(int, input().split()))
c = [0]*8
d = 0
for x in a:
  for i in range(8):
    if x < 400*(i+1):
      c[i] = 1
      break
  if x >= 3200:
    d += 1
s = sum(c)
print(max(s,1), s+d)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long int
#define fio ios_base::sync_with_stdio(0);cin.tie(0)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define slld(t) scanf("%lld",&t)
#define plld(t) printf("%lld\n",t)
#define sc(t) scanf("%c",&t)
#define pb(x) push_back(x)
#define ii pair<int,int>
#define vi vector<int>
#define vvi vector<vi >
#define vii vector<ii >
#define vvii vector<vii >
#define clr(x) memset(x,0,sizeof(x))
#define rep(i,begin,end) for(__typeof(end) i=begin-(begin>end);i!=end-(begin>end);i+=1-2*(begin>end))
#define M_PI 3.14159265358979323846
#define MOD 1000000007
#define MAX 100005
#define EPS 1e-12
using namespace std;

int main()
{
	int n; sd(n);
	int cnt = 0;
	rep(i,0,n)
	{
		int x; sd(x);
		cnt += (x%2);
	}
	if(cnt%2) printf("NO\n");
	else printf("YES\n");
	return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<tuple<int, string, int> > rs = vector<tuple<int, string, int> >(n);
    for (int i = 1; i <= n; i++) {
        string s;
        int p;
        cin >> s >> p;
        rs[i - 1] = make_tuple(i, s, p);
    }
    struct {
        bool operator()(
                tuple<int, string, int> a,
                tuple<int, string, int> b
        ) const {
            if (get<1>(a) < get<1>(b)) {
                return true;
            }
            if (get<1>(a) > get<1>(b)) {
                return false;
            }
            return get<2>(a) > get<2>(b);
        }
    } compare;
    sort(rs.begin(), rs.end(), compare);
    for (int i = 0; i < rs.size(); i++) {
        cout << get<0>(rs[i]) << endl;
    }

    return 0;
}

Measured memory_bytes: 504
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define vv vector< vector< int > >
#define ll long long
#define ALL(a) (a).begin(), (a).end()
const long long mod = 1000000000 + 7;
const long long INF = 9e18;
const double PI = 3.14159265358979323846;

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

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


int main(){
    string S;
    cin >> S;
    set<char> s;
    for(int i = 0; i < S.length(); ++i){
        s.insert(S[i]);
    }
    if(s.size() == S.length()) cout << "yes" << endl;
    else cout << "no" << endl;

    return 0;
}

Measured memory_bytes: 3572
S = int(input())
if S == 1:
    print(0)
    exit()
MOD = 10**9 + 7
A = [0] * (S + 1)
A[0] = 1
A[1] = 0
A[2] = 0

cumsum = 1
for i in range(3, len(A)):
    A[i] = (A[i - 1] + A[i - 3]) % MOD
print(A[-1])


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

#define in freopen("input.txt", "r" ,stdin)
#define out freopen("fenceplan.out", "w" ,stdout)
#define ll long long
#define pb push_back
#define fr first
#define sc second
const int mod = 1e9+7;
using namespace std;
ll a ,b;
int main (){
    //in;
    //out;
    //ios_base::sync_with_stdio(0);
    cin >> a >> b;
    cout << a * b / __gcd (a,b);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	
	int n,m; cin>>n>>m;

	int fib[107];
	fib[0]=0,fib[1]=1,fib[2]=3;
	for(int i=3;i<107;i++){
	fib[i]=fib[i-1]+i;
	}
	int x,y;
	if(n==0) { x=0; }
	else { x=fib[n-1]; }
	if(m==0) { y=0; }
	else { y=fib[m-1]; }
	cout<<x+y<<endl;

	return 0;
}

Measured memory_bytes: 256
import sys
input  = sys.stdin.readline

N = int(input())
pa,pb,pc=0,0,0
for i in range(N):
  a,b,c=map(int,input().split())
  ta=max(pb,pc)+a
  tb=max(pa,pc)+b
  tc=max(pa,pb)+c
  pa,pb,pc=ta,tb,tc
print(max(pa,pb,pc))


Measured memory_bytes: 3064
N = int(input())
A,B = map(int,input().split())
P = list(map(int,input().split()))

first = 0 
second = 0 
third = 0  

for p in P:
    if p<=A:
        first += 1     
    elif p<=B:
        second += 1     
    else:
        third += 1
print(min(first,second,third))


Measured memory_bytes: 3060
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    string O, E;
    cin >> O >> E;
    rep(i, O.size()) {
        cout << O[i];
        if (i != E.size()) {
            cout << E[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
n, x = (int(i) for i in input().split())
a = [int(i) for i in input().split()]

cnt = 0
for a_ in sorted(a):
    if x >= a_:
        x -= a_
        cnt += 1 
    else:
        x = 0
        break

if x > 0:
    cnt -= 1
print(cnt)

Measured memory_bytes: 38256
#!/usr/bin/env python3
import sys


def solve(H: int):
    count = 0
    i = 0
    while H >= 1:
        H = H // 2
        count = count + 2 ** i
        i += 1
    print(count)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    solve(H)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 1> { using type = vector<T>; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int N;
  ll M;
  while (cin >> N >> M) {
    ll res = 0;
    map<ll, ll> mp;
    mp[0] = 1;
    ll sum = 0;
    for (int i = 0; i < N; i++) {
      ll A;
      cin >> A;
      sum = (sum + A) % M;
      res += mp[sum];
      ++mp[sum];
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 4224
if __name__ == "__main__":
    N, H = map(int, input().split())
    ab = []
    max_a = 0
    for i in range(N):
        a,b = map(int, input().split())
        max_a = max(max_a, a)
        ab.append([b, a])
    ab.sort()
    ab = list(reversed(ab))
    res = 0
    result = 2 ** 100
    
    for b,_ in ab:
        H -= b
        res += 1
        if H <= 0:
            result = min(result, res)
            break
        tmp = res + H // max_a
        if H % max_a != 0:
            tmp += 1
        result = min(result, tmp)
            
    print (result)
        
    

Measured memory_bytes: 20332
#include <iostream>
using namespace std;
int main(void){
    int a=0;
    int e=1;
    int f=2;
    int z=0;
    cin>>a;
    char b[a];
    int d[a];
    for(int i=1;i<=a;i++){
        cin>>b[i];
    }
    for(int i=1;i<=a;i++){
        if(b[i]=='O'){
            d[i]=1;
        }else{
            if(b[i]=='X'){
                d[i]=2;
            }
        }
    }
    while(f<=a){
        if(d[e]+d[f]==3){
            z++;
            e=e+2;
            f=f+2;
        }else{
            e++;
            f++;
        }
    }
    cout<<z<<endl;
}



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

int main() {
	
	
	string str;
	
	while(cin >> str)
	{
		string ans;
	
		for(unsigned int i = 0; i < str.size(); i++){
			if(str[i] == '@'){
				int t = str[i + 1] - '0';
				char s = str[i + 2];
				for(int j = 0; j < t; j++)
					ans += s;
				
				i += 2;
			}
			else 
				ans += str[i];
		}
	
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1184
n = int(input())
ls = list(map(int, input().split()))
ls.sort(reverse=True)
alice_point = 0
bob_point = 0

for i in range(n):
  if i % 2 == 0:
    alice_point += ls[i]
  else:
    bob_point += ls[i]

difference = alice_point - bob_point
print(difference)

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

typedef long long ll;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t; cin >> t;
    int a[10], b[10];
    while(t--) {
        for(int i = 0; i < 10; i++) {
            cin >> a[i];
        }
        int pre = a[0], count = 0;
        for(int i = 1; i < 10; i++) {
            if(a[i] > pre) pre = a[i];
            else b[count++] = a[i];
        }
        bool flag = false;
        for(int i = 1; i < count; i++) {
            if(b[i] <= b[i-1]) {
                flag = true;
                break;
            }
        }
        if(flag) cout << "NO\n";
        else cout << "YES\n";
    }
    return 0;
}


Measured memory_bytes: 3088
let rec split_while f = function
  | [] -> ([],[])
  | hd :: tl -> if f hd then 
                  let (rl, wl) = split_while f tl in (hd :: rl, wl)
                else ([], hd :: tl)

let rec group = function
  | [] -> []
  | hd ::tl -> let (rl, wl) = split_while (fun x -> x = hd) tl in (hd :: rl) :: group wl

let poker lst =
  let is_straight xs =
    let rec iter = function
      | x :: y :: rest when (x + 1) = y -> iter (y :: rest)
      | x :: y :: rest -> false
      | _ -> true in
    if xs = [1;10;11;12;13] then true
    else iter xs in
  if is_straight lst then "straight"
  else match List.map List.length (group lst) with
       | [4;1] | [1;4] -> "four card"
       | [3;2] | [2;3] -> "full house"
       | [3;1;1] | [1;3;1] | [1;1;3] -> "three card"
       | [2;2;1] | [2;1;2] | [1;2;2] -> "two pair"
       | [2;1;1;1] | [1;2;1;1] | [1;1;2;1] | [1;1;1;2] -> "one pair"
       | _ -> "null"

let _ =
  try
    while true do
      let lst = Scanf.scanf "%d,%d,%d,%d,%d\n" (fun v1 v2 v3 v4 v5 -> List.sort compare [v1;v2;v3;v4;v5]) in
      print_endline (poker lst)
    done
  with
    End_of_file -> ()
        

Measured memory_bytes: 2304
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    A, B, C = LI()

    if A + B >= C:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10112
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
///////////////////////////////////////////////
int main(){
	static ll dp[51][51][2502] = {};
	int N,A;
	SCD2(N,A);
	static int X[52] = {};
	ARSCD1(X,N);

	dp[0][0][0] = 1;

	FORq(i,1,N){
		FORq(j,0,N){
			FORq(k,0,2500){
				if ((j == 0) || (k - X[i] < 0)) dp[i][j][k] = dp[i-1][j][k];
				else dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-X[i]];

			}
		}
	}

	ll ans = 0;

	FORq(i,1,N){
		ans += dp[N][i][i*A];
	}

	PRINTLLD(ans);


}


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

int main(){
  vector<int> s = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int n;
  cin >> n;
  cout << s[n-1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pi pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define in1(x) int x; cin>>x;
#define in2(x, y) int x, y; cin>>x>>y;
#define in3(x, y, z) int x, y, z; cin>>x>>y>>z;
#define in4(x, y, z, w) int x, y, z, w; cin>>x>>y>>z>>w;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
using namespace std;
bool primes[1000001];vi prime; void seive(); int gcd(int a, int b); int power(int x, int y);

int32_t main(void){
	IOS;
	in1(n);
	int arr[n];
	rep(i, 0, n) cin>>arr[i];
	int ans = 0;
	rep(i, 0, n)
	{
		if(i%2 == 0 && arr[i]%2) ans += 1;
	}
	cout<<ans<<endl;
}

void seive(){memset(primes, true, sizeof(primes));primes[0] = primes[1] = false;for(int i = 2; i*i<=1000000;i += 1){
if(primes[i]){for(int j = i*i; j <= 1000000;j += i) primes[j] = false;}}rep(i, 2, 1000001){if(primes[i]) prime.pb(i);}}
int gcd(int a, int b){return b==0 ? a : gcd(b, a%b);}
int power(int x, int y){ int res = 1;x = x % mod; if (x == 0) return 0;
while (y > 0){ if(y & 1) res = (res*x) % mod; y = y>>1; x = (x*x) % mod;} return res;}


Measured memory_bytes: 3644