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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const ll MOD = 1000000007;
const int MX = 2010;

int N, M, K;
ll dp[MX * 2][MX];

inline void add(ll &x, ll y) { x += y; if (x >= MOD) x -= MOD; }

int main() {
	cin >> N >> M >> K;

	for (int i = 1; i < K; ++i) {
		if (i <= N && (K - 1 - i) <= M - 1) {
			dp[1][i] = 1;
		}
	}

	ll ret = 0;

	for (int i = 1; i < MX * 2 - 1; ++i) {
		rep(j, MX) if (dp[i][j]) {
			if ((j - N) % (K - 1) == 0 && (j + (M - 1)) % (K - 1) == 0) {
				add(ret, dp[i][j]);
			}

			rep(k, K) { //add k to the front
				if (j + k <= N && (K - 1) * (i + 1) - j - k <= M-1) {
					add(dp[i + 1][j + k], dp[i][j]);
				}
			}
		}
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 60544
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<list>
#include<map>
#include<set>
#define endl "\n"
#define eb emplace_back
#define FOR(i, a, b) for(long long i = a; i < b; ++i)
#define FORR(n) for(long long i = n - 1; i >= 0; --i)
#define FORE(n) for(const auto &i : n)
#define MS(n, i) memset(n, i, sizeof(n))
typedef long long ll;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
using namespace std;

bool comp(pair<ll, ll> a, pair<ll, ll> b)
{
	return a.first < b.first;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;	
	//cin >> t;
	t = 1;
	while(t--)
	{
		double n, x, t;
		cin >> n >> x >> t;
		cout << (int)(ceil(n / x) * t) << endl;
	}
    return 0;
}

/*
4
0 1 1 1
8 1 9 3
0 0 0 0
1000000000 1000000000 1000000000 1000000000
*/

Measured memory_bytes: 3736
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n; cin >> n;
	VI a(n);
	rep(i, n)cin >> a[i];

	rep(k, n) {
		cout << a[k];
		if (k == n - 1)puts("");
		else cout << " ";
	}

	//sort
	for (int i = 1; i <= n - 1; i++) {
		int v = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;

		//print
		rep(k, n) {
			cout << a[k];
			if (k == n - 1)puts("");
			else cout << " ";
		}
	}
}


Measured memory_bytes: 3100
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
#include<string.h>
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define None cout<<"None"<<endl
typedef long long ll;
using namespace std;

int main() {
	int N; cin >> N;
	int a[N];
	for (int i = 1; i <= N; ++i) cin >> a[i];
	int cnt = 0;
	int z = 1;
	for (int i = 1; i <= N; ++i) {
		z = a[z];
		++cnt;
		if (z == 2) {
			cout << cnt << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}


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

int H, W;
vector<string> A;
vector<vector<int>> seen;
queue<pair<int, int>> to_visit;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};

int main() {
    cin >> H >> W;
    A.resize(H);
    seen.assign(H, vector<int>(W, -1));
    for (int i = 0; i < H; i++) {
        cin >> A.at(i);
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if(A.at(i).at(j) == '#') {
                pair<int, int> p = make_pair(i, j);
                to_visit.push(p);
                seen.at(i).at(j) = 0;
            }
        }
    }

    while(to_visit.size() > 0) {
        pair<int, int> p = to_visit.front();
        to_visit.pop();
        int x = p.first, y = p.second;
        for (int i = 0; i < 4; i++) {
            int nx = x + dx.at(i), ny = y + dy.at(i);
            if(nx >= 0 && nx < H && ny >= 0 && ny < W && seen.at(nx).at(ny) == -1) {
                seen.at(nx).at(ny) = seen.at(x).at(y) + 1;
                to_visit.push(make_pair(nx, ny));
            }
        }
    }

    int ans = -1;
    for (int i = 0; i < H; i++) {
        int max_row = *max_element(seen.at(i).begin(), seen.at(i).end());
        ans = max(ans, max_row);
    }

    cout << ans << endl;
}

Measured memory_bytes: 13456
#include<bits/stdc++.h>
#define gc getchar
#define re register
#define rep(i,u,z) for(re int i=u;i<=z;++i)
#define reb(i,u,z) for(re int i=u;i>=z;--i)
#define inf 0x7fffffff

using namespace std;
typedef long long ll;

const int N=1e5+10;
int n,q,pre_sum[N];
bool mrk[N];

inline int read(){
	int rt=0;
	char ch=gc();
	while(ch<'0'||ch>'9')ch=gc();
	while(ch>='0'&&ch<='9'){
		rt=(rt<<3)+(rt<<1)+(ch&15);
		ch=gc();
	}
	return rt;
}
int main(){
	n=read(),q=read();
	string s;
	cin>>s;
	rep(i,1,n-1)if(s[i]=='C'&&s[i-1]=='A')mrk[i+1]=true,pre_sum[i+1]=pre_sum[i]+1;else pre_sum[i+1]=pre_sum[i];
	int a,b;
	for(;q--;){
		a=read(),b=read();
		if(mrk[a])printf("%d\n",pre_sum[b]-pre_sum[a]);
		else printf("%d\n",pre_sum[b]-pre_sum[a-1]);
	}
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
long long INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int vp[2*300*300+1],vl[300*300+1],answer[100000];
int h,w,d,q;

int inline dist(int i){
    return abs(vp[2*i]-vp[2*i-2*d]) + abs(vp[2*i+1]-vp[2*i-2*d+1]);
}

int main(){
    scanf("%d %d %d",&h,&w,&d);
    FOR(i,1,h+1){
        FOR(j,1,w+1){
            int a;
            scanf("%d",&a);
            vp[2*a] = i;
            vp[2*a+1] = j;
        }
    }

    scanf("%d",&q);
    FOR(i,1,d+1) vl[i] = 0;
    FOR(i,d+1,h*w+1) vl[i] = vl[i-d] + dist(i);

    REP(i,q){
        int l,r;
        scanf("%d %d",&l,&r);
        answer[i] = vl[r] - vl[l];
    }
    REP(i,q) printf("%d\n",answer[i]);
    return 0;
}


Measured memory_bytes: 2560
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

char S[1005],T[1005];
signed main(){
    scanf("%s",S);
    scanf("%s",T);
    int SN=strlen(S);
    int TN=strlen(T);
    int ans=INF;
    rep(i,SN-TN+1){
        int sans=0;
        rep(j,TN){
            if(S[i+j]!=T[j]){
                sans+=1;
            }
        }
        ans=min(ans,sans);
    }
    printf("%lld\n",ans);
}

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

using namespace std;
#define int long long

typedef int number;
typedef vector<number> Array;
typedef vector<Array> matrix;

const int mod = 1000000009;

// O( n )
matrix identity(int n) {
  matrix A(n, Array(n));
  for (int i = 0; i < n; ++i) A[i][i] = 1;
  return A;
}
// O( n^2 )
Array mul(const matrix &A, const Array &x) {
  Array y(A.size());
  for (int i = 0; i < A.size(); ++i)
    for (int j = 0; j < A[0].size(); ++j)
      y[i] = (y[i] + A[i][j] * x[j]) % mod;
  return y;
}
// O( n^3 )
matrix mul(const matrix &A, const matrix &B) {
  matrix C(A.size(), Array(B[0].size()));
  for (int i = 0; i < C.size(); ++i)
    for (int j = 0; j < C[i].size(); ++j)
      for (int k = 0; k < A[i].size(); ++k)
        C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % mod;
  return C;
}
// O( n^3 log e )
matrix pow(const matrix &A, int e) {
  return e == 0 ? identity(A.size())  :
     e % 2 == 0 ? pow(mul(A, A), e/2) : mul(A, pow(A, e-1));
}

#define range(i,x,y) i=(x);i<(y);i++
#define rep(i,n) for(int i=0,i##_len=n;i<i##_len;i++)
#define all(x) begin(x),end(x)
#define lim(x,r,l) (r<=x&&x<l)
typedef long long ll;
typedef long double ld;


signed main(){
  int w, h, n; int num = 1;
  while(cin >> w >> h >> n, w != 0){
  map<int, vector<int>> obst;
  rep(i, n){
    int x, y; cin >> x >> y;
    if (obst.find(y) == obst.end()){
      obst[y] = vector<int>{x};
    } else {
      obst[y].push_back(x);
    }
  }
  if (obst.find(h) == obst.end()){
    obst[h] = vector<int>{1};
  }
  Array res(w);
  res[0] = 1;

  matrix way(w, Array(w));
  rep(i, w){
    if(i-1 >= 0) way[i][i-1] = 1;
                  way[i][i] = 1;
    if(i+1 <  w) way[i][i+1] = 1;
  }

  int prv = 1;
  for(auto ob : obst){
    int y; vector<int> xs; tie(y, xs) = ob;
    res = mul(pow(way, y - prv), res);
    for(int x: xs){
      res[x - 1] = 0;
    }
    prv = y;

  }
  cout << "Case " << num << ": " << res[w-1] << endl;
  num++;
  }
}

Measured memory_bytes: 5856
#include<stdio.h>

int main(void){
    int i,j,n,x,k[4][13]={0};
    char m;
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%c",&m);
        scanf("%c %d",&m,&x);
        if(m=='S'){
            k[0][x-1]=1;
        }else if(m=='H'){
            k[1][x-1]=1;
        }else if(m=='C'){
            k[2][x-1]=1;
        }else{
            k[3][x-1]=1;
        }
    }
    
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(k[i][j]==0){
                if(i==0){
                    printf("S %d\n",j+1);
                }else if(i==1){
                    printf("H %d\n",j+1);
                }else if(i==2){
                    printf("C %d\n",j+1);
                }else{
                    printf("D %d\n",j+1);
                }
            }
        }
    }
    
    return 0;
}


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

int main(){
  int h1,m1,h2,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int x=(h2-h1)*60+m2-m1;
  int ans=x-k;
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	n = n%10;
	if( n == 2 or n == 4 or n == 5 or n == 7 or n == 9)
		cout << "hon";
	else if( n == 0 or n == 1 or n == 6 or n == 8 )
		cout << "pon";
	else{
		cout << "bon";
	}
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int A[110];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A, A + N);

  cout << A[N-1] -A[0] << endl;
}

Measured memory_bytes: 256
N,Y = map(int,input().split())
a,b,c = N+1,N+1,N+1
count = 0

if Y // N == 10000:
    print(N,0,0)
elif Y // N == 5000:
    print(0,N,0)
elif Y // N == 1000:
    print(0,0,N)
else:
    stop = False
    for i in range(a):
        for j in range(b-i):
            c -= i+j
            if i+j+c != N:
                pass
            else:
                dama = 10000*i + 5000*j + 1000*c
                if dama == Y:
                    print(i,j,c)
                    count += 1
                    exit()
            c = N
        b = N+1
    if count == 0:
        print(-1,-1,-1)

Measured memory_bytes: 9232
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "



int main() {
	//~ string s;
	//~ cin >> s;
	//~ for(int i = 0; i < (int) s.length() - 1; ++i)
		//~ if(s[i] == 'A' && s[i+1] == 'C') {
			//~ puts("Yes");
			//~ return 0;
		//~ }
	//~ puts("No");
	
	int n;
	cin >> n;
	int odd = 1, even = 0;
	while(n--) {
		int x;
		cin >> x;
		if(x % 2) {
			even = 2 * (even + odd) + even;
		}
		else {
			even = 3 * even + odd;
			odd *= 2;
		}
	}
	printf("%d\n", even);
}


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

using namespace std;

vector<bool> eratos(1001,true);

//using namespace std;

int main(){
  //eratos;
  eratos[0] = false;
  eratos[1] = false;
  for(int i = 0; i < 1001; i++){
    if(eratos[i] == true){
      for(int j = 2; i*j < 1001; j++) eratos[i*j] = false;
    }
  }
  long long int N;
  cin >> N;
  
  map<long long int,long long int> m;
  
  unsigned long long int ans = 1;
  for(long long int i = N; i >= 1; i--){
    for(long long int j = 1; j < eratos.size(); j++){
      long long int tmp = 0;
      if(!eratos[j])continue;
      if(i % j != 0) continue;
      else{
        long long int d = j;
        while(i % d == 0 && d <= i){
          tmp += 1;
          d *= j;
        }
       m[j] += tmp; 
      }
    }
  }
  
  for(auto iter = m.begin(); iter != m.end(); iter++){
    //cout << iter->first << ":" << iter->second << endl; 
    ans = ((ans % 1000000007LL) * (iter->second + 1LL)) % 1000000007LL;
  }
  cout << ans;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <stdlib.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <cstring>
#include <sstream>
#include <stack>
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define For(I,N) for(int I=0;I<N;I++)
#define mp make_pair
typedef unsigned long long ull;
using namespace std;
int a[1000000],s[1000000],n;

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n;
	rep(n)
	{
		scanf("%d",&a[i]);
	}
	rep(n)
	{
		s[a[i]-1]++;
		s[a[i]]++;
		s[a[i]+1]++;
	}
	int m=0;
	rep(1000000)
	{
		m=max(m,s[i]);
	}
	cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 4736
/**
 *   created: 03 June 2019  00:25:23
**/
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef vector< pair<int , int> > vii;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long , long long> pll;
typedef vector< pair<long long , long long> > vll;

#define PB push_back
#define PPB pop_back
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rrep(i,a,b) for(int i = (int)(a-1); i>=(int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================
ll modexpo(ll n, ll p){
	if(p==0)
		return 1;
	if(p%2==0)
		return modexpo((n%MOD * n%MOD)%MOD, p/2);
	return (n%MOD*modexpo(n,p-1)%MOD)%MOD;
}
int main()
{
	optimizeIO();
	int tt=1;
	//cin>>tt;
	while(tt--){
		string s;
		cin>>s;
		int mini = INF;
		rep(i,0,s.size()-2){
			int n;
			n = s[i] - '0';
			n*=10;
			n += s[i+1] - '0';
			n*=10;
			n += s[i+2] - '0';
			// trace1(n);
			mini = min(mini, abs(n-753));
			
		}
		cout<<mini;
	}
	return 0;
}


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

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

    ll i,j,k,l,m,n,w,x,y,z,p,q,tmp,sum=0;
    string str;
    cin>>n;
    vector<int> a(n);
    vector<int> b(n+1);
    rep(i,n-1)   cin >> a[i];
    rep(i,n) b[a[i]]++;
    rep(i,n+1){
        if(i==0) continue;
        cout<<b[i]<<endl;
    }

    return 0;
}

Measured memory_bytes: 4748
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> dp(n + 1);
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (dp[a[i] - 1]) {
            dp[a[i]] = 1;
        }
    }
    for (int i = n; i >= 1; i--) {
        if (dp[i]) {
            cout << n - i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 1792
#!/usr/bin/python3

secret = 'keyence'
s = input()
n = len(s)
m = len(secret)

if n < m:
    print("NO")
    exit(0)

for i in range(m):
    if s[:i] + s[-(m - i):] == secret:
        print("YES")
        exit(0)

print("NO")

Measured memory_bytes: 3064
A, B, C, X, Y = map(int, input().split())
C = min(2*C, A+B)

ans = 0
ans += C*min(X, Y)
if X > Y:
  ans += min(C, A) * abs(X-Y)
else:
  ans += min(C, B) * abs(X-Y)
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int a,b,c,d,e,k;
 cin >> a >> b >> c >> d >> e >> k;
 if(e-a<=k){
     cout << "Yay!" << endl;
 }
 else{
     cout << ":(" << endl;
 }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L



int main() {
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        if (x >= k) cnt++;
    }
    cout << cnt;

    return 0;
}

Measured memory_bytes: 3672
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};const rep=(n,c:(i?:number)=>void)=>{for(let i=0;i<n;i++)c(i)};
const main=()=>{
  let n=tn(),saids=new Array(n)
  rep(n,(i)=>{
    let saidTimes=tn()
    saids[i]=[]
    rep(saidTimes,()=>{
      saids[i].push([tn(),tn()])
    })
  })
  let people=new Array(n),ans=0;
  for(let i=0;i<2**n;i++){
    let ok=true
    let maxP=0;
    for(let j=0;j<people.length;j++){
      people[j]=Boolean(i&(1<<j))
      if(people[j])maxP++
    }   for(let j=0;j<people.length;j++){
      if(!people[j])continue;
      for(let k=0;k<saids[j].length;k++){
        if(saids[j][k][1]==1){
          if(!people[saids[j][k][0]-1])ok=false
        }else{
          if(people[saids[j][k][0]-1])ok=false
        }
      }
    }
    if(ok)ans=(max(ans,maxP))
  }
  to(ans)
}
main()


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

#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
void fst()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
}
int mod = 1e9 + 7;
int binpow(int a, int b)
{
    int res = 1;
    while (b > 0)
    {
        if (b & 1)
        {
            res = res * a;
            res %= mod;
        }
        a = a * a;
        a %= mod;
        b >>= 1;
        b %= mod;
    }
    return res;
}
#define Darr(x)           \
    cerr << #x << " = ";  \
    for (auto i : x)      \
        cerr << i << " "; \
    cerr << "\n";

#define all(a) a.begin(), a.end()
#define pb push_back
#define deb(x) cerr << #x << "=" << x << " ";
#define int long long
#define R(n) for (int i = 0; i < n; i++)
#define Rj(n) for (int j = 0; j < n; j++)
#define F(i, a, n) for (int i = a; i <= n; i++)
#define MN(x, y) x = min(x, y);
#define MX(x, y) x = max(x, y);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

int n, k, tc, y, u, v;

int32_t main()
{
    fst();
    cin >> n;
    if(n>=400&&n<=599)cout<<"8";
    if(n>=600&&n<=799)cout<<"7";
    if(n>=800&&n<=999)cout<<"6";
    if(n>=1000&&n<=1199)cout<<"5";
    if(n>=1200&&n<=1399)cout<<"4";
    if(n>=1400&&n<=1599)cout<<"3";
    if(n>=1600&&n<=1799)cout<<"2";
    if(n>=1800&&n<=1999)cout<<"1";
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,max=0;
	cin>>n;
	for(int i=1;;++i)
	{
		if(i*i>n)
		{
			cout<<max<<endl;
			return 0;
		}
		if(i*i>max)
		{
			max=i*i;
		}
	}
	return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for (int i = a; i <= (b); i++)
#define ROF(i, a, b) for (int i = a; i >= (b); i--)

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

int main() {
    int n; cin >> n;
    vll a(n);
    FOR(i, 0, n - 1)
        cin >> a[i];
    ll m = 1000;
    FOR(i, 1, n - 1) {
        if (a[i] > a[i - 1]) {
            ll c = m / a[i - 1];
            m = m - a[i - 1] * c + a[i] * c;
        }
    }
    cout << m << endl;
}

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

int main() {
  vector<int> a(5);
  for (int i = 0; i < 5; i = i + 1) {
    cin >> a.at(i);
  }
  int k;
  cin >> k;
  bool d = true;
  for (int i = 0; i < 4; i = i + 1) {
    for (int j = i + 1; j < 5; j = j + 1) {
      if (a.at(j) - a.at(i) > k) {
        d = false;
        break;
      }
    }
  }
  if (d) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();

//        Map<Long,Long> map = new HashMap<Long,Long>();
//        for(long i=0;i<n;i++){
//            long temp = sc.nextLong();
//            map.put(temp,i+1);
//        }
//
//        Arrays.sort(map.keySet().toArray());
//
//        for(Long key : map.keySet()){
//            System.out.print(map.get(key)+" ");
//        }

        Map<Long,Long> map = new TreeMap<Long,Long>();
        for(long i=0;i<n;i++){
            long temp = sc.nextLong();
            map.put(temp,i+1);
        }
        for(Long key : map.keySet()){
            System.out.print(map.get(key)+" ");
        }





    }
}

Measured memory_bytes: 71688
import * as fs from 'fs';

const input = fs.readFileSync('/dev/stdin', 'utf8');
const args: string[][] = input.split('\n').map(l => l.split(' '));

const x = parseInt(args[0][0]);

const f = (a: number, b: number) => Math.pow(a, 5) - Math.pow(b, 5);

let [a, b] = [0, 0];
let tmp = 1;
if (f(a, b) !== x) {
    while (true) {
        if (tmp % 2 === 1) {
            for (let i = 1; i <= tmp; i++) {
                [a, b] = [a + 1, b];
                if (f(a, b) === x) break
            }

            if (f(a, b) === x) break

            for (let i = 1; i <= tmp; i++) {
                [a, b] = [a, b - 1];
                if (f(a, b) === x) break
            }
        } else {
            for (let i = 1; i <= tmp; i++) {
                [a, b] = [a - 1, b];
                if (f(a, b) === x) break
            }

            if (f(a, b) === x) break

            for (let i = 1; i <= tmp; i++) {
                [a, b] = [a, b + 1];
                if (f(a, b) === x) break
            }
        }

        tmp++;
    }
}

console.log(`${a} ${b}`);



Measured memory_bytes: 36904
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define ov(a) for(ll i=0;i<a.size();i++)cout<<a[i]<<" ";nl
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
	fastio();
	ll N;
	cin>>N;
	ll ar[N];
	cn(ar,N);
	ll g[N];
	g[0]=0;
	g[1]=abs(ar[1]-ar[0]);
	for(ll i=2;i<N;i++)
	{
		g[i]=min(abs(ar[i]-ar[i-1])+g[i-1],abs(ar[i]-ar[i-2])+g[i-2]);
	}
	cout<<g[N-1]<<endl;
}	


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int solve(const vector<vector<int>> &G, int node, int prev) {
    int ans = 0;
    for (auto &next : G[node]) if (next != prev) {
        ans ^= solve(G, next, node) + 1;
    }
    return ans;
}
int main() {
    int N; cin >> N;
    vector<vector<int>> G(N);
    for (int i = 0; i < N - 1; i++) {
        int x, y; cin >> x >> y; x--, y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    cout << (solve(G, 0, -1) ? "Alice" : "Bob") << '\n';
    return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 1001001001;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1e9 + 7;

int n;
vector<vector<int>> tos;
set<int> not_visited;

void bfs(int target) {
    if (not_visited.find(target) == not_visited.end()) return;
    not_visited.erase(target);
    auto to = tos[target];
    for (auto t : to) {
        bfs(t);
    }
}


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

    tos = vector<vector<int>>(n);

    rep(i, m) {
        int x, y, z;
        cin >> x >> y >> z;

        x--;
        y--;
        z--;

        tos[x].push_back(y);
//        tos[x].push_back(z);

        tos[y].push_back(x);
//        tos[y].push_back(z);

//        tos[z].push_back(x);
//        tos[z].push_back(y);

    }

    rep(i, n) {
        not_visited.insert(i);
    }

    int c = 0;
    while (!not_visited.empty()) {
        int i = *not_visited.begin();
        bfs(i);
        c++;
    }

    cout << c << endl;

}



Measured memory_bytes: 15232
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()

    var ans = 0L
    for (i <- 0 until n) {
      val a, b = sc.nextInt()
      ans += b - a + 1
    }

    println(ans)
  }
}


Measured memory_bytes: 29632
#include <stdio.h>

int main(){
  int N,M,S=0;
  scanf("%d %d",&N,&M);
  int F[200000];
  int L,R,ML=0,MR=N;
  for(int i=1;i<=M;i++){
    scanf("%d %d",&L,&R);
    if(ML<L) ML=L;
    if(R<MR) MR=R;
  }
  printf("%d\n",ML<=MR?MR-ML+1:0);
  return 0;
}

Measured memory_bytes: 1688
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10**9

def dfs(cur, a, b, c):
  if cur == N:
    return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a,b,c)>0 else INF

  ans = INF
  ans = min(ans, dfs(cur+1, a, b, c))
  ans = min(ans, dfs(cur+1, a + l[cur], b, c)+10)
  ans = min(ans, dfs(cur+1, a, b+l[cur], c)+10)
  ans = min(ans, dfs(cur+1, a, b, c+l[cur])+10)
  return ans

print(dfs(0, 0, 0, 0))


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

int main () {
    int n,i,j,k,t = 0,x = 1;
	long long ans = 0;
    char temps;
    cin >> n;
    int keep[n];
    string s[n+1],p;
    for (i = 0;i < n; i++) {
        cin >> s[i];
    }
    for (k = 0; k < n; k++) {
        for (i = 0;i < s[k].size(); i++) {
            for (j = i; j < s[k].size(); j++) {
                if (s[k][i] > s[k][j]) {
                    temps = s[k][i];
                    s[k][i] = s[k][j];
                    s[k][j] = temps;
                }
            }
        }
    }
    k =0;
    sort(s,s+n);
    
    s[n] = "";
    p = s[0];
    for (i = 1;i < n+1;i++) {
        if (s[i] != p) {
            x = 1;
            p = s[i];
        }
        else {
            ans += x;
            x++;
        }
        //cout << "ans = " << ans << endl;
        //cout << "i = " << i << endl;
        //cout << "x = " << x << endl;
    }
    cout << ans;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll x, p = 100, ans = 0;
    cin>>x;
    while(p < x){
        p += p/100;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

int main(){
  string s;cin>>s;
  int n=s.length();
  bool isok=s.back()=='0';
  isok &= s[0]=='1'&&s[n-2]=='1';
  for(int i=1;i*2<n;i++){
    isok &= s[i]==s[n-2-i];
  }
  if(!isok){
    cout << -1 << endl;
    return 0;
  }
  int l=1,r=2;
  cout << 1 << " " << 2 << endl;
  repeat(i,n-2){
    if(s[i]=='1'){
      cout << r << " " << i+3 << endl;
      l = r;
      r = i+3;
    }else{
      cout << l << " " << i+3 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>
#include<string.h>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<iostream>
#include<iomanip>
#include<utility>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define fi first
#define sec second
#define pb push_back
#define mp make_pair
#define rep(a,b,c) for(int a=1;a<=b;a+=c)
#define repp(a,b,c,d) for(int a=b;a<=c;a+=d)

const double PI=acos(-1);
const double EPS=1e-12;
const int MOD=1e9+7;
const int INF=1<<30;


using namespace std;

map<string,bool>m;

int main(){
	ios::sync_with_stdio(false);cin.tie(NULL);	cout.tie(NULL);
	int n,k,t,tt;
	cin>>n>>k;
	string s;
	int cnt[30];
	rep(i,26,1){
		cnt[i]=0;
	}
	rep(i,n,1){
		cin>>s;
		if(!m[s]){
			cnt[s[0]-'A'+1]++;
			m[s]=true;
		}
	}
	priority_queue<int>pq;
	queue<int>q;
	rep(i,26,1){
		if(cnt[i]>0){
			pq.push(cnt[i]);
		}
	}
	t=0;
	tt=0;
	rep(j,n,1){
		while(!pq.empty()){
			int x=pq.top();
			pq.pop();
			if(x>0){
				tt++;
				x--;
				if(x>0)q.push(x);
				if(tt==k){
					t++;
					tt=0;
					break;
				}
			}
			
		}
		while(!q.empty()){
			if(q.front()!=0){
				pq.push(q.front());
			}
			q.pop();
		}
		tt=0;
	}
	cout<<t<<endl;
	return 0;
}



Measured memory_bytes: 1408
#include <algorithm>
#include <complex>
#include <iostream>

using namespace std;
long long int smallest(long long int x, long long int y, long long int z) {
  return min(min(x, y), z);
}

long long int largest(long long int x, long long int y, long long int z) {
  return max(max(x, y), z);
}

int main() {
  long long int H, W;
  cin >> H >> W;
  long long int s_diff_min = H * W;
  long long int a_width, a_height;

  //まずAのheightを決める
  for (long long int i = 1; i < H; i++) {
    a_height = i;
    long long int s_a, s_b, s_c;
    //横分割
    s_a = W * a_height;
    s_b = W * ((H - a_height) / 2);
    s_c = H * W - (s_b + s_a);
    long long int tmp = largest(s_a, s_b, s_c) - smallest(s_a, s_b, s_c);
    s_diff_min = (tmp < s_diff_min) ? tmp : s_diff_min;

    //縦分割
    s_a = W * a_height;
    s_b = (H - a_height) * (W / 2);
    s_c = (H - a_height) * (W - (W / 2));
    tmp = largest(s_a, s_b, s_c) - smallest(s_a, s_b, s_c);

    s_diff_min = (tmp < s_diff_min) ? tmp : s_diff_min;
  }

  // Aのwidthを決める
  for (long long int i = 1; i < W; i++) {
    a_width = i;
    long long int s_a, s_b, s_c;
    //横分割
    s_a = H * a_width;
    s_b = H * ((W - a_width) / 2);
    s_c = H * W - (s_b + s_a);
    long long int tmp = largest(s_a, s_b, s_c) - smallest(s_a, s_b, s_c);
    s_diff_min = (tmp < s_diff_min) ? tmp : s_diff_min;

    //縦分割
    s_a = H * a_width;
    s_b = (H / 2) * (W - a_width);
    s_c = (H - (H / 2)) * (W - a_width);
    tmp = largest(s_a, s_b, s_c) - smallest(s_a, s_b, s_c);
    s_diff_min = (tmp < s_diff_min) ? tmp : s_diff_min;
  }

  cout << s_diff_min << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] p = new int[N];
		for (int i=0;i<N;i++) {
			p[i] = sc.nextInt();
		}
		Arrays.sort(p);
		int ans = 0;
		for (int i=0;i<K;i++) {
			ans += p[i];
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 38608
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
 
 
 
 
int main()
{
	int i, N;
 
	scanf("%d", &N);
 
	int a[11];
	int t[11];
 
	for (i = 0; i < N; i++) scanf("%d", &a[i]);
 
	for (i = 0; i < N; i++) {
		if (a[i] % 2 == 0) {
			t[i] = 2;
		}
		else t[i] = 1;
	}
 
	int seki=1;
 
	for (i = 0; i < N; i++) {
		seki*= t[i];
	}
 
	int p=1;
 
	for (i = 0; i < N; i++) {
		p *= 3;
	}
 
 
	printf("%d", p - seki);
}
 

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

int main() {
  ll n; cin >> n;
  set<ll> st;
  REP(i, n){
    ll d; cin >> d;
    st.insert(d);
  }
  cout << st.size() << endl;
}

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

#define Rushia_mywife ios::sync_with_stdio(0);cin.tie(0);
#define rep(i,head,n) for(int i=(head);i<n;i++)
#define F first
#define S second
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define all(x) (x).begin(),(x).end()
#define SZ(x) (int)(x).size()
#define mem(x,i) memset((x),(i),sizeof((x)))
#define odd(x) ((x)&1)
#define LG(x) (int)log2((x))

using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<long long,long long>;
using ld = long double;

mt19937 mt_rand(time(0));
const int mod = 1000000007;
const int hnum = 998244353;
const ld PI = acos(-1);

#define int long long
int qpow(int x,int powcnt,int tomod){
	int res = 1;
	for(;powcnt;powcnt>>=1,x=(x*x)%tomod)
		if(1&powcnt)res = (res*x)%tomod;
	return (res%tomod);
}
int gcd(int aaa,int bbb){
	return (bbb==0 ? aaa : gcd(bbb,aaa%bbb));
}
int lcm(int aaa,int bbb){
	return (aaa/gcd(aaa,bbb))*bbb;
}
int C(int x){
	return x*(x-1)/2;
}
// --------------------------------------**
const int N = 1e5+10;

int n,k;
int a[N];
int dp[N];

void solve(){
	cin >> n >> k;
	rep(i,1,n+1)
		cin >> a[i];
	dp[1] = 0;
	rep(i,2,n+1){
		dp[i] = (int)1e10;
		for(int j=1;j<=k;j++){
			if(i-j<1)
				break;
			dp[i] = min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
		}
	}
	cout << dp[n] << '\n';
}

signed main(){
    Rushia_mywife
    //int t; cin >> t;
    //while(t--)
    solve();
}


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

int main() {
  vector<int> a(5);
  
  for(int i = 0; i < 5; i++){
    cin >> a.at(i);
  }
  
  int ans = 0;
  
  for(int i = 0; i < 5; i++){
    if(a.at(i)%10==0){
      ans += a.at(i);
    }
    else{
      ans += (a.at(i)+(10-a.at(i)%10));
    }
  }
  
  vector<int> b = {a.at(0)%10,a.at(1)%10,a.at(2)%10,a.at(3)%10,a.at(4)%10};
  
  sort(b.begin(),b.end());

  int mini = 0;
  
  for(int i = 0; i < 5; i++){
    if(b.at(i)!=0){
      mini = b.at(i);
      break;
    }
  }
  
  if(mini!=0){
    cout << ans - (10-mini) << endl;
  }
  else{
    cout << ans << endl;
  }
  
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll MX = 1e18;
int main()
{
  int N;
  cin >> N;
  ll sum = 1;
  bool ng = false;
  REP(i, N) {
    ll a;
    cin >> a;
    if (a == 0) {
      cout << 0 << endl;
      return 0;
    }

    if (ng || (MX/sum) < a || sum * a > MX) {
      ng = true;
    }
    sum *= a;
  }
  if (ng) {
    cout << -1 << endl;
  } else {
    cout << sum << endl;
  }
  
  return 0;
}

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

int main(){
    int n;
    int cnt=0;
    int flag=0;
    long A[200];

    cin >> n;
    for(int i=0;i<n; i++){
        cin >> A[i];
        if(A[i]%2 != 0)
            flag=1;
    }
    if(flag==0){
        while(1){
            for(int i=0; i<n;i++){
                A[i] = A[i]/2;
                if(A[i]%2 != 0){
                    flag = 1;
                    break;
                }
            }
            cnt++;
            if(flag==1)
                break;
        }
    }

    cout << cnt << endl;

}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
using Graph = vector<vector<ll>>;

int main(){
  string s,t;cin >> s >> t;
  bool flag = true;
  for (int i = 0; i < s.size(); i++)
  {
    if(s.at(i) != t.at(i))flag = false;
  }
  if(s.size() + 1 != t.size())flag = false;
  if(flag)cout << "Yes" <<endl;
  else cout << "No" <<endl;
  
}

Measured memory_bytes: 3580
N = int(input())
robot_list = []
for i in range(N):
  X, L = map(int, input().split())
  left_edge = X - L
  right_edge = X + L
  robot_list.append([left_edge, right_edge])

robot_list.sort(key=lambda x: x[1])

res = 0
index = - pow(10, 10)
for i in range(N):
  if robot_list[i][0] >= index:
    index = robot_list[i][1]
    res += 1

print(res)

Measured memory_bytes: 63064
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Fixed
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete

f ps = firstP : sub firstP 0
  where
    sub p a = let np = nextP p a in if np==firstP then [] else np : sub np (angleFrom p np)
    firstP = minimumBy (comparing snd <> flip (comparing fst)) ps
    nextP p a = minimumBy (comparing (flip mod' (2*pi) . subtract a . angleFrom p)) (delete p ps)
    angleFrom (x0,y0) (x,y) = atan2 (y-y0) (x-x0)

main = do
    n <- getInt
    unless (n==0) $ map (apply2 (,) . map readDouble . wordsBy (==',')) <$> replicateM n getLine >>= print . (n-) . length . f >> main


Measured memory_bytes: 4716
class UnionFind:
  def __init__(self, n):
    self.par = [i for i in range(n)]
    self.rank = [0]*n
  def find(self, x):
    if self.par[x]==x:
      return x
    else:
      self.par[x] = self.find(self.par[x])
      return self.par[x]
  def unit(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x==y:
      return
    elif self.rank[x]<self.rank[y]:
      self.par[x] = y
      return
    elif self.rank[y]<self.rank[x]:
      self.par[y] = x
    else:
      self.par[y] = x
      self.rank[x] += 1
      
  def same(self, x, y):
    return self.find(x)==self.find(y)
  

N, M, *L = map(int, open(0).read().split())
p = L[:N]
ls = L[N:]
u = UnionFind(N+1)
for x,y in zip(*[iter(ls)]*2):
  u.unit(x,y)
ans = sum(1 if u.same(p,i+1) else 0 for i,p in enumerate(p))
print(ans)

Measured memory_bytes: 35316
#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

_, *A = map(int1, read().split())

ans = 0
for i, a in enumerate(A):
    if A[a] == i:
        ans += 1

print(ans // 2)


Measured memory_bytes: 21380
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000



int main(){
	
	int T;
	cin>>T;
	
	for(int _=0;_<T;_++){
		int N;
		cin>>N;
		
		vector<long long> K(N),L(N),R(N);
		for(int i=0;i<N;i++)cin>>K[i]>>L[i]>>R[i];
		
		vector<pair<long long,long long>> l,r;
		long long ans = 0LL;
		for(int i=0;i<N;i++){
			if(L[i]>R[i]){
				ans += R[i];
				l.emplace_back(K[i]-1,L[i]-R[i]);
			}
			else{
				ans += L[i];
				r.emplace_back(N-K[i]-1,R[i]-L[i]);
			}
		}
		sort(l.begin(),l.end());
		sort(r.begin(),r.end());
		priority_queue<long long,vector<long long>,greater<long long>> Q;
		for(int i=0;i<l.size();i++){
			if(Q.size()<=l[i].first){
				ans += l[i].second;
				Q.push(l[i].second);
			}
			else{
				if(Q.size()==0)continue;
				if(Q.top()<l[i].second){
					ans -= Q.top();
					Q.pop();
					ans += l[i].second;
					Q.push(l[i].second);
				}
			}
		}
		
		while(Q.size()!=0)Q.pop();
		for(int i=0;i<r.size();i++){
			if((int)Q.size()<=r[i].first){
				ans += r[i].second;
				Q.push(r[i].second);
			}
			else{
				if(Q.size()==0)continue;
				if(Q.top()<r[i].second){
					ans -= Q.top();
					Q.pop();
					ans += r[i].second;
					Q.push(r[i].second);
				}
			}
		}
		
		cout<<ans<<endl;
		
		
	}
	
	return 0;
}


Measured memory_bytes: 12932
#include<stdio.h>
int main()
{
     int a,b;
    char op;
    scanf("%d\n",&a);
   scanf("%c",&op);
   scanf("%d",&b);
   if(op=='+'){
    printf("%d\n",a+b);
   }
   else{
    printf("%d\n",a-b);
   }

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
// Your code here!
  long long a, b, c;
  cin >> a >> b >> c;
  int x = 0;
  if (a+b<c) {
    if (4 * a*b < (c - a - b)*(c - a - b)) {
      cout<<"Yes" << endl;
      x++;
    }
  }
  if (x == 0) {
  cout << "No" << endl;
  }
}

Measured memory_bytes: 3668
times = [int(input()) for _ in range(5)]

mod_min = 10
idx = 0
for i in range(5):
    mod = times[i] % 10
    if mod == 0:
        continue
    else:
        if mod < mod_min:
            idx = i
            mod_min = mod

ans = 0
for i in range(5):
    if idx == i:
        ans += times[i]
    else:
        if times[i] % 10 == 0:
            ans += times[i]
        else:
            ans += (times[i] // 10) * 10 + 10
print(ans)


Measured memory_bytes: 38384
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;

constexpr ll mod = 1000000007ll;

int main() {
    int n = 0;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    
    int cnt0 = 0;
    for (int x : a) {
        if (x == 0) {
            cnt0++;
        }
    }

    if (cnt0 > 3) {
        cout << 0 << endl;
        return 0;
    }

    ll color = (cnt0 == 1) ? 3 : 6;

    ll ans = 1;
    vector<ll> cur(1e5, 0);
    for (int i=0; i<n; i++) {
        if (a.at(i) == 0) {
            cur.at(0)++;
        } else {
            ans *= cur.at(a.at(i)-1) % mod;
            ans %= mod;
            cur.at(a.at(i))++;
            cur.at(a.at(i)-1)--;
        }
    }
    
    cout << ans * color % mod << endl;

    return 0;
}


Measured memory_bytes: 1408