akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let mut A: Vec<usize> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };
    let mut B: Vec<usize> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let mut C = (0..N).map(|i| (A[i], i)).collect::<Vec<_>>();
    let mut D = (0..N).map(|i| (B[i], i)).collect::<Vec<_>>();
    C.sort();
    D.sort();
    let mut res = true;
    let mut w = false;
    // println!("{:?}", C);
    // println!("{:?}", D);
    for k in 0..(N - 1) {
        let (c, i) = C[k];
        let (d, j) = D[k];
        if c > d { res = false; }
        else if C[k + 1].0 <= d { w = true; }
    }
    if C[N - 1].0 > D[N - 1].0 { res = false; }

    for k in 0..N {
        let (c, i) = C[k];
        let (d, j) = D[k];
        A[i] = k;
        B[j] = k;
    }

    let mut p = vec![0; N];
    for k in 0..N {
        let (d, j) = D[A[k]];
        p[k] = j;
    }
    let mut used = vec![false; N];
    let mut i = 0;
    while !used[i] {
        used[i] = true;
        i = p[i];
    }
    // println!("{}", res);
    if !w && (0..N).all(|j| used[j]) { res = false; }
    // println!("{:?}", p);
    // println!("{:?}", used);

    let ans = if res { "Yes" } else { "No" };
    println!("{}", ans);
}


Measured memory_bytes: 13560
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const string space=" ";
int main(){
	while(1){
		string g;
		int y,m,d;
		cin>>g;
		if(g=="#")break;
		cin>>y>>m>>d;
		if(y>31||y==31&&m>4){
			g="?";
			y-=30;
		}
		cout<<g<<space<<y<<space<<m<<space<<d<<endl;
	}
	return 0;
}


Measured memory_bytes: 3176
import fractions
import math
import sys
def input(): return sys.stdin.readline().strip()


def resolve():
    a, b = map(int, input().split())
    m = fractions.gcd(a, b)

    # cf. https://qiita.com/suecharo/items/14137fb74c26e2388f1f

    def make_prime_list_2(num):
        if num < 2:
            return []

        # 0のものは素数じゃないとする
        prime_list = [i for i in range(num + 1)]
        prime_list[1] = 0  # 1は素数ではない
        num_sqrt = math.sqrt(num)

        for prime in prime_list:
            if prime == 0:
                continue
            if prime > num_sqrt:
                break

            for non_prime in range(2 * prime, num, prime):
                prime_list[non_prime] = 0

        return [prime for prime in prime_list if prime != 0]

    def prime_factorization_2(num):
        """numの素因数分解
        素因数をkeyに乗数をvalueに格納した辞書型dict_counterを返す"""

        if num <= 1:
            # 例えば1を食ったときの対処の仕方は問題によって違うと思うのでそのつど考える。
            # cf. https://atcoder.jp/contests/abc110/submissions/12688244
            return False
        else:
            num_sqrt = math.floor(math.sqrt(num))
            prime_list = make_prime_list_2(num_sqrt)
            dict_counter={}
            # 何度もこの関数を呼び出して辞書を更新したい時はこれを引数にして
            # cf. https://atcoder.jp/contests/arc034/submissions/12251452

            for prime in prime_list:
                while num % prime == 0:
                    if prime in dict_counter:
                        dict_counter[prime] += 1
                    else:
                        dict_counter[prime] = 1
                    num //= prime
            if num != 1:
                if num in dict_counter:
                    dict_counter[num] += 1
                else:
                    dict_counter[num] = 1

            return dict_counter
    if m==1:
        print(1)
    else:
        d=prime_factorization_2(m)
        print(len(d)+1)


resolve()


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

#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()


int main(){
    ll a;
    double b;
    cin>>a>>b;
    ll ib=b*100+0.5;
    a*=ib;
    a/=100;
    printf("%lld\n",a);
    return 0;
}


Measured memory_bytes: 3784
import math

L = 10 ** 18

N = int(input())
A = [N]
A = list(map(int, input().split()))
ans = 1
for i in A:
    if i == 0:
        ans = 0
        break
    elif ans == -1:
        continue
    elif ans * i > L:
        ans = -1
    else:
        ans *= i

print(ans)

Measured memory_bytes: 21696
def prepare(m, mod=10 ** 9 + 7):
	fac = [1] * (m + 1)
	inv = [1] * (m + 1)
	for i in range(1, m + 1):
		fac[i] = fac[i - 1] * i % mod
	inv[-1] = pow(fac[-1], mod - 2, mod)
	for i in range(m - 1, -1, -1):
		inv[i] = inv[i + 1] * (i + 1) % mod
	return fac, inv

n,k,*a=map(int,open(0).read().split())
mod=10**9+7
a.sort()
fac,inv=prepare(n)

def cmb(n, r):
	assert n >= r >= 0
	return fac[n] * inv[n - r] * inv[r] % mod

m=M=0
for i,x in enumerate(a):
	if not n-i+1<=k:
		m+=cmb(n-i-1,k-1)*x
		m%=mod
	if not i+2<=k:
		M+=cmb(i,k-1)*x
		M%=mod
print((M-m)%mod)


Measured memory_bytes: 15212
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define rlp(i,n) for(int i = int(n);i >= 0;i--)
#define range1(i,a,b,c) for(int i = int(a);i <= int(b);i+=int(c))
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define sz(v) ((int)((v).size()))
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
void _run(){
    int n,k;
    scanf("%d %d",&n,&k);
    vi v;
    vector<ll> pref;
    v.resize(n);
    pref.resize(n+1);
    lp(i,n){
        scanf("%d",&v[i]);
    }
    range(i,1,n){
        pref[i]=pref[i-1]+(ll)v[i-1];
    }
    ordered_set<pair<ll,ll>>tree;
    tree.insert({0,0});
    ll ans =0;
    range(i,1,n){
        ans+=tree.order_of_key({pref[i]-(ll)k*(ll)i,(ll)i});
        tree.insert({pref[i]-(ll)k*(ll)i,(ll)i});
    }
    printf("%lld",ans);
}
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int t=1;
    // scanf("%d",&t);
    while(t--)_run();
    
    return 0;
}

Measured memory_bytes: 18036
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    string s1,s2,s3;
    cin>>s1;
    cin>>s2;
    cin>>s3;
    cout<<s1[0]<<s2[1]<<s3[2]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
template<class T> void chmax(T &a,T b){if(a<b) a = b ; }
template<class T> void chmin(T &a,T b){if(a>b) a = b ; }

void solve(){
	ll n ; cin >> n ;
	vll ans(n*n,-1) ;
	ll pos = 0 ;
	vector<pll> a(n) ;
	for(int i=0;i<n;i++){
		cin >> a.at(i).first ;
		a.at(i).second = i+1 ;
		ans.at(a.at(i).first-1) = i+1 ;
	}
	sort(all(a)) ;
	for(int i=0;i<n;i++){
		for(int j=0;j<a.at(i).second-1;j++){
			while(ans.at(pos)!=-1) pos++ ;
			ans.at(pos) = a.at(i).second ;
		}
	}
	reverse(all(a)) ;
	pos = n*n-1 ;
	for(int i=0;i<n;i++){
		for(int j=0;j<n-a.at(i).second;j++){
			while(ans.at(pos)!=-1) pos-- ;
			ans.at(pos) = a.at(i).second ;
		}
	}
	for(int i=0;i<n;i++){
		ll sub = a.at(i).second ;
		pos = -1 ;
		while(sub--){
			pos++ ;
			while(ans.at(pos)!=a.at(i).second) pos++ ;
		}
		if(pos+1!=a.at(i).first){
			cout << "No\n" ;
			return ;
		}
	}
	cout << "Yes\n" ;
	for(int i=0;i<n*n;i++) cout << ans.at(i) << (i==n*n-1?'\n':' ') ;
}

int main(){
	solve() ;
}

Measured memory_bytes: 3072
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)


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

const ll MOD = INF + 7;



int main(){
    ll n;
    cin >> n;
    map<ll, ll> mp;
    ll m = n;
    for(ll i = 2; i * i <= m; i++){
        while(m % i == 0){
            mp[i]++;
            m /= i;
        }
    }
    if(m != 1)mp[m]++;

    ll res = 0;
    for(auto m : mp){
        ll ms = m.second;
        ll j = 1;
        while(ms - j >= 0){
            ms -= j;
            j++;
            res++;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3196
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <queue>
#include <deque>
#include <cmath>
#include <iomanip>
#include <cstdio>

using namespace std;

int main(){
    string s; cin >> s;
    int ans=1000;
    for(int i=0; i<s.size()-2; ++i){
        int n=(s[i]-'0')*100 + (s[i+1]-'0')*10 + (s[i+2]-'0');
        ans=min(ans, abs(n-753));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//dont try to understand my code i really dont understand it 
#include<iostream>
#include<fstream>
#include<cmath>
#include<string>
#include<set>
#include <map>
#include<vector>
#include <queue>
#include <stack>
#include<algorithm>
using namespace std;
typedef long long ll;
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)
#define pb push_back
#define mp make_pair
#define mt make_tuple
typedef pair<int, int> ii;
const double PI = acos(-1.0);
const ll INF = 1000000000000030200;
//const ll F = LLONG_MIN;	
const int A = 1234567;
typedef long long ll;
// write what you need here : ... 


set<ll>arr; 
set<ll>::iterator it , it2;
set<ll>need;


ll gcd(ll f, ll s)
{
	ll temp;
	while (s != 0)
	{
		temp = f % s; 
		f = s;
		s = temp;
	}
	return f;
}
int main()
{
	ll a, b; 
	cin >> a >> b;
	bool can = false;
	for (int i = 0;i < a;i++)
	{
		ll temp; 
		cin >> temp;
		if (temp == b)
		{
			cout << "POSSIBLE";
			return 0;
		}
		if (temp >= b)
			can = true;
		arr.insert(temp);
	}
	if (!can)
	{
		cout << "IMPOSSIBLE";
		return 0;
	}

	
	for (it = arr.begin(); it != arr.end();it++)
	{

		ll g = gcd(*it, b);
		if (need.find(g) != need.end())
			continue;
		for (it2 = it; it2 != arr.end();it2++) {
			ll g1 = gcd(*it, *it2);
			if (g1 == g)
			{
				cout << "POSSIBLE";
				return 0;
			}
			else
				need.insert(g);
		}
		
	}

	
				

	cout << "IMPOSSIBLE";
	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#include <ctime>
using namespace std;
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define max(a,b) (a<b?b:a)
#define min(a,b) (a>b?b:a)
#define abs(x) (x<0?(-x):x) // big bug here if "-x" is not surrounded by "()"
#define IN(i,l,r) (l<i&&i<r) //the next for are for checking bound
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define rep(i,n) for (i = 0; i < n; ++i) 
#define REP(i,k,n) for (i = k; i <= n; ++i) 
#define REPR(i,k,n) for (i = k; i >= n; --i)
#define getI(a) scanf("%d", &a) //next three are handy ways to get ints, it's also force you to use '&' sign
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define wez(n) int (n); scanf("%d",&(n)) //handy if the input is right after the definition of a variable
#define wez2(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define wez3(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define TESTS wez(testow)while(testow--) //for multilple cases problems
#define whileZ int T; getI(T); while(T--) // the same as above
#define getS(x) scanf("%s", x) //get a char* string
#define clr(a,x) memset(a,x,sizeof(a)) //set elements of array to some value
#define char2Int(c) (c-'0')
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define REMAX(a,b) (a)=max((a),(b)) // set a to the maximum of a and b
#define REMIN(a,b) (a)=min((a),(b));
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) // traverse an STL data structure
#define ALL(c) (c).begin(),(c).end() //handy for function like "sort()"
#define PRESENT(c,x) ((c).find(x) != (c).end()) 
#define CPRESENT(c,x) (find(ALL(c),x) != (c).end()) 
#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);//to synchronize the input of cin and scanf
#define INF 1001001001
#define PI 3.1415926535897932384626
//for map, pair
#define mp make_pair
#define fi first
#define se second
// for debug
inline void pisz(int n) { printf("%d\n",n); }
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a,L,R) FE(i,L,R) cout << a[i] << (i==R?'\n':' ')
#define printV(a) printA(a,0,a.size()-1)
#define MAXN 10000
//for vectors
#define pb push_back
typedef int elem_t;
typedef vector<long long> vll;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
// directions
const int fx[4][2] = {{0,1}, {-1,0}, {0,-1}, {1,0}};
const int fxx[9][2] = {{0,0},{0,1}, {0,-1}, {1,0}, {-1,0}, {1,1}, {1,-1}, {-1,1}, {-1,-1}};
const int N = 500;
const ll mod = 1000000007;



int main() 
{IOS

    string n;
    cin>>n;
    ll ans = 0;
    for(ll i=0;i<n.size();i++)
    {
        ans = (ans+n[i]-'0')%9;
    }
    if(!ans)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    
    


}


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

int main()
{
    int n;
    string s;
    cin >> n >> s;

    int count = 0;
    for (int i = 0; i < n - 2; ++i)
    {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
        {
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}

/*
 <url:https://agc008.contest.atcoder.jp/tasks/agc008_c>
 問題文============================================================
 正方形のマスを 4 個繋げた形をテトロミノといいます。
 次の 7 種類のテトロミノを順に I, O, T, J, L, S, Z 型と呼ぶことにします。
 
 (図略)
 
 すぬけ君は I, O, T, J, L, S, Z 型のテトロミノをそれぞれ aI, aO, aT, aJ, aL, aS, aZ 個ずつ持っています。
 すぬけ君はこれらのテトロミノのうち K 個を組み合わせ、縦 2 マス、横 2K マスの長方形を作ろうとしています。
 このとき、すぬけ君は次のルールに従います。
 
 各テトロミノを置くとき、回転はできるが、反転はできない。
 長方形の各マスにはちょうど 1 個のテトロミノが置かれているようにする。
 長方形の外部にテトロミノが置かれていないようにする。
 
 すぬけ君はできるだけ大きい長方形を作ろうとしています。 K の最大値を求めてください。
 
 制約
 0≤aI,aO,aT,aJ,aL,aS,aZ≤109
 aI+aO+aT+aJ+aL+aS+aZ≥1
 =================================================================
 
 解説=============================================================
 
 K+=1(O:1個)(1)  K+=3(I,J,L:１個)(2)   K+=2(J:2個 or L:2個)(3)   K+=2(I:2個)(4)
 ◽️◽️         ◽️ ◽️◽️◽️◽️ ◽️         ◽️ ◽️◽️◽️               ◽️◽️◽️◽️
 ◽️◽️         ◽️◽️◽️  ◽️◽️◽️         ◽️◽️◽️ ◽️               ◽️◽️◽️◽️
 
 ================================================================
 */

enum Tetromino { I,O,T,J,L,S,Z};
ll solve(){
    //    cout << I << " " << O << " " << T << " " << J << " " << L << " "<< S << " " << Z << endl;
    ll res = 0;
    ll a[7] = {};
    for(auto &in:a) cin >> in;
    res += a[O]; // (1)
    
    ll t1 = 0, t2 = 0;
    t1 += 2*(a[J]/2);// a[J]%=2;
    t1 += 2*(a[L]/2);// a[L]%=2;
    t1 += 2*(a[I]/2);// a[I]%=2;
    
    if(a[J] >= 1 && a[L] >= 1 && a[I] >= 1){
        t2 += 3; a[J]--; a[L]--; a[I]--;
        t2 += 2*(a[J]/2);// a[J]%=2;
        t2 += 2*(a[L]/2);// a[L]%=2;
        t2 += 2*(a[I]/2);// a[I]%=2;
    }
    
    res += max(t1,t2);
    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);

    a = a-b; ///amount of free space in Bottle 1
    c = c-a; ///
    if(c<0)
        c=0;
    printf("%d\n",c);

    return 0;
}



Measured memory_bytes: 1724
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

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

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;


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

	string res = "No";
	for (ll i = 0; i <= m; i++)
	{
		for (ll j = 0; j <= n; j++)
		{
			if (n - j >= 0 && m - i >= 0)
			{
				ll s = i * (n - j) + j * (m - i);
				if (s == k)
				{
					res = "Yes";
				}
			}
		}
	}


	println(res);
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class BPowerSocket {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int n = s.nextInt();
            int m = s.nextInt();
            int total = 1;
            int count = 0;
            while (total < m) {
                total -= 1;
                total += n;
                count++;
            }
            out.println(count);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21460
#include <iostream>

using namespace std;

int main(){
  int A,B;
  cin>>A>>B;

  if(A==1)A=14;
  if(B==1)B=14;

  if(A==B)cout<<"Draw";
  else if(A>B)cout<<"Alice";
  else cout<<"Bob";
  cout<<endl;

  return 0;

}


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

#define MOD 1000000007

using namespace std;
typedef unsigned long long ull;
// typedef long long ll;

// void p() {
//     cout << "\n";
// }
// template<class Head, class... Body>
// void p(Head head, Body... body) {
//     cout << head << ",";
//     p(body...);
// }

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    for (const auto i : v) {
        os << i << " ";
    }
    os << "]";
    return os;
}


int main(int argc, char const *argv[]) {
    int N, M;
    cin >> N >> M;
    vector<int> C(N, 0);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a -= 1;
        b -= 1;
        C[a] += 1;
        C[b] += 1;
    }
    for (int i = 0; i < N; ++i) {
        cout << C[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

#define ll long long
#define forn(i, n) for (ll i = 0; i < (ll) n; ++i)
#define sz(a) static_cast<int>(a.size())

char buff[(int) 1e6 + 17];
const ll inf = (ll) 1e9 + 7ll;

const int maxn = (int) 2e3 + 17;

int n;

bool read() {
    if (scanf("%d", &n) != 1)
        return false;

    return true;
}

void solve() {
    for (ll a = 1; a <= 3500; ++a)
        for (ll b = 1; b <= 3500; ++b)
            if (4ll * a * b - n * (a + b) > 0 && (a * b * n) % (4ll * a * b - n * (a + b)) == 0) {
                ll c = (a * b * n) / (4ll * a * b - n * (a + b));
                printf("%lld %lld %lld\n", a, b, c);
                return ;
            }

    assert(false);
}

int main() {
#if SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}


Measured memory_bytes: 256
x, k, d = map(int, input().split())

x = abs(x)
kk = x // d

if kk >= k:
    print(str(x - (d * k)))
    exit()

k -= kk

if k % 2 == 0:
    print(str(x - (d * kk)))
else:
    print(str(abs(x - (d * (kk + 1)))))


Measured memory_bytes: 9180
#include <stdio.h>
int lenear(int *,int ,int);


int main(){
  int S[10000],i,n,m,cnt=0,nu;

  scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf("%d",&S[i]);
    }
    
    scanf("%d",&m);
    
    for(i=0;i<m;i++){
      scanf("%d",&nu);
      if(lenear(S,nu,n) == 1) cnt++;
    }
      printf("%d\n",cnt);
      return 0;
    }

int lenear(int *S,int T,int n){
  int i=0;
 
  S[n] = T;
  
  while(S[i] !=  T){
    i++;
    if(i == n) return 0;
  }
    return 1;
    
}



Measured memory_bytes: 2108
#include <iostream>

using namespace std;

int main()
{
    int S;
    cin>>S;
    int h,m,s;
    h=S/3600;
    m=(S%3600)/60;
    s=(S%3600)-m*60;
    cout<<h<<":"<<m<<":"<<s<<endl;

    return 0;
}



Measured memory_bytes: 3096
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<complex>

#define START 0
#define END 1
using namespace std;

typedef complex<double> point;

const double infty = 1e40;
const double eps = 1e-10;

bool eq(double a, double b){
  return abs(b-a) < eps;
}

struct anntena{
  point ul, rd;
  anntena(point a, point b):ul(a),rd(b){}
  bool isinside(const point &t){
    if( ul.real()<=t.real()&&t.real()<=rd.real()&&
	ul.imag()>=t.imag()&&t.imag()>=rd.imag())return true;
    return false;
  }
};

int main()
{
  int n;
  int tc=1;
  while(cin>>n && n>0){
    double res = 0;
    set<double> X;
    set<double> Y;
    vector<anntena> va;

    for(int i = 0; i < n; ++i){
      double x,y,r;
      scanf("%lf%lf%lf", &x, &y, &r);
      //cin >> x >> y >> r;
      X.insert(x-r);
      X.insert(x+r);
      Y.insert(y-r);
      Y.insert(y+r);
      va.push_back( anntena(point(x-r,y+r), point(x+r,y-r) ) );
    }
    for(set<double>::iterator itx = X.begin(); itx != X.end(); ++itx){

      double x = *itx;
      ++itx;
      if(itx==X.end())break;
      double nx = *itx;
      --itx;
      double span_x = nx - x;
      for(set<double>::iterator ity = Y.begin(); ity != Y.end(); ++ity){
	double y = *ity;
	++ity;
	if(ity==Y.end())break;
	double ny = *ity;
	--ity;
	double span_y = ny - y;
	/*
	point lu = point(x,ny);
	point ru = point(nx,ny);
	point ld = point(x,y);
	point rd = point(nx,y);
	*/
	point cent = point((x+nx)/2,(y+ny)/2);
	//bool lu_cont = false;
	//bool rd_cont = false;
	bool cent_cont = false;
	for(int i = 0; i < (int)va.size(); ++i){
	  if( va[i].isinside( cent ) ) cent_cont = true;
	  //if( va[i].isinside( rd ) ) rd_cont = true;
	}
	if( cent_cont ){//&& rd_cont ){
	  res += span_x * span_y;
	}
      } 
    }
    printf("%d %.2lf\n", tc, res);
    ++tc;
  }
  return 0;
}

Measured memory_bytes: 0
local road={}
local rail={}
local size={}

local function init(n)
    for i=1,n do
        road[i]=i
        rail[i]=i
        size[i]=1
    end
end

local function root(x,list)
    return list[x]==x and x or root(list[x],list)
end

local function same(x,y,list)
    return root(x,list)==root(y,list)
end

local function unite(x,y,list)
    x=root(x,list)
    y=root(y,list)
    if x==y then
        return
    end
    if size[x]>size[y] then
        x,y=y,x
    end
    list[x]=y
    size[y]=size[y]+size[x]
end

local function getsize(x)
    return size[root(x,list)]
end

----------

local n,k,l=io.read("n","n","n")
init(n)

for i=1,k do
    local p,q=io.read("n","n")
    unite(p,q,road)
end

for i=1,l do
    local r,s=io.read("n","n")
    unite(r,s,rail)
end

local counter={}
for i=1,n do
    local key=root(i,road).." "..root(i,rail)
    counter[key]=(counter[key] or 0)+1
end

for i=1,n do
    local key=root(i,road).." "..root(i,rail)
    io.write(counter[key].." ")
end
print()

Measured memory_bytes: 45148
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;

int cnt=0;

void merge(int a[], int left,int mid, int right)
{
	int n1 = mid-left;
	int n2 = right-mid;
	vi l;
	vi r;
	REP(i,n1)l.push_back(a[left+i]);
	REP(i,n2)r.push_back(a[mid+i]);
	l.push_back(INT_MAX);
	r.push_back(INT_MAX);
	int i = 0;
	int j = 0;
	for(int k = left; k < right; k++){
		if(l[i] <= r[j]){
			a[k] = l[i];
			i++;
		}else{
			a[k] = r[j];
			j++;
		}
		cnt++;
	}
	return;
}

void mergeSort(int a[], int left, int right)
{
	if(left+1 < right){
		int mid = (left+right)/2;
		mergeSort(a,left,mid);
		mergeSort(a,mid,right);
		merge(a,left,mid,right);
	}
	return;
}

int main(void)
{
	int n;
	int s[500000];
	cin >> n;
	REP(i,n) cin >> s[i];

	mergeSort(s,0,n);
	REP(i,n-1) cout << s[i] << ' ';
	cout << s[n-1] << endl;
	cout << cnt << endl;

        return 0;
}

Measured memory_bytes: 7208
#include <cstdio>

int main()
{
	int		W, H, x, y, r;

	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

	if (((x + r) > W) || ((x - r) < 0))
	{
		printf("No\n");
	}
	else if (((y + r) > H) || ((y - r) < 0))
	{
		printf("No\n");
	}
	else
	{
		printf("Yes\n");
	}

	return 0;
}

Measured memory_bytes: 2692
import sys


N=int(input())
s=input()
def find(s):
    dic={}
    for x in s:
        if x in dic:
            dic[x]+=1
        else:
            dic[x]=1

    MOD=10**9+7
    ans=1
    for x in dic:
        ans*=dic[x]+1
        ans%=MOD
    return (ans-1)%MOD

print(find(s))

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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define ins insert
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)9e18);
const int ninf=((int)-9e18);
const int mod=1000000007;

using namespace std;

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);


int n;
    cin>>n;

    vector <int> a(n);
    int c=0;

    loop(i,0,n) cin>>a[i];

    sort(all(a));

    cout<<a[n/2]-a[n/2-1];


    return 0;
}


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

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)

int main() {

	int n;
	cin >> n;
	long double dp[n + 2] = {0}, p;
	dp[1] = 1;

	fo(i, n) {
		cin >> p;
		for (int j = i + 2; j > 0; j--) {
			dp[j] = dp[j] * (1 - p) + dp[j - 1] * p;
		}
	}

	p = 0;
	Fo(i, n / 2 + 2, n + 2) p += dp[i];

	cout << setprecision(10) << p;

	return 0;
}

Measured memory_bytes: 3760
#include <stdio.h>
int main(void) {
    int num,kind,temp,i;
    while (1) {
        scanf("%d %d\n",&num,&kind);
        if (num==0&&kind==0) break;
        int bk[kind],flag=0;
        for (i=0; i<kind; i++) scanf("%d",&bk[i]);
        for (i=0; i<num*kind; i++) {
            scanf("%d",&temp);
            bk[i%kind]-=temp;
        }
        for (i=0; i<kind; i++) {
            if (bk[i%kind]<0) flag=1;
        }
        if (flag==0) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }
    return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  ll ans = 1ll<<60;
  FORe(i, -100, 100){
    ll t = 0;
    REP(j, n) t += (a[j]-i)*(a[j]-i);
    chmin(ans, t);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int x,y,sum=0,i=0;
  double ave=0;

  while(scanf(" %d,%d",&x,&y)!=EOF){
    sum+=x*y;
    ave+=(double)y;
    i++;
}
  ave=ave/i+0.5;
  printf("%d\n%.0f\n",sum,ave);
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;
//using namespace atcoder;
ll dp[43][500][500];

int main(){
    int N,Ma,Mb;
    cin >> N >> Ma >> Mb;
    vector<ll> a(N), b(N), c(N);
    rep(i,N){
        cin >> a[i] >> b[i] >> c[i];
    }
    rep(i,43)rep(j,500)rep(k,500){
        dp[i][j][k] = 1e18;
    }
    dp[0][0][0] = 0;
    rep(i,N){
        rep(j,402){
            rep(k,402){
                cmin(dp[i+1][j][k], dp[i][j][k]);
                cmin(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k] + c[i]);
            }
        }
    }
    ll ma = Ma;
    ll mb = Mb;
    ll ans = 1e18;
    rep(i,400){
        if(ma > 400 || mb > 400)break;
        rep(j,N){
            cmin(ans, dp[j+1][ma][mb]);
        }
        ma += Ma;
        mb += Mb;
    }
    if(ans == 1e18){
        ans = -1;
    }    
    cout << ans << endl;
    /*
    ll n1 = N/2;
    ll n2 = N - N/2;
    vector<vector<ll>> v(405, vector<ll>(405,1e18)), u(405, vector<ll>(405,1e18)); 
    vector<Pll> vv,uu;
    rep(i,(1LL << (n1))){
        ll suma = 0;
        ll sumb = 0;
        ll sumc = 0;
        rep(j,n1){
            if((i >> j) & 1LL){
                suma += a[j];
                sumb += b[j];
                sumc += c[j];
            }
        }
        v[suma][sumb] = sumc;
        vv.push_back({suma,sumb});
    }
    rep(i,(1LL << (n2))){
        ll suma = 0;
        ll sumb = 0;
        ll sumc = 0;
        REP(j,0,n2){
            if((i >> j) & 1LL){
                suma += a[j+n1];
                sumb += b[j+n1];
                sumc += c[j+n1];
            }
        }
        u[suma][sumb] = sumc;
        uu.push_back({suma,sumb});
    }
    ll ans = 1e18;
    rep(i, vv.size()){
        ll at = vv[i].fi;
        ll bt = vv[i].se;
        ll ma = Ma;
        ll mb = Mb;
        rep(j,1000){
            ll ca = ma - at;
            ll cb = mb - bt;
            if((0 <= ca && ca <= 400)){
                if((0 <= cb && cb <= 400)){
                    if((0 <= at && at <= 400)){
                        if((0 <= bt && bt <= 400)){
                            cmin(ans, u[ca][cb] + v[at][bt]);
                        }
                    }
                }
            }
            gt:
            ma += Ma;
            mb += Mb;
        }
    }
    if(ans == 1e18){
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;*/
}

Measured memory_bytes: 87596
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

int main()
{
    ll X;
    cin >> X;

    const auto solve = [&]()
    {
        for (ll b=-1000;b<=1000;++b)
        {
            const auto bb = b * b * b * b * b;
            const auto cc = X + bb;

            for (ll a=-1000;a<=1000;++a)
            {
                const auto aa = a * a * a * a * a;
                if (aa == cc) { return pll(a, b); }
            }
        }

        return pll(0, 0);
    };


    const auto ans = solve();
    cout << ans.first << " " << ans.second << endl;

    return 0;
}


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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const int N = 100100;
int n;
vi a[2][N];
int root[2];
vi g[N];

int dfs(int v, int idx) {
	int lst = -1;
	if (!(a[idx][v].size() & 1))
		lst = v;
	forn(i, sz(a[idx][v])) {
		int to = a[idx][v][i];
		int k = dfs(to, idx);
		if (k >= 0) {
			if (lst >= 0) {
				g[k].pb(lst);
				g[lst].pb(k);
				lst = -1;
			} else {
				lst = k;
			}
		}	
	}
	return lst;
}

bool use[N];
int x[N];

void paint(int v, int col) {
	x[v] = col;
	use[v] = 1;
	forn(i, sz(g[v])) {
		int to = g[v][i];
		if (!use[to])
			paint(to, -col);
	}
}

int main () {
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
	cin >> n;
	forn(j, 2) {
    	forn(i, n) {
    		int u;
    		cin >> u;
    		if (u < 0) {
    			root[j] = i;
    		} else {
    			a[j][u - 1].pb(i);
    		}
    	}
	}
	forn(i, n) {
		if ((a[0][i].size() & 1) ^ (a[1][i].size() & 1)) {
			puts("IMPOSSIBLE");
			return 0;
		}
	}
	forn(i, 2)
		dfs(root[i], i);
	forn(i, n)
		debug(all(g[i]));
	forn(i, n) {
		if (a[0][i].size() & 1) {
			x[i] = 0;
		} else {
			if (!use[i])
				paint(i, 1);
		}
	}
	puts("POSSIBLE");
	forn(i, n) {
		printf("%d ", x[i]);
	}
	cout << endl;
	return 0;
}


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

using namespace std;

int main()
{
	int n;
	while (cin >> n, n) {
		vector<int> score(n);

		for (int i = 0; i < n; ++i) cin >> score[i];

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

		int ans = 0;

		for (int i = 1; i < n - 1; ++i) ans += score[i];

		printf("%d\n", ans / (n - 2));
	}
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define int long long
using namespace std;

const int N = 300111;
int n,m,a,b,c,d;
string s;
int pref[N];

signed main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    cin >> s;
    int ans = 0;
    if (s.size() < 3){
        cout << 0 << endl;
        return 0;
    }
    for (int i=0;i<s.size()-2;i++){
        if (s[i] == 'A'){
            pref[i]=pref[i-1]+1;
        }
        if (s[i+1]=='B' && s[i+2]=='C'){
            pref[i+2] = pref[i];
            ans+=pref[i];
            //cout << i << endl;
        }
        //cout << i << " " << pref[i] << endl;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2196
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < A[i].size(); j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

template < typename A, size_t N, typename T >
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	string S;
	cin >> S;
	N = S.size();
	int M = 0;
	rep(i, N) M += (S[i] - '0');
	if (M % 9 == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3756
use proconio::input;

const MODULO: usize = 1_000_000_007;

fn pow(a: usize, n: usize, p: usize) -> usize {
    if n == 0 {
        1
    } else if n % 2 == 0 {
        let x = pow(a, n/2, p);
        x * x % p
    } else {
        let x = pow(a, n/2, p);
        a * ((x * x) % p) % p
    }
}

fn main() {
    input! {
        n: usize,
        k: usize,
    }

    let mut count = vec![0; k];
    let mut ans = 0;

    for x in (1..=k).rev() {
        let c = pow(k/x, n, MODULO);
        count[x-1] = c;
        for i in 2.. {
            if i * x  > k {
                break;
            }
            count[x-1] = (count[x-1] + MODULO - count[i*x-1]) % MODULO;
        }
        ans += x * count[x-1] % MODULO;
        ans %= MODULO;
    }
    
    println!("{}", ans);
}

Measured memory_bytes: 2752
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>

#define INF 100000000

using namespace std;

int main()
{
    int a, b, tmp, ans = 0;
    cin >> a >> b;
    int check[4];
    for (int i = a; i <= b; i++)
    {
        tmp = i;
        //cout << tmp << endl;
        check[0] = tmp % 10;
        tmp /= 10;
        check[1] = tmp % 10;
        tmp /= 100 ;
        check[2] = tmp % 10;
        tmp /= 10;
        check[3] = tmp % 10;
        if (check[0] == check[3] && check[1] == check[2])
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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();
		sc.close();
		int num = n / 100;
		n %= 100;
		if (num * 5 >= n) {
			System.out.println(1);
		} else {
			System.out.println(0);
		}
	}

	public static long modFactorial(long n, long mod) {
		long ans = 1;
		for (int i = 1; i <= n; i++) {
			ans *= i;
			ans %= mod;
		}
		return ans;
	}

	public static int arrayMax(int[] array) {
		int ans = Integer.MIN_VALUE;
		for (int i = 0; i < array.length; i++) {
			if (array[i] > ans)
				ans = array[i];
		}
		return ans;
	}

	public static int[] arrayInt(Scanner sc, int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static long[] arrayLong(Scanner sc, int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		return array;
	}

	public static double[] arrayDouble(Scanner sc, int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextDouble();
		}
		return array;
	}
}

class Combination {
	static final int MOD = 1000000007;
	long[] fac;
	long[] finv;
	long[] inv;

	public Combination(int size) {
		fac = new long[size];
		finv = new long[size];
		inv = new long[size];
		fac[0] = 1;
		fac[1] = 1;
		finv[0] = 1;
		finv[1] = 1;
		inv[1] = 1;
		for (int i = 2; i < size; 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;
		}
	}

	public long getComb(int n, int k) {
		if (n < k || n < 0 || k < 0) {
			return 0;
		}
		return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
int main(void){
	int num,i=0,crush=0,least=1;
	scanf("%d",&num);
	int brick[num+1];
	while(i<=num-1){
		scanf("%d",&brick[i]);
		i++;
	}
	i=0;
	while(brick[i]!='\0'){
		if(brick[i]==least){
			least++;
		}else{
			crush++;
		}
      	if(i==(num-1)) break;
		i++;
	}
	if((crush==num)&&(brick[0]!=1)){
		crush=-1;
	}
	printf("%d",crush);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e6 + 5;

int cnt[300][4005];

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

    int n;
    string s;

    cin >> n >> s;

    s = ' ' + s;

    for(int i = 1; i <= n; i++) {
        cnt[s[i]][i]++;
    }

    for(auto c : {'R', 'G', 'B'}) {
        for(int i = 1; i <= n; i++) {
            cnt[c][i] += cnt[c][i - 1];
        }
    }

    long long ans = 0;

    for(int j = 2; j <= n; j++) {
        for(int i = 1; i < j; i++) {
            if(s[i] != s[j]) {
                set<char> se = {'R', 'G', 'B'};
                se.erase(s[i]);
                se.erase(s[j]);

                char last = *se.begin();
                ans += (cnt[last][n] - cnt[last][j + 1 - 1]);

                ///j - i == k - j
                if(2 * j - i <= n && s[2 * j - i] == last) {
                    ans--;
                }
            }
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3688