akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
template<class T> using vv=vector<vector<T> >;

int main() {
  vi results;

  while (true) {
    int count;
    cin >> count;
    if (count == 0) { break; }
    vi point(count);
    for (int i = 0 ; i < count ; i++) {
      cin >> point[i];
    }
    int max_point = -1;
    int min_point = 1001;
    int ave = 0;
    for (int i = 0 ; i < point.size() ; i++) {
      ave += point[i];
      if (max_point < point[i]) {
        max_point = point[i];
      }
      if (min_point > point[i]) {
        min_point = point[i];
      }
    }
    ave -= (max_point + min_point);
    ave /= (count-2);
    results.push_back(ave);
  }

  for (int i = 0 ; i < results.size() ; i++) {
    printf("%d\n", results[i]);
  }

  return 0;
}

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

int main() {
    int N; string S;
    cin >> N >> S;
    int ans = 0;
    rep(n, 1000) {
        string T = to_string(n);
        while(T.size() < 3) T = '0' + T;
        int it = 0;
        rep(i, S.size()) {
            if(S[i] == T[it]) it++;
            if(it == 3) break;
        }
        if(it == 3) ans++;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 384
/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

// #include<algorithm>
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stdio.h>
#include<vector>

#define INF 0x3f3f3f3f

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    long long ans = 0LL;
    for(int i = 1; i <= n; ++i) {
        if(i % 3 != 0 && i % 5 != 0) ans += i;
    }
    cout << ans << endl;
    return 0;

}



Measured memory_bytes: 3692
r,g,b,n = map(int,input().split())

ans = 0
rmax = n//r
for i in range(rmax+1):
    rest = n-r*i
    gmax = rest//g
    for j in range(gmax+1):
        rest = n-r*i-g*j
        if rest%b==0: ans += 1

print(ans)


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

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

    int N;
    cin >> N;
    vector<int> A(N);
    int maxi = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A.at(i);
        if (A.at(i) > A.at(maxi)) {
            maxi = i;
        }
    }
    sort(A.begin(), A.end(), greater<int>());
    for (int i = 0; i < N; ++i) {
        if (i == maxi) {
            cout << A.at(1) << endl;
        } else {
            cout << A.at(0) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <algorithm>
#include <cstdlib>

int main()
{
    using namespace std;

    int n, x, y;
    int m;

    cin >> n >> x >> y;

    int k[n] = {};

    for(int i=1; i<=n-1; i++)
    {
        for(int j=i+1; j<=n; j++)
        {
            m = min(abs(j-i), abs(x-i)+1+abs(y-j));
            k[m]++;
        }
    }

    for(int i=1; i<=n-1; i++)
    {
        cout << k[i] << endl;
    }
    return 0;
}


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

int func(int num) {
  if (num % 2 == 0) {
    return num / 2;
  } else {
    return 3 * num + 1;
  }
}

int main() {
  int s;
  map<int,bool> hash;

  cin >> s;
  int i = 1;
  while (hash.count(s) == 0) {
    hash.insert(make_pair(s,true));
    s = func(s);
    ++i;
  }

  cout << i << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp

int main() {
  ll z=0,k,n,m,h,w,ans=0,sum=0,Max=1,Min=1e9+1;
  bool ok = false;
  string s,t,r;
  cin >> n;
  VL a(n),b(2*1e5-1),c(n);
  rep(i,n) { cin >> a[i]; b[a[i]]++;}

  rep(i,2*1e5){
    sum = sum + (b[i] * (b[i]-1) / 2);
  }

  rep(i,n){
    ans = sum;
    ans -= b[a[i]]*(b[a[i]]-1)/2;
    ans += (b[a[i]]-1)*(b[a[i]]-2)/2;
    cout << ans << endl;
  }
 
  return 0;
}

Measured memory_bytes: 7296
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] h = new int[n];
		int[] max = new int[n];
		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
			max[i] = 0;
		}
		int ans = 0;
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			max[a - 1] = Math.max(max[a - 1], h[b - 1]);
			max[b - 1] = Math.max(max[b - 1], h[a - 1]);
		}
		for (int i = 0; i < n; i++) {
			if (h[i] > max[i]) {
				ans++;
			}
		}
		sc.close();
		System.out.println(ans);
	}

}

Measured memory_bytes: 60272
c = []
for i in range(10):
    for j in range(10):
        for k in range(10):
            for l in range(10):
                c.append(i+j+k+l)
c.append(1)
n, a, b = map(int,input().split())
print(sum([i for i in list(filter(lambda i : a <= c[i] <= b, range(n+1)))]))



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

int main() {
    int A, B, C, K; cin >> A >> B >> C >> K;
    if (A >= K) {
        cout << K << endl;
    } else if (A + B >= K) {
        cout << A << endl;
    } else {
        cout << A - (K - B - A) << endl;
    }
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define iter(v, i) for (__typeof__((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define fast_io_without_cstdio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define all(v) (v).begin(), (v).end()
#define rep(i, s, e) for (int i = s; i < e; i++)

// START for segment tree
#define params int p, int L, int R
#define housekeep int mid = (L + R) >> 1, left = p << 1, right = left | 1
// END

#ifdef __linux__
#define gc getchar_unlocked
#define pc putchar_unlocked
#else
#define gc getchar
#define pc putchar
#endif

#if __cplusplus <= 199711L
template<class BidirIt>
BidirIt prev(BidirIt it, typename iterator_traits<BidirIt>::difference_type n = 1) {
    advance(it, -n);
    return it;
}

template<class ForwardIt>
ForwardIt next(ForwardIt it, typename iterator_traits<ForwardIt>::difference_type n = 1) {
    advance(it, n);
    return it;
}
#endif

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ldouble;

const double EPS = 1e-9;
const double PI = 3.141592653589793238462;

template<typename T>
inline T sq(T a) { return a * a; }

//#ifdef LOCAL_MACHINE
//#endif

int main() {
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    int n, a, b;
    scanf("%d %d %d", &n, &a, &b);
    puts(((b - a - 1) & 1) ? "Alice" : "Borys");
    return 0;
}



Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int>C(N-1),S(N-1),F(N-1);
  for(int i=0;i<N-1;i++)cin>>C[i]>>S[i]>>F[i];
  for(int s=0;s<N;s++){
    int t=0;
    for(int i=s;i<N-1;i++){
      t=max(S[i],F[i]*((t-1)/F[i]+1))+C[i];
    }
    cout<<t<<endl;
  }
}

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

using namespace std;

struct UnionFind {
    vector< int > data;
    
    UnionFind(int sz) {
        data.assign(sz, -1);
    }
    
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return (false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }
    
    int find(int k) {
        if(data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }
    
    int size(int k) {
        return (-data[find(k)]);
    }
};

int main(void) {
    int N, K, L;
    cin >> N >> K >> L;

    UnionFind street(N), train(N);
    while(K--) {
        int p, q;
        cin >> p >> q;
        --p; --q;
        street.unite(p, q);
    }
    while(L--) {
        int r, s;
        cin >> r >> s;
        --r; --s;
        train.unite(r, s);
    }

    vector<int64_t> id(N);
    map<int64_t, int> mp;
    for(int i=0; i<N; i++) {
        id[i] = street.find(i) + 1'000'000'000L * train.find(i);
        mp[id[i]]++;
    }

    for(int i=0; i<N-1; i++) {
        cout << mp[id[i]] << ' ';
    }
    cout << mp[id[N-1]] << endl;
    return 0;
}


Measured memory_bytes: 15104
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		sc.close();
		long yono = 1;
		for(int i = 2 ; i <= n ; i++){
			boolean sos = true;
			for(int j = 2 ; sos && j <= Math.sqrt(i) ; j++){
				if(i % j == 0) sos = false;
			}
			if(sos){
				int now = n;
				long so = 1;
				while(now != 0){
					so += now / i;
					now /= i;
				}
				yono *= so;
				yono %= 1000000007;
			}
		}
		ou.print(yono + "\n");
		ou.flush();
    }
}

Measured memory_bytes: 38368
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

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

    int ans=0;
    REP(i, 0, n){
        if(a[i]==b[i] && b[i]==c[i]){
            ans+=0;
        }
        else if(a[i]==b[i] || b[i]==c[i] || c[i]==a[i]){
            ans+=1;
        }
        else{
            ans+=2;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int a, b;
	cin >> a >> b;
	char ans;
	if (a + b == 15) ans = '+';
	else if (a * b == 15) ans = '*';
	else ans = 'x';
	cout << ans << endl;
	return 0;	
}

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

void dfs(int n,int last,string s){
	for(int i = n;i >= 1;i--){
		if(n - i == 0 && last >= i) {
			cout << s << n << endl;
		}
		else {
			if(last >= i) dfs(n - i,i,s + to_string(i) + " ");
		}
	}
}

int main(){
	int n;
	while(cin >> n,n){
		dfs(n,n,"");
	}
	return 0;	
}

Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main(){
	int t=1;
	//cin>>t;
	while(t--){
		int a,b;
		cin>>a>>b;
		if(a<=5){
			cout<<0<<endl;
		}
		else if(a<13){
			cout<<b/2<<endl;
		}
		else
			cout<<b<<endl;

	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0)
    return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1; // 分母
  ll numerator = 1;   // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
private:
  vector<ll> parents;

public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) {
    return root(x) == root(y);
  }

  bool merge(ll x, ll y) {
    if (issame(x, y))
      return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry])
      swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) {
    return -parents[root(x)];
  }

private:
  ll root(ll x) {
    if (parents[x] < 0)
      return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

int main() {
  ll N, M;
  cin >> N >> M;

  vector<pair<ll, ll>> bridges(M);
  for (ll i = 0; i < M; i++) {
    ll a, b;
    cin >> a >> b;
    bridges[i] = make_pair(a - 1, b - 1);
  }

  vector<ll> ans(M, 0);
  ans[M - 1] = N * (N - 1) / 2;
  UnionFind uni(N);
  for (ll i = M - 1; i > 0; i--) {
    auto points = bridges[i];
    ll a = points.first;
    ll b = points.second;
    if (uni.issame(a, b)) {
      ans[i - 1] = ans[i];
    } else {
      ans[i - 1] = ans[i] - uni.size(a) * uni.size(b);
    }

    uni.merge(a, b);
  }

  for (auto a : ans) {
    cout << a << endl;
  }
  return 0;
}


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

#include <iostream>
#include <vector>
#include <string>


int main()
{
	std::string s,t;
	std::cin >> s >> t;
	std::cout << t << s << std::endl;

	}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define int long long
#define ll long long
#define moder 1000000007
#define INF LLONG_MAX/3
#define P std::pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int n,k,a[1010],b[1000010];
set<int> st;
signed main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=2;i<=n;i++)a[i]+=a[i-1];
	int cnt=0;
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j++){
			b[cnt]=a[j]-a[i-1];
			cnt++;
		}
	}
	int ans=0;
	for(int keta=45;keta>=0;keta--){
		int c=0;
		rep(i,cnt){
			if(((b[i]>>keta)&(ll)1)&&st.find(i)==st.end())c++;
		}
		if(c>=k){
			rep(i,cnt){
				if((b[i]>>keta)&(ll)1)b[i]-=(ll)1<<keta;
				else{
					st.insert(i);
				}
			}
			ans+=(ll)1<<keta;
		}
		else{
			rep(i,cnt){
				if((b[i]>>keta)&(ll)1)b[i]-=(ll)1<<keta;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 29824
#include <iostream>
#include <vector>

using namespace std;

void PrintFrame(vector<vector<int>> data){

    for ( vector<int> elem : data) {
        int height = elem[0];
        int width = elem[1];
        for (int i = 0; i < height; i++) {
            for (int j = 0; j < width; j++) {
                if( i*j == 0 || i == height-1 || j == width-1)
                    cout << "#";
                else
                    cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
}

int main(){
    // ---------------------------
    // ITP_1_5_A: Print a Rectangle
//    int w, h;
//    std::vector<std::vector<int>> data;
//    while (true){
//        std::cin >> h >> w;
//        if (h == 0 && w ==0)
//            break;
//        data.push_back({h, w});
//    }
//    PrintRectangle(data);
    // ---------------------------

    // ---------------------------
    // ITP_1_5_B: Print a Frame
    int w, h;
    std::vector<std::vector<int>> data;
    while (true){
        std::cin >> h >> w;
        if (h == 0 && w ==0)
            break;
        data.push_back({h, w});
    }
    PrintFrame(data);
    // ---------------------------

    // ---------------------------
    // ITP_1_5_C: Print a Chessboard
    // ---------------------------

    // ---------------------------
    // ITP_1_5_D: Structured Programing
    // ---------------------------

    return 0;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define endl '\n'
#define pii pair<int,int>
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define fill(a,b) memset(a,b,sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    string s; cin>>s;
    string x(sz(s),'x');
    cout<<x<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f(a,n) for(ll i=a;i<n;i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define all(v) v.begin(),v.end()
using namespace std;
const ll mod=(1e+9)+7;
const ll size = 2e5+9;
ll gcd(ll a,ll b) {if(b==0)return a;return gcd(b,a%b);}
ll power(ll a,ll b,ll m = mod) {ll res = 1;while(b>0){if(b&1)res = (res*a)%m;b = b>>1;a = (a*a)%m;}return res;}


void solve()
{
    ll a,b,t;
    cin>>a>>b>>t;
    cout<<(t/a)*b<<endl;
}

int main()
{
    #ifdef JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    clock_t beg = clock();
    solve();
    clock_t end = clock();
    fprintf(stderr, "%.3f sec, Copyright %c 2019 Skyscraper. \n", double(end - beg) / CLOCKS_PER_SEC , 184);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int inf=1<<30;
deque<int> q;
vector<int> g[100010];
bool used[100010];
int main(){
	int n,m;
	cin>>n>>m;
	while(m--){
		int a,b;
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	q.push_back(1);
	used[1]=true;
	while(1){
		int l=q.front(),r=q.back();
		bool b=true;
		for(int i=0;i<g[l].size();i++){
			if(!used[g[l][i]]){
				q.push_front(g[l][i]);
				used[q.front()]=true;
				b=false;
				break;
			}
		}
		for(int i=0;i<g[r].size();i++){
			if(!used[g[r][i]]){
				q.push_back(g[r][i]);
				used[q.back()]=true;
				b=false;
				break;
			}
		}
		if(b)break;
	}
	cout<<q.size()<<endl;
	while(!q.empty()){
		cout<<q.front()<<" ";
		q.pop_front();
	}
	return 0;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define PI 3.1415926535898

//------------------------------------------------------

int main() {
    string s[2];
    cin >> s[0] >> s[1];

    YES(s[0][0] == s[1][2] && s[0][1] == s[1][1] && s[0][2] == s[1][0]);

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    string s;cin>>s;
    ll ans=0,cur=0;
    for(ll i=0;i<s.size();i++){
        if(s[i]=='B')cur++;
        else ans+=cur;
    }
    cout<<ans;
}




Measured memory_bytes: 720
#include <iostream>

using namespace std;

static const int N_MAX = 10000;

int linearSearch(int S[], int n, int t);

int main()
{
	int i, n, q, t, c = 0;
	int S[N_MAX] = {0};

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

	cin >> q;
	for (i = 0; i < q; i++) {
		cin >> t;
		c += linearSearch(S, n, t);
	}

	cout << c << endl;

	return 0;
}

int linearSearch(int S[], int n, int t) {
	int i = 0;
	S[n] = t;

	while (S[i] != t) i++;

	if (i == n)
		return 0;
	else
		return 1;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    for(int i = 0; i < n; i++){
        if(i % 2){
            if(k > 0 && s[i] == 'B'){
                k--;
                s[i] = 'A';
            }
            if(k == 0){
                for(int j = i; j < n; j++){
                    if(s[j] == 'A') cout << 'B';
                    else cout << 'A';
                }
                for(int j = 0; j < i; j++){
                    if(j % 2 == (i - 1) % 2) cout << 'A';
                    else cout << 'B';
                }
                cout << endl;
                return 0;
            }
        }
        else{
            if(k > 0 && s[i] == 'A'){
                k--;
                s[i] = 'B';
            }
            if(k == 0){
                for(int j = i; j < n; j++) cout << s[j];
                for(int j = 0; j < i; j++){
                    if(j % 2 == (i - 1) % 2) cout << 'A';
                    else cout << 'B';
                }
                cout << endl;
                return 0;
            }
        }
        k--;
    }
    if(n % 2){
        if(k % 2) cout << 'B';
        else cout << 'A';
        n--;
    }
    for(int i = 0; i < n; i++){
        if(i % 2 == (n - 1) % 2) cout << 'A';
        else cout << 'B';
    }
    cout << endl;
}


Measured memory_bytes: 3736
#include <iostream>
#define MOD 1000000007
using namespace std;
typedef long long ll;

ll dp1[2001][2001], dp2[2001][2001], sum[2001][2001];
int main() {
  int n, m, s[2000], t[2000];
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> t[i];
  }
  dp1[0][0] = dp2[0][0] = sum[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    dp1[i][0] = 0;
    dp2[i][0] = 1;
    sum[i][0] = 0;
  }
  for (int i = 1; i <= m; i++) {
    dp1[0][i] = 0;
    dp2[0][i] = 1;
    sum[0][i] = 1;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i] == t[j]) {
        dp1[i + 1][j + 1] = dp2[i][j];
      }
      sum[i + 1][j + 1] = sum[i + 1][j] + dp1[i + 1][j + 1];
      sum[i + 1][j + 1] %= MOD;
      dp2[i + 1][j + 1] = dp2[i][j + 1] + sum[i + 1][j + 1];
      dp2[i + 1][j + 1] %= MOD;
    }
  }
  cout << dp2[n][m] << endl;
}

Measured memory_bytes: 93952
#include<bits/stdc++.h>
using namespace std;
signed main()
{
   string str;
   cin>>str;
   string ans;
   for(int i=0;i<str.length();i++)
   {
      if(str[i]=='1')
        ans+='9';
      else if(str[i]=='9')
        ans+='1';
      else
        ans+=str[i];
   }
   cout<<ans;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
from collections import Counter
n=int(input())
S=[]
for _ in range(n):
    s=list(input().strip())
    s.sort()
    s=''.join(s)
    S.append(s)
c=Counter(S)
ans=0
for v in c.values():
    ans+=(v*(v-1))//2
print(ans)

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

int main(){
  ll N, M;
  cin >> N >> M;
  ll m = M/2;
  ll Scc = 0;
  if(m<=N)Scc = m;
  else{
    ll x =(m-N)/2;
    Scc = max(N+x, m-x-1);
  }
  cout << Scc << endl;
}

Measured memory_bytes: 256
row1 = list(map(int,input().split()))
row2 = list(map(int,input().split()))
row3 = list(map(int,input().split()))
n = int(input())
arr = []
for i in range(n):
    temp = int(input())
    arr.append(temp)
#
if row1[0] in arr and row1[1] in arr and row1[2] in arr or row2[0] in arr and row2[1] in arr and row2[2] in arr or row3[0] in arr and row3[1] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[0] in arr and row3[0] in arr or row1[1] in arr and row2[1] in arr and row3[1] in arr or row1[2] in arr and row2[2] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[1] in arr and row3[2] in arr or row1[2] in arr and row2[1] in arr and row3[0] in arr:
    print("Yes")
    exit()
else:
    print("No")

Measured memory_bytes: 3188
n,k=map(int,input().split())
a=list(map(int,input().split()))
ball=[0]*n
s=set()
for i in range(n):
    ball[a[i]-1]+=1
    s.add(a[i]-1)
kind=len(s)
ans=0
ball.sort()
for i in range(n):
    if ball[i]==0:
        continue
    if kind>k:
        kind-=1
        ans+=ball[i]
print(ans)

Measured memory_bytes: 36200
// Last Change: 07/20/2019 21:00:48.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll r;
  cin >> r;
  cout << 3 * r * r << endl;
}


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

int f(int a,int b){
  int n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

int main(){
  int i,j,cnt=0;
  int n,k;
  cin>>n>>k;
  int a[n];
  for(i=0;i<n;i++)cin>>a[i];
  for(i=0;i<n;i++)cnt=max(cnt,a[i]);
  if(cnt<k){
    cout<<"IMPOSSIBLE";
    return 0;
  }
  cnt=a[0];
  for(i=1;i<n;i++)cnt=f(cnt,a[i]);
  if(k%cnt==0)cout<<"POSSIBLE";
  else cout<<"IMPOSSIBLE";
}

Measured memory_bytes: 640
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD=1e9+7;

#define MAX 1000001
long fac[MAX], finv[MAX], inv[MAX];

void fact() {
    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 comb(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;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}



int main(){
    ios::sync_with_stdio(false);
    fact();
    ll N,A,B,C,D;
    cin>>N>>A>>B>>C>>D;
    vector<vector<ll>> g(1001, vector<ll>(1001, -1));
    //G(i,a)はi人のグル×aの作り方
    function<ll(ll,ll)> G = [&](ll i,ll a){
        if(a<=1)return 1LL;
        else if(g[i][a]!=-1)return g[i][a];
        else return g[i][a]=(((G(i,a-1)*comb(i*a,i))%MOD)*modinv(a,MOD))%MOD;
    };
    vector<vector<ll>> dp(B+1, vector<ll>(N+1, -1));
    //F(a,x)はa人以上B人以下のグループのみを使ってx人を分ける場合の数
    function<ll(ll,ll)> F = [&](ll a, ll x){
        if(x==0)return 1LL;
        else if(dp[a][x]!=-1)return dp[a][x];
        else if(a==B){
            if(x%B==0&&C<=(x/B)&&(x/B)<=D)return dp[B][x]=G(B,x/B);
            else return dp[B][x]=0;
        }
        else{
        //Fa==0
        ll ret=F(a+1,x);
        //FaがCからD
        for(ll i=C;i<=D&&x-i*a>=0;++i){
            ret+=(((F(a+1,x-i*a)*G(a,i))%MOD)*comb(x,i*a))%MOD;
            ret%=MOD;
        }
        return dp[a][x]=ret;}
    };
    cout<<F(A,N)<<endl;


    return 0;
}


Measured memory_bytes: 42432
def comb_init(max, mod)
  fac = Array.new(max)
  finv = Array.new(max)
  inv = Array.new(max)
  fac[0] = fac[1] = 1
  finv[0] = finv[1] = 1
  inv[1] = 1
  (2...max).each do |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
  end
  { fac: fac, finv: finv, mod: mod }
end

def comb(n, k, context)
  return 0 if n < k
  return 0 if n < 0 || k < 0
  fac = context[:fac]; finv = context[:finv]; mod = context[:mod]
  fac[n] * (finv[k] * finv[n - k] % mod) % mod
end

require 'prime'
N, M = gets.split.map(&:to_i)
MOD = 1000000007
comb_context = comb_init(210000, MOD)
ans = M.prime_division.map do |_, e|
  n = e + N - 1
  k = N - 1
  comb(n, k, comb_context)
end.reduce(1) { |acc, n| acc * n % MOD }
puts ans


Measured memory_bytes: 7164
#include<cstdio>
const long long mod = 1e9+7;

long long getDigit(int u){
    int res = 0;
    while(u!=0){
        u /= 10, res++;
    }
    return res;
}

long long getCount(int l,int r,int left,int mod){
    if(l%mod<=left) l = l-l%mod+left;
    else l = l-l%mod+left+mod;
    if(l>r) return 0;
    else return (r-l+mod)/mod;
}

long long power(long long a,long long b){ 
    long long res = 1;
    while(b){
        if(b&1) res = res*a%mod;
        a = a*a%mod;
        b /= 2;
    }
    return res;
}

int main(){
    long long n;
    scanf("%lld",&n);
    long long sum = 0, nextSum = 0;
    int p = 0;
    int upper = (1e7)-2;
    long long ans = 0;
    for(int i = 0; i <= upper; i++){
        sum += getDigit(i);
        while(nextSum-sum<n){
            p++;
            nextSum += getDigit(p);
        } 
        if(nextSum-sum==n) ans++; 
    }
    for(long long i = 1; i*i<=n; i++){
        if(n%i==0){
            int j = n/i;
            if(i>=8){
                long long add = 9ll*power(10,i-1)%mod;
                add -= (j-1); if(add<0) add += mod;
                ans += add; if(ans>=mod) ans -= mod;
            }
            if(j!=i && j>=8){
                long long add = 9ll*power(10,j-1)%mod;
                add -= (i-1); if(add<0) add += mod;
                ans += add; if(ans>=mod) ans -= mod;
            }
        }
    }
    //this part...
    for(int i = 8; i <= n; i++){
        long long j = i+1;
        long long left = (long long)(-n)%j;
        if(left<0) left += j;
        int maxn = n/i;
        if(n%i==0) maxn--; 
        long long add = getCount(1,maxn,left,j);
        //printf("i = %d, add = %lld\n",i,add);
        ans += add; if(ans>=mod) ans -= mod;
    }
    printf("%lld\n",ans);
    return 0;
}



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

#define MOD 1000000007
const int MAX = 510000;
typedef long long ll;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


ll solve(ll s) {
    COMinit();
    ll ret = 0;
    for (ll i = 1; i <= s / 3; i++) {
        ll r = s - 3 * i;
        // if (i == 2) {
        //     assert(r == 4);
        // }
        ll cnt = COM(r + i - 1, r);
        // if (i == 2) {
        //     cout << "cnt = " << cnt << endl;
        // }
        ret += cnt;
        ret %= MOD;
        // cout << i << " " << ret << endl;
    }
    return ret;
}


int main() {
    ll s;
    cin >> s;
    cout << solve(s) << endl;
    return 0;
}

Measured memory_bytes: 15484
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;


int main() {
	int n, p; // テ、ツクツ甘ゥツ卍?50 50
	int kouho[50];

	//10^6
	while(cin >> n >> p && n && p)
	{
		//cout << n << " " << p << endl;
		rep(i,50){kouho[i]=0;}
		int box = p;
		int index=0;
		while(true)
		{
			if(index >= n){ index=0; }	
			if(box>0){ 
				box--; kouho[index]++;
			}else{
				box=kouho[index]; kouho[index]=0;
				bool flag=false;
				/*
				rep(i,n){if(kouho[i]!=0){flag=false;}}
				if(flag){cout << index << endl; break;}
				*/
				rep(i,n){
					if(kouho[i]==p){flag=true;}	
				}
				if(flag){
					if(index==0){index=n;}
					cout << (index-1)%n << endl; break;
				}
			}
			index++;
		}
	}
	return 0;
}

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

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

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

    int count = 0;
    for(int i = 1; i < n - 1; i++) {
        if(p[i - 1] < p[i] && p[i + 1] > p[i] ||
           p[i - 1] > p[i] && p[i + 1] < p[i]) {
            count++;
        };
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
/*
ここの解説を元にACした: https://betrue12.hateblo.jp/entry/2020/06/14/232948
*/
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<tuple>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

using state = tuple<int, int, int>;

const int INF = 1 << 30;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, K;
    cin >> H >> W >> K;
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    --x1, --y1, --x2, --y2;
    vector<string> grid(H);
    for (auto& g : grid) {
        cin >> g;
    }
    priority_queue<state, vector<state>, greater<state>> que;
    vector<vector<int>> dp(H, vector<int>(W, INF));
    vector<int> dh = {-1, 0, 1, 0};
    vector<int> dw = {0, -1, 0, 1};
    dp[x1][y1] = 0;
    que.emplace(0, x1, y1);
    while (!que.empty()) {
        state now = que.top();
        que.pop();
        int dist = get<0>(now);
        int h = get<1>(now);
        int w = get<2>(now);
        if (dist > dp[h][w]) {
            continue;
        }
        rep(i, 0, 4) {
            int nh = h;
            int nw = w;
            rep(_, 0, K) {
                nh += dh[i];
                nw += dw[i];
                if (nh < 0 || nh >= H || nw < 0 || nw >= W || grid[nh][nw] == '@') {
                    break;
                }
                if (dp[nh][nw] <= dist) {
                    break;
                }
                if (chmin(dp[nh][nw], dist + 1)) {
                    que.emplace(dp[nh][nw], nh, nw);
                }
            }
        }
    }
    if (dp[x2][y2] == INF) {
        cout << -1 << endl;
    } else {
        cout << dp[x2][y2] << endl;
    }
    return 0;
}

Measured memory_bytes: 12112
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=5e5+500,mod=1000000007;
int p[N],stack[N],inq[N],vis[N],inring[N],len[N],tmp[N],cnt[N],top,n,rd[N],fac[N],ifac[N],inv[N],pw2[N],ipw2[N];
void dfs(int u)
{
    stack[++top]=u,inq[u]=1,vis[u]=1;
    int v=p[u];
    if(inq[v])
    {
        int t=top;stack[top+1]=0;
        while(stack[top+1]!=v)inring[stack[top--]]=1;
        top=t;
    }
    if(!vis[v])dfs(v);inq[u]=0;
}
void getdep(int u)
{
    int dep=0;while(!inring[u])++dep,u=p[u];
    len[u]=dep;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",p+i),rd[p[i]]++;
    for(int i=1;i<=n;i++)if(!vis[i])dfs(i);
    for(int i=1;i<=n;i++)if(rd[i]>=2+inring[i]){puts("0");return 0;}
    for(int i=1;i<=n;i++)if(!rd[i])getdep(i);
    int ans=1;
    for(int i=1;i<=n;i++)
    {
        if(!inring[i])continue;
        int u=i,tn=0,iscir=!len[u];inring[u]=0;tmp[++tn]=u;
        while(p[u]!=i)u=p[u],tmp[++tn]=u,iscir&=!len[u],inring[u]=0;
        if(iscir){++cnt[tn];continue;}
        int lst=0;
        for(int j=tn;j>=1;j--)if(len[tmp[j]]){lst=j-tn;break;}
        for(int j=1;j<=tn;j++)
        {
            if(!len[tmp[j]])continue;
            if(j-len[tmp[j]]<lst){puts("0");return 0;}
            if(j-len[tmp[j]]>lst)ans=(ans<<1)%mod;
            lst=j;
        }
    }
    fac[0]=1;for(int i=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%mod;
    inv[1]=1;for(int i=2;i<=n;i++)inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
    ifac[0]=1;for(int i=1;i<=n;i++)ifac[i]=1ll*ifac[i-1]*inv[i]%mod;
    pw2[0]=1;for(int i=1;i<=n;i++)pw2[i]=(pw2[i-1]<<1)%mod;
    ipw2[0]=1;for(int i=1;i<=n;i++)ipw2[i]=(ipw2[i-1]&1)?((ipw2[i-1]+mod)>>1):(ipw2[i-1]>>1);
    for(int i=1;i<=n;i++)
    {
        if(!cnt[i])continue;
        int tn=cnt[i];int s=0,pw=1;
        for(int j=0;j*2<=tn;j++)
        {
            int t=1ll*ifac[tn-2*j]*ifac[j]%mod*ipw2[j]%mod*pw%mod;
            if((i&1)&&i!=1)t=1ll*t*pw2[tn-2*j]%mod;
            s=(s+t)%mod;pw=1ll*pw*i%mod;
        }
        ans=1ll*ans*s%mod*fac[tn]%mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 11532
#include <iostream>
#include <algorithm>
//#include "Log_csv.h"
using namespace std;

int main() {

	int N; 
	cin >> N;
	int* integer = new int[N];
	for (int i = 0; i < N; i++) {
		cin >> integer[i];
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		ans += integer[i] - 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#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(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 510000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  vector<int>P{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  Out(P[N-1]);
}

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

using namespace std;

typedef long long ll;

const int N = 200010;
const int MAX = 100000;

int n , m,a,b,toAdd[N];

vector<int> p[N],rem[N];
vector<int> pre[N];

vector< pair<int,int> > pairs;

int BIT[N];

void add(int idx , int val){
	while(idx < N){
		BIT[idx] += val;
		idx += (idx & -idx);
	}
}
int get(int idx){
	int res = 0;
	while(idx > 0){
		res += BIT[idx];
		idx -= (idx &-idx);
	}
	return res;
}
int main(){
	//freopen("input.txt","r",stdin);
	scanf("%d%d",&n,&m);
	for (int i = 1 ; i <= MAX; ++i){
		for(int j = i ; j <= MAX ; j += i){
			p[j].push_back(i);
		}
	}
	for (int i = 0; i < n; ++i){
		scanf("%d%d",&a,&b);
		toAdd[b]++;
		rem[a].push_back(b);
	}
	for (int i = m ; i >= 1; --i){
		add(i,toAdd[i]);
		for (int j = 0; j < p[i].size(); ++j){
			int val = p[i][j];
/*			if(i == 6){
				cout << "HOO " << val << endl;
			}
			if(i == 6 && val == 3){
				cout << "TO " << i+val-1 << " " << get(i+val-1) << " " << j << endl;
			}*/
			pre[i].push_back(get(i + val-1));		
		}
		while(rem[i].size()){
			add(rem[i].back(),-1);
			rem[i].pop_back();
		}
	}
	for(int i = 1 ; i <= m ; i++){
		int res = 0;
		for(int j = i; j <= m ; j+= i){
			int idx = lower_bound(p[j].begin(),p[j].end(),i) - p[j].begin();
/*			if(i == 3){
				cout << "ADD " << j << " " << pre[j][idx] << " " << idx << endl;
			}*/
			res += pre[j][idx];
		}
		printf("%d\n",res );
	}
	return 0;
}

Measured memory_bytes: 32896
#include <stdio.h>

	int main(){
	int A1,A2,A3;
		
	scanf("%d %d %d", &A1, &A2, &A3);
	
	if (A1+A2+A3>=22){
		printf("bust");
	}
	else {
		printf("win");
	}
		
		return 0;
	}

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

int main(){
  string s;
  cin >> s;
  int n=s.size();
  long long  ans=0;
  long long w=0;
  for(int i=0;i<n;i++){
    if(s[i]=='W'){ans+=i-w;
                 w++;}
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
typedef long long ll;
using namespace std;

const int MOD = 1000000007;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main()
{
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; i++) cin >> H[i];
    for(int i = N - 1; i >= 1; i--)
    {
        if(H[i - 1] <= H[i]) continue;
        else
        {
            if(H[i - 1] -1 == H[i])
            {
                H[i - 1]--;
                continue;
            }
            else
            {
                cout << "No" << endl;
                return(0);
            }

        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 640
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <stack>
using namespace std;
#define ll int64_t
const long mod = 1e9 + 7;


const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}



struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }//最初は全て-1 :-1なら根なので全て根:木のサイズが増えると-2-3-4となる
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);//両方のルートを出して、それをつなげる
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }

  bool findSet(int x, int y) {//要素xとyが同じ集合か　→　rootを調べれば解決
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);//-1なら根、そうでないなら配列が指す場所へ移動
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main() {
  long n;
  cin >> n;

  long m;
  vector<pair<long, long>> ab;


  long p = 0;
  for (int i = 1; i < n; ++i){
    p += i;
  }


  // nが奇数の時 5なら 1-4 2-3
  // nが偶数の時 6 なら

  // n/2本だけいらない

  //

  m = p - n/2;

  int q = 0;
  if (n%2 ==0){
    q = 1 + n;
  }else{
    q = n;
  }
  cout << m << endl;

  for (int i = 1; i < n; ++i){
    for (int j = i+1; j <= n; ++j){
      if (i+j == q)continue;
      cout << i << " " << j <<endl;
    }
  }



}




















Measured memory_bytes: 256
#include <stdio.h>

int i,j,n,e,M[100][100];

int prim(int n){
  int u,sum,mincost,d[100],p[100],color[100];
 
  for(i=0;i<n;i++){
    d[i]=(1<<21);
    p[i]=-1;
    color[i]=0;
  }
  
  d[0]=0;
  while(1){
    mincost=(1<<21);
    u=-1;
    for(i=0;i<n;i++){
      if(mincost>d[i]&&color[i]!=2){
        u=i;
        mincost=d[i];
      }
    }
    if(u==-1){
      break;
    }
    color[u]=2;
    for(j=0;j<n;j++){
      if(color[j]!=2&&M[u][j]!=(1<<21)){
        if(d[j]>M[u][j]){
          d[j]=M[u][j];
          p[j]=u;
          color[j]=1;
        }
      }
    }
  }
  sum=0;
  for(i=0;i<n;i++){
    if(p[i]!=-1){
      sum+=M[i][p[i]];
    }
  }
  
  return sum;
}

int main(void)
{
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      M[i][j]=(e==-1) ? (1<<21):e;
    }
  }
  printf("%d\n",prim(n));
  return 0;
}

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

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF (1 << 29)

using namespace std;

int main(){
	int k;
	cin >> k;

	int cnt = 0;
	int num = 7;
	
	while(num % k != 0){
		num %= k;
		if(cnt > k){
			cout << "-1" << endl;
			exit(0);
		}
		num *= 10;
		num += 7;
		cnt++;
	}

	cout << cnt+1 << endl;

	return 0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=a-1;i>=b;i--)
#define endl '\n'
#define spc " "
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.14159265358979323
#define sz(a) (int)((a).size())
#define FOR(i,j,k,l) for(ll i=j;i<k;i+=l)


void Fast_IO() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   #ifndef ONLINE_JUDGE
   freopen("in.txt","r",stdin);
   freopen("out.txt","w",stdout); 
   #endif
} 

int main(){
   //Fast_IO();
  ll a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a==0) cout<<1;
  else if(b==0) cout<<2;
  else if(c==0) cout<<3;
  else if(d==0) cout<<4;
  else if(e==0) cout<<5;
   
}




Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    string s; cin >> s;
    if(s=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define MAX_N 100000
using namespace std;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, m, nn, mm, p; char s[2][MAX_N+5];
int gcd(int x, int y) {return y ? gcd(y, x%y) : x;}
int main() {
	read(n), read(m);
	scanf("%s%s", s[0], s[1]);
	p = gcd(n, m), nn = n/p, mm = m/p;
	for (int t = 1; t <= p; t++) {
		bool f = true;
		for (int i = 0; f && i < p; i++)
			if (s[0][i*nn] ^ s[1][i*mm]) f = false;
		if (f) return printf("%lld\n", 1LL*nn*mm*p*t), 0;
	}
	return puts("-1"), 0;
}

Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        long n = long.Parse(input[0]);
        long m = long.Parse(input[1]);
        if(m==100){
            m++;
        }
 
//        int kazu = int.Parse(ReadLine());
//        string[,] map = new string[kazu,kazu];
        for(int i=0;i<n;i++){
            m*=100;
        }
        WriteLine(m);
    }
}

Measured memory_bytes: 13140
'use strict'
function Main(input) {
    input = input.split("\n");
    const arr = input[0].split(' ')
    if (arr[0] % 3 === 0 || arr[1] % 3 === 0 || (arr[0] + arr[1]) % 3 === 0) {
        console.log('Possible')
    } else {
        console.log('Impossible')
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
import java.util.Scanner;

class Main {

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

        int a = scan.nextInt();
        int b = scan.nextInt();
        int d;
        int r;
        double f;
        
       d=a/b;
       r=a%b;
       f= (double)a/(double)b;
       
        System.out.printf("%d %d %f\n",d,r,f);
       
            
            
        }
    }


Measured memory_bytes: 26280