akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=4e5+5;
const int mod=1e9+7;
struct node
{
	int l,r,sum,tag;
}no[maxn<<3];
struct line
{
	int l,r;
	friend bool operator<(const line x,const line y)
	{
		return (x.l!=y.l)?x.l<y.l:x.r<y.r;
	}
}e[maxn];
struct data
{
	int pos,v;
	friend bool operator<(const data x,const data y)
	{
		return x.v<y.v;
	}
}da[maxn];
void build(int x,int l,int r)
{
	no[x].l=l,no[x].r=r;no[x].tag=1;
	if(l==r)	return;
	int mid=l+r>>1;
	build(x<<1,l,mid);
	build(x<<1|1,mid+1,r);
}
void pushdown(int x)
{
	if(no[x].tag!=1)
	{
		int tg=no[x].tag;no[x].tag=1;
		no[x<<1].tag=(1ll*no[x<<1].tag*tg)%mod;
		no[x<<1|1].tag=(1ll*no[x<<1|1].tag*tg)%mod;
		no[x<<1].sum=(1ll*no[x<<1].sum*tg)%mod;
		no[x<<1|1].sum=(1ll*no[x<<1|1].sum*tg)%mod;
	}
}
void pushup(int x)
{
	no[x].sum=(1ll*no[x<<1].sum+no[x<<1|1].sum)%mod;
}
void cheng(int x,int l,int r)
{
	pushdown(x);
	if(no[x].l==l&&no[x].r==r)
	{
		no[x].sum=(1ll*no[x].sum*2)%mod;
		no[x].tag=(1ll*no[x].tag*2)%mod;
		return ;
	}
	int mid=(no[x].l+no[x].r)>>1;
	if(r<=mid)	cheng(x<<1,l,r);
	if(l>mid)	cheng(x<<1|1,l,r);
	else cheng(x<<1,l,mid),cheng(x<<1|1,mid+1,r);
	pushup(x);
}
void add(int x,int pos,int v)
{
	pushdown(x);
	if(no[x].l==no[x].r)	
	{
		no[x].sum=(1ll*no[x].sum+v)%mod;
		return ;
	}
	int mid=no[x].l+no[x].r>>1;
	if(pos<=mid)	add(x<<1,pos,v);
	else add(x<<1|1,pos,v);
	pushup(x);
}
int getsum(int x,int l,int r)
{
	pushdown(x);
	if(no[x].l==l&&no[x].r==r)	return no[x].sum;
	int mid=no[x].l+no[x].r>>1;
	if(r<=mid)	return getsum(x<<1,l,r);
	if(l>mid) return getsum(x<<1|1,l,r);
	else return (1ll*getsum(x<<1,l,mid)+getsum(x<<1|1,mid+1,r))%mod;
}
int init()
{
	char c=getchar();int t=0;
	while(c>'9'||c<'0')	c=getchar();
	while(c>='0'&&c<='9')	t=10*t+c-'0',c=getchar();
	return t;
}
int n,cnt,lmax[maxn],rmin[maxn],a[maxn];
void solve()
{
	sort(e+1,e+1+cnt);
	build(1,0,n);
	add(1,0,1);
	for(int i=1;i<=cnt;i++)
	{
		cheng(1,e[i].r,n);
		add(1,e[i].r,getsum(1,e[i].l-1,e[i].r-1));
	}
	cout<<getsum(1,n,n);
}
int getl(int l,int r,int x)
{
	if(l==r)	return l;
	if(r==l+1)
	{
		if(lmax[l]>x)	return l;
		else return r;	
	}
	int mid=l+r>>1;
	if(lmax[mid]>x)	return getl(l,mid,x);
	else return getl(mid+1,r,x);
}
int getr(int l,int r,int x)
{
	if(l==r)	return l;
	if(r==l+1)
	{
		if(rmin[r]<x)	return r;
		else return l;
	}
	int mid=l+r>>1;
	if(rmin[mid]<x)	return getr(mid,r,x);
	else return getr(l,mid-1,x);
}
int main()
{
	n=init();
	for(int i=1;i<=n;i++)	da[i].pos=init(),da[i].v=init();
	sort(da+1,da+1+n);
//	for(int i=1;i<=n;i++)	printf("%d %d\n",da[i].pos,da[i].v);puts("");
	for(int i=1;i<=n;i++)	lmax[i]=max(lmax[i-1],da[i].pos);
//	for(int i=1;i<=n;i++)	printf("%d ",lmax[i]);puts("");
	rmin[n+1]=1e9+7;
	for(int i=n;i>=1;i--)	rmin[i]=min(rmin[i+1],da[i].pos);
//	for(int i=1;i<=n;i++)	printf("%d ",rmin[i]);puts("");
//	return 0;
	for(int i=1;i<=n;i++)	e[++cnt].l=getl(1,i,da[i].pos),e[cnt].r=getr(i,n,da[i].pos);
//	for(int i=1;i<=cnt;i++)	printf("%d %d\n",e[i].l,e[i].r);
//	return 0;
	solve();
}

Measured memory_bytes: 27392
n = input()
h_list = [int(i) for i in input().split()]

h_0 = h_list[0]
count = 0
west = [0]

for i in h_list:
    if i >= h_0 and i >= max(west):
        count += 1
    h_0 = i
    west.append(i)

print(count)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define MAXN 200005
#define INT_SIZE 32
#define debug cout<<"we are debugging"<<endl;
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int main(){
	int n;
	cin>>n;
	ll a[n],xo=0;
	for(int i=0;i<n;i++)
     {
          cin>>a[i];
          xo^=a[i];
     }
     for(int i=0;i<n;i++)
     {
          cout<<(xo^a[i])<<" ";
     }
}


Measured memory_bytes: 5156
#include <iostream>

using namespace std;

class B {
	string s, ans;
public:
	void solve()
	{
		cin >> s;

		for (char c : s)
		{
			if (c == 'B')
			{
				if (ans.size() > 0)
					ans.pop_back();
			}

			else
				ans.push_back(c);
		}

		cout << ans << endl;
	}
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

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

#define pb push_back
#define eb emplace_back

using namespace std;

using vi = vector<int>;
using ll = long long;

int main(){
    ios :: sync_with_stdio(false);
    int n;
    int m[3][3];
    for(int i=0; i<3; ++i){
        for(int j=0; j<3; ++j){
            cin  >> m[i][j];
        }
    }
    // int a1=0, a2=0, a3=0, b1=0, b2=0, b3=0;

    int v[2][3] {101,101,101,101,101,101};
    int c=0;
    
    for(int i=0; i<6; ++i){
        if(!c){
            for(int j=0; j<3; ++j){
                v[c][i/2]=min(v[c][i/2], m[i/2][j]);
            }
            for(int j=0; j<3; ++j){
               m[i/2][j]-=v[c][i/2];
            }
        }else{
            for(int j=0; j<3; ++j){
                v[c][i/2]=min(v[c][i/2], m[j][i/2]);
            }
            for(int j=0; j<3; ++j){
               m[j][i/2]-=v[c][i/2];
            }
        }
        c=1-c;
    }

    bool ans=true;
     for(int i=0; i<3; ++i){
        for(int j=0; j<3; ++j){
            if(m[i][j]) {
               // cerr << i << " " << j << " = " << m[i][j] << endl;
                ans=false;
            }
        }
    }
    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}


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

int main(){
	int A, B, K;
	cin >> A >> B >> K;

	int ans = A;
	while (ans < B+1){
		if (ans < A+K || ans > B-K){
			cout << ans << endl;
		}
		ans++;
	}
}

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

using namespace std;
typedef long long int ll;

ll calc(ll n)
{
	ll sum = 7, st = 10;
	for(int i = 0; i < 1000000; i++)
	{
		if(sum % n == 0)
			return i + 1;
		sum = sum * 10;
		sum %= n;
		sum += 7;
		sum %= n;
	}
	return -1;
}

void solve()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int cnt = 0, cnt1 = 0;
	for(int i = 0; i < n; i++)
	{
		if(s[i] == 'R') cnt++;
	}
	for(int i = 0; i < cnt; i++) if(s[i] == 'R')cnt1++;
	cout << cnt - cnt1 << "\n";
}

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

Measured memory_bytes: 3732
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;

#define EPSILON 1.0e-12

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
};
//降順
bool compare_by_b_high(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
};
bool compare_by_b_higheer(tuple<string, int, int> a, tuple<string, int, int> b) {
    if(get<0>(a) != get<0>(b)){
      return get<0>(a) <get<0>(b);
    }else{
        if(get<1>(a) != get<1>(b)){return get<1>(a) > get<1>(b);}
        else{return get<2>(a) > get<2>(b);}
    }
};



int main(){
  int N;cin>>N;
  if(N<4){
    cout<<0<<endl;
    return 0;
  }
  string S;cin>>S;
  ll R_SUM=0;
  ll B_SUM=0;
  ll G_SUM=0;
  VL R(N,0);
  VL B(N,0);
  VL G(N,0);
  int tmp=0;
  ll count1=0;
  ll count2=0;
  for(int i=0;i<2000;i++){
    if(3+2*i>N){
      i--;
      tmp=i;
      break;
    }
  }
  for(int i=0;i<=tmp;i++){
    int last=3+2*i-1;
    int middle=2+i-1;
    int start=0;
    while(last<=N){
      if(S[start]=='R'&&S[middle]=='B'&&S[last]=='G'){
        count2++;
      }else if(S[start]=='R'&&S[middle]=='G'&&S[last]=='B'){
        count2++;
      }else if(S[start]=='B'&&S[middle]=='R'&&S[last]=='G'){
        count2++;
      }else if(S[start]=='B'&&S[middle]=='G'&&S[last]=='R'){
        count2++;
      }else if(S[start]=='G'&&S[middle]=='B'&&S[last]=='R'){
        count2++;
      }else if(S[start]=='G'&&S[middle]=='R'&&S[last]=='B'){
        count2++;
      }
      start++;
      middle++;
      last++;
    }
  }
  for(int i=0;i<N;i++){
    ll tmp1=0;
    if(S[i]=='R'){
      R_SUM++;

    }
    if(S[i]=='B'){
      B_SUM++;

    }
    if(S[i]=='G'){
      G_SUM++;

    }

  }
  count1=R_SUM*G_SUM*B_SUM;
  cout<<count1-count2<<endl;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int N;
string S;

bool check(int x) {
  set<string> cand;
  for (int i = 0; i < N-2*x+1; i++) {
    cand.insert(S.substr(i, x));
    if (cand.count(S.substr(i+x, x))) {
      return true;
    }
  }
  return false;
}

int main() {
  // 二分探索、substr
  cin >> N;
  cin >> S;
  ll ok = 0; ll ng = (N / 2) + 1;
  while (abs(ng-ok) > 1) {
    ll mid = (ok+ng) / 2;
    if (check(mid)) ok = mid;
    else ng = mid;
  }
  cout << ok << '\n';
  return 0;
}

Measured memory_bytes: 7600
a = int(input())
b = int(input())
c = int(input())
x = int(input())
counts = 0
for A in range(a + 1):
    for B in range(b + 1):
        for C in range(c + 1):
            if (500 * A + 100 * B + 50 * C) == x:
                counts += 1
print(counts)


Measured memory_bytes: 9108
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        char S[] = sc.next().toCharArray();
        
        int ans = 0;
        for( int i = 1; i < N; i++ ) {
            
            int anst = 0;
            boolean l[] = new boolean[26];
            boolean r[] = new boolean[26];
            
            
            for( int j = 0; j < i; j++ ) {
                int x = S[j] - 97;
                l[x] = true;
            }
            
            for( int k = i; k < N; k++ ) {
                int x = S[k] - 97;
                r[x] = true;
            }
            
            for( int x = 0; x < 26; x++ ) {
                if( l[x] && r[x] ) {
                    anst++;
                }
            }
            
            ans = Math.max(ans, anst);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35676
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<=n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
const int maxn = 10005;
#define ine long long
int dp[maxn],g[maxn];
int h,w;
const int mod = 1e9+7;
void gogo(){
    rep1(i,w){
        if(g[i]!=-1){
            if(dp[i]==-1)
                dp[i]=0;
            if(dp[i-1]!=-1){
                dp[i]+=dp[i-1];
                dp[i]%=mod;
            }
        }else{
            dp[i]=-1;
        }
    }
}

int32_t main(){
    IOS;
    cin>>h>>w;
    memset(dp,0,sizeof(dp));
    dp[1]=1;
    rep1(i,h){
        string str;
        cin>>str;
        rep1(j,w){
            if(str[j-1]=='#'){
                g[j]=-1;
            }
        }
        gogo();
        memset(g,0,sizeof(g));
    }
    cout<<dp[w]<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;

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


main(){
	int fx,fy;
	
	while(cin>>fx>>fy){
		if(fx==0 && fy==0)break;
		
		int x=1,y=1,dir=0;
		
		string com="";
		while(cin>>com){
			if(com=="STOP"){
				break;
			}else if(com=="FORWARD"){
				int k;
				cin>>k;
				x+=k*dx[dir];
				y+=k*dy[dir];
			}else if(com=="BACKWARD"){
				int k;
				cin>>k;
				x-=k*dx[dir];
				y-=k*dy[dir];
			}else if(com=="RIGHT"){
				dir=(dir+1)%4;
			}else if(com=="LEFT"){
				dir=(dir+3)%4;
			}
			
			if(x<1)x=1;
			if(y<1)y=1;
			if(x>fx)x=fx;
			if(y>fy)y=fy;
		}
		cout<<x<<" "<<y<<endl;
	}
}

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

int main(void){
    long long a, b, c;
    cin >> a >> b >> c;
    if(c-a-b>0 && 4*a*b<(c-a-b)*(c-a-b)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

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

	int N; cin >> N;
	vector<vector<char>> v(N, vector<char>(N));
	rep(i, 0, N) rep(j, 0, N) { cin >> v[i][j]; }

	int ans = 0;
	rep(a, 0, N) {
		bool ok = true;
		rep(i, 0, N) {
			rep(j, 0, N) {
				if (v[(i + a) % N][j] != v[(j + a) % N][i])
					ok = false;
			}
		}
		if (ok)ans += N;
		dump(a, ok);
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> ans(10001, 0);
    for (int i = 1; i < 100; i++) {
        for (int j = 1; j < 100; j++) {
            for (int k = 1; k < 100; k++) {
                int a = i * i + j * j + k * k + i * j + j * k + k * i;
                if (a <= 10000) {
                    ans.at(a)++;
                }
            }
        }
    }
    for (int i = 1; i <= N; i++) {
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
//typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
//define
#define rep(i,n) for(int i=0;i<n;i++)
////////////////////////////////////////////////////////////////////

int main(){
   int n,k;
   cin >> n >> k;
   vi d(k);

   int A[100][100];
   rep(i,100){
     rep(j,100){
       A[i][j] = 0;
     }
   }

   rep(i,k){
     cin >> d.at(i);
     rep(j,d.at(i)){
     cin >> A[i][j];
     }
   }

  vi b(n);
  rep(i,n){
    b.at(i)=i+1;
  }
  
   rep(i,k){
     rep(j,d.at(i)){
       rep(l,n){
       if(A[i][j] == b.at(l)) b.at(l) = 0;
       }
     }
   }

  int c = 0;
   rep(i,n){
     if(b.at(i) > 0){
       c++;
     }
   }
   cout << c << endl;

  return 0;
}

Measured memory_bytes: 3664
N = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    exit()
lim = 10**18

ans = 1
for i in A:
    ans *= i
    if ans > lim:
        print(-1)
        exit()

else:
    if ans >10**18:
        print(-1)
    else:
        print(ans)

Measured memory_bytes: 84696
def CountingSort(A, B, k):
    global n
    C = [0]*(k+1)
    for num in A:
        C[num] += 1
    for i in range(1,k+1):
        C[i] = C[i] + C[i-1]
    for j in range(n,0,-1):
        B[C[A[j-1]]-1] = A[j-1]
        C[A[j-1]] -= 1

n = int(input())
A = list(map(int, input().split()))
B = [-1]*n
CountingSort(A, B, max(A))
print(*B)


Measured memory_bytes: 224376
from collections import Counter

n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
C = c.most_common()
a = C[0][1]
ans = []
for i in range(len(c)):
  if C[i][1] == a:
    ans.append(C[i][0])

ans.sort()
print(*ans,sep="\n")

Measured memory_bytes: 50192
m,d = map(int,input().split())
ans = 0
for i in range(1,m+1):
    for j in range(1,d+1):
        if len(str(j)) == 2:
            a = int(str(j)[0])
            b = int(str(j)[1])
            if a >= 2 and b >= 2 and a * b == i:
                ans += 1
print(ans)


Measured memory_bytes: 3060
s_a = input()
s_b = input()
s_c = input()
x = s_a[0]
while( len(s_a) >= 0 and len(s_b) >=0 and len(s_c) >= 0):

    if x == 'a':
        x = s_a[0]
        s_a = s_a[1:]


    elif x == 'b':
        x = s_b[0]
        s_b = s_b[1:]

    elif x == 'c':
        x = s_c[0]
        s_c = s_c[1:]


    if x == 'a' and len(s_a) == 0:
        print('A')
        break
    if x == 'b' and len(s_b) == 0:
        print('B')
        break
    if x == 'c' and len(s_c) == 0:
        print('C')
        break


Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
    int x,y;
    while(1){
        scanf("%d %d",&x,&y);
        if(x==0&&y==0)break;
        else{
        if(x<y)printf("%d %d\n",x,y);
        else    printf("%d %d\n",y,x);
        }
    }
    return 0;
}


Measured memory_bytes: 2040
N=int(input())
V=list(map(int,input().split()))
C=list(map(int,input().split()))
def rescale(V,C):
  price=0
  for v,c in zip(V,C):
    if v>c:
      price=price+v-c
  return price 
print("{}".format(rescale(V,C)))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
int main(){
    std::vector<std::string> s;
    int h,w;
    std::cin>>h>>w;

    for(int i=0;i<h;++i){
        std::string t;
        std::cin>>t;
        t="#"+t+"#";
        s.push_back(t);
    }
    std::string t;
    for(int i=0;i<w+2;++i) t+="#";
    s.insert(s.begin()+0,t);
    s.push_back(t);

    for(int i=0;i<h+2;++i){
        for(int j=0;j<w+2;++j){
            std::cout<<s[i][j];
        }
        std::cout<<std::endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int bn;
	scanf("%d",&bn);

	const int n=bn;
	int a[n];

	int i,max=0,min=1000;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);

		if(a[i]>max)
			max=a[i];

		if(a[i]<min)
			min=a[i];
	}

	printf("%d\n",max-min);

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n;
int ar[100005];
int main(){
  cin>>n;
  REP(i,n){
    scanf("%d",&ar[i]);
  }
  sort(ar,ar+n);

  int lb=-1,ub=n;
  while(ub-lb>1){
    int md=(lb+ub)>>1;

    int one=0,tall=0;
    bool fail=false;
    dump(md);
    REP(i,n-md) if(ar[i]>md){
      if(ar[i]-md==1) ++one;
      else if(tall==0) tall=ar[i]-md;
      else fail=1;
      dump(i);
      dump(fail);
      dump(tall);
    }
    if(fail) lb=md;
    else ub=md;
  }
  dump(ub);
  {
    int one=0,tall=1;
    REP(i,n-ub) if(ar[i]>ub){
      if(ar[i]-ub==1) ++one;
      else tall=ar[i]-ub;
    }
    dump(one);dump(tall);

    int A,B=tall-1;
    if(tall!=1) A=one;
    else A=one-1;
    dump(A);dump(B);
    if(A%2==0 && B%2==0){
      puts("Second");
    }else{
      puts("First");
    }
  }
  return 0;
}




Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;

ll dfs(int K, const vector<vector<int>> &graph, int now, int from) {
	int can_use_color_num;
	if(from==-1) {
		can_use_color_num = K-1;
	} else {
		can_use_color_num = K-2;
	}

	if(K<graph[now].size()) { // 色が足りない．
		return 0;
	} else {
 		// P(K-2, c_x)
		ll case_num=1;
		for(auto e : graph[now]) {
			if(e==from) continue;
			case_num*=can_use_color_num;
			can_use_color_num--;
			case_num %= mod;
		}

		// それぞれの子の塗り方を再帰的に計算
		for(auto e : graph[now]) {
			if(e==from) continue;
			case_num *= dfs(K, graph, e, now);
			case_num %= mod;
		}

		return case_num;
	}

}

int main() {
	ll N, K;
	cin >> N >> K;
	vector<vector<int>> tree(N);
	rep(i, N-1) {
		int a, b;
		cin >> a >> b;
		tree[a-1].push_back(b-1);
		tree[b-1].push_back(a-1);
	}

	ll ans = K*dfs(K, tree, 0 , -1);
	ans %= mod;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 11520
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N, X;
    cin >> N >> X;
    vector<int> L(N);
    for (int n = 0; n < N; ++n) cin >> L[n];
    
    int n = 1;
    int pos = 0;
    while (n <= N) {
        pos += L[n-1];
        if (pos > X) break;
        else ++n;
    }
    cout << n << endl;
    
    return 0;
}


Measured memory_bytes: 256
n=int(input())
menu=list(map(int,input().split()))
man=list(map(int,input().split()))
ak=sum(man)
tuika=list(map(int,input().split()))
s=menu[0]
for i in menu[1:]:
  if i==s+1:
    ak+=tuika[s-1]
  s=i
print(ak)

Measured memory_bytes: 3064
#!/usr/bin/env perl

chomp($s=<STDIN>);
($n,$m,$x,$y, @x, @y)=split(/\s+/,$s);


chomp($s=<STDIN>);
@x=split(/ /,$s);

chomp($s=<STDIN>);
@y=split(/ /,$s);

$z=$y;
foreach $y (@y) {
  $z > $y and $z = $y;
}

$ok = 1;

foreach $x (@x, $x) {
  $x < $z or $ok = 0;
}


print (($ok ? "No " : "") . "War\n");



Measured memory_bytes: 512
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mini[2000];
int main()
{
	int num;
	ll gx;
	scanf("%d%lld",&num,&gx);
	vector<ll>v;
	for(int i=0;i<num;i++)
	{
		ll z;
		scanf("%lld",&z);
		v.push_back(z);
		mini[i]=z;
	}
	ll ans=1000000000000000000LL;
	for(int i=0;i<num;i++)
	{
		ll s=0;
		for(int j=0;j<num;j++)s+=mini[j];
		ans=min(ans,s+gx*i);
		for(int j=0;j<num;j++)mini[j]=min(mini[j],v[(j+num-i-1)%num]);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
x, y = map(int, input().split())
if y == 0:
    if x <= 0:
        print(abs(x))
    else:
        print(abs(x)+1)
elif x==0:
    if y < 0:
        print(-y+1)
    else:
        print(y)
elif x*y < 0:
    r = []
    x, y = sorted([x, y])
    r.append(abs(y-x))
    r.append(abs(y+x)+1)
    print(min(r))
elif x > y:
    print(abs(y-x)+2)
else:
    print(abs(y-x))

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
def PoAP_fnct(MOD):
    #MOD:素数
    fact_mod = [1,1]
    inv_mod = [0,1]
    inv_fact_mod = [1,1]
    i = len(fact_mod)
    i_ = len(inv_fact_mod)

    def PoAP(x,d,n):
        nonlocal i, i_
        if d == 0:
            return pow(x,n%(MOD-1),MOD)

        while d >= i_:
            inv_mod[i_:i_] = [(-inv_mod[MOD%i_]*(MOD//i_))%MOD]
            inv_fact_mod[i_:i_] = [(inv_fact_mod[i_-1]*inv_mod[i_])%MOD]
            i_ += 1

        j = (-x*inv_mod[d])%MOD
        if j < n:
            return 0

        x = (x*inv_mod[d])%MOD

        while (x+n-1)%MOD >= i:
            fact_mod[i:i] = [(fact_mod[i-1]*i)%MOD]
            i += 1

        while x-1 >= i_:
            inv_mod[i_:i_] = [(-inv_mod[MOD%i_]*(MOD//i_))%MOD]
            inv_fact_mod[i_:i_] = [(inv_fact_mod[i_-1]*inv_mod[i_])%MOD]
            i_ += 1

        return fact_mod[(x+n-1)%MOD] * inv_fact_mod[x-1] * pow(d,n%(MOD-1),MOD) % MOD
    return PoAP

def solve():
    Q = int(input())
    PoAP = PoAP_fnct(1000003)
    res = '\n'.join([str(PoAP(*map(int, input().split()))) for _ in range(Q)])
    return str(res)

if __name__ == '__main__':
    print(solve())



Measured memory_bytes: 129108
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int group[13] = {0,1,3,1,2,1,2,1,1,2,1,2,1};

  int a,b;

  scanf("%d%d",&a,&b);

  if(group[a] == group[b]){
    puts("Yes");
  }else{
    puts("No");
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int p_judge(int x) {
    int i=2;
    while(x>=i*i) {
        if(x%i==0)
            return 0;
        i++;
    }
    return 1;
}

int main(void) {
    int n, x, cnt=0;
    scanf("%d", &n);

    for(x=11; cnt<n; x+=10) {
        if(p_judge(x)==1) {
            printf("%d ", x);
            cnt++;
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;

#define ll long long
#define pal pair<long,long>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

long long pow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}
int main(){
    ll a,b,v,w,t;
    cin >> a >> v >> b>>w >>t;
    if(v<=w){
        cout <<"NO" << endl;
        return 0;
    }
    if(abs(a-b)<=t*(v-w)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3640
k = int(input())
a, b = [int(x) for x in input().split()]
i = 1
ans = "NG"
while True:
    n = k * i
    if n < a:
        i += 1
    elif n > b:
            break
    else:
        if a <= n <= b:
            ans = "OK"
            break
        i += 1
print(ans)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

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

  int a[6];
  rep(i, 5){
    cin >> a[i];
    if(a[i] == 0){
      cout << i + 1 << '\n';
    }
  }
  
  return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
int vis[105];
int main() {
	int n, s = 0, t;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &t);
		if(vis[t] == 0) {
			vis[t] = 1;
			s++;
		}
	}
	printf("%d\n", s);
	return 0;
}



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

int main(){
  int N, a, b, c, d;
  cin >> N;
  a = N / 1000;
  b = (N - a * 1000) / 100;
  c = (N - a * 1000 - b * 100) / 10;
  d = N % 10;
  if ( b == c){
    if ( b == a || b == d)
      cout << "Yes";
    else
      cout << "No";
  }
  else
    cout << "No";
  cout << endl;
}

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;
int deco[1000];

void Sequence() {
	bool prims[1000];
	for (int i = 0; i < 1000; i++)
	{
		prims[i] = true;
	}

	for (size_t i = 2; i * i < 1000; i++)
	{
		if (!prims[i]) continue;
		int ij = i * i;
		while (ij < 1000)
		{
			prims[ij] = false;
			ij += i;
		}
	}
	int n;
	cin >> n;
	for (int i = 2; i <= n; i++)
	{
		int v = i;
		for (int j = 2; j < 1000; j++)
		{
			if (!prims[j]) continue;
			while (v % j == 0)
			{
				deco[j]++;
				v /= j;
			}
		}
	}
	ll res = 1;
	for (size_t i = 0; i < 1000; i++)
	{
		if (deco[i] == 0) continue;
		res *= deco[i] + 1;
		res %= INF;

	}
	cout << res << endl;
}
int main() {
	Sequence();
	return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	G_fix
# CreatedDate:  2020-06-05 21:28:41 +0900
# LastModified: 2020-06-05 22:05:41 +0900
#


import os
import sys
from collections import deque
#import numpy as np
#import pandas as pd


def main():
    n,m = map(int,input().split())
    path = [[] for _ in range(n+1)]
    to_cnt = [0]*(n+1)
    longest_cnt = [0]*(n+1)
    for _ in range(m):
        x,y = map(int,input().split())
        path[x].append(y)
        to_cnt[y]+=1
    
    Q = deque()
    for i in range(1,n+1):
        if to_cnt[i]==0:
            Q.append(i)

#    longest_cnt[s]=1

    while(Q):
        u = Q.popleft()
        for v in path[u]:
            to_cnt[v]-=1
            if longest_cnt[u]+1>longest_cnt[v]:
                longest_cnt[v]=longest_cnt[u]+1
            if to_cnt[v]==0:
                Q.append(v)
    print(max(longest_cnt))



if __name__ == "__main__":
    main()


Measured memory_bytes: 23040
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int k;cin >> k;
    int s;cin >> s;
    int ans = 0;
    rep(x,k+1)rep(y,k+1){
        int z = s-x-y;
        if(z >= 0 && z <= k)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cmath>

const long double pi = 3.1415926535897932384626433832795;
const long double episilon = 1e-10;
const long double toRad = pi / 180;

int main()
{
    std::ios_base::sync_with_stdio(0);
    long double a,b,x;
    std::cin >> a >> b >> x;
    std::cout.precision(10);
    long double aa = atan2l(2*(a*b-x/a)/(a), a) / pi * 180;
    long double bb = atanl(2*x/a/b/b) / pi * 180;
    long double ah = b*cosl(aa*toRad);
    if (ah/sinl(aa*toRad) >= a) std::cout << std::fixed << aa;
    else std::cout << std::fixed << 90-bb;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

struct sieve
{
    int n;
    vector<int> f, primes;

    sieve(int n = 1) : n(n), f(n + 1)
    {
        for (int i = 2; i <= n; i++)
        {
            if (f[i])
                continue;
            primes.push_back(i);
            f[i] = i;
            for (ll j = i * i; j <= n; j += i)
            {
                if (!f[j])
                    f[j] = i;
            }
        }
    }

    bool isPrime(int x)
    {
        return f[x] == x;
    }

    vector<int> factorList(int x)
    {
        vector<int> res;
        while (x != 1)
        {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    vector<pair<int, int>> factor(int x)
    {
        auto fl = factorList(x);
        if (fl.size() == 0)
        {
            return {};
        }
        vector<P> res(1, P(fl[0], 0));
        for (int p : fl)
        {
            if (res.back().first == p)
            {
                res.back().second++;
            }
            else
            {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
};

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i += 2)
    {
        int f = 0;
        for (int j = 1; j <= n; j++)
        {
            if (i % j == 0)
            {
                f++;
            }
        }
        if (f == 8)
        {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int A, B;
int count_k = 0;
cin >> A >> B;

for(int i = A; i < B+1; i++){
    int n1,n2,n3,n4,n5;

    n1 = i  % 10;
    n5 = i / 10000;

    if(n1 != n5){
        continue;
    }else{
        n4 = i / 1000 - n5 * 10;
        n2 = (i % 100) / 10;
        if(n2 == n4){
            count_k++;
        } 
    }
}
cout << count_k << endl;

}

Measured memory_bytes: 3580
if __name__ == '__main__':
    N, H = map(int, input().split())
    values = [map(int, input().split()) for _ in range(N)]
    a, b = zip(*values)

    # N, H = 4, 1000000000
    # a = (1, 1, 1, 1)
    # b = (1, 10000000, 30000000, 99999999)

    # N, H = 5, 500
    # a = (35, 28, 46, 31, 40)
    # b = (44, 83, 62, 79, 43)

    a = sorted(a)
    b = sorted(b)

    n_attacks = 0
    latter_damage = 0
    while len(b) != 0 and a[-1] < b[-1]:
        n_attacks += 1
        latter_damage += b.pop()

        if H <= latter_damage:
            print(n_attacks)
            exit(0)

    a_max = a.pop()
    # remainder (0 or 1)
    r = int(bool((H - latter_damage) % a_max))
    n_attacks += r + (H - latter_damage) // a_max
    print(n_attacks)


Measured memory_bytes: 59860
def ini(): return int(input())
def inli(): return list(map(int, input().split()))
def inf(): return float(input())
def inlf(): return list(map(float, input().split()))
def inl(): return list(input())
def pli(): return "".join(list(map(str, ans)))

x=inli()
if (x[0]==7 and x[1]==5 and x[2]==5)or (x[0]==5 and x[1]==7 and x[2]==5)or(x[0]==5 and x[1]==5 and x[2]==7):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-7
#define f first
#define s second
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
const ll MOD = 1e9+7;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int random_int(int l,int r){return uniform_int_distribution<int>(l,r)(rng);}
ll fast_power(ll x, ll p){
    ll res = 1;
    while(p > 0){
        if(p & 1){
            res = (res * x);
        }
        p = p >> 1;
        x = (x*x);
    }
    return res;
}

int n,k;
int a[3005];
ll dp[3005][3005][2];

ll solve(int left, int right, int turn) {
    if (left > right) {
        return 0;
    }
    if (dp[left][right][turn] != LLONG_MAX)
        return dp[left][right][turn];
    ll ans = turn?min(solve(left, right-1,!turn) - a[right], solve(left + 1, right, !turn) - a[left])
    :max(solve(left, right-1,!turn) + a[right], solve(left + 1, right, !turn) + a[left]);
    return dp[left][right][turn] = ans;
}

int main() {
    IO;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < 3005; i++) {
        for (int j = 0; j < 3005; j++) {
            dp[i][j][0] = LLONG_MAX, dp[i][j][1] = LLONG_MAX;
        }
    }
    cout << solve(0,n - 1,0);
    return 0;
}


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

int main() {
	string s;
	cin >> s;
	int n = s.size();
	long long ans = 0;
	for (int i = 0;i < 1 << n - 1; i++) {
		long long num = s[0] - '0';
		for (int j = 0;j < n - 1;j++) {
			if (i & (1 << j)) {
				ans += num;
				num = 0;
			}
			num = num * 10 + s[j + 1] - '0';
		}
		ans += num;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int     long long
#define F       first
#define S       second
#define _READ   freopen("input.txt","r", stdin);
#define _FAST   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
void solve()
{
    int a,b;
    cin>>a>>b;
    cout<<a*b;
}
int32_t main()
{
    clock_t tStart = clock();
    // #ifndef ONLINE_JUDGE
    // _READ
    // #endif
    _FAST    
    int t;
    t=1;
    while(t--)
        solve();
    
    #ifndef ONLINE_JUDGE
    cout<<fixed<<setprecision(5)<<"\nTime taken: "<<(double)(clock() - tStart)/CLOCKS_PER_SEC;
    #endif
    
    return 0;
}
/*
===FOR N-Dimensional Vector===
https://codeforces.com/blog/entry/76149
g++ -std=c++17 -Wshadow -Wall -g -fsanitize=address -fsanitize=undefined a.cpp -o a -D_GLIBCXX_DEBUG
*/

Measured memory_bytes: 3636
program main
character*4 :: s
integer :: x=0,i,j
 
read*, s
do i=1,4
do j=1,4
if(s(i:i) == s(j:j)) then
	x = x + 1
end if
end do
end do
if (x==8) then
print*, "Yes"
else 
print*, "No"
end if
 
end program main

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	mochi := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&mochi[i])
	}
	
	sort.Sort(sort.Reverse(sort.IntSlice(mochi)))

	var count = 0

	for i := 1; i < n; i++ {
		if mochi[i] == mochi[i-1] {
			continue
		}
		count++
	}

	fmt.Println(count + 1)
			
}



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

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < 19; ++i) {
    if (n < (1 << (i+1))) {
      cout << (1<<i) << endl;
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b=0,n=0,d=0,f=0;
  string c;
  cin>>c;
  for(int i=0;i<c.size();i++){
    if(c[i]=='N') n=1;
    if(c[i]=='S') b=1;
    if(c[i]=='W') f=1;
    if(c[i]=='E') d=1;
  }
  if(n==1&&b==1&&f==d||f==1&&d==1&&n==b||n==0&&b==0&&f==0&&d==0) cout<<"Yes";
  else cout<<"No";
  cout<<"\n";}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;

vector<int> p;
vector<vector<pair<long long, long long> > > g;
vector<char> used; 

void dfs(long long v, int c){
    p[v] = c;
    used[v] = true;
    for(auto i: g[v]){
        if(!used[i.first]){
            if(!(i.second % 2)) dfs(i.first, c);
            else dfs(i.first, !c);
        } 
    }
}

int main(){
    long long n, fr, to, w;
    cin >> n;
    g.resize(n + 1);
    used.assign(n + 1, false);
    p.resize(n + 1);
    for(int i = 0; i < n - 1; ++i){
        cin >> fr >> to >> w;
        g[fr].push_back(make_pair(to, w));
        g[to].push_back(make_pair(fr, w));
    }
    dfs(1, 0);
    for(int i = 1; i <= n; ++i) cout << p[i] << endl;
}

Measured memory_bytes: 8960
from collections import Counter

n = int(input())
v = [int(x) for x in input().split()]

v1 = Counter(v[0::2]).most_common() + [(0, 0)]
v2 = Counter(v[1::2]).most_common() + [(0, 0)]

if v1[0] != v2[0]:
    res = n - v1[0][1] - v2[0][1]
else:
    res = min(n - v1[0][1] - v2[1][1], n - v1[1][1] - v2[0][1])

print(res)


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

ll dp[300][4][4][4] = {0};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll n;
  cin >> n;
  "AGCT";
  ll P = 1000000007;
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 4; j++)
      for (int k = 0; k < 4; k++) {
        if ((i == 0 && j == 1 && k == 2) || (i == 0 && j == 2 && k == 1) ||
            (i == 1 && j == 0 && k == 2))
          continue;
        dp[3][i][j][k] = 1;
      }
  for (int id = 3; id < n; id++) {
    for (int i = 0; i < 4; i++)
      for (int j = 0; j < 4; j++)
        for (int k = 0; k < 4; k++)
          for (int l = 0; l < 4; l++) {
            if ((j == 0 && k == 1 && l == 2) || (j == 0 && k == 2 && l == 1) ||
                (j == 1 && k == 0 && l == 2))
              continue;
            if ((i == 0 && j == 1 && l == 2) || (i == 0 && k == 1 && l == 2))
              continue;
            dp[id + 1][j][k][l] += dp[id][i][j][k];
            dp[id + 1][j][k][l] %= P;
          }
  }
  ll ans = 0;
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 4; j++)
      for (int k = 0; k < 4; k++) {
        ans += dp[n][i][j][k];
        ans %= P;
      }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
<?php
list($w, $a, $b) = ints();
if ($b > $a + $w) {
    echo $b - ($a + $w);
} elseif ($a > $b + $w) {
    echo $a - ($b + $w);
} else {
    echo '0';
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 4604
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

ll gcd(ll x,ll y){
    if(y==0) return 0;
    return gcd(y,x%y);
}

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
ll se=0;
ll sume(vector<int> a,int n){

}
int main(){
    string s;cin>>s;
    bool c=false,f=false;
    for(int i=0;i<(int)s.size();i++){
        if(s[i]=='C') c=true;
        if(s[i]=='F'&&c) f=true;
    }
    if(f){
        cout<<"Yes"<<endl;
    }else cout<<"No"<<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 one = N%10;
      	if(one==0||one==1||one==6||one==8) System.out.println("pon");
      	else if(one==3) System.out.println("bon");
      	else System.out.println("hon");
    }
}

Measured memory_bytes: 35600
N = int(input())
numList = list(map(int, input().split()))
product = 1
toPrint = True
isZero = False
for j in numList:
    if j == 0:
        isZero = True
if not isZero:
    for i in numList:
        product = product * i
        if product > 10**18:
            toPrint = False
            break
if isZero:
    print(0)
else:
    if toPrint:
        print(product)
    else:
        print(-1)

Measured memory_bytes: 21712