akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
using namespace std;
const int INF=1000000;
typedef pair<int,int> p;

int H,W,d[55][55];
char s[55][55];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int bfs() {
  for (int i=0; i<55; i++) {
    for (int j=0; j<55; j++) {
      d[i][j]=INF;
    }
  }
  d[1][1]=1;
  queue<p> Q;
  Q.push(p(1,1));
  while (!Q.empty()) {
    p po=Q.front();
    Q.pop();
    if (po.first==H && po.second==W) {
      break;
    }
    for (int i=0; i<4; i++) {
      int nx=po.first+dx[i];
      int ny=po.second+dy[i];
      if (nx>0 && nx<=H && ny>0 && ny<=W && d[nx][ny]==INF && s[nx][ny]!='#') {
        d[nx][ny]=d[po.first][po.second]+1;
        Q.push(p(nx,ny));
      }
    }
  }
  return d[H][W];
}
int main() {
  cin >> H >> W;
  int cnt=0;
  for (int i=1; i<=H; i++) {
    for (int j=1; j<=W; j++) {
      cin >> s[i][j];
      if(s[i][j]=='.') {
        cnt++;
      }
    }
  }
  int distance=bfs();
  if (distance==INF) {
    cout << -1 << endl;
  } else {
    cout << cnt-distance << endl;
  }
  return 0;
}



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

using namespace std;

int f(int);
int integral(int);

int main(void) {
	int a, b;

	while(cin >> a >> b) {
		cout << integral(a) << endl; 
		cout << integral(b) << endl;
	}
	return 0;
}
int integral(int d){
	int n = 600 / d;
	int sum = 0;

	for (int i = 1; i < n; i++) {
		sum = sum + f(d * i) * d;
	}

	return sum;
}

int f(int a) {
	return a * a;
}

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

using namespace std;

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

#define ck(x,a,b) (a<=x&&x<b)

inline bool inrange(int x, int y, int z) {
  return ck(x,0,5) && ck(y,0,5) && ck(z,0,5);
}

int main() {
  
  for(int N, Tcnt=1; cin >> N && N; Tcnt++) {
    vector<vector<vector<int> > > curr(5, vector<vector<int> >(5, vector<int>(5)));
    rep(z, 5) rep(y, 5) rep(x, 5) {
      char ch; cin >> ch;
      curr[z][y][x] = ch-'0';
    }
    
    int M1; cin >> M1; vector<int> a(M1);
    rep(i, M1) cin >> a[i];
    int M2; cin >> M2; vector<int> b(M2);
    rep(i, M2) cin >> b[i];
    
    rep(n, N) {
      vector<vector<vector<int> > > next(5, vector<vector<int> >(5, vector<int>(5)));
      rep(z, 5) rep(y, 5) rep(x, 5) {
        int cnt = 0;
        REP(dz,-1,2) REP(dy,-1,2) REP(dx,-1,2) {
          int nx = x+dx, ny = y+dy, nz = z+dz;
          if(dx == 0 && dy == 0 && dz == 0) { continue; }
          if(!inrange(nx, ny, nz)) { continue; }
          cnt += curr[nz][ny][nx];
        }
        
        if(!curr[z][y][x]) {
          bool ok = 0;
          rep(I, M1) if(a[I] == cnt) { ok = 1; break; }
          if(ok) { next[z][y][x] = 1; }
        }
        
        if(curr[z][y][x]) {
          bool ok = 0;
          rep(I, M2) if(b[I] == cnt) { ok = 1; break; }
          if(ok) { next[z][y][x] = 1; }
        }
      }
      curr = next;
    }
    
    if(Tcnt>1) cout << "\n";
    cout << "Case " << Tcnt << ":";
    rep(z, 5) {
      cout << endl;
      rep(y, 5) {
        rep(x, 5) cout << curr[z][y][x];
        cout << endl;
      }
    }
  }
  
  return 0;
}

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<int>());
    if (s.length() != t.length()) {
        int diff = s.length() - t.length();
        REP(i, abs(diff)) {
            if (diff > 0) {
                t += 'a' - 1;
            } else {
                s += 'a' - 1;
            }
        }
    }
    bool ok = false;
    REP(i, s.length()) {
        if (s[i] != t[i]) {
            int diff = s[i] - t[i];
            if (diff > 0) {
                ok = false;
                break;
            } else {
                ok = true;
                break;
            }
        }
    }
    if (ok) {
        print("Yes");
    } else {
        print("No");
    }

}

signed main() {
    solve();
}


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

int main(){
	int N;
	cin >> N;
	int a[N];
	for(int i = 0; i < N; i++) cin >> a[i];
	int res = 0;
	for(int i = 0; i < N; i++){
		while(a[i]%2==0){
			res++;
			a[i] /= 2;
		}
	}
	cout << res << endl;
}


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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N, Q;
vector<tuple<ll, ll, ll>> tup;
set<ll> now;

int main() {
    cin >> N >> Q;
    REP(i, N) {
        LCIN(S, T, X);
        tup.emplace_back(S - X, 1, X);
        tup.emplace_back(T - X, 0, X);
    }
    sort(All(tup));
    auto itr = tup.begin();
    REP(i, Q) {
        LCIN(D);
        while(get<0>(*itr) <= D && itr != tup.end()) {
            if(get<1>(*itr)) {
                now.insert(get<2>(*itr));
            } else {
                now.erase(get<2>(*itr));
            }
            itr++;
        }
        cout << (!now.empty() ? *now.begin() : -1) << "\n";
    }
    return 0;
}

Measured memory_bytes: 20712
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};



int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0) break;
		vi a(n),b(m);
		for(int i=0;i<n;i++) cin>>a[i];
		for(int i=0;i<m;i++) cin>>b[i];
		P p={inf,inf};
		for(int i=0;i<n;i++) for(int j=0;j<m;j++){
			swap(a[i],b[j]);
			int t=0;
			for(int k=0;k<n;k++) t+=a[k];
			for(int k=0;k<m;k++) t-=b[k];
			if(t==0&&a[i]+b[j]<p.first+p.second) p={a[i],b[j]};
			swap(a[i],b[j]);
		}
		if(p.first==inf) cout<<-1<<endl;
		else cout<<p.second<<' '<<p.first<<endl;
	}
}


Measured memory_bytes: 3040
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
#define MAX 55
vector<ll> a(MAX),b(MAX),c(MAX),d(MAX);
ll n,m,q,ans=0;
void solve(ll i,ll v,vector<ll> lst){
  if(i==n){
    ll tmp = 0;
    for(int j=0;j<q;j++){
      if(lst[b[j]]-lst[a[j]]==c[j]){
        tmp += d[j];
      }
    }
    ans = max(tmp,ans);
    return;
  }
  for(int j=v;j<=m;j++){
    lst[i] = j;
    solve(i+1,j,lst);
  }
}
signed main(){
  init_io();
  cin >> n >> m >> q;
  for(int i=0;i<q;i++){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    b[i]--;
    a[i]--;
  }
  solve(0,1,vector<ll>(n));
  cout << ans << endl;
}


Measured memory_bytes: 3660
#include<iostream>
#include<vector>
#include<utility>

using namespace std;

#define NMAX 100
#define NOT -1

struct mini{
	int fr,to,cost;
};


int main(){

	int n,m;
	int a,b,d;
	char gav;
	int e[NMAX][NMAX];
	bool use[NMAX];
	int cost;
	mini min;

	while(1){

		cin>>n;
		if(n==0) break;
		cin>>m;

		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				e[i][j]=NOT;
			}
		}

		for(int i=0;i<m;i++){
			cin>>a>>gav>>b>>gav>>d;
			e[a][b]=d;
			e[b][a]=d;
		}

		for(int i=0;i<n;i++) use[i]=false;
		use[0]=true;
		cost=0;

		while(1){
			min.fr=NOT,min.to=NOT,min.cost=NOT;
			for(int i=0;i<n;i++){
				if(use[i]==true){
					for(int j=0;j<n;j++){
						if(use[j]==false){
							if(e[i][j]!=NOT){
								if(min.fr==NOT||min.cost>e[i][j]) min.fr=i,min.to=j,min.cost=e[i][j];
							}
						}
					}
				}
			}
			if(min.fr==NOT) break;
			use[min.to]=true;
			cost+=(min.cost)/100-1;
		}
		cout<<cost<<endl;
	}
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;

int main()
 {
 	int n,m,i,s=0;
 	cin>>n>>m;
 	int a[m];
 	for(i=0;i<m;i++)
 		cin>>a[i];
 	for(i=0;i<m;i++)
 		s=s+a[i];
 	if(n>=s)
	 	cout<<n-s<<endl;
	else
		cout<<"-1"<<endl;
			
 	return 0;
 }

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

using namespace std;
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define freopen(x) freopen(x".in", "r", stdin);freopen(x".out", "w", stdout)
#define var register int

const int N = 3001;
const int fx[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

int n, m;
char s[N];
bool mark[N][N];
int have[N][N][4];

int read();

int main() {
	n = read(), m = read();
	for (var i = 1; i <= n; ++i) {
		scanf("%s", s + 1);
		for (var j = 1; j <= m; ++j) mark[i][j] = s[j] == '#';
	}
	for (var i = 1; i <= n; ++i) {
		for (var j = 1; j <= m; ++j) {
      if (mark[i][j]) continue;
      have[i][j][0] = have[i][j - 1][0] + 1;
    }
	}
	for (var i = 1; i <= n; ++i) {
    for (var j = m; j >= 1; --j) {
      if (mark[i][j]) continue;
      have[i][j][1] = have[i][j + 1][1] + 1;
    }
	}
  for (var j = m; j >= 1; --j) {
    for (var i = n; i >= 1; --i) {
      if (mark[i][j]) continue;
      have[i][j][2] = have[i + 1][j][2] + 1;
    }
  }
  for (var j = 1; j <= m; ++j) {
		for (var i = 1; i <= n; ++i) {
      if (mark[i][j]) continue;
      have[i][j][3] = have[i - 1][j][3] + 1;
    }
  }

/*
	for (var i = 1; i <= n; ++i) {
		for (var j = 1; j <= m; ++j) printf("%d", have[i][j][0]);
		printf("\n");
	}
		printf("\n");
	for (var i = 1; i <= n; ++i) {
		for (var j = 1; j <= m; ++j) printf("%d", have[i][j][1]);
		printf("\n");
	}
		printf("\n");
	for (var i = 1; i <= n; ++i) {
		for (var j = 1; j <= m; ++j) printf("%d", have[i][j][2]);
		printf("\n");
	}
		printf("\n");
	for (var i = 1; i <= n; ++i) {
		for (var j = 1; j <= m; ++j) printf("%d", have[i][j][3]);
		printf("\n");
	}
		printf("\n");
		*/

  int res = 0;
	for (var i = 1; i <= n; ++i) {
		for (var j = 1; j <= m; ++j) {
      int sum = 0;
      for (var k = 0; k < 4; ++k) sum += have[i][j][k];
      res = max(res, sum);
    }
  }
	cout << res - 3 << endl;
  return 0;
}

int read() {
  int a = 0, c = 0, s = 0;
  while (!isdigit(c = getchar())) s |= c == '-';
  while (isdigit(c)) a = a * 10 + c - 48, c = getchar();
	return s ? -a : a;
}


Measured memory_bytes: 102144
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
ll ketawa(ll a){ll r=0;while(a){r+=a%10;a/=10;}return r;}



int main(){

  ll A,B;
  cin >> A >> B;

  ll X = gcd_(A,B);
  ll ans = 1;

  ll Y = X;
  for(ll i=2;i*i<=X;i++){
    if(Y%i==0)ans++;
    while(Y%i==0)Y/=i;
  }
  if(Y!=1)ans++;
  cout << ans << endl;

}




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

vvl G;
vl ans;

void dfs(ll v, ll p = -1) {
    // 行きの処理はこのへんに書く
    for(auto u : G[v]) {
        if(u == p) {
            continue;
        }
        ans[u] += ans[v];
        dfs(u, v);
        // 帰りの処理はこのへんに書く
    }
}

int main() {
    ll n, q;
    cin >> n >> q;    

    G.resize(n);
    rep(i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
        G[b].pb(a);
    }

    ans.resize(n);
    rep(i, q) {
        ll p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }

    const ll root = 0;
    dfs(root);

    rep(i, n) {
        cout << ans[i] << " ";
    }

    cout << endl;
    re0;
}

Measured memory_bytes: 24320
n, k = map(int, input().split())
a = list(map(int, input().split()))
x=bin(k)[2:]

ans=0
flag=True

for i in range(50):
    count=0
    for j in range(n):
        if (a[j]>>(50-i-1))&1==1:
            count+=1

    if 50-i-1>len(x)-1:
        ans+=2**(50-i-1)*count

    elif not flag:
        ans+=2**(50-i-1)*max(count, n-count)
    else:
        if 2*count>=n:
            if int(x[-(50 - i)]) == 1:
                ans+=2**(50-i-1)*count
                flag=False
            else:
                ans += 2 ** (50 - i - 1) * count
        
        else:
            if int(x[-(50-i)])==1:
                ans+=2**(50-i-1)*(n-count)
            else:
                ans+=2**(50-i-1)*count
print(ans)


Measured memory_bytes: 14620
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    int N;
    cin >> N;
    vector<int> times(N);
    for (int i = 0; i < N; ++i) cin >> times[i];
    int M;
    cin >> M;
    vector<pair<int, int>> pairs(M);
    for (int i = 0; i < M; ++i)
    {
        int Pi, Xi;
        cin >> Pi >> Xi;
        pairs[i] = { Pi, Xi };
    }
    int sum = accumulate(times.begin(), times.end(), 0);
    for (const auto &pair : pairs)
    {
        int index = pair.first - 1;
        cout << sum - times[index] + pair.second << endl;
    }

    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> isPair;
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
#define Pll pair<ll,ll>
#define vpll vector<pll>
#define sll set<ll>
#define mll map<ll,ll>

const ll oo=1e18;
const ll maxs = 3e5+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
#define mp make_pair
#define I insert
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define LB lower_bound
#define UB upper_bound
#define line() cout<<endl;
#define fr(i,a,b) for(int i=a;i<=b;++i)
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fastio(); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mst(x,a) memset(x,a,sizeof(x))

int main() 
{
    fastio();
	ll t=1;
    //cin>>t;
    while(t--){
        ll n,r;
        cin>>n>>r;
        if(n>=10){
            cout << r;
            continue;
        }
        else
        {
            ll val = r + 100*(10-n);
            cout << val ;
        }
    }  
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define T int
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
auto clk=clock();
 
ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}

const int N = 200005;

int a[N];

int main(){
    IOS
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int n;
    cin >> n;
    FOR(i,1,n){
        cin >> a[i];
        a[i] -= i;
    }
    sort(a + 1, a + n + 1);
    ll ans = 0;
    FOR(i,1,n){
        ans += abs(a[i] - a[(n+1)/2]);
    }
    cout << ans;

    cerr<<endl<<endl<<"Time: "<<fixed<<setprecision(12)<<(long double)(clock()-clk)/CLOCKS_PER_SEC<<" ms"<<endl<<endl;
 
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> v(n), p(n), q(n);
    for(int i=0;i<n;++i) v[i] = i+1;
    for(int i=0;i<n;++i) cin >> p[i];
    for(int i=0;i<n;++i) cin >> q[i];

    int kp = -1, kq = -1, k = 0;
    do {
        bool are_same = true;
        if(kp == -1) {
            for(int i=0;i<n;++i) {
                if(v[i] != p[i]) {
                    are_same = false;
                    break;
                }
            }
            if(are_same) {
                kp = k;
            }
        }
        if(kq == -1) {
            are_same = true;
            for(int i=0;i<n;++i) {
                if(v[i] != q[i]) {
                    are_same = false;
                    break;
                }
            }
            if(are_same) {
                kq = k;
            }
        }
        ++k;
    } while(next_permutation(v.begin(), v.end()));
    cout << abs(kp-kq) << endl;
}


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

int main() {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if ((w-r) >= x && (x-r) >= 0 && (h-r) >= y && (y-r) >=0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3116
n,a,b = input().strip().split()
n,a,b = [int(n),int(a),int(b)]
sum = 0

for i in range(1,n+1):
    if a<=(i//10000 + i//1000%10 + i//100%10 + i//10%10 + i%10)<=b:
        sum += i
print(sum)


Measured memory_bytes: 3060
fn main() {
    let r = read::<u32>();
    println!("{}", r * r);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう！

bool IsPrime(ll num)//素数
{
    if (num < 2ll) return false;
    else if (num == 2ll) return true;
    else if (num % 2ll == 0ll) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (ll i = 3ll; i <= sqrtNum; i += 2ll)
    {
        if (num % i == 0ll)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(){
    int q;
    std::cin >> q;
    std::vector<int> p(100010);
    int n=100010;
    rep(i,100010){
        if(i%2==0)continue;
        if(IsPrime(i)&&IsPrime((i+1)/2))p[i]=1;
    }
    rep(i,n-1){
        p[i+1]=p[i]+p[i+1];
    }
    rep(i,q){
        int l,r;
        std::cin >> l>>r;
        std::cout << p[r]-p[l-1] << std::endl;
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int h[100010];
int dp[100010];
int main(){ _;
  int n,k;cin>>n>>k;
  REP(i,n)cin>>h[i];
  dp[0]=0;
  for(int i=1;i<n;i++){
    dp[i]=1e+9;
    for(int j=max(0,i-k);j<i;j++){
      dp[i]=min(dp[i],dp[j]+abs(h[j]-h[i]));
    }
  }
  cout<<dp[n-1]<<endl;
}


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

int main()
{
	string s;
	cin >> s;
	if(s == "ABC") cout << "ARC";
	else cout << "ABC";
}


Measured memory_bytes: 3624
import java.util.*;

class Card {
    int num;
    char color;
}

public class Main extends Card {
    static boolean solve(Card[] card) {
        if(card.length == 3) {
            if(!(card[0].color == card[1].color && card[1].color == card[2].color)) return false;
            if(card[0].num == card[1].num && card[1].num == card[2].num) return true;
            Arrays.sort(card, (a, b)-> a.num - b.num);
            if(card[0].num + 1 == card[1].num && card[1].num + 1 == card[2].num) return true;
            return false;
        } else if(card.length == 6 || card.length == 9) {
            int S = card.length;
            for(int i = 0; i < S-2; i++) {
                for(int j = i+1; j < S-1; j++) {
                    for(int k = j+1; k < S; k++) {
                        Card[] card1 = new Card[3];
                        for(int l = 0; l < 3; l++) {
                            card1[l] = new Card();
                        }
                        card1[0] = card[i];
                        card1[1] = card[j];
                        card1[2] = card[k];
                        if(solve(card1)) {
                            int count = 0;
                            Card[] card2 = new Card[S-3];
                            for(int l = 0; l < S; l++) {
                                if(l != i && l != j && l != k) {
                                    card2[count] = new Card();
                                    card2[count] = card[l];
                                    count++;
                                }
                            }
                            if(solve(card2)) return true;
                        }
                    }
                }
            }
            return false;
        } else {
            return false;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i = 0; i < n; i++) {
            Card[] card = new Card[9];
            for(int j = 0; j < 9; j++) {
                card[j] = new Card();
                card[j].num = sc.nextInt(); 
            }
            for(int j = 0; j < 9; j++) {
                card[j].color = sc.next().charAt(0);
            }

            if(solve(card)) System.out.println(1);
            else System.out.println(0);
        }
    }
}


Measured memory_bytes: 33212
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    ll n,k;
    cin >> n >> k;
    ll res=0;
    for(ll i=k+1;i<=n;i++){
        res += (i-k)*(n/i)+(max(0LL,n%i-k+1*ll(k!=0)));
        DEBUG{cout << res << endl;}
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int calc(int n,int x){
    return n*(100+x)/100;
}

void run(){
    int x,y,s;
    cin>>x>>y>>s;
    if(!x)return;
    int ans=0;
    REP(i,1,s){
        REP(j,1,s){
            if(calc(i,x)+calc(j,x)==s)
                ans=max(ans,calc(i,y)+calc(j,y));
        }
    }
    cout<<ans<<endl;
    run();
}


Measured memory_bytes: 3192
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#define RG register
#define LL long long
using namespace std;
LL n,s,anss=3e18;
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
template<typename I>inline I mi(const I&a,const I&b){return a<b ? a : b;}
template<typename I>inline I f(I bb,I nn){
	I ans=0;
	for(;nn;nn/=bb) ans+=nn%bb;
	return ans;
}
int main()
{
	//freopen("Digit Sum.in","r",stdin);
	read(n,s);
	if(n==s) return printf("%lld\n",n+1), 0;
	if(n<s) return printf("-1\n"), 0;
	for(RG LL i=2;i<=sqrt(n);i++) if(f(i,n)==s) return printf("%lld\n",i), 0;
	for(RG LL i=1;i*i<=n-s;i++)
	 if((n-s)%i==0)
	 {
		LL b=(n-s)/i+1;
		if(f(b,n)==s) anss=mi(anss,b);
	 }
	printf("%lld\n",anss==3e18 ? -1 : anss);
	return 0;
}

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

int main(){

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);


    ll h;
    cin >> h;
    if(h==0){
    	cout << 0 << endl;
    }
    else{
    	ll ans = log2(h);
	    ans++;
	    ll res = 1;
	   	for(ll i=0;i<ans;++i){
	   		res*=2;
	   	}
	   	res--;
	   	cout << res << endl;
    }
    


    

	return 0;
}

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

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

int main() {
	int a[3], b[3], i,j,map[3][3];
	rep(i, 3) {
		rep(j, 3) {
			cin >> map[i][j];
		}
	}
	rep(i, 3) {
		while (min(map[i][0], min(map[i][1], map[i][2])) >= 1) {
			map[i][0]--;
			map[i][1]--;
			map[i][2]--;
		}
	}
	rep(i, 3) {
		while (min(map[0][i], min(map[1][i], map[2][i])) >= 1) {
			map[0][i]--;
			map[1][i]--;
			map[2][i]--;
		}
	}
	rep(i, 3) {
		rep(j, 3) {
			if (map[i][j] != 0) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

vector<bool> make_primes(int n) {
	vector<bool> is_prime(n, true);
	is_prime[0] = false;
	is_prime[1] = false;
	for (int i = 2; i < n; ++i) {
		for (int j = i * 2; j < n; j += i) {
			is_prime[j] = false;
		}
	}
	return is_prime;
}

bool is_like_2017[100001];
int sum[100002];

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

	vector<bool> is_prime = make_primes(100001);

	for (int i = 0; i <= 100000; ++i) {
		is_like_2017[i] = is_prime[i] && is_prime[(i + 1) / 2];
	}

	sum[0] = 0;
	for (int i = 0; i <= 100000; ++i) {
		sum[i + 1] = sum[i];
		if (is_like_2017[i]) {
			sum[i + 1]++;
		}
	}

	for (int i = 0; i < n;  ++i) {
		int l, r;
		cin >> l >> r;

		cout << sum[r + 1] - sum[l] << endl;
	}

	return 0;
}

Measured memory_bytes: 1152
#include <algorithm>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n, q;
  while (cin >> n >> q) {
    if (n == 0 && q == 0) break;
    map<string, pair<int, int>> mp;
    rep(i, n) {
      string s;
      int a, b;
      cin >> s >> a >> b;
      if (mp.count(s)) {
        int right = mp[s].second;
        if (right < b) {
          mp[s] = make_pair(mp[s].first, right);
        }
      } else {
        mp[s] = make_pair(b - a + 1, b);
      }
    }
    while (q--) {
      int c;
      cin >> c;
      bool flag = true;
      for (auto x : mp) {
        if (x.second.first <= c && c <= x.second.second) {
          cout << x.first << ' ' << c - x.second.first + 1 << endl;
          flag = false;
          break;
        }
      }
      if (flag) cout << "Unknown" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3272
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<double,double>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// Look at me please ... that's what she said
#define MOD 1000000007
using namespace std;
const int INF = 1e6 + 9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); ///activate when submit
    ll n;
    cin>>n;
    vector<pii> points;
    cout<<fixed<<setprecision(8);
    double fact=1;
    for(int i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        points.push_back({a,b});
        fact*=i+1;
    }
    vector<int> ind;
    for(int i=0;i<n;i++)ind.push_back(i);
    double calc=0;
    do{
        for(int i=0;i<(int)ind.size()-1;i++){
            calc+=sqrt((points[ind[i+1]].first-points[ind[i]].first)*(points[ind[i+1]].first-points[ind[i]].first)+(points[ind[i+1]].second-points[ind[i]].second)*(points[ind[i+1]].second-points[ind[i]].second));
        }
    } while(next_permutation(ind.begin(),ind.end()));
    cout<<calc/fact<<"\n"; 
    return 0;
}    

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int N, M;
    cin >> N >> M;
    vector<pair<ll, ll>> students(N), points(M);
    REP(i, N) cin >> students[i].first >> students[i].second;
    REP(i, M) cin >> points[i].first >> points[i].second;
    
    // calculation
    long min_idx;
    pair<ll , ll> stu, point;
    vector<ll> man(M);
    REP(i, N) {
        stu = students[i];
        REP(j, M) {
            point = points[j];
            man[j] = abs(stu.first - point.first) + abs(stu.second - point.second);
        }
        cout << IDX(man, MIN(man)) + 1 << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;

int main(void) {
	string S;
	cin >> S;
	int ans = 1000;
	for (int i = 0; i < S.length() - 2; i++) {
		int num = atoi(S.substr(i, 3).c_str());
		// cout << num << "\n";
		ans = min(ans, abs(num - 753));
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3696
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s = r.readLine();
    String sl[] = s.split(" ");
    
    int a = Integer.parseInt(sl[0]);
    int b = Integer.parseInt(sl[1]);
    
    System.out.println((a * b) % 2 == 0 ? "No" : "Yes");
  }

}


Measured memory_bytes: 23252
#pragma GCC optimize(3) 
#include <cstdio>
const int N = 2010;
const int mod = 1e9 + 7;
int n, k, fac[N * N], inv[N * N], f[N][N];
inline int C(int x, int y) {
	return 1ll * fac[x] * inv[y] % mod * inv[x - y] % mod;
}
int main() {
	scanf("%d%d", &n, &k);
	if (k == 1) {
		puts("1");
		return 0;
	}
	fac[0] = fac[1] = 1; for (int i = 2; i <= n * k; ++ i) fac[i] = 1ll * fac[i - 1] * i % mod;
	inv[0] = inv[1] = 1; for (int i = 2; i <= n * k; ++ i) inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
	for (int i = 2; i <= n * k; ++ i) inv[i] = 1ll * inv[i] * inv[i - 1] % mod;
	for (int i = 0; i <= n; ++ i) f[i][0] = 1;
	for (int i = 1; i <= n; ++ i)
		for (int j = 1; j <= i; ++ j) {
			f[i][j] = (f[i - 1][j] + (1ll * f[i][j - 1] * (n - j + 1) % mod * C(n - i + (n - j + 1) * (k - 1) - 1, k - 2) % mod)) % mod;
		}
	printf("%d\n", f[n][n]);
	return 0;
}

Measured memory_bytes: 46464
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
struct myhash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef pair<string,ll> psl;
typedef vector<psl> vpsl;
typedef vector<int> vi;

#define fur(i,a,b) for(ll (i)=(a);i<(b);++(i))
#define revf(i,a,b) for(ll (i)=(a)-1;(i)>=(b);--(i))
#define mp make_pair
#define mod 1000000007
#define inf 2000000007
#define pb push_back
#define eps 1e-5
#define X first
#define Y second


ll modpow(ll base, ll exp, ll modulus) {
  base %= modulus;
  ll result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}

ll modinv(ll a, ll m) { 
    ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) 
      return 0; 
    while (a > 1) 
    { 
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    } 
    if (x < 0)
       x += m0;
    return x;
}


int main(){
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
  ll n,x;
  cin>>n>>x;
  vll l(n);
  fur(i,0,n)cin>>l[i];
  vll d(n+1,0);
  ll ans=1;

  fur(i,1,n+1){
    d[i]=d[i-1]+l[i-1];
    if(d[i]<=x)ans++;
  }
  cout<<ans;


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
//#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
int power(int x, unsigned int y)
{
    int res = 1;

    x = x;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x);

        y = y>>1;
        x = (x*x);
    }
    return res;
}
bool isprime(int x)
{
      if(x<2)
        return false;
    for(int i=2;i*i<=x;i++)
     {
        if (x%i==0)
            return false;
    }
    return true;
}
vector<int>primeFactors(int n)
{
    vector<int>v;
    int x=0;
    while (n % 2 == 0)
    {
        x++;
        n = n/2;
        v.pb(2);
    }
    //if(x>0)
    //v.pb({2,x});
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        int y=0;
        while (n % i == 0)
        {
            y++;
            n = n/i;
            v.pb(i);
        }
        //if(y>0)
        //v.pb({i,y});
    }
    if (n > 2)
        v.pb(n);
    return v;
}

vector<int>leastPrimeFactor(int n)
{
    vector<int>least_prime(n);
    // Create a vector to store least primes.
    // Initialize all entries as 0.
    // We need to print 1 for 1.
    least_prime[1] = 1;

    for (int i = 2; i <= n; i++)
    {
        // least_prime[i] == 0
        // means it i is prime
        if (least_prime[i] == 0)
        {
            // marking the prime number
            // as its own lpf
            least_prime[i] = i;

            // mark it as a divisor for all its
            // multiples if not already marked
            for (int j = 2*i; j <= n; j += i)
                if (least_prime[j] == 0)
                   least_prime[j] = i;
        }
    }
    return least_prime;
}
int maxSubArraySum(int a[], int size)
{
    int max_so_far = INT_MIN, max_ending_here = 0;

    for (int i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
void solve()
{
int n;
cin>>n;
cout<<n*(n*n+n+1)<<endl;

}
signed main()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
//cin>>t;
t=1;
while(t--)
{
solve();
}
}



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

int main(void){
   int W,H,N;
   cin>>W>>H>>N;
   vector<int> x(N),y(N),a(N);
   for(int i=0;i<N;i++){
      cin>>x[i]>>y[i]>>a[i];
   }
   vector<vector<bool>> ans(W,vector<bool>(H));
   for(int i=0;i<W;i++){
      for(int j=0;j<H;j++){
         ans[i][j]=false;
      }
   }
   for(int i=0;i<N;i++){
      if(a[i]==1){
         for(int j=0;j<x[i];j++){
            for(int k=0;k<H;k++){
               ans[j][k]=true;
            }
         }
      }
      if(a[i]==2){
         for(int j=x[i];j<W;j++){
            for(int k=0;k<H;k++){
               ans[j][k]=true;
            }
         }
      }
      if(a[i]==3){
         for(int j=0;j<W;j++){
            for(int k=0;k<y[i];k++){
               ans[j][k]=true;
            }
         }
      }
      if(a[i]==4){
         for(int j=0;j<W;j++){
            for(int k=y[i];k<H;k++){
               ans[j][k]=true;
            }
         }
      }
   }
   int result=0;
   for(int i=0;i<W;i++){
      for(int j=0;j<H;j++){
         if(ans[i][j]==false) result++;
      }
   }
   cout<<result<<endl;
   return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#define int long long
#define lowbit(x) (x &(-x))
#define me(ar) memset(ar, 0, sizeof ar)
#define mem(ar,num) memset(ar, num, sizeof ar)
#define rp(i, n) for(int i = 0, i < n; i ++)
#define rep(i, a, n) for(int i = a; i <= n; i ++)
#define pre(i, n, a) for(int i = n; i >= a; i --)
#define IOS ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
const int way[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const int  INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double EXP = 1e-8;
const ll   MOD = 1e9 + 7;
const int  N = 2e5 + 5;
int a, b, a1, a2, b1, b2, ans;
signed main()
{
    IOS;
    cin >> a >> b;
    a1 = a / 0.08; a2 = (a + 1) / 0.08 + 1;
    b1 = b * 10; b2 = (b + 1) * 10 + 1;
    a1 = max(a1, b1); b1 = min(a2, b2);
    for(int i = a1; i < b1; i ++){
        a2 = i * 0.08;
        b2 = i * 0.1;
        if(a2 == a && b2 == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <limits.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>

using namespace std;

int main(int argc, char* argv[]){
  int x,y,z;
  cin >> x >> y >> z;
  if (x<(2 * z + y)){
    cout << 0 << endl;
  }else{
    cout << int((x-y-z*2)/(y+z)) + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
/* BABA JAGAAAAAA  */  

#include<bits/stdc++.h>
#define pb push_back
#define un unordered_map
#define us unordered_set
#define ll long long
#define fast ios:: sync_with_stdio(false);cin.tie(NULL)
#define l long 
using namespace std;
const int  mod= 1e9+7;
const int inf=1e9+3;

 int main()
 {
     fast;  
        string s,t;
         cin>>s>>t;
        int m,n;
         m=s.size();
         n= t.size();
         int  dp[m+1][n+1];
         for(int i=0; i<=m; i++)
         {
              for(int j=0; j<=n; j++)
              {
                   if(i==0 || j==0)
                   dp[i][j]=0;
                   else if(s[i-1]==t[j-1])
                   dp[i][j]=1+dp[i-1][j-1];
                   else
                   {
                       dp[i][j]= max(dp[i-1][j], dp[i][j-1]);
                   }
              }
         }
         
         string res;
         int lx=m;
         int ly=n;
         while(lx>0 && ly>0)
         {
             if(s[lx-1]==t[ly-1]){
                 res+=s[lx-1];
                 lx--,ly--;
             }
             
             else if(dp[lx-1][ly]>dp[lx][ly-1])
              lx--;
              else
              ly--;
         }
          reverse(res.begin(), res.end());
          cout<<res;
           
    
       return 0;
     
 }
  

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

int main() {
  
  int N; cin >> N; int ans = 1;
  
  vector<string> vec(N);
  
  for (int i = 0; i < N; i++) cin >> vec[i];
  
  sort(vec.begin(), vec.end());
  
  for (int i = 0; i < N - 1; i++) {
    
    if (vec[i] != vec[i + 1]) ans++;
    
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 9576
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	if(b>=c){
		cout << "delicious" << endl;
    }else if((c-b)>a){
		cout << "dangerous" << endl;
    }else{
		cout << "safe" << endl;
    }
  
	return 0;
}

Measured memory_bytes: 256