akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.AtCoder_Begginer_Contest_162
{
    class C
    {
        static void Main(string[] args)
        {
            string input1 = Console.ReadLine();
            long n = long.Parse(input1);

            long sum = 0;
            for (long i = 1; i <= n; i ++)
            {
                for (long j = 1; j <= n; j++)
                {
                    for(long k = 1; k <= n; k++)
                    {
                        sum += gcd(gcd(i, j), k);
                    }
                }
            }
            Console.WriteLine(sum);
            //Console.ReadKey();

        }

        static long gcd(long p, long q)
        {
            if (p % q == 0) return q;
            return gcd(q, p % q);
        }
    }
}


Measured memory_bytes: 27504
#include<stdio.h>
int main()
{
	int n;
	int i,j;
	scanf("%d",&n);
	for(i=1;i<10;i++)
	for(j=1;j<10;j++)
	if(i*j==n)
	{
		printf("Yes");
		return 0;
	}
	printf("No");
	return 0;
	
}


Measured memory_bytes: 128
/* C - Replacing Integer */

#include <stdio.h>

long long absolute(long long a, long long b){
  if(a >= b) return a - b;
  else return b - a;
}

long long Replace(long long n, long long k){
  if(n == k){
    return 0;
  }else if(n > k){
    if(n % k == 0) return 0;
    else return Replace(n % k, k);
  }else{
    if(n <= absolute(n, k)) return n;
    else return absolute(n, k);
  }
}

int main(void){
  long long N, K;
  scanf("%lld %lld", &N, &K);
  printf("%lld", Replace(N, K));
}


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

using namespace std;

typedef long long ll;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<pair<int,int>> vp;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<bool>> vbb;
typedef pair<int,int> pi;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define REP(n, x) for(int i = n; i < x; i++)
#define REPN(n, x) for(int i = x; i >= n; i--)
#define REPVS(arr) for(auto &x : arr)
#define REPV(arr) for(auto x : arr)
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(x) printf("%s\n", s.c_str())
#define F first
#define S second

const int INF = INT_MAX;

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

    int n;
    si(n);
    if(n >= 30){
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

void solve(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	int r = 0;
	for(int i = 0;i < n;++i){
		if(s[i] == 'R') ++r;
	}
	int ans = 0;
	for(int i = r;i < n;++i){
		if(s[i] == 'R') ++ans;
	}	
	cout << ans << newl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 3784
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

h,w,k = inm()
c = []
for i in range(h):
    c.append(ins())
ans = 0
for i in range(2**h):
    for j in range(2**w):
        sm = 0
        for x in range(h):
            for y in range(w):
                if (i>>x)%2>0 and (j>>y)%2>0 and c[x][y]=='#':
                    sm += 1
        if sm==k:
            ans += 1
print(ans)


Measured memory_bytes: 68524
n, m = map(int, input().split())
submit = {}

for _ in range(m):
  p, s = input().split()
  if submit.get(p, -1) == -1:
    submit[p] = [0, 0]
  if (submit[p])[0] == 0:
    if s == 'AC':
      (submit[p])[0] += 1
    else:
      (submit[p])[1] += 1
      
ac = 0
wa = 0
for i in submit.values():
  if i[0] > 0:
    ac += i[0]
    wa += i[1]

print(ac, wa)


Measured memory_bytes: 25292
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;


int main()
{
	string a;
	cin >> a;
	int total=0;
	for(int i=0; i<a.length(); i++)
	{
		total += a[i]-'0';
	}
	if(total%9 == 0)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
}



Measured memory_bytes: 3756
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

const ll INF = 1e18;

int A,B,Q;
vector<ll> S;
vector<ll> T;
ll X;

int main() {
    cin >> A >> B >> Q;

    S.assign(A+2,INF);
    T.assign(B+2,INF);

    S[0] = -INF;
    T[0] = -INF;
    for (int i=1; i<=A; i++) cin >> S[i];
    for (int i=1; i<=B; i++) cin >> T[i];

    for (int i=0; i<Q; i++) {
        cin >> X;
        auto b = upper_bound(S.begin(), S.end(), X);
        auto d = upper_bound(T.begin(), T.end(), X);

        ll answer = INF;
        for (auto s=b-1; s<=b; s++) {
            for (auto t=d-1; t<=d; t++) {
                auto distance1 = abs(*s - X) + abs(*t - *s);
                auto distance2 = abs(*t - X) + abs(*s - *t);
                answer = min(answer, min(distance1, distance2));
            }
        }
        cout << answer << endl;
    }
}


Measured memory_bytes: 2944
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(pair<int, int> a, pair<int, int> b) {
	return a < b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	int n;
	cin >> n;
	int ans = 0;
	if (n >= 100000) {
		n = 99999;
	}
	if (n >= 10000) {
		ans += n - 9999;
		n = 9999;
	}
	if (n >= 1000) {
		n = 999;
	}
	if (n >= 100) {
		ans += n - 99;
		n = 99;
	}
	if (n >= 10) {
		n = 9;
	}
	ans += n;
	cout << ans << endl;
	return 0;
}

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

using namespace std;
char ch[100007];
int a[30];
int main()
{
    scanf("%s",ch);
    for(int i=0; ch[i]; i++)
    {
        int k=ch[i]-'a';
        a[k]++;
    }
    int flag=0,i;
    for(i=0; i<26; i++)
        if(a[i]==0)
        {
            flag=1;
            break;
        }
    if(flag)
    {
        char ch1=(char)(i+'a');
        cout << ch1 << endl;
    }
    else
        cout <<"None"<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long lint;

int main()
{
	lint n, m;
	lint score[1024];
	static lint pSum[512 * 1023];
	
	while (scanf("%lld %lld", &n, &m) && n){
		
		for (int i = 0; i < n; i++){
			scanf("%lld", score + i);
		}
		score[n++] = 0;
		
		int k = 0;
		for (int i = 0; i < n; i++){
			for (int j = i; j < n; j++){
				pSum[k++] = score[i] + score[j];
			}
		}
		
		sort(pSum, pSum + k);
		
		lint res = 0;
		for (int i = 0; i < k; i++){
			if (pSum[i] > m) break;
			res = max(res, pSum[i] + *(upper_bound(pSum, pSum + k, m - pSum[i]) - 1));
		}
		
		printf("%lld\n", res);
	}
	return (0);
}

Measured memory_bytes: 5140
n, m = map(int, input().split())
count = [0 for i in range(n+1)]
for i in range(m):
    a,b = map(int, input().split())
    count[a] += 1
    count[b] += 1
for i in range(n+1):
    if count[i] % 2 != 0:
        print("NO")
        exit()
print("YES")


Measured memory_bytes: 4016
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll K,A,B;
    cin >> K >> A >> B;
    ll ans;
    ll ans1=K+1;
    ll ans2;
    if(K>=A+1){
      K=K-A+1;
      ans2=A+(B-A)*(K/2)+K%2;
    }
    ans=max(ans1,ans2);
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
	public static void main(String args[]) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Integer N = Integer.parseInt(br.readLine());
		String L = br.readLine();
		String[] Llist = L.split(" ");

		ArrayList<Integer> numList = new ArrayList<Integer>();
		for(int i = 0; i < N*2; i++){
			numList.add(Integer.parseInt(Llist[i]));
		}
		Collections.sort(numList, Collections.reverseOrder());

		// 降順に並べて上から2つずつ取る
		// 低い方の値を採用して、全部足す
		Integer output = 0;
		for(int i = 0; i < N*2; i++){
			if(i % 2 == 0){
				continue;
			}else{
				output += numList.get(i);
			}
		}
		System.out.println(output);
	}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#include<atcoder/all>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    scc_graph g(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        g.add_edge(a, b);
    }
    auto vs = g.scc();
    cout << vs.size() << endl;
    rep(i, vs.size()) {
        cout << vs[i].size();
        rep(j, vs[i].size()) cout << ' ' << vs[i][j];
        cout << endl;
    }
}


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

int main()
{
    int n, k;
    cin>>n;
    cin>>k;
    int count = 0;
    int a = 0;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        if(a >= k) count++;
    }
    cout<<count<<endl;
    return 0;
}


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

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

		while(true){
			int timelimit = sc.nextInt();
			int team_num = sc.nextInt();
			int q_num = sc.nextInt();
			int record_num = sc.nextInt();
			if(timelimit==0) break;

			Team[] team = new Team[team_num];
			int[][] solved = new int[q_num + 1][team_num];
			for(int i=0; i<team_num; i++){
				team[i] = new Team(q_num);
				solved[0][i] = 100-i-1;
			}

			for(int i=1; i<q_num+1; i++){
				Arrays.fill(solved[i], 1000000000);
			}

			for(int i=0; i<record_num; i++){
				int minute = sc.nextInt();
				int t = sc.nextInt();
				int q = sc.nextInt();
				int judge = sc.nextInt();
				if(judge!=0){
					team[t-1].wrong[q-1]++;
				}else{
					solved[team[t-1].cnt++][t-1] = 1000000000;
					team[t-1].duration += (minute + team[t-1].wrong[q-1]*20)*100;
					solved[team[t-1].cnt][t-1] = -t + team[t-1].duration;
					team[t-1].wrong[q-1] = 0;
				}
			}
			String str = "";
			for(int i=q_num; i>=0; i--){
				Arrays.sort(solved[i]);
				if(solved[i][0]==1000000000) continue;	
				str += str.valueOf(100-solved[i][0]%100);
				for(int j=1; j<team_num; j++){
					if(solved[i][j]==1000000000) break;
					if(solved[i][j]/100 == solved[i][j-1]/100){
						str += "=" + str.valueOf(100-solved[i][j]%100);
					}else{
						str += "," + str.valueOf(100-solved[i][j]%100);
					}
				}
				str += ",";
			}
			str = str.substring(0, str.length()-1);
			System.out.println(str);
		}
	}

	public static class Team{
		int duration = 100;
		int cnt = 0;
		int[] wrong;
		Team(int q_num){
			wrong = new int[q_num];
		}
	}
}

Measured memory_bytes: 67512
m = 10 ** 9 + 7
n = int(input())
s = input()
r, p = 1, 0
for i in range(2, n + 1):
    r = (r * i) % m
for i, c in enumerate(s):
    if int(c == 'W') == i % 2:
        p += 1
    else:
        r = (r * p) % m
        p -= 1
print(r if p == 0 else 0)


Measured memory_bytes: 3572
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-30 19:54:47
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

using ld = long double;

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

  ld a, b, x; cin >> a >> b >> x;

  if (2 * x > a * a * b) {
    cout << setprecision(17) << atan2(2 * (a * a * b - x) / (a * a), a) * 180 / acos(-1.0) << endl;
  } else {
    cout << setprecision(17) << atan2(b, 2 * x / (a * b)) * 180 / acos(-1.0) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
  char n[10];
  scanf("%s",n);
  int flag = 0;
  for(int i=0;i<3;i++){
    if(n[i] == n[i+1]){
      printf("Bad\n");
      flag = 1;
      break;
    }
  }
  if(flag == 0) printf("Good\n");
  return 0;
}

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

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

    int ans = 700;

    string S;
    cin >> S;

    for(int i = 0; i < 3; i++) {
        if(S[i] == 'o') ans += 100;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
//YESNO

using namespace std;



signed main()
{
	char str[100];
	cin >> str;
	if (str[2] == str[3] && str[4] == str[5])
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
int main(){
    int r,d,x;
    cin>>r>>d>>x;
    REP(i,10){
        x=r*x-d;
        cout<<x<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<ll>> dp(h,vector<ll>(w,0));
    rep(i,h){
        rep(j,w){
            char t;cin>>t;
            if(t=='#')  dp[i][j]=-1;
        }
    }
    dp[0][0]=1;
    rep(i,h){
        rep(j,w){
            if(dp[i][j]<0)  continue;
            if(i)   dp[i][j]=(dp[i][j]+max(0ll,dp[i-1][j]))%mod;        
            if(j)   dp[i][j]=(dp[i][j]+max(0ll,dp[i][j-1]))%mod;
        }
    }
    cout<<dp[h-1][w-1]<<endl;
    return 0;
}

Measured memory_bytes: 8064
def num_sum(L):
  ret = 0
  for l in L:
    ret += int(l)
  return ret

N, A, B = map(int, input().split())
ans = 0
for i in range(1, N+1):
  num = num_sum(list(str(i)))
  if A <= num and num <= B:
    ans += i
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll mod = 1000000007;
ll INF = 1000000009;

ll digit(ll x){
    ll count = 1;
    while(x>=10){
        count++;
        x=x/10;
    }
    return count;
}
/*
int a[11];

void base2(int x, int d){
    rep(i,d){
        a[i] = x%2;
        x = x/2;
    }
}
*/

ll d;

string base2(ll x){
    string s="";
    while(x!=0){
        if(x%2==1){
            s = '1'+s;
        }
        else{
            s = '0'+s;
        }
        x=x/2;
    }
    ll siz = s.size();
    while(d-1!=siz){
        s = '0' + s;
        siz++;
    }
    return s;
}


void solve(){
    ll s;
    cin >> s;
    ll count = 0;
    d = digit(s);
    rep(i,pow(2,d-1)){
        string t = base2(i);
        //cout << "i:" << i << " t:" << t << endl;
        t = t + '2';
        /*2進法表記
        例えばs=12345, 1011なら、1+23+4+5
        t[0]=1なのでs[0]を足す
        t[1]=0なのでtmp=s[1]
        t[2]=1なのでtmp*10+s[2]を足す
        t[3]=1なのでs[3]を足す
        */
        ll tmp=0;
        rep(j,t.size()+1){
            string st = to_string(s);
            char c=st[j];
            ll x = c-'0';
            tmp += x;
            if(t[j]=='1') {
                count += tmp;
                //cout << tmp << endl;
                tmp=0;
            }
            else if(t[j]=='2'){
                count += tmp;
                //cout << tmp << endl;
                tmp=0;
            }
            else {
                tmp = tmp*10;
            }
            //cout << tmp << endl;
        }

    }

    cout << count << endl;

}

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


Measured memory_bytes: 256
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())
  
n = i()
ans = 0
cnt = 0
def f(a):
	cnt = 0
	while a%2 == 0:
		a //= 2
		cnt += 1
	return cnt
for i in range(1,n+1):
	if f(i) >= cnt:
		cnt = f(i)
		ans = i
print(ans)

Measured memory_bytes: 3064
import java.io.*;

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null){
boolean[] cards=new boolean[11];
int count=0;
String[] values=line.split(" ");
int c1=Integer.parseInt(values[0]);
int c2=Integer.parseInt(values[1]);
int c3=Integer.parseInt(values[2]);
cards[c1]=true;
cards[c2]=true;
cards[c3]=true;
for(int i=1;i<=10;i++){
if(!cards[i]&&20-c1-c2>=i){
count++;
}
}
if(count>=4){
System.out.println("YES");
}
else{
System.out.println("NO");
}
}
}
}

Measured memory_bytes: 16896
import java.util.*;

public class Main {

    /* チェックリスト
     * intの範囲を超えていないか
     * TLEしそうな処理の有無
     */
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String in = sc.nextLine();
        int result = 0;
        char prev = 0;
        for(char c : in.toCharArray()){
            if(prev != c){
                result++;
            }
            prev = c;
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 25940
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
const int R = 300;
int f(const vector<int>& a, int x, int y) {
	// (a <= X[j] && X[j] <= b)
	auto p = lower_bound(a.begin(), a.end(), x);
	auto q = upper_bound(a.begin(), a.end(), y);
	return q - p;
}
int main() {
	int D;
	cin >> D;
	vector<int> X(D);
	for (auto& x : X) cin >> x;
	int Q;
	cin >> Q;
	vector<vector<int>> A;
	for (int i = 0; i + R <= D; i += R) {
		vector<int> B(X.begin() + i, X.begin() + (i + R));
		sort(B.begin(), B.end());
		A.push_back(B);
	}
	for (int i = 0; i < Q; ++i) {
		int l, r, e;
		cin >> l >> r >> e;
		--l; --r;
		int a = X[l];
		int b = X[r];
		if (a > b) swap(a, b);
		a -= e;
		b += e;
		int res = r - l + 1;
		for (int j = l; j <= r; ++j) {
			if (j % R == 0 && j + R - 1 <= r) {
				res -= f(A[j / R], a, b);
				j += R - 1;
			} else {
				if (a <= X[j] && X[j] <= b) --res;
			}
		}
		cout << res << endl;
	}
	cin >> D;
}


Measured memory_bytes: 3820
///   ***   ---   |||         In the name of ALLAH        |||   ---   ***   ///



#include<bits/stdc++.h>
using namespace std;


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);


#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}


inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

const int mx = 1e5+123;
ll dp[mx][30], n;
string s;

ll solve ( int i, int d )
{
    if ( i >= n ) return ( d == 5 );
    if ( dp[i][d] != -1 ) return dp[i][d];

    ll ret = 0;

    if ( s[i] == '?' ) {
        for ( int j = 0; j < 10; j++ ) {
            int tmp = d;
            tmp *= 10;
            tmp += j;
            tmp %= 13;

            ret = modAdd( ret, solve ( i+1, tmp ) );
        }
    }

    else {
        int tmp = d;
        tmp *= 10;
        tmp += ( s[i] - '0' );
        tmp %= 13;
        ret = modAdd( ret, solve ( i+1, tmp) );
    }

    return dp[i][d] = ret;

}

int main()
{
    optimize();

    cin >> s;
    n = sz ( s );

    mem ( dp, -1 );
    cout << solve ( 0, 0 );


    return 0;
}


















Measured memory_bytes: 31696
#include<iostream>
using namespace std;
int main()
{
  int x;

  cin>>x;
  if(x==3)
  {
    cout<<"YES";
  }

  else if(x==5)
  {
    cout<<"YES";
  }

  else if(x==7)
  {
    cout<<"YES";
  }
  
  else
  {
    cout<<"NO";
  }

  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll h, w, res = 11000000000;
int main(void){
        // Your code here!
        cin >> h >> w;
        for (int i = 1; i < h; i++) {
                ll a, b, c, ma, mi;
                a = i * w;
                b = w / 2 * (h - i);
                c = (w + 1) / 2 * (h - i);
                ma = max(a, max(b, c));
                mi = min(a, min(b, c));
                res = min(res, ma - mi);
        }
        for (int i = 1; i < w; i++) {
                ll a, b, c, ma, mi;
                a = i * h;
                b = h / 2 * (w - i);
                c = (h + 1) / 2 * (w - i);
                ma = max(a, max(b, c));
                mi = min(a, min(b, c));
                res = min(res, ma - mi);
        }
        if (h % 3 == 0) res = 0;
        else res = min(res, w);
        if (w % 3 == 0) res = 0;
        else res = min(res, h);
        cout << res << endl;

        return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main
{
  static int n, w;
  static int[] W, V;
  static Long[][] memo;
  public static void main(String[] args)
  {
	Scanner in = new Scanner(System.in);
    n = in.nextInt();
    w = in.nextInt();
    W = new int[n];
    V = new int[n];
    for (int i = 0; i < n; i++)
    {
      W[i] = in.nextInt();
      V[i] = in.nextInt();
    }
    
    memo = new Long[n][w+1];
    System.out.println(dp(0, 0));    
    in.close();
  }
  
  public static long dp(int at, int free)
  {
    if (free > w)
      return -(long)1e14;
    if (at == n)
      return 0;
    if (memo[at][free] != null)
      return memo[at][free];
    
    long ans = 0;
    ans = Math.max(ans, V[at]+dp(at+1, free+W[at]));
    ans = Math.max(ans, dp(at+1, free));
    return memo[at][free] = ans;
 }
}

Measured memory_bytes: 291084
r,c=map(int,input().split())
x=[]
for i in range(r):
    x.append(list(map(int,input().split())))
    x[i].append(sum(x[i]))
Y=[]
for k in range(c+1):
    y=0
    for l in range(r):
        y+=x[l][k]
    Y.append(y)
x.append(Y)
for m in range(r+1):
    print(*x[m])


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

int main()
{
  int n, a, b;
  cin >> n >> a >> b;

  if (n == 1)
    cout << "Hello World" << endl;
  else
    cout << a + b << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int S;
	int h, m, s;
	cin >> S;
	h = S / (60 * 60);
	m = (S - h * 60 * 60) / 60;
	s = S - h * 60 * 60 - m * 60;
	cout << h << ":" << m << ":" << s << endl;

	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define MAX pow(10,18)
typedef long long ll;

void Calc(ll *A,ll *B,ll *C){
    
    ll a,b,c;
    a = *B + *C;
    b = *A + *C;
    c = *A + *B;
    
    *A = a;
    *B = b;
    *C = c;
}
int main(){
  
  ll A,B,C,K;
  cin >> A >> B >> C >> K;
  
  for(int i=0;i<K;i++){
      Calc(&A,&B,&C);
  }
  if(abs(A - B) > MAX) cout << "Unfair" << endl;
  else cout << A - B << endl;
}

Measured memory_bytes: 3600
N = int(input())
E = [[] for i in range(N)]
for i in range(N-1):
  a, b, c = map(int, input().split())
  a, b = a-1, b-1
  E[a].append((b, c))
  E[b].append((a, c))
Q, K = map(int, input().split())
K = K-1
D = [-1]*N
D[K] = 0
q = [(K, 0)]
while q:
  k, d = q.pop()
  for n, c in E[k]:
    if D[n] < 0:
      D[n] = d+c
      q.append((n, d+c))
#print(D)
for i in range(Q):
  x, y = map(int, input().split())
  x, y = x-1, y-1
  r = D[x]+D[y]
  print(r)


Measured memory_bytes: 49288
#AtCoder Begginer Contest 087 B Coins

a = int(input()) #counts of 500
b = int(input()) #counts of 100
c = int(input()) #counts of 50
x = int(input()) #total value

cnt = 0

def judge(x,a,b,c):
    if 500*a + 100 * b + 50*c == x:
        return True
    
for i in reversed(range(a+1)):
    for j in reversed(range(b+1)):
        for k in reversed(range(c+1)):
            if judge(x, i, j, k):
                cnt += 1

print(cnt)







Measured memory_bytes: 3060
program speedrun
implicit none
integer::N
integer,allocatable,dimension(:)::P,Q
integer,allocatable,dimension(:)::Perm,DID
integer::i
integer::a=0,b=0
read*,N
allocate(P(N),Q(N),Perm(0:N),DID(1:N))
read*,P
read*,Q
Perm=1
do i=1,N
    Perm(i)=Perm(i-1)*i
end do
DID=0
do i=1,N
    a=a+Perm(N-i)*(P(i)-sum(DID(1:P(i)))+1)
    DID(P(i))=1
end do
DID=0
do i=1,N
    b=b+Perm(N-i)*(Q(i)-sum(DID(1:Q(i)))+1)
    DID(Q(i))=1
end do
print"(i0)",abs(a-b)
end program speedrun

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    double r = 0;
    if (n >= k) r += n - (k - 1);

    double t = 1;
    int l = k;
    for (int i = 1; l > 1; i++) {
        int i1 = min(n + 1, l), i0 = l = max(1, (k + (1 << i) - 1) >> i);
        t *= 0.5;
        if (i0 < i1) r += t * (i1 - i0);
    }

    printf("%.12f\n", r / n);

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int MAXN=200005;

struct node{
    long long num;
    int id;

    bool operator<(const node &another)const
    {
        if(num==another.num)return id<another.id;
        return num<another.num;
    }
};

int n,k;
long long a[MAXN];
node b[MAXN];

int lowbit(int x)
{
    return (x&-x);
}

void modify(int x,int num)
{
    if(x==0){
        a[x]+=(long long)num;
        return;
    }
    while(x<=n){
        a[x]+=(long long)num;
        x+=lowbit(x);
    }
}

long long sum(int x)
{
    long long ans=a[0];
    while(x>0){
        ans+=a[x];
        x-=lowbit(x);
    }
    return ans;
}

int main()
{
    scanf("%d %d",&n,&k);
    b[0].num=0;b[0].id=0;
    for(int i=1;i<=n;i++){
        int x;
        scanf("%d",&x);
        b[i].num=b[i-1].num+(long long)(x-k);
        b[i].id=i;
    }
    sort(b,b+1+n);
    long long cnt=0;
    memset(a,0,sizeof(a));
    for(int i=0;i<=n;i++){
        if(b[i].id>0)cnt+=sum(b[i].id-1);
        modify(b[i].id,1);
    }
    printf("%lld\n",cnt);
    return 0;
}

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

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define BUFF ios::sync_with_stdio(false);

typedef long long int ll;
typedef long double ld;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef pair < int, int > ii;
typedef vector < ii > vii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const int MOD = 1e9+7;
const ld pi = acos(-1);

multiset<string> ms;
int n, l;
int main() { BUFF
  cin >> n >> l;
  for(int i=0; i<n; i++) {
    string s; cin >> s;
    ms.insert(s);
  }
  for(auto it : ms)
    cout << it;
  cout << endl;
  return 0;
}


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

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

#define FOR(i,n,m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i,n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll X,Y;
    cin>>X>>Y;
    string ans="Alice";
    if(abs(X-Y)<=1)
    {
        ans="Brown";
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

int main() {
	ll a, b;
	cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) wrln("Possible");
	else wrln("Impossible");
	return 0;
}

Measured memory_bytes: 256
N, K, Q = map(int, input().split())
charanger_points = [K] * N
gained_points = [0] * N

# 正答者を記録
for i in range(Q):
	gained_points[int(input()) - 1] += 1

# 点数計算
for i in range(N):
	charanger_points[i] -=  Q - gained_points[i]

# 提示
for i in range(N):
	print('Yes' if charanger_points[i] > 0 else 'No')

Measured memory_bytes: 8624
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int C = sc.nextInt();
        if (a<b) {
            if(b<C) {
                System.out.printf("%d %d %d\n", a,b,C);
            }else if(a < C) {
                System.out.printf("%d %d %d\n", a,C,b);
            }else {
                System.out.printf("%d %d %d\n", C,a,b); 
            }
        }else {
            
            if (a<C) {
                System.out.printf("%d %d %d\n", b,a,C);
            }else if(b<C) {
                System.out.printf("%d %d %d\n", b,C,a);
            }else {
                System.out.printf("%d %d %d\n", C,b,a);
                
            }                

         }
        sc.close();    

        }
            }

            


    

    
    


Measured memory_bytes: 26248
# 初期入力
import sys
#input = sys.stdin.readline  #文字列では使わない
tstr =input().strip()
from datetime import datetime as dt

#tstr = '2012-12-29 13:49:37'
tdatetime = dt.strptime(tstr, '%Y/%m/%d')
standard ="2019/4/30"
dt_standard =dt.strptime(standard, '%Y/%m/%d')
if tdatetime <= dt_standard:
    print("Heisei")
else:
    print("TBD")

Measured memory_bytes: 10388
#include <stdio.h>
int main(void){
    int a, b;
    scanf("%d %d\n", &a, &b);
    if( (1 <= a) && (a <= 9) && (1 <= b) && (b <= 9) )
        printf("%d\n", a * b);
    else
        printf("-1\n");
    
    return(0);
}

Measured memory_bytes: 128
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int N;
  cin >> N;
  vector<int> cnt(100000, 0);
  REP(i, N) {
    int A;
    cin >> A;
    cnt[A]++;
  }

  int num = 0;
  int ans = 0;
  REP(i, cnt.size()) {
    num = 0;
    num += cnt[i];
    if (cnt[i - 1]) num += cnt[i - 1];
    if (cnt[i + 1]) num += cnt[i + 1];
    ans = max(ans, num);
  }

  cout << ans << endl;
  return 0;
}

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

int main(){
  int a, b ,c;
  cin >> a >> b >> c;
  if(a < b){
    if(a < c && c < b) cout << "Yes" << endl;
    else cout << "No" << endl;
  } else {
    if(b < c && c < a) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,ans=0;
    cin>>n;
    for(int i=105;i<=n;i+=2){
        int count=0;
        for(int j=1;j<=i;j++){
            if(i%j==0)count++;
            if(count==9)break;
        }
        if(count==8)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[105];
int main(void)
{
    int n,m,cnt=0,sum=0;
    double s;
    cin >> n >> m;
    for(int i=1;i<=n;i++)
    {
        cin >> a[i];
        sum+=a[i];
    }
    s=1.0/(4*m)*sum;
    for(int i=1;i<=n;i++)
    {
        if(s<=1.0*a[i])
            cnt++;
    }
    if(cnt>=m) cout <<"Yes";
    else cout <<"No";
    return 0;
}


Measured memory_bytes: 256
while True:
    n = int(input())
    if n==0: break

    ans = 0
    while(n<=500):
        n += 500
        ans += 1
    while(n<=900):
        n += 100
        ans += 1
    while(n<=950):
        n += 50
        ans += 1
    while(n<=990):
        n += 10
        ans += 1
    while(n<=995):
        n += 5
        ans += 1
    while(n<=999):
        n += 1
        ans += 1

    print(ans)

Measured memory_bytes: 7624
n = int(input())
s = input()

i = 0
ans = 0

while i < len(s) - 2:
    if s[i] == "A" and s[i + 1] == "B" and s[i + 2] == "C":
        ans += 1
        i += 3
    else:
        i += 1
print(ans)




Measured memory_bytes: 2940
N = int(input())
p = list(map(float,input().split(" ")))

dp = [ [0.0]*(N+1) for _ in range(N) ]
dp[0][0] = 1 - p[0]
dp[0][1] = p[0]

for i in range(1,N):
    dp[i][0] = dp[i-1][0] * (1-p[i])
    for j in range(1,N+1):
        dp[i][j] = dp[i-1][j] * (1-p[i]) + dp[i-1][j-1] * (p[i])

boarder = (N // 2) + 1
print(sum(dp[N-1][boarder:]))

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

using namespace std;

typedef long long ll;

template<typename T>
void read(T &x) {
	char ch=getchar(); 	int f=1;
	for (x=0;ch!='-'&&(ch<'0'||ch>'9');ch=getchar());
	if (ch=='-') f=-1,ch=getchar();
	for (;ch>='0'&&ch<='9';x=x*10+ch-'0',ch=getchar());
	x*=f;
}
int n,T;
int a[200010];
ll ans;
int main() {
	read(n),read(T);
	for (int i=1;i<=n;i++)
		read(a[i]);
	a[n+1]=a[n]+T;
	for (int i=1;i<=n;i++)
		ans+=min(a[i+1]-a[i],T);
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

ll nums[100];

ll dfs(ll n, ll x){
    if(n == 0 && x == 1) return 1;
    ll res;
    if(x == 0) res = 0;
    else if(x == 1) res = 0;
    else if(x <= nums[n-1] + 1) res = dfs(n-1, x-1);
    else if(x == nums[n-1] + 1) res = dfs(n-1, nums[n-1]) + 1;
    else if(x <= 2 + 2 * nums[n-1]) res = dfs(n-1, nums[n-1]) + dfs(n-1, x - (2 + nums[n-1])) + 1;
    else if(x == nums[n]) res = 2 * dfs(n-1, nums[n-1]) + 1;
    return res;
}

int main(){
    ll n, x;
    cin >> n >> x;
    nums[0] = 1;
    rep(i, 0, n) nums[i+1] = 2*nums[i] + 3;
    cout << dfs(n, x) << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <cassert>
#include <unordered_map>
#define int long long

using namespace std;

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

const int mod = 1e9 + 7;

int pw(int a, int st) {
    if (st == 0) return 1;
    int b = pw(a, st / 2);
    b = (b * b) % mod;
    if (st % 2)
        return (a * b) % mod;
    return b;
}

const int N = 2e5, inf = 4e18;
int dp[N + 1][3];


signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    vector<int> a(n);
    for (int& i : a) cin >> i;

    for (int i = 0; i <= N; ++i) for (int j = 0; j <= 2; ++j) dp[i][j] = -inf;
    for (int i = 0; i < n; ++i) {
        int NWDP = i, PRDP = i - 2;
        for (int prsk = 0; prsk <= 2; ++prsk) {
            for (int sk = 0; prsk + sk <= 2; ++sk) {
                int val = 0;
                if (PRDP - sk >= 0) {
                    val = dp[PRDP - sk][prsk];
                }
                if (PRDP - sk >= -1 || (PRDP - sk == -2 && i == 0 && prsk == 0)) {
                    dp[i][prsk + sk] = max(val + a[i], dp[i][prsk + sk]);
                }
            }
        }
    }
    
    int ans;
    if (n % 2 == 0) {
        ans = dp[n - 1][0];
        ans = max(ans, dp[n - 1][1]);
        ans = max(ans, dp[n - 2][0]);
    } else {
        ans = dp[n - 1][1];
        ans = max(ans, dp[n - 1][2]);
        ans = max(ans, dp[n - 2][0]);
        ans = max(ans, dp[n - 2][1]);
        ans = max(ans, dp[n - 3][0]);
    }

    cout << ans;
}

Measured memory_bytes: 9548
#include<bits/stdc++.h>
#define int long long
using namespace std;
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; }


signed main()
{
    int N; cin>>N; 
    vector<string> s(N);
    int ans=0;
    for(int i=0;i<N;i++){
        cin>>s[i];
        for(int j=0;j<s[i].size()-1;j++){
            if(s[i][j]=='A' and s[i][j+1]=='B') ans++;
        }
    }

    int BA=0,B=0,A=0;
    for(int i=0;i<N;i++){
        if(s[i][0]=='B' and s[i][s[i].size()-1]=='A') BA++;
        else if(s[i][0]=='B') B++;
        else if(s[i][s[i].size()-1]=='A') A++;
    }

    if(A==0 and B==0){
        ans+=max(0LL,BA-1);
    }else if(A==0){
        ans+=BA;
    }else if(B==0){
        ans+=BA;
    }else{
        ans+=(BA+1)+min(A-1,B-1);
    }
    cout<<ans<<endl;
}   


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

int main() {
#ifdef LOCAL_EXEC
//    freopen("sample.in", "r", stdin);
#else
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#endif

  char c;
  cin >> c;
  c++;
  cout << c;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	int N, K;
	cin >> N >> K;
	int R, S, P;
	cin >> R >> S >> P;

	string T;
	cin >> T;


	int kotae = 0;
	rep(i, K) {
		int dp[2][3] = {};

		for (int j = i; j < N; j += K) {
			dp[1][0] = max(dp[0][1], dp[0][2]);
			dp[1][1] = max(dp[0][2], dp[0][0]);
			dp[1][2] = max(dp[0][0], dp[0][1]);

			if (T[j] == 'r') dp[1][2] += P;
			if (T[j] == 's') dp[1][0] += R;
			if (T[j] == 'p') dp[1][1] += S;
			dp[0][0] = dp[1][0];
			dp[0][1] = dp[1][1];
			dp[0][2] = dp[1][2];
		}
		kotae += *max_element(dp[0], dp[0] + 3);
	}
	co(kotae);
	



	Would you please return 0;
}

Measured memory_bytes: 512
s = [input() for i in range(1)]
list1 = list(map(int, s[0].split()))
n = list1[0]
d = list1[1]

t = [input() for i in range(n)]
count = 0

for j in range(n):
    list2 = list(map(float, t[j].split()))
    x = list2[0]
    y = list2[1]
    if d*d >= (x*x + y*y):
        count +=1
            
print(count)



Measured memory_bytes: 23200
#include<iostream>
int main(){
    int W, H, x, y, r;
    std::cin >> W >> H >> x >> y >> r;
    if (r>x||x+r>W||r>y||y+r>H){
        std::cout << "No" << std::endl;
    }
    else {
        std::cout << "Yes" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    LL N,M;cin >> N >> M;
    if(N >= M/2)cout << M/2 << endl;
    else {
        LL ub=M,lb=0;
        while(ub-lb>1){
            LL mid=(ub+lb)/2;
            if(N+mid<=M/2-mid)lb = mid;     // mid を何個引いてるか
            else ub = mid;
        }
        cout << N + lb << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    int n = s.size(),d=10;
    int suf[n],count_[2019];
    memset(count_,0,sizeof(count_));
    long long ans=0;
    suf[n-1] = s[n-1]-'0';
    for(int i=n-2;i>=0;i--){
        suf[i] = ((int)(s[i]-'0')*d+suf[i+1])%2019;
        d*=10;
        d%=2019;
    }
    for(int i=0;i<n;i++){
        count_[suf[i]]++;
    }
    count_[0]++;
    for(int i=0;i<2019;i++){
        ans+=count_[i]*(count_[i]-1)/2;
    }
    cout<<ans<<"\n";
    return 0;
}

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


int main (int argc, char const *argv[])
{
    string s,t; cin>>s>>t;
    
    int count =0;
    if (s[0]==t[0])
    {
        count++;
    }
     if (s[1]==t[1])
    {
        count++;
    }
      if (s[2]==t[2])
    {
        count++;
    }
    
    cout<<count<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
 
#define rep(i,x) for(int i=0;i<x;++i)
 
struct edge{
    int from, to, cost;
    edge(int from, int to, int cost) : from(from), to(to), cost(cost) {};
};
 
vector<edge> edges;
 
const int MAX_N = 100000;
 
int N, M;
int dist[MAX_N];
 
void bf(int s)
{
    rep(i, N) dist[i] = LLONG_MAX / 2;
    dist[s] = 0;
 
    rep(i, N) {
        for (edge& e : edges) {
            if (dist[e.to] > dist[e.from] + e.cost) {
                dist[e.to] = dist[e.from] + e.cost;
            }
        }
    }
    for (edge& e : edges) {
        if (dist[e.to] > dist[e.from] + e.cost) {
          	dist[e.to] = dist[e.from] + e.cost;
            if (e.to == N - 1) {
              cout << "inf" << endl; exit(0);
            }
        }
    }
}
 
signed main()
{
    cin >> N >> M;
 
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        edges.emplace_back(edge(a, b, -c));
    }
 
    bf(0);
 
    cout << -dist[N - 1] << endl;
}

Measured memory_bytes: 384