akhauriyash/Code-Regression huggingface dataset:
S = input()
ans = 0

for b in range(2**(len(S)-1)):
    opes = []
    for k in range(len(S)-1):
        if b & (1 << k):
            opes.append('+')
        else:
            opes.append('')
    formula = ''.join([d + o for d,o in zip(S,opes)])
    ans += eval(formula + S[-1])
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
  int i,sum;
  char num[1001];
 
  for(;;){
    scanf("%s", &num);
    if(num[0] == '0') break;
     
    sum = 0;
    for(i=0;num[i]!='\0';i++)
      sum += num[i] - '0';
    printf("%d\n", sum);
  }
   
  return 0;
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int count;
  int check = 0;
  int answer;
  
  for (int i = 1; i < N + 1; i++) {
    count = 0;
    int a = i;
    for (int j = 1; j < 8; j++) {
      if (a % 2 == 0) {
        a /= 2;
        count++;
      }
      else {
        break;
      }
    }
    if(count >= check) {
      check = count;
      answer = i;
    }
  }
  cout << answer << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
#define VI vector<int>
#define VL vector<LL>
#define VII vector< vector<int> >
#define VLL vector< vector<LL> >
#define VS  vector<string>
#define VSS vector< vector<string> >
#define PII pair<int,int>
#define PIS pair<int,string>
#define PSI pair<string,int>
#define PLL pair<LL,LL>
const LL MOD = 1000000007;
const LL INF = 1e16;
LL facctorialMethod(int k);
int main(){
    LL a,b,kuti,total;
    cin >> a >> b;

    kuti = b - a;
    if(b==1){
        cout << 0 << endl;
        return 0;
    }
    if(kuti <= 0){
        cout << 1 << endl;
        return 0;
    }
    total = kuti / (a-1) + 1;
    if(kuti%(a-1) >= 1){
        total += 1;
    }
    cout << total << endl;

    return 0;
}

LL facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i){
        sum *= i;
    }
    return sum;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<ll, ll>
#define to second
#define cost first
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    int n; ll a, b;
    int A[100005];

    cin >> n >> a >> b;
    for(int i = 1; i <= n; i++) cin >> A[i];

    ll ans = 0;
    for(int i = 2; i <= n; i++)
        ans += min((A[i]-A[i-1])*a, b);
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
def main():
    a,b = map(int,input().split())
    s = input()

    if s[a] != '-':
        return 'No'

    for p in [s[0:a],s[a+1:]]:
        for c in p:
            if not c.isdigit():
                return 'No'

    return 'Yes'

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


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

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  string S;
  cin >> S;
  if (S == "AAA" || S == "BBB")
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}


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

#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef pair < int , int > pp;
const int mod = 1e9 + 7;
const int N   = 2e5 + 5;

vector < int > V[33];
int T[33],W[33],H[N],X[N],XX[N],F[N],n,i,tek,x,r,rr,zz;
char A[N];
long long ans;

int main(){
    cin >> A+1;
    n = strlen(A+1);
    for(i=1;i<=n;i++) { A[i] -= 'a'; T[ A[i] ]++; }
    tek = -1;
    for(i=0;i<26;i++){
        if(T[i] & 1){
            if(tek != -1) { cout << -1; return 0; }
            tek = i;
            T[i]--;
        }
        T[i] >>= 1;
    }
    
    for(i=1;i<=n/2;i++){
        x = A[i]; W[x]++; 
        H[i] = W[x] > T[x] ? 1 : -1;
        if(x == tek && W[x] == T[x]+1) H[i] = 0;
    }
    if(n&1){
        x = A[i];
        if(x == tek){
            if(W[x] < T[x]) H[i] = -1;
            else H[i] = W[x] == T[x] ? 0 : 1;
        }
        else H[i] = W[x] >= T[x] ? 1 : -1;
    } 
    memset(W , 0 , sizeof W);
    for(i=n; i>(n+1>>1) ;i--){
        x = A[i]; W[x]++; 
        H[i] = W[x] > T[x] ? -1 : 1;
        if(x == tek && W[x] == T[x]+1) H[i] = 0;
    }
    
    zz = 0;
    for(i=1;i<=n;i++){
        if(H[i] == 1) X[++r] = A[i];
        if(H[i] < 1) ans += r;    
        if(H[i] == -1) ans += zz;
        zz |= H[i] == 0;
    }
    for(i=n; i ;i--) if(H[i] == -1) XX[++rr] = A[i];
    
    if(r != rr) assert(0);
    for(i=r ;i; i--) V[ X[i] ].pb(i); 
    for(i=1;i<=r;i++){
        x = XX[i];
        H[ V[x].back() ] = i;
        V[x].pop_back();
    }
    for(i=r; i ;i--){
        for(x=H[i] ;x; x -= x&-x) ans += F[x];
        for(x=H[i] ;x <= r; x += x&-x) F[x]++;
    }

    
    cout << ans;
    return 0;
}


Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define INF 1000000000
int h,w;
vector<vector<int>> c(10,vector<int>(10,0));
vector<vector<int>> A;

/*方針*/
//➀iから1に行くまでの消費魔力の総和のうち最小のものを探す(dfsで全探索→再帰を用いる)
//➁iが0～9まで➀を求める(一次元配列にiから1に行くためにかかる最小値を求める)
//➂h*wの二次元配列について,要素が-1でないものに対して、➁を使って総和を求める

int ans=INF;
int dfs(int a,vector<bool> &visit,int sum){//今aまで到達　visit今までに訪れた数字はtrue  sum今のところの消費魔力
    if(a==1){
        return sum;//1にたどり着いたら終わり
    }
    
    for(int i=0;i<=9;i++){
        //すでに訪れたところには行かない ex)5->9->7->5->2->1の場合5->9->7が余計であり最小値になり得ないので除く
        if(!visit[i]){
            visit[i]=true;//今訪れた
            ans=min(ans,dfs(i,visit,sum+c[a][i]));//sumにa->iにかかる魔力を加算してdfs
            visit[i]=false;//pop_back的な役割 ex)5->9->7->3で3を探索し終わったら5->9->7->4と探索したい
                           //もしvisit[3]をfalseにしないと5->9->7->4と探索しているのに3も訪れたという判定になる
        }
    }
    return ans;//1に行くまでの最小消費魔力
}

int main(){
    int i,j,k;
    cin>>h>>w;
    vector<int> change_to_one(10,0);//数字iから1へ変換するのにかかる最小コスト
    A.assign(h,vector<int>(w,0));
    for(i=0;i<=9;i++){
        for(j=0;j<=9;j++){
            cin>>c[i][j];
        }
    }
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            cin>>A[i][j];
        }
    }

    for(i=0;i<=9;i++){//i->1への最小消費魔力を計算
        vector<bool> visit(10,false);
        ans=INF;
        visit[i]=true;
        change_to_one[i]=dfs(i,visit,0);//i->1のMIN
    }

    int answer=0;
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            if(A[i][j]!=-1){
                answer+=change_to_one[A[i][j]];
            }
        }
    }

    cout<<answer<<endl;
    return 0;
}

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

const ll INF = 1000000000000000;

int main()
{
    ll n, ws;
    cin >> n >> ws;
    ll w[102];
    ll v[102];
    ll vlar = 0;
    for(int i = 0; i < n; i++){
        cin >> w[i] >> v[i];
        vlar = max(vlar, v[i]);
    }
    ll dp[100002];
    fill(dp, dp + 100002, INF);
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = vlar * n; j >= v[i]; j--){
            dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
        }
    }
    int ans = 0;
    for(int j = 0; j <= vlar * n; j++){
        if(dp[j] <= ws) ans = max(ans, j);
    }
    cout << ans << endl;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int px[100000];
int py[100000];
int a[100000];

int main() {
   int H, W, D;
   cin >> H >> W >> D;
   rep (i, H) {
      rep (j, W) {
         int A;
         cin >> A;
         px[A] = j, py[A] = i;
      }
   }

   for (int i = D+1; i <= H*W; i++) {
      a[i] = a[i-D] + abs(px[i] - px[i-D]) + abs(py[i] - py[i-D]);
   }

   int Q;
   cin >> Q;
   while (Q--) {
      int l, r;
      cin >> l >> r;
      cout << a[r] - a[l] << endl;
   }

   return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>
int abst(int);
int main() {
	int n;
	scanf("%d",&n);
	int t[n+1],x[n+1],y[n+1];
	t[0] = 0; x[0] = 0; y[0] = 0;
	for(int i = 1;i <= n;i++) scanf("%d %d %d",&t[i],&x[i],&y[i]);
	int dt,dx,dy,check = 0;
	for(int i = 0;i < n;i++) {
		 dt = t[i+1] - t[i]; dx = abst(x[i+1] - x[i]); dy = abst(y[i+1] - y[i]);
		 if(dt < dx + dy || dt % 2 != (dx + dy) % 2) {
		 	check = 1;
		 	break;
		 }
	}
	if(check == 1) printf("No");
	else printf("Yes");
	return 0;
}

int abst(int n) {
	if(n >= 0) return n;
	else return -1* n;
}

Measured memory_bytes: 1280
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<iostream>
using namespace std;
int a[200010],b[200010];
inline int readin(void)
{
	int sum = 0;
	int sign = 1;
	char ch = getchar();
	while(ch > '9' || ch < '0')
	{
		if(ch == '-')
		{
			sign = -1;
		}
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9')
	{
		sum = sum*10+ch-'0';
		ch = getchar();
	}
	return sum*sign;
}
int main()
{
	int n;
	cin>>n;
	int count=0,t=1;
	for(int i=1;i<=n;i++)
		a[i]=readin();
		for(int i=1;i<=n;i++)
		{
			if(a[i]==t)
			{
				count++;
				t++;
			}
		}
	sort(a,a+n);
	if(a[1]!=1)
	{
		cout<<-1;
		return 0;
	}
	cout<<n-t+1;
	return 0;
}

Measured memory_bytes: 1024
// void call(int n){
//   int i = 1;
//  CHECK_NUM:
//   int x = i;
//   if ( x % 3 == 0 ){
//     cout << " " << i;
//     goto END_CHECK_NUM;
//   }
//  INCLUDE3:
//   if ( x % 10 == 3 ){
//     cout << " " << i;
//     goto END_CHECK_NUM;
//   }
//   x /= 10;
//   if ( x ) goto INCLUDE3;
//  END_CHECK_NUM:
//   if ( ++i <= n ) goto CHECK_NUM;

//   cout << endl;
// }

#include <iostream>
using namespace std;

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

    for(int i = 1; i <= n; i++) {
        if (i % 3 == 0) printf(" %d", i);
        else if (i % 10 == 3) printf(" %d", i);
        else {
            flag = true;
            int a = i;
            while (flag) {
                a = a/10;
                if (a%10 == 3) {
                    printf(" %d", i);
                    flag = false;
                }
                else if(a == 0) {
                    flag = false;
                }
            }
        }
    }
    cout << endl;
}


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

int  main()
{
	int n; cin >> n; //L+i−1
	int l ; cin >> l;
	int deli[n+1];
	int sum = 0;
	rep1(i, n)
	{
		deli[i] = l+i-1;
		sum += deli[i];
	}
	int ans = INT_MAX;
	rep1(i, n)
	{
		ans = min(abs(sum - (sum-deli[i])), ans);
		// cout << deli[i] << endl;
	}
	if (sum < 0)
		cout << sum + ans << endl;
	else
		cout << sum - ans << endl;
	return (0);
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	double R;
	cin >> R;
	cout << 2*R*M_PI << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


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

using namespace std;

int main()
{

	string a, b;
	
	cin >> a;
	cin >> b;
	

	for(int i = 0; i < a.size(); i++)
	{
		if(a[i] != b[i])
		{
			cout << "No";
			return 0;
		}
	}
	
	cout << "Yes";
}
	
	

Measured memory_bytes: 3596
//*****Jai Mata di*****//

#include<bits/stdc++.h>
using namespace std;
#define Nitroboost  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int 
const int MOD=1e9+7;
const int N=2e5+15;
#define pb push_back
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;


int main()
{
    Nitroboost;
    int n;
    cin>>n;
    cout<<n+n*n+n*n*n;
}
    

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

int main() {
    int n, t;
    cin >> n >> t;
    vector<int> sum(t+1, 0);
    while (n--) {
        int l, r;
        cin >> l >> r;
        sum[l]++;
        sum[r]--;
    }
    
    for (int i = 0; i <= t; i++) sum[i+1] += sum[i];
    cout << *max_element(sum.begin(), sum.end()) << endl;
    return 0;
}


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

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

#include <iostream>
int main() {
  int n, m; cin >> n >> m;
  if(n==1&&m==1){
    cout << 0 << endl;
  }
  if(n==1&&m==2){
    cout << 1 << endl;
  }
  if(n==2&&m==1){
    cout << 1 << endl;
  }
  if (n==0){
    cout << combination(m,2) << endl;
  }
  if(m==0){
    cout << combination(n,2) << endl;
  }
  if(n>=2&&m>=2){
    cout << combination(n,2) + combination(m,2) << endl; 
  }
}

Measured memory_bytes: 256
#include<stdio.h>
 int main(void)
 {
     char S[25];
     int i;

     scanf("%s",S);

     for(i=0;i<5;i++)
       printf("%c",S[i]);
         printf(" ");

     for(i=0;i<7;i++)
       printf("%c",S[i+6]);
         printf(" ");

     for(i=0;i<5;i++)
       printf("%c",S[i+14]);
         printf("\n");

     return 0;
 }


Measured memory_bytes: 128
"""
author : halo2halo
date : 15, Jan, 2020
"""

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

A, B = map(int, readline().split())
print(A + B if B % A == 0 else B - A)


Measured memory_bytes: 14316
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;
using ll=long long;

#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define REP1(i, n)  for(int i = 1; i < (int)n; ++i)
#define REPll1(i, n)  for(ll i = 1; i*i < (int)n; ++i)

int cnt(ll n) {
    int c = 0;
    while (true) {
        if (n < 1)break;
        n = n / 10;
        c++;
    }
    return c;
}

const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const ll mod = 1e9 + 7;
const ll MAX1E5 = 100000;
const ll MAX1E10 = 10000000000;
const ll MAX1E15 = 1000000000000000;

int main() {
    int N, M;
    ll a = 0, x, y, sum = 0, allSum, tmp;
    string ans = "IMPOSSIBLE";
    cin >> N >> M;
    vector<ll> X(N), Y;
    REP(i, M) {
        cin >> x >> y;
        if (x == 1 && y == N) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
        if (x == 1)Y.push_back(y);
        if (y == N)X[x]=1;
    }

    for (auto v : Y) {
        if(X[v]==1){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt int Q[100005]={0}
#define mp make_pair
#define test() int t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<int>()) 
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(int i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(int i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=mpowe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
int logtwo(int n){if(n==1)return 0;return logtwo(n/2)+1;}
vector <int> v[200005] ;   //Vector for maintaining adjacency list explained above
int level[200005];
bool vis[200005]; //Mark the node if visited 
void bfs(int s) 
{
    queue <int> q;
    q.push(s);
    level[ s ] = 0 ;  //Setting the level of the source node as 0
    vis[ s ] = true;
    while(!q.empty())
    {
        int p = q.front();
        q.pop();
        for(int i = 0;i < v[ p ].size() ; i++)
        {
            if(vis[ v[ p ][ i ] ] == false)
            {
        //Setting the level of each node with an increment in the level of parent node
                level[ v[ p ][ i ] ] = level[ p ]+1;                 
                 q.push(v[ p ][ i ]);
                 vis[ v[ p ][ i ] ] = true;
            }
        }
    }
}
int main()
{
    fastio();
   /* #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    ll n,a,b;
    cin>>n>>a>>b;
    ll na=1,nrn=1;
    for(ll i=1;i<=a;i++)
    {
        na=(na*i)%MOD;
    }
    for(ll i =n;i>=n-a+1;i--)
    {
        nrn = (nrn*i)%MOD;
    }
    ll nca = (nrn*mpowe(na,MOD-2)%MOD)%MOD;
    na =1;
    nrn=1;
    for(ll i=1;i<=b;i++)
    {
        na=(na*i)%MOD;
    }
    for(ll i =n;i>=n-b+1;i--)
    {
        nrn = (nrn*i)%MOD;
    }
    ll ncb = (nrn*mpowe(na,MOD-2)%MOD)%MOD;
    //cout<<ncb<<endl;
    ll ans = (mpowe(2,n)-1-nca-ncb+2*MOD)%MOD;
    cout<<ans<<endl;
}
 

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

int main(){

 	#ifndef ONLINE_JUDGE
 	freopen("input.txt", "r", stdin);
 	freopen("output.txt", "w", stdout);
 	#endif

 	long long a[100000];
 	int n,zero=0;
 	cin>>n;
 	for (int i = 0; i <n; ++i)
 	{
 		cin>>a[i];
 		if(a[i]==0){
 			zero++;
 		}
 	}
 	if(zero>0){
 		cout<<"0";
 		exit(0);
 	}
 	long long m=1;
 	for (int i = 0; i < n; ++i)
 	{
 		if(a[i]<=1000000000000000000/m){
 			m=m*a[i];
 		}
 		else{
 			cout<<"-1";
 			exit(0);
 		}
 	}
 	cout<<m;
 	return 0;
}

Measured memory_bytes: 4444
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>

using namespace std;

int data[30] = {};
int data2[30] = {};

int main(){
    string S;
    cin >> S;

    for(size_t i = 0; i < S.size(); ++i){
        data[int(S[i] - 'a')]++;
    }

    int ans = -1;
    for(int i = 0; i < 26; ++i){
        if(data[i] == 0){
            ans = i;
            break;
        }
    }

    if(ans == -1){
        int pos = -1;
        for(size_t i = S.size() - 2; i >= 0; --i){
            if(S[i + 1] > S[i]){
                pos = i;
                break;
            }
        }
        if(pos == -1){
            cout << -1 << endl;
        } else {
            for(size_t i = 0; i <= pos; ++i){
                data2[int(S[i] - 'a')]++;
            }
            int plus = 0;
            for(int i = 0; i < 26; ++i){
                if(data2[i] == 0 && int(S[pos] - 'a') < i){
                    plus = i;
                    break;
                }
            }
            cout << S.substr(0, pos) << char('a' + plus) << endl;
        }
    } 
    else {
        cout << S << char('a' + ans) << endl;
    }
}

Measured memory_bytes: 256
s = int(input())
i = 1
a = [s]
while 1:
    if a[i-1] % 2 == 0:
        a.append(a[i-1] / 2)
    else:
        a.append(3 * a[i-1] + 1)
    if a[i] in a[0:i]:
        print(i+1)
        break
    i += 1


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

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

    int a, e, tmp, k;
    cin >> a >> tmp >> tmp >> tmp >> e >> k;

    cout << (e - a <= k ? "Yay!" : ":(") << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort()
A.reverse()

A = A + [0, 0, 0, 0, 0]
sum = 0
for i in range(N//2 + 2):
  sum = sum + A[i*2] - A[i*2 + 1]
  
print(sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                                               \
  ifstream in("atcoder-problems/codefestival_2016_qualA_c.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string S;
  ll K;
  cin >> S >> K;
  int N = S.size();

  rep(i, N) {
    if (S[i] == 'a') continue;
    int n = 26 - (S[i] - 'a');
    if (n <= K) {
      S[i] = 'a';
      K -= n;
    }
  }
  if (K > 0) {
    K = K % 26;
    S[N - 1] += K;
  }

  cout << S << endl;
}

Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n, k, t[100010];
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> t[i];
    
    vector<int> interval;
    int sum = 0;
    for (int i = 0; i < n - 1; i++) {
        if (t[i + 1] > t[i] + 1) {
            interval.push_back(t[i + 1] - t[i] - 1);
            sum += t[i + 1] - t[i] - 1;
        }
    }
    
    int ans = t[n - 1] - t[0] + 1 - sum;
    sort(interval.begin(), interval.end());
    
    if (interval.size() >= k)
    for (int i = 0; i <= interval.size() - k; i++) {
        ans += interval[i];
    }
    
    cout << ans << endl;
    
}



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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);
  
  for (int i; i<N; i++){
    cin >> A.at(i);
  }
  for (int i; i<N; i++){
    cin >> B.at(i);
  }
  for (int i; i<N-1; i++){
    cin >> C.at(i);
  }
  int tmp=-1;
  int s = 0;
  for(int a:A){
    if (tmp==a-1){
      s+=C.at(a-2);
    }
    s+=B.at(a-1);
    tmp=a;
  }
  cout << s << endl;
  
}

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

#ifdef LOCAL
	#define D(a) cerr << #a << " = " << a << endl
#else
	#define D(a)
	#define cerr false && cerr
#endif
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) dforsn(i,0,n)
#define forn(i,n) forsn(i,0,n)
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first
#define endl '\n'
using pii = pair<int,int>;
using vi = vector<int>;
using ll = long long;

int main() {
	fastio;
	
    int n,m;
    cin >> n >>m;
    vi odds;
    vi even;
    vi* v[2] ={&even,&odds};
    forn(i,m){
        int a;
        cin >> a;
        v[a%2]->pb(a);
    }
    if(si(odds)<=2){
        if(!odds.empty()){
            even.insert(even.begin(),odds.back());
            odds.pop_back();
        }
        if(!odds.empty()){
            even.insert(even.end(),odds.back());
            odds.pop_back();
        }
        forn(i,si(even))cout << even[i] << " \n"[i==m-1];
        if(si(even)==1)even.pb(0);
        cout << si(even)-(even.front()==1) << endl;
        if(even.front()>1)cout << even.front()-1 << " ";
        forsn(i,1,si(even)-1)cout << even[i] << " ";
        cout << even.back()+1 << endl;
        
    }
    else cout << "Impossible" << endl;

	
	return 0;
}



Measured memory_bytes: 256
#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 <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

const LL MOD = 1e9 + 7;

LL dp[100005][13] = {{0}};

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    reverse(ALL(s));
    LL sz = s.size();

    dp[0][0] = 1;
    LL mul = 1;
    REP(i,sz){
        if(s[i] == '?'){
            REP(c, 10){
                REP(j, 13){
                    dp[i+1][(c * mul + j) % 13] += dp[i][j];
                }
            }
        }
        else {
            LL c = s[i] - '0';
            REP(j, 13){
                dp[i+1][(c * mul + j) % 13] += dp[i][j];
            }
        }
        mul = (mul * 10) % 13;
        REP(j,13)dp[i+1][j] %= MOD;
    }

    PUTS(dp[sz][5]);
}


Measured memory_bytes: 10704
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define double long double
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 2147483647
#include <math.h> /* M_PI */
/*
全探索を高速でさせるならDP
DPのキーに集合を持たせる。　DP[S]=S(宝箱)を全て開けられる鍵の買い方の最小コスト
*/
int main()
{
    int data = 0;
    rep(i, 5)
    {
        int a;
        cin >> a;
        if (a != i + 1)
        {
            cout << i + 1;
            data = i + 1;
            break;
        }
    }
    for (int i = data; i < 5; i++)
    {
        int a;
        cin >> a;
    }
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG minpro2019/a.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    if(2 * k - 1 <= n){
        cout << "YES" << "\n";
    }else{
        cout << "NO" << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
from heapq import heappop,heappush
q=[]
d=0
r=0
for i in range(N):
    if A[i]<B[i]:
        r+=1
        d+=B[i]-A[i]
    elif A[i]>B[i]:
        heappush(q,B[i]-A[i])
while d>0 and len(q)>0:
    d+=heappop(q)
    r+=1
print(-1 if d>0 else r)

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


int main(){

  int n;
  cin >> n;

  int num;
  int ans=0;
  for(int i=0;i<n;i++){
    cin >> num;
    if(i%2==0 && num%2==1) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 1e5+5;
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	cout<<min(a*b,c)<<endl;
	return 0; 
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  char A, B, C, D;
  cin >> A >> B >> C >> D;
  int count=0;
  if(A==B||A==C||A==D) count++;
  if(B==C||B==D) count++;
  if(C==D) count++;
  
  if(count==2) cout << "Yes" << endl;
  else if(count!=2) cout << "No" << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

static const double eps = 10e-8;

struct DATA{
	int size;
	int weight;
	int fare;
};

int main(){
	struct DATA data[6] = {
		60,2,600,
		80,5,800,
		100,10,1000,
		120,15,1200,
		140,20,1400,
		160,25,1600,
	};

	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;

		int sum=0;
		for(int i=0;i<n;i++){
			int x,y,h,w;
			scanf("%d %d %d %d",&x,&y,&h,&w);
			int size = x+y+h;
			for(int i=0;i<6;i++){
				if(size <= data[i].size
					&& w <= data[i].weight){
						sum += data[i].fare;
						break;
				}
			}
		}
		printf("%d\n",sum);
	}
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin>>s;
    int hagu=0,x;
    if(s.size()%2 == 1){
        x = (s.size()-1)/2;
    }
    else{
        x = s.size()/2;
    }
    for(int i=0; i<x; i++){
        if(s[i] != s[s.size()-1-i]){
            hagu++;
        }
    }
    cout<< hagu <<endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.nextLine();
        long sum = 0;
        int len = n.length();
        for(int i = 0;i<len;i++){
            sum += (int)n.charAt(i) - '0';
        }
        //System.out.println(sum);
        if(sum % 9 == 0)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

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

int main() {
    int h, w;
    while(1) {
        cin >> h >> w;
        if (h == 0 && w == 0) {
            break;
        } else {
            for (int j = 0; j < w; j++) {
                cout << "#";
            }
            cout << endl;
            for (int i = 1; i < h - 1; i++) {
                cout << "#";
                for (int j = 1; j < w - 1; j++) {
                    cout << ".";
                }
                cout << "#" << endl;
            }
            for (int j = 0; j < w; j++) {
                cout << "#";
            }
            cout << endl << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3104
/**
    BISMILLAH
    @Author : Arham
*/
#include <bits/stdc++.h>
using namespace std;

void solve() {
    long long x, y, a, b, c, d;
    cin >> a >> b >> c >> d;
    long long one, two, three, four;
    one = a * c;
    two = a * d;
    three = b * c;
    four = b * d;
    long long fin = max(max(one, two), max(three, four));
    cout << fin << endl;

    return;
}

int main() {
    int t = true;
    //cin >> t;
    while(t--)
        solve();

    return 0;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

namespace std {
	#define u(x, a, b) for(ll x = a; x < b; x++)
	#define d(x, a, b) for(ll x = a; x > b; x--)
}

typedef long long ll;
typedef long double ld;

#define MAXI 100010
#define MOD 1000000007

int main(){
	ll n, k, tp;
	cin >> n >> k;
	
	deque<ll> a;
	u(one, 0, n){cin >> tp; a.push_back(tp);}
	sort(a.begin(), a.end());
	
	ll prod = 1;
	
	if(k%2 && a[n-1]>=0){
		prod = a[n-1];
		a.pop_back();
		k--; 
	}
	else if(k%2){
		u(one, 0, k){
			prod*=a[n-1-one];
			prod%=MOD;
			prod+=MOD;
			prod%=MOD;
		}
		k=0;
	}
	//cout << k << endl;
	while(k){
		ll x = a.size();
		ll loprod = a[0]*a[1];
		ll hiprod = a[x-1]*a[x-2];
		
		if(loprod>hiprod){
			loprod%=MOD;
			prod*=loprod;
			prod%=MOD;
			prod+=MOD;
			prod%=MOD;
			a.pop_front();
			a.pop_front();
		}
		else{
			hiprod%=MOD;
			prod*=hiprod;
			prod%=MOD;
			prod+=MOD;
			prod%=MOD;
			a.pop_back();
			a.pop_back();
		}
		
		k-=2;
	}
	
	cout << prod;
}


Measured memory_bytes: 5236
import java.util.*;
 
 
import java.io.*;
public class Main {
public static void main (String[]args){
    String val = "";
    Scanner in = new Scanner(System.in);
    String input = in.nextLine();    // get the entire line after the prompt 
    String[] numbers = input.split(" "); // split by spaces
    val = numbers[0] + numbers[1] + numbers[2];
   if(Integer.parseInt(val)%4==0) {
       System.out.println("YES");
   }
   else{
       System.out.println("NO");
   }
}
}


Measured memory_bytes: 19924
import java.util.Arrays;
import java.util.Scanner;

//Magic Slayer
public class Main{

	void run(){
		int INF = 1<<29;
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			int[] hp = new int[n];
			for(int i=0;i<n;i++)hp[i]=sc.nextInt();
			Arrays.sort(hp);
			int maxhp = hp[n-1];
			int m = sc.nextInt();
			int sn = 0, an = 0;
			int[] singleD = new int[m];
			int[] singleM = new int[m];
			int[] allD = new int[m];
			int[] allM = new int[m];
			for(int i=0;i<m;i++){
				sc.next();
				int mp = sc.nextInt();
				boolean f = "Single".equals(sc.next());
				int d = sc.nextInt();
				if(d==0)continue;
				if(f){
					singleD[sn] = d;
					singleM[sn] = mp;
					sn++;
				}
				else{
					allD[an] = d;
					allM[an] = mp;
					an++;
				}
			}
			int[] sdp = new int[maxhp+1];
			Arrays.fill(sdp, INF);
			sdp[0] = 0;
			if(sn>0){
				for(int d=1;d<=maxhp;d++)sdp[d] = ((d-1)/singleD[0]+1)*singleM[0];
				for(int i=1;i<sn;i++){
					for(int d=1;d<=maxhp;d++){
						if(d-singleD[i]<=0)sdp[d] = Math.min(sdp[d], singleM[i]);
						else sdp[d] = Math.min(sdp[d], sdp[d-singleD[i]]+singleM[i]);
					}
				}
			}
			int[] adp = new int[maxhp+1];
			Arrays.fill(adp, INF);
			adp[0] = 0;
			if(an>0){
				for(int d=1;d<=maxhp;d++)adp[d] = ((d-1)/allD[0]+1)*allM[0];
				for(int i=1;i<an;i++){
					for(int d=1;d<=maxhp;d++){
						if(d-allD[i]<=0)adp[d] = Math.min(adp[d], allM[i]);
						else adp[d] = Math.min(adp[d], adp[d-allD[i]]+allM[i]);
					}
				}
			}
//			debug(sdp);
//			debug(adp);
			int min = INF;
			for(int d=0;d<=maxhp;d++){
				int mp = adp[d];
				for(int i=0;i<n;i++){
					mp += sdp[Math.max(0, hp[i]-d)];
					if(INF<=mp){
						mp = INF;
						break;
					}
				}
				min = Math.min(min, mp);
			}
			System.out.println(min);
		}
	}
	
	void debug(Object...o){
		System.out.println(Arrays.deepToString(o));
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

int main() {
    // get values from input
    cin.tie(0);
    ios::sync_with_stdio(false);

    double R;
    READ(R);
    
    // main procedure


    // output
    WRITE(R*2.0d*M_PI);
    

    return 0;
}


Measured memory_bytes: 3800
n,k=map(int,input().split())
s=list(input())
ct=0
for i in range(n-1):
  if s[i]=='R' and s[i+1]=='L':
    ct+=2
if s[0]=='L':ct+=1
if s[-1]=='R':ct+=1
ans=n-ct
print(min(ans+2*k,n-1))

Measured memory_bytes: 4084
#include<iostream>

using namespace std;

int main(){
	int N;

	cin >> N;

	for (int i = 0; i < N; i++){
		int  b = 1, c = 1;
		int num[10];
		int B[11] = { 0 }, C[11] = { 0 };
		bool flag = false;
		

		for (int i = 0; i < 10; i++){
			cin >> num[i];
		}

		for (int i = 0; i < 10; i++){
			if (B[b-1] < num[i]){
				//cout << "B" << B[b-1] << ' '<< num[i]<< endl;
				B[b] = num[i];
				b++;
			}
			else{
				//cout << "C" << C[c - 1] << ' ' << num[i] << endl;
				if (C[c-1] < num[i]){
					C[c] = num[i];
					c++;
				}
				else{
					flag = true;
					break;
				}

			}
		}

		if (flag == false) cout << "YES" << endl;
		if (flag == true) cout << "NO" << endl;
	}
}
		

Measured memory_bytes: 1152
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,x=map(int,input().split())
    L=list(map(int,input().split()))
    D=[0]*(n+1)
    for i in range(n):
        D[i+1]=D[i]+L[i]
    print(sum(D[i]<=x for i in range(n+1)))
resolve()

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

#define REP(i,x) for(int (i)=0; i<(int)(x); i++)

const int inf = 1000000007;
vector <int> g[100010];
long long dp[100010][10];
bool used[100010];

void dfs(int x) {
	if(used[x] == true) return;
	used[x] = true;
	dp[x][0] = dp[x][1] = 1;
	REP(i,g[x].size()) {
		int tmp = g[x][i];
		if(used[tmp] == false) {
         	dfs(tmp);
         	dp[x][0] = (dp[x][0]%inf*(dp[tmp][0]%inf+dp[tmp][1]%inf))%inf;
        	dp[x][1] = (dp[x][1]%inf*dp[tmp][0]%inf)%inf;
        }
	}
}

int main(void) {
	int N;
	cin >> N;
	REP(i,N-1) {
		int x,y;
		cin >> x >> y;
		x--; y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	dfs(0);
	cout << (dp[0][0]+dp[0][1])%inf << endl;
	return 0;
}


Measured memory_bytes: 19200
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();

        int count = 0;
        for (int i = 0; i < s.length() - 1; i++) {
            if (s.charAt(i) != s.charAt(i + 1)) {
                count++;
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 23636
#include<stdio.h>
#define MAX 1000

void insertionSort(int *,int);

main(){
  int i,n,a[100];
  
  scanf("%d",&n);
  
  for(i=0;i < n;i++){
    scanf("%d",&a[i]);
  }
  
  for(i=0;i < n-1;i++){
    printf("%d ",a[i]);
  }   
  printf("%d\n",a[n-1]);
  
  
  insertionSort(a,n);
  
  return 0;
}
void insertionSort(int *a,int n){
  int i,j,q,v;
  
  for(i = 1;i < n;i++){
    v = a[i];
    j = i - 1;
    while(j >= 0 &&a[j] > v){
      a[j + 1] = a[j];
      j--;
      a[j+1] = v;
    }
    for(q=0;q < n-1;q++){
      printf("%d ",a[q]);
    }   
    printf("%d\n",a[q]);
  }
}

Measured memory_bytes: 600
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] a = new int[N];
        HashMap<Integer,Integer> count = new HashMap<>();
        for(int i=0; i<N; i++){
            a[i] = scanner.nextInt();
            int c = count.getOrDefault(a[i], 0);
            count.put(a[i], ++c);
        }
        long allpair = 0;
        for(int i:count.keySet()){
            int val = count.get(i);
            if(val>0){
                allpair += (long)val*((long)val-1)/2;
            }
        }
        for(int i=0; i<N; i++){
            int num = a[i];
            if(count.get(num)>1){
                System.out.println(allpair - (count.get(num)-1));
            }else{
                System.out.println(allpair);
            }
        }
    }
}

Measured memory_bytes: 126464
import java.util.Scanner;
 
public class Main {
 
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int L = sc.nextInt();
sc.close();
 
int ans = 0;
if (L >= 0) {
  for (int i = 2; i <= N; i++) {
    ans += (i + L - 1);
  }
} else if (-L >= N) {
  for (int i = 1; i <= N - 1; i++) {
    ans += (i + L - 1);
  }
} else {
 for (int i = 1; i <= N; i++) {
    ans += (i + L - 1);
  }
}

System.out.println(ans);
}
}

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

#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

const int N = (int) 1e5;
const int INF = (int) 1e9 + 7;

int main(int argc, char *argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string s, t;
	cin >> s >> t;
	bool ok = true;
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] != t[i]) ok = false;
	}
	cout << (ok ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>
#include<array>
#include<cassert>
#include<list>

using namespace std;

#define SPEEDY cin.tie(0);ios::sync_with_stdio(false);

#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)

#define DEB(X) if(mode==1)cout<< #X <<": "<<X<<" ";
#define DEB2(X) if(mode==1)cout<<X<<" ";
#define ARDEB(i,X) if(mode==1)cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define FORDEB(n,X) if(mode==1)for(int i=0;i<(n);i++)ARDEB(i,X)
#define END if(mode==1)cout<<endl;

typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
struct P2{int x,y;};
//struct edge{int from,cost,to;};

const int MOD7=1000000007;
const int INF=100000000;
int mode=0;

int main(){
	string s;
	cin>>s;
	REP(i,s.size()){
		if(i%2==0){
			cout<<s[i];
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 512
dp=[[0 for _ in range(1001)]for _ in range(11)]
dp[0][0]=1
for i in range(101):
    for j in range(9,-1,-1):
        for k in range(1001-i):
            dp[j+1][k+i]+=dp[j][k]
while 1:
    n,s=map(int,input().split())
    if n==0:break
    print(dp[n][s])

Measured memory_bytes: 7932
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(void){

  ll n;
  cin>>n;
  list<ll> a;

  rep(i,n){
    ll tmp;
    cin>>tmp;
    a.pb(tmp);
  }

  a.sort();
  //auto itr=a.begin();

  while(a.size()>1){

    ll _min=*a.begin();

    auto itr=a.begin();
    while(itr != a.end()){
      itr++;
      if(itr == a.end()) break;
      ll num=*itr;
      *itr = num%_min;
    }

    a.sort();

    while( *a.begin()==0 ){
      a.pop_front();
    }

  }
  cout << *a.begin()<< endl;

  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
const long long int lim = 1000000000000000000ll;
int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	bool exceed = false, zero = false;
	long long int x, ans = 1;
	for (int i = 0; i < n; ++i)
	{
		cin>>x;
		if (!x)
		{
			zero = true;
			break;
		}
		if (!exceed && x > lim / ans)
		{
			exceed = true;
		}
		ans*=x;
	}
	if (zero)
	{
		cout<<0<<"\n";
		return 0;
	}

	if (exceed)
	{
		cout<<-1<<"\n";
		return 0;
	}
	
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3644
package main

import (
	"fmt"
)

func abs(i int) int {
	if i < 0 {
		return -i
	}
	return i
}

func main() {
	var n, sum int
	fmt.Scan(&n)
	a := make([]int, n)
	d := make([]int, n+1)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		if i == 0 {
			d[0] = abs(a[0])
			sum = d[0]
			continue
		}
		d[i] = abs(a[i] - a[i-1])
		sum += d[i]
	}
	d[n] = abs(a[n-1])
	sum += d[n]

	for i := 0; i < n; i++ {
		if i == 0 {
			fmt.Println(sum - d[0] - d[1] + abs(a[1]))
			continue
		}
		if i == n-1 {
			fmt.Println(sum - d[i+1] - d[i] + abs(a[i-1]))
			continue
		}
		fmt.Println(sum - d[i] - d[i+1] + abs(a[i-1]-a[i+1]))
	}
}


Measured memory_bytes: 6528
n, m = gets.split.map(&:to_i)
s = gets.chomp

s.reverse!

pos = 0
plst = [0]
for i in 1..n
    if s[i] == '0'
        pos = i
    end
    if i - plst[-1] >= m or i == n
        if plst[-1] == pos
            puts -1
            exit
        end
        plst << pos 
    end
end

ans = []
(plst.size-1).times do |i|
    ans << plst[i+1] - plst[i]
end

puts ans.reverse.join(" ")


Measured memory_bytes: 17196