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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string s, t;
    cin >> t >> s >> t;
    cout << "A" << s[0] << "C" << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
typedef long long ll; 
#define pb push_back
#define mp make_pair
#define mod 998244353
#define vi vector <ll>
using namespace std ; 
ll power(ll x,ll y,ll m)
{            //power(x,y)=x^y  %m;
	ll res=1%m;
	while(y)
	{
	    if(y&1)
	    res=(res*x)%m;
	    x=(x*x)%m;
	    y=(y>>1)%m;
	}
	return res;
}
ll mod_inverse(ll x,ll m)
{
	return power(x,m-2,m);
}
int main ()
{
    ios_base :: sync_with_stdio ( false );
    cin.tie( NULL );
    cout.tie( NULL );

ll n,m,k;
cin>>n>>m>>k;
char a[n][m];
ll cnt=0;
for(ll i=0;i<n;i++)
{
    for(ll j=0;j<m;j++)
    {
    cin>>a[i][j];
    if(a[i][j]=='#')
    cnt++;
    }
}
ll ans=0;
ll vis[n][m];
for(ll i=0;i<(1ll<<n);i++)
{
    
    for(ll j=0;j<(1ll<<m);j++)
    {
        memset(vis,0,sizeof vis);
        bitset<32>b(i);
         bitset<32>b1(j);
         ll aa=0;
         for(ll kk=0;kk<32;kk++)
         {
             if(b[kk]==1)
             {
                 for(ll t=0;t<m;t++)
                 {
                     if(a[kk][t]=='#' && !vis[kk][t])
                     {
                     aa++;
                     vis[kk][t]=1;
                     }
                 }
             }
              if(b1[kk]==1)
             {
                 for(ll t=0;t<n;t++)
                 {
                     if(a[t][kk]=='#' && !vis[t][kk])
                     {
                     aa++;
                     vis[t][kk]=1;
                     }
                 }
             }
         }
         if(cnt-aa==k)
         ans++;
        
    }
}
  cout<<ans<<"\n";

 

 return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define N 100010
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define READ(f) freopen (f, "r", stdin)
#define WRITE(f) freopen (f, "w", stdout)
#define pp pop_back
#define mapiter map<int, int>::iterator
#define pii pair<int, int>
#define forn(i, n) for(int i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forr(i, x, n) for(int i = x; i <= n; ++i)
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define btw cout << "bad\n"
#define PI 3.141592653589793238462643383279502884L
#define lld long double

const int inf = 1e9 + 1;
const ll modw = 1e9 + 7;
  
using namespace std;
using namespace __gnu_pbds;

int main()
{
	lld a, b, h, m;
	cin >> a >> b  >> h >> m;
	cout << setprecision(15) << fixed;
	lld d = h * 30 + m * 0.5 - m * 6;
	cout << sqrtl(a * a + b * b - 2 * a * b * cos(d * PI / 180));
	return 0;
}









Measured memory_bytes: 4120
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(var,start,stop,step) for(long long var=start;var<stop;var+=step)
#define vi vector<int>
#define vl vector<long long>
#define fio  cin.tie(nullptr); ios::sync_with_stdio(false); cout.tie(nullptr);
 
int main()
{
    fio;
    char c;cin>>c;
    if(isupper(c))
        cout<<"A"<<endl;
        else
        {
            cout<<"a"<<endl;
        }
        
    return 0;
}

Measured memory_bytes: 3640
from collections import Counter
N = int(input())
An = list(map(int,input().split()))
c = 0
Bn = []
Cn = []
for k in range(N):    
    Bn.append(An[k]+k)
    Cn.append(k-An[k])
Cj = Counter(Cn)
for i in Bn:
    c+=Cj[i]
print(c)

Measured memory_bytes: 50604
N = int(input())
b = [int(i) for i in input().split()]
a = [b[0]]
for i in range(N-1):
    if i == N - 2 :
        a.append(b[i])
    else :
        if b[i] > b[i+1]:
            a.append(b[i+1])
        else :
            a.append(b[i])
print(sum(a))


Measured memory_bytes: 3060
N = int(input())
a = [0]
for x in input().split():
    a.append(int(x))
b = [0]*(N+1)
for i in range(1, N+1)[::-1]:
    if i > N//2:
        b[i] = a[i]
    else:
        b[i] = (a[i] + sum([b[j] for j in range(i, N+1, i)])) % 2

print(sum(b))
print(" ".join(map(str, [i for i in range(1, N+1) if b[i] == 1])))


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

int dp[100001];

int dfs(int curr, vector<int> nbs[]) {
	if(dp[curr] != -1) return dp[curr];
	int ans = 1;
	for(auto i: nbs[curr]) {
		ans = max(ans, 1 + dfs(i, nbs));
	}
	return dp[curr] = ans;
}

int main() {
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	vector<int> nbs[n + 1];
	for(int i = 0; i < m; ++i) {
		int u, v;
		cin >> u >> v;
		nbs[u].push_back(v);
	}
	int ans = 0;
	memset(dp, -1, sizeof dp);
	for(int i = 1; i <= n; ++i) {
		if(dp[i] == -1) {
			dfs(i, nbs);
		}
		// cout<<dp[i]<<" ";
		ans = max(ans, dp[i]);
	}
	cout<<ans - 1;
}

Measured memory_bytes: 11360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int maxn = 1e6 + 10;
int n;
ll tmp, ans; 
ll f[maxn], g[maxn];
void norm(ll & x) 
{ 
	while(x < 0) x += mod; 
	while(x >= mod) x -= mod;
}
int main()
{
	scanf("%d", &n);
	f[0] = f[1] = 1;
	g[0] = 1;
	g[1] = 2;
	for(int i = 2; i <= n; ++i)
	{
		f[i] = g[i - 1] - f[i - 2];
		g[i] = g[i - 1] + f[i];
		norm(f[i]);
		norm(g[i]);
	}
	for(int i = 0; i <= n; ++i)
	{
		ll tmp = 0;
		if(i <= n - 2)
			tmp = (tmp + 1ll * (n - 1) * (n - 1) % mod) % mod;
		if(i <= n - 1)
			tmp = (tmp + min(n - 1, i + 1)) % mod;
		if(i == n)
			tmp = 1;
		ans = (ans + tmp * f[i] % mod) % mod;
	}
	cout << ans << endl;
	return 0;
}
	

Measured memory_bytes: 15872
import sys

msg = sys.stdin.readlines()
lines = list()

for item in msg:
    if " " in item:
        s, t = item.split()
        lines.append(s)
        lines.append(t)
    else:
        item = item.replace('\n','')
        lines.append(item)

a = int(lines[2])
b = int(lines[3])

if lines[4] == lines[0]:
    a = a - 1
elif lines[4] == lines[1]:
    b = b - 1

print("{0} {1}".format(a, b))

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, ll> pcl;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    int K;
    string S;
    cin >> K;
    cin >> S;
    if(K < S.size()) {
        for(int i = 0; i < K; i++) {
            cout << S[i];
        }
        cout << "..." << endl;
    } else {
        cout << S << endl;
    }
    return 0;
}

Measured memory_bytes: 3580
def main():
    N = int(input())
    b_t = 0
    b_x = 0
    b_y = 0
    flg = True
    for _ in range(N):
        a_t, a_x, a_y = map(int, input().split())
        spend_time = a_t - b_t
        distance = abs(a_x - b_x) + abs(a_y - b_y)
        if spend_time >= distance and (distance - spend_time) % 2 == 0:
            continue
        else:
            flg = False
            break

    if flg:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


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

int main(){
  int N;cin >>N;
  vector<int> P(N);
  rep(i,N) cin>>P[i];
  vector<int> Pmin(N,1000000000);
  Pmin[0] = P[0];
  rep(i,N-1){
    Pmin[i+1]=min(Pmin[i],P[i+1]);
  }
  int ans = 0;
  rep(i,N) if(Pmin[i] >= P[i]) ans ++;
  cout << ans << endl;
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, k, n) for (int i = k; i < n; ++i)
#define fore(i,a) for (auto &i : a)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    int n = s.size();
    string pat1 = "", pat2 = "";
    rep(i, n) {
        if (i % 2) {
            pat1 += "1";
            pat2 += "0";
        } else {
            pat1 += "0";
            pat2 += "1";
        }
    }

    int diff1 = 0, diff2 = 0;
    rep(i, n) {
        if (s[i] != pat1[i]) ++diff1;
        if (s[i] != pat2[i]) ++diff2;
    }

    cout << min(diff1, diff2) << endl;

    return 0;
}

Measured memory_bytes: 720
#include<stdio.h>
#define MAX 100000
typedef struct{
  int p,r,l;
}Node;
Node T[MAX];
int a,d[MAX],h[MAX];

int sibling(int);
void depth(int,int);
int height(int);
void print(int);

int main(){
  int n,id,r,l,x=0;
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&l,&r);
    T[id].l=l;
    T[id].r=r;
    if(r!=-1) T[r].p=id;
    if(l!=-1) T[l].p=id;
  }
  for(i=0;i<n;i++){
    if(T[i].p==-1) x=i;
  }
  depth(x,0);
  height(x);
  for(i=0;i<n;i++){
    print(i);
  }
  return 0;
}

void depth(int a, int b){
  if(a==-1) return;
  d[a]=b;
  depth(T[a].l,b+1);
  depth(T[a].r,b+1);
}
int height(int a){
  int r=0,l=0;
  if(T[a].r!=-1) r=height(T[a].r)+1;
  if(T[a].l!=-1) l=height(T[a].l)+1;
  if(T[a].r==-1 && T[a].l==-1) return 0;
  if(l>r) return h[a]=l;
  else return h[a]=r;
}
int sibling(int a){
  if(T[a].p==-1) return -1;
  if(T[T[a].p].l!=a && T[T[a].p].l!=-1) return T[T[a].p].l;
  if(T[T[a].p].r!=a && T[T[a].p].r!=-1) return T[T[a].p].r;
  return -1;
}
void print(int a){
  int dg=0;
  printf("node %d: parent = %d,",a,T[a].p);
  printf(" sibling = %d,",sibling(a));
  if(T[a].l!=-1) dg++;
  if(T[a].r!=-1) dg++;
  printf(" degree = %d,",dg);
  printf(" depth = %d, height = %d, ",d[a],h[a]);
  if(T[a].p==-1) printf("root\n");
  else if(T[a].l==-1 && T[a].r==-1) printf("leaf\n");
  else printf("internal node\n");
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e10;
const ll MAX = 2001;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
typedef pair<ll,ll> P;
ll n,k;
int main() {
    cin >> n >> k;
    COMinit();
    ll ans;
    rep(i,k){
        ans = COM(n-k+1,i+1)*COM(k-1,i)%MOD;
        PRINT(ans);
    }
}

Measured memory_bytes: 256
from copy import *

N=int(input())
X=list(map(int,input().split()))
Y=deepcopy(X)
Y.sort()
mid1=Y[N//2-1]
mid2=Y[N//2]
for i in range(N):
  if X[i]<=mid1:
    print(mid2)
  else:
    print(mid1)


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

int main() {
  int n;
  cin>>n;
  vector<vector<P> > a(n+1);
  rep(i,0,n){
    int f,t,d;
    cin>>f>>t>>d;
    d=d%2;
    a[f].push_back(P(t,d));
    a[t].push_back(P(f,d));
  }
  int b[n+1];
  rep(i,1,n+1) b[i]=-1;
  b[1]=0;
  queue<int> q;
  q.push(1);
  while(q.size()){
    int p=q.front();
    q.pop();
    rep(i,0,a[p].size()){
      if(b[a[p][i].first]==-1){
        if(a[p][i].second==0) b[a[p][i].first]=b[p];
        else b[a[p][i].first]=1-b[p];
        q.push(a[p][i].first);
      }
    }
  }
  rep(i,1,n+1) cout<<b[i]<<endl;
}


Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
string divide[4]={"dream","dreamer","erase","eraser"};
int main(){
  string S;
  cin>>S;
  for(int i=0;i<4;i++) reverse(divide[i].begin(),divide[i].end());
  reverse(S.begin(),S.end());
  bool can=true;
  for(int i=0;i<S.size();){
    bool can2=false;
    for(int j=0;j<4;j++){
      string d=divide[j];
      if(S.substr(i,d.size())==d){
        can2=true;
        i+=d.size();
      }
    }
    if(!can2){
      can=false;
      break;
    }
  }
  if(can)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}



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

typedef long long ll;
const ll mod = 998244353;

ll modpow(ll a, ll b, ll p = 998244353){
    if(b == 0)  return 1;

    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

struct ModComb{
    vector<ll> po, inv;
    ll N;

    ModComb(ll n) : N(n), po(n), inv(n) {
        po[0] = 1;
        for(int i = 1; i < N; i++)  po[i] = (po[i-1] * i) % mod;
        inv[N-1] = modpow(po[N-1], mod-2, mod);
        for(int i = N-2; i >= 0; i--)   inv[i] = (inv[i+1] * (i+1)) % mod;
    }
    
    ll nCk(ll n, ll k){
        if(k == 0)  return 1;
        if(n < k)   return 0;
        return (((po[n]*inv[n-k])%mod)*inv[k])%mod;
    }

    ll nPk(ll n, ll k){
        if(k == 0)  return 1;
        if(n < k)   return 0;
        return (po[n]*inv[n-k])%mod;
    }

    ll nHk(ll n, ll k){
        if(n == 0 && k == 0)    return 1;
        return nCk(n+k-1, k-1);
    }
};

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    ll ret = 0;
    ModComb mc(n);
    for(int i = 0; i <= k; i++){
        (ret += mc.nCk(n-1, i)*m%mod*modpow(m-1,n-i-1,mod)%mod) %= mod;
    }
    cout << ret << endl;
    return 0;
}

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

int main() {
	int n;
	cin>>n;
	int arr[n];
	int xo=0;
	for(int i=0; i<n; i++){
		cin>>arr[i];
		xo=xo^arr[i];
	}
	for(int i=0; i<n; i++){
		cout<<(xo^arr[i])<<" ";
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long tmp = a[i];
    while (true) {
      if (tmp%2 == 1) {
        break;
      }
      tmp /= 2;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <complex>
#include <iomanip>
#include <cassert>
 
using namespace std;
 
typedef long long ll;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif  
  int n, k, s;
  cin >> n >> k >> s;
  vector <int> a(n);
  for (int i = 0; i < k; ++i) a[i] = s;
  for (int i = k; i < n; ++i) a[i] = (s == 1 ? s + 1 : s - 1);
  for (int i = 0; i < n; ++i) cout << a[i] << ' ';
}


Measured memory_bytes: 1792
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

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

def gcd2(a_list):
    if len(a_list)==2:
        return gcd(a_list[0],a_list[1])
    elif len(a_list)==1:
        return a_list[0]
    else:
        return gcd(gcd2(a_list[:len(a_list)//2]),gcd2(a_list[len(a_list)//2:]))

print(gcd2(A))

Measured memory_bytes: 14224
using namespace std;
#include <bits/stdc++.h>
 
int main()
{
  long long int n,k;
  cin>>n>>k;
  long long int h[n];
  long long int sum=0;
  for(int i=0;i<n;i++)
  {
    cin>>h[i];
  }
  sort(h,h+n);
  if(k>=n)
  {
    cout<<"0";
  }
  else
  {
   for(int i=0;i<n-k;i++)
   {
     sum=sum+h[i];
   }
    cout<<sum;
  }
  
  return 0;
}

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

int main(int argc, char** argv) {
	int r, g, b, n;
	int count = 0;
	cin >> r >> g >> b >> n;

	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= n; ++j) {
			int x = (n - (i * r + j * g))/b;
			if (x >= 0 && (i*r + j*g + x*b) == n) {
				++count;
			}
		}
	}
	
	cout << count << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt(),b=s.nextInt();
        if(a>=13) System.out.println(b);
        else if(a>=6&&a<=12) System.out.println(b/2);
        else System.out.println(0);
    }




}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25364
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<ll> A(N);
    vector<bool> IsPrime(1000002,true);
    rep(i,N) cin>>A[i];
    ll cnt = 0;
    sort(all(A));
    map<ll,ll> m;
    ll ans = 0;
    rep(i,N){
       

    
        if(IsPrime[A[i]]){
            for(size_t j=2; A[i]*j<=1000002; ++j) // (max以下の)iの倍数は
                IsPrime[A[i]*j] = false;
        } 
            
            
        
        
        if(m[A[i]] == 0){
            if(IsPrime[A[i]] == 1){
                ans++;
                m[A[i]] = 1;
            }
        }else if(m[A[i]] == 1){
    
                ans--;
                m[A[i]] = 2;
    
        }
        IsPrime[A[i]] = false;
 
        
    }


    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 17456
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main() {
	int N;
	cin >> N;
	int flag = 0;
	map<string, int> ma;
	string pre;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		if (i != 0) {
			if (pre.at((int)pre.size() - 1) != s.at(0)) {
				flag = 1;
			}
			if (ma[s] != 0) {
				flag = 1;
			}
		}
		ma[s]++;
		pre = s;
	}

	if (flag == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

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

#define mod 1000000007
#define MAX 100005
using namespace std; 

int findb(int b[],int i,int r){

	int ret=upper_bound(b,b+r,i)-b;
	if(ret==r)return -1;
	else return b[ret];

}  

int c2(int k){
	return(k*(k-1)/2);
}

int main(){

	int n,k;cin>>n>>k;
	int a;
	int count=0;
	for(int i=0;i<n;i++){cin>>a;if(a>=k)count++;}
		cout<<count;
}



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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

class UnionFind{
public:
	vector<ll> par;
	vector<ll> num;

	UnionFind(ll N):par(N),num(N){
		for(ll i=0;i<N;i++){
			par[i]=i;
			num[i]=1;
		}
	}

	ll root(ll x){
		if(par[x]==x){
			return x;
		}
		return par[x]=root(par[x]);
	}

	void unite(ll x,ll y){
		ll rx = root(x);
		ll ry = root(y);
		if (rx == ry) return;
		par[rx] = ry;
		num[ry] += num[rx];
	}

	bool same(ll x,ll y){
		ll rx = root(x);
		ll ry = root(y);
		return rx == ry;
	}

	ll getsize(ll x){
		return num[root(x)];
	}
};

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

	int N=in(),M=in();
	vector<int> P(N);
	REP(i,N){
		P[i] = in()-1;
	}
	UnionFind tree(N);
	REP(i,M){
		int l=in()-1,r=in()-1;
		tree.unite(l,r);
	}
	int num = 0;
	REP(i,N){
		if(tree.same(i,P[i])) num++;
	}
	
	cout << num << endl;
	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}


int main()
{
    fastio
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(a*c, max(max(b*d,a*d),b*c));
}


Measured memory_bytes: 3648
n, a, b = map(int, input().split())

def check_a_b(n, a, b):
    sum = 0
    while n > 0:
        if sum + n%10 <= b:
            sum += n%10
            n //= 10
        else:
            return False
    if sum >= a:
        return True
    else:
        return False

ans = 0
for i in range(n+1):
    if check_a_b(i, a, b):
        ans += i
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<string.h>
#include<algorithm>
using namespace std;
char ch[10001];
int main(void)
{
	scanf("%s",ch);
	bool f = true;
	for(int i = 0;i<strlen(ch);i++)
	{
		if(ch[i] == ch[i+1])
		{
			f = false;
			break;
		}
	}
	if(f) puts("Good");
	else puts("Bad");
	return 0;
} 

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, l;
    cin >> n >> l;
    string v[n];
    for( int i = 0; i < n; i++ ) {
        cin >> v[i];
    }
    sort( v, v+n );
    for( int i = 0; i < n; i++ ) {
        cout << v[i];
    }
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <functional>
#include <string>
#include <math.h>

using namespace::std;

int main()
{
    int n,a,b;

    cin >> n >> a >> b;

    int maxx = min(a,b);
    int minx = max(0, a + b - n);

    cout << maxx << " " << minx << endl;
    return 0;
}

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

count = 0

equal = 0
minus = 1
plus = 2

status = equal

for i in range(n - 1):
    if status == equal:
        if a[i] < a[i+1]:
            status = plus
        elif a[i] > a[i+1]:
            status = minus 
    elif status == plus:
        if a[i] > a[i+1]:
            status = equal
            count += 1
    elif status == minus:
        if a[i] < a[i+1]:
            status = equal
            count +=1
print(count+1)


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

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

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

    return 0;
}

Measured memory_bytes: 256
local n = io.read("*n")
local c = 1
local state = 0
local prv = io.read("*n")
for i = 2, n do
  local nxt = io.read("*n")
  if prv < nxt then
    if state == 0 then
      state = 1
    elseif state < 0 then
      c = c + 1
      state = 0
    end
  elseif nxt < prv then
    if state == 0 then
      state = -1
    elseif 0 < state then
      c = c + 1
      state = 0
    end
  end
  prv = nxt
end
print(c)

Measured memory_bytes: 2724
#include<stdio.h>
#include<bits/stdc++.h>
#define MAX 10000
#define NIL -1
using namespace std;
struct Node
{
	int p , l , r;
};
struct Node T[MAX];
int n;

void preParse(int u)
{
	if(u == NIL)
	  return;
	printf(" %d",u);
	preParse(T[u].l);
	preParse(T[u].r);
}

void inParse(int u)
{
	if(u == NIL)
	   return;
	inParse(T[u].l);
	printf(" %d",u);
	inParse(T[u].r);
}
void postParse(int u)
{
	if(u == NIL)
	  return;
	postParse(T[u].l);
	postParse(T[u].r);
	printf(" %d",u);
}
int main()
{
	int i , v , l , r , root;
	cin >> n;
	for(i = 0 ; i < n ; i++)
	{
		T[i].p = NIL;
	}
	for(i = 0 ; i < n ; i++)
	{
		cin >> v >> l >> r;
		T[v].l = l;
		T[v].r = r;
		if(l != NIL)
		   T[l].p = v;
		if(r != NIL)
		   T[r].p = v;
	}
	for(i = 0 ; i < n ; i++)
	{
		if(T[i].p == NIL)
		   root = i;
	}
	cout << "Preorder" << endl;
	preParse(root);
	cout << endl;
	cout << "Inorder" << endl;
	inParse(root);
	cout << endl;
	cout << "Postorder" << endl;
	postParse(root);
	cout << endl;
	return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int A, B;
  cin >> A >> B;
  cout << (A ^ B) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;
const int MOD = 1'000'000'007;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

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

// const int MAX = 1010;

int main()
{
    string s;
    cin >> s;
    set<char> cs;
    for (char c : s)
    {
        cs.insert(c);
    }
    if (cs.size() == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    int mini = 100;
    for (char c : cs)
    {
        string now = s;
        int n = now.size();
        while (n != 0)
        {
            string next(n - 1, '.');
            --n;
            for (int i = 0; i < n; i++)
            {
                if (now[i] == c || now[i + 1] == c)
                {
                    next[i] = c;
                }
            }
            bool flag = true;
            for (int i = 0; i < n - 1; i++)
            {
                if (next[i] != next[i + 1])
                {
                    flag = false;
                }
            }
            if (flag)
            {
                mini = min(mini, (int)s.size() - n);
                break;
            }
            now = next;
        }
    }
    cout << mini << endl;
    return 0;
}

Measured memory_bytes: 3556
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	k := nextInt()

	box := make(map[int]int, n)

	for i := 0; i < k; i++ {
		d := nextInt()
		for j := 0; j < d; j++ {
			a := nextInt()
			box[a]++
		}
	}
	fmt.Print(n - len(box))
}


Measured memory_bytes: 1780
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(ll i = 0; i < (ll)n; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ll n; cin >> n;
  vector<ll> v(n);
  rep(i, n) cin >> v.at(i);
  
  sort(v.rbegin(), v.rend());
  
  ll a=0; ll b=0;
  
  rep(i, n){
    if(i%2 == 0)
      a += v.at(i);
    else
      b += v.at(i);
  }
  cout << a-b << endl;
}


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

typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<ll> Ai(N);
    int minus = 0;
    for (int i=0;i<N;i++){
        cin >> Ai[i];
        if (Ai[i] < 0) {
            minus++;
            Ai[i] = - Ai[i];
        }
    }
    // マイナスが奇数個のときはマイナスが１か所残る
    // マイナスが偶数個のときはマイナスを全部消せる
    sort(Ai.begin(),Ai.end());
    ll ans = 0;
    for (int i=0;i<N;i++){
        ans += Ai[i];
    }
    if (minus % 2 == 1){
        ans -= Ai[0]*2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(void){
    Cin(string, s);
    s[3] = '8';
    Cout(s);
}

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
const int MOD = 1e9 + 7;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main() {
    int n; cin >> n;
    vector<int> t(n);
    int normal = 0;
    rep(i,n){
        cin >> t[i];
        normal += t[i];
    }
    int m; cin >> m;
    rep(i,m){
        int p, x;
        cin >> p >> x;
        cout << normal - t[p-1] + x << endl;
    }
}

Measured memory_bytes: 256
S=input()
n=len(S)
A='01'*(n//2)+'0'*(n%2)
B='10'*(n//2)+'1'*(n%2)
a=0
b=0
for i in range(n):
    if S[i]!=A[i]: a+=1
    if S[i]!=B[i]: b+=1
print(min(a,b))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
ll judge(ll x, vector<ll> w){ //x以下
    ll n=w.size();
    ll res=1, tmp=0;
    rep(i,n){
        if(tmp+w[i]<=x) tmp+=w[i];
        else if(w[i]>x) return -1;
        else{
            res++; tmp=w[i];
        }
    }
    return res; //必要なトラックの数
}

int main(){
    ll n,k; cin>>n>>k;
    vector<ll> w(n);
    rep(i,n) cin>>w[i];
    ll left=0, right=1e11;
    while(right-left>1){
        ll mid=(right+left)/2;
        ll x=judge(mid,w);
        if(x==-1 || x>k) left=mid;
        else right=mid;
    }
    cout<<right<<endl;
    return 0;
}


Measured memory_bytes: 4536
/*************************
author : coldbeer
2019-06-01 7:32:28 pm IST
*************************/
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
    string s; cin >> s;
    int cnt = 0;
    int k = 15 - s.length();
    cnt += k;
    for(auto x : s) cnt += (x == 'o');
    cout << (cnt >= 8 ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.next();
		String s = sc.next();

		for (char c = 'a'; c <= 'z'; c++)
			s = s.replaceAll(c + "+", c + "");
		System.out.println(s.length());
	}
}


Measured memory_bytes: 43832
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int N=0,S=0,E=0,W=0;
  string s;
  cin >> s;
  for(int i=0; i<s.size(); i++) {
    if(s[i]=='N') {
      N=1;
    }
    else if(s[i]=='S') {
      S=1;
    }
    else if(s[i]=='E') {
      E=1;
    }
    else {
      W=1;
    }
  }
  if(N==S&&E==W) {
    cout << "Yes" << endl;
  }
  else {
    cout <<"No" << endl;
  }
}


Measured memory_bytes: 256
a,b,k = map(int, input().split())

if b-a+1 > 2*k:
    res_list = [i for i in range(a, a+k)] + [i for i in range(b-k+1, b+1)]
else:
    res_list = [i for i in range(a, b+1)]

for i in res_list:
    print(i)

Measured memory_bytes: 3060
#include <bits/stdc++.h> // only for GCC
using namespace std;

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

template<class T> inline T sqr(T x) {return x*x;}

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;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#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 FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main() {
  int n;

  while(cin >> n, n) {
    VI s;  
    REP(i, n) {
      int x;
      cin >> x;
      s.PB(x);
    }

    sort(ALL(s));
    int sum = 0;
    FOR(i, 1, n-1) sum += s[i];
    int ans = sum / (n-2);
    cout << ans << endl;
  }
  
}

Measured memory_bytes: 1220
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int h,w;

bool dfs(int x, int y, VS a){
    a[x][y] = '.';

    if(x==h-1 && y==w-1){
        REP(i,h){
            REP(j,w){
                if(a[i][j] == '#'){
                    return false;
                }
            }
        }
        return true;
    }

    bool f = false;
    VI dx = {1,0};
    VI dy = {0,1};
    REP(i,2){
        int nx = x+dx[i];
        int ny = y+dy[i];
        if(nx>=h || ny>=w){
            continue;
        }
        if(a[nx][ny] != '#'){
            continue;
        }

        if(dfs(nx,ny,a)){
            f = true;
        }

    }
    return f;
}


void Main()
{
    cin>>h>>w;
    VS a(h);
    REP(i,h){
        cin>>a[i];
    }

    if(dfs(0,0,a)){
        cout<<"Possible"<<endl;
    }
    else{
        cout<<"Impossible"<<endl;
    }


    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 3600
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int p=sc.nextInt();
		int q=sc.nextInt();
		int r=sc.nextInt();
		int min=p+q;
		if(min>q+r)
			min=q+r;
		if(min>p+r)
			min=p+r;
		System.out.println(min);
	}
		
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int64 r,d,x;
    cin >> r >> d >> x;
    REP(i,10){
        x = r * x - d;
        ANS(x);
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

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

	int N, T;
	cin >> N >> T;

	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	
	vector<int> cumax(N);
	cumax[N - 1] = A[N - 1];
	for (int i = N - 1; i > 0; i--) cumax[i - 1] = max(cumax[i], A[i - 1]);

	map<int, int> profit;
	for (int i = 0; i < N; i++) profit[cumax[i] - A[i]]++;

	cout << (*profit.rbegin()).second;
	return 0;
}

Measured memory_bytes: 5760
def main():
    N, M = map(int, input().split())
    E = [[] for _ in range(N + 1)]
    D = [0] * (N + 1)
    for _ in range(M):
        x, y = map(int, input().split())
        E[x].append(y)
        # Keeps number of input destinations for each output distination.
        D[y] += 1

    # topological sort
    Q = [i for i in range(1, N + 1) if D[i] == 0]
    L = []
    while Q:
        s = Q.pop()
        L.append(s)
        for r in E[s]:
            D[r] -= 1
            if D[r] == 0:
                Q.append(r)

    dp = [0] * (N + 1)
    for v in L:
        for k in E[v]:
            dp[k] = max(dp[k], dp[v] + 1)
    print(max(dp))


main()


Measured memory_bytes: 65824
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>

int main(void) {
	int n, k;
	int ans = 0;

	scanf("%d %d", &n, &k);
	for (int i = 0; n > 0; i++) {
		n /= k;
		ans++;
	}
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
struct drink
{
  long long cost, quant;
};
 
bool cmp(drink x, drink y)
{
  return x.cost<y.cost;
}
 
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m; cin >> n >> m; 
  drink a[n+1];
  for (int i=1; i<=n; i++) cin >> a[i].cost >> a[i].quant;
  sort(a+1,a+n+1,cmp);
  long long res = 0;
  for (int i=1; i<=n; i++)
  {
    if (m>=a[i].quant)
    {
      res += a[i].cost * a[i].quant;
      m -= a[i].quant;
    }
    else if (m<a[i].quant)
    {
      res += a[i].cost * m;
      break;
    }
    if (m==0) break;
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
double dp[3005][3005];

double F(double arr[],int i,int j)
{
	if(dp[i][j]!=2)
		return dp[i][j];
	if(i==0 and j==0)
	{
		dp[i][j]=1;
		return dp[i][j];
	}
	if(i==0)
	{
		dp[i][j]=0;
		return dp[i][j];
	}
	if(j==0)
	{
		dp[i][j]=1;
		for(int k=0;k<i;k++)
			dp[i][j]*=(1-arr[k]);
		return dp[i][j];
	}
	if(i<j)
	{
		dp[i][j]=0;
		return dp[i][j];
	}

	if(i==j)
	{
		dp[i][j]=1;
		for(int k=0;k<i;k++)
			dp[i][j]*=arr[k];
		return dp[i][j];
	}

	dp[i][j] = arr[i-1]*F(arr,i-1,j-1) + (1-arr[i-1])*F(arr,i-1,j);

	return dp[i][j];
}

int main()
{
    int n,k;
    cin>>n;
    for(int i=0;i<3005;i++)
    	for(int j=0;j<3005;j++)
    		dp[i][j]=double(2);
    double arr[n];
    for(int i=0;i<n;i++)
    	cin>>arr[i];
    double ans = 0;
    for(int i=(n/2)+1;i<=n;i++)
    	ans+=F(arr,n,i);
    cout<<setprecision(9)<<ans<<endl;
    
}



Measured memory_bytes: 71040
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;
int main(){
    int n;
    while(true){
        int count = 0,S[1000]={};
        double m,sigma=0,a;
        cin >> n;
        if(n==0) break;
        for(int i=0;i<n;i++){
            cin >> S[i];
            count +=S[i];
        }
        m=1.0*count/n;
        for(int i=0;i<n;i++){
            sigma+=(S[i]-m)*(S[i]-m);
        }
        a = sqrt(sigma/n);
        printf("%f\n",a);
    }return 0;
}


Measured memory_bytes: 3208
n=int(input())

def dfs(num):
    if int(num)>n:
        return 0
    else:
        if num.count("3")>=1 and num.count("5")>=1 and num.count("7")>=1:
            ans=1
        else:
            ans=0
        
        for i in "753":
            ans=ans+dfs(num+i)
        return ans
        

print(dfs("0"))


Measured memory_bytes: 2940