akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>

int main () {
    ll k , m ;
    cin >> k >> m ;
    if(k <= m){
        cout << "unsafe"<< endl;
    }else{
        cout << "safe" << endl;
    }
    
    return 0 ;
}

 



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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
using namespace std;

int main() {
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    string ans = (a1 + a2 + a3 >= 22) ? "bust" : "win";
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int w, h, x, y, r;
    cin >>w >>h >>x >>y >>r;
    
    if (r<=x && x<=(w-r) && r<=y && y<=(h-r)) {
        cout << "Yes" << endl;
    }
    
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3132
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e8;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max(a*b,c*d)<<endl;
}
















Measured memory_bytes: 256
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define ll long long
#define pp pair<ll,ll>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
ll max(ll x, ll y)
{
    return x>y ? x : y;
}
ll min(ll x, ll y)
{
    return x<y ? x : y;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,m;cin >> n >> m;vector<vector<ll> > v(m);
    for (int i = 0; i < m; ++i)
    {
    	ll k;cin >> k;
    	for (int j = 0; j < k; ++j)
    	{
    		ll d;cin >> d;v[i].push_back(d);
    	}
    }
    ll p[m];ll ans=0;
    for (int i = 0; i < m; ++i)
    {
    	cin >> p[i];
    }
    for(ll i=0;i<(1LL<<n);i++)
    {
    	string s;
    	ll d=i;
    	while(d)
    	{
    		s+=(d%2)+'0';d/=2;
    	}

    	while(s.size()<n)s+='0';//trace(s);
    	bool b=1;
    	for (int j = 0; j < m; ++j)
    	{
    		ll u=0;
    		for (int k = 0; k < v[j].size(); ++k)
    		{
    			if(s[v[j][k]-1]=='1')u++;
    		}
    		if((u&1)!=p[j]){b=0;break;}
    	}
    	if(b)ans++;
    }
    cout << ans;
    }

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {

  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  ll n, m, k, ans = 0;

  cin >> n >> m >> k;

  vector<int> a(n), b(m);

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

  for(int i = 0; i < m; i++) cin >> b[i];

  ll tot = 0, bpos = m - 1;

  for(int i = 0; i < m; i++) tot += b[i];

  while(bpos >= 0 && tot > k) {
    tot -= b[bpos--];
  }

  if(tot <= k) ans = bpos + 1;

  for(int i = 0; i < n; i++) {
    tot += a[i];
    while(bpos >= 0 && tot > k) {
      tot -= b[bpos--];
    }
    if(tot <= k) ans = max(ans, bpos + 1 + i + 1);
  }

  cout << ans;

  return 0;
}
/*

*/


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

const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
int x[N], y[N];
char op[N][2];
int n;
vector<pair<int, char> > v1[N << 1];
vector<pair<int, char> > v2[N << 1];

void Rotate() {
	for(int i = 1; i <= n; i++) {
		int xx = y[i], yy = 200000 - x[i];
		char ch = op[i][0];
		if(ch == 'U') ch = 'R';
		else if(ch == 'R') ch = 'D';
		else if(ch == 'D') ch = 'L';
		else ch = 'U';
		x[i] = xx, y[i] = yy, op[i][0] = ch;
	}
}

int cacl1() {
	for(int i = 0; i < N * 2; i++) v1[i].clear();
	int res = inf;
	for(int i = 1; i <= n; i++) {
		if(!(op[i][0] == 'R' || op[i][0] == 'U')) continue;
		v1[x[i] + y[i]].push_back({x[i], op[i][0]});
	}
	for(int i = 0; i < N * 2; i++) {
		sort(v1[i].begin(), v1[i].end());
		for(int j = 0; j < (int)v1[i].size() - 1; j++) {
			if(!(v1[i][j].second == 'R' && v1[i][j + 1].second == 'U')) continue;
			res = min(res, v1[i][j + 1].first - v1[i][j].first);
		}
	}
	return res * 10;
}

int cacl2() {
	for(int i = 0; i < N * 2; i++) v2[i].clear();
	int res = inf;
	for(int i = 1; i <= n; i++) {
		if(!(op[i][0] == 'R' || op[i][0] == 'L')) continue;
		v2[y[i]].push_back({x[i], op[i][0]});
	}
	for(int i = 0; i < N * 2; i++) {
		sort(v2[i].begin(), v2[i].end());
		for(int j = 0; j < (int)v2[i].size() - 1; j++) {
			if(!(v2[i][j].second == 'R' && v2[i][j + 1].second == 'L')) continue;
			res = min(res, v2[i][j + 1].first - v2[i][j].first);
		}
	}
	return res * 5;
}

void solve() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%d%d%s", &x[i], &y[i], &op[i]);
	}
	int res = 1e9;
	for(int i = 1; i <= 4; i++) {
		res = min(res, cacl1());
		res = min(res, cacl2());
		Rotate();
	}
	if(res == 1e9) puts("SAFE");
	else printf("%d\n", res);
}

int main() {
//	freopen("in.txt", "r", stdin);
	solve();
	return 0;
}


Measured memory_bytes: 37208
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define ll long long
#define vi vector<int>
#define pi pair<int, int>
#define pb push_back
#define ppb pop_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()


using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

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

    char c;
    cin >> c;
    char ans = c+1;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
const ll p=998244353;
ll n,a,b,k,ans,fct[300005]={1};
ll qpow(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1)
			res=res*a%p;
		a=a*a%p;
		b>>=1;
	}
	return res;
}
ll C(ll n,ll m){
	return fct[n]*qpow(fct[n-m]*fct[m]%p,p-2)%p;
}
int main(){
	ios::sync_with_stdio(false);
	ll i,j;
	cin>>n>>a>>b>>k;
	for(i=1;i<=n;i++)
		fct[i]=fct[i-1]*i%p;
	for(i=0;i<=n;i++){//num of a
		j=k-i*a;
		if(j%b!=0||j<0)
			continue;
		j=j/b;
		if(j>n)
			continue;
		ans=(ans+C(n,i)*C(n,j))%p;
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

bool ok(const vector<int> &a)
{
    int odd = 0;
    int even = 0;
    int mul4 = 0;
    for (auto x : a) {
        if (x % 2 != 0) {
            ++odd;
        }
        if (x % 4 == 0) {
            ++mul4;
        } else if (x % 2 == 0) {
            ++even;
        }
    }
    if (even > 0) {
        return mul4 >= odd;
    } else {
        return mul4 + 1 >= odd;
    }
}

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    
    for (auto &x : a) {
        cin >> x;
    }
    
    if (ok(a)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair
#define PB push_back
#define PII pair<int,int>
#define ll long long
int N=INT_MAX;
ll INF=1e18L+5;
map<int ,int>my;
//vector<PII>v[1000005];
char a[3009],b[3009];

void lcs(int n,int m){
    //cout<<a<<" "<<b<<" "<<n<<" "<<m<<endl;
    int l[n+1][m+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if(i==0 || j==0){l[i][j]=0;}
            else if(a[i-1]==b[j-1]){l[i][j]=1+l[i-1][j-1];}
            else{
                l[i][j]=max(l[i-1][j],l[i][j-1]);
            }
        }
    }
    int index=l[n][m];
    char s[index+1];
    s[index]='\0';
    int i=n,j=m;
    while(i!=0&&j!=0){
        if(a[i-1]==b[j-1]){s[index-1]=a[i-1];i--;j--;index--;}
        else{
            if(l[i-1][j]>=l[i][j-1]){
                i--;
            }
            else{
                j--;
            }
        }
    }
    cout<<s;
}

int main(){
    scanf("%s%s",a,b);
    int n1=strlen(a),n2=strlen(b);
    lcs(n1,n2);
}


Measured memory_bytes: 35456
#include<stdio.h>
#include<string.h>
#include<vector>
#include<utility>
using namespace std;
#define ll "ll"
#define ran 222222
char s[ran];
#define uint64 unsigned long long int
#define int64 long long int
#define MUL 197
uint64 hsh[ran],mul[ran];
int64 L,R;

int n,pos;

int64 res[26],res2[26];

int64 tmp[26];
void calc_naive(int64 x,int w){
	memset(tmp,0,sizeof(tmp));
	for(int i=1; i<=n; i++)
		tmp[s[i]-'a'] ++;
	for(int i=0; i<26; i++)
		res[i] += tmp[i] * (x / n) * w;
	for(int i=1; i<=x%n; i++)
		res[s[i]-'a'] += w;
}

struct cnt{
	int64 len;
	int64 a[26];
	cnt(){memset(a,0,sizeof(a));len=0;}
};
void add(cnt&A,cnt&B,cnt&C){
	A.len = B.len + C.len;
	for(int i=0; i<26; i++)
		A.a[i] = B.a[i] + C.a[i];
}
void sub(cnt&A,cnt&B,cnt&C){
	A.len = B.len - C.len;
	for(int i=0; i<26; i++)
		A.a[i] = B.a[i] - C.a[i];
}
vector<pair<cnt,cnt> > len;

void calc(int64 L){
	len.clear();
	cnt A,B,AB,AB2,AB4,AB4dec;
	for(int i=1; i<=n; i++){
		if(i <= pos){
			A.len ++;
			A.a[s[i]-'a'] ++;
		}else{
			B.len ++;
			B.a[s[i]-'a'] ++;
		}
	}
	add(AB, A, B);
	add(AB2, AB, AB);
	sub(AB4, AB2, A);
	add(AB4dec, AB4, AB4);
	
	len.push_back(make_pair(AB2, A));
	len.push_back(make_pair(AB4dec, B));
	int step = 1;
	while(true){
		if(len[step].first.len >= L)break;
		cnt tmp_len1, tmp_len;
		sub(tmp_len1, len[step].first, len[step].second);
		add(tmp_len, tmp_len1, tmp_len1);
		cnt tmp_match;
		add(tmp_match, len[step].second, len[step-1].second);
		len.push_back(make_pair(tmp_len, tmp_match));
		step++;
	}

	while(step > 0){
		if(L <= len[step-1].first.len)
			step --;
		else{
			L -= len[step-1].first.len - len[step-1].second.len;
			cnt tmp;
			sub(tmp, len[step-1].first, len[step-1].second);
			for(int i=0; i<26; i++)
				res[i] += tmp.a[i];
			step --;
		}
	}

	for(int i=1; i<=L; i++)
		res[s[i]-'a'] ++;
}

int main(){
	scanf("%s",s+1);
	scanf("%"ll"d%"ll"d",&L,&R);
	n = strlen(s+1) / 2;
	mul[0] = 1;
	for(int i=1; i<=n * 2; i++){
		hsh[i] = hsh[i-1] * MUL + s[i];
		mul[i] = mul[i-1] * MUL;
	}
	pos = 0;
	for(int i=n-1; i>=1; i--)
		if(hsh[i] == hsh[n * 2] - hsh[n * 2 - i] * mul[i]){
			pos = i;
			break;
		}

	if(pos == 0){
		calc_naive(L-1, -1);
		calc_naive(R, 1);
	}else{
		calc(L-1);
		memcpy(res2, res, sizeof(res2));
		memset(res,0,sizeof(res));
		calc(R);
		for(int i=0; i<26; i++)
			res[i] -= res2[i];
	}

	for(int i=0; i<26; i++)
		printf("%"ll"d%c",res[i],i<25?' ':'\n');
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long int64;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> a[26];
	for (int i = 0; i < n; ++ i) {
		a[s[i] - 'A'].emplace_back(i);		
	}
	int64 cnt = 0;
	for (int i = 0; i < n; ++ i) {
		if (s[i] == 'R') {
			auto it = upper_bound(a['G' - 'A'].begin(), a['G' - 'A'].end(), i);
			while (it != a['G' - 'A'].end()) {
				int d = (*it) - i;
				cnt += a['B' - 'A'].end() - upper_bound(a['B' - 'A'].begin(), a['B' - 'A'].end(), *it);
				if (*it + d < n && s[*it + d] == 'B') cnt --;
				it ++;
			}
			it = upper_bound(a['B' - 'A'].begin(), a['B' - 'A'].end(), i);
			while (it != a['B' - 'A'].end()) {
				int d = (*it) - i;
				cnt += a['G' - 'A'].end() - upper_bound(a['G' - 'A'].begin(), a['G' - 'A'].end(), *it);
				if (*it + d < n && s[*it + d] == 'G') cnt --;
				it ++;
			}
		}
		else if (s[i] == 'G') {
			auto it = upper_bound(a['R' - 'A'].begin(), a['R' - 'A'].end(), i);
			while (it != a['R' - 'A'].end()) {
				int d = (*it) - i;
				cnt += a['B' - 'A'].end() - upper_bound(a['B' - 'A'].begin(), a['B' - 'A'].end(), *it);
				if (*it + d < n && s[*it + d] == 'B') cnt --;
				it ++;
			}
			it = upper_bound(a['B' - 'A'].begin(), a['B' - 'A'].end(), i);
			while (it != a['B' - 'A'].end()) {
				int d = (*it) - i;
				cnt += a['R' - 'A'].end() - upper_bound(a['R' - 'A'].begin(), a['R' - 'A'].end(), *it);
				if (*it + d < n && s[*it + d] == 'R') cnt --;
				it ++;
			}
		}
		else {
			auto it = upper_bound(a['R' - 'A'].begin(), a['R' - 'A'].end(), i);
			while (it != a['R' - 'A'].end()) {
				int d = (*it) - i;
				cnt += a['G' - 'A'].end() - upper_bound(a['G' - 'A'].begin(), a['G' - 'A'].end(), *it);
				if (*it + d < n && s[*it + d] == 'G') cnt --;
				it ++;
			}
			it = upper_bound(a['G' - 'A'].begin(), a['G' - 'A'].end(), i);
			while (it != a['G' - 'A'].end()) {
				int d = (*it) - i;
				cnt += a['R' - 'A'].end() - upper_bound(a['R' - 'A'].begin(), a['R' - 'A'].end(), *it);
				if (*it + d < n && s[*it + d] == 'R') cnt --;
				it ++;
			}
		}
	}
	cout << cnt;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
const ll INF = 114514810;
const ll MOD = 1000000007;
const double EPS = 1e-8;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///


int main()
{
	int n, m;
	while (cin >> n >> m, n)
	{
		int tim[101][101], cos[101][101];
		REP(i, m)REP(j, m) tim[i][j] = (i == j ? 0 : INF);
		REP(i, m)REP(j, m) cos[i][j] = (i == j ? 0 : INF);
		while (n--)
		{
			int a, b, c, d;
			cin >> a >> b >> c >> d;
			a--; b--;
			tim[a][b] = tim[b][a] = c;
			cos[a][b] = cos[b][a] = d;
		}
		REP(k, m)REP(i, m)REP(j, m) tim[i][j] = min(tim[i][j], tim[i][k] + tim[k][j]);
		REP(k, m)REP(i, m)REP(j, m) cos[i][j] = min(cos[i][j], cos[i][k] + cos[k][j]);
		int q;
		cin >> q;
		while (q--)
		{
			int a, b, c;
			cin >> a >> b >> c;
			a--; b--;
			cout << (c == 0 ? tim[a][b] : cos[a][b]) << endl;
		}
	}
}

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

vector<long long> ans;

void dfs(string T){
  long long tmp=stoll(T);
  if(tmp>1e10) return;
  ans.push_back(tmp);

  int aa=T.at(T.size()-1)-'0';
  T+=('0'+aa);
  dfs(T);
  if(aa!=0){
    T.at(T.size()-1)=('0'+aa-1);
    dfs(T);
  }
  if(aa!=9){
    T.at(T.size()-1)=('0'+aa+1);
    dfs(T);
  }
}

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

  for(int i=1;i<=9;i++) dfs(to_string(i));
  sort(ans.begin(),ans.end());
  cout << ans.at(K-1) << endl;

  return 0;
}

Measured memory_bytes: 3444
package main

import (
	"fmt"
)

func main() {
	var A, B = 99, 99
	fmt.Scan(&A)
	fmt.Scan(&B)
	if result := answer(A, B); result != 0 {
		fmt.Println(result)
	} else {
		fmt.Println("error")
	}

}

func answer(A, B int) int {
	var result int
	var selectors = []int{1, 2, 3}
	for _, v := range selectors {
		if v != A && v != B {
			result = v
			break
		}
	}
	return result
}


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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(0)





void solve() {

	ll a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	
	
	if(a == b) {
		cout << "YES\n";
		return;
	}

	ll sa, sb;
	if(a < b) {
		sa = (ll)v * t + a;
		sb = (ll)w * t + b;
		if(sb <= sa) {
			cout << "YES\n";
		}
		else {
			cout << "NO\n";
		}
	}
	else {
		sa = a - v * t;
		sb = b - w * t;
		if(sb >= sa) {
			cout << "YES\n";
		}
		else {
			cout << "NO\n";
		}
	}	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	fix;
	solve();

	return 0;
}

Measured memory_bytes: 3640
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()


N=int(input())
X=input()
C=X.count("1")

lst=[]
lstcount=[]
for x in [C-1,C+1]:
    flg=0
    if x<=0:
        lst.append(0)
        lstcount.append(0)
    else:
        Z=0
        p=1
        for i in range(N):
            if X[-i-1]=="1":
                Z+=p
            p*=2
            if Z>=x:
                Z%=x
                flg=1
            if flg:
                p%=x
        lst.append(Z)
        lstcount.append(flg)
#print(lst)
fac1=[1]
fac2=[1]
C1=max(C-1,1)
C2=max(C+1,1)
for i in range(N):
    fac1.append(fac1[-1]*2%C1)
    fac2.append(fac2[-1]*2%C2)

for i in range(N):

    _C=C+(1 if X[i]=="0"  else -1 )
    if _C==0:
        print(0)
        continue
    if  X[i]=="0":
        lstidx=1
    else:
        lstidx=0

    idx=(N-1-i)

    value=lst[lstidx]+(fac2[idx] if  X[i]=="0" else -fac1[idx])
    #print(value,X[i]=="0",lst,C-1,C+1)
    bit=value
    count=0
    while value and _C:
        count+=1
        value%=_C
        _C=0
        bit=value
        while bit:
            _C+=bit&1
            bit>>=1
    print(max(count,1))


Measured memory_bytes: 102576
#include<iostream>

using namespace std;

int N ;
int Y ;

int main(void){
  bool flag = true ;
  cin >> N ;
  cin >> Y ;

  for(int x = 0; Y - 10000*x >= 0 ; x++){
    for(int y = 0; Y - 10000*x - 5000*y >= 0; y++){
        if((Y - 10000*x - 5000*y)/1000 == N - x - y && flag == true ){
          cout << x << " " << y << " " << N -x -y << endl ;
          flag = false ;
        }
      }
    }







  if(flag) cout << -1 << " " << -1 << " "<< -1 << endl ;

  return 0;







}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int n,m;
vector<int> e[600];
double dp[600];

double solve(int v){
    for(int i=0;i<n;i++){
        dp[i]=0;
    }
    for(int i=n-2;i>=0;i--){
        int sz=(int)e[i].size();
        double mx=0;
        for(int u:e[i]){
            dp[i]+=dp[u]+1;
            mx=max(mx,dp[u]+1);
        }
        if(i==v&&sz!=1){
            dp[i]=(dp[i]-mx)/(sz-1);
        }
        else{
            dp[i]=dp[i]/sz;
        }
    }
    return dp[0];
}

int main(){
    cin>>n>>m;
    double ans=1e10;
    for(int i=0;i<m;i++){
        int s,t;
        cin>>s>>t;
        --s,--t;
        e[s].push_back(t);
    }
    for(int i=0;i<n-1;i++){
        ans=min(ans,solve(i));
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
}

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

using namespace std;

typedef long long ll;

const int N=2e5+10;

int n,m,k;
ll a[N];
ll psum[N];


bool check(int st){
    ll val=psum[st];
    int last=st;
    while (1){
        int cur=upper_bound(a+1,a+n+1,2*val)-a-1;
        if (cur==last) return 0;
        if (cur==n) return 1;
        val+=psum[cur]-psum[last];
        last=cur;
    }
}
int solve(){
    int ans=1;
    while (!check(ans)) ans++;
    return n-ans+1;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%lld",a+i);
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++) psum[i]=psum[i-1]+a[i];
    cout<<solve()<<'\n';
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N;
vector<string> V;
void input() {
  cin >> N;
  V.resize(N);
  rep(i, 0, N - 1) { cin >> V[i]; }
}
void solve() {
  vector<map<char, int>> mp(N);
  rep(i, 0, N - 1) {
    for (auto c : V[i]) {
      mp[i][c]++;
    }
  }
  map<char, int> a;
  rep(i, 0, 25) {
    char ch = char(i + 'a');
    int val = INF;
    rep(j, 0, N - 1) { val = min(val, mp[j][ch]); }
    a[ch] = val;
  }
  for (auto x : a) {
    while (x.second) {
      cout << x.first;
      x.second--;
    }
  }
  cout << endl

      ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

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

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

typedef pair<ll, pair<ll,ll>> P;
typedef vector<P> V;

ll calc_h(const P& p, int cx, int cy) {
    return abs(p.se.fi - cx) + abs(p.se.se - cy);
}


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N; cin >> N;

    V v(N);
    REP(i, N) {
        ll x, y; ll h;
        cin >> x >> y >> h;
        v[i] = {h, {x, y}};
    }

    sort(ALL(v), greater<>());

    REP(cx, 101) REP(cy, 101) {
        if (v[0].fi == 0) {
            // all 0
            ll h = INF;
            REP(i, N) {
                h = min(h, calc_h(v[i], cx, cy));
            }

            if (h == 0) continue;

            cout << cx << " " << cy << " " << h << endl;
            return 0;
        } else {
            // at least one elm is larger than 0.
            ll h = v[0].fi + calc_h(v[0], cx, cy);
            bool f = true;
            FOR(i, 1, N) {
                if (v[i].fi == 0) {
                    if (h - calc_h(v[i], cx, cy) > 0) {
                        f = false;
                        break;
                    }
                } else {
                    ll hi = v[i].fi + calc_h(v[i], cx, cy);
                    if (h != hi) {
                        f = false;
                        break;
                    }
                }
            }

            if (!f) continue;

            cout << cx << " " << cy << " " << h << endl;
            return 0;
        }
    }

}


Measured memory_bytes: 256
import math
a,b,c,d=map(int,input().split())
a1,a2=0,0
if(c%b==0):
	a1=math.floor(c/b)
else:
	a1=math.floor(c/b)+1	
if(a%d==0):
	a2=math.floor(a/d)
else:
	a2=math.floor(a/d)+1
	# print(a1,a2)
if(a1>a2):
	print("No")
else:
	print("Yes")

Measured memory_bytes: 9192
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    a,b = map(int, input().split())

    f = 0
    if a > b:
        a,b = b,a
        f = 1
    if a == 1:
        b += 1

    d = [[-1]*100 for _ in range(100)]
    for i in range(100):
        for j in range(100):
            if a == 1:
                d[i][j] = 1
                if i >= 1:
                    if d[i-1][j] == 1:
                        b += 1
                continue
            if (i+j)%2 == 0:
                d[i][j] = 0
                a -= 1
            else:
                d[i][j] = 1
                b -= 1
        if a == 1:
            k = i
            break

    if k%2 == 0:
        b -= 2
    else:
        b -= 1
    for i in range(100):
        d[k+1][i] = 1
        if d[k][i] == 0:
            b += 1
    for i in range(100):
        d[k+2][i] = 0

    if b == -1:
        b = 0
    for i in range(k+3, 100, 2):
        for j in range(100):
            if b == 0:
                break
            if (i+j)%2 == 0:
                d[i][j] = 0
            else:
                d[i][j] = 1
                b -= 1
        else:
            continue
        break

    print(100, 100)
    if f:
        for i in range(100):
            res = []
            for j in range(100):
                if d[i][j] == 1:
                    res.append('.')
                else:
                    res.append('#')
            print(*res, sep='')
    else:
        for i in range(100):
            res = []
            for j in range(100):
                if d[i][j] == 1:
                    res.append('#')
                else:
                    res.append('.')
            print(*res, sep='')

if __name__ == '__main__':
    main()

Measured memory_bytes: 4972
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll h, w; cin >> h >> w;
    vector<string> board(h);
    rep(i, h) cin >> board[i];
    vvll h_board(h, vll(w)), v_board(h, vll(w));
    ll count = 0;
    rep(i, h) {
        count = 0; 
        rep(j, w) {
            if (board[i][j] == '#') {
                count = 0;
            } else {
                count++;
                h_board[i][j] = count;
            }
        }
        count = -1;
        for (int j = w - 1; j >= 0; j--) {
            if (board[i][j] == '#') count = -1;
            else {
                count = max(count, h_board[i][j]);
                h_board[i][j] = count;
            }
        }
    }

    rep(j, w) {
        count = 0;
        rep(i, h) {
            if (board[i][j] == '#') {
                count = 0;
            } else {
                count++;
                v_board[i][j] = count;
            }
        }
        count = -1;
        for (int i = h - 1; i >= 0; i--) {
            if (board[i][j] == '#') count = -1;
            else {
                count = max(count, v_board[i][j]);
                v_board[i][j] = count;
            }
        }
    }

    /*
    for (auto elem1 : h_board) {
        for (auto elem : elem1) cout << elem << " "; cout << endl;
    }
    cout << endl;
    for (auto elem1 : v_board) {
        for (auto elem : elem1) cout << elem << " "; cout << endl;
    }
    cout << endl;
    */

   ll max_num = 0;
   rep(i, h) rep(j, w) {
       max_num = max(max_num, h_board[i][j] + v_board[i][j] - 1);
   }
   cout << max_num << endl;
    return 0;
}

Measured memory_bytes: 67072
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (200001)
#define MOD (1000000007)

ll gcd(ll a, ll b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}

//素数判定
#define ER_MAX (1000000)
int er[ER_MAX+1];
void calcPrime(void)
{
    int i;
    er[0] = false;
    er[1] = false;
    for(i=2;i<=ER_MAX;i++) er[i] = 2;

    i = 2;
    while(i<=ER_MAX)
    {
        if(er[i]==2)
        {
            er[i] = 1;
            int j = i*2;
            while(j<=ER_MAX)
            {
                er[j] = 0;
                j += i;
            }
        }
        i++;
    }
}



int main(void)
{
    ll a,b;
    scanf("%ld %ld",&a,&b);

    ll g = gcd(a,b);
    calcPrime();

    if(g==1)
    {
        printf("1\n");
        return 0;
    }

    ll ans=1;
    ll g2 = g;
    for(ll i=2;i*i<=g;i++)
    {
        if(!er[i]) continue;
        if(g2%i==0)
        {
            ans++;
            while(g2%i==0) g2/=i;
            if(g2==1) break;
        }
    }
    if(g2!=1) ans++;

    printf("%ld\n", ans);
    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 X, K, D;
  cin >> X >> K >> D;
  if (K < abs(X) / D)
    cout << abs(X + (0 <= X ? -1 : 1) * K * D) << endl;
  else
  {
    K -= abs(X) / D;
    if (K % 2 == 0)
      cout << abs(X + (0 <= X ? -1 : 1) * (abs(X) / D) * D) << endl;
    else
      cout << abs(X + (0 <= X ? -1 : 1) * (abs(X) / D + 1) * D) << endl;
  }
  return 0;
}


Measured memory_bytes: 3620
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if l[i]+l[j]>l[k] and l[i]<l[j]<l[k]:
                ans += 1
print(ans)

Measured memory_bytes: 9132
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        long[] a = sc.nextLongArray(3);
        Arrays.sort(a);
        pw.println(a[0]*a[1]/2);
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 25464
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <cmath>
using namespace std;
typedef pair <int, int> pii;
pii p[200010];
struct node
{
    node* l;
    node* r;
    int val;
    node():l(NULL),r(NULL),val(0){}
};
node* t;
int getval(node* t)
{
    if (t==NULL) return 0;
    return t->val;
}
void update(node* t,int l, int r, int pos, int val)
{
    if (l==r)
    {
        t->val=val;
        return;
    }
    int m=(l+r)/2;
    if (pos<=m)
    {
        if (t->l==NULL) t->l=new node();
        update(t->l,l,m,pos,val);
    }
    else
    {
        if (t->r==NULL) t->r=new node();
        update(t->r,m+1,r,pos,val);
    }
    t->val=max(getval(t->l),getval(t->r));
}
int query(node* t, int l, int r, int L, int R)
{
    if (L>R) return 0;
    if (l==L && r==R)
        return t->val;
    if (t->l==NULL) t->l=new node();
    if (t->r==NULL) t->r=new node();
    int m=(l+r)/2;
    return max(query(t->l,l,m,L,min(m,R)),query(t->r,m+1,r,max(m+1,L),R));
}
int main()
{
    t=new node();
    int x1,y1,x2,y2;
    int n,i;
    scanf("%d%d%d%d%d",&x1,&y1,&x2,&y2,&n);
    if (x1>x2)
    {
        swap(x1,x2);
        swap(y1,y2);
    }
    if (x1==x2 && y1>y2) swap(y1,y2);
    for (i=1;i<=n;i++) scanf("%d%d",&p[i].first,&p[i].second);
    sort(p+1,p+n+1);
    for (i=1;i<=n;i++)
    {
        if (p[i].first>=x1) break;
    }
    for (;i<=n;i++)
    {
        if (p[i].first>x2) break;
        if (y1<=y2)
        {
            if (p[i].second<y1 || p[i].second>y2) continue;
            update(t,0,1e8,p[i].second,query(t,0,1e8,0,p[i].second)+1);
        }
        else
        {
            if (p[i].second>y1 || p[i].second<y2) continue;
            update(t,0,1e8,p[i].second,query(t,0,1e8,p[i].second,1e8)+1);
        }
    }
    int x=query(t,0,1e8,0,1e8);
    if (x1==x2 || y1==y2) printf("%0.16lf\n",(double)(abs(x1-x2)+abs(y1-y2))*100.0-x*(20-10*acos(-1.0))); else
        if (x==min(abs(x1-x2),abs(y1-y2))+1)
        printf("%0.16lf\n",(double)(abs(y1-y2)+abs(x1-x2))*100.0-((x-1)*(20-5*acos(-1.0)))-(20-10*acos(-1.0))); else
    printf("%0.16lf\n",(double)(abs(y1-y2)+abs(x1-x2))*100.0-(x*(20-5*acos(-1.0))));
    return 0;
}


Measured memory_bytes: 110336
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 1e18;
const ll fact_table = 800008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
// priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
// #define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
 
// ll mod = 998244353;
 ll mod = 1000000007;
  
ll mypow(ll number1,ll number2, ll mod){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,a,b,d,e,h,r,l,q;
ll w, ans;
ll k;
ll x[500005], y[500005], z[500005];
char s[500005], t[500005];

int main(){
    cin >> n;
    for(ll i=0;i<n;i++){
        cin >> x[i];
    }
    ll ans = INF;
    for(ll i=0;i<=100;i++){
        ll a = i;
        ll sum = 0;
        for(ll j=0;j<n;j++){
            sum += (x[j] - a) * (x[j] - a);
        }
        ans = min(ans, sum);
    }
    p(ans);
    return 0;

}


















Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

vector<int> enum_div(int n) {
  vector<int> ret = {1, n};
  
  for (int i = 2; i*i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i*i != n) ret.push_back(n/i);
    }
  }
  
  return ret;
}

int main() {
  int n, x; cin >> n >> x;
  
  vector<int> city(n);
  for (int i = 0; i < n; i++) {
    int c; cin >> c;
    city[i] = abs(c - x);
  }
  
  int mini = *min_element(city.begin(), city.end());
  vector<int> v_df = enum_div(mini);
  sort(v_df.rbegin(), v_df.rend());
  
  bool found = false;
  int ans = 1;
  
  for (int df : v_df) {
    found = true;
    for (int i = 0; i < n; i++) {
      if (city[i] % df != 0) {
        found = false;
        break;
      }
    }
    if (found) {
      ans = df;
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        m: usize,
        c: i64,
        B: [i64; m],
        A: [[i64; m]; n],
    }
    let mut ans = 0;
    for a in A {
        let mut acc = 0;
        for i in 0..m {
            acc += a[i] * B[i]
        }
        if acc + c > 0 {
            ans += 1
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

// reference: http://ir5.hatenablog.com/entry/20171209/1512821837

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let a: u32 = sc.read();
    let b: u32 = sc.read();
    if b == 1 {
        println!("{}", 0);
        return;
    }
    for i in 1..40 {
        if a * i - (i - 1) >= b {
            println!("{}", i);
            break;
        }
    }
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans=0;
  int r=0;
  for(int i=0;i<n;i++) if(s[i]=='R') r++;
  for(int i=0;i<r;i++) if(s[i]=='W') ans++;
  
    
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3740
import math

N = int(input())
X = list(map(int, input().split()))

L = min(X)
R = max(X)

result = 10**18
for i in range(L, R + 1):
    cost = 0
    for j in X:
        distance = (j - i)**2
        cost += distance
    result = min([result, cost])

print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define quick                    \
    ios::sync_with_stdio(false); \
    cin.tie(0);
#define time cerr << (0.1 * clock()) / CLOCKS_PER_SEC << endl;
#define mod 1000000007
typedef long long ll;
typedef pair<ll, ll> pl;
#define forn(n) for (ll i = 0; i < ll(n); i++)

void solve() {
    int n;
    cin >> n;
    map<string, bool> m;
    forn(n) {
        string s;
        cin >> s;
        m[s] = true;
    }
    cout << m.size() << '\n';
}

int main() {
    quick;
    solve();
    // ll t;
    // cin >> t;
    // while (t--) {
    //     solve();
    // }
}

Measured memory_bytes: 19248
#include<stdio.h>

int main(void){
  int K;
  int A,B,c=0;
  scanf("%d",&K);
  scanf("%d %d",&A,&B);
  for(int i=A;i<=B;i++){
    if(i%K==0){
      c++;
      break;
    }
  }
  if(c>0){
    printf("OK\n");
  }else{
    printf("NG\n");
  }
  return 0;
}

Measured memory_bytes: 1628
#include <iostream>

using namespace std;

int main()
{
    int n,i;
    cin>>n;
    long int a[n+1],b[n],c=0;
    for(i=0;i<n+1;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n;i++)
    {
        cin>>b[i];
    }

    for(i=0;i<n;i++)
    {
        if(b[i]>a[i])
        {
            c+=b[i];
            a[i+1]-=(b[i]-a[i]);
            if(a[i+1]<0)
            {
                c+=a[i+1];
                a[i+1]=0;
            }
        }
        else
        {
            c+=b[i];
        }
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>

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

  int N;  std::cin >> N;
  N %= 10;
  if (N == 3)
    std::cout << "bon\n";
  else if (N == 0 or N == 1 or N == 6 or N == 8)
    std::cout << "pon\n";
  else
    std::cout << "hon\n";


  return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;



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

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

long long ans=0;
for(int i=0;i<n;i++)
ans+= a[i]-1;

cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(kbd.hasNext()){
	    int n = kbd.nextInt();
	    if(n!=0){
		int i, k, m, x;
		boolean[][] p = new boolean[n+1][n+1];
		for(i=1; i<=n; i++){
		    m = kbd.nextInt();
		    //p[i][i] = true;
		    while(m>0){ 
			x = kbd.nextInt();
			p[i][x] = true;
			m--;
		    }
		}
		k = kbd.nextInt();
		while(k>0){
		    x = kbd.nextInt();
		    p[0][x] = true;
		    k--;
		}
		
		int a = 0;
		int b = n;
		while(b>0){
		    a = judge(p, n, a, b);
		    b--;
		    //System.out.println(a);
		}
		if(a<=0)
		    System.out.println("-1");
		else 
		    System.out.println(a);
	    }
	}
    }

    public static int judge(boolean[][] p, int n, int a, int b){
	boolean u = true;
	int i;
	for(i=1; i<=n; i++){
	    if(p[0][i]) {
		u = u && (p[0][i]&&p[b][i]);
		//System.out.println(p[0][i]+" "+p[b][i]);
	    }
	    else {
		//System.out.println(p[0][i]+" "+p[b][i]);
		;
	    }
	}
	//System.out.println(b+" "+a+" "+u);
	if(a==0){
	    if(u) return b;  //n番の人が初めて合致した
	    else return 0;   //まだ見つからない
	}
	else {
	    if(u) return -1;
	    else return a; 
	}
    }
}

Measured memory_bytes: 64996
import java.util.Scanner;
 
public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int K = scanner.nextInt();
    long c = 0;
    long g = 0;
      for(int i = 1; i <= N; i++){
        if(i%K==0){
          c++;
        }else if(K%2==0 && i%K==K/2){
          g++;
        }
      }
    System.out.println(c*c*c+g*g*g);
  }
}

Measured memory_bytes: 23636
from heapq import heappush, heappop

INF = 10 ** 18

def dijkstra(n, G, s):
    dist = [INF] * n
    dist[s] = 0
    h = []
    heappush(h, (0, s))

    while h:
        # 使っていない頂点のうち、現時点で最も距離の近いものを選びvとする
        d, v = heappop(h)
        if dist[v] < d:
            continue
        # vから到達可能な頂点について、距離が短くなれば更新
        for b, cost in G[v]:
            if dist[b] > dist[v] + cost:
                dist[b] = dist[v] + cost
                heappush(h, (dist[b], b))
    return dist

n, x, y = map(int, input().split())

g = [[] for i in range(n)]

for i in range(n-1):
    g[i].append((i+1, 1))
    g[i+1].append((i, 1))

g[x-1].append((y-1, 1))
g[y-1].append((x-1, 1))

ans = [0] * n

for i in range(n):
    for d in dijkstra(n, g, i):
        ans[d] += 1

for item in ans[1:]:
    print(item // 2)



Measured memory_bytes: 59612