akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int multiply= a*b;
    String result = "";
    if(multiply%2==0){
      result="Even";
    }else{
      result= "Odd";
    }
   System.out.println(result); 
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include <vector>
using namespace std;
int main(){
    vector<int> v[1005];
    int n,q;
    cin>>n>>q;
    int a,b,c;
    while(q--){
        cin>>a;
        if(a==0){
            cin>>b>>c;
            v[b].push_back(c);
        }
        else if(a==1){
            cin>>b;
            for(int i=0;i<v[b].size();i++){
                cout<<v[b][i];
                if(i!=v[b].size()-1) cout<<" ";
            }
            cout<<endl;
        }
        else{
            cin>>b;
            v[b].clear();
        }
    }
    return 0;
}


Measured memory_bytes: 5864
#include <cstdio>
using namespace std;

int n,p, c[51];

inline int next(int a) {
	return a == n - 1 ? 0 : a + 1;
}

int main(){
	int it;
	while (scanf("%d%d", &n, &p), n != 0) {
		for (int i = 0; i < 51; i++) {
			c[i] = 0;
		}
		it = 0;
		c[n] = p;
		while (true) {
			if (c[n] > 0) {
				c[it]++;
				c[n]--;
				if (c[it] == p) {
					printf("%d\n", it);
					break;
				}
			}
			else {
				c[n] += c[it];
				c[it] = 0;
			}
			it = next(it);
		}
	}
	
	return 0;
}

Measured memory_bytes: 2568
from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip().split()]
P = 0
for i in range(1, N + 1):
    if i > K:
        continue
    e = 0
    while i * 2 ** e < K:
        P += 1 / N * 0.5 ** (e + 1)
        e += 1
print(1 - P)


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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define ll long long
#define ld long double
#define sz(s) ((int)s.size())
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 2e5 + 10;
const int inf = 1e9 + 7;

int n, p, i;
string a, b;
ll ans = 1;

int main() {
    scanf("%d", &n);
    cin >> a >> b;
    if(a[0] == b[0]) i = 1, ans = 3, p = 1;
    else i = 2, ans = 6, p = 2;
    for(; i < sz(a); i++) {
        if(a[i] == b[i]) {
            if(p == 1) ans *= 2;
            else ans *= 1;
            p = 1;
        }
        else {
            if(p == 1) ans *= 2;
            else ans *= 3;
            i++;
            p = 2;
        }
    }
    cout << ans % inf << endl;;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 2e5 + 5;
int a[N], b[N];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef ONLINE_JUDGE
    // freopen("", "r", stdin);
    // freopen("", "w", stdout);
#endif
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	vector<int> v;
	for(int i = n; i >= 1; i--){
		int total = 0;
		for(int j = i + i; j <= n; j += i)
			total += b[j];
		if(total % 2 != a[i] % 2)
			v.push_back(i), b[i] = 1;
	}
	cout << v.size() << '\n';
	for(auto &x : v)
		cout << x << ' ';
	return 0;
}


Measured memory_bytes: 5220
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    int cnt = 0;
    for(int i = 0; i < N; i++) {
        int D1,D2;
        cin >> D1 >> D2;
        if(D1 == D2) {
            cnt++;
        }
        else {
            cnt = 0;
        }
        if(cnt == 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


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

int main(){
    while(1){
        int h,w;
        cin>>h>>w;
        if(h==0) break;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cout<<"#";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3092
package main

import "fmt"

func main() {
	var n, x, t, a int
	fmt.Scan(&n, &x, &t)
	if n%x == 0 {
		a = (n / x) * t
	} else {
		a = (n/x + 1) * t
	}
	fmt.Printf("%d", a)

}


Measured memory_bytes: 1832
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	line := nextLine()
	if len(line) < 4 {
		fmt.Println("No")
	} else if line[:4] == "YAKI" {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 640
sd = raw_input()
t = raw_input()
lnsd = len(sd)
lnt = len(t)
sa = 0
tru = None
for i in range(lnsd - lnt + 1):
    for i2 in range(lnt):
        a = sd[(0+sa):(lnt+sa)]
        if a[i2] != t[i2] and a[i2] != "?":
            break
        if i2 == lnt-1:
            tru= i
    sa = sa+1
if tru == None:
    print("UNRESTORABLE")
    exit()
sd = list(sd)
for i in range(lnt):
    sd[tru+i]=t[i]
strn ="".join(sd)
print(strn.replace("?", "a"))


Measured memory_bytes: 2692
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,m,a,dp[100005]={},b[100005]={};
  cin >> n >> m;
  for(int i=0; i<m; i++) {
    cin >> a;
    b[a]++;
  }
  dp[0]=1;
  for(int i=1; i<=n; i++) {
    if(!b[i]&&!b[i-1]) {
      dp[i]+=dp[i-1];
    }
    if(i!=1&&!b[i]&&!b[i-2]) {
      dp[i]+=dp[i-2];
    }
    dp[i]%=MOD;
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <map>
const int MOD = 1e9+7;
using namespace std;


int main(){
	int h, n, a, b;
	cin >> h >> n;
	vector<pair<int, int> > magic;

	for (int i = 0; i < n; i++){
		cin >> a >> b;
		magic.push_back(make_pair(a, b));
	}

	int mp[10000];
	for (int i = 0; i < h; i++) mp[i] = MOD;
	mp[h] = 0;

	for (int i = h; i >= 0; i--){
		for (int j = 0; j < n; j++){
			mp[max(0, i - magic[j].first)] = min(mp[max(0, i - magic[j].first)], mp[i] + magic[j].second);
		}
	}
	cout << mp[0] << endl;
	return 0;
}


Measured memory_bytes: 256
a,b,c = gets.split.map(&:to_f)
rad = Math::PI*(c/180)
h = b * Math.sin(rad)
x = Math.sqrt( a**2 + b**2 - 2*a*b*Math.cos(rad) )
L = a + b + x
puts a * h / 2
puts L
puts h


Measured memory_bytes: 6956
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 1000000007
#define INF ((1LL<<62LL) - 1)

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

    int n,k; cin >> n >> k;

    int ans = n%k;
    ans = min(ans, k - ans);
    cout << ans << "\n";



}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
int main() {
  int n;
  double t, a;
  cin >> n >> t >> a;
  double h[n];
  rep(i,n)
    cin >> h[i];
  a -= t;
  double tem = abs(a + h[0] * 0.006);
  int ans = 1;
  for (int i = 1; i < (int) (n); ++i) {
    if (tem > abs(a + h[i] * 0.006)) {
      tem = abs(a + h[i] * 0.006);
      ans = i + 1;
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = []
ans1 = a[0::2]
ans2 = a[1::2]
if n%2 == 0:
    ans2.reverse()
    b.extend(ans2)
    b.extend(ans1)
    print(*b)
else:
    ans1.reverse()
    b.extend(ans1)
    b.extend(ans2)
    print(*b)


Measured memory_bytes: 26356
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

s = [0]*4
N = i()
S = L()
for i in range(N):
    if S[i] == 'P':
        s[0] = 1
    if S[i] == 'W':
        s[1] = 1
    if S[i] == 'G':
        s[2] = 1
    if S[i] == 'Y':
        s[3] = 1
if sum(s) == 3:
    print('Three')
else:
    print('Four')

Measured memory_bytes: 10032
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define repc(i, s, t) for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

int N, M;
i64 cost[1005];
int mask[1005];
i64 memo[1005][1 << 13];

i64 dp(int i, int bit) {
    if (i >= M) {
        return (bit == (1 << N) - 1) ? 0 : INF;
    }

    auto &ret = memo[i][bit];
    if (~ret) return ret;

    ret = INF;
    chmin(ret, dp(i + 1, bit));
    chmin(ret, dp(i + 1, bit | mask[i]) + cost[i]);

    return ret;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    read(N, M);
    rep(i, 0, M) {
        int K;
        read(cost[i], K);

        rep(j, 0, K) {
            var(int, c);
            --c;
            mask[i] |= 1 << c;
        }
    }

    memset(memo, -1, sizeof(memo));
    const auto ans = dp(0, 0);
    print(ans >= INF ? -1 : ans);

    return 0;
}


Measured memory_bytes: 64640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mo = 1000000007;
ll mypow(ll a, ll b)
{
  ll res = 1;
  a %= mo;
  while (b)
  {
    if (b & 1)
      res = res * a % mo;
    a = a * a % mo;
    b >>= 1;
  }
  return res;
}
const ll MAX = 510000;
const ll MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (ll 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;
  }
}
long long COM(ll n, ll k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main()
{
/* 
ボール      箱	      入れ方に制限なし 箱の中身は1つ以下 箱の中身は1つ以上
区別できる   区別できる  1            2             3
区別できない  区別できる  4            5             6
区別できる   区別できない 7            8             9
区別できない  区別できない 10          11            12
*/
ll n , k ;
cin >> n >> k ;

cout << mypow(k,n) << endl;
return 0;
}


Measured memory_bytes: 3124
#include <stdio.h>
int main()
{
	int i,n,kane=100000;
	while(scanf("%d",&n)!=EOF){
	for(i=1;i<=n;i++){
	kane*=1.05;
	if(kane%1000)kane+=1000-(kane%1000);
		}
	printf("%d\n",kane);
	}
	return 0;
}

Measured memory_bytes: 588
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n; 
int main()
{
	cin >> n;
	bool en = 0;
	string s="",t="";
	while(1){
		char a[4]={'.','.','#','#'};
		char b[4]={'.','#','.','#'};
		if(!en){
			for(int i=0;i<4;i++){
				s.push_back(a[i]);
				t.push_back(b[i]);
				
				for(int i=0;i<s.size();i++) printf("%c",s[i]);
				puts("");
				for(int i=0;i<t.size();i++) printf("%c",t[i]);
				puts(""); fflush(stdout);
				
				char res[5]; scanf("%s",&res);
				if(res[0] == 'T') break;
				else if(res[0] == 'F'){
					if(i==3) en = 1;
					s.resize(s.size()-1); t.resize(t.size()-1);
				}
				else{
					return 0;
				}
			}
		}
		else{
			for(int i=0;i<4;i++){
				reverse(s.begin(),s.end());
				reverse(t.begin(),t.end());
				s.push_back(a[i]);
				t.push_back(b[i]);
				reverse(s.begin(),s.end());
				reverse(t.begin(),t.end());
				
				for(int i=0;i<s.size();i++) printf("%c",s[i]);
				puts("");
				for(int i=0;i<t.size();i++) printf("%c",t[i]);
				puts(""); fflush(stdout);
				
				char res[5]; scanf("%s",&res);
				if(res[0] == 'T') break;
				else if(res[0] == 'F'){
					if(i==3) assert(0);
					reverse(s.begin(),s.end());
					reverse(t.begin(),t.end());
					s.resize(s.size()-1); t.resize(t.size()-1);
					reverse(s.begin(),s.end());
					reverse(t.begin(),t.end());
				}
				else{
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
long long ans,len;
int c[30];
string s;
int main(){
	cin>>s;
	len=s.length();
	ans=len*(len-1)/2;
	for(int i=0;i<len;i++) c[s[i]-'a']++;
	for(int i=0;i<26;i++) ans-=1ll*c[i]*(c[i]-1)/2;
	ans++;
	printf("%lld",ans);
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){
	int max[3] = {0};
	int i,j;
	int tmp;
	for(i = 0 ; i < 10 ; i++){
		scanf("%d", &tmp);

		if(max[0] <= tmp){
			/* 一番高い時 */
			max[2] = max[1];
			max[1] = max[0];
			max[0] = tmp;
		} else if (max[1] <= tmp){
			/* 二番高い時 */
			max[2] = max[1];
			max[1] = tmp;
		} else if (max[2] <= tmp){
			/* 三番高い時 */
			max[2] = tmp;
		}
	}

	for(i = 0 ; i < 3 ; i++){
		printf("%d\n", max[i]);
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

vector<vector<int>> m;

void dfs(int x, int y, int h, int w)
{
    m[y][x] = 0;

    for (int i = max(0, y - 1); i <= min(h - 1, y + 1); ++i)
    {
        for (int j = max(0, x - 1); j <= min(w - 1, x + 1); ++j)
        {
            if (m[i][j])
            {
                // cout << y << " " << x << "->" << i << " " << j << endl;
                dfs(j, i, h, w);
            }
        }
    }
}

int main()
{
    int w = 1, h = 1;
    while (true)
    {
        cin >> w >> h;
        if (w == 0 && h == 0)
        {
            break;
        }
        m = vector<vector<int>>(h, vector<int>(w));
        rep(i, h) rep(j, w) cin >> m[i][j];

        int ans = 0;
        rep(i, h) rep(j, w)
        {
            if (m[i][j])
            {
                ans++;
                dfs(j, i, h, w);
            }
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3360
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar(n) array<int,n>
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin>>n>>m;
	int ans =0,m2=1;
	int a[n+1];
	fill(a+1,a+n+1,1);
	bool b[n+1]={false};
	b[1] = 1;
	for(int i =0; i<m; i++)
	{
		int x,y;
		cin>>x>>y;
		if(b[x])
			b[y]=1;
		a[x]--;
		a[y]++;
		if(!a[x])
			b[x]=0;
	}
	for(int i =1;i<=n;i++)
		if(b[i]) ans++;	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 768
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ii> vii;
typedef map<int,int> mii;
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 7;


int main(){
	int n; cin>>n;
	cout<<fixed<<setprecision(6)<<(double)(n/2+n%2)/n;
}

Measured memory_bytes: 256
#include<stdio.h>

int equal(const char str1[], const char str2[]){ // epual => equal クラッシュ要因。
	int i;
	for(i = 0;str1[i] == str2[i];i++)
		if(str1[i] == '\0') 
            return 1; // 下と逆。WA要因。
		return 0; // 上と逆。WA要因。
}

int main(void){
	int i,j;
	int N,M;
	int cnt = 0;
	
	
	char blue[100][11]; // ナル文字があるので11取らないといけない。クラッシュ要因。
	char red[100][11]; // ナル文字があるので11取らないといけない。クラッシュ要因。
	
	scanf("%d", &N); // scanfにはポインタ渡せ。クラッシュ要因。
	
	for(i = 0;i < N;i++){
		scanf("%s", blue[i]); // %sは小文字。クラッシュ要因。
	}
	
	scanf("%d", &M); // scanfにはポインタを渡せ。クラッシュ要因。
	
	for(i = 0;i < M;i++){
		scanf("%s", red[i]); // %sは小文字。クラッシュ要因。
	}
	
	for(i = 0;i < N;i++){
		int index = 0;
		for(j = i;j < N;j++){ // 全列挙する必要はない。
			if(equal(blue[i] , blue[j])) // インデックスにへんなもん足すな。　クラッシュ要因。
				index++;
		}
		
		for(j = 0;j < M;j++){ // 赤カードの枚数はMですよ。 WA要因。
			if(equal(blue[i] , red[j])) // インデックスにへんなもん足すな。　クラッシュ要因。
				index--;
		}
		
		if(cnt < index)
			cnt = index;
	}
	
	printf("%d", cnt);
	
	return 0;

}


Measured memory_bytes: 128
N = int(input())
A = [-1] + [int(input()) for _ in range(N)]
USED = [False] * (N+1)

cnt = 0
prev = 1
while True:
  nxt = A[prev]
  cnt += 1
  
  if nxt == 2:
    break
    
  USED[prev] = True
  if USED[nxt]:
    cnt = -1
    break
    
  prev = nxt
    
print(cnt)


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

int main(){
    int N;
    scanf("%d", &N);
    
    int A[N+1];
    
    for(int i = 1; i <= N; i++)
        scanf("%d", &A[i]);

    long long cnt = 0;
    
    for(int i = 1; i < N; i++)
    {
        if(A[i] == i)
        {
            A[i] = A[i+1];
            A[i+1] = i;
            cnt++;
        }
    }
    
    if(A[N] == N)
        cnt++;
    
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll


int t, n, m, k, a[300010], q, l, r;



int32_t main(){
INIT
cin>>n;



string res="";
for(int i=26; n>0; i*=26){
    char c= ( (n%i==0)?(i):(n%i) )/(i/26); c+='a';  c--; res=c+res; n-=( (n%i==0)?(i):(n%i) );
}
cout<<res;



return 0;
}




Measured memory_bytes: 3680
#include <iostream>
#include <set>
#include <map>
#include <algorithm>

#define N 20000

using namespace std;

typedef pair<int, int> P;
typedef set<P> S;

S bases[N];

void init_bases() {
    for (int n=0; n*n<N; ++n) {
        for (int m=n; true; ++m) {
            int b = n*n+m*m;
            if (b >= N) {
                break;
            }
            if (b > 1) {
                bases[b].insert(P(n, m));
                bases[b].insert(P(m, n));
            }
        }
    }
}

bool is_prime(int p, int q) {
    int b0 = p*p+q*q;
    for (int b1=2; b1<N; ++b1) {
        int b2 = b0/b1;
        if (b0%b1 > 0) {
            continue;
        }
        for (S::iterator iter=bases[b2].begin(); iter!=bases[b2].end(); ++iter) {
            int m = iter->first;
            int n = iter->second;
            if ((m*p+n*q)%b2 == 0 && (m*q-n*p)%b2 == 0) {
                return false;
            }
        }
    }
    return true;
}

int main() {
    int n, p, q;
    init_bases();
    cin >> n;
    for (int i=0; i<n; ++i) {
        cin >> p >> q;
        if (is_prime(p, q)) {
            cout << "P" << endl;
        } else {
            cout << "C" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2860
#include <stdio.h>

int main(void){
  int i , j , key , s_length , t_length ;
  int ans = 0;


  scanf("%d",&s_length);
  int S[s_length];
  for(i = 0 ; i < s_length ; i++){
    scanf("%d ",&S[i]);
  }

  scanf("%d" , &t_length);
  int T[t_length];
  for(i = 0 ; i < t_length ; i++){
    scanf("%d" , &T[i]);
  }

  for(i = 0 ; i < t_length ; i++){
    key = T[i];
    for(j = 0 ; j < s_length ; j++){
      if(key == S[j]){
        ans++;
        break;
      }
    }
  }


  printf("%d\n",ans);
  
  return 0;
}



Measured memory_bytes: 2144
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main() {

	int a[3];
	int i;
	for (i = 0; i < 3; i++) {
		cin >> a[i];
	}

	sort(a, a + 3);
	int ans;
	ans = 10 * a[2] + a[1] + a[0];

	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main (void){
	
	int array[100],i,a,n;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		array[i] = a;
	}
	
	for(i=n-1;i>=0;i--){
		printf("%d",array[i]);
		if(i != 0) printf(" ");
	}
	printf("\n");
return 0;
}

Measured memory_bytes: 600
n = int(input())
al = list(map(int, input().split()))
boxs = []
cnts = [0]*(n+1)


for i in range(n,0,-1):
    if cnts[i]%2 != al[i-1]:
        boxs.append(i)
        for j in range(1, int(i**0.5)+1):
            if i%j == 0:
                cnts[j] += 1
                if j*j != i: cnts[i//j] += 1


print(len(boxs))
for b in boxs: print(b)

Measured memory_bytes: 91204
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>

int main()
{
	int n;

	std::cin >> n;

	std::vector<int> v(n);
	
	for (size_t i = 0; i < n; i++)
	{
		std::cin >> v[i];
		v[i]--;
	}

	int next = 0;
	int next0;
	int count = 0;

	while (true) {
		if (next == 1) {
			break;
		}
		if (v[next] == 0) {
			std::cout << -1 << std::endl;
			return 0;
		}
		next0 = next;
		next = v[next];
		v[next0] = 0;
		count++;
	}

	std::cout << count << std::endl;

	return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <climits>
#include <iomanip>
#include <sstream>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

template <typename T>
T gcd(T a, T b) {
	while (b != 0) {
		T temp = a;
		a = b;
		b = temp % b;
	}

	return a;
}


// cout << setfill('0') << setw(5) << number < endl;
// while(getline(cin, s)) { .. } | `s` is a string

void solve() {
	int n, w;
	cin >> n >> w;
	vector<vector<ll>> dp(n+1, vector<ll>(w+1, 0));
	vector<pair<int, int>> x(n);
	for (int i = 0; i < n; ++i) {
		cin >> x[i].first >> x[i].second;
	}

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

	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= w; ++j) {
			dp[i][j] = dp[i-1][j];
			if (x[i-1].first <= j) {
				dp[i][j] = max(dp[i][j], x[i-1].second + dp[i-1][j-x[i-1].first]);
			}
		}
	}

	cout << dp[n][w] << endl;
}


int main(){
	IOS;
	
	
	
	int t = 1;
	// cin >> t;
	while(t--)
		solve();

	return 0;
}



























 

Measured memory_bytes: 80256
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        try (CustomReader in = new CustomReader()) {
            new Main().execute(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void execute(CustomReader in) throws IOException {
        int[] abc = in.readLineAsIntArray();
        if(abc[0] == abc[1] && abc[1] == abc[2]){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }

    static class CustomReader extends BufferedReader {

        private static final int DEFAULT_BUF_SIZE = 2048;
        // private static final int DEFAULT_BUF_SIZE = 4096;
        // private static final int DEFAULT_BUF_SIZE = 8192;
        //private static final int DEFAULT_BUF_SIZE = 16384;
        // private static final int DEFAULT_BUF_SIZE = 1048576;

        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in), DEFAULT_BUF_SIZE);
        }

        public int readLineAsInt() throws IOException {
            return Integer.parseInt(readLine());
        }

        public int[] readLineAsIntArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            int[] intArray = new int[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                intArray[i] = Integer.parseInt(strArray[i]);
            }
            return intArray;
        }

        public int[][] readLinesAsIntMatrix(int rows, int columns) throws IOException {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                String[] r = this.readLine().split(" ");
                for (int j = 0; j < columns; j++) {
                    matrix[i][j] = Integer.parseInt(r[j]);
                }
            }
            return matrix;
        }
    }
}

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

int main ()
{
	int m[13]={0,4,7,1,4,6,2,4,7,3,5,1,3};
	string a[7]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	int M,D;
	while(cin>>M>>D&&M&&D)
	{
		int x=m[M]-2;
		cout<<a[(x+D)%7]<<endl;
		
	}
	
	
	
	
}

Measured memory_bytes: 1196
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
const int N=1e5+5;
typedef long long ll;
int main(){
	
		ll a,b,n;
		while(cin>>a>>b>>n){
		 ll x=min(n,b-1);
		 printf("%lld\n",(a*x)/b-a*(x/b));	
	}
		return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin >> N;
    cin >> K;
    string S;
    int count[27] = {};
    rep(i ,N) {
        cin >> S;
        count[S[0] - 'A']++;
    }
    int ans = 0;
    int flag = 0;
    while(true) {
        sort(count, count+27, greater<int>());
        rep(i,K) {
            if (count[i] > 0) count[i]--;
            else {
                flag = 1;
                break;
            }
        }
        if (flag == 1) break;
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    int max = -1;
    int ans = 0;
    
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        if(a >= max){
            ans++;
            max = a;
        }
    }
    
    
    cout << ans << endl;
}



Measured memory_bytes: 256
a, b = list(map(int, input().split()))

if a > 0:
    ans = 'Positive'
elif a <= 0 and b >= 0:
    ans = 'Zero'
else:
    neg = b - a + 1
    if neg % 2 == 0:
        ans = 'Positive'
    else:
        ans = 'Negative'

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int r=0,b=0,len=s.size();
	for(int i=0;i<len;i++){
		if(s[i]=='0') r++;
		else b++;
	}
	cout<<min(r,b)*2;
	return 0;
}



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

int main() {
	char c;
	string s = "consonant";
	cin >> c;
	if (c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u') {
		s = "vowel";
	}
	cout << s << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
  	Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long ans = 0;
    for(int i = 1; i <= n; i++){
     	if(i % 3 != 0 && i % 5 != 0) ans += i; 
    }
    System.out.println(ans);
  }
}

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

using namespace std;

int a[1000000];

bool cmp(int x,int y){
	return x>y;
}

int main(){
	int n,sum=0,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	sort(a+1,a+n+1,cmp);
	for(int i=2;i<=n;i+=2)
	{
		ans+=a[i];
	}
	cout<<sum-2*ans;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn lower_bound<F>(l: isize, r: isize, criterion: &F) -> isize
where
    F: Fn(isize) -> bool,
{
    let mut l = l;
    let mut r = r;
    while r - l > 1 {
        let mid = l + (r - l) / 2;
        if criterion(mid) {
            r = mid;
        } else {
            l = mid;
        }
    }
    l
}

fn solve() {
    let (n,a,b) = get!(isize, isize, isize);
    let h = get!(isize; n);

    let mx = (h.iter().sum::<isize>()+b-1)/b;

    let crit = |x: isize| {
        let mut res = x;
        for i in 0..n {
            let crit = |y: isize| {
                let val = h[i as usize]-y*a-(x-y)*b;
                val <= 0
            };
            let y = lower_bound(-1, res, &crit)+1;
            if !crit(y) {
                return false;
            }
            res -= y;
        }
        res > -1
    };
    let x = lower_bound(0, mx+1, &crit)+1;
    println!("{}",x);
}


Measured memory_bytes: 8572
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {

        void solve(InputReader in, PrintWriter out) {
            long H = in.nextLong();
            long X = 1;
            
            while (X*2 <= H) {
                X *= 2;
            }
            out.println(2*X - 1);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        long[] nextLongArray(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}
    

Measured memory_bytes: 21588
#include<bits/stdc++.h>
#define ll long long
#define pii pair<ll,ll>
#define piii pair<ll,pii>
#define pb push_back
#define vl vector<ll>
#define vs vector<string>
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define vi vector<ll>
#define vii vector<pii>
#define F first
#define S second
using namespace std;
const ll N=2e5+5;
ll n,d,a,ans;
pii p[N];
vii v;
vi sum;
ll binary_search(ll x)
{
	if(v.empty())return 0ll;
	ll l=0,r=v.size()-1;
	while(l<=r)
	{
		ll mid=(l+r)/2;
		if(v[mid].F+d>=x)//坐标可以达到的最小值 
			r=mid-1;
		else
			l=mid+1;
	}
	if(r<0)return sum[sum.size()-1];
	else return sum[sum.size()-1]-sum[r];
}
signed main()
{
	cin>>n>>d>>a;
	rep(i,n)
	{
		cin>>p[i].F>>p[i].S;
	}
	sort(p,p+n);
	for(ll i=0;i<n;i++)
	{
		p[i].S-=binary_search(p[i].F);
		if(p[i].S<0)continue;
		pii P=mp(p[i].F+d,p[i].S/a+(p[i].S%a!=0));
		v.pb(P);
		ans+=P.S;
		if(!sum.empty())sum.pb(sum[sum.size()-1]+P.S*a);
		else sum.pb(P.S*a);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10224
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
typedef long long tolong;
const tolong mo = 1000000007;

tolong modd(tolong i,tolong N){
  tolong ans = 1;
	for(tolong j = 0;j < N;j++){
    	ans = ans*i%mo;
    }
  	return ans;
}

int main(){
    tolong N;
  	tolong Ans;
    cin >> N;
  	Ans = modd(10,N) + modd(8,N) - modd(9,N) - modd(9,N);
  	Ans = Ans % mo;
  	Ans = (Ans + mo) % mo;
   	cout << Ans << endl;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>

using namespace std;

int main() {
int a,b,c,d;
cin >> a >> b >> c >> d;
if(a*b>=c*d){
  cout << a*b << endl;
  }
  else{
    cout << c*d << endl;
  }

  return 0;
}


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;
using P = pair<ll,ll>;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}


int main() {
  int n=100100;
  int x;
  cin >> x;
  vector<int> a(n);
  if(x==2) {
    pt(2);
    return 0;
  }
  while(1) {
      for(int i=2; i<x; i++) {
          if(x%i==0) break;
          if(i==x-1) {
              pt(x);
              return 0;
          }
      }
      x++;
  }
  return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define BITBOOL(x,a) (((x)>>(a))&1)
int main(){
  ll A, B, K;
  cin >> A >> B >> K;
  if(K<A) A -= K;
  else{ B -= (K-A); A=0; }
  if(B<0) B=0;
  cout << A << " " << B;
}

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

int main(){
	int N, a, two_num = 0, four_num = 0, i;
	scanf("%d", &N);
	for(i = 0; i < N; i++){
		scanf("%d", &a);
		if(a % 4 == 0){
			four_num++;
		}
		else if(a % 2 == 0){
			two_num++;
		}
	}
	if(2 * four_num + two_num >= N || 2 * four_num + 1 == N){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
int main() {
  lli A,B,C=INF,D=0,E=0,F=0,G=0,H=0,N,M;
  cin >> N >> M;
  vector<int>P(N),Q(N),X(M),Y(M);
  rep(i,0,N)cin >> P[i] >> Q[i];
  rep(i,0,M)cin >> X[i] >> Y[i];
  rep(i,0,N){
    F=INF;
    rep(j,0,M){
      A=abs(P[i]-X[j])+abs(Q[i]-Y[j]);
      if(A<F){
        F=A;
        B=j+1;
      }
      if(j==M-1)Out(B);
    }
  }
}

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

 
int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

    string s;
    cin >> s;
    ll l = s.size(), ans = 0, b = 0;
    for(int i = 0; i < l; i++){
        if(s[i] == 'B') b++;
        else ans += b;
    }
    cout << ans;
 
 
    return 0;
}

Measured memory_bytes: 3716
import java.util.*;


public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        int beforeSize = a.length();
        int zero = 0;
        int one = 0;
        for (char c : a.toCharArray()) {
            if (c == '0') {
                zero++;
            } else {
                one++;
            }
        }
        int sub = zero - one;
        if (sub < 0) {
            sub = sub * -1;
        }
        System.out.println(beforeSize - sub);
    }
}


Measured memory_bytes: 28116
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

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

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 305;
const int p[7] = {2, 3, 5, 7, 11, 13, 17};
const int lim[7] = {9, 6, 4, 3, 3, 3, 3};

int n, ans, cur[7], w[MAXN], val[MAXN], a[MAXN][8];

inline void Solve()
{
	int now = 0;
	for (int i = 1; i <= 300; i ++)
		w[i] = 0;
	for (int i = 1; i <= n; i ++)
	{
		bool flg = true;
		for (int j = 0; j < 7 && flg; j ++)
			flg &= cur[j] >= a[i][j];
		if (flg)
		{
			if (a[i][7] ^ 1)
				w[a[i][7]] += val[i];
			else
				now += val[i];
		}
	}
	for (int i = 1; i <= 300; i ++)
		now += max(w[i], 0);
	ans = max(ans, now);
}

inline void DFS(int x)
{
	if (x == 7)
		Solve();
	else
		for (cur[x] = 0; cur[x] < lim[x]; cur[x] ++)
			DFS(x + 1);
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read();
	for (int i = 1; i <= n; i ++)
	{
		a[i][7] = Read(), val[i] = Read();
		for (int j = 0; j < 7; j ++)
			while (a[i][7] % p[j] == 0)
				a[i][7] /= p[j], a[i][j] ++;
	}
	DFS(0);
	return printf("%d\n", ans), 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

int main()
{
  int N; cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a[i];

  sort(ALL(a));

  int ans = 1<<30;
  for (int i = a.front(); i <= a.back(); ++i) {

    int sum = 0;
    for (int j = 0; j < N; ++j) {
      sum += (a[j]-i)*(a[j]-i);
    }
    ans = min(ans, sum);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}



struct UnionFind
{
  vector<int> uni;
  UnionFind(int n): uni(n+5, -1) {}
  int  root(int x)        { return (uni[x] < 0)? x : uni[x] = root(uni[x]); }
  bool same(int x, int y) { return root(x) == root(y); }
  bool unite(int x, int y){
    if ( (x=root(x)) == (y=root(y)) )return false;
    if ( uni[y] < uni[x] ) swap(x,y);
    uni[x] += uni[y],  uni[y] = x;
    return true;
  }
  int size(int i)     { return (-uni[root(i)]); }
};

inline void solve(){
  
  int n, m;
  int a[100005],b[100005];
  cin >>n >> m;
  FOR(i,m){
    cin >> a[i] >> b[i];
  }
  int Max = n*(n-1)/2;
  int ans[100005]={};
  ans[m]=Max;
  UnionFind uf(n);
  for(int i = m-1;i>=0;i--){
    int x=a[i],y=b[i];
    if(!uf.same(x,y)){      
      ans[i]=ans[i+1]-uf.size(x)*uf.size(y);
    }else{
      ans[i]=ans[i+1] ;
    }
    uf.unite(x,y);
  }
  iFOR(i,1,m+1){
    cout << ans[i] fin;
  }
  
}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}



Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

const int mod = 1000000007;
struct mint {
ll x; // typedef long long ll;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
}
mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
}
mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
mint operator+(const mint a) const { return mint(*this) += a;}
mint operator-(const mint a) const { return mint(*this) -= a;}
mint operator*(const mint a) const { return mint(*this) *= a;}
mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
}
// for prime mod
mint inv() const { return pow(mod-2);}
mint& operator/=(const mint a) { return *this *= a.inv();}
mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint choose(int n, int r){
    // if (n < r) return mint(0);
    mint x = 1, y = 1;
    for(int i = 0; i < r; i++){
        x *= n-i;
        y *= i+1;
    }
    return x / y;
}

int main(){
    int n, k;
    cin >> n >> k;
    mint ans = 0;
    for(int i = 1; i <= k; i++){
        ans = choose(k-1, i-1) * choose(n-k+1, i);
        printf("%lld\n", ans.x);
    }
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#define ll long long
#define INF 1e+18
#define MOD 998244353
using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    
    cout << (a-1)*(b-1)<<endl;
    return 0;
}


Measured memory_bytes: 256