akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(a,n) rep(i,0,n){ cout<<(i ? " ":"")<<a[i]; }cout<<endl;
const long mod=1e9+7;
int main(){
	string s;cin>>s;
	int score=0;
	rep(i,0,s.size()){
		if(i%2==0&&s.at(i)=='p') score--;
		else if(i%2==1&&s.at(i)=='g') score++;
	}cout<<score<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll h, w, k, cnt[10];
string s[20];

bool hantei(){
	zep(i, 0, 10){
		if(cnt[i] > k){
			return false;
		}
	}
	return true;
}

void update(ll bit, ll j){
	ll at = 0;
	zep(i, 0, h){
		if(s[i][j] == '1'){
			cnt[at]++;
		}
		
		if(bit & (1LL << i)){
			at++;
		}
	}
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> h >> w >> k;
	zep(i, 0, h){
		cin >> s[i];
	}
	
	ll ans = INF;

	zep(bit, 0, (1LL << h-1)){
	//zep(bit, 2, 3){
		memset(cnt, 0, sizeof(cnt));
		ll buf = __builtin_popcount(bit);
		
		zep(j, 0, w){
			update(bit, j);
			
			if(!hantei()){
				//cout << j << endl;
				buf++;
				
				memset(cnt, 0, sizeof(cnt));
				update(bit, j);
			}
			
			if(!hantei()){
				buf = INF;
				break;
			}
		}
		//cout << bit << " " << buf << endl;
		ans = min(ans, buf);
	}
	print(ans)
	return 0;
}


Measured memory_bytes: 256
gets
a = gets.chomp.split(//)
r = "R"
g = "G"
b = "B"

rc = 0
gc = 0
bc = 0

a.each{|e|
  if e == r
    rc += 1
  elsif e == g
    gc += 1
  elsif e == b
    bc += 1
  end
}

all = rc*gc*bc

(0...a.size-1).each{|i|
  (i+1...a.size).each{|j|
    k = j*2-i
    if k > a.size-1
      break
    end
    if [r,g,b] - [a[i],a[j],a[k]] == []
      all -= 1
    end
  }
}

puts("#{all}")

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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	ll x, y;
	cin >> x >> y;
	if (abs(x-y)<=1) {
		cout << "Brown" << "\n";
	} else {
		cout << "Alice" << "\n";
	}
}


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;
  vll as(n);

  rep(i,n) cin >> as[i];
  Sort(as);

  ll ans = 0;
  rep(i, n-2) repLRE(j, i+1, n-1){
    ll idx = Lower_bound(as, as[i]+as[j]);
    ans += idx - 1 - j;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3612
from sys import stdin

def main():

    input = stdin.readline

    A,B,C,K = map(int,input().split())

    sum_num = 0
    ans_num = 0

    if A >= K:
        ans_num += K
    else:
        sum_num += A
        ans_num += A
        if B >= K + sum_num:
            pass
        else:
            ans_num -= (K - A - B)
        
    print(ans_num)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9196
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<string>
#include<stdbool.h>
using namespace std;
typedef long long ll;


int main(void) {
	ll n, max1=0, num = 0;
	cin >> n;
	vector<ll>b(n + 1);
	for (ll i = 1;i <= n;i++) {
		cin >> b[i];
	}
	sort(b.begin(), b.end());
	ll index = n;
	bool right4 = true;
	while (index > 3) {
		ll num = 0;
		if (b[index] == b[index - 3]&&right4) {
			cout << b[index] * b[index] << endl;
			return 0;
		}
		else {
			for (ll i = index;i > index - 3;i--) {
				if (b[index] == b[i])num++;
			}
			if (num >= 2) {
				if (max1 == 0) {
					max1 = b[index];
					right4 = false;
				}
				else {
					cout << max1*b[index] << endl;
					return 0;
				}
			}
			index = index - num;
		}
	}
	if (max1 == 0) {
		cout << 0 << endl;
	}
	else {
		if (index == 1)cout << 0 << endl;
		else {
			if (index == 2) {
				if (b[2] == b[1])cout << max1*b[2] << endl;
				else {
					cout << 0 << endl;
				}
			}
			else {
				if (b[3] == b[2])cout << max1*b[3] << endl;
				else {
					if (b[2] == b[1])cout << max1*b[2] << endl;
					else cout << 0 << endl;
				}
			}
		}
	}
	return 0;
}

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

#define ll long long int
#define endl "\n"
#define mod 1000000007


int main()
{

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	{
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
#endif
	ll a, b, n, temp;
	cin >> a >> b >> n;
	if (b - 1 >= n) {
		temp = n;
	} else {
		temp = b - 1;
	}
	cout << (a * temp) / b << endl;
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ar array<int,2>
#define inf 1000000000000000000 
int mod=1e9+7;
int min(int a,int b){return (a<b)?a:b;}
int max(int a,int b){return (a>b)?a:b;}
int fp(int a,int b){if(b==0) return 1;int x=fp(a,b/2);x=(x*x)%mod;if(b&1) x=(x*a)%mod;return x;}


const int N=2e5+5;



void solve()
{
   string s;
   cin>>s;
   int x=0;
   for(auto i:s)
    x+=i-'0';
if(x%9==0)
{
    cout<<"Yes";
}
else
{
    cout<<"No";
}
}

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
 srand(time(0));
 int t;
 t=1;
 for(int i=1;i<=t;i++)
 {
   solve();
 }


}

Measured memory_bytes: 3780
# エラトステネスの篩, 累積和
def make_prime_table(n):
    sieve = list(range(n + 1))
    sieve[0] = -1
    sieve[1] = -1
    for i in range(4, n + 1, 2):
        sieve[i] = 2
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i] != i:
            continue
        for j in range(i * i, n + 1, i * 2):
            if sieve[j] == j:
                sieve[j] = i
    return sieve


max_lr = 10 ** 5

prime_table = make_prime_table(max_lr)

cs = [0] * (max_lr + 1)
for i in range(3, max_lr + 1, 2):
    j = (i + 1) // 2
    if prime_table[i] == i and prime_table[j] == j:
        cs[i] = 1
for i in range(1, max_lr + 1):
    cs[i] += cs[i - 1]

Q = int(input())
result = []
for _ in range(Q):
    l, r = map(int, input().split())
    result.append(cs[r] - cs[l - 1])
print(*result, sep='\n')


Measured memory_bytes: 19020
#include <iostream>
#include <string.h>
#include<algorithm>
#include<math.h>

using namespace std;

int main() {
	int N, X[101],SUM=0,SUMmin=100000000;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> X[i];
	}
	sort(X,X+N);
	for (int i = X[0]; i < X[N-1]+1; i++) {
		for (int j = 0; j < N; j++) {
			SUM += (X[j] - i) * (X[j] - i);
		}
		if (SUM < SUMmin)SUMmin = SUM;
		SUM=0;
	}
	cout << SUMmin << endl;
	return 0;
}

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

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

using i64 = long long;
using d64 = long double;
using pi = pair<int, int>;
using pli = pair<i64, i64>;
using ti = tuple<int, int, int>;
using tli = tuple<i64, i64, i64>;

#define iterall(cont) cont.begin(), cont.end()
#define prec(n) setprecision(n) << fixed

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

    i64 x, k, d;
    cin>>x>>k>>d;

    x = abs(x);

    if(x / d > k) {
        cout<<x-d*k<<endl;
    } else {
        i64 t = x / d;
        t = t + (k-t) %2;
        cout<<abs(x-d*t)<<endl;
    }

    return 0;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <queue>
#include <sstream>
using namespace std;
#define mp make_pair
#define pb push_back
#define re return
#define fi first
#define se second
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef vector<vi> vvi;
int a[100010],b[100010],n,k,acnt,bcnt,x,mn=2000000000;
int main() {
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>x;
		if(x>0)b[bcnt++]=x;
		else a[acnt++]=-x;
	}
	sort(a,a+acnt);
	for(int i=0;i<acnt;i++){
		if(i>=k-1){mn=min(mn,a[i]);break;}
		else if(bcnt<(k-i-1))continue;
		else mn=min(mn,a[i]+b[k-i-1-1]*2);
	}
	for(int i=0;i<bcnt;i++){
		if(i>=k-1){mn=min(mn,b[i]);break;}
		else if(acnt<(k-i-1))continue;
		else mn=min(mn,b[i]+a[k-i-1-1]*2);
	}
	cout<<mn<<endl;
    return 0;
}


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

int main(){
  ll n,k; cin>>n>>k;
  vector<ll> num(n);
  for(int i=0;i<n;i++){
    cin>>num[i];
  }
  vector<ll> log(40,0);
  for(int i=0;i<40;i++){
    for(int j=0;j<n;j++){
      if((1ll<<i) & num[j]) log[i]++;
    }
  }
  vector<ll> ans(41,0);
  for(int i=0;i<=40;i++){
    ll p=k; 
    for(int j=39;j>=0;j--){
      ll t=(1ll<<j);
      if(i==j || p<t || log[j]*2>=n){
        ans[i]+=t*log[j];
      }else{
        ans[i]+=(n-log[j])*t;
        p-=t;
      }
    }
  }
  ll a=0;
  for(int i=0;i<=40;i++) a=max(a,ans[i]);
  cout<<a<<endl;
}

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

int cmp(const void* a,const void* b){
	return *(int*)a - *(int*)b;
}
int b[200000]={};
int main(void){
	int n,k;
	scanf("%d%d",&n,&k);
	int i,c=0;
	int a[n+1];
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	qsort(a,n,sizeof(int),cmp);
	for(i=0;i<n;i++){
		b[c]++;
		while(a[i]==a[i+1]){
			i++;
			b[c]++;
			if(i>=n)continue;
		}
		c++;
	}
	//cはボールの種類数で,b[i]にはその数が入る
	//ボールに書かれている整数がK種類以下にする最適な方法は、
	//b[i]が小さいヤツから消していく
	qsort(b,c,sizeof(int),cmp);
	int ans = 0;
	for(i=0;i<c-k;i++){
		ans += b[i];
	}
	printf("%d",ans);
	return 0;
}

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

#define int long long 

int32_t main () {
    int n; cin >> n;
    int x = n / 500;
    n = n - (x * 500);
    // cout << n << endl;
    int y = n / 5;
    // cout << x << y << endl;
    cout << (x * 1000) + (y * 5) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    vector<int> v(3);

    REP(i,3) cin >> v[i];

    sort(ALL(v));

    cout << v[0] + v[1] << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
n, a, b, c, d = map(int, input().split())
s = input()
if c < d:
    print("YNeos"[any(s[i:i + 2] == "##" for i in range(a, d - 1))::2])
else:
    if any(s[i:i + 3] == "..." for i in range(b - 2, d - 1)):
        if all(s[i:+2] != "##" for i in range(a, c - 1)):
            print("Yes")
            exit()
    print("No")


Measured memory_bytes: 9484
#include "bits/stdc++.h"

using namespace std;

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

    string s,dv="11111110000000001111011101";//left->1,right->0
    while(true){
        cin>>s;
        if(s=="#") break;
        char last=dv[s[0]-'a'];
        int res=0;
        for(int i=1;i<(int)s.length();i++){
            if(dv[s[i]-'a']!=last){
                res++;
                last =dv[s[i]-'a'];
            }
        }
        cout<<res<<endl;
    }
}

Measured memory_bytes: 3160
// <head>
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
// </head>

// <library>
    
// </library>
ll dp[2005][2005];
int main(){
    int n; cin >> n;
    vector<pair<ll, ll>> a(n);
    for (int i = 0; i < n; i++){
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a.rbegin(), a.rend());
    for (int i = 0; i <= n; i++){
        for (int j = 0; j <= n; j++){
            ll left = 0; ll right = 0;
            if (i>0 && i-1+j<n)
                left = dp[i-1][j] + max((a[i-1+j].second - (i-1))*a[i-1+j].first,0LL);
            if (j>0 && i-1+j<n)
                right = dp[i][j-1] + max((n-1 - (j-1) - a[i-1+j].second)*a[i-1+j].first,0LL);
            dp[i][j] = max(left,right);
        }
    }
    ll ans = 0;
    for (int i = 0; i <= n; i++){
        ans = max(ans, dp[i][n-i]);
        
    }
    cout << ans << '\n';
    



    
}

Measured memory_bytes: 35000
#include <bits/stdc++.h>
#define REP(i, a, b) for (long long i = a; i <= b; ++i)
using namespace std;

string s;

inline void work(){
	cin >> s;
	REP(i, 0, s.size() - 1)	//×¢Òâ:×Ö·û´®µÄÏÂ±êÊÇ´Ó0¿ªÊ¼µÄ 
		if (s[i] == '7'){	//Èç¹ûÕâÒ»Î»ÊÇ7 
			puts("Yes");	//ÔòÊä³öYes 
			exit(0);		//µÈÍ¬ÓÚreturn 0 
		}
	puts("No");				//·ñÔòÊä³öNo 
}

int main(){
	work();
	return 0;
}

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

int main() {
	vector<int> a(3);
	for (int i = 0;i < 3;i++) {
		cin >> a[i];
	}
	int ans = 0;
	while (!(a[0]==a[1]&&a[1]==a[2])) {
		sort(a.begin(), a.end());
		if (a[1] == a[2]) {
			a[0] += 2;
		}
		else {
			a[0]++;
			a[1]++;
		}
		ans++;
	}
	cout << ans << endl;


	return 0;
}

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

int main(){
	int n, b, m = 0;
	long long ans = 0;
	long long tmp = 0;
	vector <int> a;
	cin >> n;
	while (cin >> b){
		m += b;
		a.push_back(b);
	}
	m /= n;
	for (int i = 0; i < a.size(); i++){
		ans += pow(m - a[i], 2.0);
		tmp += pow(m + 1 - a[i], 2.0);
	}
	cout << ((ans>tmp) ? tmp : ans) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long int n,a[100005],flag=0;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    a[0]--;
    for(int i=0;i<n-1;i++)
    {   
        if(a[i]<a[i+1])
        {
            a[i+1]--;
        }    
    }

    for(int i=0;i<n-1;i++)
    {
        if(a[i]-a[i+1]>0)
        {
            flag =1;
            break;
        }    
    }
   
    
    if(flag)
        cout<<"No";
    else
        cout<<"Yes";
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const  ll INF = 1e18;
const  ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i,n,init) for(ll i=init;i<(n);i++)
#define repd(i,n,init) for(ll i=(n);i>=init;i--)
#define repm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define repb(bit,n,init) for(ll bit=init;bit<(1<<n);++bit)

int main()
{
    string s;
    cin >> s;
    if(s.at(2) == s.at(3) && s.at(4) == s.at(5)){
        puts("Yes");
    }else{
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
struct dice{
	int top;
	int front;
	int right;
	int left;
	int back;
	int bottom;
	int n;
	void spin(char x){
		if(x=='E'){
			n=top;
			top=left;
			left=bottom;
			bottom=right;
			right=n;
		}
		if(x=='W'){
			for(int i=0;i<3;i++){
				spin('E');
			}
		}
		if(x=='S'){
			n=top;
			top=back;
			back=bottom;
			bottom=front;
			front=n;
		}
		if(x=='N'){
			for(int i=0;i<3;i++){
				spin('S');
			}
		}
	}
};
int main() {
	int a[6];
	int ans;
	string s;
	for(int i=0;i<6;i++){
		cin>>a[i];
	}
	cin>>s;
	dice d;
	d.top=a[0];
	d.front=a[1];
	d.right=a[2];
	d.left=a[3];
	d.back=a[4];
	d.bottom=a[5];
	for(int i=0;i<s.size();i++){
		d.spin(s[i]);
	}
	ans=d.top;
	cout<<ans<<endl;
}

Measured memory_bytes: 3200
#include<iostream>
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
  int n ;
  cin >> n  ;
  
  bool cond = 0 ;
  for(int i=0;i<=(n/7);i++){
   for(int j=0;j<=(n/4);j++){
      int sum = i*7+j*4 ;
      if(sum==n){
        cond = 1 ;
        break ;
      }
   }
   }
  
  if(cond)
    cout << "Yes" << endl ;
  else 
    cout << "No" << endl ;    
    return 0 ;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>

const long long MOD = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

int main(){
    llong X,Y;
    cin >> X >> Y;
    llong total = 0;
    llong A=X;

    while(A<=Y){
        total = total + 1;
        A = A * 2;
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main() {
    int h,w,d,q;
    cin >> h >> w >> d;
    vector<vector<int>> a(h,vector<int>(w,0));
    int tmpa;
    map<int,pii> mp;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> tmpa;
            a[i][j] = tmpa;
            mp[tmpa] = {i,j};
        }
    }
    vector<int> dist[90001];
    int tmp;
    for(int i = 0; i < d; i++){
        tmp = i;
        while(tmp+d <= h*w){
            if(tmp!=0){
                dist[i].push_back(abs(mp[tmp].first-mp[tmp+d].first)+abs(mp[tmp].second-mp[tmp+d].second));
            }
            tmp = tmp + d;
        }
    }
    for(int i = 0; i < d; i++){
        for(int j = 1; j < dist[i].size(); j++){
            dist[i][j] += dist[i][j-1];
        }
    }

    cin >> q;
    int l, r, index, ans;
    for(int i = 0; i < q; i++){
        cin >> l >> r;
        if(l==r){
            cout << 0 << endl;
            continue;
        }else{
            index = l%d;
            ans = 0;
            if((l-1)/d == 0){
                ans = dist[index][(l-1)/d+(r-l)/d-1];
            }else{
                ans = dist[index][(l-1)/d+(r-l)/d-1] - dist[index][(l-1)/d-1];
            }

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


Measured memory_bytes: 9724
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            int minX = 0;
            int minY = 0;
            int maxX = 0;
            int maxY = 0;
            int startX = 0;
            int startY = 0;
            int tempX = 0;
            int tempY = 0;
            int readCount = 0;
            int result = 0;
            int calcFLG = 0;
            
            string readValue =Console.ReadLine();
            int[] tokens = readValue.Split(' ').Select(int.Parse).ToArray();
            maxX = tokens[0];
            maxY = tokens[1];
            startX = maxX;
            startY = maxY;
            readCount = tokens[2];

            for (int i = 0; i < readCount; i++)
            {
                readValue = Console.ReadLine();
                tokens = readValue.Split(' ').Select(int.Parse).ToArray();
                tempX = tokens[0];
                tempY = tokens[1];
                calcFLG = tokens[2];

                switch (calcFLG)
                {
                    case 1:
                        if (minX < tempX)
                        {
                            minX = tempX;
                        }
                        break;
                    case 2:
                        if (startX > tempX && maxX > tempX)
                        {
                            maxX = tempX;
                        }
                        break;
                    case 3:
                        if (minY < tempY)
                        {
                            minY = tempY;
                        }
                        break;
                    case 4:
                        if (startY > tempY && maxY > tempY)
                        {
                            maxY = tempY;
                        }
                        break;
                    default:
                        break;  
                }
            }

            if (maxX - minX > 0 && maxY - minY > 0)
            {
                result = (maxX - minX) * (maxY - minY);
            }

            Console.WriteLine(result.ToString());
            //Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; i64 c; scanf("%d%lld", &n, &c);
	std::vector<i64> x(n), v(n);
	for(int i = 0; i < n; i++) {
		scanf("%lld%lld", &x[i], &v[i]);
	}

	std::vector<i64> a(n + 1), A(n + 1);
	for(int i = 0; i < n; i++) a[i + 1] = a[i] + v[i];
	for(int i = 0; i < n; i++) a[i + 1] -= x[i];
	for(int i = 1; i < a.size(); i++) A[i] = std::max(A[i - 1], a[i]);

	reverse(begin(x), end(x)); reverse(begin(v), end(v));
	std::vector<i64> b(n + 1), B(n + 1);
	for(int i = 0; i < n; i++) b[i + 1] = b[i] + v[i];
	for(int i = 0; i < n; i++) b[i + 1] -= (c - x[i]);
	for(int i = 1; i < b.size(); i++) B[i] = std::max(B[i - 1], b[i]);
	reverse(begin(x), end(x)); reverse(begin(v), end(v));

	i64 ans = std::max(A.back(), B.back());
	for(i64 i = 0, tmp = 0; i < n; i++) {
		tmp += v[i];

		ans = std::max(ans, (tmp - x[i] * 2) + B[n - i - 1]);
	}
	
	for(i64 i = n - 1, tmp = 0; i >= 0; i--) {
		tmp += v[i];
		
		ans = std::max(ans, (tmp - (c - x[i]) * 2) + A[i]);
	}
	printf("%lld\n", ans);
	return 0;
}


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

using namespace std;

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

template<class T>
inline void Max(T &x, T t) {
	if(t > x) {
		x = t;
	}
}
template<class T>
inline void Min(T &x, T t) {
	if(t < x) {
		x = t;
	}
}

const int maxn = 200000 + 9;

string s;
int cnt[26];

int main() {
//	freopen("input.txt", "r", stdin);
	
	cin >> s;
	int N = s.size();
	memset(cnt, 0, sizeof cnt);
	for(int i = 0; i < N; i++) {
		cnt[s[i] - 'a']++;
	}
	ll ans = ll(N) * (N + 1) / 2;
	for(int i = 0; i < 26; i++) {
		ans -= ll(cnt[i]) * (cnt[i] + 1) / 2;
	}
	cout << ++ans << endl;
	
	return 0;
}

Measured memory_bytes: 644
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    auto s = readln.chomp;
    int ans;

    foreach (i ; 0 .. s.length) {
        foreach (j ; i + 1 .. s.length + 1) {
            if (s[i .. j].all!(ch => "ACGT".canFind(ch))) {
                ans = max(ans, j.to!int - i.to!int);
            }
        }
    }

    writeln(ans);
}


























int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e;
  string s,ss,sss;
  cin>>a;
  cout<<(a/2-(a%2==0))<<endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
l = []
    
for i in range(N):
  a, b = map(int, input().split())
  l.append((b, a))
  
l.sort()

cur = 0
for i in range(N):
  dead, time = l[i]
  if(cur + time <= dead):
    cur += time
  else:
    print("No")
    exit()

print("Yes")

Measured memory_bytes: 29444
import scala.collection.mutable
import scala.io.StdIn

object Main extends App {

  val map = mutable.Map.empty[String,Int]
  val n = StdIn.readInt
  Iterator.continually(StdIn.readLine)
      .take(n)
      .foreach(s => {
        if (map.contains(s)) map.put(s, map(s) + 1) else map += s -> 1
      })

  val m = StdIn.readInt
  Iterator.continually(StdIn.readLine)
      .take(m)
      .foreach(s => {
        if (map.contains(s)) map.put(s, map(s)-1) else  map += s -> -1
      })

  val ans = map.values.max

  println(if(ans <0 ) 0 else ans)
}

Measured memory_bytes: 27204
t=int(input())
m=input().split()
ml=list()
possibilidades=list()
for i in m:
  ml.append(int(i))
for i in range(t):
  s1=0
  s2=0
  for j in range(len(ml)):
    if j<i:
      s1+=ml[j]
    else:
      s2+=ml[j]
  possibilidades.append(abs(s1-s2))

possibilidades.sort()
print(possibilidades[0])

Measured memory_bytes: 3064
// AtCoder Beginner Contest 161 C.cpp

#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
	long long n, k, temp, answer;
	cin >> n >> k;
	if (n < abs(n - k)) {
		cout << n << endl;
	}
	else {
		temp = n / k;
		if (k > n - temp * k) {
			temp--;
		}
		n -= k * temp;
		answer = n;
		for (int i = 0; i < 100; i++) {
			answer = min(answer, abs(answer - k));
		}
		cout << answer << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int j = n;
		int data[] = new int[n];
		int datax[] = new int[n];
		
		for(int i = 0; i < n; i++) {
			data[i] = stdIn.nextInt();
		}
		
		for(int i = 0; i < n; i++) {
			datax[j - 1] = data[i];
			j--;
		}
		
		for(int i = 0; i < n; i++) {
			if( i == n - 1) {
				System.out.println(datax[i]);
			}else {
				System.out.print(datax[i] + " ");
			}
		}
	
	}
}


Measured memory_bytes: 26212
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest067-B
#  TODO https://atcoder.jp/contests/abc067/tasks/abc067_b
import time
from contextlib import contextmanager
# from time import sleep
@contextmanager
def timer(title):
	t0 = time.time()
	yield
	print("{} - done in {:.0f}s".format(title,time.time()-t0) )

def  calcLongSnakeToy(needBarNumber,barLengthList):
	longSortedToyList = sorted(barLengthList,reverse=True)
	getBarCountRange = range(0,needBarNumber,+1)
	longLength = 0
	for i in getBarCountRange:
		longLength = longLength + longSortedToyList[i]
	answer = longLength
	return answer


if __name__ == '__main__':
	_,K = map(int,input().strip().split(' '))
	lengthList = list(map(int,input().strip().split(' ')))
	solution=calcLongSnakeToy(K,lengthList)
	print("{}".format(solution))

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    ll N, C, K;
    cin >> N >> C >> K;
    vector<ll> T(N);
    rep(i,N)cin >> T[i];
    sort(all(T));
    print(T);
    int r = 0;
    int ans = 0;
    for(int l = 0; l < N;){
        while(r < N && r - l + 1 <= C && T[r] <= T[l] + K){
            r++;
        }
        //cerr << l << " " << r << endl;
        l = r;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int hen[2];
	int tai;
	int c_chou = 0;
	int c_hishi = 0;
	
	while (scanf("%d,%d,%d", &hen[0], &hen[1], &tai) != EOF){
		if (hen[0] *  hen[0] + hen[1] * hen[1] == tai * tai){
			c_chou += 1;
		}
		else if (hen[0] == hen[1]){
			c_hishi += 1;
		}
	}
	
	printf("%d\n%d\n", c_chou, c_hishi);
	
	return (0);
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    
    int N;
    bool A[200010], C[200010];
    vector<int> B;
    cin >> N;
    for (int i = 1; i <= N; ++i){
        bool a;
        cin >> a;
        A[i] = (a>0?true:false);
    }
    int sum = 0;
    for (int i = N; i >= 1; --i){
        int j = i;
        bool c = A[i];
        while (j + i <= N){
            j += i;
            c ^= C[j];
        }
        C[i] = c;
        if (c) {
            sum++;
            B.push_back(i);
        }
    }
    
    cout << sum << endl;
    for (auto b : B){
        cout << b <<endl;
    }

}




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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define ll long long

const int INF = 2e9 + 1;
const ll INFLL = 1e18 + 1;
const int mod = 1e9 + 7;

bool cmp(const ll &a, const ll &b) {
    return abs(a) < abs(b);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    int cntn = 0, cntp = 0, cnt0 = 0;
    for (auto &c : a) {
        cin >> c;
        if (c < 0) cntn++;
        else if (c == 0) cnt0++;
        else cntp++;
    }
    if (min(k, cntn) - min(k, cntn) % 2 + cntp < k) {
        if (cnt0 > 0) {
            cout << 0;
            return 0;
        }
        sort(all(a), cmp);
        ll ans = 1;
        for (int i = 0; i < k; i++) {
            ans *= a[i];
            ans %= mod;
        }
        cout << (ans + mod) % mod;
        return 0;
    }
    sort(all(a), cmp);
    reverse(all(a));
    int cnt = 0, lastp = -1, lastn = -1;
    for (int i = 0; i < k; i++) {
        if (a[i] < 0) cnt++;
        if (a[i] < 0) lastn = i;
        else lastp = i;
    }
    int fp = n, fn = n;
    for (int i = n - 1; i >= k; i--) {
        if (a[i] < 0) fn = i;
        else fp = i;
    }
    if (cnt % 2 == 0) {
        ll ans = 1;
        for (int i = 0; i < k; i++) {
            ans *= a[i];
            ans %= mod;
        }
        cout << (ans + mod) % mod;
        return 0;
    }
    if ((lastn != -1 && fp != n) && (lastp == -1 || fn == n || a[fp] * a[lastp] > a[fn] * a[lastn])) {
        ll ans = 1;
        for (int i = 0; i < k; i++) {
            if (i != lastn) ans *= a[i];
            ans %= mod;
        }
        ans *= a[fp];
        ans %= mod;
        cout << (ans + mod) % mod;
        return 0;
    }
    ll ans = 1;
    for (int i = 0; i < k; i++) {
        if (i != lastp) ans *= a[i];
        ans %= mod;
    }
    ans *= a[fn];
    ans %= mod;
    cout << (ans + mod) % mod;
    return 0;
}


Measured memory_bytes: 4748
N=int(input())
for h in range(1,3501):
    for n in range(1,3501):
        if 4*h*n-N*h-N*n>0:
            if (N*h*n) % (4*h*n-N*h-N*n)==0:
                w=N*h*n // (4*h*n-N*h-N*n)
                print(h,n,w)
                exit()

Measured memory_bytes: 66544
import java.util.Scanner;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        double H = sc.nextInt();
        double M = sc.nextInt();

        double hRad = -((H/12)*2 + (M/60)/6)*Math.PI;
        double mRad = -(M/60)*2*Math.PI;

        double hX = Math.cos(hRad) * A;
        double hY = Math.sin(hRad) * A;
        double mX = Math.cos(mRad) * B;
        double mY = Math.sin(mRad) * B;

        double distance = Math.sqrt(Math.pow(hX-mX, 2) + Math.pow(hY-mY, 2));

        System.out.println(distance);
    }
}

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

uint64_t f(const uint64_t n) {
  if (n % 2 == 0) {
    return n / 2;
  } else {
    return 3 * n + 1;
  }
}

int main() {
  uint64_t s;
  std::cin >> s;

  std::vector<bool> flag(1000000, false);
  uint64_t i = 1;
  flag[s] = true;
  while (true) {
    i++;
    s = f(s);
    if (flag[s]) {
      std::cout << i << std::endl;
      return 0;
    } else {
      flag[s] = true;
    }
  }
  return 0;
}

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

int selectionSort(int A[],int N){
    int mini,sw=0;
    for(int i=0;i<N;i++){
        mini = i;
        for(int j=i;j<N;j++){
            if(A[j]<A [mini]) mini=j;
        }
        if(i!=mini){
            swap(A[i],A[mini]);
            sw++;
        }
    }
    return sw;
}

int main(){
    int N,A[101],mini,sw;
    cin>>N;
    for(int i=0;i<N;i++)cin>>A[i];

    sw=selectionSort(A,N);
    for(int i=0;i<N;i++){
                if(i)cout<<" ";
                cout<<A[i];
    }
    cout<<endl;
    cout<<sw<<endl;
    return 0;
    }

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

int main() {
  string str, T;
  cin >> str >> T;
  
  int i;
  for (i = str.size() - T.size(); i >= 0; i--) {
    string sub = str.substr(i, T.size());
    bool check = true;
    for (int j = 0; j < T.size(); j++) {
      if (sub.at(j) != '?' && sub.at(j) != T.at(j)) {
        check = false;
        break;
      }
    }
    
    if (check) {
      str = str.substr(0, i) + T + str.substr(i + T.size());
      break;
    }
  }
  
  if (i == -1) {
    str = "UNRESTORABLE";
  } else {
    for (int j = 0; j < str.size(); j++) {
      if (str.at(j) == '?') str.at(j) = 'a';
    }
  }
  
  cout << str << endl;

  return 0;
}

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

int main() {
    long long n;cin>>n;
    pair<long long,string>a[5];
    
    string s = "MARCH";
    for(long long i=0;i<5;++i){
        a[i].first =0;
        a[i].second=s[i];
    }
    
    string tmp;
    for(long long i=0;i<n;++i){
        cin>>tmp;
        for(long long j=0;j<5;++j){
            if(tmp[0]==a[j].second[0])a[j].first+=1;
        }
    }
    long long ans=0,ans2=0;
    for(long long i=0;i<5;++i){
      for(long long j=0;j<i;++j){
            for(long long k=0;k<j;++k){
                ans += a[i].first * a[j].first * a[k].first;
            }
        }
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  ll n;
  cin >> n;
  ll t,a;
  cin >> t >> a;
  double h[n];
  REP(i,n) cin >> h[i];
  double minimum = INF;
  int ans_num;
  REP(i,n){
    if(abs(t-h[i]*0.006-a)<minimum){
      minimum = abs(t-h[i]*0.006-a);
      ans_num = i + 1;
    }
  }
  cout << ans_num << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int MAX = 1000000;
int main(){
  vector<bool> prime(MAX + 1, true);
  prime[0] = false;
  prime[1] = false;
  for (int i = 2; i <= MAX; i++){
    if (prime[i]){
      for (int j = i * 2; j <= MAX; j += i){
        prime[j] = false;
      }
    }
  }
  while (1){
    int a, d, n;
    cin >> a >> d >> n;
    if (a == 0 && d == 0 && n == 0){
      break;
    }
    int cnt = 0;
    for (int x = a; x <= MAX; x += d){
      if (prime[x]){
        cnt++;
        if (cnt == n){
          cout << x << endl;
          break;
        }
      }
    }
  }
}


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

int main()
{
    int n,x,m,s = 1000;
    cin >> n >> x;
    for(int i = 0; i < n; i++){
        cin >> m;
        x -= m;
        s = min(s,m);
    }

    cout << n + x / s << endl;

    return 0;
}

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

#define FORS(i, j, k, step) for (int i=j; i<k; i+=step)
#define FOR(i, j, k) for (int i=j; i<k; i++) 
#define RFORS(i, j, k, step) for (int i=j; i>=k; i-=step)
#define RFOR(i, j, k) for(int i=j; i>=k; i--)
#define REP(i, k) for(int i = (0); i < (k); i++ ) 
#define RREP(i, k) for(int i = (k); i >= (0); i-- )
 
#define ALL(cont) cont.begin(), cont.end()
#define RALL(cont) cont.begin(), cont.end()
#define FOREACH(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define RESET(a, b) memset(a, b, sizeof(a))
#define INF (int)MAX_INT
#define EPS (int)1e-9
#define PI acos(-1)
#define MOD 1000000007
#define run using
#define the namespace
#define prog std
 
run the prog;

typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef long long int32;
typedef unsigned long long uint32;
typedef long long int int64;
typedef unsigned long long int uint64;
 
template <class T>
    T sqr(T val) {
        return val * val;
    }
 
template<typename T, typename U> 
static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
} 
  
// call by reference is used in x 
template<typename T, typename U> 
static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
} 

/* To find max and min value in array.
for (auto const &val: array) 
  
        // Same as max_val = max (max_val, val) 
        // Same as min_val = min (min_val,val) 
        amax(max_val, val), amin (min_val, val);
//Then in main()
int max_val = 0, min_val = 1e5; 
 */
int32 gcd(int32 a, int32 b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);
} 
void solve() {
    /* Solution code goes here */
    char c;
    cin>>c;
    if(isupper(c))
    cout<<"A";
    else
    cout<<"a";
}
 
int main() {
    std::ios_base::sync_with_stdio(false);
    int32 TC = 1;
    //cin >> TC;
    
    //cin.ignore();
    while(TC--)
    {
        solve();
    }
}

Measured memory_bytes: 3656
#include <iostream>

using namespace std;

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

    int sum = 0;
    for (int i = 1; i <= n; ++i) {
        int num = i;
        int tmp = 0;
        while (num > 0) {
            tmp += num % 10;
            num /= 10;
        }

        if (tmp >= a && tmp <= b)
            sum += i;
    }

    cout << sum << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define REP(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long N, long long A, long long B){
    cout << min(A, B) << " " << max(0LL, A+B-N) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int X; cin >> X;
  vector<bool> dp(X+200, false);
  dp[0] = true;
  for (int i = 0; i <= X; ++i) {
    if (dp[i]) {
      dp[i+100] = true;
      dp[i+101] = true;
      dp[i+102] = true;
      dp[i+103] = true;
      dp[i+104] = true;
      dp[i+105] = true;
    }
  }
  int ans = dp[X];
  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
def main7():
    buf = input("");
    bufs = buf.split();
    num = [];
    for i in range(2):
        num.append(int(bufs[i]));
    result = (num[0] - 1) * (num[1] - 1);
    print(result);



if __name__ == '__main__':
    main7()

Measured memory_bytes: 3060
#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>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s;
    cin>>s;
    int l = s.size();
    
    int ignore = 0;
    int useful = 0;
    
    ll ans = 0;
    for(int i =0; i<l; i++){
        if(s[i]=='0'){
            if(useful%2) useful++;
            else ignore++;
        }else{
            useful++;
            if(useful%2){
                ans+=l-i;
                ans+=ignore/2;
            }else{
                ans+=(ignore+1)/2;
            }
            
        }
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3720