akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>
#include <bitset>
#include <chrono>

using namespace std;
using namespace std::chrono;
typedef long long ll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()

class solver {
public:
	int D;
	vector<ll> c;
	vector<vector<ll>> s;

	void init() {
		cin >> D;
		c.resize(26);
		s.resize(D);
		rep(i, 26) {
			cin >> c[i];
		}
		rep(j, D) {
			s[j].resize(26);
			rep(i, 26) {
				cin >> s[j][i];
			}
		}
	}

	vector<ll> calc(const vector<int>& t) const {
		vector<int> last(26);
		auto down = [&last, this](int d) {
			d++;
			ll v = 0;
			rep(i, 26) {
				v += c[i] * (d - last[i]);
			}
			return v;
		};
		int N = t.size();
		vector<ll> v(N);
		rep(i, N) {
			if (i > 0)
				v[i] = v[i - 1];
			v[i] += s[i][t[i]];
			last[t[i]] = i + 1;
			v[i] -= down(i);
		}
		return v;
	}

	vector<int> greedy() const {
		vector<pair<ll, int>> cs;
		rep(i, 26) {
			cs.emplace_back(c[i], i);
		}
		sort(all(cs), greater<pair<ll, int>>());

		vector<vector<pair<ll, int>>> ss(D);
		rep(j, D) {
			rep(i, 26) {
				ss[j].emplace_back(s[j][i], i);
			}
			sort(all(ss[j]), greater<pair<ll, int>>());
		}

		vector<int> ans;
		for (auto& i : ss) {
			vector<int> ts(ans);
			ts.push_back(i[0].second);
			auto as = calc(ts);
			vector<int> tc(ans);
			tc.push_back(cs[0].second);
			auto ac = calc(tc);
			if (as.back() > ac.back())
				ans.push_back(i[0].second);
			else
				ans.push_back(cs[0].second);
		}

//		/*
//t[1..D] = 初期解(ランダム生成や、貪欲法で求めたものを利用)
//while 時間のある限り:
//	d と q をランダムに選ぶ。
//	old = t[d] # 後で戻せるように元の値を記憶しておく
//	t[d] = q
//	if 変形前より解が悪化:
//		t[d] = old
//		*/
//		system_clock::time_point start = system_clock::now();
//
//		for (;;) {
//			system_clock::time_point now = system_clock::now();
//			double elapsed = duration_cast<milliseconds>(now - start).count();
//			if (elapsed > 1900)
//				break;
//		}
//
		return ans;
	}
};

int main()
{
	solver solver;
	solver.init();
	auto ans = solver.greedy();
	for (auto t : ans) {
		cout << (t + 1) << endl;
	}
	return 0;
}


Measured memory_bytes: 4044
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int r;
	cin >> r;
	if(r<1200) cout << "ABC" << endl;
	else if(r<2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;

	return 0;
}

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

int main() {
    vector<int> v(3);
    cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(), v.end());
    int res = 0;
    res = v[1] - v[0] + v[2] - v[1];
    cout << res << endl;
}

Measured memory_bytes: 256
import sys
n, *lst = map(int, sys.stdin.read().split())
copy = sorted(lst)
max1, max2 = copy[-1], copy[-2]

if max2 < max1:
  for j in lst:
    if j != max1:
      print(max1)
    else:
      print(max2)
else:
  for j in lst:
    print(max1)

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

using namespace std;

int main(void){
	int N, K, S; 
	cin >> N >> K >> S;
	if (S != 1000000000){
		for (int i = 0; i < K; ++i)
			cout << S << " ";
		for (int i = K; i < N; ++i)
			cout << (1000000000) << " ";
	}
	else{
		for (int i = 0; i < K; ++i)
			cout << (1000000000) << " ";
		for (int i = K; i < N; ++i)
			cout << "1 ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb push_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;


const ll modo=1e9+7;
const ll inf=2e14;
const ll ms=(2e5) +5;



int main()
{
    idfc;
    int n,m;
    cin>>n>>m;
    int mx=max(n,m);
    int mn=min(n,m);
    for(int i=0;i<mx;i++)cout<<mn;
}

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

namespace dijkstra_n {
template<class W>
struct Edge {
	using type = Edge<W>;
	int to;
	W w;
	template<class... Args> Edge(int t, Args... args) : to(t), w(args...) {}
	inline bool operator<(const Edge& rhs) const { return w < rhs.w; }
	inline bool operator>(const type& rhs) const { return rhs < *this; }
	inline bool operator>=(const type& rhs) const { return !(*this < rhs); }
	inline bool operator<=(const type& rhs) const { return !(rhs < *this); }
	inline bool operator==(const type& rhs) const { return !(*this < rhs) && !(rhs < *this); }
	inline bool operator!=(const type& rhs) const { return (*this < rhs) || (rhs < *this); }
};
template<class W>
struct Edges : private vector<vector<Edge<W>>> {
	using type = vector<vector<Edge<W>>>;
	template<class... Args> Edges(Args... args) : type(args...) {}
	template<class... Args> void add_edge(int u, int v, Args... args) {
		(*this)[u].emplace_back(v, args...);
	}
	using type::begin; using type::end; using type::rbegin; using type::rend;
	using type::cbegin; using type::cend; using type::crbegin; using type::crend;
	using type::size; using type::operator[]; using type::at; using type::back; using type::front;
	using type::reserve; using type::resize; using type::assign; using type::shrink_to_fit;
	using type::clear; using type::erase; using type::insert; using type::swap; 
	using type::push_back; using type::pop_back; using type::emplace_back; using type::empty;
};
template<class W>
struct Graph {
	const int sz;
	Edges<W> e;
	Graph(int n) : sz(n), e(sz) {}
	template<class... Args> void add_edge(int u, int v, Args... args) {
		e.add_edge(u, v, args...);
	}
	int size() {
		return sz;
	}
};
template<class W, class T = W>
struct Graph_D : public Graph<W> {
	vector<T> dist;
	Graph_D(int n) : Graph<W>(n), dist(n) {}
};
template<class W, class T>
void Dijkstra(Graph_D<W, T>& g, int start, T INF_COST) {
	auto& dist = g.dist;
	auto& e = g.e;
	for (auto& ww : dist) ww = INF_COST;
	using Q_T = pair<T, int>;
	priority_queue<Q_T, vector<Q_T>, greater<>> q;
	q.emplace(0, start);
	while (!q.empty()) {
		auto a = q.top();
		q.pop();
		if (a.first >= dist[a.second]) continue;
		dist[a.second] = a.first;
	for (auto& p : e[a.second]) {
			if (p.w == INF_COST) continue;
			if (a.first + p.w < dist[p.to]) q.emplace(a.first + p.w, p.to);
		}
	}
}
}
using dijkstra_n::Dijkstra;
template<class T, class U = T> using graph = dijkstra_n::Graph_D<T, U>;

int main() {
    int n; cin >> n;
    graph<int> g(n);
    for (int i = 0; i < n; i++) {
        int v, k; cin >> v >> k;
        while (k--) {
            int u, c; cin >> u >> c;
            g.add_edge(v, u, c);
        }
    }
    Dijkstra(g, 0, INT_MAX);
    for (int i = 0; i < n; i++) {
        cout << i << " " << g.dist[i] << endl;
    }
}


Measured memory_bytes: 9616
N = gets.to_i
a = N.times.map{gets.split.map(&:to_i)}

NONE = -1
root = 0
$t = {}

def preParse(u)
  return if u == NONE
  print " #{u}"
  preParse($t[u][:l])
  preParse($t[u][:r])
end

def inParse(u)
  return if u == NONE
  inParse($t[u][:l])
  print " #{u}"
  inParse($t[u][:r])
end

def postParse(u)
  return if u == NONE
  postParse($t[u][:l])
  postParse($t[u][:r])
  print " #{u}"
end

(0...N).each do |i|
  $t[i] = {p: NONE, l: NONE, r: NONE}
end

a.each do |a|
  v, l, r = a

  $t[v][:l] = l
  $t[v][:r] = r
  $t[l][:p] = v unless l == NONE
  $t[r][:p] = v unless r == NONE
end

(0...N).each do |i|
  root = i if $t[i][:p] == NONE
end

puts 'Preorder'
preParse(root)
print "\n"
puts 'Inorder'
inParse(root)
print "\n"
puts 'Postorder'
postParse(root)
print "\n"


Measured memory_bytes: 6884
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
const ld pi = 3.14159265358979323846;
//ll MOD = 1e9 + 7;
ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
void solve(){
    ll n;
    cin>>n;
    ll a[n];
    fo(i,n)cin>>a[i];
    ll left[n],right[n];
    left[0] = a[0],right[n-1] = a[n-1];
    foa(i,1,n){
        left[i] = a[i]^left[i-1];
    }
    fod(i,n-2,0){
        right[i] = a[i]^right[i+1];
    }
    ll b[n];
    b[0] = right[1];
    b[n-1] = left[n-2];
    foa(i,1,n-1){
        b[i] = left[i-1]^right[i+1];
    }
    fo(i,n){
        cout<<b[i]<<" ";
    }
    cout<<nl;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";


}


Measured memory_bytes: 9972
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
using namespace std;
#define INF 1LL<<62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[4]={0,0,1,-1},dy[4]={1,-1,0,0};

signed main(){
    int H,W,sh,sw,K;
    cin>>H>>W>>K;
    char A[1000][1000];
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cin>>A[i][j];
            if(A[i][j]=='S'){
                sh=i; sw=j;
            }
        }
    }
    int d[1000][1000];
    for(int i=0;i<1000;i++){
        for(int j=0;j<1000;j++) d[i][j]=1000000;
    }
    queue<P> que;
    que.push(P(sh,sw));
    d[sh][sw]=0;
    while(!que.empty()){
        P x=que.front(); que.pop();
        int nowh=x.first,noww=x.second;
        for(int i=0;i<4;i++){
            int nexth=nowh+dx[i],nextw=noww+dy[i];
            if(nexth>0 && nextw>0 && nexth<=H && nextw<=W && A[nexth][nextw]=='.' && d[nexth][nextw]==1000000){
                d[nexth][nextw]=d[nowh][noww]+1;
                que.push(P(nexth,nextw));
            }
        }
    }
    int ans=1000000;
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            if(d[i][j]>K) continue;
            chmin(ans,(i-1+K-1)/K+1);
            chmin(ans,(H-i+K-1)/K+1);
            chmin(ans,(j-1+K-1)/K+1);
            chmin(ans,(W-j+K-1)/K+1);
        }
    }
    cout<<ans<<endl;



}


Measured memory_bytes: 5120
#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);

    ll N, K; cin >> N >> K;
    vector<ll> a(N+1, 0), cum(N+1, 0);
    repr(i, 1, N+1) cin >> a[i];
    repr(i, 1, N+1) cum[i] = cum[i-1] + a[i];
    repr(i, 1, N+1) cum[i] -= i, cum[i] %= K;

    // rep(i, N+1) cout << cum[i] << ' ';
    // cout << endl;

    map<int, ll> mp;
    ll ans = 0;
    // K = 1　の時　あまりは絶対０だけど、長さ０の区間はない！！
    rep(r, N+1){
        ans += mp[cum[r]];
        mp[cum[r]]++;
        if(r-K+1>=0) mp[cum[r-K+1]]--;
    }
    cout << ans << endl;
    

    return 0;
}


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

 
int main() {
  // 科目の数Nを受け取る
  string s;
  cin >> s;
  
  int sum = 0;
  
  for (int i = 0; i < s.size() ; i++){
  
    if(s.at(i) == '1'){
      sum += 1;
      }
  }
  cout << sum << endl;

}

Measured memory_bytes: 3620
import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########
n,k=map(int,input().split())
D=list(map(str,input().split()))

for i in range(n,10**6):
    if any([j in D for j in str(i)]) ==0:
        print(i);exit()


Measured memory_bytes: 10024
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false); //cin.tie(NULL); cout.tie(NULL)
#define mp make_pair
#define pb push_back
#define fs first
#define sc second

using namespace std;
typedef long long ll;
typedef long double ld;


/* BIEN CUC BO BEGIN*/
	int a, b, A[100000+2];
/* BIEN CUC BO END*/

void solve(){	
	cin >> a >> b;
	for (int i=1; i<=a; ++i){
		int k; cin >> k;
		for (int i=1; i<=k; ++i){
			int x; cin >> x;
			A[x]++;
		}
	}
	
	int ans = 0;
	for (int i=1; i<=b; ++i){
		if (A[i] == a) ++ans;
	}
	cout << ans;
}	

int main(){ FIO;
	solve();
return 0;}

Measured memory_bytes: 256
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto N = readln.chomp.to!long;
    auto n = N;
    auto S = 0;
    while (n > 0) {
        S += n % 10;
        n /= 10;
    }
    writeln(N % S == 0 ? "Yes" : "No");
}



Measured memory_bytes: 256
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let x = v[0];
	if x == 7 || x == 5 || x == 3 {
		println!("YES");
	}else{
		println!("NO");
	}
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t x){
	if(was_output)cout << " ";
	was_output = true;
	cout << x;
}

void outendl(){
	was_output = false;
	cout << endl;
}

int main(){
	int n;
	cin >> n;
	vector<int> line(n);
	foreach(i, line)cin>>i;
	sort(all(line));
	line.push_back(10000);
	int ans = 0;
	rep(i, n){
		for(int j=i+2;j<n;++j){
			int l = lower_bound(all(line), line[j]-line[i]+1)-line.begin();
			ans += max(0, min(j-i-1, j-l));
		}
	}

	cout << ans << endl;

	return 0;
}



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

int main()
{
	int n, K, min = 0, max = 0, P;
	scanf("%d %d", &n, &K);

	vector<int> w(n);
	for (int &x: w) {
		scanf("%d", &x);
		min = min > x ? min : x;
		max += x;
	}
	min -= 1;
	
	for (;;) {
		P = (max + min) / 2;
		auto i = w.begin(), e = w.end(), j = i;
		int k = 0;
		for (; i != e && j != e && k < K; i++, k++) {
			int p = 0;
			for (j = i; j != e; j++) {
				if (p + *j > P) {
					i = j - 1;
					break;
				} else if (p + *j == P) {
					i = j;
					break;
				} else
					p += *j;
			}
		}
		if ((i == e || j == e) && k <= K)
			max = P;
		else
			min = P;
		if (max == min + 1) {
			P = max;
			break;
		}
	}
	printf("%d\n", P);
}


Measured memory_bytes: 2772
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
 
	// Use ctrl+shift+b ( second option )
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
 
	string s;
	cin >> s;
	string r = s.substr(0,3);

	cout << r << endl ;


	
}


Measured memory_bytes: 3608
import java.util.*;
public class Main{
	public static void main(String[] args){
		long ans = 0;
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		
		for(int i=1; i<=Math.sqrt(n); i++){
			if(n % i == 0 && n/i-i > 1){
				ans += n/i-1;
			}
		}
		
		System.out.println(ans);
	}
}


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

int main() {
  string s;
  cin>>s;
  int gg=0;
  int pp=0;
  int ans=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='p'){
      if(pp<gg){
        pp++;
      }
      else{
        gg++;
        ans--;
      }
    }
    else{
      if(pp<gg){
        pp++;
        ans++;
      }
      else{
        gg++;
      }
    }
  }
  cout << ans;
}


Measured memory_bytes: 512
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define PI					acos(-1.0)
#define vi					vector<int>
#define vii					vector<vi>
#define vll					vector<ll>
#define mid(s,e)			(s+(e-s)/2)
#define clz(n)				__builtin_clzll(n))

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
template<typename T>
void printVec(const T &v, char sep=' ') {for (auto &i: v) cout << i << sep;}
template<typename T>
void printVecPair(const T &v, char sep=' ') {for (auto &i: v) cout << i.first <<" " << i.second<< sep;}


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	int h,n;
	cin>>h>>n;
	vll dp(h+1,1e9);
	dp[0] = 0;
	while(n--) {
			int a,b;
			cin>>a>>b;
			for(int i=0;i<=h;i++) {
					int j=min(i+a,h);
					dp[j] = min(dp[j], b + dp[i]);
			}
	}
	cout<<dp[h];
	return 0;
}





Measured memory_bytes: 384
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	ll n, m;
	vector<string> v1, v2;

	cin >> n >> m;

	REP(i, n) {
		string a;
		cin >> a;
		v1.push_back(a);
	}

	REP(i, m) {
		string b;
		cin >> b;
		v2.push_back(b);
	}

	bool flag = true;

	REP(i, n - m + 1) {
		REP(j, v1[0].size() - v2[0].size() + 1) {
			REP(k, m) {
				if (v1[i + k].substr(j, v2[0].size()) != v2[k]) {
					flag = false;
					break;
				}
			}

			if (flag) {
				cout << "Yes" << endl;
				return 0;
			}
			else {
				flag = true;
			}
		}
	}

	cout << "No" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
	int N, M;
	cin >> N >> M;
	int l, r;
	int lmax=1, rmin=N;
	rep(i, M) {
		cin >> l >> r;
		lmax = max(lmax, l);
		rmin = min(rmin, r);
	}
	int ans;
	if (rmin < lmax) ans = 0;
	else ans = rmin - lmax + 1;
	cout << ans << endl;





	return 0;
}



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

int main()
{
    string a,b; 
    cin >> a >> b;
    int l1,l2,i,j,c=1;
    l1=a.length();
    l2=b.length();
    int arr[l1+1][l2+1];
    for(i=0;i<l1+1;i++)
    for(j=0;j<=l2;j++)
    arr[i][j]=0;
    for(i=1;i<=l1;i++)
    {
    for(j=1;j<=l2;j++)
    {
        if(a[i-1]==b[j-1])
        arr[i][j]=arr[i-1][j-1]+1;
        else
        arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
        //cout << arr[i][j] << " ";
    }
    //cout << endl;
    }
    vector <char> v;
    i=l1;j=l2;
    while(i>0 && j>0)
    {
        //cout << i << " " << a[i-1] << " " << j << " " << b[j-1] << endl;
        if(a[i-1]==b[j-1])
        {
            //cout << a[i-1];
            v.push_back(a[i-1]);
            i--;
            j--;
        }
        else if(arr[i-1][j]>arr[i][j-1])
        i--;
        else
        j--;
        
    }
    for(i=v.size()-1;i>=0;i--)
    cout << v[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 35456
while True:
    try:
        a = [int(input()) for i in range(5)]
    except:
        break
    if (1 in a and 2 in a and 3 in a) or a.count(a[0]) == 5:
        for i in range(5):
            print(3)
    elif not 3 in a:
        for b in a:
            if b == 1:
                print(1)
            else:
                print(2)
    elif not 2 in a:
        for b in a:
            if b == 1:
                print(2)
            else:
                print(1)
    else:
        for b in a:
            if b == 2:
                print(1)
            else:
                print(2)
        


Measured memory_bytes: 5604
#include <iostream>
#include <cstring>
#include <stdio.h>
#include <stack>
using namespace std;
typedef long long ll;
const int N = 1e5 + 50;
int a, b, k;

int main( ){
    scanf("%d%d%d", &a, &b, &k);
    int num = 1;
    while (k--) {
        if (num % 2 == 1) {
            if (a % 2) {
                a--;
            }
            a /= 2;
            b += a;
        }
        else {
            if (b % 2)
                b--;
            b /= 2;
            a += b;
        }
        num++;
    }
    printf("%d %d\n", a, b);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int n = sc.nextInt();
      int d = sc.nextInt();
      int x = sc.nextInt();

      int[] a = new int[n];
      for (int i = 0; i < a.length; i++) {
         a[i] = sc.nextInt();
      }

      int c = 0;

      for (int i = 0; i < a.length; i++) {
         int b = a[i];
         for (int j = 0; j * b + 1 <= d; j++) {
            c++;
         }
      }

      System.out.println(c + x);

   }
}

Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
int main() {
	string s;
	int a;
	int sum = 0;
	cin >> a;
	cin >> s;
	for (int i = 0; i < a-2; i++)
	{
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
		{
			sum++;
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
using System;
class aoj
{
    static void Main()
    {
        string[] a = new string[50];
        int f = 0;
        while (true)
        {
            string []b = Console.ReadLine().Split(' ');
            if (b[0] == "0")
            {
                break;
            }
            int[] c = new int[2];
            c[0] = int.Parse(b[0]);
            c[1] = int.Parse(b[1]);
            DateTime d = new DateTime(2004, c[0], c[1]);
            DayOfWeek e = d.DayOfWeek;
            int g = (int)e;
            switch (g)
            {
                case 0:
                    a[f] = "Sunday";
                    break;
                case 1:
                    a[f] = "Monday";
                    break;
                case 2:
                    a[f] = "Tuesday";
                    break;
                case 3:
                    a[f] = "Wednesday";
                    break;
                case 4:
                    a[f] = "Thursday";
                    break;
                case 5:
                    a[f] = "Friday";
                    break;
                case 6:
                    a[f] = "Saturday";
                    break;
            }
            f++;
        }
        for(int i = 0; i < f; i++)
        {
            Console.WriteLine(a[i]);
        }
    }
}

Measured memory_bytes: 8996
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 2005

struct Info{

	ll fix_value,mult,all_mult,num_route;
};

int H,W;
int diff_row[2] = {0,1},diff_col[2] = {1,0};
ll M;
char table[SIZE][SIZE];
Info info[SIZE][SIZE];


bool rangeCheck(int row,int col){

	return row >= 0 && row <= H-1 && col >= 0 && col <= W-1;
}

int main(){

	scanf("%d %d %lld",&H,&W,&M);

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){

			info[row][col].fix_value = 0;
			info[row][col].mult = 0;
			info[row][col].all_mult = 0;
			info[row][col].num_route = 0;
		}
	}

	for(int row = 0; row < H; row++){

		scanf("%s",table[row]);
	}

	info[0][0].mult = 1;
	info[0][0].all_mult = table[0][0]-'0';
	info[0][0].num_route = 1;


	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){
			for(int i = 0; i < 2; i++){

				int adj_row = row+diff_row[i];
				int adj_col = col+diff_col[i];

				if(!rangeCheck(adj_row,adj_col))continue;

				info[adj_row][adj_col].fix_value += info[row][col].fix_value;
				info[adj_row][adj_col].fix_value %= M;

				info[adj_row][adj_col].num_route += info[row][col].num_route;
				info[adj_row][adj_col].num_route %= M;

				switch(table[adj_row][adj_col]){
				case '+':

					info[adj_row][adj_col].fix_value += info[row][col].all_mult;
					info[adj_row][adj_col].fix_value %= M;
					info[adj_row][adj_col].mult += info[row][col].num_route;
					info[adj_row][adj_col].mult %= M;
					break;

				case '*':

					info[adj_row][adj_col].mult += info[row][col].all_mult;
					info[adj_row][adj_col].mult %= M;
					break;

				default:

					ll tmp = table[adj_row][adj_col]-'0';

					info[adj_row][adj_col].mult += info[row][col].mult;
					info[adj_row][adj_col].mult %= M;

					info[adj_row][adj_col].all_mult += (10*info[row][col].all_mult+tmp*info[row][col].mult)%M;
					info[adj_row][adj_col].all_mult %= M;

					break;
				}
			}
		}
	}

	printf("%lld\n",(info[H-1][W-1].fix_value+info[H-1][W-1].all_mult)%M);

	return 0;
}



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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

//main code

int main(int argc, char const* argv[])
{
	int n,k;
	cin >> n >> k;
	int n_max = (n-1)*(n-2)/2;
	if (n_max < k) {
		cout << -1 << endl;
		return 0;
	}
	int m = n-1 + (n_max-k);
	cout << m << endl;
	for (int i = 1; i <= n-1; i++) {
		cout << 1 << " " << i+1 << endl;
	}
	if (n_max-k == 0) {
		return 0;
	}
	int count = 0;
	for (int i = 2;; i++) {
		for (int j = i+1;j < n+1; j++) {
			cout << i << " " << j << endl;
			count++;
			if (count == n_max-k) {
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int H,W,a[501][501],b[501][501],N=0;
    cin>>H>>W;
    for(int i=1;i<=H;i++){
        for(int k=1;k<=W;k++){
            cin>>a[i][k];
            b[i][k]=a[i][k];
        }
    }
    for(int i=1;i<=H;i++){
        for(int k=1;k<W;k++){
            if(b[i][k]%2==1){
                b[i][k]--;
                b[i][k+1]++;
                N++;
            }
        }
    }
    for(int i=1;i<H;i++){
        if(b[i][W]%2==1){
            b[i][W]--;
            b[i+1][W]++;
            N++;
        }
    }
    cout<<N<<endl;
    for(int i=1;i<=H;i++){
        for(int k=1;k<W;k++){
            if(a[i][k]%2==1){
                a[i][k]--;
                a[i][k+1]++;
                cout<<i<<" "<<k<<" "<<i<<" "<<k+1<<endl;
            }
        }
    }
    for(int i=1;i<H;i++){
        if(a[i][W]%2==1){
            a[i][W]--;
            a[i+1][W]++;
            cout<<i<<" "<<W<<" "<<i+1<<" "<<W<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4096
n=int(input())
A=list(map(int, input().split()))
q=int(input())
m=list(map(int, input().split()))

memo=[[None]*(n+1) for _ in range(max(m)+1)]

def solver(i,m):
    if memo[m][i] != None:
        return memo[m][i]
    else:
        if m == 0:
            memo[m][i]=True
            return True
        elif i == n:
            memo[m][i]=False
            return False
        else:
            if m-A[i] >= 0:
                memo[m][i] = solver(i+1,m) or solver(i+1,m-A[i])
                return memo[m][i]
            else:
                memo[m][i] = solver(i+1,m)
                return memo[m][i]


for mi in m:
    if solver(0,mi):
        print("yes")
    else:
        print("no")



Measured memory_bytes: 5984
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

s = ns()
n = len(s)

ans = 0
for i in range(2, n, 2):
    flag = True
    m = i // 2
    for j in range(m):
        if s[j] != s[j + m]:
            flag = False
    if flag:
        ans = i

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007ll;

int main(){
	int a,b;
	std::cin >>a>>b ;
	std::cout << max(0,a-2*b) << std::endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>

using namespace std;
#define n_max 100000

#define rep(i,n) for(int i = 0; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

int main() {

    ll n, k; cin >> n >> k;
    ll ans = 100100100100;
    
    vector<ll> h(n);

    rep(i,n){ 
        cin >> h[i];
    }
    sort(h.rbegin(), h.rend());
    for(ll i = 0; i <= h.size() - k; i++) {
        ans = min(h[i] - h[i+k-1], ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}

int n,k;
vector<int> v[110000];
vector<bool> used(110000, false);
vector<int> fu(110000);
int ans;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int p(int n, int r){
  if(n < r)return 0;
  if(r == 0)return 1;
  return fu[n] * modinv(fu[n-r], MOD) % MOD;
}

void rec(int x){
  used[x] = true;
  ans = (ans * p(k-2, v[x].size()-1))%MOD;
  rep(i,v[x].size()){
    if(used[v[x][i]])continue;
    rec(v[x][i]);
  }
}

signed main(){
  cin>>n>>k;
  ans = k;
  rep(i,n-1){  //ココ心配
    int a,b;cin>>a>>b;a--;b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }

  fu[0] = 1;fu[1] = 1;
  repd(i,2,fu.size()){
    fu[i] = fu[i-1] * i % MOD;
  }
  ans = ans * p(k-1,v[0].size()) % MOD;
  used[0] = true;
  
  rep(i,v[0].size()){
    rec(v[0][i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 10368
while True:
 S = raw_input()
 if S == '0':break
 m = [1] + [0 for i in range(10)]
 d = A = 0
 e = 1
 S = reversed(S)
 for c in S:
  d = (d + int(c) * e) % 11  
  if int(c) != 0:
   A += m[d]
  m[d] += 1
  e *= -1
 print A


Measured memory_bytes: 4696
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  ll N, A, B;

  cin >> N >> A >> B;

  ll ans = 0;

  ans += N / (A + B) * A;
  ans += min(N % (A + B), A);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 *
 * @author baito
 */
public class Main {

    /**
     * @param args the command line arguments
     * @throws java.lang.Exception
     */
    static int n,k,total,max;
    static int[] w  ;
    public static void main(String[] args)throws Exception {
        // TODO code application logic here
        ContestScanner sc = new ContestScanner();
        n = sc.nextInt();
        k = sc.nextInt();
        w = new int[n];
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            total += w[i];
            max = Math.max(max, w[i]);
        }
        int answer = solve();
        System.out.println(answer);
    }
    public static int check(int max) {
        int sum = 0,i=0,j;
        for (j = 0; j < k;j++) {
            while(sum + w[i] <= max){
                sum += w[i];
                if(i == n - 1 )return n ;
                i++;
            }
            sum = 0;
            
        }
        return i;
    }
    public static int solve() {
        int first = max-1;
        int last = total  ,ans;
        while(- first + last > 1){
            int mid = (first + last)/2;
            ans = check(mid);
           // if(ans == n) return ans;
            if(ans >=  n ) last = mid ;
            else first = mid ;
        }
       //if(check(first) == n)return first;
        return last;
    }

    
    
}

//????????????????????????
class ContestScanner {
    
    private final BufferedReader reader;
    private String[] line;
    private int idx;
    
    public ContestScanner() throws FileNotFoundException {
        reader = new BufferedReader(new InputStreamReader(System.in));
    }
    
    public ContestScanner(String filename) throws FileNotFoundException {
        reader = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
    }
    //???????????? 

    public String readLine() throws Exception {
        return reader.readLine();
    }
    
    public String nextToken() throws IOException {
        if (line == null || line.length <= idx) {
            line = reader.readLine().trim().split(" ");
            idx = 0;
        }
        return line[idx++];
    }
    
    public long nextLong() throws IOException, NumberFormatException {
        return Long.parseLong(nextToken());
    }
    
    public int nextInt() throws NumberFormatException, IOException {
        return (int) nextLong();
    }
    
    public double nextDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 39388
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(Scanner sc = new Scanner(System.in)){
			final long A = sc.nextLong();
			final long B = sc.nextLong();
			final long C = sc.nextLong();
			
			long curr_A = A, curr_B = B, curr_C = C;
			long cnt = 0;
			while(true){
				if(curr_A % 2 == 1 || curr_B % 2 == 1 || curr_C % 2 == 1){
					System.out.println(cnt);
					return;
				}
				
				final long next_A = curr_B / 2 + curr_C / 2;
				final long next_B = curr_A / 2 + curr_C / 2;
				final long next_C = curr_A / 2 + curr_B / 2;
				
				curr_A = next_A;
				curr_B = next_B;
				curr_C = next_C;
				cnt++;
				if(curr_A == A && curr_B == B && curr_C == C){
					System.out.println(-1);
					break;
				}
			}
		}
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}
		
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21332
from collections import defaultdict

def solve():
    n = int(input())
    C = defaultdict(int)
    for _ in range(n):
        s = input().strip()
        C[s] += 1
    
    print('AC x', C['AC'])
    print('WA x', C['WA'])
    print('TLE x', C['TLE'])
    print('RE x', C['RE'])


if __name__ == '__main__':
    solve()

Measured memory_bytes: 9476
#include <stdio.h>

int main(void)
{
    int a, b;
    
    scanf("%d%d", &a, &b);
    
    if(a < b)
    {
        printf("a < b\n");
    }
    else if(a > b)
    {
        printf("a > b\n");
    }
    else
    {
        printf("a == b\n");
    }
    return 0;
}

Measured memory_bytes: 580
N, M = map(int, input().split())

n_pattern = 1
m_pattern = 1

for n in range(1, N+1):
  n_pattern *= n
  n_pattern = n_pattern % (10 ** 9 + 7)

for m in range(1, M+1):
  m_pattern *= m
  m_pattern = m_pattern % (10 ** 9 + 7)
  
if N > M + 1 or N < M - 1:
  print(0)
elif N == M + 1 or M == N + 1:
  print(n_pattern * m_pattern % (10 ** 9 + 7))
elif N == M:
  print(n_pattern * m_pattern * 2 % (10 ** 9 + 7))
    

Measured memory_bytes: 3064
n,a=int(input()),sorted(list(map(int,input().split())))
m=a[-1]+1
s=[0]*m
for i in a:s[i]+=1
for i in set(a):
	if s[i]:
		for j in range(i*2,m,i):s[j]=0
print(s.count(1))

Measured memory_bytes: 40024
n, m = map(int, input().split())

ans = 1
for i in range(1, int(m**0.5)+2):
  if m % i == 0:
    if i * n <= m:
      ans = max(ans, i)
    if (m // i) * n <= m:
      ans = max(ans, m//i)
    
print(ans)

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

using namespace std;

int n;
int a[110];
bitset<110> vis;
int mask[110];
int MAX;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n;

	for(int i = 1; i <= n; i++) cin >> a[i];

	MAX = min(n, 22);
	
	for(int i = 1; i <= n; i++){
		for(int j = 2; j <= MAX; j++){
			if(i % j == 0) mask[i] |= (1 << (j - 2));
		}
	}

	long long ans = 0;

	for(int bit = 0; bit < (1 << (MAX - 1)); bit++){
		vis = 0;
		for(int k = 1; k <= n; k++){
			if(mask[k] & bit) vis[k] = true;
		}

		for(int k = n; k > MAX; k--){
			long long sum = 0;

			for(int j = k; j <= n; j += k){
				if(vis[j]) continue;

				sum += a[j];
			}

			if(sum < 0){
				for(int j = k; j <= n; j += k){
					vis[j] = true;
				}
			}
		}

		long long sum = 0;
		for(int k = 1; k <= n; k++)
			if(!vis[k]) sum += a[k];

		ans = max(ans, sum);
	}

	cout << ans <<"\n";

	return 0;
}

Measured memory_bytes: 256
# B - Robot Arms
N = int(input())
a =[list(map(int, input().split())) for i in range(N)]
#print(a)
count  = 0

a.sort()
#print(a)
for i in range(N-1):
    right = a[i][0] + a[i][1]
    left = a[i+1][0] - a[i+1][1]
    if right <= left:
        pass
    else:
        count += 1
        if a[i][0] + a[i][1] >= a[i+1][0] + a[i+1][1] and a[i][0] + a[i][1] > a[i+1][0]:
            pass
        else:
            a[i+1][0] = a[i][0]
            a[i+1][1] = a[i][1]
print(N -count)

Measured memory_bytes: 62612
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint a[200005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	n *= 2;
	for(int i = 1; i <= n; i++) cin >> a[i];
	sort(a+1, a+n+1);
	reverse(a+1, a+n+1);
	
	double ans = 0;
	for(int i = 1; i <= n; i++) ans += (double)a[i] * (n-i) / (n-1);
	printf("%.11f\n", ans);
	
	return 0;
}

Measured memory_bytes: 1792