akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main(){
  int n; cin >> n;
  map<int,int> mp1;
  map<int,int> mp2;
  for(int i = 0;i < n;i++){//mp->first:入力された数字;mp->second:その数字の要素数.
    int v; cin >> v;
    if(i % 2 == 0)mp1[v]++;
    else mp2[v]++;
  }


  int first_max1_magnitude = 0;
  int first_max1_num = 0;
  for(auto itr = mp1.begin();itr != mp1.end();itr++){
    if(first_max1_num < itr->second){
      first_max1_magnitude = itr->first;
      first_max1_num = itr->second;
    }
  }

  int second_max1_magnitude = 0;
  int second_max1_num = 0;

  for(auto itr = mp1.begin();itr != mp1.end();itr++){
    if(second_max1_num < itr->second && itr->first != first_max1_magnitude){
      second_max1_magnitude = itr->first;
      second_max1_num = itr->second;
    }
  }

  int first_max2_magnitude = 0;
  int first_max2_num = 0;
  for(auto itr = mp2.begin();itr != mp2.end();itr++){
    if(first_max2_num < itr->second){
      first_max2_magnitude = itr->first;
      first_max2_num = itr->second;
    }
  }

  int second_max2_magnitude = 0;
  int second_max2_num = 0;

  for(auto itr = mp2.begin();itr != mp2.end();itr++){
    if(second_max2_num < itr->second && itr->first != first_max2_magnitude){
      second_max2_magnitude = itr->first;
      second_max2_num = itr->second;
    }
  }

  int ans = n - first_max1_num - first_max2_num;

  if(first_max1_magnitude == first_max2_magnitude){
    ans = n - max(first_max1_num + second_max2_num,first_max2_num + second_max1_num);
  }

  cout << ans << endl;
}


Measured memory_bytes: 4992
N=int(input())
L=[list(map(int,input().split())) for i in range(N)]
t=[]
x=[]
y=[]
t.append(0)
x.append(0)
y.append(0)
for i in range(N):
    t.append(L[i][0])
    x.append(L[i][1])
    y.append(L[i][2])
for i in range(1,N+1):
    dt=t[i]-t[i-1]
    dist=abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
    if dist>dt:
        print("No")
        exit()
    else:
        if (x[i]+y[i])%2!=t[i]%2:
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 29828
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int a[200100];
int main()
{
    int n;
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    long long ans=0;
    for(int i=2;i<=n;i++)
    {
        if(a[i]<a[i-1])
        {
            ans += (a[i-1] - a[i]);
            a[i] = a[i-1];
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4400
#include <iostream>
#include <cstdio>

using namespace std;

int main(void){
    int a,b,n;
    int s;
    int i;
    
    while(cin>>a>>b>>n){
        s=0;
        for(i=0;i<n;i++){
            a*=10;
            s+=(a/b)%10;
            a=a%b;
        }
        cout<<s<<endl;
    }
    return(0);
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define optimize ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define lp(i,a,b) for(int i = a ; i <= b ; i ++)
#define rlp(i,a,b) for(int i = b ; i >= a ; i --)
#define a_sort(v) sort(v.begin(), v.end())
#define d_sort(v) sort(v.rbegin(), v.rend())
#define pii pair<int,int>
#define pi 3.14159265358979323846264338327950
using namespace std ;
// #define debug

const int MOD = 1E9 + 7 ;
const int N = 1E5 ;

int main() {
    #ifdef debug
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif // debug
    optimize

    ll a , v ; cin >> a >> v ;
    ll b , w ; cin >> b >> w ;
    ll t ; cin >> t ;
    if(v <= w) cout << "NO\n" ;
    else {
        puts(abs(a - b) <= t * (v-w) ? "YES" : "NO") ;
    }
}


Measured memory_bytes: 3656
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

const int MAX_V = 1e5;

struct edge {
    int to, cost;

    edge(int to, int cost) : to(to), cost(cost) {}
};

vector<edge> G[MAX_V];
vector<bool> seen(MAX_V, false);
vector<bool> isB(MAX_V, false);

void dfs(int idx, bool b) {
    seen[idx] = true;
    isB[idx] = b;

    for (int i = 0; i < G[idx].size(); ++i) {
        if (seen[G[idx][i].to]) continue;
        if (G[idx][i].cost % 2 == 0) dfs(G[idx][i].to, b);
        else dfs(G[idx][i].to, !b);
    }
}


int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll n = inl();
        rep(i, n - 1) {
            ll u, v, w;
            cin >> u >> v >> w;
            u--, v--;
            edge e1(u, w);
            edge e2(v, w);
            G[v].eb(e1);
            G[u].eb(e2);
        }
        rep(i, n) {
            if (!seen[i]) dfs(i, false);
        }
        rep(i, n) {
            if (isB[i]) cout << 1 << endl;
            else cout << 0 << endl;
        }


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define BR cout<<endl;
#define LEN(s) s.length();
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const ll mod=1000000007;

int main(){
    char c[3];
    rep(i,3)cin >> c[i];

    for(int i = 0; i < 3 ; i++){
        if(c[i] == '1'){
            cout << '9';
        }
        else if(c[i] == '9'){
            cout << '1';
        }
        else cout << c[i];
    }

    BR;

    return 0;
}



Measured memory_bytes: 3636
s=[]
p=[]
a=i=0
for c in input():
 if"\\"==c:s+=[i]
 elif"/"==c and s:
  j=s.pop()
  t=i-j
  a+=t
  while p and p[-1][0]>j:t+=p[-1][1];p.pop()
  p+=[(j,t)]
 i+=1
print(a)
if p:print(len(p),*list(zip(*p))[1])
else:print(0)



Measured memory_bytes: 6496
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
	int N;
	int A[2][100];
	scanf("%d",&N);
	for(int i=0;i<N;i++) scanf("%d", &A[0][i]);
	for(int i=0;i<N;i++) scanf("%d", &A[1][i]);
	int ans = 0;
	for(int i=0;i<N;i++){
		int tmp = 0;
		for(int j=0;j<=i;j++){
			tmp += A[0][j];
		}
		for(int j=i;j<N;j++){
			tmp += A[1][j];
		}
		if(tmp > ans) ans = tmp;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
multiset<string> s;
int main(){
    //freopen("beargguy.in","r",stdin);
    //freopen("beargguy.out","w",stdout);
    int r,b,g;
    scanf("%d%d%d",&r,&b,&g);
    for(int i=1;i<=r;i++){
        string a="a";
        s.insert(a);
    }
    for(int i=1;i<=b;i++){
        string a="b";
        s.insert(a);
    }
    for(int i=1;i<=g;i++){
        string a="c";
        s.insert(a);
    }
    string ans;
    while(!s.empty()){
        string fir=*s.begin();
        s.erase(s.begin());
        if(s.empty()){
            ans=fir;
            break;
        }
        string las=*(--s.end());
        s.erase(--s.end());
        if(s.empty()){
            ans=fir+las;
            break;
        }
        s.insert(fir+las);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int n;
	scanf("%d", &n);

	int cc = 0;
	for (int i = n; i > 0; i--) {
		int b = i;
		int c = 0;
		while (b / 10 >= 1) {
			c++;
			b = b / 10;
			//printf("%d *%d ", c,b);
		}
		if (c % 2 == 0) {
			cc++;
			//printf("*%d", cc);
		}
	}
	printf("%d", cc);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main(void){

    int N, D;       cin >> N >> D;
    vector<vector<int>> X(N , vector<int> (D));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < D ; j++){
            cin >> X[i][j];
        }
    }

    int ans = 0;
    for(int i = 1 ; i < N ; i++){
        for(int j = 0 ; j < i ; j++){

            int dis = 0;
            for(int k = 0 ; k < D ; k++)
                dis += (X[i][k] - X[j][k])*(X[i][k] - X[j][k]);

            int keep = 0;
            while(keep*keep <= dis){
                if(keep*keep == dis)     ans++;

                keep++;
            }
            
        }
    }

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

Measured memory_bytes: 256
n,q = map(int,input().split())
S = input()
SUM = [0]*n
for i in range(1,n):
    if S[i-1] == 'A' and S[i] == 'C':
        SUM[i] = 1
for i in range(1,n):
    SUM[i] += SUM[i-1]
for i in range(q):
    l,r = map(int,input().split())
    print(SUM[r-1]-SUM[l-1])

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

#define int long long
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

//*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)



void solve(){
    int N;
    cin >> N;
    vector<int> p(N+1,0);
    for(int i=0; i<N; i++)
        cin >> p[i] >> p[i+1];
    
    vector<vector<int>> dp(N+1, vector<int>(N+1,0));
    
    for(int w=2; w<=N; w++){
        for(int i=1; i<=N-w+1; i++){
            int j=i+w-1;
            dp[i][j] = INF;
            for(int k=i; k<=j-1; k++){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + p[i-1]*p[k]*p[j]);
            }
        }
    }
    cout << dp[1][N] << endl;
}


signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}



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

typedef struct{
	long a, b;
}store;

int comp(const void *a, const void *b){
	return (*(store*)a).a > (*(store*)b).a;
}

int main(void){
	int n, m;
	store *st;
	long sum = 0;
	scanf("%d %d", &n, &m);
	st = malloc(sizeof(store) * n);
	for(int i = 0; i < n; i++)
		scanf("%ld %d", &((st + i)->a), &((st + i)->b));
	qsort(st, n, sizeof(store), comp);
	int i = 0;
	while(m){
		if(st[i].b <= m){
			sum += st[i].a * (long)st[i].b;
			m -= st[i].b;
		//printf("%d:%d\n", st[i].a, st[i].b);
		}else{
			sum += st[i].a * m;
		//printf("%d:%d\n", st[i].a, m);
			m = 0;
		}
		i++;
	}
	printf("%ld\n", sum);
	return 0;
}


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

using namespace std;

int main()
{
  int sum = 0;
  string s;

  while(cin>>s){
    int check = 0;
    int temp = 0;
    
    for(int i = 0; i < s.size();++i){
      if(!isdigit(s[i])){
        check = 0;
      }
      else{
        if(check == 0){
          temp += s[i] - 48;
          check = 1;
        }
        else{
          temp = temp * 10;
          temp += s[i] - 48;
        }
      }

      if(check == 0 || i == s.size() - 1){
        sum += temp;
        temp = 0;
      }
    }
  }
  cout<<sum<<endl;
  
  return 0;
}


Measured memory_bytes: 3096
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
const int mod=1e9+7;

signed main(){
    int n,m;
    cin >> n >> m;
    vector<P> a(n);
    for(int i=0;i<n;i++){
        int A,B;
        cin >> A >> B;
        a[i]=make_pair(A,B);
    }
    sort(a.begin(),a.end());
    ll ans=0,bought=0;
    for(int i=0;i<n;i++){
        if(m-bought>a[i].second){
            bought+=a[i].second;
            ans+=a[i].first*a[i].second;
        }else{
            ans+=a[i].first*(m-bought);
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int N,D,ans,a[10][10],r;
int main()
{
	cin>>N>>D;
	for (int i=0;i<N;i++)
	    for (int j=0;j<D;j++)
	        cin>>a[i][j];
    for (int i=0;i<N;i++)
        for (int j=i+1;j<N;j++)
        {
        	r=0;
			for (int k=0;k<D;k++)
        	    r+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);  
			if (round(pow(round(sqrt(r)),2))==r) ans++;  
        }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
n=int(input())
syo=[]
mx=0
for i in range(n):
  a=int(input())
  gen=[]
  for j in range(a):
    x,y=map(int,input().split())
    gen.append([x-1,bool(y)])
  syo.append(gen)
for i in range(2**n):
  brk=False
  table=[False]*n
  for j in range(n):
    if((i>>j)&1):
      table[j]=True
  for j in range(n):
    if table[j]==False:
      continue
    for syogen in syo[j]:
      if table[syogen[0]]!=syogen[1]:
        brk=True
        break
    if brk:
      break
  if brk:
    continue
  cnt=table.count(True)
  if cnt>mx:
    mx=cnt
print(mx)
        

Measured memory_bytes: 9196
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int a, b; cin >> a >> b; cout << a + b << endl;
	}
	return 0;
}

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


int main() {
  int M , N;
  vector<int> A(1001);
  int count = 0;
  ll sum = 0;
  cin >> N >> M;
  rep (i, N) cin >> A.at(i);
  rep (i, N) sum += A.at(i);
  rep (i, N) if (4 * M * A.at(i) >= sum) count++;
  if (M <= count) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
# frozen_string_literal: true

n, _m, c = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
a = Array.new(n) { gets.split.map(&:to_i) }

puts a.count { |i| i.map.with_index { |j, idx| j * b[idx] }.inject(c, :+) > 0 }

Measured memory_bytes: 3836
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<set>
#include<functional>
#include<list>
#include<bitset>
using namespace std;
typedef long long ll;



int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int x = x2 - x1;
	int y = y2 - y1;
	int x3, y3, x4, y4;
	x3 = x2 - y;
	y3 = y2 + x;
	x4 = x3 - x;
	y4 = y3 -y;
	cout << x3 << " " << y3 << " " << x4 << " " << y4;
	return 0;
	
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;
typedef long long int ll;
    
int main()
{
    string S, ans;
    cin >> S;

    for (int i = 0; i < S.size(); i++) {
        ans += 'x';
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
    int N; cin >> N;
    string S; cin >> S;

    int ans = 0;
    for (int i = 0; i <= S.length() - 3; i++)
    {
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C')
        {
            ans++;
        }
    }

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

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

int bubbleSort(int A[], int N)
{
	int sw = 0;
	bool flag = 1;
		for (int i = 0;flag; i++)
		{
			flag = 0;
			for (int j = N - 1; j >= i + 1; j--)
			{
				if (A[j] < A[j - 1])
				{
					swap(A[j], A[j - 1]);
					flag = 1;
					sw++;

				}
			}
		}
	return sw;
 }

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

	sw = bubbleSort(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: 3096
board = [int(s) for _ in range(4) for s in input().split()]
move_piece = [None] * 46
GOAL = list(range(1, 16)) + [0]
def create_adjacent(h, w):
    adjacent = [[] for _ in range(h * w)]
    for i in range(h * w):
        if i % w != w - 1:
            adjacent[i].append(i + 1)
        if i % w != 0:
            adjacent[i].append(i - 1)
        if i // h < h - 1:
            adjacent[i].append(i + w)
        if i // h > 0:
            adjacent[i].append(i - w)
    return adjacent

def id_search(limit, move, space, lower):
    if move == limit:
        if board == GOAL:
            global count
            count += 1
            # print(move_piece[1:])
            print(move)
            exit()
    else:
        for x in adjacent[space]:
            p = board[x]
            if move_piece[move] == p:
                continue
            board[space], board[x] = p, 0
            move_piece[move + 1] = p
            new_lower = lower - distance[p][x] + distance[p][space]
            # 下限値枝刈り法
            if new_lower + move <= limit:
                id_search(limit, move + 1, x, new_lower)
            # もとに戻す
            board[space], board[x] = 0, p

def create_distance(h, w):
    distance = [[0] * h * w for _ in range(h * w)]
    for i in range(h * w):
        if i == 0:
            continue
        ye, xe = divmod(i - 1, w)
        for j in range(h * w):
            y, x = divmod(j, w)
            distance[i][j] = abs(ye - y) + abs(xe - x)
    return distance

def get_distance(board):
    v = 0
    for x in range(len(board)):
        p = board[x]
        if p == 0:
            continue
        v += distance[p][x]
    return v

adjacent = create_adjacent(4, 4)
# print(adjacent)
distance = create_distance(4, 4)
# print(distance)
n = get_distance(board)
count = 0
for x in range(n, 46):
    # print('move', x)
    id_search(x, 0, board.index(0), n)
    if count > 0:
        break


Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
#define ref(i,c,n) for(int i = n;i<c;i++)

int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    string s;
    cin>>s;
    int temp = a+b;
        ref(i,s.size(),0)
        {
            if(s[i] == 'a' && temp != 0)
               {
                 temp--;
                 cout<<"Yes\n";
               }
            else if(s[i] == 'b' && temp != 0 && b != 0)
            {
                temp--;
                b--;
                cout<<"Yes\n";
            }
            else
                cout<<"No\n";
        }
    return 0;
}

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



int main() {
	int N, D, X;
	cin >> N >> D >> X;
	vector<int> A(N);
	for(int i = 0; i < N; i++){
		cin >> A.at(i);
	}
	int ans = 0;
	for(int i = 0; i < N; i++){
		int cnt = 0;
		while(A.at(i) * cnt + 1 <= D){
			cnt++;
		}
		ans += cnt;
	}
	cout << ans + X << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

int main() {
    ll a;
    double b;
    cin >> a >> b;

    ll c = 100*b + 0.5;
    a *= c;
    a /= 100;
    
    out(a);
    re0;
}

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

using namespace std;

int main() {
  int a, b, c;
  long long k;
  cin >> a >> b >> c >> k;
  if (k % 2 == 0) {
    printf("%d\n", a - b);
  } else {
    printf("%d\n", b - a);
  }
  return 0;
}


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

using namespace std;
#define ll long long int
#define rep(i,n) for(i=0;i<(n);i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
typedef pair< ll, ll > lpair;

ll solve()
{
    ll k;
    cin >> k;
    ll rem = 0; ll ten = 1;
    for(ll i = 1; i <= k; i++)
    {
        rem += ten * 7;
        rem %= k;
        ten *= 10;
        ten %= k;

        if(rem == 0) return i;
    }
    return -1;
}

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

    ll t = 1;
    // cin >> t;
    while(t--) cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;


int main(void) {
	ll n, k;
	cin >> n >> k;
	vl p(n);
	rep(i, n) cin >> p[i];
	sort(all(p));
	ll ans = 0;
	rep(i, k)ans += p[i];
	cout << ans << endl;
	return 0;
}


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

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("%lld", &x); return (x); }

char field[101][101];
bool isLeave[101][101];

char getNextPosTileAndNextPos(int x, int y, int* nextX, int* nextY)
{
	char result = '.';

	switch( field[y][x] )
	{
		case '>':
			result = field[y][x + 1];
			*nextX = x + 1;
			*nextY = y;
			break;
		case '<':
			result = field[y][x - 1];
			*nextX = x - 1;
			*nextY = y;
			break;
		case '^':
			result = field[y - 1][x];
			*nextX = x;
			*nextY = y - 1;
			break;
		case 'v':
			result = field[y + 1][x];
			*nextX = x;
			*nextY = y + 1;
			break;
		case '.':
			break;
	}
	return result;
}

int main()
{
	int w;
	int h;
	int x;
	int y;

	while( true )
	{
		scanf("%d%d", &h, &w);
		if( w == 0 && h == 0 )break;
		x = 0;
		y = 0;
		loop(i, 0, h)
		{
			scanf("%s", field[i]);
		}
		loop(i, 0, h)
		{
			loop(j, 0, w)
			{
				isLeave[i][j] = false;
			}
		}
		
		do
		{
			if( isLeave[y][x] )
			{
				printf("LOOP\n");
				break;
			}
			isLeave[y][x] = true;
		}
		while( getNextPosTileAndNextPos( x, y, &x, &y ) != '.' );
		if( field[y][x] == '.' )
		{
			printf("%d %d\n", x, y);
		}
	}
	return (0);
}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  int cnt = 0, min_choice = h + w - 1;
  for (int i = 0; i < h; i ++) {
    for (int j = 0; j < w; j ++) {
      cin >> a.at(i).at(j);
      if (a.at(i).at(j) == '#') {
        cnt ++;
      }
    }
  }

  string ans;
  if (cnt == min_choice) {
    ans = "Possible";
  } else {
    ans = "Impossible";
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    ans = N
    for i in range(N + 1):
        cc = 0
        t = i
        while t > 0:
            cc += t % 6
            t //= 6
        t = N - i
        while t > 0:
            cc += t % 9
            t //= 9
        ans = min(ans, cc)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 8964
// ------------------------------------
// Date:2018/ 3/ 5
// Problem:ABC 082 TwoAnagrams b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

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

  string s, t;
  cin >> s >> t;
  // s' < t'
  sort(ALL(s));
  sort(ALL(t), [](char x, char y) { return x > y; });

  bool ok = false;
  if (s < t) ok = true;

  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}



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

typedef  long long ll;
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//
//

using namespace std;

int ctoi(char c) {
 switch (c) {
 case '0': return 0;
 case '1': return 1;
 case '2': return 2;
 case '3': return 3;
 case '4': return 4;
 case '5': return 5;
 case '6': return 6;
 case '7': return 7;
 case '8': return 8;
 case '9': return 9;
 default: return 0;
 }
}


 long double a,b,c,s,t,x,y,z;
 long double A,B,C,S,T,X,Y,Z;

 long double cnt;

 long double pi=3.14159265358979323846;

 string N,M;

unsigned long long D;

signed main(){

	cin>>a;

	if(a==0) cout<<1;
	else cout<<0;;
	
	return 0;

}


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

int main()
{
    int ans = 700;
    for(int i = 0; i < 3; ++i) {
        char tmp = fgetc(stdin);
        if(tmp == 'o') ans += 100;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
mat = np.zeros((50, 50)).astype(int)

N, M = list(map(int, input().split(' ')))
for m in range(M):
    i, j = list(map(int, input().split(' ')))
    i, j = i-1, j-1
    mat[i][j] += 1
    
for n in range(N):
    res = 0
    for i in range(N):
        res += mat[n][i]
        res += mat[i][n]
    print(res)

Measured memory_bytes: 21272
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	double T, X;
	cin >> T >> X;
	cout << setprecision(10) << T / X << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
long i,ww,n,a,b,w[31],t;
char c;
cin>>ww>>n;
for(i=1;i<=ww;i++)w[i]=i;
for(i=1;i<=n;i++){
cin>>a>>c>>b;
t=w[a];w[a]=w[b];w[b]=t;
}
for(i=1;i<=ww;i++)cout<<w[i]<<endl;
return 0;
}

Measured memory_bytes: 1160
import itertools
import bisect

n = int(input())

L = list(map(int,input().split()))

A = sorted(L)

ans = 0

for i in range(n):
    for j in range(i+1,n):
        total = L[i] + L[j]
        ans += bisect.bisect_left(A,total) - (j+1)

print(ans)  


Measured memory_bytes: 44576
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Thu Dec 27 21:13:28 2018
//
package main

import (
	"fmt"
	"sort"
)

func min(args ...int) int {
	sort.Ints(args)
	return args[0]
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	var A, B, C, X, Y int
	fmt.Scan(&A, &B, &C, &X, &Y)

	withoutHalf := A*X + B*Y
	withHalfMin := 2*C*min(X, Y) + A*(X-min(X, Y)) + B*(Y-min(X, Y))
	withHalfMax := 2 * C * max(X, Y)

	fmt.Println(min(withoutHalf, withHalfMin, withHalfMax))
}


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

int main() {
  int H, W; cin >> H >> W;
  vector<string> string_list(H);
  vector<string> sharp_line(W+2, "#");
  for(int i = 0; i < H; i++) {
    string tmp; cin >> tmp;
    string_list[i] = "#" + tmp + "#";
  }
  for(auto i : sharp_line) {
    cout << i;
  }
  cout << endl;
  for(auto i : string_list) { 
    cout << i << endl; 
  }
  for(auto i : sharp_line) {
    cout << i;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
N=int(input())
S=input()
R=[]
G=[]
B=[]
for i in range(N):
    if S[i]=='R':
        R.append(i)
    elif S[i]=='G':
        G.append(i)
    else:
        B.append(i)

out=len(R)*len(G)*len(B)
for i in range(len(R)):
    for ii in range(len(G)):
        a=1

for i in range(N-2):
    for ii in range(1,(N-i)//2+(N-i)%2):
        if S[i]!=S[i+ii] and S[i+ii]!=S[i+2*ii] and S[i]!=S[i+2*ii]:
            out-=1

print(out)

Measured memory_bytes: 9260
<?php
  
$n = trim(fgets(STDIN));
$si = [];
for($i=0; $i<$n; $i++){
  array_push($si,trim(fgets(STDIN)));
}
$m = trim(fgets(STDIN));
$ti = [];
for($i=0; $i<$m; $i++){
  array_push($ti,trim(fgets(STDIN)));
}

$s = array_count_values($si);
$t = array_count_values($ti);

$c = [0];
foreach($s as $sk => $sv){
  foreach($t as $tk => $tv){
    if ($sk == $tk) {
      array_push($c, $sv-$tv);
    } else if (!in_array($sk, $ti)){
      array_push($c, $sv);
    }
  }
}

echo max($c);

?>

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  int res = 0;
  int cnt = 0;
  p.emplace_back(n+2);
  for (int i = 0; i <= n; i++) {
    if (p[i] != i + 1) res += cnt, cnt = 0;
    else {
      cnt++;
      if (cnt == 2) {
        res += 1;
        cnt = 0;
      }
    }
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int be(int a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod))%mod; else return (be(a,b/2,mod)*be(a,b/2,mod))%mod;}
const int mod = 1e9 + 7;
#define PI 3.14159265359
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcountll
#define setbitcnt __builtin_ctz
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
#define mkp(x,y) make_pair(x,y)
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define roundup(a,b)  std::cout << std::fixed;std::cout << std::setprecision(b); std::cout << a
const int siz = (1e6 + 10);
const int logi = 21;
const double epsilon = 1e-6;
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}



signed main()
{
	#ifndef ONLINE_JUDGE
 	freopen("in.txt", "r", stdin);
 	freopen("out.txt", "w", stdout);
 	#else
// // online submission
 	#endif 
	speedrap
	int t;
	t = 1;
	//cin>>t;
	int val = 0;
	while(t--)
	{
		string s,t;
		cin>>s>>t;
		int n = s.length();
		int m = t.length();
		int ans = m;
		for(int i = 0 ; i < n ; i++)
		{
			if(i + m - 1 > n - 1)
			{
				break;
			}
			int cnt = 0;
			for(int j = 0 ; j < m ; j++)
			{
				if(s[i+j] != t[j])
				{
					cnt++;
				}
			}

			ans = min(ans,cnt);
		}
		cout<<ans;
	}
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<string>
//#define fo(i,n) for(int i=1;i<=n;i++)
//#define for(i,n) for(int i=0;i<n;i++)
#define ll long long 
using namespace std;
const int N=1e5+5;
string s;
int main()
{
	int n,res1,res2,res3,res4;
	cin>>n;
	res1=res2=res3=res4=0;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		if(s[0]=='A')res1++;
		if(s[0]=='W')res2++;
		if(s[0]=='T')res3++;
		if(s[0]=='R')res4++;
	}
	printf("AC x %d\n",res1);
	printf("WA x %d\n",res2);
	printf("TLE x %d\n",res3);
	printf("RE x %d\n",res4);
	
	return 0;
 } 

Measured memory_bytes: 3256
#include <bits/stdc++.h>
#include <iomanip>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

int main() {
  int N;  cin >> N;
  ll M=0, A=0, R=0, C=0, H=0;
  rep(i,N){
    string S;
    cin >> S;
    if(S[0] == 'M') M++;
    if(S[0] == 'A') A++;
    if(S[0] == 'R') R++;
    if(S[0] == 'C') C++;
    if(S[0] == 'H') H++;
  }
  ll ans=0;
  ans += M*A*R + M*A*C + M*A*H;
  ans += M*R*C + M*R*H;
  ans += M*C*H;
  
  ans += A*R*C + A*R*H;
  ans += A*C*H;
  
  ans += R*C*H;
  
  cout << ans << endl;
  return 0;
}
  



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>

using namespace std;
using ll = long long int;

int main()
{
  string s;
  cin >> s;
  int zero, one;
  zero = one = 0;
  for(int i = 0; i < s.size(); i++)
  {
    if(s[i] == '0') {
      zero++;
    }else{
      one++;
    }
  }
  cout << min(zero, one) * 2 << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
int n,i;
string s;
set<int>s1;
cin>>s;
n=s.size();
for(i=0;i<n;++i){
    s1.insert(s[i]);
}
if(s1.size()==n){
    printf("yes\n");
}
else{
    printf("no");
}


    return 0;
}


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

long long gcd(long long a, long long b) {
    if (a % b == 0) return b;
    return gcd(b, a % b);
}

long long lcm(long long a, long long b){
    return a / gcd(a, b) * b;
}

int main() {
    int64_t a, b, c, d;
    cin >> a >> b >> c >> d;
    auto f = [&](int64_t n) -> int64_t {
        int64_t res = n - (n / c + n / d - n / lcm(c, d));
        return res;
    };
    int64_t ans = f(b) - f(a - 1);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PUTS(x) cout << (x) << endl;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define MP make_pair
#define PB push_back
#define F first
#define S second
int main() {
    int n;
    cin >> n;
    auto v = vector<pair<string, int>>();
    rep(i, n) {
        string s;
        int t;
        cin >> s >> t;
        v.PB(MP(s, t));
    }
    string x;
    cin >> x;

    int ans = 0;
    auto flag = false;
    for (auto p : v) {
        auto s = p.F;
        auto t = p.S;
        if (flag) ans += t;
        if (s == x) flag = true;
    }
    PUTS(ans);
}


Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}
template<typename T>
T lcm( T m, T n )
{
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    long long N;
    int sum=0;

    cin >> N;
    vector<int>s(N);

    for(int i=0; i<N; i++){
        cin>>s[i];
        sum+=s[i];
    }

    sort(s.begin(),s.end());

    if(sum%10==0){
        int temp=sum;
        rep(i,N){
            if(s[i]%10!=0) {
                sum -= s[i];
                break;
            }
        }
        if(sum==temp) sum=0;
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 256
// SeeAlso:
// - https://img.atcoder.jp/abc145/editorial.pdf
// - http://drken1215.hatenablog.com/entry/2018/06/08/210000
// - https://atcoder.jp/contests/abc145/submissions/8479589
package main

import (
	"fmt"
)

const MAX = 1000000
const MOD = 1000000007

var inv = make([]int, MAX)

func knight(x, y int) int {
	// 1回の移動でX座標+Y座標の値は3増える。
	// よって、　X＋Yが3の倍数でない時答えは0
	if (x+y)%3 != 0 {
		return 0
	}
	// 3の倍数のとき、
	//(1,2)の移動の回数をn
	//(2,1)の移動の回数をmとすると
	// n + 2m = X
	// 2n + m = Y
	// が得られる
	m := (2*x - y) / 3
	n := x - 2*m
	return com(n+m, m)
}

// テーブルを作る前処理
func cominit() {
	inv[1] = 1
	for i := 2; i < MAX; i++ {
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
	}
}

func finv(x int) int {
	ans := 1

	for i := 2; i <= x; i++ {
		ans = ans * inv[i] % MOD
	}
	return ans
}

func fact(x int) int {
	ans := 1

	for i := 2; i <= x; i++ {
		ans = ans * i % MOD
	}
	return ans
}

// 二項係数計算
func com(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	cominit()
	return fact(n) * (finv(k) * finv(n-k) % MOD) % MOD
}

func main() {
	var x, y int
	fmt.Scan(&x, &y)
	fmt.Println(knight(x, y))
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	string S;
	cin >> S;
	vector<string> v;
	if (S[1] == 'S') {
		v.emplace_back(S.substr(0, 1));
		v.emplace_back(S.substr(2, 1));
	}
	else {
		v.emplace_back(S);
	}
	int ans = 0;
	for (auto s : v) chmax(ans, count(ALL(s), 'R'));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define sz(a) int((a).size())
	#define pb push_back
	#define mod 1000000007
	#define inf 1000000000000000001
	#define all(c) (c).begin(),(c).end()
	#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
	#define present(c,x) ((c).find(x) != (c).end())
	#define cpresent(c,x) (find(all(c),x) != (c).end())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	#define FOR(i, a, b) for (int i=a; i<(b); i++)
	#define F0R(i, a) for (int i=0; i<(a); i++)
	
	using namespace std;
	
	int main()
	{
		ios::sync_with_stdio(0);
    	cin.tie(0);
    	cout.tie(0);

		ll n;
		cin >> n;
		ll a[n];
		F0R(i,n) cin >> a[i];
		ll ans=0;
		F0R(i,n-1) {
			FOR(j,i+1,n) {
				ans+=a[i]*a[j];
			}
		}
		cout << ans ;
		
		return 0;
	}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String ans = "A";
    int x = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(Math.abs(a - x) > Math.abs(b - x)) ans = "B";
    System.out.println(ans);
  }
}

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


#define lp(i, n)         for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)     for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)     for(int i=(j);i>=(int)(n);--i)
#define sci(a)	scanf("%d",&a)
#define scll(a)	scanf("%lld",&a)
#define scii(a, b)	scanf("%d%d",&a, &b)
#define pri(a)	printf("%d\n",a)
#define prll(a)	printf("%lld\n",a)
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)


const double eps = 1e-8;

typedef  long long ll;

const ll mod = 1e9+7;

const int inf = 1<<30;
const int maxn = 1000500;//2e5+5;

//template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
//    return out << "(" << a.x << ", " << a.y << ")";
//}
//
//template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
//    out << "[";
//    forn(i, sz(v)) {
//        if(i) out << ", ";
//        out << v[i];
//    }
//    return out << "]";
//}



int n;
int a[maxn];
ll d;
vector<int> ans;

char s[maxn];

int f[10];

int norm(int x){
    x %= n;
    if(x < 0) x += n;
    return x;
}


inline void err(){
    puts("NO"); exit(0);
}

bool dp[1000500], vs[1000500];
bool rec(int n){
    if(n < 0) return 0;
    if(n <= 3) return 1;
    bool &ret = dp[n];
    if(vs[n]) return ret;
    vs[n] = 1;
    if(!rec(n-1) || !rec(n-2) || !rec(n-3))
        ret = 1;
    else
        ret = 0;
    return ret;
}
char st[maxn];
void solve() {
    int a,b; scii(a,b);
    int c,d; scii(c,d);
    int t1 = (c+b-1)/b;
    int t2 = (a+d-1)/d;
    if(t1<=t2) puts("Yes");
    else puts("No");
}


int main(){
   // freopen("in.txt","r",stdin);
    int tc = 1;
    //sci(tc);
    lp(tt,tc){
  //      printf("Case #%d: ",tt+1);
        solve();
    }
}

Measured memory_bytes: 3708
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define REEP(i, N) for(ll i = N - 1; i >= 0; --i)
#define FOR(i,m,n) for(ll i = m; i < n; ++i)
#define RFOR(i,m,n) for(ll i = n - 1; i >= m; --i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define PB push_back
#define KIRIAGE(a, b) a += (b - a % b) % b // a を b の倍数値まで増やす
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;} // a / b 以上の最小整数
#define sp(n) setprecision(n)
#define INF 1000000000
#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
int dx8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	int N;
	cin>>N;
	vector<int> l(2 * N);
	REP(i, 2 * N) cin>>l[i];
	sort(ALL(l));
	ll sum = 0;
	for(int i = 2 * N - 2; i >= 0; i -= 2) sum += l[i];
	cout<<sum<<endl;
}


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

int main() {
	int N;
	int v[50];
	cin >> N;
	for (int i = 0; i < N; i++)cin >> v[i];

	//vを低い順（昇順）にソートして、値が低い方から合成をする
	sort(v, v + N);
	double value;
	for (int i = 1; i < N; i++) {
		if (i == 1)
			value = ((double)v[0] + (double)v[1]) / 2.0;
		else
			value = (value + (double)v[i]) / 2.0;
	}
	cout << setprecision(6) << value << endl;

	return 0;
}

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

int main() {
	int a1, a2, a3; cin >> a1 >> a2 >> a3;
	int ans = max({ a1, a2, a3 }) - min({ a1, a2, a3 });
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int mx = 0;
    int ans = 0;
    rep(i, n) if (mx <= a[i]) {
        mx = a[i];
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3620