akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 

#define  rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i>=0; i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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

int main (void) {
  int N, M; std::cin >> N >> M;
  std::vector<P> W(N);
  for(int i=0; i<N; i++) std::cin >> W[i].first >> W[i].second;
  
  std::sort( all(W), [](P &x, P &y) { return x.first < y.first; });

  int ans = 0;
  int k = 0;
  std::priority_queue<int, std::vector<int>, std::less<int>> pq;
  for(int m=1; m<=M; m++) {
    for(;k<N;k++) {
      if ( W[k].first <= m ) pq.push(W[k].second);
      else break;
    }
    if ( !pq.empty() ) {
      ans += pq.top();
      pq.pop();
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 1660
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
anm=[list(map(int,input().split())) for _ in range(n)]

a = []
ans = 0

for i in range(n):
    a = anm[i]
    num = 0
    for j in range(m):
        num += a[j]*b[j]
    if num+c > 0:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int N_MAX = 10;
int main()
{
  string s,t;
  cin >> s;
  int res=0,tmp;
  int n=s.length();
  int a[N_MAX];
  for(int i=0;i<n;i++){
    t=s.substr(i,1);
    if(t=="A"||t=="C"||t=="G"||t=="T")
      a[i]=1;
    else
      a[i]=0;
  }
  for(int i=0;i<n;i++){
    if(a[i]==0) continue;
    tmp=1;
    for(int j=i+1;j<n;j++){
      if(a[j]==0) break;
      tmp++;
    }
    if(tmp>res) res=tmp;
  }
 cout << res << endl;
  return 0;
}

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

//data types
typedef long long ll;
typedef long li;
typedef int ii;
typedef float ff;
typedef double dd;
typedef long double pp;
typedef vector<int> vi;
typedef pair<int,int> pi;

//vector and pair components
#define f first
#define s second
#define push_back pb
#define make_pair mp

//loops
#define for1(i,v,m) for(i=v;i<=m;i++)
//#define rev(v,x,z) for(v=x;v>=z;v--)
//#define inf(m,j,k) for(m=j;m>=k;m++)

ii main()
{

    ll x,i,l=100;

    cin>>x;
    
    
    for(i=1;i>0;i++)
    {
    
        l=l+(l/100);
        
        if(l>=x)
        {
          
            break;
            
            
        }
        
        
    }
   
    
    
    cout<<i<<"\n";
    
    
}


Measured memory_bytes: 3652
def resolve():
    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    T = list(input())

    score = {'r':  P, 's': R, 'p': S}

    ans = 0
    for i in range(K):
        ans += score[T[i]]

    for i in range(K, N):
        if T[i-K] == T[i]:
            T[i] = ' '
            continue
        ans += score[T[i]]

    print(ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 4084
import sys

def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))


n = inp()
S = inpl()
q = inp()
T = inpl()

S.sort()
T.sort()

# 先頭インデックスを返す
#   存在しなかった場合はどうする？
def binary_search(num):
    left = 0
    right = n-1
    while right - left > 1:
        mid = (right + left) // 2
        if S[mid] >= num:
            right = mid
        else:
            left = mid
    if S[right] == num:
        return right
    else:
        return -1

def dup_count(idx):
    for i in range(idx, n-1):
        if S[idx] == S[i]:
            pass
        else:
            break
    return i - idx + 1

ans = 0
for i in T:
    idx = binary_search(i)
    if idx >= 0:
        ans += 1
        # ans += dup_count(idx)
print(ans)


Measured memory_bytes: 16712
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let m: usize = read();
    let q: usize = read();
    let lr: Vec<(usize, usize)> = (0..m).map(|_| (read(), read())).collect();
    let pq: Vec<(usize, usize)> = (0..q).map(|_| (read(), read())).collect();

    let mut citys = vec![vec![0; 502]; 502];

    for &(l, r) in lr.iter() {
        citys[l][r] += 1;
    }

    for i in 0..502 {
        for j in 0..501 {
            citys[i][j + 1] += citys[i][j];
        }
    }

    for &(p, q) in pq.iter() {
        let mut sum = 0;
        for i in p..q + 1 {
            sum += citys[i][q] - citys[i][p - 1];
        }
        println!("{}", sum);
    }
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

typedef long long ll;

ll N;
vector<ll> A;
ll Res = 1ll << 60;

int main() {
  cin >> N;
  A.resize(N);
  for (ll i = 0; i < N; ++i) cin >> A[i];
  for (bool positive_start : {true, false}) {
    ll res = 0, sum = 0;
    for (ll i = 0; i < N; ++i) {
      if ((i == 0 && positive_start) || sum < 0) {
        sum += A[i];
        if (sum <= 0) {
          res += 1 - sum;
          sum = 1;
        }
      } else {
        sum += A[i];
        if (sum >= 0) {
          res += sum - (-1);
          sum = -1;
        }
      }
    }
    Res = min(Res, res);
  }
  cout << Res << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <string>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int n; cin >> n;
    long long array[n]; for(int i = 0; i<n; ++i)cin >> array[i];
    long long min1 = 0;
    long long sum1 = 0;
    for(int i = 0; i<n; ++i){
        sum1 += array[i];
        if(i%2 == 0){
            if(sum1 <= 0){
                min1 += abs(sum1)+1;
                sum1 += abs(sum1)+1;
            }
        }else{
            if(sum1 >= 0){
                min1 += abs(sum1)+1;
                sum1 -= abs(sum1)+1;
            }
        }
    }
    long long  min2 = 0;
    long long sum2 = 0;
    for(int i = 0; i<n; ++i){
        sum2 += array[i];
        if(i%2 == 1){
            if(sum2 <= 0){
                min2 += abs(sum2)+1;
                sum2 += abs(sum2)+1;
            }
        }else{
            if(sum2 >= 0){
                min2 += abs(sum2)+1;
                sum2 -= abs(sum2)+1;
            }
        }
    }
    cout << min(min1, min2) << endl; return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

void swap(int *a1, int *a2) {
    int tmp = *a1;
    *a1 = *a2;
    *a2 = tmp;
}

struct pair3 {
    int64_t a;
    int64_t b;
    int64_t c;
};

#define INF (1e+9)

#define min3(a,b,c) min(min(a,b),c)
#define max3(a,b,c) max(max(a,b),c)
int64_t calc_diff(struct pair3 p) {
    return max3(p.a, p.b, p.c) - min3(p.a, p.b, p.c);
}

int cut_hw(struct pair3 *out, int height, int width) {
    // height is bigger
    int64_t hlow = height/3;
    int64_t hhigh = height/3 + 1;
    int64_t wlow = width/2;
    int64_t wrem = width - width/2;
    int cidx = 0;
    int64_t hrem = height-hlow;
    out[cidx++] = (struct pair3){hlow*width, wlow*hrem, wrem*hrem};
    hrem = height - hhigh;
    out[cidx++] = (struct pair3){hhigh*width, wlow*hrem, wrem*hrem};
    return cidx;
}


int main(void) {
    int height, width;
    get_int2(&height, &width);
    int64_t ans = INF;
    if(height < width) swap(&height, &width);
    // cut the same way
    ans = (height%3==0 || width%3==0) ? 0 : width;

    struct pair3 cands[10];
    int cidx = 0;
    cidx += cut_hw(cands, height, width);
    cidx += cut_hw(&cands[cidx], width, height);

    int i;
    for(i = 0; i < cidx; i++) {
#ifdef DEBUG
        printf("%d, %d, %d, %d\n", cands[i].a, cands[i].b, cands[i].c, calc_diff(cands[i]));
#endif
        ans = min(ans, calc_diff(cands[i]));
    }
    printf("%lld\n", ans);
    return 0;
}

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

int main(void){
  
  char a, b, c, d; cin >> a >> b >> c >> d;

	if( a == b || b == c || c == d){

      cout << "Bad" << endl;
      
    }else{
      
      cout << "Good" << endl;
      
    }

return 0;

}


Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/


int main() {

ll D,N;
cin>>D>>N;
if(N!=100){
  cout<<(ll)powl(100,D)*N<<endl;
}
else{
cout<<(ll)powl(100,D)*(101)<<endl;
}






return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define pi pair<int,int>
#define endl "\n"
#define MAXN 100005
using namespace std;

int n,x;
map<int,int> m;

void solve()
{
    cin>>n;
    for(int i=1;i<n;i++)
    {
    	cin>>x;m[x]++;
    }
    for(int i=1;i<=n;i++) cout<<m[i]<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    solve();
}


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

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll)x.size()
#define hell            2019
#define inf             (ll)1e18 + 5
#define PI              (double)3.14159265358979323844
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741


ll expo(ll base, ll exponent) {                     //return base^exponent modulo hell
    ll ans = 1;
    while(exponent !=0 ) {
        if((exponent&1) == 1) {
            ans = ans*base ;
            ans = ans%hell;
        }
        base = base*base;
        base %= hell;
        exponent>>= 1;
    }
    return ans%hell;
}

ll add(ll a,ll b) {
	return ((a%hell)+(b%hell))%hell;
}
ll sub(ll a,ll b) {
	return ((a%hell)-(b%hell)+hell)%hell;
}
ll mul(ll a,ll b) {
	return ((a%hell)*(b%hell))%hell;
}

void solve() {
    string s;
    cin>>s;
    ll n=sz(s);
    mii m;
    ll temp=0;
    m[0]++;
    repr(i,n,0){
    	temp=add(temp,mul(s[i]-'0',expo(10,n-i-1)));
    	m[temp]++;
    }
    ll ans=0;
    for (auto i:m){
    	ans+=(i.S*(i.S-1))/2;
    }
    cout<<ans<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 3744
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio> 
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rangeRep(i, n, m) for(int (i) = (n); (i) < (m); (i)++)

int canGo[100001] = {0};

class Solve {
public:
	Solve() {};
	~Solve() {};

	void solver() {
		int ans = 0;
		int n;
		std::cin >> n;
		std::vector<std::pair<int, int>> friends(n, std::make_pair(0, 0));
		rep(i, n) {
			std::cin >> friends[i].first >> friends[i].second;
			//Exclude myself
			friends[i].first--; friends[i].second--;
		}
		//Record the number of people who can go.
		for (auto& x : friends) {
			canGo[x.first]++;
			canGo[x.second + 1]--;
		}
		//fill
		rangeRep(i, 1, n + 1) {
			canGo[i] += canGo[i - 1];
		}
		int max = 0;
		rep(i, n+1) {
			if (canGo[i] >= i) {
				max = i;
			}
		}
		std::cout << max << std::endl;
	}
private:

};

int main() {
	Solve solve;
	solve.solver();
	return 0;
}

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

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

    int A, B, K;
    cin >> A >> B >> K;

    for(int i = 0; i < K; i++){
        int t;
        if(!(i % 2)){
            if(A % 2){
                A--;
            }
            t = A / 2;
            A /= 2;
            B += t;
        }else{
            if(B % 2){
                B--;
            }
            t = B / 2;
            B /= 2;
            A += t;
        }
    }
    cout << A << " " << B << endl;

    return 0;
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int x = Integer.parseInt(str[0]);
		int y = Integer.parseInt(str[1]);

		for (int i = 0; i <= x; i++) {
			int count = i * 2 + (x - i) * 4;

			if (count == y) {
				System.out.println("Yes");
				return;
			}
		}

		System.out.println("No");
	}
}


Measured memory_bytes: 32584
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
int main() {
	ll A[3];
	cin >> A[0] >> A[1] >> A[2];
	if (A[0] + A[1] + A[2]<=21) {
		cout << "win";
	}else{
		cout << "bust";
	}
	
	
}

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

int main()
{
	//AGCACG
	string input, sub;
	int max = 0;
	cin >> input;
	for (char x : input)
	{
		if (x == 'A' || x == 'C' || x == 'G' || x == 'T')
			sub += x;
		else 
		{
			if (sub.length() > max)
			{
				max = sub.length();
			}
			sub.clear();
		}
	}
	if (sub.length() > max)
	{
		max = sub.length();
	}
	cout << max << endl;
	return 0;
}

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

int main()
{
	int N;
	cin >> N;
	bool yellow = false;
	for (int i = 0; i < N; i++)
	{
		char c;
		cin >> c;
		if (c == 'Y')
			yellow = true;
	}

	if (yellow)
		cout << "Four" << endl;
	else
		cout << "Three" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
int n;
int a[100010];
int main() { 
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	bool ok=1;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]%2==0){
			if(a[i]%3!=0 && a[i]%5!=0)ok=0;
		}
	}
	if(ok)cout<<"APPROVED"<<endl;
	else cout<<"DENIED"<<endl;
    return 0; 
}/*
*/

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
using namespace std;
const double PI = 3.1415926535897932;
int main() {
  int r = 0;
  cin >> r;
  double res = PI * 2 * r;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define inf (int)(3e18)
#define P pair<int,int>
#define mod (int)(1e9+7)

template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}

int N,M;
int S,T;
vector<P>G[100005];
vector<int>dis1,ans1,dis2,ans2;
void dijkstra(int s,vector<int>&dis,vector<int>&ans){
	dis.resize(N,inf);ans.resize(N,0);
	dis[s]=0;ans[s]=1;
	priority_queue<P,vector<P>,greater<P>>que;
	que.push({0,s});
	while(!que.empty()){
		P p=que.top();que.pop();
		if(dis[p.second]<p.first)continue;
		for(P e:G[p.second]){
			if(dis[e.first]==p.first+e.second){
				ans[e.first]+=ans[p.second];
				ans[e.first]%=mod;
			}else if(dis[e.first]>p.first+e.second){
				dis[e.first]=p.first+e.second;
				ans[e.first]=ans[p.second];
				que.push({dis[e.first],e.first});
			}
		}
	}
}
signed main() {
	cin>>N>>M>>S>>T;S--;T--;
	rep(i,M){
		int a,b,c;cin>>a>>b>>c;a--;b--;
		G[a].push_back({b,c});
		G[b].push_back({a,c});
	}
	dijkstra(S,dis1,ans1);
	dijkstra(T,dis2,ans2);
	int ans=ans1[T]*ans2[S]%mod;
	rep(i,N){
		if(dis1[i]+dis2[i]!=dis1[T])continue;
		if(dis1[i]==dis2[i]){
			ans-=ans1[i]*ans1[i]%mod*ans2[i]%mod*ans2[i]%mod;
			ans=(ans+mod)%mod;
			continue;
		}
		for(P e:G[i]){
			if(dis1[i]+e.second+dis2[e.first]!=dis1[T])continue;
			if(dis1[e.first]==dis2[e.first])continue;
			if(dis1[e.first]<dis2[e.first]||dis2[i]<dis1[i])continue;
			ans-=ans1[i]*ans1[i]%mod*ans2[e.first]%mod*ans2[e.first]%mod;
			ans=(ans+mod)%mod;
		}
	}
	cout<<ans<<endl;
}


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

int N, A, B, used[100], rings[100]; vector<int> G[100];
 
int rec(int pos)
{
    used[pos] = true; int ret = 1;
     
    for(int i = 0; i < rings[pos]; i++)
    {
        if(!used[G[pos][i]])
        {
            ret = max(ret, rec(G[pos][i]) + 1);
        }
    }
     
    used[pos] = false;
     
    return ret;
}
 
int main()
{
    int N, A, B;
     
    while(true)
    {
        scanf("%d", &N);
         
        if(N == 0) { break; }
 
        for(int i = 0; i < 100; i++)
        {
            used[i] = false;
            rings[i] = 0;
            G[i].clear();
        }
     
        for(int i = 0; i < N; i++)
        {
            scanf("%d", &A); A--;
            scanf("%d", &B); B--;
         
            G[A].push_back(B);
            G[B].push_back(A);
        }
         
        for(int i = 0; i < 100; i++)
        {
            rings[i] = G[i].size();
        }
         
        int nodes = 0;
         
        for(int i = 0; i < 100; i++)
        {
            if(rings[i])
            {
                nodes++;
            }
        }
     
        int ret = 0;
     
        for(int i = 0; i < 100; i++)
        {
            ret = max(ret, rec(i));
                 
            if(ret == nodes) { break; }
        }
         
        printf("%d\n", ret);
    }
     
    return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

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

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,k; cin>>n>>k;
  vll a(n);
  rep(i,n) cin>>a[i];
  ll ans=(n-1+k-2)/(k-1);
  cout<<ans<<endl;
}

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

int main() {
    ios::sync_with_stdio(false);
    int N, K;
    while (cin >> N >> K && (N || K)) {
        vector<int> S(K);
        for (int i=0; i<K; ++i) cin >> S[i];
        int t;
        bool ok = true;
        for (int i=0; i<N; ++i) {
            for (int j=0; j<K; ++j) {
                cin >> t;
                if (ok) {
                    S[j] -= t;
                    if (S[j] < 0) {
                        ok = false;
                    }
                }
            }
        }
        cout << (ok ? "Yes" : "No") << endl;
    }
    return 0;
}

Measured memory_bytes: 1192
# input
N, M = map(int, input().split())

stores = []
s_append = stores.append
for i in range(N):
    A, B = map(int, input().split())
    s_append(
        {
            "price": A,
            "stock": B
        }
    )
stores.sort(key=lambda x: x["price"])

money = 0
for drink in stores:
    if M <= drink["stock"]:
        money += drink["price"] * M
        break
    else:
        money += drink["price"] * drink["stock"]
        M -= drink["stock"]

print(money)

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n;

int main() {
	cin >> n;
	
	LL ans = 1;
	LL MOD = 1e9 + 7;
	inc1(i, n) { (ans *= i) %= MOD; }
	
	cout << ans << endl;
	
	return 0;
}


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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;
    vector<i64> a(n);
    for (auto& e : a) cin >> e;
    sort(all(a));
    partial_sum(all(a), begin(a));
    i64 i = n - 1;
    while (i - 1 >= 0 && a[i] - a[i - 1] <= a[i - 1] * 2) i--;
    cout << n - i << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(){
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    int i, j, p[n];
    for(i=0;i < n;i++){
        scanf("%d", &p[i]);
    }
    int first, second, third;
    first = second = third = 0;
    for(i = 0; i < n; i++){
        if(p[i] <= a)
            first++;
        else if(p[i] <= b)
            second++;
        else if(p[i] > b)
            third++;
    }
    if(first < second && first < third)
        printf("%d\n", first);
    else if(second < third)
        printf("%d\n", second);
    else
        printf("%d\n", third);        

    return 0;
}

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

using namespace std;

const int MOD = 1000000007;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  string S;
  cin >> N >> S;
  vector<int> counts(26, 0);
  for (auto s : S)
    counts[s - 'a']++;
  int res = 1;
  for (auto c : counts)
    res = 1LL * res * (c + 1) % MOD;
  cout << res - 1 << '\n';
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  vector<int> x(5);
  REP(i, 5) cin >> x[i];
  REP(i, 5) if (x[i] == 0) {
    cout << i + 1 << endl;
    return;
  }
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3612
// #Sazaの1日1AC
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;
const long long INF=9e15;
const double PI=3.14159265358979323846;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vP=vector<pair<long long, long long>>;
//ショートカット
#define rep(i,n) for(long long i = 0; i < n; i++)
#define rep2(i,k,n) for(long long i = k; i < n; i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mkp make_pair
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define chin(x) char x;cin>>x;
#define sin(s) string s;cin>>s;
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

#define max(a,b) max((ll)a,(ll)b)
#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//繰り返し二乗法
long long repeat_squaring(long long x, long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=repeat_squaring(x,n/2);
    return t*t%mod;
  }
  else
    return x*repeat_squaring(x,n-1);
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//構造体

//Union-Find木
struct UnionFind{
  //メンバ変数 
  vector<long long>par; //par[i]:=頂点iの親
  vector<long long>s; //s[i]:=頂点iが属する集合の個数(iが根のとき)
  
  //コンストラクタ
  UnionFind(long long N):par(N),s(N){
    for(long long i=0;i<N;i++){
      par[i]=i; //最初はすべてが根として初期化
      s[i]=1;
    }
  }
  //メンバ関数
  //root(i):=頂点iの根
  long long root(long long i){
    if(par[i]==i) return i;
    par[i]=root(par[i]); //経路圧縮
    return root(par[i]); //再帰
  }
  //size[i]:=iが属する集合の個数
  long long size(long long i){
    return s[root(i)];
  }
  //same(x,y) xとyが同じ根を持つか(同じ集合に含まれるか)
  bool same(long long x, long long y){
    return root(x)==root(y);
  }
  //unite(x,y) xの根をyの根に繋げる(集合を合併)
  void unite(long long x, long long y){
    if(!same(x,y)){
      long long rx=root(x);
      long long ry=root(y);
      par[rx]=par[ry];
      s[ry]=s[rx]+s[ry];
    }
  }
};

/////////////////⊂('ω'⊂ )))Σ≡GO!/////////////////
int dp[3005][3005][5];

//メイン関数
int main(){
  //doubleの桁数
  
  int x; cin >> x;
  cout << (2 - x) / 2 << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  map<ll, ll> m1,m2,m3;
  rep(i,n) cin >> a[i];
  rep(i,n){
    m1[a[i]]++;
    m2[a[i]+1]++;
    m3[a[i]-1]++;
  }
  ll ans = 0;
  rep(i,n){
    ll sum = m1[a[i]] + m2[a[i]] + m3[a[i]];
    ans = max(ans, sum);
  }
  cout << ans << endl;
}

Measured memory_bytes: 15744
#include<stdio.h>

using namespace std;

long long int a[5];

int main(){
    long long int n;
    scanf("%lld%lld%lld%lld%lld%lld", &n, &a[0], &a[1], &a[2], &a[3], &a[4]);

    long long int min = a[0];
    for(int i = 0; i < 5; i++){
        if(a[i] < min){
            min = a[i];
        }
    }

    long long int loss = 5;

    if(min < n){
        loss += n / min;
        if(n % min == 0){
            loss--;
        }
    }

    printf("%lld\n", loss);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        long N = sc.nextLong();
        long ans = 1;
        for(long i = 1; i < N + 1; i++) ans =  ans * i % 1000000007;  
        
        System.out.println(ans);
    }
}


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

int main(){
    string a,b;
    cin >> a;
    cin >> b;
    bool judge = true;
    for(int i = 0; i < a.length();i++){
        if(a[i] != b[i]) judge = false;
    }
    if(judge) cout << "Yes" << endl;
    else cout << "No" << endl;

}

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

int main() {
    int num_blue_cards, num_red_cards, max_score = 0;
    unordered_map<string, int> scores;
    string str;

    cin >> num_blue_cards;
    for(int i = 0; i < num_blue_cards; i++) {
        cin >> str;
        if(scores.count(str) == 0) {
            scores[str] = 1;
        }
        else {
            scores[str]++;
        }
    }
    cin >> num_red_cards;
    for(int i = 0; i < num_red_cards; i++) {
        cin >> str;
        if(scores.count(str) == 0) {
            scores[str] = -1;
        }
        else {
            scores[str]--;
        }
    }
    for (auto s : scores){
        if(s.second > max_score) {
            max_score = s.second;
        }
    }
    cout << max_score << endl;
}

Measured memory_bytes: 256
import math


def run(N):
    if N == 0:
        return 0
    ans = 0
    if N % 2 == 0:
        for i in range(int(math.log(N, 5))):
            ans += N // (10 * (5**i))
    return ans


def main():
    N = int(input())
    print(run(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<map>
#include<string>
using namespace std;
typedef pair<string,int> mypair;
int main(){
	map<string,int> mp;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int q;
		cin>>q;
		if(q){
			string s;
			cin>>s;
		auto it = mp.find(s);
		if(it!=mp.end())		cout<<it->second<<endl;
		}else{
		string s;
		int x;
		cin>>s>>x;
		mp.erase(s);
		mp.insert(mypair(s,x));
		//mp.insert_or_assign(mypair(s,x));
		}

	}


	return 0;
}



Measured memory_bytes: 27908
#-*-coding:utf-8-*-

def main():
    abc = list(map(int, input().split()))

    if (max(abc) % 2 == 0 and sum(abc) % 2 == 0) or (max(abc) % 2 != 0 and sum(abc) % 2 != 0):
        M = max(abc)
    else:
        M = max(abc) + 1

    print((3 * M - sum(abc)) // 2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
//fifer a tak luboin
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define mp make_pair
#define pb push_back
#define s second
#define f first
#define endl "\n"

// using namespace __gnu_pbds;
using namespace std;
// template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 

const double eps = 1e-10;                                     
const double pi = acos(-1.0);

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 
    // freopen("input.in.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ll n;
    cin >> n;
    string ans = "";
    while (n > 0) {
        n--;
        ans += char((n % 26) + 'a');
        n /= 26;
    }
    
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;  
}


Measured memory_bytes: 3640
/*----------------by syr----------------*/
/*

         iii                  ii
     rBQBBBBBBE       BBR iBBBBQBBL     XBBBBBBQBBBBB
   iBBQJ    7BBB      BBsSBBr   BBQ      i      cBBB
  rBBU       iBBw     BBBQi     HBBi           KBBi
  BBH         BB5    iBBB       isL          wBB5
 GBB         iBBi    6BB                   iBBB
 BBQ         BQB     BBD                  QBBi
 BBB        BQB     iQBi                1BBv
 sBBg     wBBB      QBB               iBBB
  7BBBBBBBBBi       BBR              wBBBBBBBBBBBBB
     irvi           ii               ii    i i iii
                i5U
               BBB
               BB7
              1BB
      iPBBBBBKBBR    JBR1       rQBO   BR  UBQP  iBBQi
    7BBBGs7sXBBBi     QBBr     gBBE   rBB BB2BB7HBZQBB
   QBBi      sBQ       BBB   iBBB     SQBBR  BBBB  cBQ
  gBQ        BBg        BBB KBBi      MBBH   BBB   BBs
 iBBv       iBBi         QBBBL        BBR   pBB   iBB
 pBB        BBB         iBBBB        iBB    BBL   KBB
 MBB       BBBR        BBB JBBi      DBR   iBQ    BBL
 GBB     7BBBB2      PBBH   BBBi     BQr   DBB   iBB
  BQBXwgBBP BB7    1BBB      BBQ7   1BB    BBc   BBB
   2BBBBw   BB    EBBS        QBBi  HBa   iBB    BB7
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;
const int maxk = 105;
const int magic = 4e4 + 5;

inline void add(int &a, int b){(a += b) %= INF;}
inline int mul(int a, int b){return 1ll * a * b % INF;}

int n, k, ans;
int f[maxk][magic], g[maxk][magic], h[maxk][magic];

int main(){
	scanf("%d%d", &n, &k);
	int sq = 0;
	for(; sq * sq <= n; ++sq);
	--sq;
	REP(i, 1, k) REP(j, 1, sq){
		if(i != 1)
			add(f[i][j], g[i - 1][sq]);
		else
			add(f[i][j], 1);
		if(i > 2){
			add(f[i][j], mul(g[i - 2][j], max(n / j - sq, 0)));
			add(f[i][j], (h[i - 2][sq] - h[i - 2][j] + INF) % INF);
		}
		else if(i > 1)
			add(f[i][j], max(n / j - sq, 0));
		add(g[i][j], g[i][j - 1]);
		add(g[i][j], f[i][j]);
		add(h[i][j], h[i][j - 1]);
		add(h[i][j], mul(f[i][j], max(n / j - sq, 0)));
	}
	//REP(i, 1, k){REP(j, 1, sq) printf("%d ", f[i][j]); puts("");}
	REP(j, 1, sq){
		add(ans, f[k][j]);
		add(ans, mul(f[k - 1][j], max(n / j - sq, 0)));
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 48896
N = int(input())
S = input()
a = ""
b = ""
if len(S)%2 == 1:
    print("No")
else:
    for i in range(0,(len(S)//2)):
        a += S[i]
    for j in range((len(S)//2),len(S)):
        b += S[j]
    if a == b:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <string>

#define rep(i, s, n) for(int (i) = (s); (i) < (n); ++(i))
#define print(x) cout << (x) << endl 
#define min2(a, b) ((a) < (b)) ? (a) : (b)
#define max2(a, b) ((a) > (b)) ? (a) : (b)

typedef long long ll;

using namespace std;

string str;

ll dfs(int index, ll s, ll p){
    if(index == str.length()){
        return s + p;
    }
    ll n = str[index] - '0';
    return dfs(index + 1, s + p, n) + dfs(index + 1, s, p * 10 + n);
}

int main(){
    cin >> str;
    cout << dfs(1, 0, str[0] - '0') << endl;
    return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


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


    // N-C を全探索
    long long ans = 0;
    FOR(i, 1, N){
        long long num = 0;
        bool flag = false;
        for(int j = 1; j*j <= i; ++j){
            if(i%j == 0) ++num;
            if(j*j == i) flag = true;
        }
        ans += 2*num;
        if(flag) --ans;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
int main(void){
	int n,Count=0,count2=0,i,len,kazu[1000],sum=0;
	char x[1000],a;
	while(1){
		sum=0;
		scanf("%s",x);
		if(x[0]=='0'){
			break;
		}
		len=strlen(x);	//????????°??°???
		for(i=0;i<len;i++){
			a=x[i];
			kazu[i]=atoi(&a);
			sum=sum+kazu[i];
		}
		printf("%d\n",sum);
		
	}
	
	
	return 0;
}

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

using namespace std;

using ll = long long;

template <class SemiLattice>
struct SparseTable {
    using T = typename SemiLattice::T;

    int n;
    vector< vector<T> > table;
    vector<int> log_table;

    SparseTable(const vector<T>& v) {
        n = v.size();

        log_table.resize(n + 1, 0);
        for (int i = 2; i <= n; i++) {
            log_table[i] = log_table[i >> 1] + 1;
        }

        table.resize(log_table[n] + 1, vector<T>(n));
        for (int i = 0; i < n; i++) {
            table[0][i] = v[i];
        }

        size_t sz = table.size();
        for (int i = 1; i < sz; i++) {
            for (int j = 0; j + (1 << i) <= n; j++) {
                table[i][j] = SemiLattice::merge(table[i - 1][j], table[i - 1][j + (1 << (i - 1))]);
            }
        }
    }

    //区間[l, r)に対するクエリに答える
    T query(int l, int r) {
        assert(l < r); 
        int k = log_table[r - l];
        return SemiLattice::merge(table[k][l], table[k][r - (1 << k)]);
    }
};

//以下、SemiLatticeの例
template <class U = ll>
struct RMQSL {
    using T = U;
    static T merge(T a, T b) { return __gcd(a, b); }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    SparseTable< RMQSL<int> > st(a);

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int g = 0;
        if (i > 0) g = st.query(0, i);
        if (i < n - 1) {
            if (g == 0) g = st.query(i + 1, n);
            else g = __gcd(g, st.query(i + 1, n));
        }
        ans = max(ans, g);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 8064
#include<stdio.h>
#include<stdlib.h>


typedef struct {
  int num;
  int ban;
} stu;

int cmp( const void *p, const void *q ) {
    return ((stu*)p)->ban - ((stu*)q)->ban;
}

int main(){
  int i,j,k,N;
  scanf("%d",&N);
  stu A[N];
  for(i=0;i<N;i++){
  scanf("%d ",&A[i].ban);
    A[i].num=i;
  }
  qsort(A,N,sizeof(stu),cmp);
  for(i=0;i<N;i++){
    printf("%d ",A[i].num+1);
  }
  puts("");
  return 0;
}
  



Measured memory_bytes: 1788
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;

 public class Main {
     static Node[] ls;

     static class Node {
         int id = 0;
         int parent = -1;
         int left = -1;
         int right = -1;
         int depth = 0;
         int height = 0;

         Node(int id, int left, int right, int depth) {
             this.id = id;
             this.left = left;
             this.right = right;

             this.depth = depth;
         }
     }

     public static int getSibling(Node[] n, int idParent, int currentId) {
         for (Node no : n) {
             if (no.id == idParent) {
                 if (no.left != currentId) {
                     return no.left;
                 } else {
                     return no.right;
                 }

             }
         }

         return -1;
     }

     public static int getDegree(Node node) {
         int counter = 0;

         if (node.left != -1) {
             counter++;
         }

         if (node.right != -1) {
             counter++;
         }

         return counter;
     }

     public static String getType(Node n) {
         if (n.parent == -1) {
             return "root";
         } else if (n.left == -1 && n.right == -1) {
             return "leaf";
         } else {
             return "internal node";
         }
     }

     public static void getHeight(int id, int d) {
         ls[id].height = 0;
         ls[id].depth = d;

         if (ls[id].left != -1) {
             int h = ls[id].left;
             getHeight(h, d+1);
             if ((ls[h].height+1) > ls[id].height) {
                 ls[id].height = ls[h].height+1;
             }
         }

         if (ls[id].right != -1) {
             int h = ls[id].right;
             getHeight(h, d+1);
             if ((ls[h].height+1) > ls[id].height) {
                 ls[id].height = ls[h].height+1;
             }
         }
     }

     public static void main(String[] args) {
         Scanner inp = new Scanner(System.in);
         int n = inp.nextInt();

         ls = new Node[n];
         for (int i = 0; i < n; i++) {
             ls[i] = ls[i] = (new Node(i, -1, 0, 0));
         }

         for (int i = 0; i < n; i++){
             int id = inp.nextInt();
             int left = inp.nextInt();
             int right = inp.nextInt();

             ls[id].left = left;
             ls[id].right = right;

             if (left != -1) {
                 ls[left].parent = id;
             }

             if (right != -1) {
                 ls[right].parent = id;
             }
         }

         int nodeCount = 0;

         for ( Node no : ls) {
             if (no.parent == -1) {
                 getHeight(no.id, 0);
             }
         }

         for ( Node no : ls) {
             int degree = getDegree(no);

            System.out.println("node " + no.id + ": parent = " + no.parent + ", sibling = " + getSibling(ls, no.parent, no.id) + ", degree = " + degree + ", depth = " + no.depth + ", height = " + no.height + ", " + getType(no));
         }
     }
 }




Measured memory_bytes: 26192
#include<iostream>
#include <fstream>

#define LOCAL  1
#define UPLOAD 2

using namespace std;

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    string s;
    cin >> s;

    bool sb[s.length()];
    for(int i=0;i<s.length();i++){
        sb[i] = s[i] == '0';
    }

    int ret = 0;
    for(int i=0;i<s.length()-1;i++){
        if(sb[i] == sb[i+1]){
            sb[i+1] = !sb[i+1];
            ret++;
        }
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int A[1000005],B[1000005],dp[100005][1],i,n,sum,say,a,b,c,d,e,f,mak,S,g,sum2,x,y,m,j,C[1000005],l,r,D[200005],k,T,say1,say2,say3 ;
 char s[1000005],ch;
vector<int> v1,v2,v;

 

int main(){
scanf("%d",&n); 
for(i=1;i<=n;i++){ 	scanf("%d",&A[i] );    if(A[i]!=i){say++;} }
if(say>2){printf("NO"); return 0; }
printf("YES");

	return 0;
}

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

#define pb push_back
#define ff first
#define ss second

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

int a[3];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[2] * 10 + a[1] + a[0] << endl;
	return 0;
}


Measured memory_bytes: 256