akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
// #include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int N;cin>>N;
  int M = 101;
  map<int,int> mp;
  for (int i = 1; i < M; i++)
  {
    for (int j = 1; j < M; j++)
    {
      for (int k = 1; k < M; k++)
      {
         mp[i*i + j*j + k*k + i*j + i*k + j*k]++;
      }
    }
  }
  for (int i = 1; i <= N; i++)
  {
    cout<<mp[i]<<endl;
  }
  

  return; 
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

using namespace std;
typedef long long LL;
const LL mod=1000000007;

LL modpow(LL x, LL n){
	LL r=1;
	while(n){
		if(n&1) r=r*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return r;
}

int main(){
  int N;
  cin >> N;
  vector<LL> A(N);
  rep(i,N) cin >> A[i];
  LL ans=0;
  for(LL bit=0; bit<60; bit++){
    LL a=0;
    rep(i,N) if(A[i]&(1LL<<bit)) a++;
    ans+=a*(N-a)%mod*modpow(2,bit);
    ans%=mod;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
import sys
n,m=map(int,input().split())
ab=[]
for i in range(n):
    ab.append(list(map(int,input().split())))

ab=sorted(ab,key=lambda x:x[0])

ans=0
for i in range(n):
    c=ab[i][1]
    if c<m:
        ans+=ab[i][0]*c
        m-=c
    else:
        ans+=ab[i][0]*m
        print(ans)
        sys.exit()
        
    


Measured memory_bytes: 29788
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define int long long
using namespace std;
signed main() {
	int N;
	string S;
	cin >> N >> S;

	for (int i = 0; i < S.size(); i++) {
		if (S[i] == S[i + 1]) {
			N--;
		}
	}
	cout << N << endl;
	
}

Measured memory_bytes: 3752
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    auto ans = (s.front() == s.back()) ^ (n & 1) ? "First" : "Second";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,c=1,s=0;
    cin>>n>>x;
    int a[n],b[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        s+=a[i];
        a[i]=s;
    }
    for(int i=0;i<n;i++)
    {
        if(a[i]<=x)
        {
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int sum=0,n,x,k,ans=0;
int a[1000001];
map<int,int> m; 
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        m[x]++;
    }
    int q=m.size();
    map<int,int>::iterator it=m.begin();
    for(it;it!=m.end();it++)
    {
        a[++sum]=(*it).second;
    }
    sort(a+1,a+sum+1);
    for(int i=1;i<=q-k;i++)
    {
        ans+=a[i];
    }
    cout<<ans<<endl;
    return 0;
 } 

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

const int mod = 1e9 + 7;

const int maxn = 2e5+10;
long long f[maxn];
long long inv[maxn];

int Pow(int x,int k, int mod) {
	int res = 1;
	while (k) {
		if (k & 1) res = 1ll * res * x % mod;
		x = 1ll * x * x % mod;
		k >>= 1;
	}
	return res;
}

long long get(int n, int m) {
	long long res = 0;
	for(int i=1;i<=n;i++) {
		long long t = 1ll * m * m % mod;
	        long long t1 = 0;
		t1 += 1ll * (n - i + 1) * ( n - i) / 2;
		t1 %= mod;
		res += 1ll * t * t1 % mod;	
		res %= mod;
	}
	return res;
}



long long C(int k, int n) {
	long long res = 0;
	res = 1ll * f[n] * inv[k] % mod;
	res = 1ll * res * inv[n - k] % mod;
	return res;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	f[0] = 1;
	inv[0] = 1;
	for(int i=1;i<maxn;i++) {
		f[i] = f[i-1] * i % mod;
		inv[i] = inv[i-1] * Pow(i, mod - 2, mod) % mod;
	}

	int n , m, k;
	cin >> n >> m >> k;
	int t = n * m;

	long long t1 = get(n, m);
	long long t2 = get(m, n);
	long long t3 = C(k-2, t-2);

	cerr << t3 << " " << t1 <<" " << t2 << endl;
	long long res = 1ll * t3 * (t1 + t2) % mod;
	cout << res;
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
const double INF = 1e18;
const double EPS = 1e-10;
 
int main(){
    double d;
    int n,b;
    cin >> d >> n >> b;
    vector<double> p(n),h(n);
    for(int i=0; i<n; i++){
        cin >> p[i] >> h[i];
    }
 
    double ans = INF;
    for(int i=0; i<=b; i++){
        double v = d/(i+1)/2; //V = vx*vy
        double vy = sqrt(v);
        for(int j=0; j<=i; j++){
            double center = j*2*v +v;
            for(int k=0; k<n; k++){
                double w = abs(p[k] -center);
                if(abs(w-v) < EPS){
                    vy = INF;
                    j = i+1;
                    break;
                }
                if(w -center > v) continue;
                vy = max(vy, sqrt(2*h[k]/(1-(w*w)/(v*v))));
            }
        }
        double vx = v/vy;
        ans = min(ans, sqrt(vx*vx +vy*vy));
    }
    cout << fixed << setprecision(10);
    cout << ans << endl;
    return 0;
}


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

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

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

int main() {
  int A, B, Q; cin >> A >> B >> Q;
  vector<ll> s(A+2), t(B+2), x(Q);
  s[0] = t[0] = -30000000001;
  s[A+1] = t[B+1] = 30000000001;
  for (int i=1; i<=A; i++) cin >> s[i];
  for (int i=1; i<=B; i++) cin >> t[i];
  for (int i=0; i<Q; i++) cin >> x[i];

  for (int i=0; i<Q; i++) {
    int s_east = lower_bound(s.begin() + 1, s.end() - 1, x[i]) - s.begin();
    int s_west = s_east - 1;
    int t_east = lower_bound(t.begin() + 1, t.end() - 1, x[i]) - t.begin();
    int t_west = t_east - 1;

    cout <<
      min(min(min(
		  x[i] - min(s[s_west], t[t_west]), max(s[s_east], t[t_east]) - x[i]),
	      s[s_east] - t[t_west] + min(s[s_east] - x[i], x[i] - t[t_west])),
	  t[t_east] - s[s_west] + min(t[t_east] - x[i], x[i] - s[s_west]))
	 << endl;
  }
}


Measured memory_bytes: 3712
N = int(input())
A = [int(i) for i in input().split()]

from collections import Counter

Acnt = Counter(A)

ans = [-1] * 2
for key,cnt in Acnt.items():
    if cnt >= 4:
        if key > ans[0]:
            ans[0] = key
        if key > ans[1]:
            ans[1] = key
    elif cnt >= 2:
        if key > ans[0]:
            ans[0] = key
    
    ans.sort()

if -1 in ans:
    print(0)
else:
    print(ans[0] * ans[1])

Measured memory_bytes: 18320
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    ll N;
    cin >> N;

    vector<ll> x(N), y(N), h(N);
    ll start = -1;

    rep(i, N) {
        cin >> x[i] >> y[i] >> h[i];
        if (h[i] > 0) start = i;
    }

    ll X = -1, Y = -1, H = -1;

    rep(i, 101) {
        rep(j, 101) {
            ll tmph = h[start] + abs(i - x[start]) + abs(j - y[start]);
            bool flg = true;

            rep(n, N) {
                if (h[n] > 0 && tmph != h[n] + abs(i - x[n]) + abs(j - y[n]))
                    flg = false;
                if (h[n] == 0 && tmph > abs(i - x[n]) + abs(j - y[n]))
                    flg = false;
            }

            if (flg) {
                X = i;
                Y = j;
                H = tmph;
            }
        }
    }

    cout << X << " " << Y << " " << H << endl;

    return 0;
}

Measured memory_bytes: 3556
#include <iostream>
using namespace std;
int main(void){
    int x,y;
    while(true){
        cin >> x;
        cin >> y;
        if(x==0 && y==0){
            break;//whileから抜ける
        }
        if(x < y){
            cout << x << " " << y;
        }
        else{
            cout << y << " " << x;
        }
        cout << endl;
    }
}


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


int main(){
    int n,y;
    cin>>n>>y;
    int a,b,c;
    for(int i=0;i<=2000;i++){
        for(int j=0;j<=2000;j++){
            if(n-i-j<0){
                continue;
            }
            int count=i*10000+j*5000+(n-i-j)*1000;
            if(count==y){
                cout<<i<<" "<<j<<" "<<n-i-j<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
}
    
 

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
const int MAX = 16;

int n,m;
int r,c,size,angle;
int field[MAX][MAX];
int tmp[MAX][MAX];  
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
bool flg;

void print(){
  for(int i = 0 ;i < n ; i++){
    for(int j = 0 ; j < n ; j++){
      if(!j) cout << field[i][j];
      else cout << " " << field[i][j];
    }
    cout << endl;
  }
}

void rt(){
 for(int i = 0 ; i < size ; i++){
    for(int j = 0 ; j < size ; j++){
       tmp[r+i-1][c+j-1] = field[r+size-j-2][c+i-1]; 
    }
  }

 for(int i = 0 ; i < size ; i++){
   for(int j = 0 ; j < size ; j++){
     field[r+i-1][c+j-1] = tmp[r+i-1][c+j-1];
   }
 }
}

void rot(){
  if(angle == 0 || angle == 360) return;  
  
  int cnt;

  if(angle == 90) cnt = 1;
  else if(angle == 180) cnt = 2;
  else cnt = 3;

  for(int i = 0 ; i < cnt ; i++){
    memset(tmp,0,sizeof(tmp));
    rt();
  }
}

void rev(){
  for(int i = r-1 ; i < r+size-1 ; i++){
    for(int j = c-1 ; j < c+size-1 ; j++){
      field[i][j] = abs(field[i][j]-1);
    }
  }
}

void ls(){
  int tmp = field[r-1][0];
  for(int i = 0 ; i < n-1 ; i++){
    field[r-1][i] = field[r-1][i+1];
  }
  field[r-1][n-1] = tmp;
}

void rs(){
  int tmp = field[r-1][n-1];
  for(int i = n-1 ; i >= 1 ; i--){
    field[r-1][i] = field[r-1][i-1];
  }
  field[r-1][0] = tmp;
}

void irev(int x,int y){
  if(0 <= x && x < n && 0 <= y && y < n){
    if(flg){
      field[x][y] = 0;
      for(int i = 0 ; i < 4 ; i++){
	int nx = x + dx[i];
	int ny = y + dy[i];
	if(0 <= nx && nx < n && 0 <= ny && ny < n
	   && field[nx][ny]) irev(nx,ny);
      }
    }
    else{
      field[x][y] = 1;
      for(int i = 0 ; i < 4 ; i++){
	int nx = x + dx[i];
	int ny = y + dy[i];
	if(0 <= nx && nx < n && 0 <= ny && ny < n
	   && !field[nx][ny]) irev(nx,ny);
      }
    }
  }
}

int main(){
  cin >> n >> m;
  for(int i = 0 ; i < n ; i++)
    for(int j = 0 ; j < n ; j++)
      cin >> field[i][j];

  while(m--){
    int o;
    cin >> o;
    switch(o){
    case 0:
      cin >> r >> c >> size >> angle;
      rot();
      break;
    case 1:
      cin >> r >> c >> size;
      rev();
      break;
    case 2:
      cin >> r;
      ls();
      break;
    case 3:
      cin >> r;
      rs();
      break;
    case 4:
      cin >> r >> c;
      if(field[r-1][c-1]) flg = true;
      else flg = false;
      irev(r-1,c-1);
      break;
    }
  }
  print();

  return 0;
}

Measured memory_bytes: 1168
N = int(input())
W = []
for _ in range(N):
    w = input()
    W.append(w)

unique = list(set(W))
if len(unique) != N:
    print("No")
    exit()

for i in range(1, N):
    if W[i - 1][-1] != W[i][0]:
        print("No")
        exit()

print("Yes")


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

#define ll long long
#define ull unsigned ll

#define vi vector <int>
#define ii pair <int, int>
#define vii vector <ii>
#define INFLL 9e18
#define INF 2e9
#define EPS 1e-9
#define pb push_back
#define emp emplace_back
#define PI acos(-1.0)
#define endl "\n"
#define mp make_pair
#define DEBUG 0


int main ()

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

    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    
    long double a, b;
    cin >> a >> b;
    cout << (long long)(a*b) << endl;
    return 0;
}

Measured memory_bytes: 3748
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
#define MAXN 100000
char s[MAXN+5];
int p,ans;
int main()
{
    scanf("%s",s+1);
    int len=strlen(s+1);
    for(int i=1;i<=len;i++)
    {
        if(s[i]=='g')
        {
            if(p>0)p--,ans++;
            else p++;
        }
        else
        {
            if(p>0)p--;
            else p++,ans--;
        }
    }
    printf("%d",ans);
}


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

vector<vector <long long> > num(10);

int main(){
  long long k;
  cin >> k;

  if(k<10){
    cout << k;
    return 0;
  }
  for(int i=1;i<10;i++)num[0].push_back(i);
  int count = 9;
  for(int keta=0;keta<10;keta++){
    for(int i=0;i<num[keta].size();i++){
      if(num[keta][i]%10==0){
        num[keta+1].push_back(num[keta][i]*10);
        count++;
        if(count==k){
          cout << num[keta][i]*10;
          return 0;
        }
        num[keta+1].push_back(num[keta][i]*10+1);
        count++;
        if(count==k){
          cout << num[keta][i]*10+1;
          return 0;
        }
      }else if(num[keta][i]%10==9){
        num[keta+1].push_back(num[keta][i]*10+8);
        count++;
        if(count==k){
          cout << num[keta][i]*10;
          return 0;
        }
        num[keta+1].push_back(num[keta][i]*10+9);
        count++;
        if(count==k){
          cout << num[keta][i]*10;
          return 0;
        }
      }else{
        num[keta+1].push_back(num[keta][i]*10+num[keta][i]%10-1);
        count++;
        if(count==k){
          cout << num[keta][i]*10+num[keta][i]%10-1;
          return 0;
        }
        num[keta+1].push_back(num[keta][i]*10+num[keta][i]%10);
        count++;
        if(count==k){
          cout << num[keta][i]*10+num[keta][i]%10;
          return 0;
        }
        num[keta+1].push_back(num[keta][i]*10+num[keta][i]%10+1);
        count++;
        if(count==k){
          cout << num[keta][i]*10+num[keta][i]%10+1;
          return 0;
        }        
      }
    }
  }

  return 0;
}



Measured memory_bytes: 1272
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority queue
#include<deque>//double_ended queue
using namespace std;
int main()
{ 
    int n,m;//頂点、辺
    cin>>n>>m;
    int t[n+1];//親情報を記録したTree
    for(int i=0;i<n+1;i++){
        t[i]=i;
    }
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        //同一連結成分か？
        while(t[a]!=t[t[a]]){
            t[a]=t[t[a]];
        }
        while(t[b]!=t[t[b]]){
            t[b]=t[t[b]];
        }
        if(t[a]!=t[b]){
            if(t[a]<t[b]){t[t[b]]=t[a];}
            else{t[t[a]]=t[b];}
        }
    }
    int ans=0;
    for(int i=1;i<n+1;i++){
        if(i==t[i]){ans++;}
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {

        if (y & 1)
            res = (res * x) % p;

        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int lcm(int a, int b)
{
    return (a * b) / __gcd(a, b);
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc;
    tc = 1;
    while (tc--)
    {
        int n, m, k;
        cin >> n >> m;
        map<int, int> mp,me;
        int a;
        string s;
        int ca=0, pe = 0;
        for (int i = 0; i < m;i++){
            cin >> a >> s;
            if(s=="AC"&&mp[a]==0){
                mp[a] = 1;
                pe += me[a];
                ca++;
            }
            if(s=="WA"&&mp[a]==0){
                me[a]++;
            }
        }
        cout << ca << " " << pe << endl;
    }

    return 0;
}

Measured memory_bytes: 12800
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
	
	void run() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int k[] = new int[m];
		
		for(int i = 0; i < m;i++) {
			int kn = sc.nextInt();
			for(int j =0 ; j < kn; j++) {
				k[i] |= (1 << (sc.nextInt()-1));
			}
		}
		
		int p[] = new int[m];
		for(int i =0 ; i < m; i++) {
			p[i] = sc.nextInt();
		}
		
		int  count=0;
		for(int i = 0; i < 1<<n;i++) {
			boolean flag = true;
			for(int j = 0; j< m;j++) {				
//				System.out.println(m + " " +k[j]+" " + i+ " " +Integer.bitCount((k[j] & i)));
				flag = flag && (p[j] == Integer.bitCount((k[j] & i))%2 );
			}
			if(flag) {
//				System.out.println(i);
				count++;
			}
		}
		
		System.out.println(count);
		
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main() {
    int n, q; cin >> n >> q;
    vector<vector<int>> G(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> X(n);
    for (int i = 0; i < q; i++) {
        int p, x; cin >> p >> x;
        X[--p] += x;
    }

    vector<bool> V(n);
    queue<int> Q;
    Q.push(0); V[0] = true;
    while (!Q.empty()) {
        int s = Q.front(); Q.pop();
        for (int t : G[s]) {
            if (V[t]) continue;
            X[t] += X[s];
            V[t] = true;
            Q.push(t);
        }
    }

    cout << X[0];
    for (int i = 1; i < n; i++) {
        cout << ' ' << X[i];
    }
    cout << endl;
}


Measured memory_bytes: 15604
data=(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)
print(str(data[int(input())-1]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> ii;
typedef pair<long long, pair<int, int>> iii;
typedef pair<ii, ii> iiii;

const double PI = acos(-1.0), EPS = 1e-6;
const int N = 200005, M = 100005, mod = 998244353 , mxLog = 20;

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(6), cout << fixed;

    int t, x;
    cin >> t >> x;
    cout << 1.0 * t / x << '\n';


    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashSet<Long> base = new HashSet<>();
        for (int i = 0; i < n; i++) {
            HashSet<Long> next = new HashSet<>();
            long x = sc.nextInt();
            next.add(x);
            for (long y : base) {
                next.add(getLCD(x, y));
            }
            base.addAll(next);
        }
        System.out.println(base.size());
    }
    
    static long getLCD(long x, long y) {
        return x / getGCM(x, y) * y;
    }
    
    static long getGCM(long x, long y) {
        if (x % y == 0) {
            return y;
        } else {
            return getGCM(y, x % y);
        }
    }
}


Measured memory_bytes: 33908
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int main(){
	char a[4];
	int ans=0;
	for(int i=0;i<4;i++){
		cin>>a[i];
		if(a[i]=='+'){
			ans++;
		}else{
			ans--;
		}
	}
	cout<<ans;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


void solve(long long X, long long A){
    if(X < A){
        cout << 0 << endl;
    }else{
        cout << 10 << endl;
    }
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    long long A;
    scanf("%lld",&A);
    solve(X, A);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

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

void solve(long long N, std::vector<long long> A) {
    sort(A.rbegin(), A.rend());
    vector<int> B;
    B.push_back(A.front());
    for(int i = 1 ; i < A.size() ; i++) {
        B.push_back(A[i]);
        B.push_back(A[i]);
    }
    sort(B.rbegin(), B.rend());
    B.resize(N-1);
    cout << accumulate(B.begin(), B.end(), 0ll) << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}

Measured memory_bytes: 6896
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define m0(x) memset(x,0,sizeof(x))
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

map<ll, ll> primeFactors(ll n)
{
    map<ll, ll> ret;
    while (n % 2 == 0)
    {
        if( ret.find(2) != ret.end() ) {
            ret[2]++;
        }
        else
        {
            ret[2] = 1;
        }
        n = n / 2;
    }
    for (ll i = 3; i <= sqrt(n); i = i+2)
    {
        while (n%i == 0)
        {
            if( ret.find(i) != ret.end() ) {
            ret[i]++;
        }
        else
        {
            ret[i] = 1;
        }
            n = n / i;
        }
    }
    if (n > 2)
        {
            if( ret.find(n) != ret.end() ) {
            ret[n]++;
        }
        else
        {
            ret[n] = 1;
        }
        }
    return ret;
}

void print_map(map<ll, ll> mp){
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        std::cout << "key = " << itr->first           // キーを表示
                        << ", val = " << itr->second << "\n";    // 値を表示
    }
}

// Returns nCr % p
ll nCrModp(ll n, ll r, ll p)
{
    ll C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> h;
    rep(i, N) {
        ll tmp;
        cin >> tmp;
        h.push_back(tmp);
    }
    ll count = 0;

    while (true)
    {
        bool flag = false;
        rep(i, N) {
            if (!flag & h.at(i) > 0) {
                count++;
                flag = true;
            } else if (flag & h.at(i) == 0) {
                flag = false;
            }
        }
        bool no_zero_flag = false;
        rep(i, N)
        {

            if (h.at(i) > 0)
            {
                h.at(i)--;
            }
        }
        rep(i, N)
        {
            if (h.at(i) > 0) {
                no_zero_flag = true;
            }
        }
        if (!no_zero_flag) {
            cout << count << endl;
            return 0;
        }
    }
    return 0;
}



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

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

template<class T> vector<T> read_vector(sint n) {
	vector<T> vs;
	for (sint i = 0; i < n; ++i) {
		vs.push_back(read<T>());
	}
	return vs;
}

inline void write() {
}

template<class T> void write(T const& t) {
	cout << t;
}

template<class T> void write(vector<T> const& ts) {
	if (ts.size() > 0) {
		cout << ts[0];
	}
	for (size_t i = 1; i < ts.size(); ++i) {
		cout << ' ' << ts[i];
	}
}

template<class T, class... Args> void write(T const& t, Args const&... args) {
	cout << t << ' ';
	write(args...);
}

template<class... Args> void writeln(Args const&... args) {
	write(args...);
	cout << '\n';
}

int main() {
	ios_base::sync_with_stdio(false);
	cin .exceptions(ios_base::badbit | ios_base::failbit);
	cout.exceptions(ios_base::badbit | ios_base::failbit);
	cin .tie(nullptr);
	cout.tie(nullptr);
	cout.precision(16);
	void run();
	run();
	return 0;
}

void run() {
	auto const N = read<sint>();
	auto const K = read<sint>();
	auto const Hs = read_vector<sint>(N);

	sint sum = 0;
	for (sint h: Hs) {
		if (h >= K) {
			++sum;
		}
	}
	writeln(sum);
}

Measured memory_bytes: 1400
def main():
    N = int(input())

    h, n, w = -1, -1, -1
    for i in range(1, 3501):
        for j in range(i, 3501):
            if 4*i*j > N*i+N*j:
                if N*i*j % (4*i*j-N*i-N*j) == 0:
                    h, n = i, j
                    w = N*i*j // (4*i*j-N*i-N*j)
                    break

        else:
            continue
        break

    print(h, n, w)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    lint N,K;
    cin >> N >> K;
    lint A[N];
    rep(i,N) cin >> A[i];
    rep(i,K){
        lint B[N+1]={};
        rep(j,N){
            lint l=max(0LL,j-A[j]);
            lint r=min(N-1,j+A[j]);
            B[l]++,B[r+1]--;
        }
        for(int j=0;j<N;j++) B[j+1]+=B[j];
        rep(j,N) A[j]=B[j];
        bool chk=true;
        rep(j,N) if(A[j]!=N) chk=false;
        if(chk){
            break;
        }
    }
    rep(i,N) cout << A[i] << " ";
    cout << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pair<int, int> > vp;
typedef pair<int, int> pr;
typedef tuple<int, int, int> ti;

#define FOR(i, a, b) for (int i = (a), _b = (b); i < _b; i++)
#define FORD(i, b, a) for (int i = (b), _a = (a); i > _a; i--)
#define pb push_back
#define print(v) cout << v << '\n'
#define pr_vec(v)   for (int i = 0; i != v.size(); i++) cout << v[i] << ' '
#define vin(v)  for (auto &i: v)    cin >> i

ld pi = 3.141592653589793238;
ll M = 1e9 + 7;

int gcd(int a, int b) {
    if (a == 0) return b;

    return gcd(b % a, a);
}

bool is_prime(ll n) {
    if (n == 2) return true;
    if (n < 2) return false;
    if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2) {
        if (n % i == 0) return false;
    }

    return true;
}

bool is_palindrome(string s) {
    return equal(s.rbegin(), s.rend(), s.begin());
}


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

    ll t, n, m, k, q, x, y;
    string s;
    bool flag;

    cin >> n;

    if (is_prime(n)) {
        print(1);
        return 0;
    }

    m = 2;
    k = 0;

    unordered_map<ll, ll> factors;

    while (n % 2 == 0) {
        k++;
        n /= 2;
    }

    if (k > 0)  factors[2] = k;
    k = 0;

    for (int i = 3; i <= sqrt(n); i += 2) {
        k = 0;
        while (n % i == 0) {
            k++;
            n /= i;
        }
        factors[i] = k;
    }
    if (n > 2) {
        factors[n] = 1;
    }

    // for (auto i: factors) {
    //     cout << i.first << " -- " << i.second << '\n';
    // }

    m = 0;

    for (auto i: factors) {
        k = i.second;

        ll j = 1;
        while ((j * (j + 1)) / 2 <= k) {
            j++;
        }
        m += j - 1;
    }

    print(m);

    // while (m <= n) {
    //     if (n % m == 0) {
    //         if (is_prime(m)) {
    //             ll div = m;
    //             while (m < n && n % div == 0) {
    //                 n /= div;
    //                 div *= m;
    //                 k++;
    //             }
    //         }
    //     } else if (is_prime(n)) {
    //         k++;
    //         break;
    //     }
    //     m++;
    // }

    // print(k);

    return 0;

}


Measured memory_bytes: 22776
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()
#define endl "\n"

typedef tree<pair<ll,ll> ,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth smallest: " << *A.find_by_order(k-1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

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

    ll pres[4] = {0};
 	ll a, b;
 	cin >> a >> b;
 	pres[a] = pres[b] = 1;
 	for(int i=1;i<4;i++)
 	{
 		if(!pres[i])
 		{
 			cout << i << endl;
 			return 0;
 		}
 	}
    return 0;
}

Measured memory_bytes: 256
a,b,c,x,y = map(int,input().split())
ans = a*x+b*y
for i in range(2*max(x,y)+1):#ABピザを買う枚数で全探索
  ans = min(ans,i*c+max(0,(x-(i//2)))*a+max(0,(y-(i//2)))*b)
print(ans)

Measured memory_bytes: 39816
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll t,a,b,i,j,k,n,x;
    vector<ll>v;
    for(i=0;i<3;i++)
    {
        cin>>k;
        v.push_back(k);
    }
    sort(v.begin(),v.end());
    if(v[0]+v[1]==v[2])
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
    return 0;
}


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

/*
,,,,
　　　　　　　　　　　　　　　　　　　　　　　　　　,.斗*''“i:i:{
　　　　　　　　　　　　　,.　｡. . . * : : : ''' : : : :” :”“ ''ｰ - 弋,,_
　　　　　 　 　 ,.斗*''“ : : : : : : : : : : : : : ' ' ' ' ' ' : : : : : : : : : : :”: '':* ｡ ,
　　　 ,.斗*''“ ” ＼：　　 ”・・． ' ' ' '　　　　　　　　 ' ' ' ' : : : : : : : : : : : : ”ミ*｡,,,,,,　　　　　　 　 　 　 ＿
　　く.　 ◎　 ﾞ:.ﾞ:..　ﾟ:,　:　───────────　　　--　　,,,,,,__ ' ' ' :.:.:.:.:.”≧s｡.　　＿,,,｡s*i:i:i:i:<
　　ﾏ*s｡ :,　 }　ﾟ:,　 :}　　　　　　　　　　　　　　　　　　　　　　　　　　　　”　''　-　”””：：”：：`*｡i:i:i:i:i:i:i;:’
　　　` .｡`　 ,　,ノ ／｡ ,,,_　　　　　　　　　　　　　　　　　　　　　　　　　　　　　＿＿`　　} }　　ﾉi:i:i:i:i:ﾂ
　　　　　 `　*　｡　　`*｡i:i:i::*=-　　　　　　　　　　　＿＿　　　　　　,,,....｡s*'i,:’　　　”`*｡＿,*’i:i:i:i:r’
　　　　　　　　　　　”　─ --　　　　｡｡｡｡｡　　 -　－`''''''''ヽ ─ '''”　　　｀ｰ“　　　　　　　`*｡i:i:i:i:i:i:
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*｡i:i:::
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*ﾟ:,
         fozubaoyou    no BUGs alive!
*/

typedef long long ll;
//{
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define dumo dump
//}

#define debug_interval ','
#define dump_interval endl
#define debug_toggle 0

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cout<<endl;}
template<class...A> inline void debug_rest() {cout<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cout<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cout<<first,debug_rest(rest...);}
//}

int a,b,c,d,ans;
string s,t,u;

int main(){
  cin>>a>>b;
  if(a<=8&&b<=8)dump("Yay!");
  else dump(":(");
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

char dd[501][501];
int main(){
    int h,w,d;
    cin >> h >> w >> d;
    
    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if((i+j)%(2*d)<d){
                if((i-j+2000*d)%(2*d)<d){
                    dd[i][j] = 'R';
                }else{
                    dd[i][j] = 'G';
                }
            }else{
                if((i-j+2000*d)%(2*d)<d){
                    dd[i][j] = 'B';
                }else{
                    dd[i][j] = 'Y';
                }
            }
        }
    }
    rep(i,h){
        rep(j,w){
            cout << dd[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 768
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

const int MOD=1000000007;

int main(){
  int h,w,k;
  cin>>h>>w>>k;
  
  ll dp[110][8];
  rep(i,110){
    rep(j,8) dp[i][j]=0;
  }
  dp[0][0]=1;

  vector<int> C={1,2,3,5,8,13,21};
  
  for(int i=1;i<=h;i++){
    for(int j=0;j<w;j++){
      if(j==0){
        dp[i][j]=((dp[i-1][j]*C[max(0,j-1)]%MOD)*C[max(0,w-j-2)]%MOD+
        (dp[i-1][j+1]*C[max(0,j-1)]%MOD)*C[max(0,w-j-3)]%MOD)%MOD;
      }
      else if(j==w-1){
        dp[i][j]=((dp[i-1][j-1]*C[max(0,j-2)]%MOD)*C[max(0,w-j-2)]%MOD+
        (dp[i-1][j]*C[max(0,j-1)]%MOD)*C[max(0,w-j-2)]%MOD)%MOD;
      }
      else{
        dp[i][j]=((dp[i-1][j-1]*C[max(0,j-2)]%MOD)*C[max(0,w-j-2)]%MOD+
        (dp[i-1][j]*C[max(0,j-1)]%MOD)*C[max(0,w-j-2)]%MOD+
        (dp[i-1][j+1]*C[max(0,j-1)]%MOD)*C[max(0,w-j-3)]%MOD)%MOD;
      }
    }
  }

  cout<<dp[h][k-1]<<endl;
  
  return 0;
}

Measured memory_bytes: 3584
N = input()
rs = list(map(int,input().split(' ')))

buf = 0
for i,r in enumerate(rs):
	flg = 0
	for j in range(0,i):
		if(rs[i] < rs[j]):
			flg = 1
		else:
			pass
	if flg == 0:
		buf = buf + 1
print(buf)

Measured memory_bytes: 3060
fun main(args: Array<String>) {
    // var numberTests = readLine()!!.toInt()
    // var results = mutableListOf<String>()

    // for (i in 0..numberTests-1) {
    var nmk = readLine()!!.split("\\s+".toRegex())
    var n = nmk[0].toInt()
    var m = nmk[1].toInt()
    var k = nmk[2].toLong()

    var aarray = readLine()!!.split("\\s+".toRegex()).map {it.toLong()}
    var barray = readLine()!!.split("\\s+".toRegex()).map {it.toLong()}

    
    val result = experiment(n, m, k, aarray, barray)
    // results.add(result)
    // }

    // for (result in results) {
        println(result)
    // }
}

fun experiment(n: Int, m: Int, k: Long, aarray : List<Long>, barray : List<Long>) : String {

    var result = 0

    val maxAandSum = calcNumMax(k , aarray)
    val maxBandSum = calcNumMax(k , barray)

    // println("${maxAandSum.first} , ${maxBandSum.first}")

    val minimax = maxAandSum
    var currentMaxNum = minimax.first
    var currentSumNum = minimax.second
    val anotherMax = maxBandSum.first
    var currentSumAnother : Long = 0
    var currentNum =  currentMaxNum
    var currentAnotherNum = 0

    for (i in 0..anotherMax-1) {
        if (currentSumNum + currentSumAnother + barray[i] > k) {
            // 超えるので、今の結果を記録
            if (currentMaxNum < currentNum + i) currentMaxNum = currentNum + i
            while (currentSumNum + currentSumAnother + barray[i] > k) {
                currentSumNum -= aarray[currentNum-1]
                currentNum -= 1
            }
        } else {
            // 超えないので、冊数積んで記録
            if (currentMaxNum < currentNum + i+1) currentMaxNum = currentNum + i + 1
        }
        
        currentSumAnother += barray[i]


        // println("$i $currentMaxNum $currentSumNum $currentSumAnother")
    }

    return currentMaxNum.toString()
}

fun calcNumMax(k: Long , arr : List<Long> ) : Pair<Int, Long> {
    var maxNum : Int = 0
    var sumCurrent : Long = 0
    for (i in 0..arr.size-1) {
        if (sumCurrent + arr[i] > k) {return Pair(i, sumCurrent)}
        else {sumCurrent +=  arr[i] }
    } 
    return Pair(arr.size, sumCurrent)
}

Measured memory_bytes: 81852
M = 1000000007
n = int(input())


def pack(s):
    p = [s[0]]
    for i in range(1, len(s)):
        if s[i] != s[i - 1]:
            p.append(s[i])
    return p


s1 = pack(input())
s2 = pack(input())


def solve():
    res = 6 if s1[0] != s2[0] else 3
    for i in range(1, len(s1)):
        if s1[i - 1] != s2[i - 1]:
            if s1[i] != s2[i]:
                res *= 3
            else:
                res *= 1
        else:
            if s1[i] != s2[i]:
                res *= 2
            else:
                res *= 2
        res %= M
    return res


print(solve())


Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<cstdio>

using namespace std;

void SwapPeachAndApple(string &str){
	string s;

	for(unsigned int i = 0; i < str.length(); i++){
		if( str.find("apple", i) == i ){
			s += "peach";i+=4;
		}else if( str.find("peach", i) == i ){
			s += "apple";i+=4;
		}else{
			s += str.at(i);
		}
	}
	str = s;
	return ;
}

int main(void){
	char buf[1024];
	string s;

	cin.get(buf, sizeof(buf)/sizeof(buf[0]));
	s = buf;
	SwapPeachAndApple(s);

	cout << s << endl;
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <cstdio>
#include <vector>
#include <iostream>
#include <string.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#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++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

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

int main(){
	int ans = INF;
	int x, tmp, unchi;
	cin >> x;
	FOR(i, 1, 100){
		FOR(j, 2, 100){
			tmp = pow(i, j);
			if (tmp > x)break;
			if ((x - tmp) <= ans){
				 unchi = tmp;
				 ans = x - tmp;
			}
		}
	}
	cout << unchi << "\n";
	return 0;
}


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

int main(void)
{
    int N,K;
    cin >> N;
    cin >> K;
    int d[K+1]={0};
    int A[K+1][N+1]={0};
    int i,j;
    for(i=1;i<=K;i++){
        cin >> d[i];
        for(j=1;j<=d[i];j++){
            cin >> A[i][j];
        }
    }

    int k;
    int P[N+1]={0};
    int count = 0;

    for(i=1;i<=N;i++){ 
        for(j=1;j<=K;j++){ 
            for(k=1;k<=d[j];k++){
                if(i == A[j][k]){
                    P[i] = P[i] + A[j][k];
                }
            }
        }
        if(P[i] == 0) count++;
    }

    cout << count << endl;

}

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

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

void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c, std::vector<long long> d){
    REP(i, N) {
        int ans = 0;
        int mini = 2001001001;
        REP(j, M) {
            int dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (mini > dist) ans = j + 1;
            chmin(mini, dist);
        }
        cout << ans << '\n';
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(N);
    std::vector<long long> b(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    std::vector<long long> c(M);
    std::vector<long long> d(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&c[i]);
        scanf("%lld",&d[i]);
    }
    solve(N, M, std::move(a), std::move(b), std::move(c), std::move(d));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define FOR(i, s, n) for(int i=(int)(s); i<(int)(n); ++i)
#define ALL(n) (n).begin(), (n).end()
#define pb push_back

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;

const ll MAX_V = 100000;
const ll INF = 1e9;
const ll MOD = 998244353;

int main(){
    int n; cin >> n;
    int a[n];
    REP(i, n) cin >> a[i];
    int sum = 0;
    REP(i, n) sum += a[i];
    int mean = sum / n;

    int cost_a = 0, cost_b = 0;
    REP(i, n){
        cost_a += pow((mean - a[i]), 2);
    }
    REP(i, n){
        cost_b += pow((mean+1 - a[i]), 2);
    }
    cout << min(cost_a, cost_b) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;



//少数点表示
//cout <<std::fixed << std::setprecision(14)

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    char c,ans;
    cin >> c;
    ans=c+1;
    cout << ans;
}

Measured memory_bytes: 256
import numpy as np

def getNearestValue(list, num):
    """
    概要: リストからある値に最も近い値を返却する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

n = int(input())
ali = list(map(int, input().split()))
naka = sum(ali)/2

zoukali = []
total = 0
for a in ali:
    total += a
    zoukali.append(total)

medi_ind = getNearestValue(zoukali, naka)

mae = sum(ali[:medi_ind+1])
ushiro = sum(ali[medi_ind+1:])


print(abs(mae-ushiro))

Measured memory_bytes: 35700