akhauriyash/Code-Regression huggingface dataset:
n,k = map(int, input().split())
a = list(map(int, input().split()))

mod=10**9+7
a.sort()

if n==k:
    ans=1
    for num in a:
        ans*=num
        ans%=mod
    print(ans)
    exit()

if a[-1]<0: # all a is minus
    if k%2==1: # ans is minus
        a.sort(reverse=True)
        ans=1
        for num in a[:k]:
            ans*=num
            ans%=mod
        print(ans)
        exit()

# ans>=0

ans=1
if k%2==1:
    ans=a[-1]
    a.pop(-1)
    k-=1

pz_a=[]
m_a=[]

for num in a:
    if num<0:
        m_a.append(num)
    else:
        pz_a.append(num)
pz_a.sort(reverse=True)

c2_a=[]
lastnum=-1
for i in range(len(pz_a)):
    num1=pz_a[i]
    if lastnum==-1:
        lastnum=num1
    else:
        c2_a.append(lastnum*num1)
        lastnum=-1

lastnum=1
for i in range(len(m_a)):
    num1=m_a[i]
    if lastnum==1:
        lastnum=num1
    else:
        c2_a.append(lastnum*num1)
        lastnum=1

c2_a.sort(reverse=True)

for num in c2_a[:k//2]:
    ans*=num
    ans%=mod

print(ans)


Measured memory_bytes: 114096
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  string s;
  cin >> s;
  int n = s.size();
  for(int i = 0;i < n;i++)cout << 'x' << flush;
  cout << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int main() {
  ios::sync_with_stdio(false);
  string a;
  cin>>a;
  for(auto k:a){
    cout<<'x';
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,p; cin >> n >> p;
	string s; cin >> s;
	ll ans=0;
	ll now=0;
	ll digit=1;
	if(p==2){
		for(int i=0;i<n;i++){
			if((s[i]-'0')%2==0){
				ans+=i+1;
			}
		}
		cout << ans << endl;
		return 0;
	}else if(p==5){
		for(int i=0;i<n;i++){
			if((s[i]-'0')%5==0){
				ans+=(i+1);
			}
		}
		cout << ans << endl;
		return 0;
	}
	map<ll,ll> mp;
	mp[0]++;
	for(int i=n-1;i>=0;i--){
		now+=digit*(s[i]-'0');
		now%=p;
		ans+=mp[now];
		mp[now]++;
		(digit*=10)%=p;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<double> A(N);
  rep(i,N) cin >> A[i];
  double ans=0;
  rep(i,N){
    ans += 1.0/A[i];
  }
  ans = 1.0/ans;
  cout << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    long long n,nc;
    long long sum=0;
    scanf("%lld",&n);
    nc=n;

    while(n>0){
        sum+=n%10;
        n/=10;
    }

    if(nc%sum==0){
        puts("Yes");
    }else{
        puts("No");
    }

    return 0;
}

Measured memory_bytes: 128
N=int(input())
if N>81:
    print("No")
else:
    p_list=[9,8,7,6,5,4,3,2,1]
    for p in p_list:
        d,m=divmod(N,p)
        if d<10 and m==0:
            print("Yes")
            break
    else:print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	int ans=0;
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++){
		ans+=int(s[i]-48);
		ans%=9;
	}
	if(ans)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
} 

Measured memory_bytes: 3728
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
for i in range(n):
    b = int(input())
    for x in range(3):
        for y in range(3):
            if a[x][y] == b:
                a[x][y] = 'o'
for x in range(3):
    if a[x][0] == a[x][1] == a[x][2] == 'o':
        print('Yes')
        exit(0)
for y in range(3):
    if a[0][y] == a[1][y] == a[2][y] == 'o':
        print('Yes')
        exit(0)
if a[0][0] == a[1][1] == a[2][2] == 'o':
    print('Yes')
elif a[0][2] == a[1][1] == a[2][0] == 'o':
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9096
#include <stdio.h>
#include <string.h>

int main(){
  int n, i, j, a, b;
  char in[512], dec[512];

  fgets(in, sizeof(in), stdin);
  n = atoi(in);
  for(i = 0;i < n;i++){
    fgets(in, sizeof(in), stdin);
    for(a = 3;a < 52;a += 2){
      if(a == 13) continue;
      for(b = 0;b < 26;b++){
	for(j = 0;j <= strlen(in);j++){
	  if(in[j] >= 'a' && in[j] <= 'z')
	    dec[j] = (((in[j] - 'a') * a + b) % 26) + 'a';
	  else 
	    dec[j] = in[j];
	}
	if(strstr(dec, "this") != NULL || strstr(dec, "that") != NULL) goto end;
      }
    }
  end:;
    printf("%s", dec);
  }
  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  ll t=1,a=1;
  cin>>n;
  rep(i,n)
  {
    ll p,q;
    cin>>p>>q;
    ll tp=max((t-1)/p+1,(a-1)/q+1);

    t=tp*p;
    a=tp*q;
  }
  cout<<t+a<<endl;
  return 0;

}


Measured memory_bytes: 764
#include<stdio.h>

void insertionsort(int *A,int n){
		int i,j,k,v;
		
		for(i=1;i<n;i++){

			for(k=0;k<n-1;k++){
			printf("%d ",A[k]);
			}
			
			printf("%d\n",A[n-1]);
			v = A[i];
			j = i-1;
			while(j>=0&&A[j]>v){
				A[j+1]=A[j];
				j--;
				A[j+1]=v;
				
			}
			
		}
		
			for(k=0;k<n-1;k++){
			printf("%d ",A[k]);
			}
			printf("%d\n",A[n-1]);
}
	
	





int main(){
  int n,i,A[1000];
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  insertionsort(A,n);

  return 0;
}

Measured memory_bytes: 1776
#include<stdio.h>

int main(void){

  int N;
  scanf("%d",&N);
  int p[10] = {0};
  int max = 0;
  int max_num;

  for(int i = 0 ; i < N ; i++){
    scanf("%d", &p[i]);

    if(max < p[i]){       //最大値と場所保存
      max = p[i];
      max_num = i;
     }
    
  }

  p[max_num] /= 2;        //半額にする


  int sum = 0;
  for(int i = 0 ; i < N ; i++){
    sum += p[i];
  }

  printf("%d",sum);
  

  return 0;
}

Measured memory_bytes: 128
def pre_cmb(N, MOD):
    FACT = [1, 1]  # 階乗
    INV = [0, 1]  # 各iの逆元
    FACTINV = [1, 1]  # 階乗の逆元

    for i in range(2, N + 1):
        FACT.append((FACT[-1] * i) % MOD)
        INV.append(pow(i,MOD-2,MOD))
        FACTINV.append((FACTINV[-1] * INV[-1]) % MOD)
    PRELIST = FACT, FACTINV
    return PRELIST


def cmb(N, R, MOD, PRELIST):
    FACT, FACTINV = PRELIST
    if (R < 0) or (N < R):
        return 0
    R = min(R, N - R)
    return FACT[N] * FACTINV[R] * FACTINV[N-R] % MOD


n, m, k = map(int, input().split())
mod = 998244353

prelist = pre_cmb(n, mod)

cnt = 0
for i in range(k + 1):
    cnt += (m * pow(m - 1, n - i - 1, mod) * cmb(n - 1, i, mod, prelist)) % mod

print(cnt % mod)


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

int main(){
	int n, ans;
	long long int root[40] = {}, day[31] = {};
	root[0] = 1;
	root[1] = 1;
	root[2] = 2;
	for(int i = 3;i<40;i++){
		root[i] = root[i - 1] + root[i - 2] + root[i - 3];
	}
	for(int i = 0;i<40;i++){
		day[i] = root[i] / 10;
		if(root[i] % 10 > 0){
			day[i]++;
		}
	}
	while(cin >> n){
		if (n == 0) break;
		ans = 0;
		if (day[n] > 0) ans++;
		ans += day[n] / 365;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
bool isok(vector<int> &v, int mini, int k)
{
    int cnt = 0;
    for (auto i : v)
    {
        if (i > mini)
        {
            if (i % mini == 0)
                cnt += (i / mini)-1;
            else
                cnt += ((i + mini) / mini)-1;
        }
    }

    if (cnt <= k)
    {
        return true;
    }
    else
    {
        return false;
    }
}
int main()
{
    int n, k;
    cin >> n >> k;

    vector<int> v(n);

    for (auto &i : v)
    {
        cin >> i;
    }

    int mini = 1, maxi = 1e9 + 100;

    while (mini < maxi)
    {
        int mid = mini + (maxi - mini) / 2;
        if (isok(v, mid, k))
        {
            maxi = mid;
        }
        else
        {
            mini = mid + 1;
        }
    }

    cout << mini << endl;
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
using ll        = long long;
using ld        = long double;
using vl        = vector<ll>;
using vd        = vector<ld>;
using vs        = vector<string>;
using vb        = vector<bool>;
using vvl       = vector<vector<ll>>;
using vvd       = vector<vector<ld>>;
using vvs       = vector<vector<string>>;
using vvb       = vector<vector<bool>>;
using pll       = pair<ll, ll>;
constexpr ll mod= 1e9 + 7;
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for(ll(i)= 0; (i) < (n); (i)++)
#define REPS(i, n) for(ll(i)= 1; (i) <= (n); (i)++)
#define RREP(i, n) for(ll(i)= (n - 1); (i) >= 0; (i)--)
#define RREPS(i, n) for(ll(i)= (n); (i) > 0; (i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define YES(n) ((n) ? "YES" : "NO")
#define Yes(n) ((n) ? "Yes" : "No")
#define yes(n) ((n) ? "yes" : "no")

template <class T>
inline void chmin(T& a, T b) {
    if(a > b) { a= b; }
}

template <class T>
inline void chmax(T& a, T b) {
    if(a < b) { a= b; }
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    ll A,B;
    cin >> A >> B;
    A--;
    ll Ax = 0,Bx = 0;
    if(A % 4 == 0){
        Ax = A;
    }else if(A % 4 == 1){
        Ax = 1;
    }else if(A %4 == 2){
        Ax = A  + 1;
    }else{
        Ax = 0;
    }
    if(B % 4 == 0){
        Bx = B;
    }else if(B % 4 == 1){
        Bx = 1;
    }else if(B %4 == 2){
        Bx = B  + 1;
    }else{
        Bx = 0;
    }
    cout << (Ax ^ Bx) << "\n";
}

Measured memory_bytes: 3656
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main()
{
	double a, q;
	cout<<setprecision(6);
	cout<<setiosflags(ios::fixed);
	while (cin>>q, q!=-1) {
		a = q/2.0;
		while ( abs(a*a*a-q) >= 0.00001*q ) a -= (a*a*a-q) / (3.0*a*a);
		cout<<a<<endl;
	}
	return 0;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll a, b, c, x;
  cin >> a >> b >> c >> x;
  ll ans = 0;
  rep(i, a+1){
    rep(j, b+1){
      rep(k, c+1){
        if(500*i + 100 * j + 50 * k == x)ans++;
      }
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3604
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

/*-----<Defines>-----*/
#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)-1)/(x)+1)
#define     flush           fflush(stdout)

using ull=unsigned long long;
using ll=long long;
using ld=long double;
/*-----</Defines>-----*/

/*-----<Debugging Stuff>-----*/
string to_string(char s)
{   string res="'''";res[1]=s;return res; }

string to_string(string s)
{   return '"'+s+'"'; }

string to_string(const char* s)
{   return to_string((string)s); }

string to_string(bool b)
{   return (b?"true":"false"); }

template<typename A, typename B>
string to_string(pair<A, B> p)
{   return "("+to_string(p.F)+", "+to_string(p.S)+")"; }

template<typename A>
string to_string(A v)
{
    bool first=1; string res="{";
    for(const auto &x:v)
    {
        if(!first)  res+=", ";
        first=0;
        res+=to_string(x);
    }
    res+="}";
    return res;
}

void debug() { cout<<"\n"; }
template<typename Head, typename... Tail>
void debug(Head H, Tail... T)
{
    cout<<" "<<to_string(H);
    debug(T...);
}

#define show(...) cout << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
/*-----</Debugging Stuff>-----*/

/*-----<Mod Operations>-----*/
const int M=1e9+7;
inline int add(int a,int b,int p=M){ a=a+b; if(a>=p) a-=p; return a; }
inline int sub(int a,int b,int p=M){ a=a-b; if(a<0) a+=p; return a; }
inline int mul(int a,int b,int p=M){ a=(a*1ll*b)%p; return a; }
/*-----</Mod Operations>-----*/

/*-----<Constants>-----*/
const ld pi=acos(-1),eps=1e-9;
const ll inf=1e18;
const int N=1;
/*-----</Constants>-----*/

void solve()
{
    int n;
    cin>>n;

    vi v(n);
    for(auto &c:v)
        cin>>c;

    int xr=0;
    for(int i=0;i<n;++i)
        xr^=v[i];

    for(int i=0;i<n;++i)
        cout<<(v[i]^xr)<<" ";
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 4668
#include <iostream>
#include <vector>
using namespace std;
template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a(x%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend ostream& operator<<(ostream &os, const modint &X){
    return os << X.a;
  }
  friend istream& operator>>(istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};

using mint = modint<(long long)(1e9+7)>;
int main(){
  string L;
  cin >> L;
  vector<vector<mint>> dp(L.length()+1,vector<mint>(2,mint(0)));
  dp[0][0] = 0;
  dp[0][1] = 1;
  for(size_t i = 0; i < L.length(); ++i){
    if(L[i] == '1'){
      dp[i+1][1] = dp[i][1]*2;
      dp[i+1][0] = dp[i][1] + dp[i][0]*3;
    }else{
      dp[i+1][1] = dp[i][1];
      dp[i+1][0] = dp[i][0]*3;
    }
  }
  cout << (dp.back()[0] + dp.back()[1]) << endl;
}


Measured memory_bytes: 5760
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')

n, x, t = LI()
ans = (n // x) * t

if n % x == 0:
    print(ans)
else:
    print(ans + t)


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rep(i, k, n) for (int i = (int)(k); i < (int)(n); ++i)
#define rrep(i, k, n) for (int i = (int)(n) - 1; i >= (int)(k); --i)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vv_ii;
typedef pair<int,ii> i_ii;
typedef vector<i_ii> vi_ii;

template <class T>
inline ostream& operator<<(ostream & o, vector<T> const& v) {
    for (int i = 0; i < (int)(v.size()) - 1; ++i)
        o << v[i] << ' ';
    if (!v.empty())
        o << v.back();
    return o;
}

template <class T, class Q>
inline ostream& operator<<(ostream & o, pair<T,Q> const& p) {
    o << "(" << p.fi << "," << p.se << ")";
    return o;
}


int main(){

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

    
    string s;
    cin >> s;
    cout << (s[2] == s[3] && s[4] == s[5] ? "Yes\n" : "No\n");
    

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
   int n,x,sum,cont;
   int i,j,k;

   while(1){
   scanf("%d %d", &n,&x);
   if(n==0 && x==0) break;

   cont=0;
   for(i=1;i<=n-2;i++){
      for(j=i+1;j<=n-1;j++){
         for(k=j+1;k<=n;k++){
         sum = i+j+k;
         if(sum==x) cont++;
         }
      }
   }
   printf("%d\n", cont);
   }

}



Measured memory_bytes: 2056
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
using namespace std;
#define i64  long long
#define lint long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define MOD 1000000007

#define int long long

int N_global;

int DFS(string input)
{
  if(stoll(input) > N_global) return 0;//再起の終了地点
  int a = 0,b = 0,c = 0;
  int res = 0;
  for (int i = 0; i < input.size(); i++)
  {
    if(input[i] == '7') a++;
    if(input[i] == '5') b++;
    if(input[i] == '3') c++;
  }

  if((a>0)&&(b>0)&&(c>0))res++;

  res += DFS(input + '7');
  res += DFS(input + '5');
  res += DFS(input + '3');
  
  return res;
}
void solve()
{

  int N;
  cin>>N;
  N_global = N;

  cout<<DFS("0")<<endl;
  return;  
}
 
int32_t main(int32_t argc, const char *argv[])
{
 
  solve();
 
  return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
#define dout(n) cout<<# n<<" = "<<n<<endl;
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,x,y;
    cin>>n>>x>>y;
    x--;y--;
    vector<vector<ll>> v(n,vector<ll>(n,1e9));
    FOR(i,0,n){
        deque<ll> q;
        q.push_back(i);
        v[i][i] = 0;
        while(!q.empty()){
            ll from = q.front();
            q.pop_front();
            if(0<from && v[i][from-1]==1e9){
                v[i][from-1] = v[i][from]+1;
                q.push_back(from-1);
            }
            if(from<n-1 && v[i][from+1]==1e9){
                v[i][from+1] = v[i][from]+1;
                q.push_back(from+1);
            }
            if(from == x && v[i][y] == 1e9){
                v[i][y] = v[i][x]+1;
                q.push_back(y);
            }       
            if(from == y && v[i][x] == 1e9){
                v[i][x] = v[i][y]+1;
                q.push_back(x);
            }       
        }
    }
    vector<ll> ans(n);
    FOR(i,0,n){
        FOR(j,i+1,n){
            ans[v[i][j]]++;
        }
    }
    FOR(i,1,n){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 31616
a = int(input())
l = list(map(int,input().split()))
MOD = (10**9) + 7
cnt =[0]*60
for i in l:
    for j in range(60):
        cnt[j] += (i>>j)%2==1
ans = 0
for i in range(60):
    ans += cnt[i] * (a - cnt[i])<<i
    ans %= MOD
print(ans)

Measured memory_bytes: 122808
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;


int main(){
	int N,K;cin >> N >> K;
	vector<int> d(101);
	set<int> S;
	vector<vector<int>> A(101,vector<int> (101));
	rep(i,K){
		cin >> d[i];
		rep(j,d[i]){
		cin >> A[i][j];
		S.insert(A[i][j]);
		
	}
	}
	
	int count = 0;
	for (int i = 1; i <= N; i++){
		if(S.count(i)) {
		count++;
		
		}
	}
	cout << N - count << endl;
}

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

const int MN = 302;

int N, K, M;
int comb[MN][MN], fact[MN];

int cc[MN][MN];
int dp(int val, int cnt) {
    if(val == K + 1) return cnt == 0;
    int &ret = cc[val][cnt];
    if(ret != -1) return ret;

    ret = dp(val + 1, cnt);
    for(int i = 0; i < cnt; i++) {
        ret += 1LL * comb[cnt][i] * dp(val + 1, i) % M * dp(val, cnt - 1 - i) % M;
        ret %= M;
    }
    return ret;
}

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

    for(int i = 0; i < MN; i++) {
        comb[i][0] = 1;
        for(int j = 1; j <= i; j++) {
            comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % M;
        }
    }

    memset(cc, -1, sizeof(cc));
    printf("%d", dp(1, N));
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<string>
using namespace std;
typedef long long ll;
int n, a[100010], b[100010], cnt;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	for (int i = 0; i < n - 1; i++) {
		if (a[i] == a[i + 1]) {
			b[cnt] = a[i];
			cnt++;
			a[i] = 0;
			a[i + 1] = 0;
		}
	}
	if (cnt < 2)cout << 0 << endl;
	else cout << (ll)b[cnt - 1] * b[cnt - 2] << endl;
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num))+1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl;
#define dpa(v) cerr << "[ " << endl;REPI(itr, v) { cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl; } cerr << "]" << endl;


void solve(long long A, long long B){
  cout << max(A+B, max(A-B, A*B)) << endl;
}

signed main(){
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  solve(A, B);
}


Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
ll solve(ll a,ll b)
{
	if(a==0)return 1;
	int n;
	for(int i=0;i<62;i++)if((a>>i)&1)n=i;
	if((b>>n)&1)
	{
		a&=~(1ll<<n);
		b&=~(1ll<<n);
		return solve(a,b);
	}
	else
	{
		ll ret=(1ll<<n)-b;
		a&=~(1ll<<n);//0~a b~msk-1
		if(a>=b)return ret+(1ll<<n);
		else return ret+min(1ll<<n,(1ll<<n)-b+solve(a,0));
	}
}
int main()
{
	ll a,b;
	cin>>a>>b;
	cout<<solve(b,a)<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            bool flend = true;
                List<int> anslist = new List<int>();
            while (flend)
            {
                string str = Console.ReadLine();
                string[] str2 = str.Split();
                int n = int.Parse(str2[0]);
                int x = int.Parse(str2[1]);
                int ans = 0;

                if (n == 0 && x == 0)
                    break;

                for (int i = 1; i <= n-2; i++)
                {
                    for (int j = i+1; j <= n-1; j++)
                    {
                        for (int k = j+1; k <= n; k++)
                        {
                            if (i + j + k == x)
                                ans++;

                        }
                        
                    }
                    
                }
                anslist.Add(ans);
            }
            foreach (var item in anslist)
            {
                
            Console.WriteLine(item);
            }
            Console.ReadLine();
            //string str = Console.ReadLine();
            //string[] str2 = str.Split();
            //int W = int.Parse(str2[0]);
            //int H = int.Parse(str2[1]);
            //int x = int.Parse(str2[2]);
            //int y = int.Parse(str2[3]);
            //int r = int.Parse(str2[4]);
            //if (x - r < 0 || W < x + r || y - r < 0 || H < y + r)
            //{
            //    Console.WriteLine("No");

            //}
            //else
            //{
            //    Console.WriteLine("Yes");

            //}
            ////Console.ReadLine();
            //bool flend = true;
            //List<int> anslist = new List<int>();
            //while (flend)
            //{
            //    string str = Console.ReadLine();
            //    string[] str2 = str.Split();
            //    int a = int.Parse(str2[0]);
            //    char op = char.Parse(str2[1]);
            //    int b = int.Parse(str2[2]);
            //    int ans = 0;
            //    switch (op)
            //    {
            //        case '+':
            //            ans = a + b;
            //            break;
            //        case '-':
            //            ans = a - b;
            //            break;
            //        case '*':
            //            ans = a * b;
            //            break;
            //        case '/':
            //            ans = a / b;
            //            break;
            //        case '?':
            //            flend = false;
            //            break;
            //        default:
            //            break;
            //    }
            //    if (flend)
            //        anslist.Add(ans);
            //}
            //foreach (var item in anslist)
            //{

            //    Console.WriteLine(item);
            //}
            //Console.ReadLine();

        }
    }
}

Measured memory_bytes: 5668
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  int count = 0;
  rep (i, n) {
    int tmp;
    cin >> tmp;
    v[i] = tmp;
    while (1) {
      if (tmp % 2 == 0) {
        tmp /= 2;
        count++;
      }
      else break;
    }
  }
  P(count);

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <algorithm>
#include <functional>
#include <vector>
#include <cmath>
#include <chrono>
#include <queue>
#include <set>
#include <cassert>
#include <random>
#include <chrono>
#include <complex>
#include <cstring>
constexpr int P = 1000000007;
int power(int base, int e) {
    int res = 1;
    while (e > 0) {
        if (e % 2 == 1)
            res = 1ll * res * base % P;
        base = 1ll * base * base % P;
        e /= 2;
    }
    return res;
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n;
    std::cin >> n;
    std::vector<int> p(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> p[i];
        if (p[i] != -1)
            --p[i];
    }
    std::vector<int> fa(n, -1);
    auto find = [&](int x) {
        while (fa[x] >= 0 && fa[fa[x]] >= 0)
            x = fa[x] = fa[fa[x]];
        return fa[x] < 0 ? x : fa[x];
    };
    int cnt = 0, k = 0;
    auto merge = [&](int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) {
            ++cnt;
            return;
        }
        fa[x] += fa[y];
        fa[y] = x;
    };
    for (int i = 0; i < n; ++i) {
        if (p[i] >= 0) {
            merge(i, p[i]);
        } else {
            ++k;
        }
    }
    int ans = 1ll * (n - cnt) * power(n - 1, k) % P;
    std::vector<int> dp(k + 1), fac(n + 1);
    fac[0] = 1;
    for (int i = 1; i <= n; ++i)
        fac[i] = 1ll * fac[i - 1] * i % P;
    dp[0] = 1;
    for (int i = 0; i < n; ++i) {
        if (p[i] == -1) {
            int s = -fa[find(i)];
            ans = (ans + 1ll * (P - s + 1) * power(n - 1, k - 1)) % P;
            for (int j = k; j > 0; --j)
                dp[j] = (dp[j] + 1ll * dp[j - 1] * s) % P;
        }
    }
    for (int i = 2; i <= k; ++i)
        ans = (ans + 1ll * (P - power(n - 1, k - i)) * fac[i - 1] % P * dp[i]) % P;
    std::cout << ans << std::endl;
    return 0;
}

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

int main(){
  int n[5];
  for(int i=0; i<5; i++){
    cin>>n[i];
  }
  for(int i=0; i<5; i++){
    if(n[i]==0){
      cout<<i+1;
      break;
    }
  }
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,pii> pr;
double heads(int n,int req,vector<double> &prob,vector<vector<double>> &dp){
	if(req == 0){
		return 1.00;
	}
	if(n == 0){
		return 0.00;
	}
	if(dp[n][req]!=-1){
		return dp[n][req];
	}
	return dp[n][req] = prob[n-1] * heads(n-1,req-1,prob,dp) + (1-prob[n-1]) * heads(n-1,req,prob,dp);
}
int main(int argc,char const* argv[]){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin>>n;
	vector<double> prob(n);
	for(int i=0;i<n;i++){
		cin>>prob[i];
	}
	double ans = 0.00;
	int majority = n/2;
	majority++;
	vector<vector<double>> dp(n+1,vector<double>(n+1,-1));
	ans = heads(n,majority,prob,dp);
	cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 74040
let diff3 a b c = max a (max b c) - min a (min b c)
let calc a b =
  let sub_calc s0 a' b' =
    let d0 = diff3 s0 (a'/2*b') ((a'-a'/2)*b') in
    let d1 = diff3 s0 (b'/2*a') ((b'-b'/2)*a') in
    min d0 d1
  in
  [ sub_calc (a/3*b) (a-a/3) b;
    sub_calc ((a+3)/3*b) (a-(a+3)/3) b;
    sub_calc (b/3*a) a (b-b/3);
    sub_calc ((b+3)/3*a) a (b-(b+3)/3);
  ] |> List.fold_left min 1010101010101010
let h, w = Scanf.scanf "%d %d" (fun x y -> x, y)
let () = calc h w |> Printf.printf "%d\n"


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

struct Edge { int to, id;};

vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v, int c=-1, int p=-1) {
  int k = 1;
  rep(i,g[v].size()) {
    int u = g[v][i].to, ei = g[v][i].id;
    if (u == p) continue;
    if (k == c) ++k;
    ans[ei] = k; ++k;
    dfs(u,ans[ei],v);
  }
}

int main() {
  int n;
  cin >> n;
  g.resize(n);
  //ans = vector<int>(n-1);
  ans.resize(n-1);
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].push_back((Edge){b,i});
    g[b].push_back((Edge){a,i});
  }
  dfs(0);
  int mx = 0;
  rep(i,n) mx = max(mx, int(g[i].size()));
  cout << mx << endl;
  rep(i,n-1) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 8320
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(map(int, input().split()))

N = int(input())
aa = inpl()

S1 = 0
S2 = sum(aa)
ans = INF

for i,a in enumerate(aa):
	if i == N-1:
		break
	S1 += a
	S2 -= a
	ans = min(abs(S1-S2),ans)

print(ans)


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

dp = [1]*(n+1)

for a in a_list:
    dp[a] = 0

for i in range(2,n+1):
    if dp[i] != 0:
        dp[i] = dp[i-1] + dp[i-2]

print(dp[n]%(10**9+7))

Measured memory_bytes: 460020
#include <cstdio>
#include <vector>
#include <set>
#include <queue>
using namespace std;


int main(){
	vector<char> goal(32);
	for(int i = 0; i < 4; ++i){
		for(int j = 0; j < 7; ++j){
			goal[i * 8 + j] = (i + 1) * 10 + j + 1;
		}
	}

	int n;
	for( scanf("%d", &n); n--; ){
		int x;
		vector<char> v(32);
		v[0] = 11;
		v[8] = 21;
		v[16] = 31;
		v[24] = 41;

		for(int i = 0; i < 4; ++i){
			for(int j = 1; j <= 7; ++j){
				scanf("%d", &x);
				
				if( x % 10 != 1 ){
					v[i * 8 + j] = x;
				}
			}
		}
		
		queue<vector<char> > q;
		q.push(v);
		q.push( vector<char>() );

		set<vector<char> > st;
		st.insert(v);

		int t = 0;
		while(true){
			if( q.size() == 1 ){
				t = -1;
				break;
			}
			
			v = q.front();
			q.pop();
			
			if( v.empty() ){
				++t;
				q.push(v);
				continue;
			}
			
			if( v == goal ){
				break;
			}

			int pos[48] = {};
			for(int i = 0; i < 4; ++i){
				for(int j = 0; j <= 7; ++j){
					int p = i * 8 + j;
					pos[ v[p] ] = p;
				}
			}

			for(int i = 0; i < 4; ++i){
				for(int j = 1; j <= 7; ++j){
					int p = i * 8 + j;
					
					if( v[p] == 0 && v[p - 1] % 10 != 7 ){
						vector<char> v2 = v;
						x = v[p - 1];
						v2[p] = x + 1;
						v2[ pos[x + 1] ] = 0;
						
						if( st.find(v2) == st.end() ){
							st.insert(v2);
							q.push(v2);
						}
					}
				}
			}
		}
		
		printf("%d\n", t);
	}
}

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

int main()
{
    int n,m; cin>>n>>m;
    vector<int> x(m);
    for(int i=0;i<m;i++) cin>>x[i];
    sort(x.begin(),x.end());
    vector<int> dx(m-1);
    for(int i=0;i<m-1;i++) dx[i]=x[i+1]-x[i];
    sort(dx.begin(),dx.end());
    ll sum=0;
    for(int i=0;i<m-1-(n-1);i++) sum+=dx[i];
    cout<<sum<<endl;
    return 0;
}

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

int main() {
	int N, M, T[100], P, X;
	int sum = 0;
	cin >> N;
	for (int i = 0;i < N;++i) {
		cin >> T[i];
		sum += T[i];
	}int x = sum;
	cin >> M;
	for (int i = 0;i < M;++i) {
		cin >> P >> X;
		sum += X- T[P-1];
		cout << sum << endl;
		sum = x;
	}
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
ret = 'No'
c = Counter(A)
if all([i == 0 for i in c]):
    ret = 'Yes'
else:
    v = set(list([i[1] for i in c.items()]))
    if len(c) == 3 and all([i == N/3 for i in v]):
        c = list(c)
        if c[0] ^ c[1] == c[2]:
            ret = 'Yes'
    elif len(c) == 2 and 0 in c:
        for i in c.items():
            if i[0] == 0 and i[1] == N/3:
                ret = 'Yes'

print(ret)

Measured memory_bytes: 14468
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
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); }


//BELOW
const int MAX_N = 100;         // n の最大値
vector<vector<long long>> com;  // 前計算の結果を保存
 
// 動的計画法で前処理
void init() {
    com.assign(MAX_N, vector<long long>(MAX_N,0));
    com[0][0] = 1;
    for (int i = 1; i < MAX_N; ++i) {
        com[i][0] = 1;
        for (int j = 1; j < MAX_N; j++) {
            com[i][j] = (com[i - 1][j - 1] + com[i - 1][j]);
        }
    }
}
// nCk を取得
long long COM(int n, int k) {
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    return com[n][k];
}



void solve(void)
{
  int N,A,B;
  cin>>N>>A>>B;
  vector<int> vec (N,0);
  for (int i = 0; i < N; i++)
  {
     cin>>vec[i];
  }
  init();
  sort(ALL(vec));
  reverse(ALL(vec));
  double AVE = 0;
  for (int i = 0; i < A; i++)
  {
    AVE += vec[i];
  }
  AVE /= (double)A;
  cout<<AVE<<endl;
  if(vec[0] != vec[A-1])
  {
    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
      if(vec[i] ==vec[A-1])cnt++;
    }
    int cnt_2 = 0;
    for (int i = 0; i < A; i++)
    {
      if(vec[i] ==vec[A-1])cnt_2++;
    }
    
    cout<<COM(cnt,cnt_2)<<endl;
    return;
  }
  else
  {

    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
      if(vec[i] ==vec[0])cnt++;
    }
    int res = 0;
    for (int k = A; k < min(B+1,cnt+1); k++)
    {
      res += COM(cnt,k); 
    }
    cout<<res<<endl;
    
  }
  
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

/* -128 ~ 127 */
using i8  = int8_t;
/* 0 ~ 255 */
using u8  = uint8_t;
/* -32,768 ~ 32,767 */
using i16 = int16_t;
/* 0 ~ 65,535 */
using u16 = uint16_t;
/* -2,147,483,648 ~ 2,147,483,647 */
using i32 = int32_t;
/* 0 ~ 4,294,967,295 */
using u32 = uint32_t;
/* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using i64 = int64_t;
/* 0 ~ 18,446,744,073,709,551,615 */
using u64 = uint64_t;
/* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f32 = float;
/* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f64 = double;
using f80 = __float80;

template <class T>
using Vec = vector<T>;

template <typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template <typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

/* 定数 */
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;

#define fn auto
#define ALL(v) v.begin(), v.end()

fn get_digit(u64 num) -> u64 {
    u64 digit = 0;
    while (num != 0) {
        num /= 10;
        digit++;
    }
    return digit;
}

fn Main() {
    u64 S;
    cin >> S;
    u64 ans = S;
    u64 d = get_digit(S) - 1;
    for (u64 tmp = 1; tmp < (1 << d); tmp++) {
        u64 T = S;
        bitset<9> s(tmp);
        u64 sum = 0;
        u64 num = T % 10;
        u64 digit = 10;
        T /= 10;
        for (u64 i = 0; i < d; i++) {
            if (s.test(i)) {
                sum += num;
                num = T % 10;
                digit = 10;
            } else {
                num += (T % 10) * digit;
                digit *= 10;
            }
            T /= 10;
        }
        sum += num;
        ans += sum;
    }
    cout << ans << endl;
}

fn main() -> int {
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}



Measured memory_bytes: 256
def gcd(a,b):
	if b == 0:
		return a
	return gcd(b,a % b)

def lcm(a,b):
	return a // gcd(a,b) * b

def candiv(l,u,x):
	return u // x - (l - 1) // x

a,b,c,d = map(int,input().split())
print(b - a + 1 - candiv(a,b,c) - candiv(a,b,d) + candiv(a,b,lcm(c,d)))

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	string S;
	cin >> S;
	set<char> cset;
	for (auto c : S)cset.insert(c);

	if (SZ(cset) == SZ(S))
	{
		cout << "yes" << endl;
	}
	else
	{
		cout << "no" << endl;
	}

	return 0;
}

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

char c[1000000];

int main(){

  int n,m;
  scanf("%d",&n);
  while(n != 0){
    scanf("%d",&m);
    scanf("%s",c);
    int ans = 0,flag;
    for(int i=0;i<m-2*n;i++){
      if(c[i] == 'I'){
	flag = 0;
	for(int j=i+1;j<m;j=j+2){
	  if(c[j]=='O'&&c[j+1]=='I'){
	    flag++;
	  } else{
	    break;
	  }
	}
	if(flag >= n){
	  ans += flag-n+1;
	}
	i += flag*2;
      }
    }
    printf("%d\n",ans);
    scanf("%d",&n);
  }

  return (0);
}

Measured memory_bytes: 3580