akhauriyash/Code-Regression huggingface dataset:
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int a,b,c;

int main()
{
	cin>>a>>b>>c;
	cout<<min(c,b/a)<<endl;
	rt0;
}

Measured memory_bytes: 764
import java.util.*;
public class Main {
    public static void main(String[] args){
     Scanner s=new Scanner(System.in);
     int A=s.nextInt();
     int B=s.nextInt();
     int C=s.nextInt();
     int ans=C-(A-B);
     if(ans<0)
         System.out.println(0);
     else {
         System.out.print(ans);
     }
    }
}

Measured memory_bytes: 21332
def calc_cost(hoge):
    cost = 0
    hoge_refer = sorted(hoge[:])
    #checker true means that this index have already looked.
    checker = [False] * len(hoge)
    #abs_min is minimum num in input array.
    abs_min = hoge_refer[0]
    #indexer -> key: sorted val, val: zero 2 n-1
    indexer = {hoge_refer[i]:i for i in range(len(hoge_refer))}
    
    for now_index in range(len(hoge)):
        if checker[now_index]:
            continue
        current = now_index
        size = 0
        sum_num = 0
        circle_min = 10 ** 4
        while True:
            checker[current] = True
            size += 1
            val = hoge[current]
            circle_min = min(circle_min, val)
            sum_num += val
            current = indexer[val]
            if checker[current]:
                break
        cost += min(sum_num+(size-2)*circle_min, circle_min+sum_num+(size+1)*abs_min)
    return cost
        
    
if __name__ == '__main__':
    _ = int(input())
    hoge = [int(x) for x in input().split()]
    print(calc_cost(hoge))


Measured memory_bytes: 5720
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;


int main() {
    int s;
    cin >> s;
    string ans;
    int s1 = s % 100;
    int s2 = (s - s%100) / 100;

    if ((s1 >= 1 && s1 <= 12) && (s2 >= 1 && s2 <= 12)) {
        ans = "AMBIGUOUS";
    } else if (s1 >= 1 && s1 <= 12) {
        ans ="YYMM";
    } else if (s2 >= 1 && s2 <= 12) {
        ans = "MMYY";
    } else {
        ans = "NA";
    }
    
    cout << ans << endl;
}



Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define MAX_INT 100005

ll N, M, A, B, C;
ll arr[MAX_INT];
vector<ll> V;


int main() {
	scanf("%lld", &N);
	cout << (ceil(N / 2.0)) << " ";
	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
n, m = list(map(int, input().split()))
a = ['' for i in range(n)]
b = ['' for i in range(m)]

for i in range(n):
    a[i] = list(input())

for i in range(m):
    b[i] = list(input())

ans = False

for i in range(n - m + 1):
    for j in range(n - m + 1):
        _a = a[i:i+len(b)]
        _a = list(map(lambda x: x[j:j+len(b)], _a))

        if b == _a:
            ans = True

if ans:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double l = (double)sc.nextInt();
        double h = l/3;
        double w = l/3;
        double x = l/3;
        System.out.println(h*w*x);
    }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int a, b; cin >> a >> b;
    int num = b - a;
    int h = 0;
    FOR(i, 1, num) h += i;
    cout << h - a << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
	int main(){
		int x,y;
		y = 0;
		while ( 1 ){
			cin >> x;
			if ( x == 0 ) break;
			y = y + 1;
			cout << "Case" << " " << y << ":" << " " << x << endl;
		}
	}

Measured memory_bytes: 1160
main = do
    [a, b, x] <- map read . words <$> getLine
    let radToDeg x = x * 180 / pi
    print $ if x <= a ^ 2 * b / 2
        then radToDeg $ atan (a * b ^ 2 / 2 / x)
        else radToDeg $ atan $ 2 * (a ^ 2 * b - x) / (a ^ 3)


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

struct Tree {
  int sibling = -1;
  int degree = 0;
  int parent = -1;
  int height = 0;
  int depth = 0;
  string type = "";
};

#define MAX 30
Tree tree[MAX];

int main() {
  int N; cin >> N;
  for (int i = 0; i < N; i++) {
    int id, left, right;
    cin >> id >> left >> right;
    
    if (left != -1 || right != -1) {
      tree[id].type = "internal node";
    } else {
      tree[id].type = "leaf";
    }

    if (left != -1) {
      tree[left].sibling = right;
      tree[left].parent = id;
      tree[id].degree++;
    }
    if (right != -1) {
      tree[right].sibling = left;
      tree[right].parent = id;
      tree[id].degree++;
    }
  }

  for (int i = 0; i < MAX; i++) {
    for (int j = i; tree[j].parent != -1; j = tree[j].parent) {
      tree[i].depth++;
    }
  }
  for (int i = 0; i < MAX; i++) {
    for (int j = i; j != -1; j = tree[j].parent) {
      tree[j].height = max(tree[j].height, tree[i].depth-tree[j].depth);
    }
  }

  for (int i = 0; i < MAX; i++) {
    if (tree[i].type == "") continue;
    
    if (tree[i].parent == -1) tree[i].type = "root";
    
    cout << "node " << i << ": parent = " << tree[i].parent << ", sibling = " << tree[i].sibling << ", degree = " << tree[i].degree << ", depth = " << tree[i].depth << ", height = " << tree[i].height << ", " << tree[i].type << endl;
  }
}




Measured memory_bytes: 3184
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int H, W;
    string S[60];
    cin >> H >> W;
    for (int i = 0; i < H; i++) cin >> S[i];

    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            int counter = 0;
            if (S[i][j] == '.'){
                if (i > 0){
                    if (j > 0 && S[i - 1][j - 1] == '#') counter++;
                    if (S[i - 1][j] == '#') counter++;
                    if (j < W-1 && S[i - 1][j + 1] == '#') counter++;
                }
                if (i < H - 1){
                    if (j > 0 && S[i + 1][j - 1] == '#') counter++;
                    if (S[i + 1][j] == '#') counter++;
                    if (j < W-1 && S[i + 1][j + 1] == '#') counter++;
                }
                if (j > 0 && S[i][j - 1] == '#') counter++;
                if (j < W-1 && S[i][j + 1] == '#') counter++;
                S[i][j] = '0' + counter;
            }
        }
        cout << S[i] << endl;
    }
}


Measured memory_bytes: 256
n = int(input())
s = input()
s_list = list(s)
result = s_list.count("R") * s_list.count("G") *s_list.count("B") 
for i in range(1,n):
  left = s_list[:i]
  right = s_list[i+1:]
  for j in range(min(len(left),len(right))):
    if s[i] != s[i-j-1] and s[i] != s[i + j + 1] and s[i-j-1] != s[i + j + 1]:
      result -= 1
    
print(result)


Measured memory_bytes: 9292
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=3e3+10;
const ll MOD=1e9+7;
const ll INF=1e18;

int N;
ll a[16][16];
ll sum[1<<16];
ll dp[1<<16];
ll ans;

ll dfs0(int bit){
    if(sum[bit]!=INF)return sum[bit];
  	if(bit==0){
      sum[bit]=0;
      return 0;
    }
    int last=(bit&(-bit));
  	ll tmp=dfs0((bit)^(last));
    last=log2(last);
    rep(d,N)if(((bit>>d)&1)==1){
        tmp+=a[d][last];
    }
    sum[bit]=tmp;
    return tmp;
}

ll dfs(int used){
    if(dp[used]!=-INF)return dp[used];
    if(used==((1<<N)-1)){
        dp[used]=0;
        return 0;
    }
    ll tmp=-INF;
    int la0=(used+1)&(-used-1);
    la0=log2(la0);

    rep(bit0, 1<<(N-1-la0)){
        int bit=(bit0<<(la0+1))^(1<<la0);
        if(((used)^(bit))==used+bit){
            tmp=max(tmp, sum[bit]+dfs(used+bit));
        }
    }
    dp[used]=tmp;
    return tmp;
}

void solve(){
    cin>>N;
    rep(i,N)rep(j,N)cin>>a[i][j];

    rep(bit, 1<<N) sum[bit]=INF;
    rep(bit, 1<<N) dfs0(bit);

    rep(used, 1<<N) dp[used]=-INF;
	ans=dfs(0);
    cout<<ans<<endl;
}

int main(){
    solve();
}

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

int main(){
    int za[100][100] = {{0}}, x, y, n, i, j, a, x1, y1, ans = 0, k;
    scanf("%d %d %d",&x ,&y, &n);
    for(i = 0; i < x; i++){
        for(j = 0; j < y; j++) za[i][j] = 1; 
    }
    for(i = 0; i < n; i++){
        scanf("%d %d %d", &x1, &y1, &a);
        switch(a){
            case 1:
                for(k = 0; k < x1; k++){
                    for(j = 0; j < y; j++) za[k][j] = 0;
                }
                break;
            case 2:
            for(k = x1; k < x; k++){
                    for(j = 0; j < y; j++) za[k][j] = 0;
                }
                
                break;
            case 3:
                for(k = 0; k < x; k++){
                    for(j = 0; j < y1; j++) za[k][j] = 0;
                }
                break;
            case 4:
                for(k = 0; k < x; k++){
                    for(j = y1; j < y; j++) za[k][j] = 0;
                }
                break;
        }
    }

    for(i = 0; i < x; i++){
        for(j = 0; j < y; j++) {
            if(za[i][j]) ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <ctime>
using namespace std;
typedef long long ll;

const int INF = 100000000;
const int MAX_N = 100000;


int main(int argc, char *args[]) {
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;
	vector<int> Nums;
	int now = 1;
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == (char)('0' + now)) {
			cnt++;
		}else {
			Nums.push_back(cnt);
			now = 1 - now;
			cnt = 1;
		}
	}
	if (cnt != 0) {
		Nums.push_back(cnt);
	}

	if (Nums.size() % 2 == 0)Nums.push_back(0);

	int Add = 2 * K + 1;

	vector<int> sum(Nums.size() + 1);

	for (int i = 0; i < Nums.size(); i++) {
		sum[i + 1] = sum[i] + Nums[i];
	}
	int ans = 0;

	for (int i = 0; i < Nums.size(); i += 2){
		int left = i;
		int right = min(i + Add, (int)Nums.size());
		int tmp = sum[right] - sum[left];

		ans = max(tmp, ans);
	}

	cout << ans << endl;

}

Measured memory_bytes: 1272
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    char c;
    cin >> c;
    string ans;

    ans = c+1;

    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>

#define NUM 12

using namespace std;

void Change(const int s[], int c[], const int n) {
	for(int i = 0; i < n; i++) {
		c[i] = 0;
	}
	for(int i = 0; i < n; i++) {
		for(int k = 0; k < n; k++) {
			if(s[i] == s[k]) {
				c[i]++;
			}
		}
	}
}

int main() {
	while(1) {
		int s[NUM];
		int c[NUM];
		int n, count = 0;
		cin >> n;
		if(n == 0) break;
		for(int i = 0; i < n; i++) {
			cin >> s[i];
		}

		while(1) {
			Change(s, c, n);
			bool endflag = true;
			for(int i = 0; i < n; i++) {
				if(s[i] != c[i]) endflag = false;
			}
			if(endflag) break;
			else {
				count++;
				for(int i = 0; i < n; i++) {
					s[i] = c[i];
				}
			}
		}

		cout << count << endl;
		for(int i = 0; i < n; i++) {
			cout << s[i] << (i != n - 1 ? " " : "");
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
void main() {
  problem();
}

void problem() {
  auto N = scan!int;
  auto K = scan!int;
  auto A = scan!long(N);
  
  void solve() {
    foreach(i, a; A[K..N]) {
      writeln(a > A[i] ? "Yes" : "No");
    }
  }

  solve();
}

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

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

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


Measured memory_bytes: 10168
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double n,d=0;
    cin>>n;
    double a;
    for(int i=1;i<=n;i++)
    {
        if(i%2!=0)
            d++;
    }

    cout<<fixed<<setprecision(10)<<d/n<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys


def read():
    return sys.stdin.readline().rstrip()


def main():
    _, _, m = map(int, read().split())
    a = [int(i) for i in read().split()]
    b = [int(i) for i in read().split()]
    ans = min(a) + min(b)
    for i in range(m):
        x, y, c = map(int, read().split())
        ans = min(a[x - 1] + b[y - 1] - c, ans)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 18488
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("NO"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

bool f(int n, vp a, int s) {
  int l = 1, r = n;
  reverse(rng(a));
  for (P p : a) {
    int x = p.se;
    if (p.fi) { // aoki
      if (x == -1) r = min(r+1,n);
      else l = max(1,l-1);
    } else {
      if (x == -1) l = l+1;
      else r = r-1;
    }
    if (l > r) return false;
  }
  // cerr<<a<<endl;
  // cerr<<l<<" "<<r<<" "<<s<<endl;
  return l <= s && s <= r;
}

int main() {
  int h,w,n;
  scanf("%d%d%d",&h,&w,&n);
  int sa, sb;
  scanf("%d%d",&sa,&sb);
  vp a, b;
  v(string) s(2);
  cin>>s;
  rep(i,n) {
    rep(j,2) {
      if (s[j][i] == 'U') a.pb(P(j,-1));
      if (s[j][i] == 'D') a.pb(P(j,1));
      if (s[j][i] == 'L') b.pb(P(j,-1));
      if (s[j][i] == 'R') b.pb(P(j,1));
    }
  }
  if (!f(h,a,sa)) dame;
  if (!f(w,b,sb)) dame;
  puts("YES");
  return 0;
}






















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

int main() {
  int n;
  while (cin >> n) {
    if (n==-1) {
      break;
    }
    vector<int> ve;
    while (true) {
      ve.push_back(n%4);
      n/=4;
      if (n==0) {
	break;
      }
    }
    for (int i = ve.size()-1; i>=0; i-- ) {
      cout << ve[i] << flush;
    }
	cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3012
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
const double pai=acos(-1.0);
double a,b,x;
int main(){
	scanf("%lf%lf%lf",&a,&b,&x);
	double V=a*a*b;
	if(x>(V/2)){
		double y=V-x;
		double h=(y*2.0)/(a*a);
		double jiao=atan(h/a);
		printf("%.10lf",(jiao/pai)*180.0);
	}
	else{
		double y=x;
		double h=(y*2.0)/(b*a);
		double jiao=atan(b/h);
		printf("%.10lf",(jiao/pai)*180.0);
	}
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
 
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    /*     input! {
        n: usize,
        mut plan: [(i32, i32, i32); n],  // Vec<(i32, i32, i32)>
    }
 */
    input! {
        s:String,
    }

    let mut xx = 0;
    let mut cnt = 0;
    for (i,c) in s.chars().enumerate() {
        if c == 'B' {
            xx += i;
            cnt += 1;
        }
    }
    let last_idx = s.len() - 1;
    let start_idx = s.len() - cnt ;
    let yy = (start_idx + last_idx) * cnt / 2;
    println!("{}", yy - xx);


}    


Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>

int main()
{
        char dance[100];
        int count=0;

        int i=0,j=1;

        scanf("%s",dance);

        while(1)
        {
                if(dance[i]=='R'||dance[i]=='U'||dance[i]=='D')
                {
                        count++;
                }
                if(i+2>strlen(dance)) {break;}

                i=i+2;
        }

        while(1)
        {
                if(dance[j]=='L'||dance[j]=='U'||dance[j]=='D')
                {
                        count++;
                }
                if(j+2>strlen(dance)) {break;}

                j=j+2;
        }
        if(count==strlen(dance)) {printf("Yes\n");}
        else{printf("No\n");}

        return 0;
}


Measured memory_bytes: 128
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

/*-----<Defines>-----*/
#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     flush           fflush(stdout)

using ull=unsigned long long;
using ll=long long;
using ld=long double;
/*-----</Defines>-----*/

/*-----<Debugging Stuff>-----*/
string to_string(char s)
{   string res="'''";res[1]=s;return res; }

string to_string(string s)
{   return '"'+s+'"'; }

string to_string(const char* s)
{   return to_string((string)s); }

string to_string(bool b)
{   return (b?"true":"false"); }

template<typename A, typename B>
string to_string(pair<A, B> p)
{   return "("+to_string(p.F)+", "+to_string(p.S)+")"; }

template<typename A>
string to_string(A v)
{
    bool first=1; string res="{";
    for(const auto &x:v)
    {
        if(!first)  res+=", ";
        first=0;
        res+=to_string(x);
    }
    res+="}";
    return res;
}

void debug() { cout<<"\n"; }
template<typename Head, typename... Tail>
void debug(Head H, Tail... T)
{
    cout<<" "<<to_string(H);
    debug(T...);
}

#define show(...) cout << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
/*-----</Debugging Stuff>-----*/

/*-----<Mod Operations>-----*/
const int M=1e9+7;
inline int add(int a,int b,int p=M){ a=a+b; if(a>=p) a-=p; return a; }
inline int sub(int a,int b,int p=M){ a=a-b; if(a<0) a+=p; return a; }
inline int mul(int a,int b,int p=M){ a=(a*1ll*b)%p; return a; }
/*-----</Mod Operations>-----*/

/*-----<Constants>-----*/
const ld pi=acos(-1),eps=1e-9;
const ll inf=1e18;
const int N=1;
/*-----</Constants>-----*/

void solve()
{
    int n;
    cin>>n;

    int d;
    cin>>d;

    d*=d;

    int ans=0;
    for(int i=0;i<n;++i)
    {
        int x,y;
        cin>>x>>y;

        x*=x;
        x+=y*y;

        if(x<=d)
            ++ans;
    }

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




Measured memory_bytes: 3640
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;

int main()
{
	int n;
	scanf("%d", &n);
	ll a[300000];
	for(int i=0; i<(1<<n); i++){
		scanf("%lld", &a[i]);
	}
	vector<P> am[300000];
	am[0].push_back(P(a[0], 0));
	am[1].push_back(P(a[1], 1));
	am[1].push_back(P(a[0], 0));
	sort(am[1].begin(), am[1].end());
	for(int k=2; k<(1<<n); k++){
		set<P> st;
		st.insert(P(a[k], k));
		for(int i=0; i<18; i++){
			if(((k>>i)&1)==1){
				st.insert(am[k&(~(1<<i))][0]);
				if((k&(~(1<<i)))>0) st.insert(am[k&(~(1<<i))][1]);
			}
		}
		auto itr=st.end();
		itr--;
		am[k].push_back(*itr);
		itr--;
		am[k].push_back(*itr);
	}
	ll ans=a[0]+a[1];
	printf("%lld\n", ans);
	for(int k=2; k<(1<<n); k++){
		ll ans1=am[k][0].first+am[k][1].first;
		if(ans<ans1) ans=ans1;
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 24704
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  string s;
  cin>>s;
  int a=(s[5]-'0')*10+(s[6]-'0');
  int b=(s[8]-'0')*10+(s[9]-'0');
  bool ok=true;
  
  if(a>4)ok=false;
  if(ok) cout<<"Heisei"<<endl;
  else cout<<"TBD"<<endl;
}









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

int main() {
    int a, b, h;
    cin >> a;
    cin >> b;
    cin >> h;
    
    int s = min(a, b) * h + abs(a - b) * h / 2;
    
    cout << s << endl;
    
    return 0;
}


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

int main()
{
  string s;
  cin >> s;
  int bee = 0;
  
  if(s[0] == '1') bee++;
  if(s[1] == '1') bee++;
  if(s[2] == '1') bee++;
  cout << bee << endl;
}

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

const int maxn = 1e5 + 5;

int n;
char s[maxn], ch[10];

void get(int x)
{
	printf("%d\n", x);
	fflush(stdout);
	scanf("%s", ch);
	if(ch[0] == 'V')
		exit(0);
	s[x] = ch[0];
}

int main()
{
	scanf("%d", &n);
	int l = 0, r = n - 1;
	get(0);
	get(n - 1);
	while(l + 2 < r)
	{
		int k = (r - l) >> 1, mid;
		if(k & 1)
			mid = (l + r) / 2 - 1;
		else
			mid = (l + r) / 2;
		get(mid);
		if(s[l] == s[mid])
			l = mid;
		else
			r = mid;
	}
	for(int i = l; i <= r; i++)
		get(i);
	return 0;
}

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

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

    int h, w, m;
    cin >> h >> w >> m;

    vector<int> x(h), y(w);
    vector<pair<int, int>> z(m);
    for (int k = 0; k < m; k++) {
        int i, j;
        cin >> i >> j;
        i--; j--;

        x[i]++;
        y[j]++;
        z[k] = { i, j };
    }

    int mx = *max_element(x.begin(), x.end());
    int my = *max_element(y.begin(), y.end());

    long long a = 0, b = 0;
    for (int i = 0; i < h; i++) {
        if (x[i] == mx) a++;
    }
    for (int j = 0; j < w; j++) {
        if (y[j] == my) b++;
    }

    long long r = 0;
    for (int k = 0; k < m; k++) {
        auto [i, j] = z[k];
        if (x[i] == mx && y[j] == my) r++;
    }

    cout << mx + my - (r >= a * b) << endl;

    //一番多いやつでいいんだよね高々1個減るだけだから
    //候補の中に1個でも爆弾が存在しないマスがあるかどうか

    return 0;
}

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


int main() {
  string s; cin >> s;
  
  int a=s.at(0)-'0';
  int b=s.at(1)-'0';
  int c=s.at(2)-'0';
  int d=s.at(3)-'0';
  if ((a+b+c+d)==7) cout <<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
  else if ((a+b+c-d)==7) cout <<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
  else if ((a+b-c+d)==7) cout <<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
  else if ((a+b-c-d)==7) cout <<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
  else if ((a-b+c+d)==7) cout <<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
  else if ((a-b+c-d)==7) cout <<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
  else if ((a-b-c+d)==7) cout <<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
  else if ((a-b-c-d)==7) cout <<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
}

Measured memory_bytes: 256
/***** author : @C0d1ngPhenomena *****/

	#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		ll N;
		cin>>N;
		set<string> my;

		string a;

		for (int i = 0; i < N; ++i)
		{
			cin>>a;
			my.insert(a);
		}

		cout<<my.size();
		return 0;
	}



Measured memory_bytes: 19200
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void){

    int a[5]={0};
    string str="null";
    while(scanf("%d,%d,%d,%d,%d",&a[0],&a[1],&a[2],&a[3],&a[4])!=EOF){
        sort(a,a+5);
        if(((a[0]==a[1])&&(a[2]==a[3])&&(a[2]==a[1]))||((a[1]==a[2])&&(a[2]==a[3])&&(a[3]==a[4])))str="four card";
        else if(((a[0]==a[1])&&(a[1]==a[2])&&(a[3]==a[4]))||((a[0]==a[1])&&(a[2]==a[3])&&(a[3]==a[4])))str="full house";
        else if(((a[0]==1)&&(a[1]==10)&&(a[2]==11)&&(a[3]==12)&&(a[4]==13))||((a[0]+1==a[1])&&(a[1]+1==a[2])&&(a[2]+1==a[3])&&(a[3]+1==a[4])))str="straight";
        else if(((a[0]==a[1])&&(a[1]==a[2]))||((a[1]==a[2])&&(a[2]==a[3]))||((a[2]==a[3])&&(a[3]==a[4])))str="three card";
        else if(((a[0]==a[1])&&((a[2]==a[3])||(a[3]==a[4])))||((a[1]==a[2])&&(a[3]==a[4])))str="two pair";
        else if((a[0]==a[1])||(a[1]==a[2])||(a[2]==a[3])||(a[3]==a[4]))str="one pair";

        cout<<str<<endl;
    }
	return 0;
}

Measured memory_bytes: 1236
//FA専用
#include <bits/stdc++.h>
using namespace std;
#define int long long
const long long LINF=1e18;
using ld=long double;
int a,b,c,d,e,f,k,n,m,h,w,ans,cnt;
char C;
string s,t,u;
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}
template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}
void yy(bool a){
  cout<<(a?"Yes":"No")<<endl;
}
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
const int MOD=1e9+7;
std::vector<int> Factorial(5e6),Finverse(5e6);
int pw(int n,int k){
  if(k<0)return pw(n,k+MOD-1);
  int res=1;
  while(k){
    if(k&1)res*=n;res%=MOD;
    n*=n;n%=MOD;
    k>>=1;
  }
  return res;
}
int nCk(int n,int k){
  int res=1;
  for(int i=0;i<k;i++)res*=(n-i),res%=MOD;
  for(int i=1;i<=k;i++)res*=pw(i,MOD-2),res%=MOD;
  return res;
}

signed main(){
  cin>>n>>a>>b;
  ans=pw(2,n)-1;
  ans-=nCk(n,a);
  ans-=nCk(n,b);
  ans%=MOD;ans+=MOD;ans%=MOD;

  fin(ans);
}


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

def solve():
    N = int(input())
    Vs = list(map(int, input().split()))

    Vs.sort()

    new_v = (Vs[0]+Vs[1])/2

    if N == 2:
        print(new_v)
        return

    for i in range(2, N):
        new_v = (new_v+Vs[i])/2

    print(new_v)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int ans[504][200004];

int main(){
  int N, K;
  scanf("%d", &N);
  scanf("%d", &K);
  std::vector<int > A(N);
  for (int i=0; i<N; i++){
    scanf("%d", &A[i]);
    ans[0][i]=A[i];
  }
  for (int j=1; j<500; j++){
    std::vector<int> diff(N+4, 0);
    for (int i=0; i<N; i++){
      if (i+ans[j-1][i]+1<N) diff[i+ans[j-1][i]+1]--;
      diff[std::max(0, i-ans[j-1][i])]++;
    }
    int counter=0;
    for (int i=0; i<N; i++){
      //if (j==1) printf("diff[%d]=%d\n", i,diff[i]);
      counter+=diff[i];
      ans[j][i]=counter;
    }
  }
  if (K>=500){
    //for (int i=0; i<2000000000000; i++){
    for (int i=0; i<N; i++){
      printf("%d%c", N, (i==N-1)?'\n':' ');
    }
  } else {
    for (int i=0; i<N; i++){
      printf("%d%c", ans[K][i], (i==N-1)?'\n':' ');
    }
  }
  return 0;
}


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

using namespace std;

int main()
{
	int r, g, b;
	cin >> r >> g >> b;

	int total = 100 * r + 10 * g + b;

	if (total % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	
}


Measured memory_bytes: 3636
#!/usr/bin/env python3
import sys
from bisect import bisect_left
from collections import Counter
INF = float("inf")

KETA_MAX = 10


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(N: int, a: "List[int]"):
    keta = [Counter() for _ in range(KETA_MAX)]
    for i in range(N):
        x = a[i]
        for j in range(KETA_MAX):
            keta[j][x & 1] += 1
            x >>= 1

    for cnt in keta:
        if cnt[1] == 0:
            continue
        elif cnt[1] == cnt[0]*2:
            continue
        else:
            no()
            return
    yes()
    return

    # print(*keta, sep="\n")
    # def solve(N: int, a: "List[int]"):
    #     a.sort()
    #     used = Counter(a)
    #     used_orig = used.copy()
    #     x = [a[0]]
    #     used[0] -= 1

    #     # print("first, ", a[0])
    #     # 2番目の帽子を全探索
    #     for i in range(1, N):
    #         # print("2nd, ", a[i])
    #         x.append(a[i])
    #         used[i] -= 1
    #         for j in range(2, N):
    #             cand = x[-1] ^ x[-2]
    #             # print("cand, ", cand)
    #             pl = bisect_left(a, cand)
    #             if pl >= len(a):
    #                 break
    #             if cand == a[pl] and used[cand] > 0:
    #                 x.append(cand)
    #                 used[pl] -= 1
    #             else:
    #                 break
    #         else:
    #             yes()
    #             print(x)
    #             print(used)
    #             return
    #         x = [a[0]]
    #         used = used_orig.copy()
    #     no()
    #     return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()


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

int euclid(int, int);
int multiple(int, int);

int main(void){
  int a, b;
  while(cin >> a >> b){
    cout << euclid(a, b) << " " << multiple(a, b) << endl;
  }
  return 0;
}

int euclid(int a, int b){
  int r;
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

  return b;
}

int multiple(int a, int b){
  int xa = a;
  int xb = b;
  while(xa != xb){
    if(xa < xb) xa += a;
    else xb += b;
  }

  return xa;
}

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

int f(int a, int n) {
    int r = 1;
    
    for (int i = 0; i < n; i++) {
        r *= a;
    }
    
    return r;
}

int main() {
    int d, n;
    cin >> d >> n;
    int ans = f(100, d) * ((n == 100) ? n+1 : n);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
h,n = map(int,input().split())

ab = [list(map(int,input().split())) for i in range(n)]
ma = max(a for a,b in ab)


dp = [10**10]*(h+ma+1)
dp[0] = 0

for i in range(1,h+ma+1):
    dp[i] = min(dp[i-a]+b for a,b in ab)

print(min(dp[h:]))

Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef long double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define cerr if(true)cerr
void print(){cout<<endl;}
template<typename T,typename... Args>
void print(T a, Args... args) {cout<<a<<" ";print(args...);}
lli llipowerp(lli x, lli y, lli p=LLONG_MAX)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
template <typename T>
inline void printvec(vector<T> inp){
    for(auto it:inp) cout<<it<<" ";
    cout << endl;
}
//---------------------------------------------------------------------------------
int main(){
    lli n,k;
    cin>>n>>k;
    vector<lli> a(n+1);
    fori(n) cin>>a[i+1];
    map<lli,lli> mps;
    lli curr=1;
    lli count=1;
    lli start;
    while(1){
        if(mps.count(curr)){
            start=mps[curr];
            break;
        }
        else{
            mps[curr]=count;
            count++;
            curr=a[curr];
        }
    }
    //print(start,count,curr);
    if(n>k){
        
        lli ans = 1;
        for (lli i = 1; i <= k; i++)
        {
            ans = a[ans];
        }
        cout << ans << endl;
    }
    else{
        k-=(start-1);
        lli rem=k%(count-start);
        if(rem==0) rem=count-start;
        lli skip=start+rem-1;
        lli ans=1;
        for(lli i=1;i<=skip;i++){
            ans=a[ans];
        }
        cout<<ans<<endl;

    }


       
}

Measured memory_bytes: 17096
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

bool to[100][100]={};
int a[100],b[100];
    int N,M;
int g=0;
bool f[100];
bool Func(int n){
    f[n]=true;
    if(n==g){
        return true;
    }
    for(int i=1;i<=N;i++){
        if(to[n][i]&&!f[i]){
            if(Func(i))return true;
        }
    }
    return false;
}
int main(){
    cin>>N>>M;
    for(int i=0;i<M;i++){
        cin>>a[i]>>b[i];
        to[a[i]][b[i]]=true;
        to[b[i]][a[i]]=true;
    }
    int ans=0;
    for(int i=0;i<M;i++){
        for(int j=1;j<=N;j++)f[j]=false;
        to[a[i]][b[i]]=false;
        to[b[i]][a[i]]=false;
        g=b[i];
        if(!Func(a[i])){
            //cout<<i<<endl;
            ans++;
        }
        to[a[i]][b[i]]=true;
        to[b[i]][a[i]]=true;
    }
    cout<<ans;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pb push_back
//#define mp make_pair
#define eps 1e-9
#define pp pair < pair<ll,ll> , ll> 
#define fo(i,j,k) for(int i=j;i<=k;i++)
#define foll(i,j,k) for(ll i=j;i<=k;i++)
#define clr(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vll vector<ll>
#define sz(a) a.size()
#define len(a) a.length()
#define all(a) a.begin(),a.end()
#define io_file freopen("Contest/input_file.in", "r", stdin); freopen("Contest/output_file.in", "w", stdout)


const int MAXN = 2e5+5;
using namespace std;
ll power(ll x, ll y)
{
  ll res = 1;
  while(y>0)
  {
    if(y&1)
       {
         res = (res*x)%mod;
        }
     x = (x*x)%mod;
     y = y>>1;
  }
    return res;
}
std::vector<ll> divi[1000004];

void divisor(int n)
{
   for(ll i=1;i<=n;i++)
   {
     for(ll j=i;j<=n;j+=i)
     {
       divi[j].pb(i);
     }
   }
}

int n;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    cin>>n;
    if(n%10==0)
    {
    	cout<<10<<endl;
    }
    else {
    	ll ans = 0;
    	string s = to_string(n);
    	for(char c : s)
    	{
    		ans = ans + c-'0';
    	}
    	cout<<ans<<endl;
    }
   	return 0;


}


Measured memory_bytes: 23680
#include<iostream>
#include <string.h>
using namespace std;
int main() {
  string s;
  getline(cin,s);
  if (s[0] == 'S') {
    cout << "Cloudy";
  } else if (s[0] == 'C') {
    cout << "Rainy";
  } else {
    cout << "Sunny";
  }
  return 0;
}

Measured memory_bytes: 764
n = int(input())
a = sorted([int(i) for i in input().split()])

if n == 2:
    print(a[1] - a[0])
    print("{} {}".format(a[1], a[0]))
    exit()

if a[0] <= 0 and 0 <= a[-1]:
    import bisect
    print(sum(map(lambda x: abs(x), a)))
    x0 = bisect.bisect_left(a,0)

    # 0以下から0以上をひいていく（一番大きいものを除く）
    if a[-2] >= 0:
        if x0 == 0:
            x0 += 1
        print("{} {}".format(a[0], a[x0]))
        res = a[0] - a[x0]

        for x in a[x0+1:-1]:
            print("{} {}".format(res, x))
            res -= x
    else:
        res = a[0]

    # 一番大きいものから上のものと負の数を引いていく
    print("{} {}".format(a[-1], res))
    res = a[-1] - res
    for x in a[1:x0]:
        print("{} {}".format(res,x))
        res -= x

elif a[0] > 0:
    print(sum(a) - 2*a[0])

    print("{} {}".format(a[0],a[1]))
    res = a[0] - a[1]
    for x in a[2:-1]:
        print("{} {}".format(res, x))
        res -= x
    
    print("{} {}".format(a[-1], res))
else:
    print(-sum(a) + 2*a[-1])

    print("{} {}".format(a[-1],a[-2]))
    res = a[-1] - a[-2]
    for x in a[:-2]:
        print("{} {}".format(res, x))
        res -= x
    

Measured memory_bytes: 60500
from collections import deque

MOD = int(1e9) + 7
MAX = int(2e5)


def div(a, b):
    return a * pow(b, MOD-2, MOD) % MOD


FACT = [1] * (MAX+1)
for i in range(1, MAX+1):
    FACT[i] = (i * FACT[i-1]) % MOD
INV = [1] * (MAX+1)
INV[MAX] = div(1, FACT[MAX])
for i in range(MAX, 0, -1):
    INV[i-1] = (INV[i] * i) % MOD


def main():
    N, K = map(int, input().split())
    adj = [set() for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        adj[a-1].add(b-1)
        adj[b-1].add(a-1)
    ans = 1
    q = deque()
    q.append((0, -1))
    while len(q):
        cur, prev = q.pop()
        if len(adj[cur]) + 1 > K:
            print(0)
            return
        if prev == -1:
            tmp = FACT[K] * INV[K - (len(adj[cur]) + 1)]
        else:
            tmp = FACT[K - 2] * INV[K - 2 - (len(adj[cur])-1)]
        ans = (ans * tmp) % MOD
        for nxt in adj[cur]:
            if nxt == prev:
                continue
            q.append((nxt, cur))
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 82848
import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
s = S()

print(s.count("ABC"))

Measured memory_bytes: 38256
/* HARDWORK IS THE KEY TO SUCCESS.
       RATING IS TEMPORARY , KNOWLEDGE IS PERMANENT.!!!*/
    #include <bits/stdc++.h>
    #define pragma
    using namespace std;
    #define ll long long
    #define ld long double
    #define T ll t = 1; cin>>t; while(t--)
    #define vin ll n; cin>>n; vector<ll>x(n); for(ll i=0; i<n; i++) cin>>x[i]
    #define vout for(ll i=0; i<n; i++) cout<<x[i]<<" "
    #define ain ll n,k,i; cin>>n; ll a[n + 1]; for( i=1; i<=n; i++) cin>>a[i]
    #define aout for(ll i=0; i<n; i++) cout<<a[i]<<" "
    #define matin ll m,n; cin >> n; ll a[n + 1][n + 1] ; for(ll i=1;i<=n;i++) for(ll j=1;j<=n;j++) cin>>a[i][j];
    #define matout for(ll i=0;i<m;i++){for(ll j=0;j<n;j++) cout<<a[i][j]<<" "; cout<<"\n";}
    #define sin set<ll>s; ll n; cin>>n; ll tmp; for(ll i=0;i<n;i++){cin>>tmp; s.I(tmp);}
    #define sout for(auto it=s.begin();it!=s.end();++it) cout<<*it<<" "
    #define F first
    #define S second
    #define I insert
    #define pb push_back
    #define ppb pop_back
    #define AISORT sort(a,a+n)
    #define ADSORT sort(a,a+n,greater<ll>())
    #define VISORT sort(x.begin(),x.end())
    #define VDSORT sort(x.begin(),x.end(),greater<ll>())

    const ll maxs = 1e5+3;
    const ll maxs1 = 1e3+4;
    const ll mod = 1e9 + 7;

    //MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

    //POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

    //MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}

//     ll n;
//     ll a[maxs];
//     ll tree[maxs];
    bool vis[maxs];
    vector<ll>graph[maxs];
    //ALWAYS CLEAR THEM WHEN TESTCASES ARE GIVEN
    //ALWAYS RETURN WHEN ST == ED CONDITION IN SEGMENT TREES
    


    int main()
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        string s;
        cin >> s;
        if(s[0] == '7' || s[ 1] == '7' || s[2] == '7')
            cout << "Yes";
        else
            cout << "No";
        
    }

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

typedef long long ll;
const int MOD = 1000000007;
const int MAX = 1000000000;

int main(){
  int N;
  cin >> N;
  vector< pair<int, int> > L(N);
  for(int i = 0; i < N; i++){
    int x,l;
    cin >> x >> l;
    L[i].first = x + l;
    L[i].second = x - l;
  }
  sort(L.begin(), L.end());
  int res = 1;
  int idx = 0;
  for(int i = 1; i < N; i++){
    if(L[i].second < L[idx].first){
      continue;
    }else{
      res++;
      idx = i;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 1024
#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int n;
int main()
{
	fast;
	cin>>n;
	if (n<3)
	   cout<<0;
	else
	   cout<<n/3;
    return 0;
}

Measured memory_bytes: 384
from math import ceil, floor


def exist(A, B, x):
    """
    check if i and j exist such that Ai + Bj = x
    """
    max_i = x // A
    for i in range(max_i + 1):
        if (x - A * i) % B == 0:
            return True
    else:
        return False


A, B, C, D, E, F = [int(elem) for elem in input().split(' ')]

max_density = 0.
status_when_max_dens = {'water': 0, 'sugar': 0}
for x in range(1, F + 1):
    if exist(100 * A, 100 * B, x):
        for y in range(F - x + 1):
            if exist(C, D, y):
                density = y / (x + y)
                if (density >= max_density)\
                and (y <= x / 100 * E)\
                and (x + y <= F):
                    max_density = density
                    status_when_max_dens['water'] = x
                    status_when_max_dens['sugar'] = y


water = status_when_max_dens['water']
sugar = status_when_max_dens['sugar']
print(water + sugar, sugar)

Measured memory_bytes: 42076