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

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    using P = pair<int, int>;
    vector<pair<int, int>> b;
    bool flag = false;
    rep(i, n) {
        if (flag) {
            chmax(b.back().second, a[i]);
            if (i != n-1 && a[i] > a[i+1]) {
                flag = false;
            }
        } else {
            if (i != n-1 && a[i] < a[i+1]) {
                b.push_back(P(a[i], 0));
                flag = true;                
            }
        }
    }
    ll now = 1000;
    ll kabu = 0;
    rep(i, b.size()) {
        if (b[i].first < b[i].second) {
            kabu = now / b[i].first;
            now %= b[i].first;
            now += kabu * b[i].second;
            kabu = 0;
        }
    }

    cout << now << endl;
    // vector<int> mx(n);
    // mx[n-1] = a[n-1];
    // for (int i = n-2; i >= 0; --i) {
    //     chmax(mx[i], mx[i+1]);
    //     chmax(mx[i], a[i]);
    // }
    // ll now = 1000;
    // ll kabu = 0;
    // ll buy_price = -1;
    // rep(i, n) {
    //     if (i == n-1) {
    //         now += kabu * a[i];
    //         break;
    //     }
    //     if (buy_price == -1) {
    //         if (a[i] < mx[i]) {
    //             kabu += now / a[i];
    //             now %= a[i];
    //             buy_price = a[i];
    //         }
    //     } else {
    //         if (buy_price < a[i]) {
    //             now += kabu * a[i];
    //             kabu = 0;
    //             buy_price = -1;
    //         }
    //     }
    //     cout << now << endl;
    // }
    // cout << now << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long 
#define INF (ll)1e18 + 50
#define MAXN (int)2e5 + 50
#define fi first
#define se second
#define MOD 1000000007
#define all(v)((v).begin()), ((v).end())
#define A 911382323
#define B 972663749

inline bool check(ll n)
{
	if(n == 1) return 0;
	if(n == 2) return 1;
	
	for(ll i = 2; i*i <= n; i++)
		if(n % i == 0) return 0;
	
	return 1;
}

int32_t main() {
    
    ll a; cin >> a;
    ll resp = 0;
    for(ll i = a; ; i++)
    {
   		if(check(i))
   		{
   			resp = i;
   			break;
   		}
   	}
    
    cout << resp;
    
}

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


int main(void) {
	int digitsum[1000];
	char words[10000];
	int cnt = 0;
	//??????????????\???
	while (fgets(words, sizeof(words), stdin)) {
		//????????°???????????????
		int i;
		int digit[1000];
		for (i = 0; i <strlen(words)-1 ; i++) {
			digitsum[cnt] +=(words[i]-'0') ;
		}
		if (digitsum[cnt] == 0)break;
		cnt++;
	}
	int i;
	for (i = 0; i < cnt; i++) {
		printf("%d\n", digitsum[i]);

	}
	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

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

	string ans = "No";
	if (abs(a - c) <= d || (abs(b - a) <= d&&abs(b - c) <= d))
	{
		ans = "Yes";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <set>
#include <map>
#include <complex>
#include <iostream>
#include <time.h>
#include <stack>
#include <stdlib.h>
#include <memory.h>
#include <bitset>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>

using namespace std;

const int MaxN = 1e5 + 10;
const int MOD = 1e9 + 7;
const int INF = 1e9;

pair < double, double > p[MaxN];
pair < double, char > all[MaxN];
int n, k;

bool can(double rad) {
  int res = 1;
  for (int i = 1; i <= n && res < k; ++i) {
    int c = 1, sz = 0;
    for (int j = 1; j <= n; ++j) {
      if (i == j) {
        continue;
      }
      double d = hypot(p[i].first - p[j].first, p[i].second - p[j].second);
      if (d / 2 > rad) {
        continue;
      }
      pair < double, double > v = make_pair((p[j].first - p[i].first) / d, (p[j].second - p[i].second) / d);
      double l1 = d / 2;
      double l2 = sqrt(rad * rad - l1 * l1);
      l1 /= rad;
      l2 /= rad;
      pair < double, double > p1 = make_pair(v.first * l1 + v.second * l2, v.second * l1 - v.first * l2);
      pair < double, double > p2 = make_pair(v.first * l1 - v.second * l2, v.second * l1 + v.first * l2);
      double ang1 = atan2(p1.second, p1.first);
      double ang2 = atan2(p2.second, p2.first);
      if (ang1 > ang2) {
        c++;
      }
      all[sz++] = make_pair(ang1, 1);
      all[sz++] = make_pair(ang2 + 1e-10, -1);
    }
    sort(all, all + sz);
    for (int j = 0; j < sz; ++j) {
      c += all[j].second;
      if (res < c) {
        res = c;
      }
    }
  }
  return res >= k;
}

int main() {

  cin >> n ;
  k=n;
  for (int i = 1; i <= n; ++i) {
    cin >> p[i].first >> p[i].second;
  }
  random_shuffle(p + 1, p + n + 1);
  double l = 0, r = 1e4;
  for (int it = 0; it < 1000; ++it) {
    double m = (l + r) / 2;
    if (can(m)) {
      r = m;
    } else {
      l = m;
    }
  }
  cout.precision(10);
  cout << fixed << (l + r) / 2.0 << '\n';
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{self, prelude::*};

#[allow(unused_must_use)]
#[allow(unused_assignments)]
#[allow(unused_variables)]
fn solve<B: BufRead, W: Write>(mut scan: Scanner<B>, mut w: W) {
    let n: usize = scan.token();
    let mut sum: u128 = 0;

    for i in 1..=n {
        if i%3 == 0 || i%5== 0 {
            continue;
        }
        sum += i as u128;
    }

    let ans = sum;
    writeln!(w, "{}", ans);
}
 
fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    let reader = Scanner::new(stdin.lock());
    let writer = io::BufWriter::new(stdout.lock());
    solve(reader, writer);
}
#[allow(dead_code)]
fn vector_to_str<T: ToString>(vector: &Vec<T>, separator: &str) -> String { 
    use std::fmt::Write;
    let mut ans = String::new();
    for line in vector.iter() {
        write!(&mut ans, "{}{}", line.to_string(), separator).unwrap();
    }
    ans
}
#[allow(dead_code)]
fn matrix_to_str<T: ToString>(matrix: &Vec<Vec<T>>, separator: &str) -> String { 
    use std::fmt::Write;
    let mut ans = String::new();
    for line in matrix.iter() {
        for elem in line.iter() {
            write!(&mut ans, "{}{}", elem.to_string(), separator).unwrap();
        }
        write!(&mut ans, "\n").unwrap();
    }
    ans
}
pub struct Scanner<B> {
    reader: B,
    buf_str: Vec<u8>,
    buf_iter: std::str::SplitWhitespace<'static>,
}
impl<B: BufRead> Scanner<B> {
    pub fn new(reader: B) -> Self {
        Self {
            reader,
            buf_str: Vec::new(),
            buf_iter: "".split_whitespace()
        }
    }
    pub fn token<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buf_iter.next() {
                return token.parse().ok().expect("Failed parse");
            }
            self.buf_str.clear();
            self.reader.read_until(b'\n', &mut self.buf_str).expect("Failed read");
            self.buf_iter = unsafe {
                let slice = std::str::from_utf8_unchecked(&self.buf_str);
                std::mem::transmute(slice.split_whitespace()) }
        }
    }
    pub fn get_matrix<T: std::str::FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>> {
        // m rows and n columns
        let mut ans: Vec<Vec<T>> = Vec::with_capacity(m);
        for i in 0..m {
            ans.push(Vec::with_capacity(n));
            for _ in 0..n {
                ans[i].push(self.token::<T>());
            }
        }
        ans
    }
    pub fn get_vector<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        let mut ans: Vec<T> = Vec::with_capacity(n);
        for _ in 0..n {
            ans.push(self.token::<T>());
        }
        ans
    }
}


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

int main() {
  string s;
  cin >> s;
  if(s[0] == s[1]){
    cout << "Bad";
  }
  else if(s[1] == s[2]){
    cout << "Bad";
  }
  else if(s[2] == s[3]){
    cout << "Bad";
  }
  else{
    cout << "Good";
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

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

    int N, M; cin >> N >> M;
    vector<vector<pair<int,int>>> vec(N+1);
    vector<int> p(M), y(M);

    rep(i, M){
        int y; cin >> p[i] >> y;
        vec[p[i]].push_back(make_pair(y, i));
    }
    repr(i, 1, N+1) sort(vec[i].begin(), vec[i].end());

    vector<pair<int, int>> ans(M);
    repr(i, 1, N+1){
        rep(j, vec[i].size()){
            ans[vec[i][j].second].second = j+1;
        }
    }
    rep(i, M) ans[i].first = p[i];
    

    rep(i, M) printf("%06d%06d\n", ans[i].first, ans[i].second);

    return 0;
}

Measured memory_bytes: 8576
// Problem : 
// 			A - Irreversible operation
// 			Editorial
// 		
// Contest : AtCoder - AtCoder Grand Contest 029
// URL : https://atcoder.jp/contests/agc029/tasks/agc029_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define sz(x)             (int)x.size()
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*(b/gcd(a,b)))
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
#define watch(x)         cout << #x << " = " << x << endl
#define trace(x)         cerr << #x << " = " << x << endl
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){
    
	string s; cin>>s;
	vi black(len(s),0);
	int cnt = 0, res = 0;
	int i = 0;
	for(char c : s){
		if(c=='B') cnt++;
		black[i] = cnt;
		i++;
	}
	for(i = 0;i<len(s);i++){
		if(s[i]=='W') res += black[i];
	}
	cout<<res;
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

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

int main(){
    int n,q,t,x,y;
    cin>>n>>q;
    queue<int>a[n];
    for(int i=0;i<q;i++){
        cin>>t;
        if(t==0){
            cin>>x>>y;
            a[x].push(y);
        }
        else if(t==1){
            cin>>x;
            if(!a[x].empty())cout<<a[x].front()<<endl;
        }
        else if(t==2){
            cin>>x;
            if(!a[x].empty())a[x].pop();
        }
    }
    return 0;
}


Measured memory_bytes: 4244
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+3;


int main(){

    int n;
    cin>>n;

    bool flag = false;
    int cmpt = 0;
    for(int a,b,i=0;i<n;i++){
        cin>>a>>b;
        if(a==b){
            cmpt++;
        }
        else{
            cmpt=0;
        }
        if(cmpt>=3){
            flag = true;
        }
    }

    if(flag)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3644
#!/usr/bin/env python

n=int(input())
S=[0] * n

min_charas={}

# 入力の選択
for i in range(0, n):
    charas={}
    # 文字の選択とカウント
    for k in input():
        try:
            charas[k] += 1
        except KeyError:
            charas[k] = 1
    
    # 文字の最小数をカウント
    if(i==0):
        min_charas = charas
    else:
        for j in min_charas:
            try:
                if(min_charas[j] > charas[j]):
                    min_charas[j] = charas[j]
            except KeyError:
                # print("Key", j)
                min_charas[j] = 0
                continue
    
    # print(charas)

# print(min_charas)

for i in sorted(min_charas):
    for j in range(0, min_charas[i]):
        print(i, end='')
print()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
struct Restorant {
    int num;
    int score;
    string city;
};
bool compare(Restorant a, Restorant b) {
    int cmp = a.city.compare(b.city);
    if(cmp == 0) {
        return a.score > b.score;
    }
    else {
        return cmp < 0;
    }
}
int main() {
    int N;
    cin>>N;
    struct Restorant res[N];
    for(int i=0;i<N;i++) {
        res[i].num = i+1;
        cin>>res[i].city>>res[i].score;
    }
    sort(res, res+N,compare);
    for(int i=0;i<N;i++) {
        cout<<res[i].num<<"\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s,t;
  cin >> s >> t;
  int a,b;
  cin >> a >> b;
  string u;
  cin >> u;
  if(u == s)cout << a-1 << " " << b << endl;
  else if(u == t) cout << a << " " << b-1 << endl;
}

Measured memory_bytes: 3516
#include<stdio.h>
#define MAX 100000


int main()
{
        char str[MAX];
        int abc[26] = {0};
        int i;

        scanf("%s", str);

        for(i=0; str[i]!='\0'; i++)
        {
                abc[str[i]-'a']++;
        }

        for(i=0; i<26; i++)
        {
                if(abc[i]==0)
                {
                        printf("%c\n", i+'a');
                        return 0;
                }
        }

        printf("None\n");
        return 0;
}


Measured memory_bytes: 256
# Problem https://atcoder.jp/contests/abc113/tasks/abc113_b
# Python 3rd Try


class Problem:
    def __init__(self, allnumber, maxthermo, avepoint, highs):
        self.allnumber = allnumber
        self.maxthermo = maxthermo
        self.avepoint = avepoint
        self.highs = highs

    def problemprint(self):
        print(self.allnumber)
        print(self.maxthermo)
        print(self.avepoint)
        print(self.highs)

    def solve(self):
        maxdiff = 100000.0
        result = 1
        for j in range(0, self.allnumber):
            difftemp = abs(self.avepoint-(self.maxthermo-self.highs[j]*0.006))
#            print('{}->{}'.format(maxdiff,difftemp))
            if difftemp < maxdiff:
                maxdiff = difftemp
                result = j+1
        return result


if __name__ == "__main__":
    N = int(input())
    T, A = map(float, input().split(' '))
    HI = list(map(float, input().split(' ')))
    print(Problem(N, T, A, HI).solve())
#    print(Problem(2, 12.5, 5.0, [1000.0, 2000.0]).solve())
#    print(Problem(3, 21.0, 11.0, [81234.0, 94124.0, 52141.0]).solve())


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    string S;
    cin >> S;
    int s = 0;
    while (s < S.size()) {
        if (S.substr(s, 7) == "dreamer") {
            if (s+7 < S.size() && S.at(s+7) == 'a') s += 5;
            else s += 7;
        } else if (S.substr(s, 5) == "dream") {
            s += 5;
        } else if (S.substr(s, 6) == "eraser") {
            s += 6;
        } else if (S.substr(s, 5) == "erase") {
            s += 5;
        } else {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
    char s[3];
    scanf("%s",s);
    if(s[0] != s[1] && s[1] != s[2] && s[2] != s[0]){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
N = int(input())
insu_list = [[2, 0]]
ans = 1

for i in range(N):
    n = i+1
    for j in range(len(insu_list)):
        while n % insu_list[j][0] == 0:
            n /=insu_list[j][0]
            insu_list[j][1] += 1
    if n != 1:
        insu_list.append([n, 1])
for i in range(len(insu_list)):
    ans *= insu_list[i][1] + 1
print(ans%(10**9+7))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();
    int k = scan.nextInt();

    boolean[] res = new boolean[n];
    for (int i = 0; i < n; i++) {
      res[i] = false;
    }

    for (int i = 0; i < k; i++) {
      int d = scan.nextInt();
      for (int j = 0; j < d; j++) {
        int tmp = scan.nextInt();
        tmp--;
        if (res[tmp] == false) {
          res[tmp] = true;
        }
      }
    }

    int cnt = 0;

    for (int i = 0; i < n; i++) {
      if (res[i] == false) {
        cnt++;
      }
    }

    System.out.println(cnt);

  }

}

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

int h, w;
string m[1005];
long long dp[1005][1005];

long long mod=1000000007;

int main (){
	
	cin >> h >> w;
	for (int i=0; i < h; i++)
		cin >>m[i];
		
	dp[0][0]=1;
		
	for (int i=0; i < h; i++)
		for (int j=0; j < w; j++)
		{
			if (i==0 && j==0) continue;
			if (m[i][j]!='#')
			{
				if (i>0) dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
				if (j>0) dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
			}
		}
		
	
	cout << dp[h-1][w-1];
	
	return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<ii> vii;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr(be, en) for(int i = be; i <= en; i++) 
int main()
{
	ios_base::sync_with_stdio(false);
	cout.tie(NULL);
	cin.tie(NULL);
	int n;
	string s;
	cin  >> n >> s;
	vi r, g, b;
	set<int> sr, sg, sb;
	for(int i = 0; i < s.size(); i++)
	{
		if(s[i] == 'R') 
		{
			r.pb(i + 1);
			sr.insert(i + 1);
		}
		if(s[i] == 'G')
		{
			g.pb(i + 1);
			sg.insert(i + 1);
		}
		if(s[i] == 'B') 
		{
			sb.insert(i + 1);
			b.pb(i + 1);
		}
	}
	map<int, int> hm;
	map<int, int> :: iterator it;
	vi :: iterator itv1, itv2;
	int num = 0;
	ll ans = 0;
	for(int i  = 0; i < g.size(); i++)
	{
		for(int j = 0; j < b.size(); j++)
		{
			itv1 = lower_bound(r.begin(), r.end(), b[j]);
			itv2 = lower_bound(r.begin(), r.end(), g[i]);
			if((b[j] + g[i])%2 == 0)
			{
				if(sr.find((b[j] + g[i])/2) != sr.end()) ans--;
			}
			ans += abs(itv2 - itv1);
		}
	}
	// cout << ans << "\n";
	for(int i  = 0; i < b.size(); i++)
	{
		for(int j = 0; j < r.size(); j++)
		{
			itv1 = lower_bound(g.begin(), g.end(), b[i]);
			itv2 = lower_bound(g.begin(), g.end(), r[j]);
			if((b[i] + r[j])%2 == 0)
			{
				if(sg.find((b[i] + r[j])/2) != sg.end()) ans--;
			}
			ans += abs(itv2 - itv1);
		}
	}
	// cout << ans << "\n";
	for(int i  = 0; i < g.size(); i++)
	{
		for(int j = 0; j < r.size(); j++)
		{
			itv1 = lower_bound(b.begin(), b.end(), r[j]);
			itv2 = lower_bound(b.begin(), b.end(), g[i]);
			if((r[j] + g[i])%2 == 0)
			{
				if(sb.find((r[j] + g[i])/2) != sb.end()) ans--;
			}
			ans += abs(itv2 - itv1);
		}
	}
	cout << ans ;
}

Measured memory_bytes: 3828
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Long a = sc.nextLong();
		Long b = sc.nextLong();
        Long c = sc.nextLong();
        if(c>a+b && 4*a*b < (c-a-b)*(c-a-b)){System.out.println("Yes");}
        else{System.out.println("No");}
	}
}


Measured memory_bytes: 23124
n , m = map(int,input().split())
iki = set()
nori = set()
for i in range(m):
    a , b = map(int,input().split())
    if a == 1:
        iki.add(b)
    if b == n:
        nori.add(a)

if iki.isdisjoint(nori):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Measured memory_bytes: 19024
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn=1e5+5;
ll a[maxn];
int main(){
	ll n,m;
	ll x=1;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(x>1e9) continue;
		x=x*a[i]/2/__gcd(x,a[i]/2);
	}
	int flag=0;
	for(int i=0;i<n;i++){
		ll t=x*2/a[i];
		if(t%2==0){
			flag=1;
			break;
		}
	}
	if(flag) {
		printf("0\n");
		return 0;
	}
	ll k=m/x;
	if(k&1) printf("%lld\n",k/2+1);
	else printf("%lld\n",k/2);
}

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

int main() {
  int N;
  cin >> N;
  int count = 0;
  int tmpCount = 0;

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

    int tmpNum = 0;
    cin >> tmpNum;

    while(1){
      
      if(tmpNum%2==0){
        tmpCount++;
      }else{
        break;
      }

      tmpNum  /= 2;

    }

    if(i==0){
      count = tmpCount;
    }else{
      if(count > tmpCount){
        count = tmpCount;
      }
    }

    tmpCount = 0;

  }

  cout << count << endl;

}


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

void printvec(vi& a, int n) {
    cout << a.front();
    for (int i = 1; i < n; i++) {
        cout << " " << a[i];
    }
    cout << endl;
}

void insertionsort(vi& a, int n) {
    for (int i = 1; i < n; i++) {
        int v = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > v) {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
        printvec(a, n);
    }
}

int main() {
    int n;
    vi as;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        as.push_back(a);
    }
    printvec(as, n);
    insertionsort(as, n);
}


Measured memory_bytes: 3152
#include <cstdio>
#include <cstring>
#include <cmath>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <utility>

using namespace std;
#define LL long long
#define pb push_back
#define mk make_pair
#define pill pair<int, int>
#define ft first
#define sd second
#define mst(a, b)	memset(a, b, sizeof a)
#define REP(i, x, n)	for(int i = x; i <= n; ++i)
const int qq = 2e5 + 10;
const int MOD = 1e9 + 7;
int n, m;
bool a[qq], b[qq];

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; ++i) {
		int x, y;	scanf("%d%d", &x, &y);
		if(x == 1) {
			a[y] = true;
		}
		if(x == n) {
			b[y] = true;
		}
		if(y == 1) {
			a[x] = true;
		}
		if(y == n) {
			b[x] = true;
		}
	}
	if(a[n] == true || b[1] == true) {
		puts("POSSIBLE");
		return 0;
	}
	for(int i = 1; i <= n; ++i) {
		if(a[i] && b[i]) {
			puts("POSSIBLE");
			return 0;
		}
	}
	puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;cin>>n;
    int S[n];
    for(int i=0;i<n;i++){
        cin>>S[i];
    }
    int q;cin>>q;
    int T[q];
    for(int i=0;i<q;i++){
        cin>>T[i];
    }
    int sum=0;
    for(int i=0;i<q;i++){
        if(*lower_bound(S,S+n,T[i])==T[i]) sum++;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3672
// A.

#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	if (n <= 1) {
		cout << "Hello World" << endl;
	} else {
		int a, b;
		cin >> a >> b;
		cout << (a + b) << endl;
	}
	return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,ans=0;
    cin>>n;
    ll c[n];
    for(int i=0;i<n;i++){
        cin>>c[i];
    }
    sort(c,c+n);
    reverse(c,c+n);
    n--;
    for(int i=0;i<=n;i++){
        ans+=(((c[i]*modpow(2,2*n))%mod)*(i+2))%mod;
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,a,b; cin>>n>>a>>b;
    vector<int> ans(3,0);
    rep(i,n){
        int p; cin>>p;
        if(p<=a) ans[0]++;
        else if(p>=b+1) ans[2]++;
        else ans[1]++; 
    }
    cout<<min(ans[0],min(ans[1],ans[2]))<<endl;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
  ll t;
 // cin>>t;
 // while(t--){
  ll a,b=0,c=0,d=0,e=0;
  string s;
  cin>>s;
  b=s.length();
  for(ll i=0;i<b;i++){d=d+(s[i]-'0');}
   
   if(d%9==0){cout<<"Yes";}
   else{cout<<"No";}
 // }
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define double long double
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = a; i < (int)(b); ++i)

using namespace std;

int32_t main() {
    int n, k;
    cin >> n >> k;
    int h[n + 1];
    FOR(i, 1, n + 1) {
        cin >> h[i];
    }
    int d[n + 1];
    d[1] = 0;
    FOR(i, 2, n + 1) {
        int mn = INT32_MAX;
        FOR(j, 1, k + 1) {
            if (i - j <= 0) {
                break;
            }
            int cur = d[i - j] + abs(h[i] - h[i-j]);
            if (cur < mn) {
                mn = cur;
            }
        }
        d[i] = mn;
    }
    cout << d[n];
    return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	int a0=0,a2=0;
	for(int i=0;i<n;++i){
		int a,t=0; cin>>a;
		if(a%4==0)++a2;
		else if(a%2!=0)++a0;
	}
	cout<<(a2-a0>=0||a2-a0>=-1&&a2+a0==n?"Yes"s:"No"s)<<"\n"s;
}

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

typedef pair<int, int> P;

void Main() {
  int H, W, M;
  cin >> H >> W >> M;

  set<P> obj;
  for (int i = 0; i < M; i++) {
    int h, w;
    cin >> h >> w;
    obj.insert(P(h, w));
  }

  map<int, int> row, col;
  int row_maxval = 0, col_maxval = 0;
  for (P tmp: obj) {
    row_maxval = max(row_maxval, ++row[tmp.first]);
    col_maxval = max(col_maxval, ++col[tmp.second]);
  }
  vector<int> max_rows, max_cols;
  for (auto r: row) {
    if (r.second == row_maxval) max_rows.push_back(r.first);
  }
  for (auto c: col) {
    if (c.second == col_maxval) max_cols.push_back(c.first);
  }

  int ans = row_maxval + col_maxval - 1;
  for (auto h: max_rows) {
    for (auto w: max_cols) {
      if (obj.find(P(h, w)) == obj.end()) {
        cout << ans + 1 << endl;
        return;
      }
    }
  }
  cout << ans << endl;
}


int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

/*

*.*
.*.
**.

**.
...
*..

...*.
.**.*
....*
..*..
*.***

*/


Measured memory_bytes: 49612
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#define LL long long
using namespace std;
#define maxn 100007

struct node
{
    LL to;
    LL len;
};
vector <node> edge[maxn];
LL a[maxn];
LL vis[maxn];
LL flag=1;
void dfs(LL i)
{
    vis[i]=1;
    if(flag==0) return;
    if(edge[i].size()==0) return;
    for(LL j=0;j<edge[i].size();j++)
    {
        LL k=edge[i][j].to;
        if(a[k]!=-1&&a[k]!=edge[i][j].len+a[i])
        {
            flag=0;
        }
        a[k]=edge[i][j].len+a[i];
        if(flag==0) return;
        if(!vis[k]) dfs(k);
    }
}
int main()
{
    //freopen("in.txt","r",stdin);
    LL n,m,l,r,x,y,d,i,j,k;
    scanf("%I64d%I64d",&n,&m);
    for(i=1;i<=n;i++)
        a[i]=-1;
    node f,ne;
    while(m--)
    {
        scanf("%I64d%I64d%I64d",&l,&r,&d);
        f.to=r;
        f.len=d;
        edge[l].push_back(f);
        f.to=l;
        f.len=-d;
        edge[r].push_back(f);
    }
    for(i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            a[i]=1;
            dfs(i);
        }
        if(flag==0) break;
    }
    if(flag) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 17280
using System;
using System.Collections.Generic;

public class CSharp
{
    public static void Main()
    {
        Kyopuro chokudai = new Kyopuro();
        chokudai.AtCoder();
    }
}

public class Kyopuro
{

    int n, m;
    bool[][] s;
    int[] k, p;

    public void AtCoder()
    {
        string[] input;
        input = Console.ReadLine().Split(' ');
        n = int.Parse(input[0]);
        m = int.Parse(input[1]);
        k = new int[m];
        p = new int[m];
        s = new bool[m][];

        for(int i=0; i<m; i++)
        {
            input = Console.ReadLine().Split(' ');
            k[i] = int.Parse(input[0]);
            s[i] = new bool[n];
            for(int j=1; j<=k[i]; j++)
            {
                s[i][int.Parse(input[j]) - 1] = true;
            }
        }
        input = Console.ReadLine().Split(' ');
        for (int i = 0; i < m; i++) p[i] = int.Parse(input[i]);

        int b = (int)Math.Pow(2, n);
        int ans = 0;
        bool f = false;
        int[] q = new int[m];
        for(int i=0; i<b; i++)
        {
            f = true;
            q = new int[m];
            for(int j=0; j<n; j++)
            {                
                if((i >> j) % 2 == 1)
                {
                    for(int a=0; a<m; a++)
                    {
                      
                        if (s[a][j])
                        {
                            q[a]++;                        
                        }
                    }
                }
            }
            for(int j=0; j<m; j++)
            {
                if (q[j] % 2 != p[j]) f = false;
            }
            
            if (f) ans++;
        }

        Console.WriteLine(ans);
    }
    public static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	int ans = 6 - a- b;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repp(i,a,b)	for(ll int i=b-1;i>=a;i--)
#define tr(container,it) for(__typeof__(container.begin()) it = container.begin(); it != container.end(); it++)
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define mpi         map<pair<ll int,ll int>,ll int>
#define vii         vector<pair<ll,pair<ll,ll> > >
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;
#define N  100005
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

ll me(ll a,ll b){
	if(b==0) return 1;
	if(b%2) return (a*me((a*a)%hell,b/2))%hell;
	return me((a*a)%hell,b/2)%hell;
}

void solve(){
	ll n,k;
	cin>>n>>k;
	ll a[k+5]={0};
	repp(i,1,k+1){
		ll x=k/i;
		a[i]=me(x,n);
		for(ll j=2*i;j<=k;j+=i){
			a[i]=(a[i]+hell-a[j])%hell;
		}
	}
	ll an=0;
	rep(i,1,k+1){
		an=(an+a[i]*i)%hell;
	}
	cout<<an%hell;
}	

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll TESTS=1,an=1;
	// cin>>TESTS;
	while(TESTS--){
		// cout<<"Case #"<<an<<": ";
		an++;
		solve();

	}
	return 0;
}


Measured memory_bytes: 4436
package main

import (
	"fmt"
	"sort"
)

func main() {
	var a, b, c, d, e int
	fmt.Scan(&a, &b, &c, &d, &e)
	dataset := []int{a, b, c, d, e}

	sort.Sort(sort.Reverse(sort.IntSlice(dataset)))
	fmt.Printf("%d %d %d %d %d\n", dataset[0], dataset[1], dataset[2], dataset[3], dataset[4])
}



Measured memory_bytes: 1160
#include<cstdio>
#include<cstring>
#include<algorithm>
const int MAXN=100010;
int h[MAXN],f[MAXN];
 
int main(){
	int n,k;scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&h[i]);
	memset(f,0x3f,sizeof(f));
	f[1]=0;
	for(int i=2;i<=n;i++){
		for(int j=1;j<=std::min(i-1,k);j++)
			f[i]=std::min(f[i],std::abs(h[i]-h[i-j])+f[i-j]);
	}
	printf("%d\n",f[n]);
}


Measured memory_bytes: 896
#include<iostream>
#include<string>
using namespace std;
string s;
char f(char a)
{
  if(a=='b')return 'd';
  if(a=='d')return 'b';
  if(a=='p')return 'q';
  if(a=='q')return 'p';
}
int main()
{
  cin>>s;
  for(int i=0;i<s.size();i++)
    if(s[i]!=f(s[s.size()-i-1])){cout<<"No";return 0;}
  cout<<"Yes";
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define f first
#define s second
#define sz(x) (ll)x.size()
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> osSet;

using pll = pair<ll, ll>;

const ll maxN = 1e5;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

ll func(ll x){
	return (x*(x+1))/2;
}

ll _pow(ll b, ll p){
	if(p == 0) return 1;
	if(p == 1) return b;
	ll exB = b*b;
	if(p&1) return b*_pow(exB, p/2);
	return _pow(exB, p/2);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll a, b, c;
	cin >> a >> b >> c;
	if(a != b and a !=c)
		cout << a;
	else if(b !=a and b!=c)
		cout << b;
	else
		cout << c;
	return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>          // printf(), fgets()
#include <stdlib.h>         // strtod()

const char NUL = '\0';

int
main(int argc, char **argv)
{
	char line[81];
	double stack[20];
	char *nextp = NULL;

	while (fgets(line, sizeof(line), stdin) != NULL)
	{
		double a, b;
		double d;
		int sp = 0;

		const char *s = line;
		while (*s != '\n' && *s != NUL)
		{
			while (*s == ' ')
				s++;

			d = strtod(s, &nextp);
			if (s != nextp)
			{
				stack[sp++] = d;
				s = nextp;
			}
			else
			{
				b = stack[--sp];
				a = stack[--sp];
				switch (*s)
				{
				case '+':
					d = a + b;
					break;

				case '-':
					d = a - b;
					break;

				case '*':
					d = a * b;
					break;

				case '/':
					d = a / b;
					break;
				}

				stack[sp++] = d;
				s++;
			}
		}

		d = stack[--sp];
		printf("%.8f\n", d);
	}

	return 0;
}

Measured memory_bytes: 584
#include <stdio.h>

int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  if (a+b == 15) {
    puts("+");
  }
  else if (a*b == 15) {
    puts("*");
  }
  else {
    puts("x");
  }
  return 0;
}

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

char s[200010];
int main()
{
	int i,n=0;
	scanf("%s",s+1);
	for(i=1;s[i];i++)
		n+=(s[i]-'0');
	if(n%9==0) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

// aを常に小さい値にする　大きい値にする
template<class T> bool chmin(T &a, T b){
    if(a>b) {
        a = b;
        return true;
    }
    return false;

}
template<class T> void chmax(T &a, T b){ if(a<b) a = b; }

// 二分探索 前方のindexを返すもの（自分自身を含む） 前方: -INF側のこと
template<class T> int former(const vector<T> &v, T x){
    return upper_bound(v.begin(), v.end(), x) - v.begin() -1; // upper_bound : keyより大きい要素の内の一番左側のイテレータを返す
}
// 二分探索 後方のindexを返すもの（自分自身を含む）後方: INF側のこと
template<class T> int latter(const vector<T> &v, T x){
    return lower_bound(v.begin(), v.end(), x) - v.begin(); // lower_bound : key以上の要素の内の一番左側のイテレータを返す
}

// 最大公約数を求める GCD
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
// loopで書くなら
/*
 * int gcd(int a, int b){
 *     int r;
 *     while( (r = a % b) != 0 ) {
                a = b;
                b = r;
       }
       return b;
 * }
 *
 * */

/*
 * 複数の最大公約数に関して　前提知識として配列[a,b,c]のgcdはgcd(gcd(a,b),c)であることは知っておこう
 * つまり、累積和を用いる
 *
 * 問題は「N 個の値の中から 1 個だけ取り除いた N−1 個の整数の最大公約数の最大値を求める」こととなる
 *
 * つまり i番目を除いた、最大公約数を求めて、i:0->Nまで動かして最大公約数の最大を取ればよい
 * i番目を除いた最大公約数を累積和(累積GCDといった方が正確)を求めておく
 *
 * この際にA1, A2, ... Ai-1, Ai, Ai+1, ... An-1
 *        -------①--------     ------②-------
 *  ①と⓶の部分のGCDを求めておくと、楽にできる
 *
 *  left[p] := 区間 [0,p) の最大公約数
 *  right[p] := 区間 [p,N) の最大公約数
 *
 *  こうしておけば、

    前処理: O(NlogA)
    集計: O(NlogA)

    で求められる


    ----------------------なぜ右からの累積 GCD も必要か----------------------------
    今回の問題が累積 GCD じゃなくて、累積和だったなら、実は

    right[p] := 区間 [p,N) の累積和
    は要らなくて、

    left[p] := 区間 [0,p) の累積和
    だけで OK。これで区間 [l,r) の和は

    left[r]−left[l]
    で求められるのだ。だが今回の累積 GCD には「 - 」に対応する機能がない。引き算ができない。よって、区間 [p,N) についての GCD を求めるには右からの累積 GCD が必要になる。
 *
 * */

int main() {

    string S;
    cin >> S;

    // 0スタート
    int count0 = 0;
    rep(i, S.size()){
        if(i % 2 ==  0 && S[i] != '0') {
            count0++;
        }else if(i % 2 ==  1 && S[i] != '1'){
            count0++;
        }
    }

    // 1スタート
    int count1 = 0;
    rep(i, S.size()){
        if(i % 2 ==  0 && S[i] != '1') {
            count1++;
        }else if(i % 2 ==  1 && S[i] != '0'){
            count1++;
        }
    }

    int res = 0;
    if(count0 > count1){
        res = count1;
    }else{
        res = count0;
    }
    cout << res << endl;
}

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

int main()
{
ll n ;
cin >> n ;
vector<ll> a(n);
rep(i, n){
  cin >> a[i];
}
priority_queue<pair<ll,ll>> q;
vector<ll> b(n);
rep(i, n){
  cin >> b[i];
  q.push({b[i],i});
}
auto mod = [&](ll modx){modx%=n;modx+=n;modx%=n;return modx;};

while(q.size()!=0){
pair<ll,ll> p=q.top();
q.pop();
if(b[p.second]==a[p.second])continue;
ll te=b[mod(p.second+1)]+b[mod(p.second-1)];
ll ma=max(b[mod(p.second+1)],b[mod(p.second-1)]);
if(ma>a[p.second]){
  ans+=(b[p.second]-ma-1)/te +1;
  b[p.second]-=(b[p.second]-ma-1)/te *te;
  b[p.second]-=te;
  if(b[p.second]<a[p.second]){cout << -1 << endl;return 0;}
  q.push({b[p.second],p.second});
}
else{
  ans+=(b[p.second]-a[p.second])/te;
  b[p.second]-=(b[p.second]-a[p.second])/te *te;
  if(b[p.second]!=a[p.second]){cout << -1 << endl;return 0;}
}
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 9456
N, A, B = map(int, input().split())
S = input()

for c in S:
    if c == 'b':

        B -= 1
        if B >= 0 and (A+B) >= 0:
            print("Yes")
        else:
            print("No")
    elif c == 'a':
        A -= 1
        if (A+max(0, B)) >= 0:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 4016
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll x, y;
  cin >> x >> y;
  ll ans = 0;
  while (x <= y) {
    x *= 2;
    ans += 1;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,k,count=0;
    cin >> a >> b >> k;
    
    if(a < b){
        c = a;
    }else{
        c = b;
    }
    for(int i = c ; i > 0 ; i--){
        if(a%i == 0 && b%i ==0){
            count++;
            if(count == k){
                cout << i;
            }
        }
    } 
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint c[4005][4005];
void init() {
    c[0][0] = 1;
    rep(i, 4001) {
        rep(j, 4001) {
            c[i+1][j] += c[i][j];
            c[i+1][j+1] += c[i][j];
        }
    }
}

mint comb(int n, int k) {
    if(k < 0) return 0;
    return c[n][k];
}

mint f2(int n, int k) {
    return comb(n+k-1, k-1);
}

mint f(int n, int k) {
    if(n < k) return 0;
    if(n==0 && k==0) return 1;
    if(k < 1) return 0;
    return f2(n-k, k);
}

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

    EFOR(i, 1, k) {
        mint blue = f(k, i);
        mint red = 0;

        red += f(n-k, i-1);
        red += f(n-k, i);
        red += f(n-k, i);
        red += f(n-k, i+1);

        mint ans = blue*red;
        cout << ans.x << endl;
    }

    return 0;
}


Measured memory_bytes: 125568
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s, t;
    cin, s, t;
    int ss = s.size(), tt = t.size();
    int ans = 1 << 30;
    REP(i, 0, ss - tt + 1) {
        int cnt = 0;
        REP(j, 0, tt) {
            cnt += s[i + j] != t[j];
        }
        chmin(ans, cnt);
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 3640
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

minutes = [A, B, C, D, E]
diff = []

for i in minutes:
    if i % 10 == 0:
        diff.append(0)
    else: diff.append(10 - (i % 10))

print(sum(minutes) + sum(diff) - max(diff))        


Measured memory_bytes: 3060