akhauriyash/Code-Regression huggingface dataset:
Imports System

Module Program
    Sub Main(args As String())

        Dim N As String = Console.ReadLine()

        Dim ans As String
        Select Case Right(N, 1)
            Case 3
                ans = "bon"
            Case 0, 1, 6, 8
                ans = "pon"
            Case Else
                ans = "hon"
        End Select

        Console.WriteLine(ans)

    End Sub
End Module


Measured memory_bytes: 26744
import std.stdio, std.conv, std.array, std.math;

void main() {
    string[] input = readln.split;
    int m = input[0].to!int;
    int k = input[1].to!int;
    int n = pow(2, m);
    if(n == 1) {
        if(k == 0) {
            writeln(0, " ", 0);
        } else{
            writeln(-1);
        }
        return;
    }

    if(n == 2) {
        if(k == 0) {
            writeln(0, " ", 0, " ", 1, " ", 1);
        } else {
            writeln(-1);
        }
        return;
    }

    if(n <= k) {
        writeln(-1);
        return;
    }

    if(k == 0) {
        foreach(i; 0..n) {
            write(i);
            write(" ");
            write(i);
            if(i != n - 1){
                write(" ");
            }
        }
        writeln("");
        return;
    }

    foreach(i; 0..n) {
        if(k != i) {
            write(i, " ");
        }
    }
    write(k, " ");
    foreach(i; 0..n) {
        int j = n - i - 1;
        if(k != j) {
            write(j, " ");
        }
    }
    writeln(k);
}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int W,a,b;
    cin >> W >> a >> b;
    int sub = max(a - b,b - a);
    if (sub <= W) cout << 0 << endl;
    else cout << sub - W << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

#include <iostream>

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;

int main(){
	int n;
	cin >> n;
	int m = 0;
	int res = 0;
	for (int i = 0; i < n; i++) {
		int temp;
		cin >> temp;
		if (temp >= m) {
			m = temp;
			res++;
		}
	}
	cout << res;
	
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# atcoder 
# Türkçe konuşyorum
# Türkler var mı
# memnün oldum
import sys

sys.setrecursionlimit(10 ** 8)

str = input()
num = int(str[-1])

if num == 3:
    print('bon')
elif num == 0 or num == 1 or num == 6 or num == 8:
    print('pon')
else:
    print('hon')



Measured memory_bytes: 9168
def selectionSort(A, N):
    ret = 0
    for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        A[i], A[minj] = A[minj], A[i]
        if i != minj:
            ret += 1
    return ret


n = int(input())
a = list(map(int, input().split()))

count = selectionSort(a, n)

print(" ".join(map(str, a)))
print(count)

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

// 1-indexed
template <class T, class E>
struct SegmentTreeLaze {
  // a,b:T c,d:E e:E(unit)
  // g(f(a,b),c) = f(g(a,c),g(b,c))
  // g(g(a,c),d) = g(a,h(c,d))
  // g(a,e) = a
  typedef function<T(T, T)> F;
  typedef function<T(T, E)> G;
  typedef function<E(E, E)> H;
  int n, height;
  F f;
  G g;
  H h;
  T tunit;
  E eunit;
  vector<T> dat;
  vector<E> laz;
  SegmentTreeLaze(){};
  SegmentTreeLaze(int newn, F f, G g, H h, T nt, E ne)
      : f(f), g(g), h(h), tunit(nt), eunit(ne) {
    init(newn);
  }
  void init(int newn) {
    n = 1, height = 0;
    while(n <= newn) n <<= 1, ++height;
    dat.assign(n << 1, tunit);
    laz.assign(n << 1, eunit);
  }

  inline T reflect(int k) {
    return laz[k] == eunit ? dat[k] : g(dat[k], laz[k]);
  }

  inline void eval(int k) {
    if(laz[k] == eunit) return;
    laz[k << 1] = h(laz[k << 1], laz[k]);
    laz[(k << 1) | 1] = h(laz[(k << 1) | 1], laz[k]);
    dat[k] = reflect(k);
    laz[k] = eunit;
  }

  inline void thrust(int k) {
    for(int i = height; i; --i) eval(k >> i);
  }

  void recalc(int k) {
    while(k >>= 1)
      dat[k] = f(reflect(k << 1), reflect((k << 1) | 1));
  }
  // [a,b)
  void update(int a, int b, E newdata) {
    thrust(a += n);
    thrust(b += n - 1);
    for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if(l & 1) laz[l] = h(laz[l], newdata), l++;
      if(r & 1) --r, laz[r] = h(laz[r], newdata);
    }
    recalc(a);
    recalc(b);
  }

  void set_val(int k, T newdata) {
    thrust(k += n);
    dat[k] = newdata;
    laz[k] = eunit;
    recalc(k);
  }

  // [a,b)
  T query(int a, int b) {
    thrust(a += n);
    thrust(b += n - 1);
    T vl = tunit, vr = tunit;
    for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if(l & 1) vl = f(vl, reflect(l++));
      if(r & 1) vr = f(reflect(--r), vr);
    }
    return f(vl, vr);
  }
};

struct data {
  long long l, r, a;
};

long long n, m;
map<long long, vector<data>> mp;

long long solve();

int main() {
  cin >> n >> m;
  for(int i = 0; i < m; ++i) {
    long long l, r, a;
    cin >> l >> r >> a;
    mp[r].push_back({l, r, a});
  }

  cout << solve() << endl;
  return 0;
}

long long solve() {
  auto f = [](long long l, long long r) {
    return max(l, r);
  };
  auto g = [](long long l, long long r) { return l + r; };
  auto h = [](long long l, long long r) { return l + r; };
  SegmentTreeLaze<long long, long long> dp(n, f, g, h, 0,
                                           0);
  for(int i = 1; i <= n; ++i) {
    dp.update(i, i + 1, dp.query(1, i + 1));
    long long mpsize = mp[i].size();
    for(int j = 0; j < mpsize; ++j)
      dp.update(mp[i][j].l, i + 1, mp[i][j].a);
  }
  return dp.query(1, n + 1);
}


Measured memory_bytes: 30592
from fractions import*
a,b=map(int,input().split())
c=gcd(a,b)
d=a*b//gcd(a,b)
s=input()
t=input()
for i in range(c):
    if s[i*(a//c)] != t[i*(b//c)]:
        print(-1)
        exit()
print(d)

Measured memory_bytes: 5432
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>	
using namespace std;
char s[6];
bool cmp(char a,char b) {
	return a>b;
}
int main() {
	for(int i=1;i<=4;i++) {
		cin>>s[i];
	}
	sort(s+1,s+5,cmp);
	if(s[1]==s[2]&&s[3]==s[4]&&s[2]!=s[3]) {
		cout<<"Yes"<<endl;
	} else {
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
Mod = 1000000007




def main(): #startline-------------------------------------------
    m,d = map(int,input().split())
    ans = 0
    for i in range(1,m+1):
        for j in range(1,d+1):
            if j < 10:
                continue
            else:
                p = [k for k in str(j)]
                if int(p[0])<2 or int(p[1])<2:
                    continue
                elif int(p[0])*int(p[1]) == i:
                    ans += 1
    print(ans)
if __name__ == "__main__":
    main() #endline===============================================





def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n < 2 is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))):
        if prime[i] == 1:
            for j in range(2*i,n):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n):
        if prime[i] == 1:
            res.append(i)
    return res

class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py

    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
    string s;
    int i = 0;
    cin >> s;

    int n = (s.size());
    int count = 0;
    rep(i, n/2) {
       if (s[i] != s[n-i-1]) {
           /* code */
           count++;
       }
    }
    cout << count;
}

Measured memory_bytes: 256
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;
ll mod9 = 1000000009;

signed main(){
    ll n,m;
    ll sum=0,ma;
    cin>>n>>m;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
        sum += a[i];
    }
    sort(a.begin(),a.end(),greater<ll>());
    bool f=true;
    rep(i,m){
        if(a[i]*4*m<sum){
            f=false;
        }
    }
    if(f) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

ll choose2(ll n){
    return n*(n-1)/2;
}

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) {
    cin >> a[i];
    a[i]--;
    }
    vector<int> cnt(n);
    rep(i,n) cnt[a[i]]++;
    ll tot = 0;
    rep(i,n) tot += choose2(cnt[i]);
    
    rep(i,n) {
        ll ans = tot;
        ans -= choose2(cnt[a[i]]);
        ans += choose2(cnt[a[i]]-1);
        cout << ans << endl;
    }
    return 0;

}


Measured memory_bytes: 4808
#include<stdio.h>

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    if(a==b){
        printf("Draw");
    }
    else if(a==1){
        printf("Alice");
    }
    else if(b==1){
        printf("Bob");
    }
    else if(a<b){
        printf("Bob");
    }
    else if(b<a){
        printf("Alice");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n, a[100010];
int main()
{
    int a, ans = 0, k;
    scanf("%d%d", &a, &k);
    while (a)
    {
        a /= k;
        ans++;
    }
    printf("%d\n", ans);
    return 0;
}

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

int main(){
	long int n, m, l, sum=0;
	cin >> n >> m >> l;

	long int **A = new long int*[n+1];
	for(long int i=0; i<=n; i++){
		A[i] = new long int[m+1];
	}

	long int **B = new long int*[m+1];
	for(long int i=0; i<=m; i++){
		B[i] = new long int[l+1];
	}

	for(long int r=1; r<=n; r++){
		for(long int c=1; c<=m; c++){
			cin >> A[r][c];
		}
	}

	for(long int r=1; r<=m; r++){
		for(long int c=1; c<=l; c++){
			cin >> B[r][c];
		}
	}

	for(long int i=1; i<=n; i++){
		for(long int j=1; j<=l; j++){
			sum = 0;
			for(long int k=1; k<=m; k++){
				sum += A[i][k] * B[k][j];
			}
			if(j<l)
				cout << sum << " ";
			if(j==l)
				cout << sum;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i,n) REP(i,0,n)
#define REP(i,l,r) for(int i=l;i<r;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
struct edge{
    int to,cost;
};
class dijkstra{
    int V;
    int d[100002];
    priority_queue<P,vector<P>,greater<P>>que;
    void update(int s,vector<edge> G[]){
        fill(d,d+V+1,100000000000ll);
        d[s]=0;
        que.push(make_pair(0,s));
        while(!que.empty()){
            P p=que.top();
            que.pop();
            int v=p.second;
            if(d[v]<p.first)continue;
            rep(i,G[v].size()){
                edge e=G[v][i];
                if(d[e.to]>d[v]+e.cost){
                    d[e.to]=d[v]+e.cost;
                    que.push(make_pair(d[e.to],e.to));
                }
            }
        }
    }
public:
    dijkstra(int v,int s,vector<edge> G[]){
        V=v;
        update(s,G);
    }
    int find(int e){
        return d[e];
;    }
};
ll dp[100000][3];
signed main(){
    ll n;
    cin>>n;
    rep(i,n){
        rep(j,3){
            int in;
            cin>>in;
            if(!i){
                dp[i][j]=in;
            }
            else{
                rep(k,3){
                    if(j==k)continue;
                    dp[i][j]=max(dp[i-1][k]+in,dp[i][j]);
                }
            }
        }

    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}



Measured memory_bytes: 2560
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Akash
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CAlchemist solver = new CAlchemist();
        solver.solve(1, in, out);
        out.close();
    }

    static class CAlchemist {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            PriorityQueue<Double> a = new PriorityQueue<>(n);
            for (int i = 0; i < n; i++) {
                a.add(in.nextDouble());
            }
            while (a.size() > 1) {
                double x = a.poll();
                double y = a.poll();
                a.add((x + y) / 2);
            }
            out.println(a.poll());
        }

    }
}



Measured memory_bytes: 23380
/* 
 * エラトステネスの篩を使った問題
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1172&lang=jp
 */
#include<iostream>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define ALL(c) (c).begin(), (c).end()
#define dump(a) cerr << #a << "=" << (a) << endl
#define PRIME_MAX 123456*2

using namespace std;

int main() {
	int N;
	bool prime[PRIME_MAX+1];

	prime[0] = false;
	prime[1] = false;
	REP(i,2,PRIME_MAX+1) prime[i] = true;

	//エラトステネスの篩
	REP(i,2,PRIME_MAX+1) {
		if (prime[i]) {  
			for (int j=i+i; j<PRIME_MAX+1; j+=i) prime[j] = false; 
		}
	}

	int prime_cnt;
	while(cin >> N && N) {
		prime_cnt=0;
		REP(i,N+1,2*N+1) { //n < i <= 2*n
			if (prime[i]) {
				prime_cnt++;
			}
		}
		cout << prime_cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 1400
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
const ll nmax = 1e9 + 7;
const ll MOD = 998244353;
const double PI = 2 * asin(1);

int main(){
  int N; cin >> N;
  pair <ll, ll> RL[N];
  for (int i = 0; i < N; i++){
    ll X, L; cin >> X >> L;
    RL[i].first = X + L;
    RL[i].second = X - L;
  }
  sort(RL, RL + N);

  int ans = 1, now = RL[0].first;
  for (int i = 1; i < N; i++){
    if (now <= RL[i].second){
      now = RL[i].first;
      ans++;
    }
  }
  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 1792
//q097.cpp
//Tue Sep 15 22:34:16 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

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

ll gcd (ll a, ll b){ //最大公約数
	if (b == 0){
		return a;
	}
	return gcd(b, a%b);
}

ll lcm (ll a, ll b){ //最小公倍数
	ll temp = gcd(a,b);
	return (a/temp)*b;
}

int main(){
	ll n,m;
	cin >> n >> m;

	ll logtwo = -1;
	ll x;
	rep(i,n){
		ll tmp;
		cin >> tmp;
		tmp = tmp/2;
		if (logtwo==-1){
			ll z = tmp;
			ll c = 0;
			while(z%2==0){
				c++;
				z = z/2;
			}
			logtwo = c;
			x = tmp;
		}else {
			ll z = tmp;
			ll c = 0;
			while(z%2==0){
				c++;
				z = z/2;
			}
			if (logtwo != c){
				cout << 0 << endl;
				return 0;
			}else {
				x = lcm(x,tmp);
				if (x>m){
					cout << 0 << endl;
					return 0;
				}
			}
		}
	}
	if (x>m){
		cout << 0 << endl;
	}else {
		cout << (m-x)/(x*2)+1 << endl;
	}
//	printf("%.4f\n",ans);
}

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

#define Fast           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO             freopen("in.txt", "r", stdin)
#define FC             freopen("out.txt", "w", stdout)
#define aise           cout<<"aise"<<endl
#define pb             push_back
#define pf             push_front
#define ppb            pop_back
#define ppf            pop_front
#define mp             make_pair
#define ll             long long
#define all(x)         x.begin(), x.end()
#define mset(v, a)     memset(v, a, sizeof(v))
#define pll            pair< ll, ll >
#define pd             pair< double, double >
#define ff             first
#define ss             second
#define pi             acos(-1.0)
#define mxN            2010
#define inf            1e14
#define mod            1000000007
#define tc             ll tc;scanf("%lld",&tc);while(tc--)

//NCR iterative
/*voidcomb_table(intN)
{
    for(inti=0; i<=N; ++i)
    {
        for(intj=0; j<=i; ++j)
        {
            if(j==0or j==i)
            {
                C[i][j]=1LL;
            }
            else
            {
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}*/


//NCR recursive
/*ll dp[55][55];

ll NCR(ll n,ll r)
{

    if(n==r)
        return dp[n][r]=1;
    if(r==0)
        return dp[n][r]= 1;
    if(r==1)
        return dp[n][r]=n ;
    if(dp[n][r] != -1)
        return dp[n][r];
    return dp[n][r] = NCR(n-1,r)+NCR(n-1,r-1);
}*/

//Sieve:
/*bool Flag[1000010];
vector<ll> Prime;

void sieve()
{

    ll val=sqrt(1000010);
    for(ll i=4;i<=1000005; i+=2) Flag[i]=1;
    for(ll i=3;i <= val;i+=2)
    {

        if(Flag[i]==0)
        {

            for(ll j=i*i;j<=1000005;j+=i) Flag[j]=1;
        }
    }
    Flag[1]=1;
    for(ll i=1;i<=1000000;i++)
        if(Flag[i]==0) Prime.pb(i);
}*/


//Conversion
/*string bin(ll x)
{

    string ret;
    while(x)
    {

        ll t=x%2;
        char c;
        if(t==1)
            c='1';
        else
            c='0';
        ret.pb(c);
        x/=2;
    }
    reverse(all(ret));
    return ret;
}*/

/*ll lcm(ll x, ll y)
{

    ll ret=__gcd(x,y);
    return (x*y)/ret;
}*/

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

int main()
{

    ll x,k,d;
    cin >> x >> k >> d;
    if(x < 0) x*=-1;
    ll vf=x/d;
    if(x%d) vf++;
    if(k<=vf)
    {

        ll ans=x-k*d;
        cout << abs(ans);
        return 0;
    }
    k-=vf;
    ll a=x-vf*d;
    ll b=a+d;
    if(k%2) cout << abs(b);
    else cout << abs(a);
}


Measured memory_bytes: 3648
while True:
    L=[]
    for i in range(8):
        s=raw_input()
        if "1" in s:
            L.append("0"+s+"0")
    if len(L)==4:
        print "B"
    elif len(L)==3:
        x=L[0].index("1")
        print "F" if L[1][x+1]=="1" else "D"
    elif len(L)==2:
        x=L[0].index("1")
        if L[1][x+1]=="1":
            print "A" if L[1][x]=="1" else "E"
        else:
            print "G"
    else:
        print "C"
    try:
        skip=raw_input()
    except EOFError:
        break

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

int main() {
    constexpr int mod = 1e9 + 7;
    vector<int> cnt(3, -1);
    long long ans = 1;
    
    int N;
    cin >> N;
    rep(i, N) {
        int a;
        cin >> a;
        int c = 0;
        rep(j, 3) {
            if (cnt[j] == a - 1) ++c;
        }
        ans *= c;
        ans %= mod;
        rep(j, 3) {
            if (cnt[j] == a - 1) {
                ++cnt[j];
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

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

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

using namespace std;

int main()
{
    using T = tuple<string,int,int> ;
    int n,i;

    cin >> n;
    vector<T> rest(n);

    for(i=0; i<n; i++){
        string s;
        int a;
        cin >> s >> a;
        rest.at(i) = T(s,-a,i+1);
    }
    
    sort(rest.begin(),rest.end());

    for(i=0; i<n; i++){
        string S;
        int A;
        int N;
        tie(S,A,N) = rest.at(i);
        cout << N << endl;
    }

    return 0;

}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<map>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1e9
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int main(){

    int n;
    cin >> n;
    for(int i = n;n <= 999;i++){
        if(i % 111 == 0){
            cout << i << endl;
            return 0;
        }
    }
    
  
    return 0;
}

Measured memory_bytes: 768
import sys

N_MAX = 200000 + 5
INF = 10**9 + 7
sys.setrecursionlimit(N_MAX)
MOD = 10**9 + 7

# ## COMBINATION (MOD) ## #
MOD = 10**9 + 7  # , N = 2*10**5 で 0.3s
N_MAX = 2 * 10**5  # 問題サイズに合わせて変えておく

fac = [1, 1]  # 元テーブル
facinv = [1, 1]  # 逆元テーブル
inv = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N_MAX + 1):
    fac.append((fac[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    facinv.append((facinv[-1] * inv[-1]) % MOD)


def fac(n, a):
    ans = 1
    for i in range(a):
        ans *= n
        ans %= MOD
        n -= 1
    return ans


def cmb(n, r):
    if (r < 0 or r > n):
        return 0
    # r = min(r, n-r)
    return fac[n] * facinv[r] * facinv[n - r] % MOD


def main():
    n, a, b = map(int, sys.stdin.readline().rstrip().split())

    # 全種類
    ans = pow(2, n, MOD) - 1  # -1 : 全部選ばない場合
    ans %= MOD

    # a種類になる場合
    ans -= fac(n, a) * facinv[a]
    ans %= MOD

    ans -= fac(n, b) * facinv[b]
    ans %= MOD

    print(ans)


main()

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


int main(){
    int N;
    cin>>N;
    
    int a;
    vector<int> cnt(1e5+3, 0);
    
    for(int i=0; i<N; i++){
        cin>>a;
        cnt[a]++;
        cnt[a+1]++;
        cnt[a+2]++;
    }

    int ans=0;
    for(int c : cnt){
        ans=max(c, ans);
    }

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

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

#define IOS ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
 
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vp vector<pii>
#define vs vector<string>
#define all(v) v.begin(),v.end()

#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define ff  first
#define ss  second
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
 
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
     
#define pi 3.14159265358979323846//20 decimals
#define MOD 1000000007

 
int32_t main(){

   //  #ifndef ONLINE_JUDGE
   // freopen("input.txt", "r", stdin);
   //  freopen("output.txt", "w", stdout);
   //  #endif
     IOS
    // // 
    string s;
    cin>>s;
   string ans="Good";
   for(int i=0;i<sz(s)-1;i++)
      {
        if(s[i]==s[i+1])
        {
            ans="Bad";break;
        }
    }
    cout<<ans;
return 0;
}

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

int main(void)
{
	int x,y,z,a=0,b,c;
	scanf("%d %d %d",&x,&y,&z);
	if (z-x <= y && z-x >= 0) printf("YES");
	else printf("NO");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
const Int MOD = 1000000007;
const Int MAX = 500000;
Int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
Int COM(int n, int k){
    if (n < k || n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
    COMinit();
    int N, K; cin >> N >> K;
    Int ans = 0;
    for (int i = 0; i <= min(N - 1, K); i++) {
        ans = ans + COM(N, i) * COM(N - 1, N - i - 1);
        ans %= MOD;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 12032
def main():
    N, M, X, Y = map(int, input().split())

    x = list(map(int, input().split()))
    y = list(map(int, input().split()))

    max_x = max(x)
    min_y = min(y)

    for i in range(X+1, Y):
        if max_x < i and min_y >= i:
            print('No War')
            exit()

    print('War')

main()

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;

	int count = 0;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i]) count++;
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 3924
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;

public class Main {
	int N;
	Map<Integer, Integer> map;
	int[] A;
	long pairNum;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		N = Integer.parseInt(in.readLine());
		String[] tokens = in.readLine().split(" ");
		A = new int[N];
		for (int i = 0; i < N; ++i) {
			A[i] = Integer.parseInt(tokens[i]);
		}
		this.map = new HashMap<>();
		for (int i = 0; i < N; ++i) {
			if (!this.map.containsKey(A[i])) {
				this.map.put(A[i], 0);
			}
			this.map.put(A[i], this.map.get(A[i]) + 1);
		}
		pairNum = 0;
		for (Integer key : this.map.keySet()) {
			pairNum += (long)map.get(key) * (long)(map.get(key) - 1) / 2;
		}
	}

	void calc() {
		for (int i = 0; i < N; ++i) {
			int a = A[i];
			long val = pairNum;
			long num = map.get(a);
			val -= (num * (num - 1)) / 2;
			val += (num - 1) * (num - 2) / 2;
			System.out.println(val);
		}
	}

	void showResult() {
	}

}



Measured memory_bytes: 74236
n = int(input())
a = map(int, input().split())
cnt=0
twocnt=0
for i in a:
	if(i % 4 == 0):
		cnt+=1
	elif(i % 2 == 0):
		twocnt+=1
cnt += twocnt//2

if(cnt >= n//2):
	print ("Yes")
else:
	print ("No")

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

int n,k;
pii s[125252];
bool used[125252];
int main(){
  scanf("%d%d", &n, &k);
  REP(i,n){
    int a,b;
    scanf("%d%d",&a,&b); --a;
    s[i] = pii(b,a);
  }
  sort(s,s+n);
  priority_queue<int> Q;
  int typs = 0;
  ll sum = 0;
  REP(_,k){
    n--;
    int t = s[n].second;
    int v = s[n].first;
    sum += v;
    if(used[t]){
      Q.push(-v);
    }else{
      used[t] = true;
      typs++;
    }
  }
  ll ans = sum + (ll)typs * typs;
  while(n>0 && Q.size()>0){
    sum += Q.top(); Q.pop();
    while(n--){
      int t = s[n].second;
      int v = s[n].first;
      if(used[t])continue;
      used[t] = true;
      typs++;
      sum += v;
      break;
    }
    ans = max(ans, sum + (ll)typs*typs);
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
int main(void){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a+b == c+d){
    cout << "Balanced" << endl;
  }else if(a+b > c+d){
    cout << "Left" << endl;
  }else{
    cout << "Right" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

int gcd(int a, int b){
    while(b > 0){
        a %= b;
        swap(a, b);
    }
    return a;
}

int main(int argv, char **argc){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int k;
    cin >> k;
    ll ans =0;
    for(int i = 1; i <= k; ++i){
        for(int j = 1; j <= k; ++j){
            for(int q = 1; q <= k; ++q){
                ans += gcd(gcd(i, j), q);
            }
        }
    }
    cout << ans << endl;
}


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

static const int N = 100;

int main(){
    int n, p[N+1], m[N+1][N+1];
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> p[i-1] >> p[i];
    }

    for(int i=1; i<=n; i++) m[i][i] = 0;
    for(int l=2; l<=n; l++){
        for(int i=1; i<=n-l+1; i++){
            int j = i + l -1;
            m[i][j] = (1 << 21);
            for(int k=i; k<=j-1; k++){
                m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
            }
        }
    }

    cout << m[1][n] << endl;

    return 0;
}


Measured memory_bytes: 3132
import java.io.*;

public class Main {

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

    String[] in = br.readLine().split(" ");
    x = Long.parseLong(in[0]);

    br.close();

    long i = -1000, j = -1000;
    boolean ok = false;

    for(i = -1000; i <= 1000; i++){
      for(j = -1000; j <= 1000; j++){
        if(gj(i) - gj(j) == x) {
          ok = true;
          break;
        }
      }
      if(ok) break;
    }

    PrintWriter out = new PrintWriter(System.out);
    out.println(i + " " + j);
    out.flush();

  }

  static long gj(long a){
    return a * a * a * a * a;
  }
}

Measured memory_bytes: 36732
// B.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[])
{
	int n;
	string s;
	cin >> n >> s;
	int ans = 0, d = 0;
	for (char c : s) {
		d += c == 'I' ? 1 : -1;
		ans = max(ans, d);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

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

using namespace std;

#define ll long long
#define ld long double

//#define TEST

struct line {
	ld theta; // (0, pi]
	int s, l;
	line(ld t, int s, int l) : theta(t), s(s), l(l) {}
};

line make_line(int i1, int i2, pair<int, int> p1, pair<int, int> p2) {
	int dir_x = p1.first - p2.first;
	int dir_y = p1.second - p2.second; // 2点間のベクトル
	int v_x = -dir_y; int v_y = dir_x; // 垂直二等分線の方向ベクトル
	if (v_y < 0) { v_y = -v_y; v_x = -v_x; }

	if (v_y == 0) {
		int l = p1.second > p2.second ? i2 : i1;
		int s = l == i1 ? i2 : i1;
		return line(M_PI, s, l);
	}
	else {
		ld t = atan2l(v_y, v_x);
		int l = p1.first > p2.first ? i2 : i1;
		int s = l == i1 ? i2 : i1;
		return line(t, s, l);
	}
}

signed main() {
	int n; cin >> n;
	vector<pair<int, int>> p(n);
	for (int i = 0; i < n; ++i)
		cin >> p[i].first >> p[i].second;

	vector<line> lines;
	for (int i = 0; i < n; ++i)
		for (int j = i + 1; j < n; ++j)
			lines.push_back(make_line(i, j, p[i], p[j]));

	sort(
		lines.begin(), lines.end(),
		[](line a, line b) { return a.theta < b.theta; }
	);

#ifdef TEST
	for (auto li : lines)
		cout << li.s << " " << li.l << " " << li.theta << endl;
#endif

	vector<ld> ok(n, 0);
	for (int i = 0; i <= lines.size(); ++i) {
		ld g = i == lines.size() ? M_PI : lines[i].theta;
		g -= i == 0 ? 0 : lines[i - 1].theta;
		vector<int> cnt(n + 1, 0);
		// i未満はl
		for (int j = 0; j < i; ++j)
			cnt[lines[j].l]++;
		// i以降はs
		for (int j = i; j < lines.size(); ++j)
			cnt[lines[j].s]++;
		// n-1なやつを探す
		int add_idx = n;
		for (int j = 0; j < n; ++j) {
			if (cnt[j] == n - 1) {
				add_idx = j;
				break;
			}
		}
		if (add_idx < n)
			ok[add_idx] += g;
	}

	for (int i = 0; i < lines.size(); ++i) {
		swap(lines[i].s, lines[i].l);
	}

	for (int i = 0; i <= lines.size(); ++i) {
		ld g = i == lines.size() ? M_PI : lines[i].theta;
		g -= i == 0 ? 0 : lines[i - 1].theta;
		vector<int> cnt(n + 1, 0);
		// i未満はl
		for (int j = 0; j < i; ++j)
			cnt[lines[j].l]++;
		// i以降はs
		for (int j = i; j < lines.size(); ++j)
			cnt[lines[j].s]++;
		// n-1なやつを探す
		int add_idx = n;
		for (int j = 0; j < n; ++j) {
			if (cnt[j] == n - 1) {
				add_idx = j;
				break;
			}
		}
		if (add_idx < n)
			ok[add_idx] += g;
	}

#ifdef TEST
	for (auto o : ok)
		cout << o << " ";
	cout << endl;
#endif

	cout << setprecision(15);

	for (auto o : ok)
		cout << (o / M_PI / 2) << endl;

	return 0;
}

Measured memory_bytes: 640
s = input()
n = len(s)
s = int(s,2)

if n%2 == 0:
  a = int("10"*(int(n/2)),2)
  b = int("01"*(int(n/2)),2)
else:
  a = int("10"*(int((n-1)/2)) + "1",2)
  b = int("01"*(int((n-1)/2)) + "0",2)

ansa = bin(s^a).count("1")
ansb = bin(s^b).count("1")
print(min(ansa,ansb))

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }

int n;
int m;
int a[10000];
int b[10000];

int main () {
	scanf ("%d", &n);
	ll sa = 0, sb = 0;
	for (int i = 0; i < n; i++) {
		scanf ("%d", &a[i]);
		sa += a[i];
	}
	for (int i = 0; i < n; i++) {
		scanf ("%d", &b[i]);
		sb += b[i];
	}
	if (sa > sb) {
		printf ("No\n");
		re 0;
	}
	ll rem = sb - sa;
	ll need = 0;
	for (int i = 0; i < n; i++)
		if (b[i] < a[i])
			need += a[i] - b[i];
		else
		if ((b[i] - a[i]) % 2 == 1)	
			need++;
//	cout << rem << " " << need << endl;
//	for (int i = 0; i < n; i++) cout << b[i] - a[i] << endl;
	if (need <= rem && (rem - need) % 2 == 0) {
		printf ("Yes\n");
	} else {
		printf ("No\n");
	}
	return 0;
}

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

int main()
{
    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i){
        cin >> A.at(i);
    }
    A.push_back(A.at(0) + K);
    int l=0;
    for (int i = 0; i < N; ++i)
    {
        l = max(l, A[i + 1] - A[i]);
    }

    int ans = K - l;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
from itertools import product

def read():
    N = int(input())
    return N,

def solve(N):
    count = 0
    for i in range(3, 10):
        for x in product('357',repeat=i):
            if '3' in x and '5' in x and '7' in x:
                if int(''.join(x), 10) <= N:
                    count += 1
    return count

if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 3060
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
// #include <prettyprint.hpp>
using namespace std;
typedef long long ll;
static const ll max_h = 12;
static const ll max_w = 1010;
static const ll max_value = -10000000000;
static const ll max_num = 2010;
// static const ll mod = 1000000007;
// vector<vector<ll>> F(max_h, vector<ll>(max_w, 0));
vector<pair<ll, ll>> infant_list(max_num);
vector<vector<ll>> dp(max_num, vector<ll>(max_num, 0));
ll ans = 0;
ll N;


int main(){
    // int u, v;
    // bool updated = false;
    // ll ans = 0;
    ll A;
    scanf("%lld", &N);
    for(ll i=0;i<N;i++){
        scanf("%lld", &A);
        infant_list[i] = make_pair(i+1, A);
    }

    sort(
        infant_list.begin(), 
        infant_list.begin()+N,
        [](const pair<ll,ll>& x, const pair<ll,ll>& y){return x.second > y.second;}
    );

    dp[0][0] = 0;
    for(ll i=1;i<=N;i++){
        for(ll x=0;x<=i;x++){
            ll y = i - x;
            pair<ll, ll> last_infant = infant_list[i-1];
            ll value_add_to_y = max_value, value_add_to_x = max_value;
            if(y>0){
                value_add_to_y = last_infant.second * (N-y+1 - last_infant.first) + dp[x][y-1];
            }
            if(x > 0){
                value_add_to_x = last_infant.second * (last_infant.first - x) + dp[x-1][y];
            }
            // cout << last_infant <<"N-y+1=" << N-y+1<< endl;
            // printf("x+y = %lld, x=%lld, y=%lld, value y=%lld, value x = %lld\n", i, x, y, value_add_to_y, value_add_to_x);
            dp[x][y] = max(value_add_to_x, value_add_to_y);
        }
    }

    ll ans = max_value;
    for(ll i=0;i<=N;i++){
        ans = max(dp[i][N-i], ans);
    }
    printf("%lld\n", ans);
    
    // double limit = 1. / (double)(4 * M);



    return 0;

}

Measured memory_bytes: 34780
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll n, k;
    cin >> n >> k;
    int ans = 0;
    ll m = 1;
    while(m <= n) {
        m *= k;
        ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 100

int main(){
  int n, i, j,k, a[N], tmp=0,minj,count=0;

    scanf("%d", &n);

    for (i = 0; i < n; i++) scanf("%d",&a[i]);

    for (i = 0; i < n; i++) {
        minj = i;
        for (j = i; j < n ; j++) {
            if (a[j] < a[minj]) {
                minj = j;
	    }
	}
                //A[i] と A[minj] 交換
	if(minj!=i){
                tmp = a[i];
                a[i] = a[minj];
                a[minj] = tmp;
		count++;
	}
        
    }

    for (k = 0; k < n; k++){
      printf("%d",a[k]);
      if(k!=n-1) printf(" ");
    }

    printf("\n%d\n",count);

    return 0;
}



Measured memory_bytes: 2104
#include<stdio.h>
int main(){
  char s[102];
  int g=0,i;
  while(fgets(s,101,stdin)){
    if(s[0]=='0')break;
    int a=0,b=0;
    for(i=1;s[i]!=10;i++){
      if(s[i]=='A')a++;
      else         b++;
    }
    if(a>b)a++;
    else   b++;
    printf("%d %d\n",a,b);
  }
  return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1145141919810
int main(){
    double n,sum=0,ans=0;
    cin>>n;
    vector<ll>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    vector<ll>dp(n-1);

    for(int i=0;i<n-1;i++){
        ans+=a[i];
        dp[i]=abs(ans-(sum-ans));
    }
    ll mini=INF;
    for(int i=0;i<n-1;i++){
        mini=min(mini,dp[i]);
    }
    cout<<mini<<endl;

}

Measured memory_bytes: 3328
import heapq
n, m = map(int, input().split())
A = list(map(int, input().split()))
B = [-a for a in A]
heapq.heapify(B)

for i in range(m):
    largest = heapq.heappop(B)
    heapq.heappush(B, -(-largest//2))
    
ans = 0
for i in range(n):
    ans += -heapq.heappop(B)
print(ans)


Measured memory_bytes: 75756
#include <iostream>
using namespace std;
int main(){
     int n;
     cin >> n;
     string s;
     cin >> s;
     int ans = 0;
     for (int i = 0; i < n; i++) {
        if (s[i - 1] != s[i]) 
	   ans++;
    }
 
    cout << ans;
    return 0;
}


Measured memory_bytes: 512
import java.util.Arrays; 
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		boolean[] can = new boolean[1000001];
		
		while(true){
			final int n = sc.nextInt();
			final int a = sc.nextInt();
			final int b = sc.nextInt();
			
			if(n == 0 && a == 0 && b == 0){
				break;
			}
			
			for(int i = 0; i <= n; i++){
				can[i] = false;
			}
			
			can[a] = true;
			can[b] = true;
			
			int count = 0;
			
			if(a <= n && b <= n){
				if(a == b){
					count++;
				}else{
					count+=2;
				}
			}
			
			for(int i = 0; i <= (n - a); i++){
				//System.out.println(i + " " + count);
				
				if(can[i] == true && can[i + a] == false){
					can[i + a] = true;
					count++;
				}
			}
			
			for(int i = 0; i <= (n - b); i++){
				//System.out.println(i + " " + count);
				
				if(can[i] == true && can[i + b] == false){
					can[i + b] = true;
					count++;
				}
			}
			
			System.out.println(n - count);
		}
		
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s; cin >> s;
    while(!s.empty())
    {
        s.pop_back();
        if(s.size() % 2 == 0) {
            string l = s.substr(0, s.size()/2);
            string r = s.substr(s.size()/2);
            if(l == r) {
                cout << s.size() << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
import numpy as np
from itertools import combinations
 
n, d = map(int, input().split())
x = np.empty((n, d), dtype=np.int64)
for i in range(n):
    x[i] = [int(i) for i in input().split()] 
res = 0
for i, j in combinations(range(n), 2):
    if (np.sum((x[i]-x[j])**2)**0.5).is_integer():
        res += 1
print(res)

Measured memory_bytes: 12776
n = int(input())
p = list(map(int, input().split()))
s = 0
for i in range(n-2):
    if p[i] < p[i+1] < p[i+2]:
        s += 1
    elif p[i] > p[i+1] > p[i+2]:
        s += 1
print(s)

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = nextInt()
	}
	return ints
}

func defeat(monsterNum, defeatingNum int) (remainingMonsterNum, defeatedNum int) {
	defeatedNum = defeatingNum
	if defeatedNum > monsterNum {
		defeatedNum = monsterNum
	}
	remainingMonsterNum = monsterNum - defeatedNum
	return
}

func count(as, bs []int) int {
	bs = append(bs, 0) // as にサイズを合わせる
	carry := 0
	defeatedAll := 0
	for i, v := range bs {
		monsterNum, defeatCount := defeat(as[i], carry)
		defeatedAll += defeatCount

		monsterNum, defeatCount = defeat(monsterNum, v)
		defeatedAll += defeatCount
		carry = v - defeatCount
	}
	return defeatedAll
}

func main() {
	n := nextInt()
	as := nextInts(n + 1)
	bs := nextInts(n)
	r := count(as, bs)
	fmt.Println(r)
}


Measured memory_bytes: 6144
#include <stdio.h>

int main() {
	char str[255];
	scanf("%s", str);
	// happy,newyear, enjoy
	str[5] = ' '; // karakter ke 6 pasti koma
	str[13] = ' '; // karakter ke 14 pasti koma
	printf("%s\n", str);
	return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
using namespace std;
 
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  
  int A;
  cin >> A;
  if (A<=9||(A<=18&&A%2==0)||(A<=27&&A%3==0)||(A<=36&&A%4==0)||(A<=45&&A%5==0)||(A<=54&&A%6==0)||(A<=63&&A%7==0)||(A<=72&&A%8==0)||(A<=81&&A%9==0)){
    cout << "Yes" << endl;
  }
  else { 
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;

int main()
{
    int n,b;
    int a[100005];
    cin >> n;
    long long ans = 0;
    for (int i = 1; i <= n + 1; i++) {
        cin >> a[i];
    }

    for (int i = 1; i <= n; i++) {
        cin >> b;

        if (a[i] >= b) {
            a[i] -= b;
            ans += b;
        }
        else {
            b -= a[i];
            ans += a[i];
            a[i] = 0;
            if (a[i + 1] >= b) {
                a[i + 1] -= b;
                ans += b;
            }
            else {
                b -= a[i + 1];
                ans += a[i + 1];
                a[i + 1] = 0;
            }
           
        }
    }

    cout << ans << endl;
    return 0;

}



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

using namespace std;

int main(){
  int n, x;
  
  cin >> n >> x;
  vector< int > a(n);

  for ( int i = 0; i < n; i++ ){
    cin >> a.at( i );
  }

  sort( a.begin(), a.end() );
  int tmp = x;
  int i, c = 0;
  for ( i = 0; i < n; i++ ){
    if ( tmp >= a.at( i ) ){
      tmp -= a.at( i );
      c++;
    }
  }

  if ( c == n && tmp > 0 ){
     c--;
  }
  //if ( c < 0 ) c = 0;
  cout << c << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		if(a==b) {
			System.out.println(a+b);
		}
		else {
			int c=Math.max(a, b);
			System.out.println(c+c-1);
		}
	}
}


Measured memory_bytes: 23764
#include <iostream>
using namespace std;
int main(void){
	int N;
  	cin >> N;
  	int a[N];
  	int i;
  	for(i=0;i<N;i++) cin >> a[i];
  	int max,min;
  	max = a[0];
  	min = a[0];
  	for(i=1;i<N;i++){
    	if(a[i] > max) max = a[i];
      	if(a[i] < min) min = a[i];
    }
  	cout << max - min << endl;
  	
}

Measured memory_bytes: 256