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

void swap(int a,int b)
{
    int ab = a;
    a = b;
    b = ab;
}

void sort3(int one,int two,int three)
{
    if(one > two)swap(one,two);
    if(two > three)swap(two,three);
    if(one > two)swap(one,two);
}

int main()
{
    int K;
    long long ans = 0;
    int dp[205][205][205] = {};

    cin>>K;

    for(int first = 1; first <= K;first++)
    {
        for(int second = 1; second <= K; second++)
        {
            for(int third = 1; third <= K; third++)
            {
                int smallest = first,half = second,most = third;
                
                sort3(smallest,half,most);


                if(dp[smallest][half][most] != 0)
                {
                    ans += dp[smallest][half][most];
                    continue;
                }

                int count = 1;//最大公約数を記憶する変数
                while(1)
                {
                    //3つの数字が割り切れる数字が存在したかの確認
                    bool check = false;
                    for(int i = 2; i <= smallest; i++)
                    {
                        if(smallest % i == 0 and half % i == 0 and most % i == 0)
                        {
                            smallest = smallest / i;
                            half = half / i;
                            most = most / i;
                            count *= i;
                            check = true;
                            break;
                        }

                    }
                    if(check == false)break;
                }
                
                dp[smallest][half][most] = count;
                ans += dp[smallest][half][most];
            }
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 37272
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
 
int A, B, C, D;
 
void Solution() {
 
    while(true) {
        C -= B;
        if (C < 1) break;
        A -= D;
        if (A < 1) break;
    }
 
    if (A >= 1) cout << "Yes" << endl;
    else if (A < 1) cout << "No" << endl;
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    cin >> A >> B >> C >> D;
    Solution();
 
    return 0;
}

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

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

#define ll long long int
#define ld long double
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define pi 3.14159265358979
#define pa pair<ll,ll>
//#define goodset tree<pa, null_type, less<pa>, rb_tree_tag, tree_order_statistics_node_update>
//#define FRE freopen("acm.in","r",stdin); freopen("acm.out","w",stdout);

const ll mod = 1e9+7 ;
const ll N = 1e5+7;

int main()
{
    FAST
    ll tc,i,j,k;
    //cin>>tc;
    tc=1;
    while(tc--)
    {
       ll n;
       cin>>n;
       ll a[n];
       for(i=0; i<n; i++)
        cin>>a[i];

       ll ans=0;
       ll mx=a[0];
       for(i=1; i<n; i++)
       {
           if(a[i]>=mx)
           {
               mx=max(a[i],mx);
           }
           else
            ans+=(mx-a[i]);
       }
       cout<<ans;

    }
    return 0;
}





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

using namespace std;

int main(){
    int n;

    cin >> n;

    n++;

    int a[n]={0};

    a[0]=0;

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

    int ans[n]={0};

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

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

Measured memory_bytes: 5160
#include <stdio.h>

int main(){
	char s[100000]={'\0'};
	scanf("%s", s);

	char tmp = '0';
	int i=0;
	int ans1=0;
	while(s[i]!='\0'){
		if(s[i]!=tmp){
			ans1++;
		}
		i++;
		if(tmp=='0')
			tmp = '1';
		else
			tmp = '0';
	}
	
	tmp = '1';
	i=0;
	int ans2=0;
	while(s[i]!='\0'){
		if(s[i]!=tmp){
			ans2++;
		}
		i++;
		if(tmp=='0')
			tmp = '1';
		else
			tmp = '0';
	}
	if(ans1<ans2)
		printf("%d ", ans1);
	else
		printf("%d", ans2);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, const char * argv[]) {
    int N;
    int a[100];
    int count = 0;
    
    cin >> N;
    
    for(int i = 0; i < N; i++) {
        cin >> a[i];
    }
    
    for(int j = 0; j < N; j++) {
        if (a[j] == a[j+1]) {
            a[j+1] = -1;
            count += 1;
        }
    }
    
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;

int a[N], b[N];
int n;

int c[N];

int lowbit(int x) {return x & (-x);}

void add(int x, int v) {
    for(; x < N; x += lowbit(x)) c[x] += v;
}

int query(int x) {
    int ans = 0;
    for(; x; x -= lowbit(x)) ans += c[x];
    return ans;
}

bool check(int x) {
    b[0] = 0;
    for(int i = 1; i <= n; i++) {
        if(a[i] < x) b[i] = -1;
        else b[i] = 1;
        b[i] += b[i - 1];
    }
    int Min = *min_element(b, b + n + 1);
    if(Min <= 0) for(int i = 0; i <= n; i++) b[i] -= Min - 1;
    ll tot = 0;
    for(int i = 0; i <= n; i++) {
        tot += query(b[i]);
        add(b[i], 1);
    }
    for(int i = 0; i <= n; i++) add(b[i], -1);
    return tot >= (1ll * (n + 1) * n / 2 + 1) / 2;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    int l = 1, r = 1e9 + 1, mid;
    while(l < r) {
        mid = (l + r) >> 1;
        if(check(mid)) l = mid + 1;
        else r = mid;
    }
    cout << l - 1;
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define w(x) int x; cin>>x; while(x--)
#define f(i,n) for(ll i=0;i<n;i++)
#define ff first
#define ss second

void ganekasar()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

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

    vector<double> dp(n+1, 0.0);

    dp[0] = 1;

    for(int coin = 0; coin < n; coin++)
    {
        double p_heads;
        cin>>p_heads;

        for(int i = coin+1; i >= 0; i--)
        {
            if(i == 0)
                dp[i] = dp[i]*(1 - p_heads);
            else
                dp[i] = dp[i-1]*p_heads + dp[i]*(1 - p_heads);
        }
    }

    double answer = 0;

    for(int heads = 0; heads <= n; heads++)
    {
        int tails = n - heads;

        if(heads > tails)
            answer += dp[heads];
    }

    cout<<fixed<<setprecision(10)<<answer<<endl;
    
    return 0; 
} 

Measured memory_bytes: 3780
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

bool same(int n, int *array, int *rs)
{
  int cnt = 0;

  for (int i = 0; i < n; i++){
    if (array[i] == rs[i]){
      cnt++;
    }
  }

  return (n == cnt ? true : false);
}

int main()
{
  int n;
  int array[12];

  while (scanf("%d", &n), n){
    for (int i = 0; i < n; i++){
      scanf("%d", &array[i]);
    }
    for (int op = 0;; op++){
      int rs[12];
      for (int i = 0; i < n; i++){
        int cnt = 0;
        for (int j = 0; j < n; j++){
          if (array[i] == array[j]){
            cnt++;
          }
        }
        rs[i] = cnt;
      }
      if (same(n, array, rs)){
        printf("%d\n", op);
        for (int i = 0; i < n - 1; i++){
          printf("%d ", rs[i]);
        }
        printf("%d\n", rs[n - 1]);
        break;
      }
      memcpy(array, rs, sizeof(array));
    }
  }

  return (0);
}

Measured memory_bytes: 1188
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
num=n-1
num2=0
num3=1
ans=pow(2,n//2,10**9+7)
for i in range(n//2):
    for j in range(2):
        if a[num2]!=num:
            num3=0
            break
        num2+=1
    num-=2
    if num3==0:
        break
if n%2==1:
    if a[-1]!=num:
        ans=0
if num3==0:
    ans=0
print(ans)


Measured memory_bytes: 20472
/*input
5
1 2 3 4 5
1000000000 1000000000 1000000000 1000000000 1000000000
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<ld,ld>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll INF64=4e18;
const int INF=1e6+1;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll sub(ll a,ll b){
    ll x=a-b;
    while(x<0) x+=MOD;
    while(x>MOD) x-=MOD;
    return x;
}
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=(res*a);
        if(res>1e10) return 1e11;
        a=(a*a);
        b>>=1;
    }
    return res;
}
const ll maxn=200005;
const ll maxlg=__lg(maxn)+2;
int h[maxn],a[maxn];
ll dp[maxn];
set<ll> s;
int main(){
    int n;
    cin>>n;
    REP(i,n) cin>>h[i];
    REP(i,n) cin>>a[h[i]];
    s.insert(0);
    REP(i,n){
        auto cur=s.upper_bound(h[i]);
        dp[h[i]]=dp[*prev(cur)]+a[h[i]];
        while(cur!=s.end() and dp[h[i]]>=dp[*cur]) cur=s.erase(cur);
        s.insert(h[i]);
    }
    cout<<dp[*s.rbegin()]<<'\n';
}

Measured memory_bytes: 12800
n,k=map(int, input().split())
h=list(map(int,input().split()))
dp=[0]*(n)
if k+1<=n:
  max=k+1
else:
  max=n
  
for i in range(1,max):
  dp[i]=abs(h[0]-h[i])

for i in range(k,n):
  li=[abs(h[i]-h[ik])+dp[ik] for ik in range(i-1,i-k-1,-1) ]
  dp[i]=min(li)
  
print(dp[-1])

Measured memory_bytes: 20552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000

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

int main() {
    int a, b, c, ans=0;
    cin >> a >> b >> c;
    for(int i=a;i<=b;i++){
        if(c % i == 0) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3132
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<cstring>
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < (n);++i)
#define reps(i,n) for(int i = 1;i <= (n);++i)
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;
	cin >> a >> b;
	cout << max({a + b,a - b,a * b}) << '\n';
	return 0;
}

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

int main(void){
  struct{
    int A,B;
  }data[200000];

  unsigned *board[2][4097]; 
  unsigned **calc,*center[4097],ans=0;
  int i,j,k,N;
  const unsigned mod=(unsigned)1E9+7;

  for(i=0;i<2;i++){
    for(j=0;j<4097;j++){
      board[i][j]=(unsigned *)calloc(4097,sizeof(unsigned));
      if(i==1) center[j]=board[1][j]+2049;
    }
  }
  calc=&center[2049];

  scanf("%d",&N);
  for(i=0;i<N;i++) scanf("%d%d",&data[i].A,&data[i].B);

  for(i=0;i<4097;i++) for(j=0;j<4097;j++) board[0][i][j]=(i==0 || j==0)?1:(board[0][i][j-1]+board[0][i-1][j])%mod;
 
 for(i=0;i<N;i++) calc[-data[i].A][-data[i].B]++;
 for(i=0;i<4097;i++){
   for(j=0;j<4097;j++){
     if(i!=0) board[1][i][j]+=board[1][i-1][j];
     if(j!=0) board[1][i][j]+=board[1][i][j-1];
     board[1][i][j]%=mod;
   }
 }

 for(i=0;i<N;i++){
   ans+=calc[data[i].A][data[i].B];
   if(ans>=board[0][2*data[i].A][2*data[i].B]) ans-=board[0][2*data[i].A][2*data[i].B];
   else ans+=mod-board[0][2*data[i].A][2*data[i].B];
   ans%=mod;
 }
 
 if(ans%2) ans+=mod;
 ans/=2;
 printf("%u\n",ans%mod);

 for(i=0;i<2;i++) for(j=0;j<4097;j++) free(board[i][j]);

  return 0;
}

Measured memory_bytes: 132992
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
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 long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
typedef pair<double, long long> pair_t;
bool comp(const pair_t& a, const pair_t& b) {
	if (a.first == b.first)return  a.second > b.second;
	else {
		return a.first > b.first;
	}
}

int main() {
	ll n;
	bool flag = true;
	cin >> n;
	vector<ll>a(n);
	rep(i, n)cin >> a[i];
	for (ll i = 0; i < n; i++) {
		if (a[i] % 2 == 0 && (a[i] % 3 != 0 && a[i] % 5 != 0))flag = false;
	}
	cout << (flag == true ? "APPROVED" : "DENIED") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    ll res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}
ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}

ll f[200001];
 
ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a; 
 while(b > 0)
    {
        if(b%2 == 1)
    {
        x=(x*y);
        if(x>MOD) x%=MOD;
    }
    y = (y*y);
    if(y>MOD) y%=MOD; 
    b /= 2;
    }
 return x;
}
 
/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}
 
ll C(ll n, ll r, ll MOD)
{
 
 return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}
 


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    vector <int> v(n);
    generate(all(v),nxt);
    int x=0;
    for(auto i:v)
        x^=i;
    for(auto i:v){
        int y=x^i;
        cout<<y<<" ";
    }
    cout<<endl;


    return 0;   
}


 
 


Measured memory_bytes: 4000
#include<stdio.h>

int search(int A[], int n, int key){
	int i = 0;
	A[n] =key;
	while( A[i] != key ) i++;
	return i != n;
}

int main(void){
	int i,n,A[10000+1],q,key,sum = 0;
	
	scanf("%d",&n);
	for( i = 0; i < n; i++)scanf("%d",&A[i]);
	
	scanf("%d",&q);
	for( i = 0; i < q; i++){
	    scanf("%d",&key);
		if(search(A,n,key))sum++;
	}
	printf("%d\n",sum);
	
    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
///1<<3シフト演算子 とは　0001の1を三つずらして1000にする, これは8を表しておりつまりbitは0から7まで
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
#define PI 3.14159265359
#define MOD 1000000007
using namespace std;
using ll = long long;
using ld = long double;

//条件式 ? 真の場合の文 : 偽の場合の文
//string S  S,at(i),S += T,S += c,S.size(),S.substr(l)l文字目から最後まで,
///S.substr(l, r)l文字目からl+r-1文字目 n文字目から0個で空列を返せる
//*min_element(all(x)) *max_element(all(x))
//vi x; x.back(),x.front(),x.push_back(),x.pop_back()
//gcd(a, b)最大公約数
//sort(all(x)),reverse(all(x)),sort(x.begin()+l,a.begin()+r)lからrまで
//stack<int> a; a.push(x),a.pop(),a.top(),a.empty()bool
//queue<int> b; b.push(x),b.pop(),b.front(),b.empty()bool,b.size() 要素が小さい順
//priority_queue<int, vector<int>, greater<int>> c,c.top()
//map<int, int> M1; 変数[key] = value; 変数.erase(key); 変数.at(key); 変数.count(key)所属判定　変数.size()
//find(all(x), key)boolソート済みのベクトル
//*lower_bound(all(x),k)以上の最小の要素,*uppper_bound(all(x),k)より大きい最小の要素
//char('0'+cnt) 数字cntからcharへの変換
//int(char-'0') charからintへの変換
//binary_search(all(p),x) bool型

int main(){

    ld a,b,h,m;
    cin >> a >> b >> h >> m;
    ld ans;
    ans = a*a + b*b -2*a*b*cos((30*h -5.5*m)*2*PI/360);
    ans = sqrt(ans);
    CST(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 4184
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


N = I()
prev_t = 0
prev_x = 0
prev_y = 0
for i in range(N):
    t, x, y = LI()
    if abs(prev_x-x) + abs(prev_y-y) > (t - prev_t) or (abs(prev_x-x) + abs(prev_y-y) + (t - prev_t)) % 2:
        print('No')
        exit()
    prev_t = t
    prev_x = x
    prev_y = y
print('Yes')


Measured memory_bytes: 42732
#include<stdio.h>
#include<stdlib.h>
int main(void){
  int n,d,i,j,k,dist,ans=0;
  scanf("%d %d",&n,&d);
  int x[n][d];
  for(i=0;i<n;i++){
    for(j=0;j<d;j++){
      scanf("%d",&x[i][j]);
    }
  }
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
      dist = 0;
      for(k=0;k<d;k++){
        dist += abs(x[i][k]-x[j][k])*abs(x[i][k]-x[j][k]);
      }
      //printf("%d:\n",dist);
      for(k=0;k<=dist;k++){
        //printf("%d-%d",k*k,dist);
        if(k*k==dist){
          ans++;
          break;
        }
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<bool> memo(N + 1, false);
	for (int i = 0; i < K; ++i) {
		int d;
		cin >> d;
		for (int j = 0; j < d; ++j) {
			int a;
			cin >> a;
			memo[a] = true;
		}
	}

	int ans = 0;
	for (int i = 1; i <= N; ++i) {
		if (!memo[i]) { ++ans; }
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include <time.h>
#include <iostream>
using namespace std;
int main(void)
{

  int n, d, count = 0;
  cin >> n >> d;

  for (int i = n; i > 0; i -= d * 2 + 1)
  {
    count++;
  }
  cout << count << endl;
}


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

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 300000;
int a[N];
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt",  "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++){
            char c;
            cin >> c;
            a[c - 'a']++;
        }
    }
    int x, y, z;
    x = y = z = 0;
    if (n % 2 && m % 2){
        z = 1;
        y = n / 2 + m / 2;
        x = (n * m - 2 * y - z) / 4;
    } else
    if (n % 2 || m % 2){
        if (m % 2) swap(m, n);
        z = 0;
        y = m / 2;
        x = (n * m - 2 * y)/ 4;
    } else x = n * m / 4;
    for (int i = 0; i < 26 && z; i++){
        if (a[i] % 2){
            a[i]--;
            z--;
        }
    }
    for (int i = 0; i < 26; i++){
        if (a[i] % 2){
            cout << "No";
            return 0;
        }
        a[i] /= 2;
        while(x && a[i] > 1){
            a[i] -= 2;
            x--;
        }
        while(y && a[i]){
            y--;
            a[i]--;
        }
    }
    for (int i = 0; i < 26; i++){
        if (a[i]){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}


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

int main()
{
    int N;
    long long W;
    cin>>N>>W;
    long long w0 = -1;
    vector<long long> v[4];
    for (int i=0; i<N; i++)
    {
        long long tw, tv;
        cin>>tw>>tv;
        if (w0==-1)
            w0 = tw;
        v[tw-w0].push_back(tv);
    }

    for (int i=0; i<4; i++)
    {
        sort(v[i].begin(), v[i].end());
        reverse(v[i].begin(), v[i].end());
    }

    vector<long long> s[4];
    for (int i=0; i<4; i++)
    {
        s[i].resize(v[i].size()+1);
        for (int j=0; j<(int)v[i].size(); j++)
            s[i][j+1] = s[i][j]+v[i][j];
    }

    long long ans = 0;
    long long n[4];
    for (n[0]=0; n[0]<=v[0].size(); n[0]++)
    for (n[1]=0; n[1]<=v[1].size(); n[1]++)
    for (n[2]=0; n[2]<=v[2].size(); n[2]++)
    {
        long long t = n[0]*w0 + n[1]*(w0+1) + n[2]*(w0+2);
        if (t<=W)
        {
            n[3] = min((long long)v[3].size(), (W-t)/(w0+3));
            long long a = 0;
            for (int i=0; i<4; i++)
                a += s[i][n[i]];
            ans = max(ans, a);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
def resolve():
    N, D, A = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(N)]
    AB.sort()

    # imos
    imos = [0] * (N+1)
    ans = 0
    R = 0
    for l in range(N):
        if l:
            imos[l] += imos[l - 1]
        x = AB[l][0]
        h = AB[l][1]
        if imos[l] < h:
            R = max(R, l + 1)
            while R < N and AB[R][0] <= 2 * D + x:
                R += 1
            d = h - imos[l]
            cnt = (d+A-1) // A
            imos[l] += cnt * A
            imos[R] -= cnt * A
            ans += cnt
    print(ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 53436
using System;
using System.Text;


class Program
{


    static void Main(string[] args)
    {

        char[] cs = new char[] { ' ', ',' };
        //int val = int.Parse(Console.ReadLine());
        //int[] vals = parseAry(Console.ReadLine().Split(cs));
        //string str = Console.ReadLine();
        //string[] strs = Console.ReadLine().Split(cs);

        //string res="";
        //int res = 0; ;
        //int t = int.Parse(Console.ReadLine());
        //string str = Console.ReadLine();
        ///int[] vals = parseAry(Console.ReadLine().Split(cs));
        //int n = int.Parse(Console.ReadLine());

        int res = 0;

        string str = Console.ReadLine();

        //int[] vals = parseAry(Console.ReadLine().Split(cs));

        for (int i = 0; i < str.Length; i++)
        {
            if (str[i] == '2') { res++; }
        }

        Console.WriteLine(res);

        return;
    }

    //　String[]  ----->  int[]
    static int[] parseAry(string[] str)
    {
        int[] nums = new int[str.Length];
        for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
        return nums;
    }
    //　String[]  ----->  long[]
    static long[] parseAryL(string[] str)
    {
        long[] nums = new long[str.Length];
        for (int i = 0; i < str.Length; i++) { nums[i] = long.Parse(str[i]); }
        return nums;
    }

    //文字列を1文字ずつString[]に入れる
    static string[] strAry(String str)
    {
        string[] re = new string[str.Length];
        for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); }
        return re;
    }

}

Measured memory_bytes: 11092
while True:
    count = 0
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    for i in range(1,n-1):
        for j in range(i+1,n):
            target = x - (i+j)
            if j+1 <= target <= n:
                count += 1
    print(count)


Measured memory_bytes: 5596
s = input()
S = [int(s[i]) for i in range(len(s))]
# print(S)
count = 0
before = 0
while 1:
    #print("S:", S)
    is_continue = False
    # print(len(S))
    #deleted = False
    for i in range(max([before, 0]), len(S) - 1):
        #print(before, i)
        #print(S[i], S[i + 1])
        # print(S)
        if S[i] != S[i + 1]:
            # print(count)
            del S[i]
            del S[i]
            count += 2
            is_continue = True
            before = i - 2
            #deleted = True
            break
    if not is_continue:
        break
print(count)


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

int main(){
	int dx[4]={0,1,0,-1};
    int dy[4]={1,0,-1,0};

	int w,h;
	while(cin>>w>>h and w>0){
		queue<pair<int,int>> q;
	    int sy,sx;
		char c[h][w]; int d[h][w];
		rep(i,h){
	        rep(j,w){
	            cin>>c[i][j]; d[i][j]=INF;
				if(c[i][j]=='@'){
					sy=i; sx=j;
				}
	        }
	    }
		d[sy][sx]=0;
	    q.push(make_pair(sy,sx));

		int ans=1;
		while(q.size()){
	        pair<int,int> p=q.front(); //キューの先頭を取り出す
	        q.pop(); //取り出したら削除
	        int prev=d[p.first][p.second]; //一手前の手数prev
	        rep(i,4){ //4方向探索
	            int cy=p.first+dy[i];
	            int cx=p.second+dx[i];
	            if(c[cy][cx]=='.' and d[cy][cx]==INF){ //通行可能かつ未到達
					if(0<=cy and cy<h){
						if(0<=cx and cx<w){
							d[cy][cx]=prev+1;
			                q.push(make_pair(cy,cx));
							ans++;
						}
					}
	            }
	        }
	    }
		cout<<ans<<endl;
	}
    return 0;
}



Measured memory_bytes: 3056
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

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

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

const int N = 100000;
vector<pair<LL, LL>> sa;

int main() {
	int n;
	cin >> n;
	auto sa = vector<pair<LL, LL>>(n);
	REP(i, n) {
		int a, b;
		scanf("%d%d", &a, &b);
		sa[i] = MP((LL)(a + b), a);
	}
	sort(ALL(sa), greater<pair<LL, LL>>());
	LL ret = 0;
	REP(i, n) {
		if (i &1) {
			ret -= sa[i].first - sa[i].second;
		}
		else {
			ret += sa[i].second;
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define watch(x) cout << (#x) << " is " << (x) << endl
 
bool isPrime(int i) {
	if(i < 2) {
		return false;
	}
	if(i == 2) {
		return true;
	}
	if(!(i % 2)) {
		return false;
	}
	for(int j = 3; j * j <= i; j += 2) {
		if(!(i % j)) {
			return false;
		}
	}
	return true;
}
void solve() {
	int n;
	cin >> n;
	string ans = "7";
	set<int> s;
	long long a = 7;
	while(true) {
		if(a >= n) {
			a %= n;
			if(!a) {
				cout << ans.size() << "\n";
				return;
			}
			else {
				if(s.find(a) != s.end()) {
					cout << -1 << "\n";
					return;
				}
				else {
					s.insert(a);
					a = stoll(to_string(a) + '7');
					ans += '7';
				}
			}
		}
		else {
			a = stoll(to_string(a) + '7');
			ans += '7';
		}
	}
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
    int T = 1; 
    // cin >> T;
    while(T--) {
    	solve();
    }
	return 0;
}


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

using namespace std;

int main(){
    int N;
    string S;
    while(cin >> N >> S){
        int res = 0;
        for(int i=0;i<1000;i++){
            int o = 0;
            vector<int> d(3);
            int t = i;
            for(int j=0;j<3;j++){ d[j] = t%10; t/=10; }
            for(const auto& c : S){
                if(c-'0' == d[o]){
                    o++;
                    if(o==3) break;
                }
            }
            if(o == 3) ++res;
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int a[]=new int[n];

		long kosuu=0;

		a[0]=sc.nextInt();
		if(a[0]!=0) {
			System.out.print(-1);
		}
		else {
			for(int i=1;i<n;i++) {
				a[i]=sc.nextInt();

				if(a[i]>0) {
					kosuu++;
				}

				if(a[i]<=a[i-1]) {
					if(a[i]!=0) {
						kosuu+=a[i]-1;
					}
				}

				if(a[i]-a[i-1]>1) {
					kosuu=-1;
					break;
				}

			}

			System.out.print(kosuu);
		}

	}

}


Measured memory_bytes: 85008
using System;
public class Class1
{
	public static void Main()
	{
		while(true)
		{
		string dataSet =Console.ReadLine();
		if(dataSet=="0")
		{
			break;
		}
		char[] cs=dataSet.ToCharArray();
		int sum=0;
		
		for(int i=0;i<cs.Length;i++)
		{
			
			sum+=int.Parse(cs[i].ToString());
		}
		
		Console.WriteLine(sum);
	}
	}
}

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

ans = 0
q = True
while q == True:
    for i in range(n):
        if a[i]%2 == 0:
            a[i] = a[i]//2
        else:
            print(ans)
            q = False
            break
    ans += 1


Measured memory_bytes: 63696
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef unsigned long long LL;

const int maxn = 100009;
LL n, A, B, h[maxn];
LL l = 0, r = 9e18, mid;

bool check(LL x){
	LL res = 0;
	for (LL i=1; i<=n; i++)
		if (h[i] > B*x)
			res += (h[i]-B*x+A-B-1)/(A-B);
	return res <= x;
}

int main(){
	scanf("%llu%llu%llu", &n, &A, &B);
	for (LL i=1; i<=n; i++) scanf("%llu", &h[i]);
	while (l < r){
		mid = (l+r) >> 1;
		if (check(mid)) r = mid;
		else l = mid + 1;
	}
	printf("%llu\n", l);
	return 0;
}

Measured memory_bytes: 896
N=gets.to_i
M=10**9+7;I=[1,1];*F=I;*R=I
2.upto(N){|i|I<<z=(M-M/i)*I[M%i]%M;F<<i*F[-1]%M;R<<z*R[-1]%M}
r=0
(-~N/2...N).each{|i|r=(r+F[i-1]*R[N-i-1]*R[2*i-N]*F[i]*F[N-i-1])%M}
p (F[N]-r)%M

Measured memory_bytes: 27288
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;

long mod = 1000000007;
/* C++の構造体 メンバがpublicなclass */
typedef struct mint
{
    ll x;
    mint(ll x = 0) : x(x % mod) {} //コンストラクタ
    /* 演算子オーバーロード */
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
} mint_t;

ll intpow(mint_t m, int n)
{
    if (n == 0) return 1;
    mint_t ans(1);
    while (n >= 1)
    {
        if ((n % 2) == 0){
            m *= m.x;
            n /= 2;
        }else {
            ans *= m.x;
            n -= 1;
        }
    }
    return ans.x;
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

combination com(2000100);

mint g(int i, int j){

    return com(i+j+2, i+1) - 1;
}

int main()
{
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    r1--, c1--;    
    mint ans = g(r2, c2);
    ans -= g(r1, c2);
    ans -= g(r2, c1);
    ans += g(r1, c1);

    cout << ans.x << endl;
}



Measured memory_bytes: 31488
#include <stdio.h>

int main() {
	int N;
	double sum = 0;
	scanf("%d", &N);
	if (N > 1000000) {
		N = 1000000;
	}

	for (int i = 1;i <= N;i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			sum += i;
		}
	}
	printf("%.0lf", sum);

	return 0;
}

Measured memory_bytes: 1752
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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; }



int main(int argc, char const *argv[]) {
  ll n, q,sum=0;
  cin >> n;
  vector<ll> a(n);
  map<ll,ll>  mp;
  rep(i, n) {
    cin >> a[i];
    mp[a[i]]++;
    sum += a[i];
  }

  cin >> q;
  vector<ll> b(q),c(q);
  rep(i,q) cin >> b[i] >> c[i];

  rep(i,q){
    ll cnt=mp[b[i]];
    //printf("bf is %d\n" ,bf);
    //show(a);
    sum -= b[i] * cnt;
    sum += c[i] * cnt;
    mp[b[i]] = 0, mp[c[i]] += cnt;
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 11404
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
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;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

ll grundy[200][200];

ll dfs(ll w, ll b) {
    if(grundy[w][b] >= 0) return grundy[w][b];

    set<ll> se;
    if(w-1 >= 0) se.insert(dfs(w-1, b));
    if(b-1 >= 0) se.insert(dfs(w+1, b-1));
    for(ll i = 1; i <= b && i <= w; i++) se.insert(dfs(w, b-i));

    ll res = 0;
    while(se.count(res)) res++;
    return grundy[w][b] = res;
}

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

    ll n; cin >> n;

    rep(i, 200) rep(j, 200) grundy[i][j] = -1;
    grundy[0][0] = 0;

    ll g = 0;
    rep(i, n) {
        ll w, b;
        cin >> w >> b;
        g ^= dfs(w, b);
    }

    if(g == 0) cout << 1 << endl;
    else cout << 0 << endl;
}



Measured memory_bytes: 3496
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		
		while(scan.hasNext()){
			double v = scan.nextDouble();
			double t = v / 9.8;
			double y = 4.9 * t * t;
			int N =(int) Math.ceil((y + 5) / 5);
			System.out.printf("%d\n", N);
		}
	}
}

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

bool isprime(int n) {
  if (n <= 3) return true;
  else {
    bool ok = true;
    for (int i=2; i*i<=n; i++)
      if (n%i==0) ok = false;
    return ok;
  }
}

int main() {
  int x;
  cin >> x;
  
  int p = x;
  while (!isprime(p)) p++;
  
  cout << p << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
main(){
  int n;
  cin>>n;
  while(n--){
  string s;
  cin>>s;
  if(s[0]=='>'){
    if(s[1]=='\''){
      int sum=0;
      if(s.size()<6)goto L;
      r(i,s.size())if(s[i]=='=')sum++;
      if(s.size()%2==0&&s[s.size()/2]=='#'&&sum==s.size()-4&&s[s.size()-1]=='~')
        cout<<'A'<<endl;
      else goto L;
    }
    else if(s[1]=='^'){
      int c=2;
      if(s.size()%2||s.size()<6)goto L;
      while(c<s.size()-3){
        if(s[c]!='Q')goto L;
        c++;
        if(s[c]!='=')goto L;
        c++;
      }
      if(s[c]=='~'&&s[c+1]=='~')cout<<'B'<<endl;
      else goto L;
    }
    else goto L;
  }
  else goto L;
  if(0)L:cout<<"NA"<<endl;
  }
}

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

int selectionSort(int a[], int n)
{
	int cnt = 0;
	for(int i=0;i<n;++i)
	{
		bool flag = 0;
		int minIndex = i;
		for(int j=i;j<n;++j)
		{
			if(a[j]<a[minIndex])
			{
				minIndex = j;
				flag = 1;
			}
		}
		if(flag)
		{
			swap(a[i], a[minIndex]);
			cnt++;
		}
		
	}
	return cnt;
}
void solve()
{
	int a[105],n;
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> a[i];
	int ans = selectionSort(a, n);
	for (int i = 0; i < n - 1; ++i) printf("%d ", a[i]);
	printf("%d\n", a[n - 1]);
	printf("%d\n", ans);
	
}
int main()
{
	solve();
	return 0;
}

Measured memory_bytes: 3176
#include<bits/stdc++.h>
#define ll long long
#define fastio  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD=1000000007;
#define PI acos(-1)
using namespace std;
int main(){
	int a,b;
	cin >> a >> b ;
	if(a <= 2*b)
	cout << 0 << endl;
	else cout << a - 2*b << endl;
}


Measured memory_bytes: 3516
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
#define fi first
#define se second
#define sc scanf
#define pr printf
#define pb push_back
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
using namespace std;
ll exp(ll a , ll b){
	if(b == 0)	return 1;
	int x = b % 2 == 0 ?   ((exp(a , b/2)%mod)*(exp(a , b / 2)%mod))%mod :  (a%mod*exp(a , b - 1) % mod)%mod;
	return x;
}
int parent[100005], value[100005] , size[100005];
void init(){
	for(int i = 0 ; i <= 100004 ; i++)
	{	
		parent[i] = i;
		size[i] = 1;
	}
}
int whoispar(int x){
		if(parent[x] == x)
			return x;
		else{
			int fx = parent[x];
			parent[x] = whoispar(parent[x]);
			value[x] += value[fx];
			return parent[x];
		} 
		return parent[x];
}
// union by size
void uni(int x , int y , int z){
	int parX = whoispar(x);
	int parY = whoispar(y);
	if(parX != parY){
		value[parX] = z + value[y] - value[x];
		parent[parX] = parY;
	}
}
int main(int argc,char ** argv){
	dhoom;
	int n , q; 
	cin >> n >> q;
	init();
	for(int i = 0 ; i < q ; i++){
		int c , l , r , z;
		cin >> c ;
		if(c == 0){
			cin >> l >> r >> z;
			uni(l , r , z);
			
		}
		else
		{
			cin >> l >> r;
			if(whoispar(l) == whoispar(r))
				cout << value[l] - value[r]  << endl;
			else 
				cout << "?" << endl;
		}
	}
	return 0;
	
}



Measured memory_bytes: 5580
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < pll, int > a, pair < pll, int > b)//true for a before b
{
	ll val = a.F.F*b.F.S - a.F.S*b.F.F;
	if(val >= 0LL)
		return 1;
	return 0;
}

const int N = (3e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 8000;

int brr[N];
vi arr[N];

void solve()
{
	int n, a, b, c, m, x, i;
	cin >> n >> a >> b;
	if(a+b-1 > n)
	{
		cout << -1;
		return;
	}
	if(1LL*a*b < 1LL*n)
	{
		cout << -1;
		return;
	}
	m = n-b;
	fo(i,1,b+1)
		brr[i] = 1;
	fo(i,1,b+1)
	{
		x = min(m,a-1);
		brr[i] += x;
		m -= x;
	}
	c = 0;
	fo(i,1,b+1)
		while(brr[i]--)
			arr[i].pb(++c);
	for(i = b; i > 0; i--)
		for(auto x : arr[i])
			cout << x << " ";
	return;
}

int main()
{
	sws;
	// clock_t clk;
	// clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1;
	// cin >> t;
	while(t--)
		solve();
	// Code ends here

	// clk = clock() - clk;
	// cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 16640
from itertools import permutations

def power(base, exp):
  """ Fast power calculation using repeated squaring """
  if exp < 0:
      return 1 / power(base, -exp)
  ans = 1
  while exp:
      if exp & 1:
          ans *= base
      exp >>= 1
      base *= base
  return ans

def parse():
  return int(input())

def main():
  X = parse()

  A = None
  B = None

  # Z = [i for i in range(0, 5)]
  # print(Z)
  # print(list(permutations(range(0, 5), 2)))
  # print(list(permutations(range(0, 5), 2)))
  # exit(0)

  max_val = 1000
  signs = [[1, 1], [-1, 1], [1, -1], [-1, -1]]

  for i in range(0, max_val + 1):
    for j in range(0, max_val + 1):
      for sign in signs:
        # A5 = 
        # print(i * sign[0], j * sign[1])
        if power(i * sign[0], 5) - power(j * sign[1], 5) == X:
          A = i * sign[0]
          B = j * sign[1]
          print(A, B)
          exit(0)
  print(0, 0)

if __name__ == "__main__":
  main()

Measured memory_bytes: 9204
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int x = scanner.nextInt();
		int a[] = new int[n + 1];

		for (int i = 0; i < m; i++) {
			a[scanner.nextInt()] = 1;
		}

		int left = 0;
		for (int i = 0; i <= x; i++) {
			left += a[i];
		}

		int right = 0;
		for (int i = x; i <= n; i++) {
			right += a[i];
		}

		System.out.println(Math.min(left, right));
	}
}


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

int main(){
    int i;
    cin>>i;
    
    int a[i];
    int min;
    long long max,sum;
    int j;
    
    for(j=0;j<i;j++){
        scanf("%d",&(a[j]));
    }
    min=a[0];
    max=a[0];
    sum=a[0];
    for(j=1;j<i;j++){
        if(a[j]<min) min=a[j];
        if(a[j]>max) max=a[j];
        sum += a[j];
    }
    printf("%d %lld %lld\n",min,max,sum);
}

Measured memory_bytes: 3224
import sys
input = sys.stdin.readline

from collections import Counter

n = int(input())
a = [int(x) for x in input().split()]

c = Counter(a)
# print(c)
total = 0

for i in c.keys():
    # print(c[i])
    if c[i] - 1 > 0:
        total += int((1 / 2) * c[i] * (c[i] - 1))

# print(total)

for i in a:
    ans = total - int((1 / 2) * c[i] * (c[i] - 1))
    if c[i] - 2 > 0:
        ans += int((1 / 2) * (c[i] - 1) * (c[i] - 2))
    print(ans)

Measured memory_bytes: 84940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();

		int[] l =  new int[N];
		int[] r = new int[N];
		for (int i = 0; i < N; i++) {
			l[i] = scanner.nextInt();
			r[i] = scanner.nextInt();
		}

		/*
		for (int i : l) {
			System.out.println("l：" + i);
		}
		for (int i : r) {
			System.out.println("r：" + i);
		}
		*/

		int count = 0;
		for (int i = 0; i < N; i++) {
			count += r[i] - l[i] + 1;
		}
		System.out.println(count);

	}

}

Measured memory_bytes: 26736
n=int(input())
a=list(map(int,input().split()))
kind=[0]*(2*(10**5)+1) #0はダミー
kind2=[0]*(2*(10**5)+1) #0はダミー
for i in range(n):
    kind[a[i]]+=1
ans=0
for i in range(2*(10**5)+1):
    if kind[i]<=1:
        continue
    num=(kind[i]*(kind[i]-1))//2
    ans+=num
    kind2[i]=(kind[i]*(kind[i]-1))//2
    
for i in range(n):
    b=kind[a[i]]-1
    if b<=1:
        print(ans-kind2[a[i]])
        continue
    num=(b*(b-1))//2
    print(ans-kind2[a[i]]+num)

Measured memory_bytes: 87372