akhauriyash/Code-Regression huggingface dataset:
//#define _USE_MATH_DEFINES
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }
inline int safe_mul(const int x, const int y) __attribute__ ((warn_unused_result));

vector<int> dx(500, 0);
vector<int> dy(500, 0);

inline bool good(const char c, const char c1, const char c2) {
    return c == c1 || c == c2;
}

bool check(const int w, const int h, int x, int y, const string& s, const string& t, char c1, char c2) {
    for (size_t i = 0; i < s.size(); ++i) {
        {
            char c = s[i];
            if (good(c, c1, c2)) {
                x += dx[c];
                y += dy[c];
                if (x < 1 || x > h || y < 1 || y > w)
                    return true;
            }
        }
        {
            char c = t[i];
            if (!good(c, c1, c2)) {
                int nx = x + dx[c];
                int ny = y + dy[c];
                if (nx >= 1 && nx <= h && ny >= 1 && ny <= w) {
                    x = nx;
                    y = ny;
                }
            }
        }
    }
    return false;
}


int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("out.txt", "w", stdout);
//    cin.tie(0);
//    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    dy['L'] = -1;
    dy['R'] = 1;
    dx['U'] = -1;
    dx['D'] = 1;

    int w,h;
    cin >> h >> w;
    int n;
    cin >> n;
    int sx, sy;
    cin >> sx >> sy;
    string s,t;
    cin >> s >> t;

    string go = "LURD";
    for (int i = 0; i < 4; ++i) {
        if (check(w, h, sx, sy, s, t, go[i], go[(i + 1) % 4]))
            FINAL_OUT("NO");
    }

    FINAL_OUT("YES");
}


Measured memory_bytes: 920
#include<stdio.h>
int main() {
    char a,b,s;
    scanf("%c%c%c",&a,&b,&s);
    if(a=='1'&&b=='1'&&s=='1'){
        printf("3\n");
    } else if((a=='1'&&b=='1'&&s=='0')||(a=='1'&&b=='0'&&s=='1')||(a=='0'&&b=='1'&&s=='1')){
printf("2");}
    else if((a=='0'&&b=='0'&&s=='1')||(a=='0'&&b=='1'&&s=='0')||(a=='1'&&b=='0'&&s=='0')){
        printf("1\n");
    }else{
        printf("0\n");
    }
    return 0;
}

Measured memory_bytes: 128
n=int(input())
a=list(range(0,101,7))
b=list(range(0,101,4))
ans=False
for i in a:
    for j in b:
        if i+j==n and i<=100 and j<=100:
            ans=True
            break
if(ans): print("Yes")
else: print("No")


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <string>
#include <limits.h>
#include <iomanip>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <set>
#include <bitset>
#include <unordered_map>
#include <string.h>
#define fastIo                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define MOD 1000000007

using namespace std;
int main()
{
    fastIo;
    string s,t;
    cin>>s>>t;

    int ans = INT_MAX;
    for(int i =0;i<=(s.length()-t.length());i++)
    {
        int m =0;
        for(int j=0;j<t.length();j++)
        {
            if(s[i+j]!=t[j])
                m++;
        }
        ans = min(ans,m);

    }
    cout<<ans<<endl;

    

   
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main()
{
	string s;
	cin >> s;

	REP(i, (int)s.size()){
		if (s[i] == 'A') cout << 'X';
		else if (s[i] == 'B') cout << 'Y';
		else if (s[i] == 'C') cout << 'Z';
		else cout << (char)(s[i] - 3);
	}
	cout << endl;
}



Measured memory_bytes: 3188
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

long long n, a[200009], s[200009], ans;

long long cntD(int L, int R, int m)
{
	long long tL = s[m];
	if (L) tL -= s[L - 1];
	long long tR = s[R] - s[m];
	return abs(tL - tR);
}

long long fun(int L, int R)
{
	int l = L, r = R;
	while (l + 1 < r) {
		int mid = (l + r) / 2;
		if (cntD(L, R, mid) < cntD(L, R, mid - 1)) l = mid;
		else r = mid;

	}
	return min(s[l] - s[L - 1], s[R] - s[l]);
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		s[i] = a[i];
		s[i] += s[i - 1];
	}
	ans = 1e18;
	for (int i = 2; i < n - 1; i++) {
		long long mi = fun(1, i);
		long long mx = s[i] - mi;
		long long tmp = fun(i + 1, n);
		mi = min(mi, tmp);
		mx = max(mx, s[n] - s[i] - tmp);
		ans = min(ans, mx - mi);
	}
	cout << ans << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string.h>
#include <stack>
#include <map>
#include <unordered_map>
#include <climits>
using namespace std;
const int INF = 1e9;
#define ll long long
#define int ll
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define testcase \
    int t;       \
    cin >> t;    \
    while (t--)
#define pb push_back
#define endl "\n"
#define deb1(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << " | " << #y << ": " << y << endl
#define deb3(x, y, z) cout << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl
#define deb4(x, y, z, w) cout << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << " | " << #w << ": " << w << endl
#define deb5(a, b, c, d, e) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(a) int((a).size())
#define pii pair<int, int>
#define fi first
#define se second
#define ld long double
#define vii vector<int>
#define all(v) v.begin(), v.end()
#define prec(n) fixed << setprecision(n)
const int MOD = (int)1e9 + 7;
const int MOD2 = 1007681537;
const ll LINF = (ll)1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-12;
inline ll gcd(ll a, ll b)
{
    ll r;
    while (b)
    {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
inline ll fpow(ll n, ll k, int p = MOD)
{
    ll r = 1;
    for (; k; k >>= 1)
    {
        if (k & 1)
            r = r * n % p;
        n = n * n % p;
    }
    return r;
}
template <class T>
inline int chkmin(T &a, const T &val) { return val < a ? a = val, 1 : 0; }
template <class T>
inline int chkmax(T &a, const T &val) { return a < val ? a = val, 1 : 0; }
inline void addmod(int &a, int val, int p = MOD)
{
    if ((a = (a + val)) >= p)
        a -= p;
}
inline void submod(int &a, int val, int p = MOD)
{
    if ((a = (a - val)) < 0)
        a += p;
}
inline int mult(int a, int b, int p = MOD) { return (ll)a * b % p; }
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }

template <class T>
inline void get_arr(T arr[], int n)
{
    for (int i = 0; i < n; i++)
        cin >> arr[i];
}
template <class T>
inline void print_arr(T arr[], int n)
{
    for (int i = 0; i < n; i++)
        cout << arr[i] << " ";
    cout << endl;
}

const int nmax=3005;
int dp[nmax][nmax];

int32_t main()
{
    int n;
    cin>>n;
    int arr[n];
    get_arr(arr,n);
    for(int L=n-1;L>=0;L--)
    {
        for(int R=L;R<n;R++)
        {
            if(L==R)
            {
                dp[L][R]=arr[L];
            }
            else
            {
                dp[L][R]=max(arr[L]-dp[L+1][R],arr[R]-dp[L][R-1]);
            }
        }
    }
    cout<<dp[0][n-1]<<endl;
}


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

using namespace std;

int main() {
    vector<int> s(3);
    for (int i = 0; i < 3; i++) {
        cin >> s[i];
    }
    int ans = 0;
    while (1) {
        bool finish = false;
        for (int i = 0; i < 3; i++) {
            if (s[i]%2 == 1) finish = true;
        }
        if (finish) break;
        vector<int> ns = s;
        for (int i = 0; i < 3; i++) {
            int sum = 0;
            for (int j = 0; j < 3; j++) {
                if (j==i) continue;
                sum += s[j] / 2;
            }
            ns[i] = sum;
        }
        ++ans;
        if (s == ns) {
            ans = -1;
            break;
        }
        s = ns;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define FOR(i,l,r) for (int i=(l); i<(r); ++i)
#define sz(x) (int)(x).size()
#define dbg(x) cout << (#x) << ' ' << (x) << endl
#define memfill(x, a) memset((x), (a), sizeof(x))
#define all(x) (x).begin(), (x).end()

typedef string str;
typedef long long int64;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

const int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const int64 LLINF = 1LL << 60LL;

/*-------- END OF TEMPLATE --------*/

#define PI 3.1415926535

/*
area = pi * r^2
2 pi * r
*/

int main() {
    int r; scanf("%i",&r);
    double circum = 2 * r * PI;
    printf("%.6f\n",circum);
}


Measured memory_bytes: 3744
A, B, Q = map(int, input().split())
INF = 10 ** 18
S = [-INF] + [int(input()) for _ in range(A)] + [INF]
T = [-INF] + [int(input()) for _ in range(B)] + [INF]
X = [int(input()) for _ in range(Q)]


def binary_search(q, A):
    l, r = 0, len(A)
    while r - l > 1:
        mid = (l + r) // 2
        if q > A[mid]:
            l = mid
        else:
            r = mid
    return A[l], A[r]


def main():
    for x in X:
        s1, s2 = binary_search(x, S)
        t1, t2 = binary_search(x, T)
        print(min(abs(s-t) + min(abs(s-x), abs(t-x)) for s in [s1, s2] for t in [t1, t2]))
    return

if __name__ == '__main__':
    main()


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

using i64 = long long int;

int main(){
    int n, t, a;
    cin >> n >> t >> a;
    int ans = -1;
    double min = 1e9;
    for(int i=1;i<=n;++i){
        int h;
        cin >> h;
        if(abs(t-h*0.006-a) < abs(min)){
            ans = i;
            min = t-h*0.006-a;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector <ll> vi;
typedef pair <ll, ll> pi;
typedef vector <pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(),x.end()
#define SZ(x) (ll) x.size()
#define f first
#define s second
#define MAXN 100100
ll INF = 1e18;
deque<pi> dq;
ll max_constant;
ll N,E,T;
ll off;
ll D[MAXN];
ll dp[MAXN];
ll d2[MAXN];
queue<pi> Q;
multiset<ll> S2;
ll X[MAXN];
 
int main(){
	cin>>N>>E>>T;
	for (int i=1;i<=N;++i)cin>>D[i];
	// X[0] = 0;
	// for (int i=1;i<=N;++i){
	// 	X[i] = INF;
	// 	for (int j=0;j<i;++j){
	// 		X[i] = min(X[i], X[j] + D[i] - D[j] + max(T, 2*D[i] - 2*D[j+1]) );
	// 	}
	// }

	max_constant = INF;
	Q.push(mp(T+2*D[1], -2*D[1]));
	S2.insert(T);
 
	for (int i=1;i<=N;++i){
		while (SZ(Q) && Q.front().f <= 2*D[i]){
			pi cur = Q.front();Q.pop();
			max_constant = min(max_constant, cur.s);
			S2.erase(S2.find(cur.f+cur.s));
		}
		// cout<<max_constant<<'\n';
		dp[i] = INF;
		// Case 1 is using the constant
		dp[i] = min(dp[i], 3*D[i]+max_constant);
		// Case 2: is waiting
		dp[i] = min(dp[i], T + D[i] - D[i-1] + dp[i-1]);
		// Case 3: Need to wait
		if (SZ(S2))dp[i] = min(dp[i], *S2.begin() + D[i]);
		// cout<<i<<' '<<-2*D[i+1]<<' '<<D[i]<<' '<<dp[i]<<' '<<-2*D[i+1] - D[i]+ dp[i]<<'\n';
		Q.push(mp(T+2*D[i+1], -2*D[i+1] - D[i]+ dp[i]));
		S2.insert(T-D[i]+dp[i]);
		// cout<<"Ins "<<T-D[i]+dp[i]<<'\n';
		// cout<<X[i]<<' '<<dp[i]<<'\n';
		// assert(dp[i] == X[i]);
	}
	cout<<dp[N] + E-D[N];
}

Measured memory_bytes: 4480
#include <stdio.h>

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

  int a, ans = 0;
  for (int i = 0; i < N; i++) {
    scanf("%d", &a);
    if(a%2 != 0) ans = 1;
  }

  if(ans) printf("first\n");
  else printf("second\n");

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>  // sort, 二分探索, etc
#include <iomanip>  // setprecision (浮動小数点の出力の誤差)
#include <map>
#include <queue>
#include <set>
#include <stack>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=a,i##_len=(b);i<i##_len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define cauto const auto&
#define UNIQUE(v) (v).erase( unique(all(v), (v).end() );
#define SZ(x) ((ll)(x).size()) // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define INF 1000000000000
#define MOD 1000000007
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

using namespace std;
using ll = long long;
using ull = unsigned long long;

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;}

const char newl = '\n';

ll qp(ll a,ull b){ll ans=1;do{if(b&1u)ans*=a;a*=a;}while(b>>=1u);return ans;}
ll qp(ll a,ull b,ll mod){ll ans=1;do{if(b&1u)ans=ans*a%mod;a=a*a%mod;}while(b>>=1u);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll comb(int n, int r) {
    vector<vector<ll> > v(n+1, vector<ll>(r+1, 0));
    for(int i=0;i<n+1;i++) {v[i][0]=1; if(i < r+1)v[i][i]=1; }
    for(int i=1;i<n+1;i++) {for(int j=1;j<min(i,r+1);j++) {v[i][j]=v[i-1][j-1]+v[i-1][j];}}
    return v[n][r];
}

// INT_MAX   = 2.1e+09 (2147483647)
// LONG_MAX  = 9.2e+18 (9223372036854775807)
// LLONG_MAX = 9.2e+18 (9223372036854775807)


int main() {
    ll h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    ll start = h1 * 60 + m1;
    ll end = h2 * 60 + m2;

    cout << end - start - k;

    return 0;
}


Measured memory_bytes: 3176
#include <stdio.h>


int main(){
	int a, b, c, d;
	scanf("%d", &d);
	a = d / 3600;
	b = (d - (a * 3600)) / 60;
	c = d - (a * 3600) - (b * 60);
	printf("%d:%d:%d\n",a,b,c);

	return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

//#include<bits/stdc++.h>

// #include "beginner_138/beginner_138.h"
// Still dunno how to put linker 

using namespace std; 

// Sort that saves index.


void c_sol02(){
    int n ;
    int n_max = 100000;

    cin >> n;
    vector<int> B(n);
    vector<int> A(n);

    fill(B.begin(),B.end(),n_max);
    for(int i = 0; i < n-1; i++)cin >> B[i];
    
    // Use min
    A[0] = B[0];
    for(int i = 1 ; i < B.size(); i++){
        A[i] = min(B[i-1],B[i]);
    }

    int sum = 0;
    for(int i = 0; i < n; i++) sum+= A[i];

    cout << sum;

}

void c_sol01(){
    int n ;
    cin >> n;
    vector<int> B(n-1);
    for(int i = 0; i < n-1; i++)cin >> B[i];

    // Sort and register index
    sort(B.begin(), B.end());

    for(int i = 0; i < B.size(); i++) cout << i << " ";
    cout<<endl;
    vector<int> A(n);
    fill(A.begin(),A.end(), -1); // Enter value for empty, which is -1

    for(int i = 0; i < B.size(); i++){
        if(A[i]==-1)A[i] = B[i];
        if(A[i+1]==-1)A[i+1] = B[i];
    }

    int ans = 0;
    for(int i = 0; i < n; i++) ans += i;

    cout << ans;
}

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

    c_sol02();
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int i=a,inc=(b-a)/abs(b-a); i!=b ; i+=inc)
#define scan(arr,n) for(int i=0;i<n;i++) cin>>arr[i]
#define deb(x) cout<<#x<<"->"<<x<<endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define print(arr,a,b) for(int i=a;i!=b;i++){cout<<arr[i]<<" ";}cout<<endl;
using ll=long long int;
int arr_min(int arr[],int a,int b){ int min=arr[0]; for(int i=a;i!=b;i++){if(min>arr[i]) min=arr[i];}return min;}
int arr_max(int arr[],int a,int b){ int max=arr[0]; for(int i=a;i!=b;i++){if(max<arr[i]) max=arr[i];}return max;}

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

	#ifndef ONLINE_JUDGE
      	freopen("input.txt", "r", stdin);
      	freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t-->0){
    	int n,k;
    	cin>>n>>k;
    	int arr[101]={0};

    	for(int i=0;i<k;i++)
    	{
    		int x;
    		cin>>x;
    		for(int i=0;i<x;i++)
    		{
    			int y;
    			cin>>y;
    			arr[y]++;
    		}
    	}
    	int count=0;
    	for(int i=1;i<=n;i++)
    	{
    		if(arr[i]==0)
    			count++;
    	}
    	
    	cout<<count<<endl;
    }
    return 0;
}

Measured memory_bytes: 3648
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

fn main() {
    input! {
        s: chars
    }
    let mut sm = vec![];
    let mut i = 0;
    while i < s.len() {
        if i+1<s.len() && s[i] == 'B' && s[i+1] == 'C' {
            sm.push('D');
            i+=2;
        } else {
            sm.push(s[i]);
            i+=1;
        }
    }
    
    let mut cnt = 0u64;
    let mut ret = 0u64;
    for j in 0..sm.len() {
        let i = sm.len()-1 - j;
        if sm[i] == 'B' || sm[i] == 'C' {
            cnt = 0;
        } else if sm[i] == 'A' {
            ret += cnt;
        } else {
            cnt += 1;
        }
    };
    println!("{}" ,ret);
}



Measured memory_bytes: 6396
a = str(input())
apple = []
orange = []
for i in a:
    apple.append(int(i))
x = apple[0]
y = apple[1]
z = apple[2]
w = apple[3]
if apple[0] + apple[1] + apple[2] + apple[3] == 7:
    print("{o}+{p}+{q}+{r}=7".format(o=x, p=y, q=z, r=w))
elif apple[0] - apple[1] + apple[2] + apple[3] == 7:
    print("{o}-{p}+{q}+{r}=7".format(o=x, p=y, q=z, r=w))
elif apple[0] - apple[1] - apple[2] + apple[3] == 7:
    print("{o}-{p}-{q}+{r}=7".format(o=x, p=y, q=z, r=w))
elif apple[0] - apple[1] - apple[2] - apple[3] == 7:
    print("{o}-{p}-{q}-{r}=7".format(o=x, p=y, q=z, r=w))
elif apple[0] + apple[1] - apple[2] + apple[3] == 7:
    print("{o}+{p}-{q}+{r}=7".format(o=x, p=y, q=z, r=w))
elif apple[0] + apple[1] - apple[2] - apple[3] == 7:
    print("{o}+{p}-{q}-{r}=7".format(o=x, p=y, q=z, r=w))
elif apple[0] + apple[1] + apple[2] - apple[3] == 7:
    print("{o}+{p}+{q}-{r}=7".format(o=x, p=y, q=z, r=w))
elif apple[0] - apple[1] + apple[2] - apple[3] == 7:
    print("{o}-{p}+{q}-{r}=7".format(o=x, p=y, q=z, r=w))
else:
    pass

Measured memory_bytes: 38256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;

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

		// 1行、2つ(複数)数字
		String[] ss0 = br.readLine().trim().split(" ", 0);
		long N = Integer.parseInt(ss0[0]);
		long A = Integer.parseInt(ss0[1]);
		long B = Integer.parseInt(ss0[2]);
		
		if(A>B){ System.out.println(0); return; }
		if(A==B){ System.out.println(1); return; }
		if(N==1){ System.out.println(0); return; }

		
		if(N==2){ System.out.println(1); return; }

		//if( N<(B-A+1) ) { System.out.println(0); return; }
		
		System.out.println( (B-A)*(N-2) +1 );

		return;
	}
	//-----------------------------------------------------------------
	// Debug.Print
	static void dp(String s) {
		System.out.println(s);
	}
	static void dp(StringBuilder s) { dp(s.toString()); }
	static void dp(int i) { dp(String.valueOf(i)); }
	static void dp(long i) { dp(String.valueOf(i)); }




}


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

int main() {
	int N;
	cin >> N;
	vector<int> price(N);
	int sum = 0;

	for (int i = 0; i < N; i++) {
		cin >> price.at(i);
		sum += price.at(i);
	}

	sort(price.begin(), price.end());
	cout << sum - price.at(N - 1) / 2 << endl;
}

Measured memory_bytes: 256
// TO KAISE HAI AAP LOG!! //

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

#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define F first
#define S second
#define all(v) v.begin(),v.end()
ll mod=1e9+7;
 
/*/----------------------------- Code begins -----------------------------/*/
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll t=1,tc;
    //cin>>t;
    for(tc=1;tc<=t;tc++){
      ll a,b,c,k;
      cin>>a>>b>>c>>k;
      while(b<=a && k>0){
          b*=2;
          k--;
      }
      while(c<=b && k>0){
          c*=2;
          k--;
      }
      if(b>a && c>b)cout<<"Yes";
      else cout<<"No";
    }
	return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

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

    char s;
    cin >> s;
    if(s == 'A'){
        cout << 'T';
    }else if(s == 'T'){
        cout << 'A';
    }else if(s == 'G'){
        cout << 'C';
    }else{
        cout << 'G';
    }
    cout << endl;

    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> Q;
const ll mod = 1000000007;
const ll INF = 1000000000000000;

ll n, a[30], b[30], c[30];
ll bit[100010], ans;

bool used[100010];

ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= n)
	{
		bit[i] += x;
		i += i & -i;
	}
}

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

ll div(ll x)
{
	return pow_mod(x, mod - 2);
}



int main(void)
{
	cin >> n;
	ll ans = 0;

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

	for (int i = 1; i <= n; i++)
	{
		ans += b[a[i]];
		if (i < n)
		{
			if (a[i] + 1 == a[i + 1])
			{
				ans += c[a[i]];
			}
		}
	}

	cout << ans << endl;
	
	int www;
	cin >> www;
}


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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
  
  char x='a';
  char y='A';
  char ans;
  cin>>ans;

  rep(i,26){
    if(x==ans){
      cout<<'a'<<endl;
      return;
    }
    x++;
  }

  rep(i,26){
    if(y==ans){
      cout<<'A'<<endl;
      return;
    }
    y++;
  }
  
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 7792
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<queue>
using namespace std;

typedef pair<int, int> pi;
pair <int, int>p;
int n, m, c;
char ma[1001][1001];
int x, y;
int te[1001][1001];
int xw[4] = { 1, 0, -1, 0 };
int yw[4] = { 0, 1, 0, -1 };
char name[10] = { '1', '2', '3', '4', '5', '6', '7', '8', '9' };
int nat = 0;
int na;
int op = 10000;
int main()
{
	queue<pi> q;
	cin >> n >> m >> na;
	for (int i = 0; i < n; i++){
		for (int i2 = 0; i2 < m; i2++){
			cin >> ma[i][i2];
			te[i][i2] = op;
			if (ma[i][i2] == 'S'){
				p.first = i;
				p.second = i2;
			}
		}
	}

	int count;

	count = 0;
	q.push(p);

	te[p.first][p.second] = 0;
	while (!q.empty()){
		p = q.front();
		q.pop();

		for (int i = 0; i < 4; i++){
			x = p.first + xw[i];
			y = p.second + yw[i];
			if (0 <= x && x < n && 0 <= y && y < m && ma[x][y] != 'X' && te[x][y] == op){

				if (ma[x][y] == name[nat]){
					while (!q.empty()){ q.pop(); }
					q.push(make_pair(x, y));
					count += te[p.first][p.second] + 1;
					nat++;
					if (nat == na){ cout << count << endl; return 0; }
					for (int i2 = 0; i2 <= n; i2++){
						for (int i3 = 0; i3 <= m; i3++){
							te[i2][i3] = op;
						}
					}
					te[x][y] = 0;
					break;
				}
				else{
					q.push(make_pair(x, y));
					te[x][y] = te[p.first][p.second] + 1;
				}
			}
		}
	}
}

Measured memory_bytes: 8028
#pragma GCC optimize("O3")
                #pragma comment(linker, "/stack:200000000")
                #pragma GCC optimize("unroll-loops")
                 
                #include <algorithm>
                #include <bitset>
                #include <cassert>
                #include <chrono>
                #include <cmath>
                #include <complex>
                #include <cstdio>
                #include <cstdlib>
                #include <cstring>
                #include <ctime>
                #include <deque>
                #include <functional>
                #include <iomanip>
                #include <iostream>
                #include <iterator>
                #include <limits>
                #include <climits>
                #include <list>
                #include <map>
                #include <numeric>
                #include <queue>
                #include <random>
                #include <ratio>
                #include <set>
                #include <sstream>
                #include <stack>
                #include <string>
                #include <unordered_map>
                #include <unordered_set>
                #include <utility>
                #include <vector>
                using namespace std;
                 
                typedef long long ll;
                typedef long double LD;
                #define int ll
                #define double LD
                #define pb push_back
                #define mp make_pair
                #define REP(i,n) for (int i = 0; i < n; i++)
                #define loop(i,n) for (int i = 0; i < n; i++)
                #define FOR(i,a,b) for (int i = a; i < b; i++)
                #define REPD(i,n) for (int i = n-1; i >= 0; i--)
                #define FORD(i,a,b) for (int i = a; i >= b; i--)
                #define remax(a,b) a = max(a,b)
                #define remin(a,b) a = min(a,b)
                #define mem(a, b) memset(a, b, sizeof a)
                #define append push_back
                #define all(v) v.begin(),v.end()
                #define F first
                #define S second
                #define print(x) cout << (x) << endl
                #define PRECISION(x) cout << fixed << setprecision(x)
                #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
                #define N 1010
                #define pb push_back
                const double PI=acos(-1);
                const int MOD = 1000000007;
                const int FMOD = 998244353;
                const double eps = 1e-9;
                 
                mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
     			
     			
     			signed main()
     			{
     				int a;
					 cin>>a;
					 
					 cout<<a+pow(a,2)+pow(a,3);	
				}

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

#define ll       long long
#define ull      unsigned ll
#define pii      pair<int, int>
#define pll      pair<ll, ll>
#define mp       make_pair
#define ff       first
#define ss       second
#define sz(x)    (int) x.size()
#define all(v)   v.begin(), v.end()

template <typename T> inline void smin(T &a, T b) {a = a < b ? a : b;}
template <typename T> inline void smax(T &a, T b) {a = a > b ? a : b;}

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}

template <typename T> inline void Int(T &n) {
    n = 0; int f = 1; register int ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}

template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l); }

const int mod = (int) 1e9 + 7;

inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (ll) a * b % mod;}

const int inf = (int) 2e9 + 5;
const ll  Inf = (ll) 2e18 + 5;
const int N   = (int) 2e5 + 5;



int solve() {
    ll n, a, b; Int(n, a, b);
    if(a == 0) printf("0\n");
    else if(b == 0) printf("%lld\n", n);
    else {
       ll ans = n / (a + b) * a;
        if(n % (a + b) >= a) ans += a;
        else ans += n % (a + b);
        printf("%lld\n", ans);
    }
    return 0;
}

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int test = 1, tc = 0;
    //Int(test);
    //cin >> test;
    while (test--) {
        //printf("Case %d: ", ++tc);
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int X;
    cin >> X;
    ll ans = 0;
    for (int i = 1; i <= X; i++) {
        ll t = i;
        while(1){
            t *= i;
            if(t <= X) ans = max(ans, t);
            if(t >= X || t == 1)break;    
        }
    }
    pr(ans);
}

Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <math.h>           // fabs()
#include <stdbool.h>

int
main(int argc, char **argv)
{
	while (true)
	{
		int n;
		scanf("%d", &n);
		if (n == 0)
			break;

		int mp;
		double mbmi = 200.0;
		for (int i = 0; i < n; ++i)
		{
			int p, h, w;
			scanf("%d%d%d", &p, &h, &w);
			double m = h / 100.0;
			double rbmi = fabs(w / (m * m) - 22.0);
			if (rbmi < mbmi)
			{
				mbmi = rbmi;
				mp = p;
			}
			else if (rbmi == mbmi && p < mp)
				mp = p;
		}

		printf("%d\n", mp);
	}

	return 0;
}


Measured memory_bytes: 1732
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll MOD = 1e9 + 7;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N, A, B;
	cin >> N >> A >> B;
	ll sum = N / (A + B)*A;
	sum += min(N % (A + B), A);
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


ll solve(ll N, ll X, ll sum){
    ll Lp = pow(2,N+1)-3;
    ll Np = pow(2,N)-1;

    if(N == 0) return sum+1;

    if(X == 1) return sum;
    if(X > 1 && X <= Lp + 1) return solve(N-1,X-1,sum);
    if(X == Lp + 2) return solve(N-1,X-2,sum+1);
    if(X > Lp + 2 && X <= 2*Lp+2) return solve(N-1,X-Lp-2,sum+Np+1);
    if(X == 2*Lp+3) return sum+2*Np+1;
}

int main(){
    ll N; cin >> N;
    ll X; cin >> X;
    pr(solve(N,X,0));
    return 0;
}


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

#define endl "\n"
#define int long long int
#define mod 1000000007
#define vi vector<int>
#define pint pair<int,int>
#define vint vector<vector<int>>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const int N = 1e6+5;
int A[N], B[N], P[N];

int mat[1005][1005];
pint edges[N];
unordered_map<int, set<int>> m;

bool compare(vi a, vi b)
{
    return a[0] < b[0];
}

int lcm(int a, int b)
{
    return (a*b)/(__gcd(a,b));
}

int mypow(int a, int x)
{
    if(a<=1 || x==1) return a;
    if(x==0) return 1;

    int temp = mypow(a,x/2);
    if(x%2==0) return ((temp%mod) * (temp%mod))%mod;
    else return (a%mod * ((temp%mod) * (temp%mod))%mod)%mod;
}

int count_bits(int n)
{
    int cnt = 0;
    while(n)
    {
        n = n & (n-1);
        cnt++;
    }return cnt;
}

void bfs(int src, int n)
{
    unordered_map<int, bool> visited;
    for(int i=0;i<n;i++) visited[i] = false;
    queue<int> q;
    q.push(src);
    visited[src] = true;

    while(!q.empty())
    {
        int curr = q.front();
        q.pop();
        B[curr] -= min(B[curr], A[src]);
        //cout<<curr<<" "<<endl;

        for(auto neigh: m[curr])
        {
            if(visited[neigh] == false)
            {
                //cout<<neigh<<endl;
                q.push(neigh);
                visited[neigh] = true;
                m[src].erase(neigh);
                m[neigh].erase(src);
            }
        }
    }
}

void void_solve(int n)
{

}

int int_solve(int n)
{
    int i,ans = 0;
    for(i=1;i<n;i++)
    {
        ans += (n-1)/i;
    }return ans;
}

string string_solve(string s, int x)
{

}

bool bool_solve(int n)
{

}

int32_t main()
{
    //code
	IOS;

    int t,n,m,a,b,x,y,i,j,z;
    //cin>>t;
    t = 1;
    while(t--)
    {
        cin>>n;
        cout<<int_solve(n)<<endl;

        //if(bool_solve(n)) cout<<"YES"<<endl;
        //else cout<<"NO"<<endl;
        //void_solve(n);


    }

	return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int p(int i){
  int d,dmax;

  if(i == 2)
    return 1;

  dmax = sqrt(i)+1;
  for(d = 2; d <= dmax; d++){
	if(i%d == 0){
	  return 0;
	}

      }
  return 1;
}

int main(){
  int n;
  int i,j,count;

  

  while(1){
    scanf("%d", &n);
    if(n == 0)
      break;
    count=0;
    for(i = n+1  ; i <= 2*n ; i++){
      count += p(i);
    }
    printf("%d\n",count);
    
  }
  return 0;
}
	
	
  



Measured memory_bytes: 2040
#include<iostream>

using namespace std;

int n,ans,c[105];
char ch;

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>ch;
		if(!c[ch]) ans++,c[ch]=1;
	}
	if(ans==3) puts("Three");
	else puts("Four");
	return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		ArrayList<Integer> x = new ArrayList<>();
		ArrayList<Integer> y = new ArrayList<>();
		for (int i = 0; i <= 10000; i++) {
			x.add(in.nextInt());
			y.add(in.nextInt());
			if (x.get(x.size() - 1) == 0 && y.get(y.size() - 1) == 0) {
				break;
			}
		}
		for (int i = 0; i < x.size(); i++) {
			if (x.get(i) == 0 && y.get(i) == 0) {
				break;
			}
			System.out.println(Math.min(x.get(i), y.get(i)) + " " + Math.max(x.get(i), y.get(i)));
		}
	}
}	


Measured memory_bytes: 37436
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // [b,c) イテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
#include <iomanip>

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

cout << fixed << setprecision(10);
int64_t W, H, x, y; cin >> W >> H >> x >> y;

cout << W * H / 2. << " ";
if (x == W/2. && y == H/2.) cout << "1\n";
else cout << "0\n";

}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	ll k,a,b;
	cin>>k>>a>>b;
	ll ans=1;
	rep(i,k){
		if(b-a>2&&k-i>=2&&ans>=a){
			ans+=b-a;
			++i;
		}
		else ++ans;
	}
	cout<<ans<<endl;
	return 0;
}

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

public class Main{
	public static void main(String[] args){
		try{
			Scanner scanner = new Scanner(System.in);
			String input = scanner.nextLine();
			String[] nums = input.split(" ", 0);
			
			System.out.println(Integer.parseInt(nums[0]) + 1 - Integer.parseInt(nums[1]));
		} catch(IndexOutOfBoundsException e){
			e.printStackTrace();
		} catch(NumberFormatException e){
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 23764
N = int(input())
for i in range(N):
    a = list(map(int, input().split()))
    a = sorted(a)
    x = a[0]
    y = a[1]
    z = a[2]
    if x**2 + y**2 == z**2:
        print("YES")
    else:
        print("NO")
        

Measured memory_bytes: 7524
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
ll X, Y;
void func()
{
    cin >> X >> Y;
    ll ans = 0;
    while (X <= Y)
    {
        X *= 2;
        ++ans;
    }
    cout << ans << endl;
}
int main()
{
    func();
}

Measured memory_bytes: 3556
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
const ll MOD=998244353;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};
vector<mint> Ikano_Array(int n){
  vector<mint> res(n+1);
  for(int i=1;i<=n;++i){
    res[i] = (mint)1/i;
  }
  for(int i=1;i<=n;++i){
    for(int j=i*2;j<=n;j+=i){
      res[j] -= res[i];
    }
  }
  return res;
}
int main()
{
  int n;
  cin >> n;
  vector<mint> a(n);
  ll mxll = 0;
  rep(i,n){
    cin >> a[i].x;
    mxll = max(mxll,a[i].x);
  }
  int mx = mxll;
  vector<mint> num(mx+1);
  rep(i,n) num[a[i].x].x++;
  
  
  vector<mint> c = Ikano_Array(mx);
  
  vector<mint> sum(mx+1),sumeq(mx+1);

  rep1(i,mx){
    for(int j=i;j<=mx;j+=i){
      mint jj(j);
      sum[i] += num[j]*jj;
      sumeq[i] += jj*jj*num[j];
    }
  }

  //  rep1(i,mx) cout << i << ":" << sum[i].x << "\n";
  
  /*  
  rep(i,n){
    ll aa = a[i].x;
    for(ll j=1;j*j<=aa;++j){
      if(aa%j==0){
	sum[j] += a[i];
	sumeq[j] += a[i]*a[i];
	if(aa/j!=j){
	  sum[aa/j] += a[i];
	  sumeq[aa/j] += a[i]*a[i];	  
	}
      }      
    }
  }
  */
  mint res(0);
  rep1(i,mx){
    sum[i] = (sum[i]*sum[i]-sumeq[i])/2;
    res += c[i] * sum[i];
  }

  cout << res.x << "\n";
  
  return 0;
}


Measured memory_bytes: 33024
#include<bits/stdc++.h>
#define maxn 100007
#define ll long long int
using namespace std;

struct edge{int u,v;}e[maxn];

inline bool cmp(edge a,edge b){return a.u==b.u?a.v<b.v:a.u<b.u;}

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*f;
}

inline void writ(int x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) writ(x/10);
	putchar(x%10+'0');
}
inline void write(int x){writ(x);putchar('\n');}

int main()
{
	int n=read(),m=read(),ans=0;
	for (int i=1;i<=m;++i) e[i].u=read(),e[i].v=read();
	sort(e+1,e+m+1,cmp);
	for (int i=1;i<m;++i)
	{
		if (e[i].v<=e[i+1].u) {++ans;continue;}
		if (e[i].v<=e[i+1].v) e[i+1].v=e[i].v;	
	}
	write(ans+1);
	return 0;
}

Measured memory_bytes: 1152
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

ll modpow(ll a, ll b){
    if(b == 0) return 1;
    else if(b % 2 == 0){
        ll d = modpow(a, b / 2) % MOD;
        return (d * d) % MOD;
    }
    else{
        return (a * modpow(a, b - 1)) % MOD;
    }
}

const int MAX_N = 2010;

ll fact[MAX_N], finv[MAX_N];
ll comb(int n, int r){
    if(n < r || r < 0) return 0;
    return fact[n] * finv[n-r] % MOD * finv[r] % MOD;
}

void calc(int n){
    fact[0] = finv[0] = 1;
    for(int i=1; i<=n; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        finv[i] = modpow(fact[i], MOD - 2);
    }
}

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

    int n, k; cin>>n>>k;
    calc(2005);

    cout << comb(n + k - 1, k - 1) << endl;

    return 0;
}


Measured memory_bytes: 3252