akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

int main(){
    int N, K;
    LL S;
    cin >> N >> K >> S;

    int n = N - (K-1);

    LL val = S/n;
    LL val_last = S/n + S%n;

    int i=0;
    if (val==0){
        while(i<N){
            if(i<K){
                cout << val_last << " ";
            }else{
                cout << val_last + 1 << " ";
            }
            i++;
        }

    }else{
        while(i<N){
            if((i+1)%n==0){
                cout << val_last << " ";
            }else{
                cout << val << " ";
            }
            i++;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

unsigned GetDigit(unsigned num) { return to_string(num).length(); }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    string S; cin >> S;
    vector<int> res(4);
    REP(i,4) res[i] = (S[i]-'0');

    for(int bit=0; bit < (1<<3); ++bit){
        int ans=res[0];
        string field;
        for(int i=0; i<3; ++i){
            if(bit & (1<<i)){
                ans += res[i+1];
                field.push_back('+');
            }else{
                ans -= res[i+1];
                field.push_back('-');
            }
        }
        if(ans == 7){
            REP(i,4){
                if(i!=3) cout << res[i] << field[i];
                else cout << res[i] << "=7" << endl;
            }
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

int main(){
	int a,b;
	cin>>a>>b;

	int cnt=0;

	if(b==1){
		cout<<0;
		return 0;
	}

	if(a>=b){
		cout << 1;
		return 0;
	}

	while(true){
		if(b<=a){ // コンセントをフルで
			cnt++;
			break;
		}else{
			b-=(a-1);
			cnt++;
		}
	}

	cout << cnt;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

int gcd(int a,int b){
    return b ? gcd(b, a % b) : a;
}


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

    int w,h,n; cin >> w >> h >> n;
    vector<int> x(n),y(n),a(n);
    for(int i = 0;i < n;i ++) cin >> x.at(i) >> y.at(i) >> a.at(i);

    int xl = 0,xr = w,yu = h,yd = 0;

    for(int i = 0;i < n;i ++){
        if(a.at(i) == 1) xl = max(xl,x.at(i));
        if(a.at(i) == 2) xr = min(xr,x.at(i));
        if(a.at(i) == 3) yd = max(yd,y.at(i));
        if(a.at(i) == 4) yu = min(yu,y.at(i));
    }

    int bns = max(xr - xl,(int)0);
    int cns = max(yu - yd,(int)0);

    cout << bns * cns << endl;
}

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


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

    int count = 0;

    for(int i=1; i<=N; i++){
        if(i < 10){
            count++;
        }
        if(i > 99 && i < 1000){
            count++;
        }
        if(i > 9999 && i < 100000){
            count++;
        }
    }

    cout << count;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n), f(n);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> f[i];

    sort(ALL(a), greater<>());
    sort(ALL(f));

    auto check = [&](ll mid) {
        ll cnt = 0;
        REP(i, n) {
            // f[i] * (a[i] - j) <= mid
            ll j = max(0LL, a[i] - mid / f[i]);
            cnt += j;
        }
        return cnt <= k;
    };

    ll lb=-1, ub=INF;
    while(ub-lb>1) {
        ll mid = (lb+ub)/2;
        if(check(mid)) ub = mid;
        else lb = mid;
    }
    cout << ub << endl;

    return 0;
}

Measured memory_bytes: 3456
N,K=map(int,input().split())
a=list(map(int,input().split()))
a=sorted(a)
a.append(-1)

ans=[]
count=1

for i in range(N):
    if a[i+1]==a[i]:
        count += 1
    else:
        ans.append(count)
        count=1

ans=sorted(ans,reverse=True)

if K >= len(ans):
    print(0)
else:
    print(sum(ans[K:]))

Measured memory_bytes: 25644
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }


const int MAXN = 300;

int n, d1, d2;
vector<pair<int, int> > delta[2];
vector<pair<int, int>> adj[2][2 * MAXN][2 * MAXN];

int col[2][2 * MAXN][2 * MAXN];
int qx[2 * MAXN * 2 * MAXN], qy[2 * MAXN * 2 * MAXN], qhead, qtail;

pair<int, int> cur[2 * MAXN * 2 * MAXN]; int ncur;

void run() {
	scanf("%d%d%d", &n, &d1, &d2);

	FORE(dx, -2*n, +2*n) FORE(dy, -2*n, +2*n) {
		if (dx*dx + dy*dy == d1) delta[0].PB(MP(dx, dy));
		if (dx*dx + dy*dy == d2) delta[1].PB(MP(dx, dy));
	}
	REP(i, 2) REP(x, 2 * n) REP(y, 2 * n) REPSZ(j,delta[i]) {
		int nx = x + delta[i][j].first, ny = y + delta[i][j].second;
		if (nx < 0 || nx >= 2 * n || ny < 0 || ny >= 2 * n) continue;
		adj[i][x][y].PB(MP(nx, ny));
	}

	memset(col, -1, sizeof(col));
	REP(i, 2) REP(sx, 2 * n) REP(sy, 2 * n) if (col[i][sx][sy] == -1) {
		col[i][sx][sy] = 0; qhead = qtail = 0; qx[qhead] = sx, qy[qhead] = sy, ++qhead;
		while (qtail < qhead) {
			int x = qx[qtail], y = qy[qtail]; ++qtail;
			REPSZ(j, adj[i][x][y]) {
				int nx = adj[i][x][y][j].first, ny = adj[i][x][y][j].second;
				if (col[i][nx][ny] != -1) assert(col[i][nx][ny] != col[i][x][y]); else col[i][nx][ny] = 1 - col[i][x][y], qx[qhead] = nx, qy[qhead] = ny, ++qhead;
			}
		}
	}
	REP(c0, 2) REP(c1, 2) {
		ncur = 0;
		REP(x, 2 * n) REP(y, 2 * n) if (col[0][x][y] == c0&&col[1][x][y] == c1) cur[ncur++] = MP(x, y);
		if (ncur >= n*n) {
			REP(i, n*n) printf("%d %d\n", cur[i].first, cur[i].second);
			return;
		}
	}
	assert(false);
}

int main() {
	run();
	return 0;
}


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

const long long MOD =  1e9 + 7;

long long power(long long x, long long n, long long M){
  long long tmp = 1;

  if ( n > 0 ){
    tmp = power(x, n/2, M);
    if ( n%2 == 0 ) tmp = (tmp*tmp)%M;
    else tmp = (((tmp*tmp)%M)*x)%M;
  }
  return tmp;
}

int main() {
    int n;

    std::cin >> n;

    std::map<int, int> m;

    for(int i = 0; i < n; ++i) {
        int tmp;
        
        std::cin >> tmp;

        ++m[tmp];
    }

    if(n % 2 == 0) {
        if(m[0] != 0) {
            std::cout << 0 << std::endl;

            return 0;
        }
    }else {
        if(m[0] != 1) {
            std::cout << 0 << std::endl;

            return 0;
        }
    }

    m.erase(0);

    for(auto&& p : m) {
        if(p.second != 2) {
            std::cout << 0 << std::endl;

            return 0;
        }
    }

    std::cout << power(2, n / 2, MOD) << std::endl;
}

Measured memory_bytes: 3200
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

int n;
vector<int> a;
vector<int> path;
multiset<int> ign;
set<int> used;
clock_t st;

void solve(int idx, int now){
    path[idx] = now;
    if((double(clock()) - st) / CLOCKS_PER_SEC >= 2){
        cout << -1 << endl;
        exit(0);
    }
    if(idx == n - 1){
        for(int i = 0; i < n; ++i)
            cout << path[i] + 1 << " \n"[i == n - 1];
        exit(0);
    }

    used.erase(now);

    if(ign.size() >= 2){
        int ign_beg = *ign.begin();
        if(used.find(ign_beg) != used.end()){
            ign.erase(ign.find(a[ign_beg]));
            if(*ign.begin() == *ign.rbegin() && used.find(*ign.begin()) != used.end()){
                used.emplace(now);
                ign.insert(a[ign_beg]);
                return;
            }
            ign.insert(a[ign_beg]);
        }

        int ign_rbeg = *ign.rbegin();
        if(used.find(ign_rbeg) != used.end()){
            ign.erase(ign.find(a[ign_rbeg]));
            if(*ign.begin() == *ign.rbegin() && used.find(*ign.begin()) != used.end()){
                used.emplace(now);
                ign.insert(a[ign_rbeg]);
                return;
            }
            ign.insert(a[ign_rbeg]);
        }
    }


    ign.erase(ign.find(a[now]));

    for(auto it = used.begin(); it != used.end();){
        int val = *it;
        if(val != a[now])
            solve(idx + 1, val);
        it = used.upper_bound(val);
    }
    used.emplace(now);
    ign.insert(a[now]);
}


signed main(){
    long long N;
    st = clock();
    scanf("%lld",&N);
    std::vector<int> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%d",&A[i]);
    }
    n = move(N);
    a = move(A);
    path.assign(n, 150);
    for(int i = 0; i < n; ++i){
        used.emplace(i);
        --a[i];
        ign.insert(a[i]);
    }
    for(int i = 0; i < n; ++i)
        solve(0, i);
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 17296
#include <iostream>
#include <string>
using namespace std;
int main()
{
  long long N;
  cin >> N;
  string ans = "";
  do {
    int mod = N % 26;
    mod = (mod + 25) % 26;
    ans = (char)(mod +'a') + ans;
    N = (N-mod-1) / 26;
  } while (N > 0);
  cout << ans << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  vector<long> L(n);
  for(int i=0; i<n; i++){
    cin >> L[i];
  }
  long ans = 0;
  sort(L.begin(), L.end());
  for(int i=0; i<n-2; i++){
    for(int j=i+1; j<n-1; j++){
      for(int k=j+1; k<n; k++){
        if(L[i]+L[j] > L[k]){
          ans++;
          //cout << L[i] << L[j] << L[k] << endl;
        }else{
          break;
        }
      }
      
    }
    
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(S: int, W: int):
    if W >= S:
        print("unsafe")
    else:
        print("safe")
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    solve(S, W)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61704
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll MOD{ (ll)1e9 + 7 };

int n;
int a[300010];
priority_queue<ll, vector<ll>, greater<ll>> pq1;
priority_queue<ll> pq2;
ll sum1 = 0, sum2 = 0;
ll dp1[300010], dp2[300010];
ll ans = -1e18;

int main() {
	cin >> n;
	for(int i = 0; i < 3 * n; i++) {
		cin >> a[i];
		if (i < n) {
			pq1.push(a[i]);
			sum1 += a[i];
		}
		if(i >= 2 * n) {
			pq2.push(a[i]);
			sum2 += a[i];
		}
	}
	for(int i = n; i <= 2 * n; i++) {
		dp1[i] = sum1;
		sum1 += a[i];
		pq1.push(a[i]);
		sum1 -= pq1.top();
		pq1.pop();
	}
	for (int i = 2 * n - 1; i >= n - 1; i--) {
		dp2[i] = sum2;
		sum2 += a[i];
		pq2.push(a[i]);
		sum2 -= pq2.top();
		pq2.pop();
	}
	for (int i = n; i <= 2 * n; i++) {
		ans = max(ans, dp1[i] - dp2[i - 1]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6004
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define sl(c) (('a')<=(c)&&(c)<=('z'))
#define ll(c) (('A')<=(c)&&(c)<=('Z'))
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define makeupper(t) (transform(all(t),t.begin(),::toupper))
#define makelower(t) (transform(all(t),t.begin(),::tolower))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define NEXT_LINE string junk; getline(cin, junk);
#define output(v) do{rep(i,v.size())cout<<(i?" ":"")<<v[i];cout<<"\n";}while(0)
#define output2(v) rep(i,v.size()){rep(j,v[i].size()){cout<<(j?" ":"")<<v[i][j];}cout<<"\n";}
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
int main(){
    string s,t="";
    string u="AKIHABARA";
    cin>>s;
    lint now=0,i=0;
    while(1){
        if(i==(lint)u.size()){
            if(now==(lint)s.size())break;
            else {
                cout<<"NO";
                return 0;                
            }
        }
        if(s[now]==u[i]){
            now++;
            i++;
        }else if(u[i]=='A'){
            i++;
        }else{
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
    return 0;
}

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

def solve_2(num):
    if num > k:
        return k - (num-k) + 1
    else:
        return num + 1
ans = 0
first = 0
if s > 2*k:
    first = s -2*k
while first <= k:
    if s - first < 0:
        break
    ans += solve_2(s - first)
    first += 1

print(ans)


Measured memory_bytes: 2940
#include<stdio.h>
int gcd(int a,int b){
    if(a<b)return gcd(b,a);
    return b?gcd(b,a%b):a;
}
int main(){
    int a[100000],b[100000],c[100000],i,n,q,r=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",&a[i]);
    b[0]=a[0];
    for(i=1;i<n;i++)b[i]=gcd(b[i-1],a[i]);
    c[n-1]=a[n-1];
    for(i=n-1;i--;)c[i]=gcd(c[i+1],a[i]);
    r=c[1];
    if(r<b[n-2])r=b[n-2];
    for(i=1;i<n-1;i++)if(r<(q=gcd(b[i-1],c[i+1])))r=q;
    printf("%d",r);
    return 0;
}

Measured memory_bytes: 1280
use std::io;
use std::cmp;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();

    let whn: Vec<usize> = s.trim().split(' ').map(|x| x.parse().unwrap()).collect();

    let mut x1 = 0;
    let mut x2 = whn[0];
    let mut y1 = 0;
    let mut y2 = whn[1];

    for _ in 0..whn[2] {
        let mut s = String::new();
        io::stdin().read_line(&mut s).ok();

        let xya: Vec<usize> = s.trim().split(' ').map(|x| x.parse().unwrap()).collect();

        if xya[2] == 1 {
            x1 = cmp::max(x1, xya[0]);
        }
        else if xya[2] == 2 {
            x2 = cmp::min(x2, xya[0]);
        }
        else if xya[2] == 3 {
            y1 = cmp::max(y1, xya[1]);
        }
        else {
            y2 = cmp::min(y2, xya[1]);
        }
    }

    println!("{}",
        if x1 < x2 && y1 < y2 {
            (x2 - x1) * (y2 - y1)
        }
        else {
            0
        }
    );
}


Measured memory_bytes: 380
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,k,sum;
    cin>>a>>b>>c>>k;
    if(a>b&&a>c){
        for(int i=0;i<k;i++)
            a=a*2;
        sum=a+b+c;
    }
    else if(b>a&&b>c){
        for(int i=0;i<k;i++)
            b=b*2;
        sum=a+b+c;
    }
    else{
        for(int i=0;i<k;i++)
            c=c*2;
        sum=a+b+c;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  st s;
  ci(s);
  ll ans=700;
  FOR(i,0,3){
    if(s[i]=='o') ans+=100;
  }
  co(ans)
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;

int main()
{
//	freopen("input.txt","r",stdin);
	int k,x;
	cin>>k>>x;
	for(int i=x-k+1;i<=x+k-1;i++)
	{
		cout<<i<<' ';
	}
	cout<<endl;
	return 0;
}

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

int main(){
	int N, i, AC=0, WA=0, TLE=0, RE=0;
	cin >> N;
	string S[N];
	for(i=0; i<N; i++){
		cin >> S[i];
	}
	
	for(i=0; i<N; i++){
		if(S[i]=="AC")		AC++;
		else if(S[i]=="WA")	WA++;
		else if(S[i]=="TLE")	TLE++;
		else			RE++;
	}
	
	cout << "AC x " << AC << endl;
	cout << "WA x " << WA << endl;
	cout << "TLE x " << TLE << endl;
	cout << "RE x " << RE << endl;
	
	return 0;
}


Measured memory_bytes: 6720
/*
ABHIJEET BISWAS
CSE 4th SEM 
MNNIT ALLAHBAD
https://atcoder.jp/contests/dp/tasks/dp_r
*/

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1e18
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pli pair<long long,int>
#define pll pair<long long,long long>
#define MAX 1000009
#define pb push_back
#define mp map<int,int>
#define f first
#define s second
#define popi __builtin_popcount
#define popll __builtin_popcountll
#define grp vector<int> graph[MAX];
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll arr[51][51];
ll res[51][51];
ll temp[51][51];
ll n,k;
int multiply()
{
	
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		temp[i][j]=0;
	}
	for(int i=1;i<=n;i++)
	{
		for(int k=1;k<=n;k++)
		{
			for(int j=1;j<=n;j++)
			{
				temp[i][j]= (temp[i][j]+res[i][k]*arr[k][j])%MOD;
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		res[i][j]=temp[i][j];
	}
	
}
void power(ll b)
{
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	if(i==j)
	res[i][j]=1;
	else
	res[i][j]=0;
	while(b>0)
	{
		if(b&1)
		{
			multiply();
		}
		b=b/2;
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			temp[i][j]=0;
		}
		for(int i=1;i<=n;i++)
			{
				for(int k=1;k<=n;k++)
				{
					for(int j=1;j<=n;j++)
					{
						temp[i][j]= (temp[i][j]+arr[i][k]*arr[k][j])%MOD;
					}
				}
			}
			for(int i=1;i<=n;i++)
			{
				for(int j=1;j<=n;j++)
				arr[i][j]=temp[i][j];
			}
	}
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	arr[i][j]=res[i][j];
}
int main() {
	fastIO
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		cin>>arr[i][j];
	}
	power(k);
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		ans=(ans+arr[i][j])%MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

#include<stack>
vector<vi> g;
void visit(int v, vector< vector<int> >& scc,
    stack<int> &S, vector<bool> &inS,
    vector<int> &low, vector<int> &num, int& time) {
  low[v] = num[v] = ++time;
  S.push(v); inS[v] = true;
  each(e, g[v]) {
    int w = *e;
    if (num[w] == 0) {
      visit(w, scc, S, inS, low, num, time);
      low[v] = min(low[v], low[w]);
    } else if (inS[w])
      low[v] = min(low[v], num[w]);
  }
  if (low[v] == num[v]) {
    scc.push_back(vector<int>());
    while (1) {
      int w = S.top(); S.pop(); inS[w] = false;
      scc.back().push_back(w);
      if (v == w) break;
    }
  }
}
void stronglyConnectedComponents(vector< vector<int> >& scc) {
  const int n = g.size();
  vector<int> num(n), low(n);
  stack<int> S;
  vector<bool> inS(n);
  int time = 0;
  rep(u, n) if (num[u] == 0)
    visit(u, scc, S, inS, low, num, time);
}

const int mod = (int)1e9 + 7;
int n, m, to[2000], deg[2000];
ll rec(const vector<vi> &e, int c){
	ll res = 1;
	each(i, e[c]) (res *= rec(e, *i)) %= mod;
	return res + 1;
}

int main(){
	cin >> n >> m;
	g.resize(n);
	rep(i, m){
		int a, b;
		cin >> a >> b;
		g[b - 1].pb(a - 1);
	}
	vector<vi> scc;
	stronglyConnectedComponents(scc);
	set<pi> es;
	int N = scc.size();
	vector<vi> e(N + 1);
	
	rep(i, N) each(j, scc[i]) to[*j] = i;
	rep(i, n) each(j, g[i]){
		int a = to[i], b = to[*j];
		if(es.count(mp(a, b)) || a == b) continue;
		es.insert(mp(a, b));
		e[a].pb(b);
		deg[b]++;
	}
	rep(i, N) if(deg[i] == 0) e[N].pb(i);
	cout << (rec(e, N) + mod - 1) % mod << endl;
	return 0;
}

Measured memory_bytes: 1428
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      
      int a, b, c, d, e;
      
      cin >> a >> b >> c >> d >> e; 
      
      if (a == 0){
        cout << 1 << endl;
      }
      
      else if (b == 0){
        cout << 2 << endl;
      }
        
      else if (c == 0){
        cout << 3 << endl;
      }
      
      else if (d == 0){
        cout << 4 << endl;
      }
      
      else if (e == 0){
        cout << 5 << endl;
      }
      
      
    }

Measured memory_bytes: 3592
while (line = gets)
  n, s = line.chop.split(" ").map{|s| s.to_i}

  if n == 0 && s == 0
    break
  end

  digs = (0..9).map{|k| k}
  count = 0

  digs.combination(n) do |arr|
    if arr.inject{|s,i| s + i } == s
      count += 1
    end
  end

  puts count
end

Measured memory_bytes: 6104
import itertools
n, g = map(int, input().split())
L = []
for i in range(n):
    t = list(map(int, input().split()))
    # 配点
    t.append((i+1)*100)
    # この配点の問題を全部解いた時の得点
    t.append((i+1)*100*t[0]+t[1])
    L.append(t)
# print(L)

ans = g//100
# https://img.atcoder.jp/abc104/editorial.pdf bit全探索
for i in range(2**n):
    count = 0
    score = 0
    m = 0
    for j in range(n):
        if (i >> j) & 1:
            score += L[j][3]
            count += L[j][0]
        else:
            m = j
    # print(bin(i), m, score, count)
    if score >= g:
        ans = min(ans, count)
    else: # 解いていない配点の問題の中で一番配点が高いもの
        if (g - score)/L[m][2] <= L[m][0] and (g - score)%L[m][2] == 0:
            count += (g - score)//L[m][2]
        elif (g - score)/L[m][2] + 1 <= L[m][0]:
            count += ((g - score)//L[m][2])+1
        else:
            count = g//100
        ans = min(ans, count)
    # print(bin(i), m, L[m], score, count)
print(ans)

# 全探索したら時間超過
# ans = 100 * n
# for v in itertools.permutations(L):
#     score = 0
#     count = 0
#     k = 0
#     p = v[k][0]
#     while score < g:
#         score += v[k][2]
#         p -= 1
#         count += 1
#         if p == 0:
#             score += v[k][1]
#             k += 1
#             if k < n:
#                 p = v[k][0]
#     ans = min(ans, count)
# print(ans)

# DPっぽく解こうとしたけど失敗
# P = []
# G = []
# for i in range(n):
#     s, t = map(int, input().split())
#     P.insert(0, s)
#     G.insert(0, t//100)
# score = 0
# k = 0
# count = 0
# while score < g:
#     count += 1
#     if 1 in P:
#         j = P.index(1)
#         score += n-j + G[j]
#         P[j] = 0
#         if j == k:
#             k += 1
#     else:
#         score += n-k
#         P[k] -= 1
#     print(P,G,score,count,k)
# print(count)

Measured memory_bytes: 3064
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

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

int main() {
	int a, b;
	string s;
	cin >> a >> b >> s;
	for (int i = 0; i < a; i++) {
		if ("0" <= s.substr(i, 1) && s.substr(i, 1) <= "9") {

		}
		else {
			cout << "No" << endl;
			return 0;
		}
	}
	if (s.substr(a, 1) != "-") {
		cout << "No" << endl;
		return 0;
	}
	for (int i = a + 1; i < a + b + 1; i++) {
		if ("0" <= s.substr(i, 1) && s.substr(i, 1) <= "9") {

		}
		else {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <set>
#include <map>
using namespace std;

void solve(vector<string> arr) {
    /*
    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < 9; j++) {
            cout << arr[i][j];
            if ((j+1)%3 == 0) {
                cout << " ";
            }
        }
        cout << endl;
        if ((i+1)%3 == 0) {
            cout << endl;
        }
    }
    */

    int i = 0;
    for (int k = 0; k < 3; k++) {
        int tmp = k;
        for (int j = 1; j <= 3; j++) {
            arr[i][tmp] = arr[i][tmp] == '1' ? '2' : '1';
            tmp+=3;
            i+=1;
        }
    }


    /*
    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < 9; j++) {
            cout << arr[i][j];
            if ((j+1)%3 == 0) {
                cout << " ";
            }
        }
        cout << endl;
        if ((i+1)%3 == 0) {
            cout << endl;
        }
    }
    */
    for (string s : arr) {
        cout << s << endl;
    }

}

int main()
{
    int n;
    cin >> n;
    unordered_map<long long int, long long int> m;
    long long int tot = 0;
    for (int i = 0; i < n; i++) {
        long long int x;
        cin >> x;
        m[x]++;
        tot += x;
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int b, c;
        cin >> b >> c;
        tot -= m[b]*b;
        tot += m[b]*c;
        m[c] += m[b];
        m[b] = 0;
        cout << tot << endl;
    }



}


Measured memory_bytes: 6884
package main

import (
	"fmt"
	"io"
	"os"
	"runtime"
)

func run(input io.Reader, output io.Writer) int {
	var s string
	fmt.Scanf("%s\n", &s)
	var q int
	fmt.Scanf("%d\n", &q)

	head := true
	left := make([]byte, 0)
	right := make([]byte, 0)
	for i := 0; i < q; i++ {
		var t int
		fmt.Scanf("%d", &t)

		if t == 1 {
			head = !head
			if runtime.GOOS == "windows" {
				fmt.Scanf("\n")
			}
		} else {
			var f int
			var c byte
			fmt.Scanf("%d %c\n", &f, &c)
			if (head && f == 1) || (!head && f == 2) {
				left = append(left, c)
			} else {
				right = append(right, c)
			}
		}
	}

	var ans []byte
	S := []byte(s)
	if head {
		for l, r := 0, len(left)-1; l < r; l, r = l+1, r-1 {
			left[l], left[r] = left[r], left[l]
		}
		ans = append(ans, left...)
		ans = append(ans, S...)
		ans = append(ans, right...)
		fmt.Printf("%s\n", string(ans))
	} else {
		for l, r := 0, len(right)-1; l < r; l, r = l+1, r-1 {
			right[l], right[r] = right[r], right[l]
		}
		for l, r := 0, len(S)-1; l < r; l, r = l+1, r-1 {
			S[l], S[r] = S[r], S[l]
		}
		ans = append(ans, right...)
		ans = append(ans, S...)
		ans = append(ans, left...)
		fmt.Printf("%s\n", string(ans))
	}
	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


Measured memory_bytes: 5888
private fun getInts(): LongArray {
    return readLine()!!.split(" ").map {it.toLong()}.toLongArray()
}


fun main(){
    getInts()
    val v =getInts()
    var count = 0
    for (i in v.indices){
        for (j in i+1 until v.size) {
            for (k in j+1 until v.size) {
                if (noteq3(v[i],v[j],v[k]) && isTriangle(v[i],v[j],v[k])){
                    count++
                }
            }
        }
    }
    print(count)
}

private fun noteq3(i:Long,j:Long,k:Long):Boolean {
    return (i != j) && (j != k) && (k != i)
}
private fun isTriangle(a:Long,b:Long,c:Long):Boolean {
    return (a+b>c)&&(b+c>a)&&(c+a>b)
}

Measured memory_bytes: 38720
#-*-coding:utf-8-*-

def main():
    turns = int(input())
    animals=[]
    scores=[0,0]
    for _ in range(turns):
        animals=list(input().split())
        if animals[0]==animals[1]:
            scores[0]+=1
            scores[1]+=1
        elif  animals[0]>animals[1]:
            scores[0]+=3
        else:
            scores[1]+=3
    print(*scores)

if __name__=="__main__":
    main()


Measured memory_bytes: 5608
#include <iostream>
#include <set>
#include <string>

using namespace std;

int main() {
  int n;
  cin >> n;
  
  string s;
  set<string> seen;
  cin >> s;
  char c = s[s.size() - 1];
  bool ok = true;
  seen.insert(s);
  for (int i = 1; i < n; i++) {
    cin >> s;
    if ((s[0] != c) || (seen.find(s) != seen.end())) {
      ok = false;
    }
    seen.insert(s);
    c = s[s.size() - 1];
  }
  cout << (ok ? "Yes" : "No");
}


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

using namespace std;

#define ll long long

//Tumhe kya laga me code nahi kar sakta, me sab kar sakta hai,
//kyunki hindustan ka yuva sirf hindustan ko nahi desh ko badal sakta hai

int main()
{
	string s;
	cin>>s;
	string ans;
	for(int i = 0;i<s.size();i++)
	{
		ans+='x';
	}
	cout<<ans;
	return 0;
}

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

char Grading(int m,int f,int r){
	if((m==-1)||(f==-1)){
		return 'F';
	}else if((m + f)>= 80 ){
		return 'A';
	}else if((m + f)>= 65){
		return 'B';
	}else if((m+f) >= 50){
		return 'C';
	}else if((m+f)>=30){
		if(r>=50){
			return 'C';
		}
		return 'D';
	}else{
		return 'F';
	}
}

int main()
{
	int m,r,f;
	cin>>m>>r>>f;
	while( (m!=-1) || (r!=-1) || (f!=-1)){
		cout<<Grading(m,r,f)<<endl;
		cin>>m>>r>>f;
	}
	return 0;
}

Measured memory_bytes: 3032
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> P;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n;cin>>n;
    string s;cin>>s;
    if(n<=2){
        cout<<0<<endl;
        return 0;
    }
    ll ans=0;
    ll sum[n][3];
    memset(sum,0,sizeof sum);
    ll b[n];
    rep(i,0,n){
        if(s[i]=='R')b[i]=0;
        else if(s[i]=='G')b[i]=1;
        else b[i]=2;
    }
    rep(i,0,n){
        rep(j,1,i){
            if(b[i]==b[j])continue;
            ll num=3-b[i]-b[j];
            ll t=sum[j-1][num];
            if(2*j-i>=0&&b[2*j-i]==num)t--;
            ans+=t;
        }
        rep(k,0,3){
            if(i>0)sum[i][k]=sum[i-1][k];
        }
        sum[i][b[i]]++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3776
#include<stdio.h>
int main(void){
  int d,t,s;
  scanf("%d %d %d",&d,&t,&s);
  if(d<(t*s+1)){
  	printf("Yes\n");
  }else{
  	printf("No\n");
  }
  
  return 0;
  
}


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

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

    if(a%2 == b%2) {
        out((b-a)/2);
    }
    else {
        if(a-1 <= n-b) {
            out(a + (b-a-1)/2 );
        }
        else {
            ll x = n-b+1;
            out( x + (n - (a+x))/2 );
        }
    }
    
    re0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
int N,A,B,C; 
int check(vector<int> &l, int num,int a,int b,int c){
    if (num == N){
        if (a == 0 || b == 0 || c == 0){
            return MM;
        } else {
            return abs(a-A) + abs(b-B) + abs(c-C);
        }
    }
    int mn = MM;
    mn = min(mn,check(l, num+1,a,b,c));
    mn = min(mn,check(l, num+1,a, b + l[num], c) + (b > 0 ? 10 : 0));
    mn = min(mn,check(l, num+1,a + l[num], b, c) + (a > 0 ? 10 : 0));
    mn = min(mn,check(l, num+1,a, b, c + l[num]) + (c > 0 ? 10 : 0));
    return mn;
}

int main(){
    cin >> N >> A >> B >> C;
    vector<int> l(N);
    
    for (int i = 0; i < N; i++){
        cin >> l[i];
    }
    cout << check(l,0,0,0,0);
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    string s, ans="";
    cin >> s;
    for(auto i : s){
        if(i == 'B'){
            if(!ans.empty()){
                ans.pop_back();
            }
        }else{
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#define forn(i, n) for (long long i = 0; i < (long long) (n); ++i)
#define pb emplace_back
#define endl '\n'

template<typename T> void _dbg(const char*_s,T _h) { cerr<<_s<<" = "<<_h<<"\n"; }

template<typename T, typename... Ts> void _dbg(const char*_s,T _h,Ts... _t) {
    for(int _b=0;((_b+=*_s=='(')-=*_s==')')!=0||*_s!=',';)cerr<<*_s++;
    cerr<<" = "<<_h<<",";_dbg(_s+1,_t...);
}

#define int long long

#ifdef LOCAL
    #define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
    #define dbg(...)
#endif

const int N = 500 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n;

bool read() {
    if (!(cin >> n))
        return false;

    return true;
}

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

    return a;
}

void solve(int id = 0) {
    int sum = 0;

    forn (i, n)
        forn (j, n)
            forn (k, n)
                sum += gcd(i + 1, gcd(j + 1, k + 1));

    cout << sum << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    T = 1;

    while (read())
        solve(T++);

    return 0;
}



Measured memory_bytes: 3652
package main

import (
	"fmt"
)

func main() {
	var r, g, b, n int
	fmt.Scan(&r, &g, &b, &n)

	var cnt int
	for i := 0; i <= n/r; i++ {
		for j := 0; j <= n/g; j++ {
			bk := n - r*i - g*j
			if bk >= 0 && bk%b == 0 {
				cnt++
			}
		}
	}

	fmt.Println(cnt)
}


Measured memory_bytes: 1772
#include <iostream>
#include<string>

using namespace std;

bool cal_string_palindrome(string Y){
    int num;
    num=Y.size();
    for(int i=0;i<=(num-1)/2;i++){
        char s1 = Y[i];
        char s2 = Y[num-1-i];
//        cout << s1 << ":" << s2 << endl;
        if (s1 != s2){
            return false;
        }
    }
    return true;
}


int main(){
    string X;
    bool ans1,ans2,ans3;
    int N;
    cin >> X;
    N=X.size();
    ans1=cal_string_palindrome(X);
    ans2=cal_string_palindrome(X.substr(0,(N-1)/2));
    ans3=cal_string_palindrome(X.substr((N+3)/2-1,(N-1)/2));
    if(ans1 ==true and ans2 ==true and ans3 ==true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())

if K == 0:
    print(N * N)
    exit()

ans = 0
for b in range(K + 1, N + 1):
    ans += (N // b) * (b - 1 - K + 1)
    ans += max(N % b + 1 - K, 0)

print(ans)


Measured memory_bytes: 2940
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
//#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;

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

    ll a,b,c,n,f=0,mini=INF;
    ll sum=0,maxi=0;
    string str,sub;
    ll h,w;
    ll m,k,d;
    ll x;
    cin>>n>>x;
    n++;
    vector<ll> v(n);
    rep(i,n-1)cin>>v[i];
    rep(i,n-1) v[i]-=x;
    v[n-1]=0;
    sort(v.begin(),v.end());
    //rep(i,n) cout<<v[i]<<" ";
    //cout<<endl;
    mini=v[1]-v[0];
    rep(i,n-1){
        mini=__gcd(mini,abs(v[i+1]-v[i]));
    //    cout<<mini<<" ";
    }
    cout<<mini<<endl;
    return 0;
}


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

using namespace std;


#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 2e6 + 1, MOD = 1e9 + 7, mod = 998244353, INF = 3e17;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;


signed main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);
   int A, B, C;
   cin >> A >> B >> C;
   int ans = 0;
   ans+= min(A, C);
   C = max(C - A, 0ll);
   ans+= min(C, B) * 2;
   int k = min(C, B);
   C-= k, B-= k;
   if (C) ans++;
   cout << ans + B;
}


Measured memory_bytes: 256