akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<50);
const double inf=pow(10,10);
const ld pi=acosl(1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

void solve(){
  ll n;cin>>n;
  vector<ll>A(n);
  vector<vector<ll>>x(n);
  vector<vector<ll>>y(n);
  rep(i,n){
    cin>>A[i];
    x[i].resize(A[i]);
    y[i].resize(A[i]);
    rep(j,A[i]){
      cin>>x[i][j]>>y[i][j];
      x[i][j]--;
    }
  }
  //cout<<"FIN"<<endl;
  ll ans=0;
  rep(s,pow(2,n)){
    bool isOK=true;
    ll count=0;
    rep(i,n){
      if((s>>i)&1){
        //iは正直者
        count++;
        rep(j,A[i]){
          if(y[i][j]==1){
            if(!((s>>x[i][j])&1))isOK=false;
          }else{
            if(((s>>x[i][j])&1))isOK=false;
          }
        }
      }
    }
    if(isOK)ans=max(ans,count);
  }
  cout<<ans<<endl;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	solve();
}


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

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<double,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, n, e, f, g, sum, A[500010], B[500000], rui[500000], dp[5000];
ll ma = Min;
P C[10010];
str S; bool check = true;	vector<ll> v;



int main() {
	//Code Line
	cin >> a >> n;

	for (int i = 0; i < n; i++) {
		cin >> A[i] >> B[i];
		C[i].first = (double)A[i] / (double)B[i];
		C[i].second = i;
		g += A[i];
	}
	sort(C, C + n);


	while (a > 0) {
		if (g < a) {
			f = C[n - 1].second;
			a -= A[f];
			sum += B[f];
		}
		else {
			ll dp[20000] = {}; Min = INF;
			for (int i = 1; i < 20000; i++) {
				dp[i] = INF;
			}
			for (int i = 0; i < a; i++) {
				for (int j = 0; j < n; j++) {
					dp[i + A[j]] = min(dp[i + A[j]], dp[i] + B[j]);
				}
			}
			for (int i = a; i < 20000; i++) {
				if (Min > dp[i]) { Min = dp[i]; }
			}
			sum += Min;
			break;
		}

	}

	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 4480
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    long long n, m; std::cin >> n >> m;
    long long lo = 0, hi = (long long)1e12 + 1;
    while (hi - lo > 1) {
        long long mid = lo + (hi - lo) / 2;
        bool a = m >= 2 * mid;
        bool b = n + (m - 2 * mid)/2 >= mid;
        if (a && b) lo = mid;
        else hi = mid;
    }
    std::cout << lo << std::endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

void chmin(int &x, int y) { x = min(x, y); }

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

    vector<vector<int>> dis(n, vector<int>(n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            dis[i][j] = abs(i - j);
        }
    }

    vector<int> ret(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            chmin(dis[i][j], dis[i][x] + 1 + dis[y][j]);
            chmin(dis[i][j], dis[i][y] + 1 + dis[x][j]);
            ret[dis[i][j]]++;
        }
    }

    for (int i = 1; i < n; i++)cout << ret[i] / 2 << endl;
    return 0;
}

Measured memory_bytes: 16000
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
long long dp[100010];

int main(){
    int n, w, ans = 0;
    cin >> n >> w;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    for(auto&& i : dp){
        i = (long long)1e18;
    }
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 100000; j >= b[i]; j--){
            dp[j] = min(dp[j], dp[j - b[i]] + a[i]); 
        }
    }
    for(int i = 100000; i >= 0; i--){
        if(dp[i] <= w){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main(){
    Hello
    int n;
    cin >> n;
    bool vis[n + 5] = {};
    vector<vector<pair<ll, ll>>> v;
    v.resize(n + 5);
    for(int i = 0; i < n - 1; i++){
        ll x, y, c;
        cin >> x >> y >> c;
        v[x].push_back({y, c});
        v[y].push_back({x, c});
    }
    ll dist[n + 5] = {};
    queue<int> q;
    q.push(1);
    dist[1] = 0;
    vis[1] = true;
    while(q.size()){
        ll node = q.front();
        q.pop();
        for(int i = 0; i < v[node].size(); i++){
            if(vis[v[node][i].first]) continue;
            vis[v[node][i].first] = true;
            dist[v[node][i].first] = (dist[node] + v[node][i].second) % 2;
            q.push(v[node][i].first);
        }
    }
    for(int i = 1; i <= n; i++)
        cout << dist[i] << endl;
    return 0;
}

Measured memory_bytes: 11616
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
	int N;
	string x, y, temp;
	int i, a[80];
	

	cin >> N;

	for(i = 0;i < 80;i++){
		a[i] = 0;
	}

	while(N != 0){
		bool over = false;
		if(N == 0) break;
		cin >> x >> y;
		N--;
		if(x.size() > 80 || y.size() > 80){
			cout << "overflow" << endl;
			continue;
		}

		if(x == "0" && y == "0"){
			cout << "0" << endl;
			continue;
		}

		if(x.size() < y.size()){
			temp = x;
			x = y;
			y = temp;
		}
		int xi = 0, yi = 0;
		for(i = 0;i < x.size();i++){
			xi = x[x.size() - 1 - i] - '0';
			//cout << "xi = " << xi << endl;
			if(i >= y.size()){
				yi = 0;
			}
			else {
				yi = y[y.size() - 1 - i] - '0';
				//cout << "yi = " << yi << endl;
			}
			a[i] += xi + yi;
			//cout << "xi + yi  = " << a[x.size() - 1 - i] << endl;
			if(a[i] > 9){
				if(i < 79){
					a[i] = a[i] - 10;
					a[i + 1] += 1;
				}
				else if(i >= 79){
					cout << "overflow"	<< endl;
					over = true;
					break;				
				}
			}

			
		}
		 
		if(!over){
			bool start = false;
			for(i = 79;i >= 0;i--){
				if(!start && a[i] > 0){
					start = true;
				}
				if(start){
					cout << a[i];
				}
			}
			cout << endl;
		}
		
		for(i = 0;i < 80;i++){
				a[i] = 0;
		}
		
	}
	return 0;
}

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

long long f(long long b, long long n){
	if(n < b) return n;
	else return f(b, n/b) + (n % b);
}

int main(){
	long long n, s;
	cin >> n >> s;
	if(n < s){
		cout << -1 << endl;
		return 0;
	}
	if(n == s){
		cout << n+1 << endl;
		return 0;
	}
	vector<long long> array;
	for(int i=1; i<=sqrt(n); i++){
		if((n-s) % i == 0){ array.push_back(i+1); array.push_back(((n-s)/i)+1); }
	}
	sort(array.begin(), array.end());
	for(int i=0; i<array.size(); i++){
		if(f(array[i], n) == s){
			cout << array[i] << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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 (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//g++ yarudake.cpp -std=c++17 -I .
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
//約数列挙オーダー√n
vector<int> divisor(int n)
{
    vector<int> res;
    for (int i = 1; i * i <= n; i++)
        if (n % i == 0)
        {
            res.push_back(i);
            if (i != n / i)
                res.push_back(n / i);
        }
    return res;
}
//高速素因数分解 O(nlogn)
template <typename T>
vector<T> smallest_prime_factors(T n) //iの最小の素因数
{

    vector<T> spf(n + 1);
    for (int i = 0; i <= n; i++)
        spf[i] = i;

    for (T i = 2; i * i <= n; i++)
    {

        // 素数だったら
        if (spf[i] == i)
        {

            for (T j = i * i; j <= n; j += i)
            {

                // iを持つ整数かつまだ素数が決まっていないなら
                if (spf[j] == j)
                {
                    spf[j] = i;
                }
            }
        }
    }

    return spf;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<n;i++){
        ans+=(n-1)/i;
    }
    cout<<ans<<"\n";
}

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

using namespace std;
using ll = long long;

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

  const ll mod = 1e9 + 7;

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

  ll ans = 0;

  vector<ll> acc(n, 0ll);
  for (int i = n - 1; i > 0; i--) {
    acc[i - 1] += acc[i] + a[i];
    acc[i - 1] %= mod;
  }

  for (int i = 0; i < n - 1; i++) {
    ans += (acc[i] * a[i]) % mod;
    ans %= mod;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6360
#include<stdio.h>
#include<algorithm>
using namespace std;
pair<int,int> v[10000];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		int ret=0;
		for(int i=0;i<a;i++){
			int c,d;
			scanf("%d%d",&c,&d);
			ret+=c*d;
			v[i]=make_pair(-d,c);
		}
		std::sort(v,v+a);
		for(int i=0;i<a;i++){
			if(b>=v[i].second){
				b-=v[i].second;
				ret+=v[i].first*v[i].second;
			}else{
				ret+=v[i].first*b;
				b=0;
			}
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1100
#include<bits/stdc++.h>
using namespace std ;
#define ll long long 
#define pb push_back
#define in(x) int x; cin>>x;
#define ln(x) long long x; cin>>x;
#define memf(a) memset(a,false,sizeof(a))
#define F first
#define S second
#define endl "\n"
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
int main()
{
	fast
	int n,x,t;
	cin>>n>>x>>t;
	ll ans=ceil((double)n/x) * t;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<set>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)

int N;
ll Y;

int main() {
  cin >> N >> Y;
  
  int total = 0;
  int res10000 = -1, res5000 = -1, res1000 = -1;
  REP(i,N+1) {
    for (int j = 0; j+i<N+1; j++) {
      int k = N - i - j;
      total = 10000*i + 5000*j + 1000*k;
      if (total == Y) {
        res10000 = i;
        res5000 = j;
        res1000 = k;
        break;
      }
    }
  }
  
  cout << res10000 << ' ' << res5000 << ' ' << res1000 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1234567890
#define pii pair<int,int>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    int a = 0, b = 0, c = 0, d = 0;
    for (int i=1;i<=n;i++) {
        string s;
        cin >> s;
        if (s == "AC") a++;
        if (s == "WA") b++;
        if (s == "TLE") c++;
        if (s == "RE") d++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

typedef long long LL;
typedef vector<int> VI;

#define MOD 1000000007

struct BinCoef {
  vector<int64_t> fac;
  vector<int64_t> finv;
  vector<int64_t> inv;
  int size;
  int64_t mod;
  BinCoef(int size, int64_t mod) : size(size), mod(mod), fac(size, -1), finv(size, -1), inv(size, -1) {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < size; i++){
      fac[i] = fac[i - 1] * i % mod;
      inv[i] = mod - inv[mod%i] * (mod / i) % mod;
      finv[i] = finv[i - 1] * inv[i] % mod;
    }
  }
  int64_t com(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
  }
};

int main() {
  int N, K;
  cin >> N >> K;
  auto bc = BinCoef(10000, MOD);
  for (int i = 1; i <= K; i++) {
    cout << (bc.com(N-K+1, i) % MOD * bc.com(K-1, i-1) % MOD) % MOD << endl;
  }

  return 0;
}


Measured memory_bytes: 512
// AOJ 2858: Prime-Factor Prime
// 2017.11.25 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <math.h>

#define MAX  31623			// sqrt(1e9)
char tbl[MAX+3];

int sz;						// max sz = 3402, prime[0] = 2, prime[3401] = 31623
int prime[3500] = {  		// prime[40] = 179, 179^2 = 32041
  2, 3,  5,  7, 11, 13, 17, 19, 23, 29, 
 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 
 73, 79, 83, 89, 97,101,103,107,109,113, 
127,131,137,139,149,151,157,163,167,173, 
179 };

int sqp[41] = {				// squre of prime: sqp[i] = prime[i] * prime[i]
  4, 9,25,49,121,169,289,361,529,841,961,
1369,1681,1849,2209,2809,3481,3721,4489,5041,
5329,6241,6889,7921,9409,10201,10609,11449,11881,12769,
16129,17161,18769,19321,22201,22801,24649,26569,27889,29929,
32041 };

char ptbl[31] = { 0,0,1,1,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0 };

void sieve()
{
	int i, j, k;

	for (i = 1; i < 41; i++) {
		k = prime[i];
		for (j = sqp[i]; j < MAX; j += k) tbl[j] = 1;
	}
	for (sz = 40, i = 179; i <= MAX; i += 2) if (!tbl[i]) prime[sz++] = i;
}

int a[1000002];
int b[1000002];

int bsch(int x)
{
	int m, l = 0, r = sz;

    while (l < r) {
        m = (l + r) >> 1;
		if (prime[m] == x) return m;
        if (prime[m] < x) l = m + 1; else r = m;
    }
	return l-1;
}

int main()
{
	int l, r, i, k, ll, rr, p0, pp, ans;
	long long j;

	sieve();

	scanf("%d%d", &l, &r);
	if (r < 4) { puts("0"); return 0; }
	sz = bsch((int)sqrt(r));

	for (i = r-l; i >= 0; i--) b[i] = 1;
	for (i = 0; i <= sz; i++) {
		p0 = prime[i];
		for (j = p0; j <= r; j *= p0) {
			pp = (int)j;
			ll = pp*(1+(l-1)/pp), rr = pp*(r/pp);
			while (ll <= rr) a[ll-l]++, b[ll-l] *= p0, ll += pp;
		}
	}

	ans = 0;
	for (k = l, i = 0; k <= r; i++, k++) {
		if (k != b[i]) a[i]++;
		if (ptbl[a[i]]) ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 9704
#include <iostream>
#define NIL 2000000001
using namespace std;
typedef struct{
	int key;
	int lch;//??????id
	int rch;//??????id
}NODE;
NODE node[500001];
int root;
int n,a;
string s;
bool flag;

void insert(int id,int num){
	int node1=root;
	int parent=-1;
	while(node1!=-1){
		parent=node1;
		if(num<node[node1].key){
			node1=node[node1].lch;
		}else{
			node1=node[node1].rch;
		} 
	}
	//parent=node1;
	if(parent==-1){
		root=id;
		node[id].lch=node[id].rch=-1;
		node[id].key=num;
	}else if(num<node[parent].key){
		node[parent].lch=id;
		node[id].key=num;
		node[id].rch=node[id].lch=-1;
	}else{
		node[parent].rch=id;
		node[id].key=num;
		node[id].rch=node[id].lch=-1;
	}
}

void inordertreewalk(int id){
	if(node[id].lch!=-1)inordertreewalk(node[id].lch);
	//if(id==root){
	//	cout << node[id].key;	
	//}else if(node[id].key>node[root].key){
		cout << " "<< node[id].key;
	//}else{
	//	cout << node[id].key<<" ";
	//}
	if(node[id].rch!=-1)inordertreewalk(node[id].rch);
	return;
}

void preordertreewalk(int id){
	//if(id==root){
	//	cout << node[id].key;	
	//}else{
		cout << " "<< node[id].key;
	//}
	if(node[id].lch!=-1)preordertreewalk(node[id].lch);
	if(node[id].rch!=-1)preordertreewalk(node[id].rch);
	return;
}

bool find(int num){
	int id=root;
	while(id!=-1){
		if(node[id].key==num){
			return true;
		}else if(node[id].key>num){
			id=node[id].lch;
		}else{
			id=node[id].rch;
		}
	}
	return false;
}

int main(){
	root=-1;
	cin >>n;
	for(int i=0;i<n;i++){
		cin >>s;
		if(s=="insert"){
			cin >>a;
			insert(i,a);
		}else if(s=="print"){
			if(root==-1)continue;
			inordertreewalk(root);
			cout <<endl;
			preordertreewalk(root);
			cout <<endl;
		}else if(s=="find"){
			cin >>a;
			flag=find(a);
			if(flag){
				cout << "yes"<<endl;
			}else{
				cout << "no"<<endl;
			}
		}

	}
}

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

const int maxn = 55;
int n;
long double x[maxn], y[maxn];

//Credit: geeksforgeeks
// Function to find the circle on 
// which the given three points lie 
pair<pair<long double,long double>,long double> findCircle(int x1, int y1, int x2, int y2, int x3, int y3) 
{ 
    long double x12 = x1 - x2; 
    long double x13 = x1 - x3; 
  
    long double y12 = y1 - y2; 
    long double y13 = y1 - y3; 
  
    long double y31 = y3 - y1; 
    long double y21 = y2 - y1; 
  
    long double x31 = x3 - x1; 
    long double x21 = x2 - x1; 
  
    // x1^2 - x3^2 
    long double sx13 = pow(x1, 2) - pow(x3, 2); 
  
    // y1^2 - y3^2 
    long double sy13 = pow(y1, 2) - pow(y3, 2); 
  
    long double sx21 = pow(x2, 2) - pow(x1, 2); 
    long double sy21 = pow(y2, 2) - pow(y1, 2); 
  
    long double f = ((sx13) * (x12) 
             + (sy13) * (x12) 
             + (sx21) * (x13) 
             + (sy21) * (x13)) 
            / (long double)(2 * ((y31) * (x12) - (y21) * (x13))); 
    long double g = ((sx13) * (y12) 
             + (sy13) * (y12) 
             + (sx21) * (y13) 
             + (sy21) * (y13)) 
            / (long double)(2 * ((x31) * (y12) - (x21) * (y13))); 
  
    long double c = -pow(x1, 2) - pow(y1, 2) - 2 * g * x1 - 2 * f * y1; 
  
    // eqn of circle be x^2 + y^2 + 2*g*x + 2*f*y + c = 0 
    // where centre is (h = -g, k = -f) and radius r 
    // as r^2 = h^2 + k^2 - c 
    long double h = -g; 
    long double k = -f; 
    long double sqr_of_r = h * h + k * k - c; 
  
    // r is the radius 
    long double r = sqrt(sqr_of_r); 
  
    return {{h,k},sqr_of_r};
    /*
    cout << "Centre = (" << h << ", " << k << ")" << endl; 
    cout << "Radius = " << r; 
    */
} 

long double sqr(long double x) { return x*x; }
long double dist(long double x1, long double y1, long double x2, long double y2) {
    return sqr(x1-x2) + sqr(y1-y2);
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    long double X = 0, Y = 0, d, e;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        X += x[i];
        Y += y[i];
    }

    if (n == 2) {
        long double ans = sqrt(dist(x[0],y[0],x[1],y[1]))/2;
        cout << fixed << setprecision(10) << ans << '\n';
        return 0;
    }

    X /= n;
    Y /= n;
    long double P = 0.1;
    for (int i = 0; i < 30000; i++) {
        int f = 0;
        d = dist(X,Y,x[0],y[0]);
        for (int j = 1; j < n; j++) {
            e = dist(X,Y,x[j],y[j]);
            if (d < e) {
                d = e;
                f = j;
            }
        }
        X += (x[f]-X)*P;
        Y += (y[f]-Y)*P;
        P *= 0.999;
    }
    cout << fixed << setprecision(10) << sqrt(d) << '\n';
}



Measured memory_bytes: 256
N = int(input())
P = list(map(float, input().split()))

dp = [[0] * (N+1) for i in range(N+1)]
dp[0][0] = 1

for i in range(1, N+1):
  for j in range(i+1):
    dp[i][j] = dp[i-1][j] * (1 - P[i-1]) + (dp[i-1][j-1] if j > 0 else 0) * P[i-1]
print(sum(dp[N][N//2+1:]))

Measured memory_bytes: 262280
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int n, m, max_a;
int a[100];

bool check(int k) {
	int num = 1, sum = 0;
	for(int i = 0; i < n; i++) {
		sum += a[i];
		if(sum > k) {
			num++;
			sum = a[i];
		}
	}
	return num <= m;
}

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

	while(cin >> m >> n, m) {
		for(int i = 0; i < n; i++) {
			cin >> a[i];
		}
		max_a = *max_element(a, a + n);

		int ng = max_a - 1, ok = max_a * n;
		while(abs(ng - ok) > 1) {
			int mid = (ng + ok) / 2;
			if(check(mid)) ok = mid;
			else ng = mid;
		}

		cout << ok << endl;
	}
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MAXX 1005
#define PI 3.14159265358979323846264338327950
#define ll signed long long int
using namespace std;
ll t , n, k,  x = 0, y = 2, m, ans = 0 ;
ll a[MAXX], b[MAXX], c[MAXX], d;
double f = 0.5;
vector<ll> v[MAXX];
bool used[MAXX];

signed main()
{
	
	cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for(int i = 1; i <= n; i++){
        cin >> b[i];
        ans += b[i];
    }
    for(int i = 1; i <= n - 1; i++){
        cin >> c[i];
    }
    for(int i = 2; i <= n; i++){
        if(a[i] == (a[i - 1] + 1))
            ans += c[a[i - 1]];
    }
    cout << ans << endl;
	return 0;    
}

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

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	int a,b;
	cin >> a >> b;
	if(a %3 == 0 || b%3 == 0 || (a+b)%3 == 0)
		cout << "Possible\n";
	else
		cout << "Impossible\n";	
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC115_B solver = new ABC115_B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC115_B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long n = in.nextInt();
            Long[] p = new Long[(int) n];
            for (int i = 0; i < n; i++) {
                p[i] = in.nextLong();
            }

            Arrays.sort(p);
            p[(int) n - 1] = p[(int) n - 1] / 2;
            long ans = 0;
            for (long ele : p) {
                ans += ele;
            }
            out.print(ans);
        }

    }
}



Measured memory_bytes: 20948
#大工

import heapq

n,m,r = map(int,input().split())
edge = [[] for i in range(n)]

#aは辺の重み、u,vは辺の情報
for i in range(m):
    u,v,a = map(int,input().split())
    edge[u].append([a,v])

inf = 1145141919810364364
start = 10**15

d = [inf] * n
used = [False] * n
d[r] = 0
used[r] = True
lis = []
    
for k,l in edge[r]:
    heapq.heappush(lis,k*(10**6)+l)
        
while lis:
    minedge = heapq.heappop(lis)
        
    if used[minedge%(10**6)]:
        continue
 
    v = minedge%(10**6)
    d[v] = minedge//(10**6)
    used[v] = True
 
    for q in edge[v]:
        if not used[q[1]]:
            heapq.heappush(lis,(q[0]+d[v])*(10**6)+q[1])
            
for i in d:
    if i >= inf:
        print("INF")
    else:
        print(i)


Measured memory_bytes: 98228
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> v(n), c(n);
	rep(i, n) cin >> v[i];
	rep(i, n) cin >> c[i];
	int ans = 0;
	rep(bit, (1 << n)) {
		int x = 0, y = 0;
		rep(i, n) {
			if (bit & (1 << i)) {
				x += v[i];
				y += c[i];
			}
		}
		maxs(ans, x - y);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(){
    
    int N,s[100]={},sum,min=100,i;
    
    scanf("%d",&N);
    
    for(i=0;i<N;i++){
        scanf("%d",&s[i]);
        sum+= s[i];
        if(s[i] % 10 != 0 && min > s[i] )min=s[i];
    }
    
    if(sum % 10 != 0)printf("%d",sum);
    else if(sum % 10 == 0 && min % 10 != 0)printf("%d",sum-min);
    else printf("0\n");
    
    return 0;
}

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

//累積和を取って考える
//和の期待値＝期待値の和（E[X+Y] = E[x]+E[Y]）を用いて解ける
int main() {
  ll N, K;
  cin >> N >> K;
  ll p[N];
  ll E[N];

  rep(i, N) cin >> p[i];

  ll sum = 0;
  ll max_sum = 0;
  queue<ll> q;

  for (ll i = 0; i < N; i++) {
    E[i] = (p[i] + 1);
  }


  for (ll i = 0; i < N; i++){
    sum += E[i];
    q.push(E[i]);
    if (q.size() > K) {
      sum -= q.front(); q.pop();
    }
    if (q.size() == K) max_sum = max(max_sum, sum);
  }

  double answer = max_sum * 0.5;

  printf("%.10f\n", answer);
  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main() {
	int n, k;
	cin >> n >> k;
	cout << (n-1)*(k-1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int A, B;
  cin >> A >> B;

  if (B % A == 0)
    cout << A + B << endl;
  else
    cout << B - A << endl;

  return 0;
}


Measured memory_bytes: 764
class Factorials:
    # nに十分大きい数を入力
    def __init__(self, n, mod):
        self.mod = mod

        # self.fac[i] ≡ i! (factorial:階乗)
        self.fac = [1]
        num = 1
        for i in range(1, n+1):
            num *= i
            num %= mod
            self.fac.append(num)

        # self.rec[i] ≡ 1 / i! (reciprocal:逆数)
        num = pow(num, mod-2, mod)
        self.rec = [1 for i in range(n+1)]
        self.rec[n] = num
        for i in range(n-1, 0, -1):
            num *= i + 1
            num %= mod
            self.rec[i] = num

    # comb(n, r) ≡ nCr
    def comb(self, n, r):
        return self.fac[n] * self.rec[r] * self.rec[n - r] % self.mod
    
    # perm(n, r) ≡ nPr
    def perm(self, n, r):
        return self.fac[n] * self.rec[n-r] % self.mod

    # fact(n) ≡ n!
    def fact(self, n):
        return self.fac[n]

mod = 10**9 + 7

n = int(input())
a = list(map(int, input().split()))

check = [-1] * n
for i in range(n+1):
    a[i] -= 1
    if check[a[i]] == -1:
        check[a[i]] = i
    else:
        m = n + check[a[i]] - i
        break

fct = Factorials(n+1, mod)

for i in range(1, n+2):
    if m >= i - 1:
        print((fct.comb(n+1, i) - fct.comb(m, i-1)) % mod)
    else:
        print(fct.comb(n+1, i))

Measured memory_bytes: 96988
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long gcd(long long a, long long b) {
	if (a % b == 0) {
		return (b);
	}
	else {
		return (gcd(b, a % b));
	}
}

long long a[100010];
int main() {
	long long n, m;
	long long co1 = 0;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		long long a1 = a[i];
		long long co = 0;
		for (;;) {
			if (a[i] % 2 == 0) {
				a[i] /= 2;
				co++;
			}
			else {
				break;
			}
		}
		if (i != 0) {
			if (co1 != co) {
				cout << "0" << endl;
				return 0;
			}
		}
		co1 = co;
		a[i] = a1 / 2;
	}
	long long lcm = 1;
	for (int j = 0; j < n; j++) {
		lcm = a[j] / gcd(lcm, a[j]) * lcm;
		if (lcm > m) {
			cout << "0" << endl;
			return 0;
		}
	}
	long long ans = 0;
	if (lcm <= m) {
		m -= lcm;
		ans++;
		ans += m / (lcm * 2);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  string s;
  cin >> s;
  int n=s.size();
  if(s[0]==s[n-1]){
    if(n%2==1) cout << "Second" << endl;
    else cout << "First" << endl;
  }
  else{
    if(n%2==0) cout << "Second" << endl;
    else cout << "First" << endl;
  }

  
  return 0;
    

}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <random>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

llong pow(int x, int n) {
    llong ans = x;
    if (n == 0) return 1;

    for(int i = 0; i < n - 1; i++) {
        ans *= x;
    }

    return ans;
}

void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}

const static int MAX = 500;

int h, w;
char field[MAX][MAX];
bool flag = false, visited[MAX][MAX] = {false};

void dfs(int i, int j) {
    if (field[i][j] == 'g') {
        flag = true;
        return;
    }
    if (visited[i][j]) return;
    visited[i][j] = true;

    rep(k, 4) {
        if (0 <= i + dx[k] && i + dx[k] <= h - 1 && 0 <= j + dy[k] && j + dy[k] <= w - 1 && field[i + dx[k]][j + dy[k]] != '#') {
            dfs(i + dx[k], j + dy[k]);
        }
    }
}

int main() {
   llong n, m, ans;
    cin >> n >> m;
    if (n == 1 && m == 1) {
        cout << 1 << endl;
    } else if((n == 1 && m != 1) || (m == 1 && n != 1)) {
        cout << max(n, m) - 2;
    } else {
        ans = (n - 2) * (m - 2);
        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;



int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,a=0;
    cin>>n;
    while(n)
    {
        if(n%10==2)
        {
            a++;
        }
        n/=10;
    }
    cout<<a;
    return 0;
}
/**

**/


Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int h1,h2,k1,k2,hsum,ksum,ht,kt;
	int a,b,c,d;
	scanf("%d %d",&h1,&h2);
	scanf("%d %d",&k1,&k2);
	scanf("%d %d %d %d",&a,&b,&c,&d);
	hsum=h1*a+h2*b+(h1/10)*c+(h2/20)*d;
	ksum=k1*a+k2*b+(k1/10)*c+(k2/20)*d;
	if(hsum>ksum)	printf("hiroshi\n");
	else if(hsum==ksum)	printf("even\n");
	else printf("kenjiro\n");
	return 0;
}


Measured memory_bytes: 2620
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
using namespace std;
typedef long long ll;

int main(void){
  string s;
  int k;
  cin >> s >> k;

  set<string> st;
  string tmp;
  for(int i = 0; i < s.size(); i++){
    if(s.size() - i <= 4){
      for(int j = 1; j <= s.size() - i; j++){
        tmp = s.substr(i, j);
        st.insert(tmp);
      }
    }
    else {
      for(int j = 1; j <= 5; j++){
        tmp = s.substr(i, j);
        st.insert(tmp);
      }
    }
  }
  int cnt = 0;
  for(auto ite = st.begin(); ite != st.end(); ite++){
    cnt++;
    if(cnt == k){
      cout << *ite << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=1000000000000000000,mod=1000000007,BS,k;

int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
        ll sum=0;
        string a,b;
        cin>>a>>b;
        for(ll i=0;i<a.length();i++)
        if(a[i]!=b[i])sum++;
        cout<<sum;
}


Measured memory_bytes: 3800
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9+7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
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;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
#define INT_MAX 1e9+7

int main(){
    ll n; cin >> n;
    vl x(n), y(n);
    rep(i,n) cin >> x[i] >> y[i];
    double ans = 0;
    vl nxt(n);
    rep(i,n) nxt[i] = i;
    ll cnt = 0;
    do{
        rep(i,n-1){
            ll v = nxt[i+1];
            ll u = nxt[i];
            ans += sqrt((x[v]-x[u])*(x[v]-x[u])+(y[v]-y[u])*(y[v]-y[u]));
        }
        cnt++;
    }while(next_permutation(all(nxt)));
    printf("%.10f\n",ans/(double)cnt);
}

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

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX_N = 3000;
int N;
ll a[MAX_N];

int main() {
  cin >> N;
  rep(i,N) cin >> a[i];

  ll ans = 0;
  rep(i,N) ans += a[i]-1;

  cout << ans << endl;

}


Measured memory_bytes: 256
#include <cstdio>

int main()
{
	const int MAX = 7368791;

	static bool flags[MAX + 1];

	int m, n;

	while (true)
	{
		scanf("%d %d", &m, &n);
		if (m == 0 && n == 0)
		{
			break;
		}

		for (int i = 1; i <= MAX; ++i)
		{
			flags[i] = false;
		}

		for (int i = m, count = 0; count < n; ++i)
		{
			if (flags[i])
			{
				continue;
			}

			for (int j = i; j <= MAX; j += i)
			{
				flags[j] = true;
			}
			++count;
		}

		for (int year = m; year <= MAX; ++year)
		{
			if (!flags[year])
			{
				printf("%d\n", year);
				break;
			}
		}
	}
}


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

int main()
{
  int N, M, b[300000];
  static long long Counter[1000001] = {};
  long long c[300000];
  cin >> N;
  for(int i = 0; i < N; i++) {
    int a;
    cin >> a;
    Counter[a] += a;
  }
  for(int i = 1; i < 1000001; i++) {
    Counter[i] += Counter[i - 1];
  }
  cin >> M;
  for(int i = 0; i < M; i++) {
    cin >> b[i];
  }
  for(int i = 0; i < M; i++) {
    cin >> c[i];
  }
  for(int i = 0; i < M; i++) {
    if(Counter[b[i]] >= c[i]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 12488
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

bool findSubs(string& str, string& sub)
{
    int charIdx = 0;
    int strIdx = 0;

    while (strIdx < str.length() && charIdx < 3)
    {
        while (strIdx < str.length())
        {
            if (sub[charIdx] == str[strIdx])
                break;

            ++strIdx;
        }

        if (charIdx == 2 && strIdx < str.length())
            return true;

        ++strIdx;
        ++charIdx;
    }

    return false;
}

int solve()
{
    int N;
    string str;

    cin >> N >> str;

    int counter = 0;

    for (int i = 0; i < 1000; ++i)
    {
        string comb = pad(i);
        
        if (findSubs(str, comb))
            ++counter;
    }

    return counter;
}

int main()
{
    cout << solve() << endl;

    return 0;
}

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

int main() {
    ll N;
    ll X, D;
    cin >> N >> X >> D;
    if (D < 0) {
        X += D * (N - 1);
        D *= -1;
    }
    if (D == 0) {
        if (X == 0) {
            puts("1");
            return 0;
        }
        cout << N + 1 << endl;
        return 0;
    }

    vector<pair<ll, pair<ll, ll>>> p(N + 1);
    auto x = (X % D + D) % D;
    for (ll i = 0; i <= N; ++i) {
        auto t = (x * i) % D;
        auto k = (X * i - t) / D;
        p[i] = {t, {k + i * (i - 1) / 2, k + i * (2 * N - i - 1) / 2 + 1}};
    }

    sort(p.begin(), p.end());

    vector<pair<ll, pair<ll, ll>>> q{{D, {0, 0}}};
    for (const auto& i : p) {
        if (i.first != q.back().first)
            q.push_back(i);
        else if (q.back().second.second >= i.second.first)
            q.back().second.second = max(q.back().second.second, i.second.second);
        else
            q.push_back(i);
    }

    ll ans{0};
    for (const auto& i : q)
        ans += i.second.second - i.second.first;

    cout << ans << endl;
}


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

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

int main(){
    string s,t; cin>>s>>t;
    int n=s.size();
    s=s+s;
    rep(i,n){
        int cnt=0;
        rep(j,n){
            if(s[i+j]==t[j]) cnt++;
        }
        if(cnt==n){
            cout<<"Yes"<<endl;
            break;
        }
        if(i==n-1) cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

flag = 0

for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 == 0 or a[i] % 5 == 0:
            flag = 0
        else:
            flag = 1
            break

if flag == 0:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060
open System

let (|FizzBuzz|Fizz|Buzz|Num|) n = 
    match n % 3, n % 5 with 
    | 0, 0 -> FizzBuzz 
    | 0, _ -> Fizz 
    | _, 0 -> Buzz 
    | _ -> Num n 

[1 .. int <| Console.ReadLine()]
|> List.map (function (Num n) -> int64 n | _ -> 0L)
|> List.sum
|> printfn "%i"

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

int tax(int rate, int val)
{
    return (100+rate)*val/100;
}

int max(int a, int b)
{
    return a>=b?a:b;
}

int main() {
    while(true)
    {
        int x,y,s;
        cin >> x >> y >> s;
        if(x==0)
            break;
        int maximum = 0;
        for(int i=1;i<s;i++)
            for(int j=i;j<s;j++)
                if(tax(x,i)+tax(x,j) == s)
                    maximum = max(maximum,tax(y,i)+tax(y,j));
        cout << maximum << endl;
    }

    return 0;
}

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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  long long n, a, b;
  cin >> n >> a >> b;

  long long ans = n / (a+b);
  ans *= a;

  n %= (a+b);
  ans += min(n, a);
  cout << ans << '\n';
}





Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)

int main() {
  int N; cin>>N;
  vector<long long> a(N);
  REP(i,N) cin>>a[i];
  int max_ind =	0, min_ind = 0;
  REP(i,N) {
    if(a[i] > a[max_ind]) max_ind = i;
    if(a[i] < a[min_ind]) min_ind = i;
  }
  vector<pair<int, int> > ans;
  bool ord = true;
  if(a[min_ind] < 0 && a[max_ind] > 0) {
    if(abs(a[min_ind])  >  abs(a[max_ind])) {
      ord = false;
      REP(i,N) {
        if(a[i] >= 0) {
          ans.push_back(make_pair(min_ind, i));
          a[i] += a[min_ind];
        }
      }
    } else {
      ord = true;
      REP(i,N) {
        if(a[i] <= 0) {
          ans.push_back(make_pair(max_ind, i));
          a[i] += a[max_ind];
        }
      }
    }

  } else {
    if(a[min_ind] >= 0) ord = true;
    else ord = false;
  }
  //  REP(i,N) cout << a[i] << " " ; cout << endl;                                  
  if(ord) {
    REP(i,N-1) {
      if(a[i] >	a[i+1]) {
	a[i+1] += a[i];
	ans.push_back(make_pair(i, i+1));
      }
    }
  } else {
    for(int i =	N-1; i > 0; i--) {
      if(a[i] <	a[i-1]) {
	a[i-1] += a[i];
	ans.push_back(make_pair(i, i-1));
      }
    }
  }
  //  REP(i,N) cout << a[i] << " " ; cout << endl;                                  
  //  cout << "--------" << endl;                                                   
  cout << ans.size() << endl;
  REP(i,ans.size()) {
    cout << (ans[i].first+1) << " " << (ans[i].second+1) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
LEFT = 0
RIGHT = 1
key_dict = {
        LEFT : ["q", "w", "e", "r", "t",
            "a", "s", "d", "f", "g",
            "z", "x", "c", "v", "b",],
        RIGHT : ["y", "u", "i", "o", "p",
            "h", "j", "k", "k", "l",
            "n", "m",],
        }

def get_input():
    data_input = input()
    return data_input

def count_chage_num(data_input):
    change_num = 0
    hand_place = None
    for c in data_input:
        if c in key_dict[LEFT]:
            if hand_place != LEFT:
                change_num += 1
            hand_place = LEFT
        else:
            if hand_place != RIGHT:
                change_num += 1
            hand_place = RIGHT
    if change_num != 0:
        change_num -= 1
    return change_num


if __name__ == "__main__":
    while True:
        data_input = get_input()
        if data_input[0] == "#":
            break
        change_num = count_chage_num(data_input)
        print(change_num)



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

#define vec(v) vector<int>(v)
#define be(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define mapci(mp) map<char*,int>(mp)
#define mapcc(mp) map<char*,char*>(mp)
typedef long long ll;
using namespace std;

int main() {
    int n,ans=0;
    cin>>n;
    ll a[n],b[n+1]={0};
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>n){
            ans++;
        }
        else{
            b[a[i]]++;
        }
    }
    sort(a,a+n);
    for(int i=1;i<=n;i++){
        if(i>b[i]){
            ans+=b[i];
        }
        else if(i<b[i]){
            ans+=(b[i]-i);
        }
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#define MAXN 100015

int a[MAXN];

int main(){

   /* freopen("10.in","r",stdin);
    freopen("10.out","w",stdout);*/
    int n,i,ans=0,maxn=-1;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if(a[i]>=maxn)maxn=a[i],ans++;
    }
    printf("%d",ans);
    return 0;

}

Measured memory_bytes: 128