akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

ll combi(ll n, ll r){
	ll a=1, b=1;
	for(int i = 0; i < r; i++) {
		a*=(n-i);
		b*=(i+1);
        if(a%b==0){
            a/=b;
            b=1;
        }
	}
	return a/b;
}

int main(){
    int N;
    cin >> N;
    int A, B;
    cin >> A >> B;
    vector<ll> v(N);
    for(int i=0; i<N; i++) cin >> v[i];
    sort(v.rbegin(), v.rend());
    ll sum = 0;
	for (int i = 0; i < A; i++) sum += v[i];
    printf("%f\n", sum/(A+.0));
    ll ans=0;
    int n = count(v.begin(), v.end(), v[A-1]);
    if(v[0]==v[A-1]){
        for(int i=A; i<=B && i<=n; i++) ans += combi(n, i);
    }else{
        int c=0;
        while(v[c] != v[A-1]) c++;
        ans = combi(n, A-c);
    }
    cout << ans;
}

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

int N;
int cnt = 0;

void dfs(ll cur, int use){
    if(cur>N) return;
    if(use == 0b111) cnt++;

    dfs(cur*10+7, use|0b100);
    dfs(cur*10+5, use|0b010);
    dfs(cur*10+3, use|0b001);
}

int main(void){
    cin >> N;
    dfs(0,0b000);
    cout << cnt << endl;
}

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

#define REP(i, n) for(int i=0;i<n;i++)
#define RREP(i, n) for(int i=n;i>=0;i--)
#define TCASES int _t; cin>>_t; while(_t-- > 0)
#define PI 3.141592653589793238462643383279
const int MOD = 1e9+7;
#define N 1000

vector<pair<int, int>>  inp1, inp2;
vector<int> adj[N];
int n;
int match_to[N];
bool visited[N];

bool dfs(int u){
	if(visited[u]) return false;
	visited[u] = true;
	for(int i : adj[u]){
		if(match_to[i] == -1 || dfs(match_to[i])){
			match_to[i] = u;
			return true;
		}
	}

	return false;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef LOCAL_TEST
	freopen("input.txt","r",stdin);
	#endif
	cin >> n;
	
	for(int i=0;i<n;i++){
		int a, b; cin >> a >> b;
		inp1.push_back({a,b});
	}

	for(int i=0;i<n;i++){
		int a, b; cin >> a >> b;
		inp2.push_back({a, b});
		match_to[i] = -1;
	}

	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(inp1[i].first < inp2[j].first && inp1[i].second < inp2[j].second){
				adj[i].push_back(j);
			}
		}
	}

	int cnt = 0;
	for(int i=0;i<n;i++){
		memset(visited, false, sizeof(visited));
		cnt += dfs(i);
	}

	// for(int i=0;i<n;i++) cout << match_to[i] << ' '; cout << endl;
	cout << cnt << '\n';
}


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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
	ll a, b, k;
	scanf("%lld%lld%lld", &a, &b, &k);
	a -= k;
	if (a<0)
	{
		b += a;
		if (b<0)
		{
			b = 0;
		}
		a = 0;
	}
	printf("%lld %lld", a, b);
	
}




Measured memory_bytes: 128
#include <stdio.h>

int main () {
	int n; 
	scanf("%d", &n);
	char string[10005];
	scanf("%s", string);
	for(int i = 0; string[i] != '\0'; i++) {
		string[i] += n;
		if(string[i] > 'Z') {
			string[i] = 64 + (string[i] - 'Z');
		}
	}
	printf("%s", string);
	
	return 0;
}

Measured memory_bytes: 1728
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int m,n;
double a[100][100],b[100][100];
double f(int p,int q,double r){
  int i;
  double mx=0;
  if(p==m){
    mx=r;
  }else if(b[p][q]<r){
    b[p][q]=r;
    for(i=0;i<n;i++)
      mx=max(mx,f(p+1,i,r*a[q][i]));
  }
  return mx;
}
int main(){
  int i,j;
  double mx;
  while(cin>>n>>m&&n+m){
    for(i=0;i<n;i++)
      for(j=0;j<n;j++)
	cin>>a[i][j];
    memset(b,0,sizeof(b));
    mx=0;
    for(i=0;i<n;i++)
      mx=max(mx,f(1,i,1));
    printf("%.2lf\n",mx);
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<utility>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int n,m,d[2005][2005][4],ans;
char a[2005][2005];
int main(){
	ans=-999999;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>a[i][j];
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
			if(a[i][j]=='.')
				d[i][j][0]=d[i][j-1][0]+1;
			else
				d[i][j][0]=0;
		for(int j=m;j>=1;j--)
			if(a[i][j]=='.')
				d[i][j][1]=d[i][j+1][1]+1;
			else
				d[i][j][1]=0;
	}
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++)
			if(a[j][i]=='.')
				d[j][i][2]=d[j-1][i][2]+1;
			else
				d[j][i][2]=0;
		for(int j=n;j>=1;j--)
			if(a[j][i]=='.')
				d[j][i][3]=d[j+1][i][3]+1;
			else
				d[j][i][3]=0;
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			ans=max(ans,d[i][j][0]+d[i][j][1]+d[i][j][2]+d[i][j][3]-3);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 66816
d,g=map(int,input().split())
l=[list(map(int,input().split())) for i in range(d)]
ans=float('inf')
for i in range(2**d):
  a=[]
  b=[]
  s=0
  sg=g
  for j in range(d):
    if (i>>j)&1:
      a.append(j)
    else:
      b.append(j)
  if a:
    for k in a:
      sg-=100*(k+1)*l[k][0]+l[k][1]
      s+=l[k][0]
  if sg>0:
    if b:
      for m in range(1,l[b[-1]][0]):
        sg-=100*(b[-1]+1)
        s+=1
        if sg<=0:
          ans=min(ans,s)
          break
  else:
    ans=min(ans,s)
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
  int N, K, Q;
  int *point;/*格納する領域*/
  int *round;

  scanf("%d%d%d", &N, &K, &Q);

  round = (int *)malloc(sizeof(int) * Q);
  if (round == NULL) {
    exit(0);
  }

  point = (int *)malloc(sizeof(int) * N);
  /*ポインタ変数　= malloc(必要なメモリのバイトサイズ)*/
  if (point == NULL) {
    exit(0);
  }

  for (int i = 0; i < Q; i++) {
    scanf("%d", &round[i]);
  }

  for (int i = 0; i < N; i++) {
    point[i] = K - Q;
  }

  for (int i = 0; i < Q; i++) {
    point[round[i]-1]++;
  }


  /*Conclusion*/
  for (int i = 0; i < N; i++) {
    if (point[i] > 0) {
      printf("Yes\n");
    }else printf("No\n");
  }

  free(point);
  free(round);
  return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep(a,n) for(int i=a;i<n;i++)
#define rep1(a,n) for(int i=a;i<=n;i++)
int main()
{
    int n,r,p=-1,flag=1;
    string s;
    cin>>s;

    for(int i=1;i<s.size();i++)
    {
        if(s[i]==s[i-1])
        {
           flag=0;
           break;
        }
    }
    if(flag==0)
      cout<<"Bad\n";
    else
        cout<<"Good\n";
    return 0;
}


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

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

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

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll n, c, k;
    cin >> n >> c >> k;
    vector<ll> a(n);
    for(ll &x : a){
        cin >> x;
    }
    sort(ALL(a));
    ll bus = 0;
    ll mn = 0;
    ll cnt = 0;
    for(int i = 0; i < n; i++){
        if(i == 0){
            mn = a[i] + k;
            cnt++;
        }else{
            if(a[i] <= mn && cnt < c){
                cnt++;
            }else{
                bus++;
                cnt = 1;
                mn = a[i] + k;
            }
        }
    }
    if(cnt > 0){
        bus++;
    }
    cout << bus;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

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

int main(){
  unsigned long long N,sum;
  cin>>N;
  sum=0;
  for(int i=1;i<=N;i++){
    if(i%3!=0&&i%5!=0){
      sum+=i;
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long int lli;
const lli mod1 = 1e9+7;
const lli mod2 = 1e9+9;
const lli base1 = 1007;
const lli base2 = 1009;

vector<bool> used;
vector<vector<int> > adj;
map<pair<lli, lli>, lli> hnum;
pair<lli, lli> dfs(int node){
    if(used[node]) return make_pair(0, 0);
    used[node] = true;
    pair<lli, lli> res(1, 1);
    for(int i: adj[node]){
        pair<lli, lli> chi = dfs(i);
        res.first = (res.first +chi.first *base1) %mod1;
        res.second = (res.second +chi.second *base2) %mod2;
    }
    hnum[res]++;
    return res;
}

int main(){
    int n;
    cin >> n;
    used.resize(n);
    adj.resize(n);
    for(int i=0; i<n-1; i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    
    dfs(0);
    lli ans = 0;
    for(auto h: hnum){
        lli num = h.second;
        ans += num*(num-1)/2;
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)

int main() {

    string s,t; cin >> s >> t;
    vector<bool> s_alp(26,false);
    vector<bool> t_alp(26,false);

    vector<vector<int>> s_alp_locate(26);
    vector<vector<int>> t_alp_locate(26);

    rep(i, s.size()) {
        s_alp[s[i]-'a'] = true;
        s_alp_locate[s[i]-'a'].push_back(i);
    }
    rep(i, t.size()) {
        t_alp[t[i]-'a'] = true;
        t_alp_locate[t[i]-'a'].push_back(i);
    }

    // できないかの判定
    rep(i, s_alp.size()) {
        if(t_alp[i]) if(!s_alp[i]) {
            cout << "-1" << endl;
            return 0;
        }
    }

    // できる場合
    ll now_index = -1;
    ll ans = 0;
    rep(i, t.size()) {
        char now = t[i];
        auto position = upper_bound(s_alp_locate[now-'a'].begin(), s_alp_locate[now-'a'].end(), now_index);

        // 次のiに行かないと行けない場合
        if(position == s_alp_locate[now-'a'].end()) {
            if(now_index >= s_alp_locate[now-'a'][s_alp_locate[now-'a'].size()-1]) {
                // 次のiにいく処理
                ans += (s.size()-now_index-1);
                now_index = s_alp_locate[now-'a'][0];
                ans += now_index+1;
                continue;
            }
        }
        auto idx_lower = distance(s_alp_locate[now-'a'].begin(), position);
        auto location = s_alp_locate[now-'a'][idx_lower];

        ans += location-now_index;
        now_index = location;
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1724
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <random>
#include <iomanip>
#include <limits>
 
using namespace std;
 
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,l,ii,jj;
ll n,m,a,b,c,d,ans,num,ddx,ddy;
ll x[100005],y[100005];
string s;


int main(){
	cin>>a>>b>>c>>d;
	
	p(min(a,b)+min(c,d));
	return 0;
}

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//切り上げ除算
long long cutup(long long a,long long b){return (a+b-1)/b;}

//累乗
template<typename t>
constexpr t my_pow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
    }
    return x;
}
#define pow my_pow

//chmin,chmax
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll x,a,b;
    cin>>x>>a>>b;
    cout<<(abs(x-a)>abs(x-b)?'B':'A')<<endl;
}

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

int main(void){
    int a, b, k, f;
    cin >> k >> a >> b;
    f = 0;

    for(int i = 0; (a + i) <= b; ++i){
        if((a + i) % k == 0){
            cout << "OK" << endl;
            f = 1;
            break;
        }
    }

    if(f == 0){
        cout << "NG" << endl;
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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 ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll a, b;
  cin >> a >> b;

  ll ans = a * b - (a + b - 1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int MAX = 2100000;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; 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;
    }
}
long long 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(){ 
  COMinit();
  ll n, k; cin >> n >> k;
  vector<ll> A(n); rep(i, n) cin >> A[i];

  ll mx = 0, mn = 0;
  sort(all(A));
  rep(i, n){
    int num = n - i - 1;
    ll com = COM(num, k-1);
    if(com==0) break;
    ll tmp = com * A[i] % MOD;
    mn = (mn + tmp + MOD) % MOD;
  }
  sort(all(A), greater<ll>());
  rep(i, n){
    int num = n - i - 1;
    ll com = COM(num, k-1);
    if(com==0) break;
    ll tmp = com * A[i] % MOD;
    mx = (mx + tmp + MOD) % MOD;
  }
  ll res = (mx - mn + MOD) % MOD;
  cout << res << ln;  
}


Measured memory_bytes: 50304
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        double w = sc.nextDouble();
        double h = sc.nextDouble();
        double x = sc.nextDouble();
        double y = sc.nextDouble();
        System.out.print((w*h/2d) + " " + ((w == (x + x) && h == (y + y)) ? 1 : 0));
    }
}

Measured memory_bytes: 23380
#include<iostream>
using namespace std;
int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if(A==7){
        if(B==5 && C==5){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
    else if(C==7){
        if(A==5 && B==5){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
    else if(B==7){
        if(A==5 && C==5){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
    else{
        cout << "NO" << endl;
    }
}

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

#define eb emplace_back
#define sz(s) (int)(s.size())
#define all(s) s.begin(), s.end()
#define ll long long

const int N = 1e6 + 9;
const int INF = 1e9 + 9;

void solve() {
	int n;
	cin >> n;
	vector <int> a(n);
	for (int i = 0; i < n; ++ i) {
		cin >> a[i];
	}
	sort(all(a));
	if (a[n - 1] - a[0] >= 2) {
		cout << "No\n";
		return;
	}
	int cnt = 0, cnt1 = 0;
	for (int i = 0; i < n; ++ i) {
		if (a[i] == a[0])
			++cnt;
		else
			++cnt1;
	}
	if (cnt == n) {
		if (a[0] == n - 1 or a[0] <= n / 2)
			cout << "Yes\n";
		else
			cout << "No\n";
		return;
	}
	if (cnt1 <= 1) {
		cout << "No\n";
		return;
	}

	if (a[n - 1] >= cnt + 1 and a[n - 1] <= cnt + cnt1 / 2)
		cout << "Yes\n";
	else
		cout << "No\n";
}

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

Measured memory_bytes: 768
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int center = sc.nextInt();
		StringBuilder sb = new StringBuilder();

		int min = Math.max(center-num+1, -1000000);
		int max = Math.min(center+num-1, 1000000);

		for(int i = min; i <= max; i++){
			sb.append(i);
			sb.append(" ");
		}

		System.out.println(sb.toString().trim());
	}
}




Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
 
public class Main {
	public static final int TARO=0;
	public static final int HANAKO=1;
	public void exec() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] inStr= br.readLine().split(" ");
        double x1=Double.parseDouble(inStr[0]);
        double y1=Double.parseDouble(inStr[1]);
        double x2=Double.parseDouble(inStr[2]);
        double y2=Double.parseDouble(inStr[3]);
        double dx = x2 - x1;
        double dy = y2 - y1;
        out.printf("%.4f",Math.sqrt(dx*dx + dy*dy));
        out.flush();
    }
  
    public static void main(String[] args) throws IOException {
        new Main().exec();
    }
}

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

int main(void){
	int N,d,p,res=0;
	cin>>N>>d;
	rep(i,N){
		cin>>p;
		res+=max(0,p-d);
	}
	if(res==0)cout<<"kusoge"<<endl;
	else cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3084
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args)throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try{
      String[] S = br.readLine().split(" ");
      int K = Integer.parseInt(S[0]);
      int N = Integer.parseInt(S[1]);
      S = br.readLine().split(" ");
      int[] val = new int[N];
      for(int i = 0; i < N; i++){
        val[i] = Integer.parseInt(S[i]);
      }
      int max = 0;
      for(int i = 0; i < N; i++){
        int a = 0;
        if(i == N-1){
          a = K-val[i]+val[0];
        }else{
          a = Math.abs(val[i]-val[i+1]);
        }
        max = a > max ? a : max;
      }
      System.out.println(K-max);
    }catch(Exception e){
    }
  }
}

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


using namespace std;

int main () {
  vector<vector<int>> vec(3,vector<int>(3));
  for (int i=0;i<3;i++) {
    for (int j=0;j<3;j++) {
      cin>>vec.at(i).at(j);
    }
  }
  
  int sum;
  for (int i=0;i<3;i++) {
    for (int j=0;j<3;j++) {
      sum+=vec.at(i).at(j);
    }
  }
  
  if (sum%3 != 0) {
    cout<<"No"<<endl;
  }
  else {
    if (vec.at(0).at(0)+vec.at(1).at(1)+vec.at(2).at(2)==sum/3&&vec.at(0).at(1)+vec.at(1).at(2)+vec.at(2).at(0)==sum/3&&vec.at(0).at(2)+vec.at(1).at(0)+vec.at(2).at(1)==sum/3) {
      cout<<"Yes"<<endl;
    }
    else {
      cout<<"No"<<endl;
    }
  }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

import static java.lang.System.in;

public class Main {
    static long[][] selfCon, selfUncon;
    static long mod = 1000000000+7;
    static int n;
    public static void main(String[] args) throws FileNotFoundException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n+1];
        for(int i=1;i<=n;i++) a[i]=sc.nextLong();
        long[] mid = new long[n+1], dp = new long[n+1];
        dp[1] = a[1];dp[2] = Math.max(a[1]+a[2],-a[1]-a[2]);
        mid[2] = Math.max(-a[2]+a[1],-a[1]+a[2]);
        for(int i=3;i<=n;i++){
            dp[i] = Math.max(a[i]+dp[i-1],-a[i]+mid[i-1]);
            mid[i] = Math.max(-a[i]+dp[i-1],a[i]+mid[i-1]);
        }
        long ans = dp[n];
        System.out.println(ans);
    }
}


Measured memory_bytes: 50372
#include <bits/stdc++.h>
class union_find {
 public:
  using tp = std::vector<size_t>::size_type;
  // 取り扱う型.

  explicit union_find(const tp n) : parent(n), rank(n, 0), cache(),
    element(n, 1) {
    for (tp i = 0; i < n; i++) {
      parent[i] = i;
    }
    cache.reserve(n);
  }

  tp root(tp n) {
    // 番号nの親を求める. ついでに経路圧縮を行う.

    while (parent[n] != n) {
      // 根になるまで親を探索. ついでにキャッシュ変数に追加.
      cache.push_back(n);
      n = parent[n];
    }
    for (const auto i : cache) {
      // キャッシュ変数に追加された子の親を経路圧縮.
      parent[i] = n;
    }
    cache.clear();
    return n;
  }

  bool same(tp x, tp y) {
    // xとyが同じグループに属しているか計算.
    return root(x) == root(y);
  }

  tp unite(const tp x, const tp y) {
    // xとyを同じグループにする.
    const auto x_root = root(x);
    const auto y_root = root(y);

    if (x_root == y_root) {
      // 根が同じなら元から同じグループ.
      return 0;
    }
    const auto decrease = element[x_root] * element[y_root];
    if (rank[x_root] < rank[y_root]) {
      // rankの大きい方の根を統合後の根にする.
      parent[x_root] = y_root;
      element[y_root] += element[x_root];
    } else if (rank[y_root] < rank[x_root]) {
      // rankの大きい方の根を統合後の根にする.
      parent[y_root] = x_root;
      element[x_root] += element[y_root];
    } else {
      // rankが同じなら, どっちかを根にして根になったほうのランクを上げる.
      parent[x_root] = y_root;
      rank[x_root]++;
      element[y_root] += element[x_root];
    }
    return decrease;
  }

 private:
  std::vector<tp> parent;
  // 親の番号を格納. 自分が根なら parent[i] == i になる.
  std::vector<tp> rank;
  // 自分の下に何段分の子があるかを格納.
  std::vector<tp> cache;
  // root計算のときに経路圧縮を行うためのキャッシュ変数.
  std::vector<tp> element;
  // グループの数.
};

int main() {
  uint64_t n, m;
  std::cin >> n >> m;

  std::vector<std::pair<uint64_t, uint64_t>> pair(m);

  for (auto &i : pair) {
    uint64_t a, b;
    std::cin >> a >> b;
    i = {a, b};
  }

  std::vector<uint64_t> cost(m);
  cost.back() = n * (n - 1) / 2;

  union_find uf(n);

  for (uint64_t i = 0; i < m - 1; i++) {
    const auto index = m - 1 - i;
    const auto dec = uf.unite(pair[index].first - 1, pair[index].second - 1);
    cost[index - 1] = cost[index] - dec;
  }

  for (const auto i : cost) {
    std::cout << i << std::endl;
  }
  return 0;
}

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

int main() {
    int k, x;
    cin >> k >> x;
    cout << x - k + 1;
    for (int i = 1; i < 2 * k - 1; i++) {
        cout << ' ' << x - k + 1 + i;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import itertools


sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M, Q = map(int, input().split())
ABCD = [list(map(int, input().split())) for _ in range(Q)]


ans = 0
for lst in itertools.combinations_with_replacement(range(1, M + 1), N):
    s = 0
    for a, b, c, d in ABCD:
        if (lst[b - 1] - lst[a - 1]) == c:
            s += d

    ans = max(ans, s)

print(ans)


Measured memory_bytes: 9144
N = int(input())

# 約数の全列挙
def divisors(n):
    divisors = []
    R = int(n**(0.5)) + 1
    for i in range(1, R):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    # divisors.sort(reverse=True)  # ソート
    return divisors

ans = len(str(N))
for a in divisors(N):
    b = N // a
    ans = min(ans, max(len(str(a)), len(str(b))))
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <ctype.h>
#include <algorithm>
#include <cmath>

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)
#define cube(x) (x) * (x) * (x)

const int INF = 1e9;

using namespace std;

int main() {
    string str;
    int pre, pos;
    stack<int> s;
    getline(cin, str);
    istringstream is(str);
    while(is >> str){
        if(atoi(str.c_str()) != 0){
            s.push(atoi(str.c_str()));
        }
        else {
            if(str == "0"){
                s.push(atoi(str.c_str()));
                continue;
            }
            pos = s.top();
            s.pop();
            pre = s.top();
            s.pop();
            if(str == "+")
                s.push(pre + pos);
            if(str == "-")
                s.push(pre - pos);
            if(str == "*")
                s.push(pre * pos);
        }
    }

    cout << s.top() << endl;

    return 0;
}

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

int main()
{
	string s1,s2;
	cin>>s1>>s2;
	int a,b;
	cin>>a>>b;
	string t;
	cin>>t;
	if(t==s1)
		cout<<a-1<<" "<<b;
	else
		cout<<a<<" "<<b-1;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9

ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll n;cin>>n;
    ll a[n],b[n];f(i,0,n){cin>>a[i];b[i]=a[i];}
    sort(b,b+n);ll cnt=0;
    f(i,0,n){
        if(b[i]!=a[i])cnt++;
    }
    if(cnt>2)cout<<"NO";
    else cout<<"YES";
    return 0;  
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
bool used[100][10][10];
int x[100],y[100];
int n;
int dx[]={-1,0,1,2,2,2,1,0,-1,-2,-2,-2},dy[]={2,2,2,1,0,-1,-2,-2,-2,-1,0,1};
main()
{
	int sx,sy;
	while(cin>>sx>>sy,sx||sy)
	{
		cin>>n;
		for(int i=0;i<n;i++)
		{
			cin>>x[i]>>y[i];
			for(int j=0;j<10;j++)for(int k=0;k<10;k++)used[i][j][k]=0;
		}
		queue<pair<int,pair<int,int> > >P;
		P.push(make_pair(0,make_pair(sx,sy)));
		bool f=0;
		while(!P.empty())
		{
			int c=P.front().first,X=P.front().second.first,Y=P.front().second.second;
			P.pop();
			if(c==n)
			{
				f=1;
				break;
			}
			for(int r=0;r<12;r++)
			{
				int tx=X+dx[r],ty=Y+dy[r];
				if(tx<0||ty<0||tx>=10||ty>=10||abs(tx-x[c])>1||abs(ty-y[c])>1)continue;
				if(used[c][tx][ty])continue;
				used[c][tx][ty]=1;
				P.push(make_pair(c+1,make_pair(tx,ty)));
			}
		}
		cout<<(f?"OK":"NA")<<endl;
	}
}



Measured memory_bytes: 3088
n,m = map(int,input().split())
ls = []
switch = [(i+1) for i in range(n)]
ls = [list(map(int,input().split())) for i in range(m)]
p = list(map(int,input().split()))

patterns = []
for i in range(2**n):
    patterns.append(list(bin(i)[2:].zfill(n)))

ans = 0

for pattern in patterns:
    on = []
    light = 0
    for j in range(n):
        if pattern[j] == '1':
            on.append(switch[j])
    for k in range(m):
        count = 0
        for l in range(1,ls[k][0]+1):
            if ls[k][l] in on:
                count += 1
        if count % 2 == p[k]:
            light += 1
    if light == m:
        ans += 1
            
print(ans)

Measured memory_bytes: 3188
L,R = map(int, input().split())

if R - L >= 2019:
  print(0)
else:
  ans = 2019
  for i in range(L,R):
    for j in range(i + 1,R + 1):
      aa = i * j
      aaa = aa % 2019
    
      if aaa < ans:
        ans = aaa
    
      if ans == 0:
        break
      
  print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <set>

using namespace std;

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

	long long N;
	cin >> N;

	set<long long> result;
	result.insert(N);
	if (N - 1 > 1) result.insert(N - 1);

	for (long long i = 2; i * i <= N; i++)
	{
		if (N % i == 1)
		{
			result.insert(i);
			result.insert((N - 1) / i);
		}
		else if (N % i == 0)
		{
			long long newN = N;
			while (newN % i == 0) newN /= i;

			if (newN % i == 1) result.insert(i);
		}
	}

	cout << result.size();

	return 0;
}


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

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

  if(N < K){
    cout << "1" << endl;
  }else if(N == K){
    cout << "0" << endl;
  }else{
    int a[K];
    fill(a,a+K,0);
    int i = 0;
    while(N != 0){
      ++a[i++];
      i %= K;
      --N;
    }
    cout << *max_element(a,a+K)-*min_element(a,a+K) << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
//配列の添字ズレに注意
//=に注意

int main(){
  int n,a,ans=0; cin>>n;
  
  for(int i=1;i<n+1;i++){
    cin>>a;
    if(i*a%2==1)ans++;
  }
  
  //string s; cin>>s;
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const int INF = 1001001001;
const int MOD = 1000000007;

int n;
double dp[310][310][310];

double dfs(int i, int j, int k) {
    if (dp[i][j][k] >= 0) return dp[i][j][k];

    if (i == 0 && j == 0 && k == 0) return 0.0;

    double res = 0.0;
    if (i > 0) res += dfs(i - 1, j    , k    ) * i;
    if (j > 0) res += dfs(i + 1, j - 1, k    ) * j;
    if (k > 0) res += dfs(i    , j + 1, k - 1) * k;

    res += n;
    res *= 1.0 / (i + j + k);

    return dp[i][j][k] = res;
}


int main(){
    cin >> n;
    int one = 0;
    int two = 0;
    int three = 0;

    rep(i, n) {
        int a;
        cin >> a;
        if (a == 1) ++one;
        else if (a == 2) ++two;
        else ++three;
    }

    memset(dp, -1, sizeof(dp));

    cout << fixed << setprecision(10) << dfs(one, two, three) << endl;
}

Measured memory_bytes: 233088
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <set>
#include <cmath>

using namespace std;

int main(){
    long int n,k;
    cin>>n>>k;
    vector<vector<int>> v(n, vector<int>(2, 0));
    int i;
    for(i=0;i<n;i++){
        cin>>v[i][0]>>v[i][1];
    }
    sort(v.begin(),v.end());
    long int c=0;
    i=0;
    while(i<n){
        c+=v[i][1];
        if(c>=k){
            cout<<v[i][0]<<endl;
            break;
        }
        i++;
    }
   
	return 0;
}

Measured memory_bytes: 5760
n = int(input())
v_list = [int(i) for i in input().split()]
c_list = [int(i) for i in input().split()]

ans = 0
for i in range(n):
    if v_list[i] - c_list[i] > 0:
        ans += v_list[i] - c_list[i]
        
print(ans)

Measured memory_bytes: 3060
use std::cmp;

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let v: Vec<isize> = s.trim().split_whitespace().map(|x| x.parse().unwrap()).collect();
    println!("{}", cmp::max(0, cmp::max(v[1],v[2]) - (cmp::min(v[1],v[2]) + v[0])));
}



Measured memory_bytes: 4352
n = input()
x = list(map(float, input().split()))
y = list(map(float, input().split()))


def distance(x, y, p):
    dist = sum([abs(x_ - y_)**p for x_, y_ in zip(x, y)]) ** (1/p)
    return dist


manhattan = distance(x, y, 1)
euclid = distance(x, y, 2)
minkowski = distance(x, y, 3)
chebyshev = max([abs(x_ - y_) for x_, y_ in zip(x, y)])

print(manhattan)
print(euclid)
print(minkowski)
print(chebyshev)



Measured memory_bytes: 5644
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((((a)%MOD*(b)%MOD)%MOD)/gcd((a),(b)))%MOD
#define deba(a) cout << #a << " " << a << endl;
bool ok = false;
int fact[1000005];
bool setwiseCop(ll arr[], ll n)
{
	ll result = arr[0];
	for (ll i = 1; i < n; i++)
	{
		result = gcd(arr[i], result);

		if (result == 1)
		{
			return true;
		}
	}
	if (result != 1)
		return false;
	return true;
}
void facCalc(ll x)
{
	if (ok == true)
		return;
	for (int i = 1; i * i <= x; i++) {
		if (x % i == 0) {
			int a = i;
			int b = x / i;
			if (a == b) {
				a = i;
				b = 1;
			}
			if (a != 1) {
				if (fact[a]) {
					ok = true;
					return;
				}
				fact[a]++;
			}
			if (b != 1) {
				if (fact[b]) {
					ok = true;
					return;
				}
				fact[b]++;
			}
		}
	}
}
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("/home/kushagra/Desktop/Kushagra/input.txt", "r", stdin);
	freopen("/home/kushagra/Desktop/Kushagra/output.txt", "w", stdout);
#endif
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		ll a[n];
		rep(i, 0, n)
		cin >> a[i];
		rep(i, 0, n)
		facCalc(a[i]);
		if (!ok)
			cout << "pairwise coprime";

		else if (setwiseCop(a, n))
			cout << "setwise coprime";
		else
			cout << "not coprime";
	}
	return 0;
}

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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

int a, b, c;

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

	cin >> a >> b >> c;
	if (a == b && b == c) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
x = list(map(int,input().split()))
y = x
y.sort()
mini = 10000000000000
for i in range(y[-1], 0, -1):
    tmp = 0
    for j in x:
        tmp += (j - i)**2
    if mini >= tmp:
        mini = tmp
print(mini)

Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  string s;
  R s;
  ll ans=MAX;
  rep(k,2) {
    ll cnt=0;
    rep(i,s.size()) {
      if(s[i]-'0'!=(k+i)%2) cnt++;
    }
    ans=min(ans,cnt);
  }
  pr(ans);
}

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


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

string S;

int main() {
    cin >> S;

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

    char ans = 'a';
    bool f = false;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == ans) {
            if (ans == 'z') {
                f = true;
                break;
            }
            ans++;
        }
    }

    if (f) cout << "None" << endl;
    else cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main(){
  string s; cin >> s;
  int q; cin >> q;
  int t; int f; char c;
  string x = "";
  string y = "";
  bool r = false;
  for(int i=0; i<q; i++) {
    cin >> t;
    if (t == 1) {
      r = !r;
    }else if (t == 2) {
      cin >> f >> c;
      if (f == 1 && r) y += c;
      if (f == 1 && !r) x += c;
      if (f == 2 && r) x += c;
      if (f == 2 && !r) y += c;
    }
  }
  reverse(all(x));
  s = x + s + y;
  if (r) reverse(all(s));
  cout << s << endl;

}

// EOF


Measured memory_bytes: 1348
N, M = list(map(int, input().split(" ")))
list_a = list(map(int, input().split(" ")))

##半公倍数が存在するかチェック
def check_exist(l) :
  if(len(l) == 1) :
    return True
  while(True) :
    flag = l[0] % 2
    for x in l[1:] :
      if(x % 2 != flag) :
        return False
    if(flag == 0) :
      l = list(map(lambda x: int(x/2), l))
    else :
      return True
    

##最大公約数を求める

def gcd(a, b) :
  if(b==0) :
    return a
  else :
    return gcd(b, a%b)
   
##最小公倍数を求める
def lcm(a, b) :
  cd = gcd(a, b)
  return (a / cd) * b
  
##複数個の整数の最小公倍数を求める
def lcm_multi(l) :
  cm = 1
  for x in l :
    cm = lcm(x, cm)
    if(cm > 4 * M) :
      print(0)
      exit()
    
  return cm

if(not(check_exist(list_a))) :
  print(0)
  exit()

## 1/2の公倍数
lcm_m = lcm_multi(list(map(lambda x: int(x/2), list_a)))

if(M-lcm_m < 0) :
  print(0)
else :
  print(int((M-lcm_m) / (2*lcm_m)) + 1)



Measured memory_bytes: 15148
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			(3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
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;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<endl;}
void Yn(bool b){cout<<(b?"Yes":"No")<<endl;}
void yn(bool b){cout<<(b?"yes":"no")<<endl;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,x,y;
	cin>>n>>m;
	vi ans(n,-2);
	vb root(n,true);
	vvi c(n);
	vector<set<int>> p(n);
	rep(i,n+m-1){
		cin>>x>>y;
		x--;y--;
		root[y]=false;
		c[x].push_back(y);
		p[y].insert(x);
	}
	queue<int> q;
	int r=-1;
	rep(i,n){
		if(root[i])r=i;
	}
	q.push(r);
	ans[r]=-1;
	while(!q.empty()){
		int t=q.front();q.pop();
		rep(i,c[t].size()){
			if(p[c[t][i]].size()==1){
				ans[c[t][i]]=*p[c[t][i]].begin();
				q.push(c[t][i]);
			}
			p[c[t][i]].erase(t);
		}
	}
	rep(i,n)cout<<ans[i]+1<<"\n";
	//rep(i,n)cout<<p[i].size()<<endl;
}



Measured memory_bytes: 16128
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int[] dice=new int[6];
		int top=1,n=5,w=4,s=2,e=3;
		String[] str=br.readLine().split(" ");//diceの配列に面の値を読み込む
		for(int i=0;i<6;i++){
			dice[i]=Integer.parseInt(str[i]);
		}
		String a=br.readLine();
		char dis[]=a.toCharArray();//読み込んだ方角推移をchar型のdis[]に格納
		for(int i=0;i<a.length();i++){
			switch (dis[i]){
			case 'S':
				{s=top;top=n;n=7-s;break;}
			case 'W':
				{w=top;top=e;e=7-w;break;}
			case 'N':
				{n=top;top=s;s=7-n;break;}
			case 'E':
				{e=top;top=w;w=7-e;break;}
			default:
					System.out.println("その方角は受け入れられません");
			}
		}
		System.out.println(dice[top-1]);
	}
}

Measured memory_bytes: 16896
use std::io::{self, BufRead};

fn find_index(ps: &Vec<usize>, n: usize) -> usize {
  let mut digits: Vec<usize> = (1..(n+1)).collect();
  let mut total: usize = 0;
  for i in 0..n {
    if let Some(j) = digits.iter().position(|&x| x == ps[i]) {
      let x =  j * (1..(n-i)).product::<usize>();
      total += x;
      digits.remove(j);
    }
  }
  total
}

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let line = lines.next().unwrap().unwrap();
  let n: usize = line.parse().unwrap();
  let line = lines.next().unwrap().unwrap();
  let ps: Vec<usize> = line.split(' ').map(|x| x.parse().unwrap()).collect();
  let line = lines.next().unwrap().unwrap();
  let qs: Vec<usize> = line.split(' ').map(|x| x.parse().unwrap()).collect();
  let x = find_index(&ps, n);
  let y = find_index(&qs, n);
  let ans = if x < y { y - x } else { x - y };
  println!("{}", ans);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> v(h);
	rep(i,h) cin >> v[i];
	queue<pii> q;
	vector<vector<int>> dist(h, vector<int>(w, INF));
	rep(i,h) {
		rep(j,w) {
			if (v[i][j] == '#') {
				dist[i][j] = 0;
				q.push(make_pair(i,j));
			}
		}
	}

	while (!q.empty()) {
		auto p = q.front(); q.pop();
		rep(d, 4) {
			int ni = p.first + dy[d];
			int nj = p.second + dx[d];
			if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
			if (dist[ni][nj] != INF) continue;
			dist[ni][nj] = dist[p.first][p.second] + 1;
			q.push(make_pair(ni, nj));
		}
	}

	int ans = 0;
	rep(i,h) rep(j,w) ans = max(ans, dist[i][j]);
	cout << ans << endl;
}

Measured memory_bytes: 17112
def divisors(n):
    d=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            d.append(i)
            if i!=n//i:
                d.append(n//i)
    d.sort()
    return d

x,y=map(int,input().split())
print(-1 if y in divisors(x) else x)

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

int main() {
    int a, b;
    cin >> a >> b;
    
    int count = 0;
    int tap = 0;
    
    while(count < b) {
     tap++;
     count += a;
     if(count >= b) {
      break;
     }
     
     count--;
    }
    
    if(b == 1){
     cout << 0;
     }
      else {
      cout << tap;
      }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1,mod=1e9+7;
const int inf=(1ull<<31)-1;
ll n;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>n;
	if (!(n&1)){
		n>>=1;
		ll t5=n;
		for (;t5;n-=t5%5,t5/=5);
		n>>=2;
		cout<<n;
	}
	else 
		cout<<"0";
	return 0;
}

Measured memory_bytes: 256