akhauriyash/Code-Regression huggingface dataset:
import java.io.*;

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
int[][] dp=new int[11][331];
boolean[] use=new boolean[10];
dfs(1,0,dp,use);
while((line=br.readLine())!=null){
String[] values=line.split(" ");
int n=Integer.parseInt(values[0]);
int s=Integer.parseInt(values[1]);
if(n>10||s>330){
System.out.println("0");
continue;
}
System.out.println(dp[n][s]);
}
}
private static void dfs(int depth,int sum,int[][] dp,boolean[] use){
dp[depth-1][sum]++;
for(int i=0;i<=9;i++){
if(!use[i]){
use[i]=true;
dfs(depth+1,sum+depth*i,dp,use);
use[i]=false;
}
}
}
}

Measured memory_bytes: 19412
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
#define ll long long 
int n;
vector<int> g[200005];
int d1[100005],d2[100005];
void dfs(int rt,int fa,int d,int dist[])
{
    dist[rt]=d;
    for(int x:g[rt])
    {
        if(x!=fa)
            dfs(x,rt,d+1,dist);
    }
}
int main()
{
    while(cin>>n)
    {
        for (int i=0;i<n;i++) {
            g[i].clear();
        }
        int u,v;
        for (int i=0;i<n-1;i++)
        {
            cin >> u >> v;
            u--,v--;
            g[u].push_back(v);
            g[v].push_back(u);
        }
        dfs(0,-1,0,d1);
        dfs(n-1,-1,0,d2);
        int ans=0;
        for(int i=0;i<n;i++)
        {
            if (d1[i]<=d2[i]) {
            	ans++;
			}
            else {
            	ans--;
            }
        }
        if(ans>0)
            cout << "Fennec" << endl;
        else
            cout<<"Snuke"<<endl;
    }
    return 0;
}

Measured memory_bytes: 15104
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx") 
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp>
using namespace std;
using namespace __gnu_pbds;
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define F2(i,a,b) for(int i=(a);i<(b);++i)
#define dF(i,a,b) for(int i=(a);i>=(b);--i)
#define dF2(i,a,b) for(int i=(a);i>(b);--i)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define INF 0x3f3f3f3f
#define INFll 0x3f3f3f3f3f3f3f3f
#define y0 _lxybz_
#define y1 _ljmnzyzhhhoscartxdy_
typedef long double ld;
typedef long long ll;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize
#define lo(x) ((x)&(-(x)))
#define trav(a, x) for (auto &a : x)
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
const ld Pi = 4*atan((ld)1);
template<class T> void chmin(T &a,const T&b) { a = min(a, b); }
template<class T> void chmax(T &a,const T&b) { a = max(a, b); }
namespace IO{
template<class T> inline void read(T&ret)
{
	ret=0; int f=1; char c=getchar();
	while(c<48||c>57){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	ret*=f;
}
template<class T> inline void prin(const T&ret)
{
	if(!ret){putchar(48);return;} static T o; o=ret;
	if(o<0){putchar('-');o=-o;}
	static int op[25],tt; tt=0;
	while(o){
		op[++tt]=o%10;
		o/=10;
	}
	for(int i=tt;i;--i)putchar(op[i]+48);
}
template<class T> inline void pri_(const T&ret)
{
	prin(ret);putchar(' ');
}
template<class T> inline void priE(const T&ret)
{
	prin(ret);putchar('\n');
}
}
using namespace IO;

#define N 
#define MO 
int n,a,r;
inline void _Sol_()
{
	read(n);read(r);
	if(n<10)a=r+100*(10-n);else a=r;
	priE(a);
}

int main()
{
	int T=1; //read(T);
	while(T--)_Sol_();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
double degree(double x) {
    return 180 * x / 3.141592653;
}
int main()
{
    double a,b,x;
    cin >> a >> b >> x;
    cout << fixed;
    if(a * a * b < 2 * x) {
        cout << setprecision(10) << degree(atan(2 * (a * a * b - x) / (a * a * a))) << endl;
    }else {
        cout << setprecision(10) << degree(atan(a * b * b / (2 * x))) << endl;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int A[100000];
int res;
int ress;
int resx[100000];
int resy[100000];
inline int doit(int x, int y){
  resx[ress] = x;
  resy[ress++] = y;
  return x - y;
}
int main(){
  int i, j, k, mi, mx;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY, Q5VJL1cS=0, RZTsC2BF, cTE1_r3A, e98WHCEY;
    for(KL2GvlyY=(0);KL2GvlyY<((N-1)+1);KL2GvlyY++){
      cTE1_r3A = A[KL2GvlyY];
      if(Q5VJL1cS==0 || e98WHCEY>cTE1_r3A){
        e98WHCEY = cTE1_r3A;
        Q5VJL1cS = 1;
        RZTsC2BF = KL2GvlyY;
      }
    }
    mi =RZTsC2BF;
  }
  {
    int FmcKpFmN, KrdatlYV, WYIGIcGE, t_ynMSdg, xr20shxY=0;
    for(FmcKpFmN=(0);FmcKpFmN<((N-1)+1);FmcKpFmN++){
      t_ynMSdg = A[FmcKpFmN];
      if(xr20shxY==0 || WYIGIcGE<t_ynMSdg){
        WYIGIcGE = t_ynMSdg;
        xr20shxY = 1;
        KrdatlYV = FmcKpFmN;
      }
    }
    mx =KrdatlYV;
  }
  if(mi==mx){
    mx++;
  }
  for(i=0;i<(N);i++){
    if(i==mi || i==mx){
      continue;
    }
    if(A[i] >= 0){
      A[mi] = doit(A[mi], A[i]);
    }
    else{
      A[mx] = doit(A[mx], A[i]);
    }
  }
  res = doit(A[mx], A[mi]);
  wt_L(res);
  wt_L('\n');
  for(i=0;i<(ress);i++){
    wt_L(resx[i]);
    wt_L(' ');
    wt_L(resy[i]);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190902-1

// --- original code ---
// int N, A[1d5];
// 
// int res, ress, resx[1d5], resy[1d5];
// 
// inline int doit(int x, int y){
//   resx[ress] = x;
//   resy[ress++] = y;
//   return x - y;
// }
// 
// {
//   int i, j, k, mi, mx;
//   rd(N,A(N));
// 
//   mi = argmin[k=0---N-1](A[k]);
//   mx = argmax[k=0---N-1](A[k]);
//   if(mi==mx) mx++;
// 
//   rep(i,N){
//     if(i==mi || i==mx) continue;
//     if(A[i] >= 0) A[mi] = doit(A[mi], A[i]);
//     else          A[mx] = doit(A[mx], A[i]);
//   }
//   res = doit(A[mx], A[mi]);
// 
//   wt(res);
//   rep(i,ress) wt(resx[i], resy[i]);
// }


Measured memory_bytes: 3072
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iomanip>
using namespace std;
 
#define PI 3.14159265358979323846264338327950L

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int cnt = 1;
	while ( 1 ) {
		if (cnt % 2 == 1) {
			C -= B;
			if (C <= 0) {
				cout << "Yes" << endl;
				return 0;
			}
		} else {
			A -= D;
			if (A <= 0) {
				cout << "No" << endl;
				return 0;
			}
		}
		cnt++;
	}
}

Measured memory_bytes: 3624
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#define ll long long
using namespace std;
int d[100] = {};
int A[100][100] = {};
int B[100] = {};
int main(){
     int N,K,counter;
     cin >> N >> K;
     for(int i = 0; i < K; i++){
          cin >> d[i];
          for(int j = 0; j < d[i]; j++){
               cin >> A[i][j];
               B[A[i][j] - 1] = 1;
          }
     }
     counter = 0;
     for(int i = 0; i < N; i++){
          if(B[i] == 0){
               counter++;
          }
     }
     cout << counter << endl;
     return 0;
}

Measured memory_bytes: 3672
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //e
  int n;
  cin >> n;
  vector<int> pos(n);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    pos[--a] = i;
  }
  long long ans = 0;
  set<int> st;
  st.insert(-1);
  st.insert(n);
  st.insert(pos[n - 1]);
  for (int i = n - 2; i >= 0; i--) {
    auto a = st.upper_bound(pos[i]);
    a--;
    auto b = st.upper_bound(pos[i]);
    if (*b < n) {
      auto bb = b;
      bb++;
      ans += (1LL * (pos[i] - *a) * (*bb - *b)) * (i + 1);
    }
    if (*a > -1) {
      auto aa = a;
      aa--;
      ans += (1LL * (*b - pos[i]) * (*a - *aa)) * (i + 1);
    }
    st.insert(pos[i]);
  }
  cout << ans << endl;
  return 0;
}

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

/*マージソートでx,y座標共に昇順に並べる。（x最優先)*/
void merge( int* x, int* y, int left, int mid, int right )
{
    int ls = mid - left;
    int rs = right - mid;

    int L1[ls+1], R1[rs+1];
    int L2[ls+1], R2[rs+1];
    L1[ls] = 2000000000, R1[rs] = 2000000000;
    L2[ls] = 2000000000, R2[rs] = 2000000000;
    

    for( int i = 0; i < ls; i++ )
    {
        L1[i] = x[left+i];
        L2[i] = y[left+i];
    }
    for( int i = 0; i < rs; i++ )
    {
        R1[i] = x[mid+i];
        R2[i] = y[mid+i];
    }

    int i = 0, j = 0;
    for( int k = left; k < right; k++ )
    {
        if( L1[i] < R1[j] )
        {
            x[k] = L1[i];
            y[k] = L2[i];
            i++;
        }
        else if ( L1[i] > R1[j] )
        {
            x[k] = R1[j];
            y[k] = R2[j];
            j++;
        }
        else
        {
            if( L2[i] <= R2[j] )
            {
                x[k] = L1[i];
                y[k] = L2[i];
                i++;
            }
            else
            {
                x[k] = R1[j];
                y[k] = R2[j];
                j++;
            }
        }
    }
}

void mergeSort( int* x, int* y, int left, int right )
{
    if( left + 1 < right )
    {
        int mid = ( left + right ) / 2;
        mergeSort( x, y, left, mid );
        mergeSort( x, y, mid, right );
        merge( x, y, left, mid, right );
    }
}

int main()
{
    int n;

    cin >> n;

    int x[n], y[n];

    for( int i = 0; i < n; i++ )
        cin >> x[i] >> y[i];

    mergeSort( x, y, 0, n );

    for( int i = 0; i < n; i++ )
        cout << x[i] << " " << y[i] << endl;

    return 0;
}


Measured memory_bytes: 4632
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>

using namespace std;
vector<long long int> bou;
vector<long long int> kotae;
set<long long int> S;
long long int n;
long long int a;
long long int now;
long long int c;
long long int aa,bb;
long long int kotaee;
int q1;
int q2;

int main(){
	cin >> n;
	for(long long int i =0;i<n;i++){
		cin >> a;
		bou.push_back(a);
		S.insert(a);
	}
	sort(bou.begin(),bou.end(),greater<long long int>());
	now = bou[0];
	kotaee = 1;
	if(bou[0] == bou[1] && bou[1] == bou[2] && bou[2] == bou[3]){
		cout << bou[0]*bou[0] << endl;
		return 0;
	}
	for(long long int i = 1;i<n;i++){
		if(now == bou[i]){
			if(q1 != bou[i] && q1 == 0){
				q1 = bou[i];
				if(bou[i] == bou[i+1] && bou[i+1] == bou[i+2] && bou[i] == bou[i-1]){
					cout << bou[i]*bou[i] << endl;
					return 0;
				}
			}
			else if(q1 != bou[i]){
				kotaee = q1 * bou[i];
				cout << kotaee << endl;
				return 0;
			}
		}
		else {now = bou[i];}
	}
	cout << 0 << endl;
	return 0;
}
	
			
		
		

Measured memory_bytes: 5748
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pw(x) (1ll << (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl

//-----
const int N = 1e3 + 7;
const db eps = 1e-10;
int sgn(db d) { return (d > eps) - (d < -eps); }
int n, x[N], y[N], r[N];
db eg[N][N];
db len(db x, db y) { return sqrt(x * x + y * y); }
db dis[N];
db dij(int s = 0, int t = 1) { 
	rep(i, 0, n) if (i != s) dis[i] = eg[s][i];
	priority_queue<pair<db, int> > stk;
	rep(i, 0, n) stk.push({-dis[i], i});
	while (!stk.empty()) {
		db _d; int u;
		tie(_d, u) = stk.top(); stk.pop();
		if (sgn(_d + dis[u]) != 0) continue;
		rep(v, 0, n) if (dis[v] > dis[u] + eg[u][v]) {
			dis[v] = dis[u] + eg[u][v];
			stk.push({-dis[v], v});
		}
	}
	return dis[t];
}
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	rep(i, 0, 2) cin >> x[i] >> y[i], r[i] = 0;
	cin >> n; n += 2;
	rep(i, 2, n) cin >> x[i] >> y[i] >> r[i];
	rep(i, 0, n) rep(j, 0, n) {
		eg[i][j] = max(0., len(x[i] - x[j], y[i] - y[j]) - r[i] - r[j]);
	}
	cout << setprecision(15) << dij();
	return 0;
}

Measured memory_bytes: 13936
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

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

    int n, k, s;
    cin >> n >> k >> s;
    int a = s;
    int b = s + 1;
    if (a == 1e9) {
        b = 1;
    }
    for (int i = 0; i < n; i++) {
        if (i < k) cout << a << ' ';
        else cout << b << ' ';
    }
    cout << endl;
}   


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

P f(int x) {
    int a = x%10;
    int b = 0;
    while (x) {
        b = x;
        x /= 10;
    }
    return P(a,b);
}

int main() {
    int n;
    cin >> n;
    map<P,int> freq;
    for (int i = 1; i <= n; ++i) {
        P p = f(i);
        freq[p]++;
    }
    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        P p = f(i);
        P q(p.second, p.first);
        ans += freq[q];
    }
    cout << ans << endl;
    return 0;
}

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

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

int main(){

	int n, x, sum = 0, menor = 1e5;
	
	scanf("%d %d", &n, &x);
	
	vector<int> m(n);
	
	rep(i,n){
		scanf("%d", &m[i]);
		if (m[i] < menor) menor = m[i]; 
		sum += m[i];
	}
	auto a = n + (x-sum)/menor;
	printf("%d\n", (sum <= x) ? a : 0 );
	return 0;
}



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

int main()
{
	char c;
	cin >> c;
	switch(c)
	{
		case 'a':
		case 'e':
		case 'i':
		case 'o':
		case 'u':
			cout << "vowel" << endl;
			break;
		default:
			cout << "consonant" << endl;
			break;
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int main() {
	ll X,Y;
	cin >> X >> Y;
	//01 10 11 に持ち込まれた人が負け
	//20 02 30 03 で回ってきたら勝ち
	//二人とも適切なプレイをするというのに勝敗が一意に決まる→初期状態で勝敗はもう決まっている!?
	//X+Y<=2 && abs(X-Y)<=1　に相手を落とし込めばいい
	//X,Y -> X-2i,Y+i 
	//abs(X-Y)>1 -> abs(X-Y)<=1には常にコントロールできる X+Yは自然に減っていく
	//abs(X-Y)<=1 -> abs(X-Y)<=1 は不可能
	//初期状態がabs(X-Y)<=1 だとAliceの負け??
	if(abs(X-Y)<=1) cout << "Brown" << endl;
	else cout << "Alice" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

long long Merge(int A[],int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  int i,j,k;
  int L[n1+1],R[n2+1];
  long long res=0;
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1]=1000000001;
  R[n2]=1000000001;
  
  i=j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
    }else{
      A[k]=R[j];
      j++;
      res+= (long long)n1- (long long)i;
    }
  }
  return res;
}

long long Merge_Sort(int A[],int left,int right){
  int mid;
  long long res=0;
  if(left+1<right){
    mid=(left+right)/2;

    res+=Merge_Sort(A,left,mid);
    res+=Merge_Sort(A,mid,right);
    res+=Merge(A,left,mid,right);
    
  }
  return res;
}

int main(){
  int i,n,S[200000];
  long long x;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&S[i]);

  x=Merge_Sort(S,0,n);
  printf("%ld\n",x);
  return 0;
}

Measured memory_bytes: 2156
# require 'pry'
INF = 10 ** 8
H, W = gets.split.map(&:to_i)
areas = []
H.times do
  areas << gets.chomp.split("") + ["@"]
end
areas << Array.new(W+1, "@")
# areas.each do |a|
#   p a
# end
dp = Array.new(H+1){Array.new(W+1, 0)}
# binding.pry
(H-1).downto(0) do |i|
  (W-1).downto(0) do |j|
    if areas[i][j] == "."
      # dp[i][j] = [areas[i+1][j] == "@" ? INF : dp[i+1][j], areas[i][j+1] == "@" ? INF : dp[i][j+1]].min
      sita = areas[i+1][j] == "@" ? INF : dp[i+1][j]
      migi = areas[i][j+1] == "@" ? INF : dp[i][j+1]
      dp[i][j] = sita <= migi ? sita : migi
      dp[i][j] = 0 if dp[i][j] == INF
   elsif areas[i][j] == "#"
      # dp[i][j] = [areas[i+1][j] == "@" ? INF : areas[i+1][j] == "#" ? dp[i+1][j] : dp[i+1][j] + 1, areas[i][j+1] == "@" ? INF : areas[i][j+1] == "#" ? dp[i][j+1] : dp[i][j+1] + 1].min
      sita = areas[i+1][j] == "@" ? INF : areas[i+1][j] == "#" ? dp[i+1][j] : dp[i+1][j] + 1
      migi = areas[i][j+1] == "@" ? INF : areas[i][j+1] == "#" ? dp[i][j+1] : dp[i][j+1] + 1
      dp[i][j] = sita <= migi ? sita : migi
      dp[i][j] = 1 if dp[i][j] == INF
    end
  end
end
# dp.each do |d|
#   p d
# end
puts dp[0][0]


Measured memory_bytes: 2812
N, M = map(int, input().split())
AB = list()
for i in range(N):
    AB.append(tuple(map(int, input().split())))
AB.sort()
money = 0
i = 0
while M > AB[i][1]:
    M -= AB[i][1]
    money += AB[i][0]*AB[i][1]
    #print(money)
    i += 1

money += AB[i][0]*M
M = 0
print(money)


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

C = [[0]*10 for _ in range(10)]
for n in range(1, N+1):
    s = str(n)
    C[int(s[0])][int(s[-1])] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += C[i][j]*C[j][i]
print(ans)


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

using namespace std;

typedef long long LL;
#define N 420
#define M 82000

const LL mod=998244353;

LL n,ans,a[N],b[N][N],p[N][N],cnt,fa[M],sz[M],sz2[M],sum[M],C[N][N],f[M][N],g[M][N],dp[N],pw[N];

void upd(LL &x,LL y){x=(x+y%mod+mod)%mod;}

int main(){
	scanf("%lld",&n);
	pw[0]=1; for (LL i=1;i<=n;++i) pw[i]=pw[i-1]*2%mod;
	for (LL i=1;i<=n;++i){
		scanf("%lld",a+i);
		for (LL j=1;j<=a[i];++j) b[j][i]=1;
	}
	for (LL i=1;i<=n;++i){
		for (LL j=1;j<=n;++j) if (b[i][j]){
			if (!b[i][j-1]){p[i][j]=++cnt; fa[cnt]=p[i-1][j];}
			else p[i][j]=p[i][j-1];
			++sz[p[i][j]]; ++sz2[fa[p[i][j]]];
		}
	}
	for (LL i=1;i<=cnt;++i){
		sum[i]=sz[i]-sz2[i];
		f[i][0]=1;
		g[i][0]=1;
	}
	for (LL i=0;i<=n;++i){
		C[i][0]=1;
		for (LL j=1;j<=i;++j) C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	for (LL v=cnt;v;--v){
		memset(dp,0,sizeof dp);
		for (LL i=0;i<=sz[v];++i){
			upd(dp[i],g[v][i]*(pw[sz[v]-i]-1));
			for (LL j=1;j<=i;++j)
				upd(dp[i-j],g[v][i]*C[i][j]%mod*pw[sz[v]-i]);
		}
		memcpy(g[v],dp,sizeof g[v]);
		memset(dp,0,sizeof dp);
		for (LL i=0;i<=sz[v];++i){
			upd(g[v][sz[v]-i],f[v][i]);
			for (LL j=0;j<=sz[v]-i;++j)
				upd(dp[i+j],f[v][i]*C[sz[v]-i][j]%mod*pw[i]);
		}
		memcpy(f[v],dp,sizeof f[v]);
		LL u=fa[v];
		memset(dp,0,sizeof dp);
		for (LL i=0;i<=sum[u];++i)
			for (LL j=0;j<=sz[v];++j){
				upd(dp[i+j],f[u][i]*f[v][j]);
			}
		sum[u]+=sz[v];
		memcpy(f[u],dp,sizeof f[u]);
		memset(dp,0,sizeof dp);
		for (LL i=0;i<=sum[u];++i)
			for (LL j=0;j<=sz[v];++j){
				upd(dp[i+j],g[u][i]*g[v][j]);
			}
		memcpy(g[u],dp,sizeof g[u]);
	}
	printf("%lld\n",g[1][0]);
		
	return 0;
}
			

Measured memory_bytes: 534784
s = list(input())
t = ["dream","dreamer","erase","eraser"]
s = s[::-1]
t1=[]
for i in t:
    t1.append(i[::-1])

count = 0
while True:
    check = False
    for i in t1:
        
        if s[count:min(count+len(i),len(s))] == list(i):
            count += len(i)
            check = True
            if count == len(s):
                print("YES")
                exit()
            break
    if count == len(s):
        print("Yes")
        exit()
    if check == False:
        print("NO")
        exit()

Measured memory_bytes: 4652
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int     ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 1e-8;



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

    ll t;
    cin>>t;
    if(t>=30) cout<<"Yes"<<nn;
    else cout<<"No"<<nn;











}


/* Final check before submit :

1. array size or integer overflow,like uninitialised 0 index.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***

*/





Measured memory_bytes: 3548
n = int(input())
dv = float('inf')
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

div = make_divisors(n)
# print(make_divisors(n), len(make_divisors(n)))
# print(make_divisors(n)[169//2])
l = len(make_divisors(n))
# print(div)
if l % 2 == 0:
    for i in range(l//2):
        if dv > (div[i]-1) + (div[l-i-1]-1):
            dv = (div[i]-1) + (div[l-i-1]-1)
else:
    for i in range((l//2)+1):
        if dv > (div[i]-1) + (div[l-i-1]-1):
            dv = (div[i]-1) + (div[l-i-1]-1)

print(dv)

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

int main()
{
    int n, m;
    cin >> n >> m;

    vi v(n);
    int suma = 0;
    for(auto &z : v)
    {
        cin >> z;
        suma += z;
    }

    sort(rall(v));

    double izraz = (double)suma / (4.00*m);

    if(v[m-1]>=izraz)cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define y1 as214
#define ii pair < int , ll >
#define iii pair < int , ii >
#define iv pair < ii , ii >
 
#define fi first
#define se second
#define fr front()
#define pb push_back
 
#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , n) for(int i = 0 ; i < n ; ++i)
 
#define ll long long
#define oo INT_MAX
 
const int N = 1e2 + 5;
const int K = 1e5 + 5;
ll n , k;
ll mod = 1e9 + 7;
ll a[N];
ll dp[N][K] , dp1[N][K];
 
/// dp[i][j] là số cách chia kẹo cho i đưa nhỏ đầu tiên và tốn đúng j viên kẹo.
/// dp1[i][j] là số cách chia kẹo cho i đứa nhỏ đầu tiên và tốn ko quá j viên kẹo.
 
int main()
{
    //freopen("M.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    FOR(i , 1 , n)
        cin >> a[i];
    FOR(i , 0 , a[1])
    {
        dp1[1][i] = i + 1;
        dp[1][i] = 1;
    }
    FOR(i , a[1] + 1 , k)
        dp1[1][i] = dp1[1][i - 1];
 
    FOR(i , 1 , n)
    {
        dp1[i][0] = 1;
        dp[i][0] = 1;
    }
 
    FOR(i , 2 , n)
    {
        FOR(j , 1 , k)
        {
            dp[i][j] = (dp[i][j] + (dp1[i - 1][j] - ((j - a[i] - 1 >= 0) ? dp1[i - 1][j - a[i] - 1] : 0)) + mod) % mod;
            dp1[i][j] = (dp[i][j] + dp1[i][j - 1]) % mod;
        }
    }
    cout << dp[n][k] << endl;
}

Measured memory_bytes: 159232
my $N = <STDIN>;
my $str = <STDIN>;
@m = split(/ /,$str);
my $str2 = <STDIN>;
@s = split(/ /,$str2);
 
my $sum = 0;
 
my $amari_m = 0;
my $anari_s = 0;
for(my $i=0;$i<=$N;$i++){
   #print "$i $sum $anari_s\n";
   $amari_m = $m[$i];
   if ($anari_s >   $amari_m){
      $sum = $sum + $amari_m;
      $anari_s = $s[$i];
      next;
   }else{
      $sum = $sum + $anari_s;
      $amari_m = $amari_m - $anari_s;
   }
   #print "$i $sum $anari_s\n";
   if ($s[$i] >  $amari_m){
     $sum = $sum + $amari_m;
     $anari_s = $s[$i] - $amari_m;
     next;
   }else{
     $sum = $sum + $s[$i];
     $anari_s = 0;
   }
}
 
print "$sum\n";

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

int main() {
  int n; 
  cin >> n;
  int ans = 1;
  rep(i, 3) ans *= n;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
let(&)m n=let rec($)x y=if y<=0then x else y$(x mod y)in(max m n)$(min m n);;let(@)m n=m*n/(m&n);;let rec f()=Scanf.scanf"%d %d
"(fun a b->f(Printf.printf"%d %d
"(a&b)(a@b)));;try f()with _->()

Measured memory_bytes: 2324
N, C, K =map(int, input().split())
T = [int(input()) for _ in range(N)]
T = sorted(T)
ans = 1
tmp = 1
mintime = T[0]

for i in range(1, N):
    nowtime = T[i]
    tmp += 1   
    if tmp > C or nowtime - mintime > K:
        mintime = nowtime
        ans += 1
        tmp = 1

print(ans)

Measured memory_bytes: 8280
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

    int m = 100010;
    VI p(m);
    REP(i,n){
        int a;
        scanf("%d", &a);
        p[a]++;
        p[a+1]++;
        p[a+2]++;
    }

    int ans = 0;
    REP(i,m) ans = max(ans, p[i]);
    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;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	int n, k;
	cin >> n >> k;
	
	vi h(n);
	for(int& x : h)cin >> x;
	
	vi dp(n, INT_MAX);
	dp[0] = 0;
	for(int i=1 ; i<n ; ++i){
		for(int j=i-1 ; j>=max(0, i-k) ; --j){
			dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
		}
	}
	
	cout << dp[n-1];
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 3988
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 5e5+10;
ll a[N];
string s;
queue<ll>q;
ll n;
ll num=0;
int main(){
	cin >> s;
	n=s.length()+1;
	if(s[0]=='<')
	q.push(0);
	for(ll i=0;i<n-1;i++){
		if(s[i]=='<'&&s[i-1]=='>')
		q.push(i);
	}
	if(s[n-2]=='>')
	q.push(n-1);
	while(!q.empty()){
		ll x=q.front();
		q.pop();
		ll l=x,r=x;
		a[x]=0;
		if(x==0){
			while(s[r]=='<'){
				a[r+1]=max(a[r]+1,a[r]);
				r++;
			}
		}
		else if(x==n-1){
			while(s[l-1]=='>'){
				a[l-1]=max(a[l-1],a[l]+1);
				l--;
			}
		}
		else{
			while(s[l-1]=='>'){
				a[l-1]=max(a[l-1],a[l]+1);
				l--;
			}
			while(s[r]=='<'){
				a[r+1]=max(a[r]+1,a[r]);
				r++;
			}
		}
	}
	ll ans=0;
	for(ll i=0;i<=n;i++){
		ans+=a[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 5636
#include <stdio.h>

#define rep(i, N) for (int i = 0; i < N; i++)

//int dxy[5] = {0, 1, 0, -1, 0};
// 01Trie BIT CHT DFT FFT avl cmd cusum dijkstra dinic geo2 gin graph kruskal lca lcm matrix ncm next_combination ppuf segtree st tmp topcoder uf vi 

//最大公約数
int gcd(int x, int y) { return y ? gcd(y, x%y) : x; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }

int ans[1000];
int ptr, a;

int solve(int p, int q, int denom, int max_denom, int n)
{
    if (!p || !n) return 0;
    int ret = 0;
    for (int i = max_denom; i * denom <= a; i++) {
        if (p * i < q) continue;
        //int tmp = lcm(i, q);
        int tmp = i * q;
        int s = p * (tmp/q) - tmp / i;
        ret += !s;
        ret += solve(s, tmp, denom * i, i, n-1);
    }
    return ret;
}

signed main()
{
    int p, q, n;
    while (1) {
        scanf("%d %d %d %d", &p, &q, &a, &n);
        if (!q) break;
        ans[ptr++] = solve(p, q, 1, 1, n);
    }

    for (int i = 0; i < ptr; i++) {
        printf("%d\n", ans[i]);
    }

    return 0;
}



Measured memory_bytes: 2040
n,m = gets.split.map(&:to_i)

a = []
m.times do |i|
  a[i] = gets.split.map(&:to_i)
end

l = []
r = []
m.times do |i|
  l << a[i][0]
  r << a[i][1]
end

lm = l.max
rm = r.min

puts ((rm-lm) >= 0) ? (rm-lm+1) : 0


Measured memory_bytes: 11284
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int a;
    string s;
    cin >> a >> s;
    if (a < 3200) cout << "red" << endl;
    else cout << s << endl;

    return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define X real()
#define Y imag()
#define all(r) (r).begin(),(r).end()
#define gsort(r) sort(all(r),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using comd = complex<double>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(all(v),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vary(int,v,5,0);
  rep(i,5) cin>>v[i];
  sort(all(v),greater<int>());
  rep(i,4)cout << v[i]<<" ";
  cout << v[4] << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int K, X; cin >> K >> X;
  for (int i=-1*(K-1); i<=K-1; i++) cout << X+i << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int) N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=(int) n;i--)
#define p(s) cout<<(s)<<endl
#define DEBUG(x,y) cout<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl;
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9;

int a[100010];
int four,two,one;
int main(){
	int N;
	cin>>N;
	REP(i,0,N){
		cin>>a[i];
		if(a[i]%4==0){
			four++;
		}else if(a[i]%2==0){
			two++;
		}else{
			one++;
		}
	}
	string ans="No";
	if(four-one+1>0){
		ans="Yes";
	}
	if(one-four==1&&two==0){
		ans="Yes";
	}
	p(ans);
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int x, a, b;
  cin >> x >> a >> b;
  int da = abs(x - a);
  int db = abs(x - b);
  if(da < db) cout << "A" << endl;
  else cout << "B" << endl;
}


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

  int main() {

    int K;
    string S;
    cin >> K;
    cin >> S;

    if (K >= S.size())
    {
      cout << S << endl;
    }
    else
    {
      for (int i; i < K; i++)
        {
          cout << S.at(i);
        }
      cout << "..." << endl;
    }
    
  }


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;


int main(){FIN
    
    ll a,b,k;cin>>a>>b>>k;
    ll gcd = __gcd(a,b);
    ll c=0;
    ll i = gcd;
    while(1){
        if(gcd%i==0){
            c++;
        }
        
        if(c==k) break;
        i--;
    }
    cout<<i<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

ll A, B, N;

ll f(ll x) {
    return (A * x) / B - A * (x / B);
}

int main() {
    cin >> A >> B >> N;

    cout << f(min(B - 1, N)) << endl;
    return 0;
}


Measured memory_bytes: 3640
#include "bits/stdc++.h"

using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ll long long
#define li long int
#define ld long double
#define lld long long double

#define pb push_back
#define mk make_pair
#define F first
#define S second

#define all(v) (v).begin(),(v).end()
#define fill(a) memset(a, 0, sizeof(a))

const int MX = 1e6;
const int MI = -1e6;
const int MOD = 1e9 + 7;
const string ALPHA = "abcdefghijklmnopqrstuvwxyz";
const double PI = 3.1415926535;

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

const int mod=1e9+7;
inline int add(int x,int y){
  x+=y;
  if (x>=mod) return x-mod;
  return x;
}
inline int sub(int x,int y){
  x-=y;
  if (x<0) return x+mod;
  return x;
}
inline int mul(int x,int y){
  return (x*1ll*y)%mod;
}
inline int power(int x,int y){
  int ans=1;
  while(y){
    if (y&1) ans=mul(ans,x);
    x=mul(x,x);
    y>>=1;
  }
  return ans;
}
inline int inv(int x){
  return power(x,mod-2);
}

int main()
{
  IOS;
  int n;
  cin >> n;
  ll ans=0;
  for (int i=1; i<=n; i++)
    {
      if (i%3==0 && i%5==0)
	continue;
      else if (i%3==0)
	continue;
      else if (i%5==0)
	continue;
      else
	ans+=i;
    }
  cout << ans << endl;	
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  
  vector<int> l(n);
  for(int i = 0; i < n; i++){
    cin >> l[i];
  }
  
  std::sort(l.begin(),l.end(),std::greater<int>());
  
  int c = 0;
  for(int i = 0; i < n-2; i++){
    for(int j = i + 1; j < n-1; j ++){
      for(int k = j + 1; k < n; k++){
        if(l[i] < l[j] + l[k]){
          c++;
        }
      }
    }
  }
  cout << c;   

  return 0;
}

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

int main() {
    int x;
    cin >> x;
    if(x == 7 or x == 5 or x == 3){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
	#define mes(a, b)  memset(a, b, sizeof a)
	#define pb push_back
	typedef unsigned long long int ull;
	typedef long long int ll;
	const int    maxn = 2e5 + 20;
	const int    maxm = 1e5 + 10;
	const ll     mod  = 1e9 + 7;
	const ll     INF  = 1e18 + 100;
	const ll    inf  = 1e9 + 10;
	const double pi   = acos(-1.0);
	const double eps  = 1e-8;
	using namespace std;
	int main(){
		string s;cin >> s;
		if(s == "ABC") puts("ARC");else puts("ABC");
	}

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

int main()
{
  ll x;
  cin >> x;
  ll i = 1;
  ll sum;
  while (1) {
    sum += i;
    i++;
    if (sum >= x) {
      cout << i - 1 << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
import sys
import math
from typing import Tuple
input = sys.stdin.readline

def  print_vec (A: list):
    print (" ".join(map (str, A)))

def swap (A, i, j):
    temp = A [i]
    A [i] = A [j]
    A [j] = temp
 

def bubble_sort(A: list) -> Tuple[list, int]:
    if len (A) <= 1:
        return (A, 0)
    swap_cout = 0
    for i in range(len(A)):
        for j in range(len(A) - 1, i + 1 - 1, -1):
            if A[j] < A[j - 1]:
                swap_cout += 1
                swap (A, j, j - 1)
    return (A, swap_cout)



if __name__ == "__main__":
    n = int(input())
    res = 0
    vec = list (map (int, input ().split ()))
    result=  bubble_sort(vec)
    print_vec (result [0])
    print(result [1])




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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    freopen ("in.txt", "r", stdin);
#endif
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
  //  freopen ("in.txt", "r", stdin);

    int n,m;cin>>n>>m;
    vii a(n);
    FOR(i,n) cin>>a[i].first>>a[i].second;
    sort(a.begin(),a.end(),[](const ii x,const ii y){return x.first<y.first || (x.first==y.first && x.second>y.second);});
    int t=m-1,i=0;
    vi stock;
    int ret=0;
    while(i<n && t>=0){
        if (t+a[i].first<=m)  {stock.push_back(a[i++].second); push_heap(stock.begin(),stock.end());}
        else{
            if (!stock.empty()){
                ret += stock.front();
                pop_heap(stock.begin(),stock.end());
                stock.pop_back();
            }
            --t;
        }
    }
    while(t>=0 && !stock.empty()){
        ret += stock.front();
        pop_heap(stock.begin(),stock.end());
        stock.pop_back();
        --t;
    }
    cout << ret;
}



Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
    ll x,a,b; cin>>x>>a>>b;
    cout<<(x-a)%b<<endl;
    return 0;
}

Measured memory_bytes: 256
import math

def suicide(x, h):
    r2 = (math.sqrt(2)*x*0.5)**2 + h**2
    t2 = r2 - (0.5*x)**2
    t = math.sqrt(t2)
    S = x*x + 4*(x*t*0.5)
    print S

import sys

x = 0
h = 0
for line in sys.stdin:
    if x == 0:
        x = int(line.rstrip())
    elif x:
        h = int(line.rstrip())
    if x  and h :
        suicide(x, h)
        x = 0
        h = 0

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

typedef long long int ll;
ll n, a[200007];
map<ll, ll> occ;

int main() {
    cin >> n;
    for(ll i = 1; i <= n; ++i) cin >> a[i];

    ll ans = 0;
    for(ll i = 1; i <= n; ++i) {
        if(occ[i - a[i]] > 0) ans += occ[i - a[i]];
        occ[i + a[i]]++;
    }

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

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

int main() {
  ll N,M;
  cin>>N>>M;
  vector<ll> A(N);
  rep(i,N){
      cin>>A.at(i);
  }
  sort(A.begin(),A.end());
  ll l=0,r=1e9,m;
  while(r-l>1){
      m=(r+l)/2;
      ll count=0;
      rep(i,N){
          count+=A.end()-lower_bound(A.begin(),A.end(),m-A.at(i));
      }
      if(count>M){
          l=m;
      }
      else{r=m;}
  }
  vector<ll> B(N+1);
  B.at(N)=0;
  B.at(N-1)=A.at(N-1);
  rep(i,N-1){
      B.at(N-2-i)=B.at(N-1-i)+A.at(N-2-i);
  }

  /*test
  cout<<r<<endl;
  rep(i,N){
      cout<<A.at(i)<<" ";
  }
  cout<<endl;
  rep(i,N+1){
      cout<<B.at(i)<<" ";
  }
  cout<<endl;*/

  ll ans=0,num=0,sum=0;
  rep(i,N){
      //cout<<lower_bound(A.begin(),A.end(),r-A.at(i))-A.begin()<<endl;
      num=lower_bound(A.begin(),A.end(),r-A.at(i))-A.begin();
      ans+=B.at(num)+(N-num)*A.at(i);
      sum+=N-num;
  }
  ans+=(M-sum)*(r-1);

  cout<<ans<<endl;
}

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

using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i, a, b) for(ll i=a;i<b;i++)
#define REP(i, a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i, a) for(ll i=a;i>0;i--)
#define rrep(i, a, b) for(ll i=a-1;i>=b;i--)
#define printall(n, array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
typedef vector<vector<ll>> VVE;
const ll mod = 1e9 + 7; //10^9+7

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    ll big = max(a, b);
    ll small = min(a, b);
    if(big > c && small < c){
        print("Yes");
    }else{
        print("No");
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  long long int cou[4000]={0},b[4000],c[4000];
  int date,to,i,j,a[4000]={0};
  while(1){
    scanf("%d",&date);
    if(date == 0) break;
    for(i=0;i<date;i++){
      scanf("%d %lld %lld",&a[i],&b[i],&c[i]);
      cou[i] = b[i]*c[i];
      for(j=0;j<i;j++){
	if(a[i] == a[j]){
	  cou[j] = cou[i] + cou[j];
	  cou[i] = 0;
	}
      }
    }
    to = 0;
    for(i=0;i<date;i++){ 
      if(cou[i]>=1000000){
	printf("%d\n",a[i]);
	to++;
      }
    }
    if(to == 0){
      printf("NA\n");
    }
  } 
  return 0;
}

Measured memory_bytes: 688
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
  int n,i;
  long double t=1,a=1,tt,aa,k;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> tt >> aa;
    k=max(ceil(t/tt),ceil(a/aa));
    t=k*tt;
    a=k*aa;
  }
  cout << (long long)(t+a) << endl;
  return 0;
}

Measured memory_bytes: 256
k=int(input())
n=len(input())
mod=10**9+7

def prepare(m, mod=10 ** 9 + 7):
	fac = [1] * (m + 1)
	inv = [1] * (m + 1)
	for i in range(1, m + 1):
		fac[i] = fac[i - 1] * i % mod
	inv[-1] = pow(fac[-1], mod - 2, mod)
	for i in range(m - 1, -1, -1):
		inv[i] = inv[i + 1] * (i + 1) % mod
	return fac, inv

fac, inv = prepare(n+k)

def cmb(n, r):
	assert n >= r >= 0
	return fac[n] * inv[n - r] * inv[r] % mod

ans=0
for i in range(0,k+1):
	ans+=pow(25,k-i,mod)*pow(26,i,mod)%mod*cmb(n+k-i-1,k-i)%mod
	ans%=mod
print(ans)

Measured memory_bytes: 107008
#include <iostream>
#include <vector>
#include <string>

using namespace std;

void trace(int A[], int N)
{
    int i;
    for (i = 0; i < N; i++)
    {
        if (i > 0)
            cout << " ";
        cout << A[i] ;
    }
    cout << endl;
}


void bubbleSort(int A[], int N,int *c)
{
    // N 個の要素を含む 0-オリジンの配列 A
    bool flag = true; // 逆の隣接要素が存在する
    while (flag)
    {
        flag = false;
        for (int j = N - 1; j > 0; j--)
        { // j が N-1 から 1 まで
        if (A[j] < A[j - 1]) {
				(*c)++;
                int v = A[j];
                A[j] = A[j - 1];
                A[j - 1] = v;
                //         A[j] と A[j-1] を交換
                flag = 1;
            }
        }
    }
}
int main()
{
    int A[100], N,c;
    cin >> N;

    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
c=0;
	bubbleSort(A,N,&c);
    trace(A,N);
cout << c << endl;
}



Measured memory_bytes: 3080