akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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;
}

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;

int N;
string item;
set<string> items;

void solve() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> item;
        items.insert(item);
    }
    cout << items.size();
        
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 19092
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define int_maxvalue numeric_limits<int>::max()
int n, k;
set<string>a;
string strs[10];
void put() {
	if (k == 2) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i == j) { continue; }
				a.insert((strs[i] + strs[j]));
			}
		}
	}
	if (k == 3) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				for (int i1 = 0; i1 < n; i1++) {
					if (i == j || i == i1 || j == i1) { continue; }
					a.insert((strs[i] + strs[j] + strs[i1]));
				}
			}
		}
	}
	if (k == 4) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i == j) { continue; }
				for (int i1 = 0; i1 < n; i1++) {
					if (i == i1 || j == i1) { continue; }
					for (int i2 = 0; i2 < n; i2++) {
						if (i == i2 || j== i2 || i2 == i1) { continue; }
						a.insert((strs[i] + strs[j] + strs[i1]+strs[i2]));
					}
				}
			}
		}
	}
	return;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (true) {
		cin >> n >> k;
		a.clear();

		if (n == 0 && k == 0) { break; }
		rep(i, n) { cin >> strs[i]; }
		put();
		cout << a.size() << endl;
	}
	return 0;
}


Measured memory_bytes: 3260
#(0)環境
from itertools import accumulate
import bisect
n, m, k = map(int,input().split())
#[0]足すことで上から０冊読んだという要素として加えると実装が楽に(一冊も読めんかった)
#accumulate:累積和などが求められる
a = [0] + list(accumulate(map(int,input().split())))
b = [0] + list(accumulate(map(int,input().split())))
ans =[0]

for i in range(n + 1):
    c = bisect.bisect_right(b, k - a[i]) - 1
    #k-s<0のときはインデックスがー１なので除外しなあかん
    if c != -1:
        ans.append(c + i)
print(max(ans))


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


int main() {
  int N, X; cin >> N >> X;
  vector<int> m(N);
  int sum = 0;
  int min_m = 1000;

  for(int i=0; i<N; i++){
    cin >> m[i];
    sum += m[i];
    min_m = min(min_m, m[i]);
  }

  cout << N+((X-sum)/min_m) << endl;



  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int X,A,B;
	cin>>X>>A>>B;
 
 
 if(X< B-A ) cout << "dangerous"<<endl;
else if (B-A>0) cout <<"safe"<<endl;
 else cout << "delicious"<<endl;
 
 
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int foo(int S, vector<int>& c, vector<int>& a, vector<char>& memo) {
	if (memo[S] != -1) return memo[S];
	int n = c.size(), cnt = 0;
	vector< vector<int> > v(4);
	for (int i = 0; i < n; i++)
		if (S & (1 << i)) {
			cnt++;
			if (!(S & a[i])) v[c[i] - 1].push_back(i);
		}	
	int mini = cnt;
	for (int j = 0; j < 4; j++) {
		int m = v[j].size();
		for (int k = 0; k < m; k++)
			for (int _k = k + 1; _k < m; _k++) {
				int _S = S - (1 << v[j][k]) - (1 << v[j][_k]);
				mini = min(mini, foo(_S, c, a, memo));
			}
	}
	return memo[S] = mini;
}

int main() {
	for (;;) {
		int n; cin >> n;
		if (n == 0) break;
		vector<int> x(n), y(n), r(n), c(n);
		for (int i = 0; i < n; i++)
			cin >> x[i] >> y[i] >> r[i] >> c[i];
		vector<int> a(n);
		for (int i = 0; i < n; i++)
			for (int j = 0; j < i; j++) {
				int dx = x[i] - x[j], dy = y[i] - y[j], d = r[i] + r[j];
				if (dx * dx + dy * dy < d * d) a[i] |= (1 << j);
			}
		vector<char> memo(1 << n, -1);
		cout << n - foo((1 << n) - 1, c, a, memo) << endl;
	}
}

Measured memory_bytes: 17704
/** In the Name of ALLAH */


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define PB push_back
#define F first
#define S second
#define MP make_pair
#define endl '\n'
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int dx[] = {0, 0, +1, -1, +1, +1, -1, -1};
int dy[] = {+1, -1, 0, 0, +1, -1, +1, -1};

inline ll gcd ( ll a, ll b ) { return __gcd (a, b); }
inline ll lcm ( ll a, ll b ) { return ( a * ( b / gcd (a, b) ) ); }



#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}


int main()
{
	optimize();

	int n, cnt = 0, a;
	cin >> n;
	for ( int i = 1; i <= n; i++ ) {
		cin >> a;
		if ( i % 2 == 1 && a % 2 == 1 ) cnt++;
	}

	cout << cnt <<  endl;

	return 0;
}



Measured memory_bytes: 3604
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int a,b,k,x[100]={0},i,j,c=0;
	scanf("%d%d%d",&a,&b,&k);
	if(a>b){
		swap(a,b);
	}
	for(i=a;i>=1;i--){
		if(a%i==0&&b%i==0){
			c++;
			x[c]=i;
		}
	}
	printf("%d\n",x[k]);
	return 0;
}


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

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    string s;cin>>s;
    int a[n];
    int cnt[3];
    fill(cnt,cnt+3,0);
    rep(i,0,n){
        a[i]=s[i]-'0'-1;
        cnt[a[i]]++;
    }
    if(cnt[1]==0){
        rep(i,0,n)a[i]/=2;
    }
    int num[1000001];
    num[0]=0;
    rep(i,1,1000001){
        num[i]=num[i-1];
        int u=i;
        while(u%2==0){
            num[i]++;
            u/=2;
        }
    }
    int ans=0;
    rep(i,0,n){
        if(a[i]==1){
            int ri=n-i-1;
            int le=i;
            int f=num[le+ri]-num[le]-num[ri];
            if(f==0)ans^=1;
        }
    }
    if(cnt[1]==0)ans*=2;
    cout<<ans<<endl;
}


Measured memory_bytes: 9116
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	unordered_map<int,int> mp;
	rep(i,n){
		cin >> a[i];
		mp[a[i]]++;
	}
	sort(all(a));
	a.erase(unique(all(a)),a.end());
	int m = a.size();
	int cnt = 0;
	rep(i,m){
		cnt += mp[a[i]] - 1;
	}
	cout << m - cnt % 2 << '\n';
	return 0;
}


Measured memory_bytes: 5156
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <vector>
#include <climits>
#include <queue>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
template<typename T1, typename T2>
inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2>
inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
const ll MOD = 1000000007;
const ll INF = 1LL << 60;


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

	if (n == 0) {
		cout << x;
		return 0;
	}

	vector<int> p(n);
	vector<bool> data(110, true);
	rep(i, n)
		cin >> p[i];

	rep(i, n) {
		data[p[i]] = false;
	}
	
	int ans = 10000;
	rep(i, 110) {
		if (data[i]) {
			if (abs(x - i) < abs(ans - x))
				ans = i;
			if (abs(x - i) == abs(ans - x)) {
				if (i < ans)
					ans = i;
			}
				
		}

	}



	cout << ans;
	

}




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

const int M = 1e9+7;

int main(){
	int n;
	cin>>n;
	long long int p = 1;

	for(int i=1;i<=n;i++){
		p*=i;
		if(p>M) p%=M;
	}
	cout<<p;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<algorithm>
#include<functional>
using namespace std;
int main() {
    int h,w,i,j,f;
    char s[100][100];
    cin>>h>>w;
    for(i=1;i<=h;i++){
        for(j=1;j<=w;j++){
            cin>>s[i][j];
        }
    }
    i=0;
    for(i=1;i<=h;i++){
        for(j=1;j<=w;j++){
            if(s[i][j]=='#'){
                if(s[i][j-1]=='#'||s[i-1][j]=='#'||s[i][j+1]=='#'||s[i+1][j]=='#'){
                    f=1;
                }else{
                    f=0;
                    goto fin;
                }
            }
        }
    }
fin:
    if(f){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int a[1000],n,m,ans;
int main(){
	while(true){cin>>n>>m;if(n==0&&m==0)break;ans=0;for(int i=0;i<n;i++){cin>>a[i],ans+=a[i];}sort(a,a+n);for(int i=n%m;i<n;i+=m)ans-=a[i];cout<<ans<<endl;}
	return 0;
}

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

using namespace std;


int main() {
    int N, M;
    array<array<int, 2>, 100000> A;
    long long res = 0;

    cin >> N >> M;

    for (int i = 0; i < N; i++) {
        cin >> A[i][0] >> A[i][1];
    }

    sort(&A[0], &A[N], [](auto &x, auto &y) { return x[0] < y[0]; });

    int i = 0;
    while (M > 0) {
        res += A[i][0];
        M -= 1;
        A[i][1] -= 1;
        if (A[i][1] == 0) {
            i++;
        }
    }

    cout << res;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
string s;
int main() {
  cin>>s;
  if (s[0] == 'a' || s[0] == 'e' || s[0] == 'i' || s[0] == 'o' || s[0] == 'u') {
  	cout<<"vowel"<<endl;
  } else {
  	cout<<"consonant"<<endl;
  }
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
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)*}
    };
}
#[allow(unused_macros)]
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)*}
    };
}
#[allow(unused_macros)]
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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

use std::cmp::min;

fn main() {
    input! {
        n: usize,
        k: usize,
        h: [i32; n],
    }
    let mut dp = vec![std::i32::MAX; n];
    dp[n - 1] = 0;
    for i in (0..n-1).rev() {
        for diff in 1..(k + 1) {
            if i + diff >= n { break; }
            dp[i] = min(dp[i], dp[i + diff] + (h[i + diff] - h[i]).abs());
        }
    }
    println!("{}", dp[0]);

} 


Measured memory_bytes: 4352
#include<stdio.h>
#define M 10000

int main(){
  int n, S[M], q, T[M], i ,j, count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);

  
  scanf("%d",&q);
  for(i=0;i<q;i++)
    scanf("%d",&T[i]);

  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(S[i]==S[j])
	S[j]=-1;
    }
  }

  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(T[i]==T[j])
	T[j]=-1;
    }
  }
  
  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(T[i]==S[j])count++;
    }
  }

  printf("%d\n",count);
  
  return 0;
}



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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
ll a,b,n;

ll fn(ll x)
{
     ll res = (a*x)/b , res2 = a*(x/b);
     res -= res2;
    return res;
}

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

    cin >> a >> b >> n;

    ll lf=0 , rt=n , m1 , m2;
    while(rt-lf > 3)
    {
        m1 = lf+(rt-lf)/3;
        m2 = rt-(rt-lf)/3;
        if (fn(m1) > fn(m2)) rt = m2;
        else lf = m1;
    }

    ll ans=-1e18;
    for(lf; lf<=rt; lf++)
    {
        ans = max(ans , fn(lf));
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
using namespace std;

int main() {
	int k=0,c=0;
	bool ans=false;
	char S[101],T[101];
	cin>>S>>T;
	for(int i=0;i<strlen(S);i++)
	{
		k=i;
		for(int j=0;j<strlen(S);j++)
		{
			if(S[k%(strlen(S))]==T[j])c++;
			k++;
		}
		if(c==strlen(S))ans=true;
		c=0;
	}
	if(ans)cout<<"Yes";
	else cout<<"No";
	}

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

constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
using ll = long long int;
using ull =  unsigned long long int;

int main() {
	ll N;
	cin >> N;
	ll ans = 0;
	if (N == 1) {
		cout << 0 << endl;
		return 0;
	}
	for (ll i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			ll s = 0;
			s = N / i - 1;
			if (N / s == N % s)ans += s;
			if (i != 1 && i * i != N) {
				s = N / (N / i) - 1;
				if (N / s == N % s)ans += s;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(int i=a; i<b; i++)
#define loopb(i, a, b) for(int i=a; i>=b; i--)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli power(lli x, lli y, lli p){
    lli res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int main(){
	fastio;
	lli n;
	cin>>n;
	vll S(n);
	loop(i, 0, n)
		cin>>S[i];
	lli ans = 0;
	loop(i, 0, n-1){
		loop(j, i+1, n){
			ans += (S[i] * S[j]);
		}
	}
	cout<<ans<<"\n";
}


Measured memory_bytes: 256
N,Q = map(int,input().split())
S = input()
t = [0]*(N+1)
l = [0]*Q
r = [0]*Q
for i in range(N-1):
	t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l,r = map(int,input().split())
    print(t[r-1]-t[l-1])

Measured memory_bytes: 14604
#include <stdio.h>

int main(int argc, char const *argv[])
{
    int x, y;

    scanf("%d", &x);

    if (x)
    {
        y = 0;
    }
    else
    {
        y = 1;
    }

    printf("%d\n", y);

    return 0;
}


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

void solve(long long N, std::vector<long long> A)
{
    if (any_of(begin(A), end(A), [](auto a) { return a == 0; })) {
        cout << 0 << endl;
        return;
    }
    ll ans = 1;
    for (ll i = 0; i < N; i++) {
        auto ans_p = ans;
        ans *= A[i];
        if (ans > (ll)1e18 || ans < ans_p) {
            cout << -1 << endl;
            return;
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4056
n = int(input())
h = list(map(int, input().split()))
ans = 0
def reverse():
    p = h.index(max(h))
    a = 0
    if p == n-1:
        a += 1
        h[p] -= 1
        return a
    elif h[p] == h[p+1] and p < n-1:
        h[p] -= 1
        return a
    else:
        a += 1
        h[p] -= 1
        return a

while sum(h) > 0:
    ans += reverse()
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main (int argc, char *argv[]) 
{
    int N;
    cin >> N;

    int ans = 0;
    for (int i = 1; i <= N; i++)
    {
        string str = to_string(i);
        if (str.length() % 2 == 1)
        {
            ans++;
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))
dp = [float('inf')]*N
dp[0] = 0
for i in range(N-1):
    dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1]-h[i]))
    if i+2<N:
        dp[i+2] = min(dp[i+2], dp[i]+abs(h[i+2]-h[i]))
print(dp[-1])


Measured memory_bytes: 52552
#include<iostream>
#include<queue>

using namespace std;

typedef struct{
    char name[10];
    int time;
}Quantum;

int main(){
    int n,q,total = 0;
    cin >> n >> q;
    Quantum Q[100000];
    queue<Quantum> exec;

    for(int i=0;i < n;i++){
        cin >> Q[i].name >> Q[i].time;
        exec.push(Q[i]);
    }
    
    while(!exec.empty()){
        Quantum tmp = exec.front();exec.pop();
        if(tmp.time - q <= 0){
            total += tmp.time;
            cout << tmp.name << " " << total << endl;
        }else{
            total += q;
            tmp.time -= q;
            exec.push(tmp);
        }
    }

    return 0;
}


Measured memory_bytes: 4480
#include <stdio.h>

int main(void)
{
	int h, m, s;
	int sec;
	
	while (1){
		scanf("%d%d%d", &h, &m, &s);
		if (h == -1 && m == -1 && s == -1){
			break;
		}
		
		sec = h * 3600 + m * 60 + s;
		sec = 2 * 3600 - sec;
		
		
		printf("%02d:%02d:%02d\n", sec / 3600, (sec / 60) % 60, sec % 60);

		sec *= 3;
		printf("%02d:%02d:%02d\n", sec / 3600, (sec % 3600) / 60, sec % 60);
	}
	return (0);
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
typedef long long lint;

int N, A, B;
lint dp[55][55], cnt[55][55];

int main() {
	cin >> N >> A >> B;
	
	memset(dp, 0, sizeof(dp));
	memset(cnt, 0, sizeof(cnt));
	cnt[0][0] = 1;
	
	for_(i,0,N) {
		lint v; cin >> v;
		for_(j,0,i+1) {
			if (cnt[i][j] == 0) continue;
			
			for_(b,0,2) {
				lint &pre = dp[i+1][j+b], nxt = dp[i][j] + b * v, &pre_c = cnt[i+1][j+b];;
				if (pre <= nxt) {
					pre_c = (pre == nxt ? pre_c : 0) + cnt[i][j];
					pre = nxt;
				}
			}
		}
	}
	
	long double ans_v = 0;
	lint ans_c = 0;
	for_(i,A,B+1) {
		long double val = (long double)dp[N][i] / i;
		if (ans_v <= val) {
			ans_c = (ans_v == val ? ans_c : 0) + cnt[N][i];
			ans_v = val;
		}
	}
	printf("%.9Lf\n%Ld\n", ans_v, ans_c);
}

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

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

Measured memory_bytes: 256
#include <stdio.h>


int main(){

 int n,i,l,j,k,ans;
  int p[100];
 int m[100][100];

 scanf("%d",&n);

 for(i = 1; i <= n; i++)
  scanf("%d %d",&p[i-1],&p[i]);
  
 for(i = 1; i <= n; i++)
   m[i][i] = 0;
 
 for(l = 2; l <=n; l++){
  for(i = 1; i <= n-l+1; i++){
   j = i + l - 1;
   m[i][j] = 100000000000000;
    for(k = i; k < j;k++){
     if(m[i][j] > m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j])
      m[i][j] = m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j];
    }
   }
  }

 
      
 printf("%d\n",m[1][n]);
 
 return 0;
}

Measured memory_bytes: 636
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApplication1
{

    class Program
    {

        static void Main(string[] args)
        {


            string[] str = Console.ReadLine().Split(' ');

            long n = long.Parse(str[0]);
            long p = long.Parse(str[1]);
            var list = new List<long>();
            
            var pri = new Dictionary<long, long>();

            if (p == 1 || n == 1)
            {
                Console.WriteLine(p);
                return;
            }

            long ans = 1;

            for (int i = 2; i <= Math.Sqrt(p); i++)
            {              
                while (p % (long)Math.Pow(i, n) == 0)
                {
                    ans *= i;
                    p /= (long)Math.Pow(i, n);
                }
            }
           
            Console.WriteLine(ans);

        }

    }



}
    


Measured memory_bytes: 13268
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>

using namespace std;
typedef long long ll;

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

    ll a=0;
    ll temp=0;
    ll ans=0;
    ll anss =0;
    string x;
  
    vector<ll> z;
    ll N;

    cin>>N;

    cin >> x;
    if(N==1){
        cout << 1 << endl;
        return 0;
    }
    std::vector<char> y(x.begin(), x.end());
    sort(y.begin(),y.end());
     //cout << y[1] << endl;
    for(ll i=0;i<N-1;i++){
        temp++;
        if(i<N-2){
            if(y[i]!=y[i+1]){
                z.push_back(temp);
                //cout << z[a] << endl;
                a++;
                temp=0;
            }
        }else{
            if(y[i]!=y[i+1]){
                z.push_back(temp);
                a++;
                z.push_back(1);
            }else{
                temp++;
                z.push_back(temp);
            }
        }

    }

    ans=1;
    for(ll i=0;i<z.size();i++){
        ans=ans*(z[i]+1);
        if(ans>1000000000+7){
            ans=ans%(1000000000+7);
        }
    }
ans=ans-1;

ans=ans%(1000000000+7);
    


    cout << ans << endl;
    

}

Measured memory_bytes: 592
// AOJ 2917: Pray
// 2019.2.17 bal4u

#include <stdio.h>
#include <stdlib.h>

int main()
{
	int h, w, x, y;

	scanf("%d%d%d%d", &h, &w, &x, &y);
	if ((h*w & 1) && ((x+y) & 1)) puts("No");
	else puts("Yes");
	return 0;
}



Measured memory_bytes: 2052
#include<iostream>
#include<vector>
#define F(i,n) for(int i=0;i<n;i++)
#define lli long long int
#define vi vector<int>
#define vll vector<long long>
#define pb(x) .push_back(x)
using namespace std;
void printVector(vector<int> v)
{
    char ch = ' ';
    for(int i=0;i<v.size();i++)
    {
        printf("%d",v[i]);
        printf("%c",ch);
    }

}


int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    string s;
    cin>>s;
    lli sum = 0;
    for(int i = 0;s[i]!='\0';i++)
    sum+=s[i]-'0';
    if(sum%9==0)
    cout<<"Yes";
    else
    {
        cout<<"No";
    }
    
 return 0;
}

Measured memory_bytes: 3384
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  ll N, T; cin >> N >> T;
  ll t[N]; rep(i, N) cin >> t[i];

  ll result = T;
  for(int i=N-2; i>=0; i--) result += min(t[i+1]-t[i], T);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1792
N = int(input())
X = []
Y = []
for i in range(N):
    x, y = [int(n) for n in input().split()]
    X.append(x)
    Y.append(y)
ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        ans += ((X[j]-X[i])**2 + (Y[j]-Y[i])**2)**0.5
print(ans*2/N)


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

using namespace std;

int main()
{
    int n, x, t;
    cin >> n >> x >> t;
    int p = n/x;
    int r = n%x;
    cout << (p * t + (r ? max(r/x, 1) * t : 0)) << '\n';
    return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    long long int a, b; cin >> a >> b;
    if (a >= 1 && b >= 1) printf("%s\n", "Positive");
    else if (a <= 0 && b >= 0) printf("%s\n", "Zero");
    else {
        long long int c = abs(0 - a), d = abs(0 - b);
        if ((c + d - 1) % 2 == 0) printf("%s\n", "Positive");
        else printf("%s\n", "Negative");
    }
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> memo(N, 0);
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    memo.at(A - 1)++;
  }
  sort(memo.begin(), memo.end());
  reverse(memo.begin(), memo.end());
  int B = 0;
  for (int i = 0; i < K; i++) {
    B += memo.at(i);
  }
  cout << N - B << endl;
}

Measured memory_bytes: 4032
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  lint a, b, c; cin >> a >> b >> c;
  if (c - a - b < 0) cout << "No" << endl;
  else {
    if (4 * a * b < (c - a - b) * (c - a - b)) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}


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

int main()
{
	char b;
	cin>>b;
	
	if(b=='A') cout<<'T'<<endl;
	if(b=='T') cout<<'A'<<endl;
	if(b=='C') cout<<'G'<<endl;
	if(b=='G') cout<<'C'<<endl;
	
	return 0;
}


Measured memory_bytes: 256
/*

*/
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((ll)(x).size())
#define cin1(x) cin >> x
#define cin2(x, y) cin >> x >> y
#define cin3(x, y, z) cin >> x >> y >> z
#define cin4(x, y, z, _) cin >> x >> y >> z >> _
#define cin5(x, y, z, p, q) cin >> x >> y >> z >> p >> q
#define cou(x) cout << x
#define cous(x) cout << x << " "
#define coul(x) cout << x << "\n"
#define ret(x) return x
#define MAX 5000001
#define start int main() {   fastio
#define finish ret(0); }
#define Test ll _t cin1(_t); rep(i, 0, _t)

struct point{    int x, y, ind;   char ch;  };
typedef long long ll;
typedef vector<ll> VI;
typedef pair<ll,ll> PII;
typedef double db;
//mt19937 mrand(random_device{}());
const ll mod=1000000007;
//ll rnd(ll x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}ret(res);}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll fact[13];
void factorial() {   fact[0]=1;  rep(i, 1, 12) fact[i]=(fact[i-1]*i);  }
vector <ll> sie; //for sieve function
ll spf[MAX+7];  //for sieve function
void sieve() {    rep(i, 2, MAX)  {  if (spf[i] == 0) {  spf[i] = i;   sie.pb(i);  }    for (ll j=0; j<SZ(sie) && i*sie[j] <= MAX && sie[j] <= spf[i]; j++)   spf[i * sie[j]] = sie[j]; }   }
bool cmp(point A, point B){   if(A.x != B.x) ret(A.x < B.x);  ret(A.y < B.y);   }
// head collected

ll n, a, b, re, ans, ex;
string str;
char ara_a[55][55];
char ara_b[55][55];

start;

    cin3(n, a, b);
    re = n / (a + b);
    ans = re * a;
    ex = n % (a + b);
    if ( ex > a )
        ex = a;
    ans += ex;

    coul(ans);


finish


Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N,K = inpl()
dd = inpl()

def check(N):
	tmp = list(map(int,list(str(N))))
	for t in tmp:
		if t in dd:
			return False
	return True

while True:
	if check(N):
		print(N)
		break
	N += 1


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

int main(){
  long long N, A, B;
  cin >> N >> A >> B;
  vector<long long> x(N);
  long long ans=0;
  for(int i=0; i<N; i++){
    cin >> x.at(i);    
  }
  for(int i=0; i<N-1; i++){
    if((x.at(i+1)-x.at(i))*A<=B) ans+=(x.at(i+1)-x.at(i))*A;
    else ans+=B;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]
X = [0]*(N+1)
for i in A:
    X[i] += 1

ans = 0
for i in range(1, N+1):
    ans = K + X[i] - Q
    if ans > 0:
        print("Yes")
    else:
        print("No")

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

using Lint=long long;

template<int mod> class ModInt
{
 private:
    Lint val;
 public:
    Lint value(){ return val; }
    ModInt(Lint x=0){ val=x%mod; }
    ModInt pow(int n){
        ModInt res(1),x(val);
        while(n>0){ if(n&1) res*=x; x*=x; n>>=1; }
        return res;
    }
    ModInt inv(){ return pow(mod-2); }
    ModInt& operator+=(ModInt rhs){ val+=rhs.val; if(val>=mod) val-=mod; return *this; }
    ModInt& operator-=(ModInt rhs){ val+=mod-rhs.val; if(val>=mod) val-=mod; return *this; }
    ModInt& operator*=(ModInt rhs){ val=val*rhs.val%mod; return *this; }
    ModInt& operator/=(ModInt rhs){ *this*=rhs.inv(); return *this; }
    ModInt operator+(ModInt rhs){ return ModInt(val)+=rhs; }
    ModInt operator-(ModInt rhs){ return ModInt(val)-=rhs; }
    ModInt operator*(ModInt rhs){ return ModInt(val)*=rhs; }
    ModInt operator/(ModInt rhs){ return ModInt(val)/=rhs; }
};
using mint=ModInt<1000000007>;

template<class T> class Matrix
{
 public:
    vector<vector<T>> A;
    Matrix(int n):A(n,vector<T>(n)){}
    Matrix(int n,int m):A(n,vector<T>(m)){}

    vector<T>& operator[](int i){ return A[i]; }
    int height(){ return A.size(); }
    int width(){ return A[0].size(); }
    static Matrix I(int n){
        Matrix mat(n);
        for(int i=0;i<n;i++) mat[i][i]=1;
        return mat;
    }

    Matrix& operator+=(Matrix& B){
        int H=height(), W=width();
        for(int i=0;i<H;i++) for(int j=0;j<W;j++)
            A[i][j]+=B[i][j];
        return *this;
    }
    Matrix& operator-=(Matrix& B){
        int H=height(), W=width();
        for(int i=0;i<H;i++) for(int j=0;j<W;j++)
            A[i][j]-=B[i][j];
        return *this;
    }
    Matrix& operator*=(Matrix& B){
        int H=height(), W=B.width(), K=width();
        vector<vector<T>> C(H,vector<T>(W));
        for(int i=0;i<H;i++) for(int j=0;j<W;j++)
            for(int k=0;k<K;k++) C[i][j]+=A[i][k]*B[k][j];
        A.swap(C);
        return *this;
    }
    Matrix operator+(Matrix& B){ return Matrix(*this)+=B; }
    Matrix operator-(Matrix& B){ return Matrix(*this)-=B; }
    Matrix operator*(Matrix& B){ return Matrix(*this)*=B; }
    Matrix pow(Lint K){
        Matrix res=Matrix::I(height());
        Matrix B=*this;
        while(K>0){
            if(K&1) res*=B; B*=B; K>>=1;
        }
        return res;
    }
};

int main()
{
   Lint N,K; cin>>N>>K;
   Matrix<mint> G(N);
   for(int i=0;i<N;i++) for(int j=0;j<N;j++){ int t; cin>>t; G[i][j]=t; }

   G=G.pow(K);
   mint ans=0;
   for(int i=0;i<N;i++) for(int j=0;j<N;j++) ans+=G[i][j];
   cout<<ans.value()<<endl;
   return 0;
}


Measured memory_bytes: 384
n, m = map(int, input().split())
mat = [input() for _ in range(n)]

for i in range(n):
    for j in range(m):
        if mat[i][j] == '.':
            score = 0
            if not i == 0:
                if mat[i-1][j] == '#': score += 1
            
            if not i == n - 1:
                if mat[i+1][j] == '#': score += 1
            
            if not j == 0:
                if mat[i][j-1] == '#': score += 1
            
            if not j == m - 1:
                if mat[i][j+1] == '#': score += 1
            
            if not i == 0 and not j == 0:
                if mat[i-1][j-1] == '#': score += 1
            
            if not i == 0 and not j == m - 1:
                if mat[i-1][j+1] == '#': score += 1
            
            if not i == n - 1 and not j == 0:
                if mat[i+1][j-1] == '#': score += 1
            
            if not i == n - 1 and not j == m - 1:
                if mat[i+1][j+1] == '#': score += 1

            print(score, end='')
        else:
            print(mat[i][j],end='')
    print()

Measured memory_bytes: 3444
numbers=int(input())
list_num=[int(i) for i in input().split()]
sorted_list=sorted(list_num)

median1=sorted_list[int(numbers/2)-1]
median2=sorted_list[int(numbers/2)]

for i in list_num:
    if i <= median1:
        print(median2)
    else:
        print(median1)

Measured memory_bytes: 25472
import itertools

N, K = map(int, input().split()) # N円の品物、K個の嫌いな数字
D = set(list(map(int, input().split()))) # 嫌いな数字のリスト
base = set(range(10))

target_num = base - D
keta = len(str(N))

answer = float('inf')
for p in itertools.product(target_num, repeat=keta):
    temp = 0
    for i, num in enumerate(p):
        temp += num * 10**i
        
    if temp >= N:
        answer = min(answer, temp)

for p in itertools.product(target_num, repeat=keta+1):
    temp = 0
    for i, num in enumerate(p):
        temp += num * 10**i
        
    if temp >= N:
        answer = min(answer, temp)

print(answer)

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair



int main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int ans = 0;
  rep (i, 4000) {
    if (r * i > n) break;
    rep (j, 4000) {
      if (r * i + g * j > n) break;
      if ((n - r * i - g * j) % b == 0) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}


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

using namespace std;

int main() {
  long long a, b, c, d;
  scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

  puts(d >= abs(a - c) ||d >= abs(a - b) && d >= abs(b - c) ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using p = pair<int,long long>;
using ll = long long;
const auto INF =(ll)1e9;
int main(){
  ll n;
  cin >> n;
  auto a = vector<ll>(n,0);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }

  ll ans =0;
  for (int i = 0; i < n; i++)
  {
     while(a[i]!=0&&a[i]%2==0){
        ans++;
        a[i]/=2;
     }
  }

  cout << ans;
  


}

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

int main() {
    int N, K, t;
    vector<int> l;
    cin >> N >> K;
    REP(i,N){
        cin >> t;
        l.push_back(t);
    }
    sort(l.begin(),l.end());
    int ans = 0;
    REP(i,K){
        ans += l[N-i-1];
    }
    cout << ans << endl;
    return 0;
}


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

#define PB          push_back
#define PF          push_front
#define MP          make_pair
#define FI          first
#define SE          second
#define SIZE( A )   int( ( A ).size( ) )
#define ALL( A )    ( A ).begin( ), ( A ).end( )
#define ALLR( A )   ( A ).rbegin( ), ( A ).rend( )

using namespace std;

typedef long long           ll;
typedef unsigned long long  ull;
typedef long double         lf;
typedef pair< int, int >    pii;
typedef pair< ll, ll >      pll;
typedef vector< bool >      vb;
typedef vector< lf >        vd;
typedef vector< ll >        vll;
typedef vector< int >       vi;
typedef vector< pii >       vpii;

const int MAXN = int( 1e5 )+10;
const int MOD  = int( 360 );
const int oo   = INT_MAX;
const lf EPS = 1e-9;

struct pt {
  lf x, y;
  pt( ) { }
  pt( lf x, lf y ) : x( x ), y ( y ) { }
};

inline lf x( pt P ) { return P.x; }
inline lf y( pt P ) { return P.y; }

istream& operator >> ( istream& in, pt& p ) {
  lf x,y; in >> x >> y;
  p = pt(x,y); return in;
}

ostream& operator << ( ostream& out, const pt& p ) {
  out << double(p.x) << " " << double(p.y);
  return out;
}

pt operator + ( const pt& A, const pt& B ) {
  return pt( x(A)+x(B), y(A)+y(B) );
}

pt operator - ( const pt& A, const pt& B ) {
  return pt( x(A)-x(B), y(A)-y(B) );
}

pt operator * ( const lf& B, const pt& A ) {
  return pt( x(A)*B, y(A)*B );
}

pt operator * ( const pt& A, const lf& B ) {
  return pt( x(A)*B, y(A)*B  );
}

inline lf norm( pt A ) {
  return x(A)*x(A) + y(A)*y(A);
}

inline lf abs( pt A ) {
  return sqrt( norm(A) );
}

inline bool same ( lf a, lf b ) {
  return a+EPS > b && b+EPS > a;
}

inline lf dist ( pt A, pt B ) { return norm( B - A ); }

int n;
pt P[ MAXN ], extra[ MAXN ];

bool cmpX( const pt &A, const pt &B ) {
  return A.x < B.x;
}

lf sqr( lf x ) {
  return x*x;
}

void merge( int f, int m, int t ){
	int total = t - f + 1;
	for( int i = 0, l = f, r = m+1; i < total; ++i ){
		if( l == m+1 ){
      extra[ i ] = P[ r++ ];
		}
		else if( r == t+1 ){
		  extra[ i ] = P[ l++ ];
		}
		else if( P[l].y < P[r].y ){
		  extra[ i ] = P[ l++ ];
		}
		else{
		  extra[ i ] = P[ r++ ];
		}
	}
	for( int i = 0; i < total; ++i ){
    P[ f+i ] = extra[ i ];
	}
}

lf solve( int f, int t ) {
  if( f == t ) return oo;
	int mi = (f + t)/2;
	lf mx = P[ mi ].x;
	lf d = min( solve( f, mi ), solve( mi+1, t ) );
	merge( f, mi, t );
	vector< int > idxs;
	for( int i = f; i <= t; ++i ){
		if( sqr(mx - P[i].x) < d ) idxs.push_back( i );
	}
	for( int i = 0; i < idxs.size(); ++i ){
		for( int j = i+1; j < idxs.size() && sqr(P[ idxs[i] ].y - P[ idxs[j] ].y) < d; ++j ){
			d = min( d, dist( P[ idxs[i] ], P[ idxs[j] ] ) );
		}
	}
	return d;
}

int main( ) {

  #ifdef LOCAL
    freopen( "CGL_5_A-in25.txt", "r", stdin );
    //freopen( "output", "w", stdout );
  #else
    //freopen( "input", "r", stdin );
    //freopen( "output", "w", stdout );
    ios_base::sync_with_stdio( 0 );
    cin.tie( 0 );
  #endif
  cout << fixed << setprecision( 10 );
  cin >> n;
  for( int i = 0; i < n; ++i ) {
    cin >> P[i];
  }
  sort( P, P+n, cmpX );
  cout << double( sqrt(solve( 0, n-1 )) ) << '\n';
  return 0;
}

Measured memory_bytes: 9560
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 200005
using namespace std;

typedef long long ll;
ll n, k, l, r = 1e18, m, a[N], b[N];

bool f(ll p) {
	ll i, t = k;
	for (i = 0; i < n; i++) {
		t -= max(0LL, (a[i] * b[i] - p + b[i] - 1) / b[i]);
		if (t < 0) return 0;
	}
	return 1;
}

int main()
{
	ll i;
	cin >> n >> k;
	for (i = 0; i < n; i++) scanf("%lld", &a[i]);
	for (i = 0; i < n; i++) scanf("%lld", &b[i]);
	sort(a, a + n, greater<int>());
	sort(b, b + n);
	while (l < r) {
		m = (l + r) / 2;
		if (f(m)) r = m;
		else l = m + 1;
	}
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 3328
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7

    n, d = map(int, input().split())
    count = 0
    for i in range(n):
        p, q = map(int, input().split())
        if p**2+q**2<=d**2:
            count += 1
    print(count)




if __name__ == '__main__':
    solve()

Measured memory_bytes: 74568
program main
   integer h,w,d,i,j,fie(1:2,0:100000),dist(0:100000),q,l,r
   integer,ALLOCATABLE :: a(:,:)
   read(*,*)h,w,d
   allocate(a(1:h,1:w))
   do i=1,h
      read(*,*)a(i,1:w)
   enddo
   
   do i=1,h
      do j=1,w
         fie(1,a(i,j))=i
         fie(2,a(i,j))=j
      enddo
   enddo
   dist(1)=0
   dist(0)=0
   do i=2,H*W+100
      if(i-d<0)then
         dist(i)=0
      else
         dist(i)=dist(i-d)+max(fie(1,i)-fie(1,i-d),-fie(1,i)+fie(1,i-d))+max(fie(2,i)-fie(2,i-d),-fie(2,i)+fie(2,i-d))
      endif
   enddo
   
   read(*,*)q
   do i=1,q
      read(*,*)l,r
      write(*,*)dist(r)-dist(l)
   enddo

end program main



Measured memory_bytes: 4216