akhauriyash/Code-Regression huggingface dataset:
//https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_d
//D - Lucky PIN
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}
int main() {
    ll N; cin>>N;
    string S; cin>>S;

    auto check_func = [&](array<ll,3>& pin)->bool{
        ll p=0;
        for(const auto& c:S){
            if(c-'0'==pin[p]){
                ++p;
                if(p>=pin.size()) return true;
            }
        }
        return false;
    };

    ll ans=0;
    array<ll,3> pin;
    FOR(i,0,10){
        FOR(j,0,10){
            FOR(k,0,10){
                pin[0]=i;
                pin[1]=j;
                pin[2]=k;
                if (check_func(pin)) ++ans;
            }
        }
    }
    cout<<ans<<endl;    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
signed main(){
	string s;
	cin>>s;
	if(s=="SUN")cout<<7;
	else if(s=="MON")cout<<6;
	else if(s=="TUE")cout<<5;
	else if(s=="WED")cout<<4;
	else if(s=="THU")cout<<3;
	else if(s=="FRI")cout<<2;
	else if(s=="SAT")cout<<1;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<numeric>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i <= (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

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

	string S;
	cin >> S;

	vector<ll> ans(S.size());

	ll l=0;
	ll rr;
	rep(i,S.size()){
		if(S[i]=='R' && S[i+1] == 'L'){
			rr = i;
			repk(j,i+1,S.size()){
				if(j == S.size() - 1){
					ans[i] += (rr-l)/2 + (j-rr)/2 + 1;
					ans[i+1] += (rr-l+1)/2 + (j-rr+1)/2;
					
					rep(i,S.size()){
						cout << ans[i] << " ";
					}
					cout << endl;
					return 0;
				}
				if(S[j] == 'R'){
					ans[i] += (rr-l)/2 + (j-rr-1)/2 + 1;
					ans[i+1] += (rr-l+1)/2 + (j-rr)/2;
					l = j;
					i = j -1;
					break;
				}
			}
		}
	}

	rep(i,S.size()){
		cout << ans[i] << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 1488
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};
const int NMAX=100010;
mint fact[NMAX],infac[NMAX];
void Make_Fact(){
  fact[0]=fact[1]=1;
  for(int i=2;i<=NMAX-1;++i){
    fact[i]=fact[i-1]*(mint)i;
  }
}
void Make_InvFact(){
  infac[0]=infac[1]=1;
  for(int i=2;i<=NMAX-1;++i){
    infac[i]=infac[i-1]/(mint)i;	
  }
}
mint Comb(int n,int k){
  if(n<0||k<0||n-k<0) return 0;
  return fact[n]*infac[k]*infac[n-k];
}

int main()
{
  int n,k;cin >> n >> k;
  Make_Fact();
  Make_InvFact();
  rep1(i,k){
    mint res = Comb(n-k+1,i)*Comb(k-1,i-1);
    cout << res.x << "\n";
  }

  
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define MAXN 500005
#define ll long long
using namespace std;
int n,m,c,t;
int l[MAXN],r[MAXN];
char s[MAXN];
int main() {
    cin>>n>>m>>c;
    scanf("%s",s+1);
    int now=-c-1,cnt=0;
    for(int i=1;i<=n;i++){
        if(s[i]=='x'||i-now<c+1)continue;
        l[++cnt]=i,now=i;
    }
    now=n+c+1;
    if(cnt>m)return 0;
    t=cnt;
    for(int i=n;i>=1;i--){
        if(s[i]=='x'||now-i<c+1)continue;
        r[cnt--]=i,now=i;
    }
    for(int i=1;i<=t;i++){
        if(l[i]==r[i])cout<<l[i]<<endl;
    }
   return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
long long N,A[100010]={};
long long cnt=0;

long long pow1(long long a,long long b){
  long long ans=1;
  if(b==0){
    return 1;
  }
  else{
    for(long long i=0;i<b;i++){
      ans = a*ans;
      ans%=1000000007;
    }
    return ans;
  }
}

//char op;
int main(){
  cin >> N;
  for(long long i=0;i<N;i++){
    cin >> A[i];
  }
  sort(A,A+N);
  if(N%2==0){
    for(long long i=0;i<N;i+=2){
      if(A[i]==i+1 && A[i+1]==i+1) cnt++;
      else break;
    }
    if(cnt==N/2){
      cout << pow1(2,N/2) << endl;
      return 0;
    }
  }
  else{
    if(A[0]==0){
      for(long long i=1;i<N;i+=2){
        if(A[i]==i+1 && A[i+1]==i+1) cnt++;
        else break;
      }
      if(cnt==(N-1)/2){
        cout << pow1(2,(N-1)/2) << endl;
        return 0;
      }
    }
  }
  cout << 0 << endl;

  return 0;
}


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

using namespace std;

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  string s;
  cin >> s;
  long long answer = 0;
  int current = 0;
  for (auto c : s) {
    if (c == 'B') {
      ++current;
    } else {
      answer += current;
    }
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 3712
N = int(input())
W_arr = [int(x) for x in input().split()]

W_tot = sum(W_arr)
diff_min = 999999999
for i in range(len(W_arr)+1):
    W_part = sum(W_arr[:i])
    diff = abs(W_part-(W_tot-W_part))
    diff_min = min(diff_min, diff)

print(diff_min)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    if(s.at(0) != 'A') {
        cout << "WA" << endl;
        return 0;
    }else {
        s.erase(s.begin());
    }
    if(count(s.begin() + 1,s.end() - 1,'C') != 1) {
        cout << "WA" << endl;
        return 0;
    }else {
        s.erase(find(s.begin(),s.end(),'C'));
    }
    for(int i = 0;i < s.size();i++) {
        if(s.at(i) < 'a' || s.at(i) > 'z') {
            cout << "WA" << endl;
            return 0;
        }
    }
    cout << "AC" << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

signed main() {
	int n;
	string s;
	cin >> n;
	cin >> s;
	if (n % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}
	rep(i, n / 2) {
		if (s[i] != s[i + n / 2]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  

  int x;
  cin >> x;
  if(x>=30){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }


return 0;
}
///....


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

#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 SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    ll n;

    cin >> n;

    ll ans = 0;

    ans += (n/500*1000);
    n %= 500;

    ans += (n/5*5);
    
  	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  string S;
  cin >> N >> S;

  ll ans = 0;
  REP(i, 1, N) {
    string first = S.substr(0, i);
    string second = S.substr(i);

    bool fc[26] = {}, sc[26] = {};
    ll cnt = 0;
    for (auto c : first) {
      fc[c - 'a'] = true;
    }
    for (auto c : second) {
      sc[c - 'a'] = true;
    }
    REP(j, 0, 26) {
      if (fc[j] && sc[j]) {
        cnt++;
      }
    }
    if (cnt > ans) {
      ans = cnt;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
let input = require('fs').readFileSync('/dev/stdin', 'utf8');
let Arr = (input.trim()).split("\n");
let N1 = Number(Arr[0]);
let arr1 = Arr[1].split(" ").map(Number);
let arr2 = Arr[3].split(" ").map(Number);

const binarySearch = (key) => {
  let mid;
  let left = 0;
  let right = N1;
  if (key < arr1[0] || arr1[N1-1] < key) return 0;
  while (left < right) {
    mid = Math.floor((left + right) / 2);
    if (key < arr1[mid]) right = mid;
    else if (key > arr1[mid]) left = mid + 1;
    else return 1;
  }
  return 0;
}

const summing = (a, b) => a + b;
console.log(arr2.map(binarySearch).reduce(summing, 0));




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

#define MIN(X,Y) ((X)<(Y)?(X):(Y))
#define ABS(X) ((X)<0?-(X):(X))

int main(void){
  int n,a[3],h[8];
  int ans;
  
  cin >> n >> a[0] >> a[1] >> a[2];
  for (int i=0; i<8; i++) cin >> h[i];
  ans = 1001001;
  // bit全探索
  for (int i=0; i < 1<<(2*n); i++){
    int sm[4]={0}, nm[4]={0};
    int t = i, cost = 0;
    for (int j=0; j<n; j++){
      nm[t%4]++; sm[t%4]+=h[j];
      t/=4;
    }
    if (nm[0]==0 || nm[1]==0 || nm[2]==0) continue;
    for (int i=0; i<3; i++){
      cost += ABS(a[i]-sm[i]);
      cost += (nm[i]-1)*10;
    }
    ans = MIN(ans,cost);
    //cout << i << " " << cost << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())

tx = tx - sx
ty = ty - sy

ans = "" 
ans += "U" * ty
ans += "R" * tx
ans += "D" * ty
ans += "L" * tx
ans += "L"
ans += "U" * (ty + 1)
ans += "R" * (tx + 1)
ans += "D"
ans += "R"
ans += "D" * (ty + 1)
ans += "L" * (tx + 1)
ans += "U"

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;
void visit(const vector<vi> &g, int v, vector< vector<int> >& scc,
    stack<int> &S, vector<bool> &inS,
    vector<int> &low, vector<int> &num, int& time) {
  low[v] = num[v] = ++time;
  S.push(v); inS[v] = true;
  for(int e : g[v]) {
    int w = e;
    if (num[w] == 0) {
      visit(g, w, scc, S, inS, low, num, time);
      low[v] = min(low[v], low[w]);
    } else if (inS[w])
      low[v] = min(low[v], num[w]);
  }
  if (low[v] == num[v]) {
    scc.push_back(vector<int>());
    while (1) {
      int w = S.top(); S.pop(); inS[w] = false;
      scc.back().push_back(w);
      if (v == w) break;
    }
  }
}
vector<vi> stronglyConnectedComponents(const vector<vi>& g) {
  const int n = g.size();
  vector<int> num(n), low(n);
  stack<int> S;
  vector<bool> inS(n);
	vector<vi> scc;
  int time = 0;
  rep(u, n) if (num[u] == 0)
    visit(g, u, scc, S, inS, low, num, time);
	return scc;
}
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	vi in, out;
	{
		int n, m; cin >> n >> m;
		vector<vi> g(n);
		rep(i, m){
			int a, b; cin >> a >> b;
			g[a].pb(b);
		}
		vector<vi> scc = stronglyConnectedComponents(g);
		if(scc.size() == 1){
			cout << 0 << endl;
			return 0;
		}
		in.resize(scc.size());
		out.resize(scc.size());
		vi to(n);
		rep(i, scc.size()) for(int j : scc[i]) to[j] = i;
		rep(i, n) for(int j : g[i]){
			int a = to[i], b = to[j];
			if(a == b) continue;
			out[a]++;
			in[b]++;
		}
	}
	int x = 0, y = 0;
	rep(i, in.size()){
		if(in[i] == 0) x++;
		if(out[i] == 0) y++;
	}
	cout << max(x, y) << endl;
	
	return 0;
}


Measured memory_bytes: 5628
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t;
	t=1;
	while(t--){
		int n=5;
		int ans=0;
		for(int i=1;i<=5;i++){
			cin>>n;
			if(n==0)
			ans=i;
		}
		cout<<ans<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    // Your code here!
    int N;
    double a= 0;
    cin >> N;
    for(int i=1;i<=N;i++){
        if(i%3 !=0 && i%5 != 0){
            a += i;
            //cout << i <<"\n";
        }
    }
    cout << setprecision(100)<<a;
}

Measured memory_bytes: 3732
import java.util.*;

public class Main{
    
    static final int MOD = (int)1e9+7;
    
    static int n;
    static ArrayList<Integer>[] g;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        n = Integer.parseInt(sc.next());
        g = new ArrayList[n];
        for(int i=0; i<n; i++){
            g[i] = new ArrayList<>();
        }
        
        for(int i=0; i<n-1; i++){
            int a = Integer.parseInt(sc.next())-1;
            int b = Integer.parseInt(sc.next())-1;
            g[a].add(b);
            g[b].add(a);
        }
        
        ArrayDeque<Integer> q = new ArrayDeque<>();
        q.addLast(0);
        int[] cnt = new int[2];
        int[] color = new int[n];
        Arrays.fill(color, -1);
        color[0] = 0;
        cnt[0]++;
        while(q.size()!=0){
            int now = q.removeLast();
            for(int next : g[now]){
                if(color[next] == -1){
                    q.addLast(next);
                    color[next] = color[now]^1;
                    cnt[color[next]]++;
                }
            }
        }
        
        StringJoiner sj = new StringJoiner(" ");
        int[] used = new int[3];
        if(cnt[0]<=n/3 || cnt[1]<=n/3){
            for(int i=0; i<n; i++){
                if(color[i] == (cnt[0]<cnt[1] ? 0:1)){
                    sj.add((used[2]+1)*3 + "");
                    used[2]++;
                }else{
                    for(int j=0; j<3; j++){
                        if(used[j]*3+j+1<=n){
                            sj.add(used[j]*3+j+1 + "");
                            used[j]++;
                            break;
                        }
                    }
                }
            }
        }else{
            for(int i=0; i<n; i++){
                if(used[color[i]]*3+color[i]+1<=n){
                    sj.add(used[color[i]]*3+color[i]+1 + "");
                    used[color[i]]++;
                }else{
                    sj.add((used[2]+1)*3 + "");
                    used[2]++;
                }
            }
        }
        
        System.out.println(sj.toString());
    }
}


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

int N;
int A[100000];
int B[100000];

int get_index(int x) {
  int small = 0;
  int big = N;
  int mid = N / 2;
  while (1) {
    int mid = (small + big) / 2;
    if (B[mid] < x) {
      small = mid;
    } else if (B[mid] > x) {
      big = mid;
    } else {
      return mid;
    }
  }
}

void solve() {
  memcpy(B, A, sizeof(int) * N);
  sort(B, B + N);
  int acc = 0;
  for (int i = 0; i < N; i++) {
    if ((get_index(A[i]) - i) % 2) {
      acc++;
    }
  }
  cout << acc / 2 << endl;
}

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  solve();
  return 0;
}


Measured memory_bytes: 1024
/*
 * author :Sadik Hassan(_sad_)
 *
*/
#include "bits/stdc++.h"
using namespace std;
using   ll =          long long;
using   ld =          long double;
#define nl            "\n"
#define pb            push_back
#define fi            first
#define se            second
#define MP            make_pair
#define PI            (acos(-1.0))
#define rep1(i,n)     for(int i=1;i<=n;i++)
#define rep(i,n)      for(int i=0;i<n;i++)
#define SZ(s)         (int)s.size()
#define all(x)        (x).begin(), (x).end()
#define rall(x)       (x).rbegin(), (x).rend()
#define w(t)          int t;cin>>t;while(t--)
#define TSU(s)        transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSL(s)        transform(s.begin(),s.end(),s.begin(),::tolower);
#define _SAD()     	  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0),cout<<fixed<<setprecision(15);

typedef vector<int> vi;
typedef vector<ll> vii;
typedef set<int> si;
typedef set<ll> sii;
/*---------------------------------------------------------------------*/

const int N = (int)1e6+1;
const int MOD =(int)1e9+7;
const ll INF = (ll)1e18+5;

int main()
{
    _SAD()
    int n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
       ll gu=n/i;
       ans+=gu*(gu+1)/2LL*i;
    }
    cout<<ans<<nl;
    return 0;
}


Measured memory_bytes: 3556
#include <cstdio>

int main(void)
{
	int n, q, s[100000], t[50000];
	int ans = 0;
	scanf("%d", &n);
	for(int i = 0; i != n; i++) {
		scanf("%d", s + i);
	}
	scanf("%d", &q);
	for(int i = 0; i != q; i++) {
		scanf("%d", t + i);
		int l = 0, r = n, mid;
		while(r - l > 1) {
			mid = (l + r) / 2;
			if (s[mid] == t[i]) {
				ans++;
				break;
			} else {
				if(s[l] == t[i] || s[r] == t[i]) {
					ans++;
					break;
				}
				if(s[mid] > t[i]) {
					r = mid;
				} else {
					l = mid;
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3324
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    ll N,a[100000];
    cin >>N;
    for (int i = 0; i < N; i++) {
        std::cin >> a[i];
    }
    ll res=0;
    for (int i = 0; i < N; i++) {
        ll t=1;
        while(true){
            if(a[i]%(ll)pow(2,t)==0){
                res++;
                t++;
            }else{
                break;
            }
        }
    }
    std::cout << res << std::endl;
    
}



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

vector <int> G[100006];
int d[100006];
int v[100006];
int ans[100006];
vector <int> q;

int main(){

  int n;
  int m;
  int i,j;
  int a,b;

  scanf("%d %d", &n, &m);
  for(i = 1;i <= n;i++){
    d[i] = 100100100;
    v[i] = 0;
  }

  for(i = 0;i < m;i++){
    scanf("%d %d", &a, &b);

    G[a].push_back(b);
    G[b].push_back(a);
  }

  d[1] = 0;
  v[1] = 1;

  q.push_back(1);
  int u,x;
  int head = 0;
  int tail = 1;

  while(head != tail){
    u = q[head++];
    for(i = 0;i < G[u].size();i++){
      x = G[u][i];
      if(v[x] == 0){
        q.push_back(x);
        tail++;
        d[x] = d[u] + 1;
        ans[x] = u;
        v[x] = 1;
      }
    }
  }

  int f = 0;
  for(i = 1;i <= n;i++){
    if(v[i] == 0) f = 1;
  }

  if(f == 1) printf("No\n");

  else {
    printf("Yes\n");
    for(i = 2;i <= n;i++) printf("%d\n", ans[i]);
  }

  return 0;
}


Measured memory_bytes: 11452
N, K = map(int, input().split())
A = list(map(int, input().split()))
l = 0
r = 10**9
while (r-l>1):
    x = (r+l)//2
    now = 0
    for a in A:
        now += (a-1)//x
    if now <= K:
        r = x
    else:
        l = x
print(r)

Measured memory_bytes: 30668
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main (void) {
    int i, j;
    int n, m;
    scanf("%d%d", &n, &m);

    int food[m + 1];
    for (i = 0; i <= m; i++) {
        food[i] = 0;
    }
    /* food 配列に各食べ物が何人に好かれているかを格納 */
    int k, fav;
    for (i = 0; i < n; i++) {
        scanf("%d", &k);
        for (j = 0; j < k; j++) {
            scanf("%d", &fav);
            food[fav]++;
        }
    }

    /* n 人全員から好かれている食べ物の数を数える */
    int ans = 0;
    for (i = 1; i <= m; i++) {
        if ( food[i] == n )
            ans++;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
N,M,Q = map(int,input().split())
grid = [[0]*N for i in range(N)]
ans_list = []
for i in range(M):
    L,R = map(int,input().split())
    L -= 1
    R -= 1
    grid[L][R] += 1
for i in range(N):
    acc = 0
    for j in range(N):
        acc += grid[i][j]
        grid[i][j] = acc
for j in range(N):
    acc = 0
    for i in range(N-1,-1,-1):
        acc += grid[i][j]
        grid[i][j] = acc

for i in range(Q):
    p,q = map(int,input().split())
    p -= 1
    q -= 1
    ans_list.append(grid[p][q])

for e in ans_list:
    print(e)

Measured memory_bytes: 10352
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int n;
vector<pii> edge[100100];
int dist[100100];

void dfs(int u) {
    for(auto&&i:edge[u]) {
        int v = i.first;
        int c = i.second;

        if(dist[v] == INF) {
            dist[v] = dist[u] + c;
            dist[v] %= 2;
            dfs(v);
        }
    }
}

signed main() {

    cin >> n;

    int a, b, c;
    memset(dist,0x3f, sizeof(dist));
    
    for(int i = 0; i < n-1; i++) {
        cin >> a >> b >> c;
        edge[a].bash({b, c});
        edge[b].bash({a, c});
    }
    dist[1] = 0;
    dfs(1);

    for(int i = 1; i <= n; i++) {
        cout << dist[i]%2 << endl;
    }

  
    return 0;
}



Measured memory_bytes: 7680
import collections
n = int(input())
a = sorted(collections.Counter(list(map(int, input().split()))).items(), reverse=True)
h = w = 0
for k, v in a:
    if h == 0 or w == 0:
        t = v
        while True:
            if t >= 2:
                if h == 0:
                    h = k
                    t -= 2
                elif w == 0:
                    w = k
                    t -= 2
                else:
                    break
            else:
                break
    else:
        break
print(h * w)


Measured memory_bytes: 21412
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const int INF = 1e9;
const double pi=acos(-1);
using namespace std;

int main(){
  int k;
  cin >> k;
  int a=k/2;
  int b=(k+1)/2;
  cout << a*b << endl;
  return 0;
}

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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




bool check(LL n,LL k)
{
    if(n < k)return 0;
    while(n >= k)
    {
        if(n%k == 0)n/=k;
        else n-=n/k*k;
    }
    return n == 1LL;
}

int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    LL i,n,rt,cnt=2;
    cin >> n;
    if(n == 2)cout << "1";
    else
    {
        rt=sqrt(n);
        for(i=2;i<=rt;i++)
        {
            cnt+=check(n,i);
            if(n/i != i)cnt+=check(n,n/i);
        }
        cout << cnt;
    }
    return 0;
}


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

int main(){
  int N, M;
  cin >> N >> M;
  
  vector<pair<long long int, int>> shop(N);
  
  for(int i = 0; i < N; i++){
    cin >> shop.at(i).first >> shop.at(i).second;
  }
  
  sort(shop.begin(), shop.end());
  
  int buy = 0; int index = 0;
  long long int ans = 0;
  while(buy < M){
    int b = min(shop.at(index).second, M - buy) ;
    buy += b;
    ans += b * shop.at(index).first;
    index++;
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 1792
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# Ciの値でsortする、Tを0000で固定した後、最後に2**N倍
N = ir()
C = np.array(lr())
MOD = 10 ** 9 + 7
C.sort()
# N-2がマイナスになる時に注意、一番右は2**(N-1)
two_power = np.array([(1+N-i) * pow(2, (N-2), MOD) % MOD if i < N-1 else pow(2, i, MOD) for i in range(N)])
answer = (C * two_power % MOD).sum() * 2**N
print(answer%MOD)


Measured memory_bytes: 34492
n,m = map(int,input().split())
li = [list(map(int,input().split())) for i in range(m)]
num = [0 for i in range(n)]
num[0] = 1
numc = [0 for i in range(n)]

for i in range(m):
    if numc[li[i][0]-1] == 0:
        num[li[i][0]-1] = li[i][1]
        numc[li[i][0]-1] += 1
    elif li[i][1] != num[li[i][0]-1]:
        num = [-1]
        break

if n != 1 and num[0] == 0:
    num = [-1]
elif n == 1 and numc[0] ==0:
  	num = [0]
print(''.join(map(str,num)))

Measured memory_bytes: 3188
N, K, Q = [int(s) for s in input().split(' ')]
S = [K] * (N + 1)
A = [Q] * (N + 1)
for i in range(Q):
    a = int(input())
    A[a] -= 1

for s, a in zip(S[1:], A[1:]):
    if s - a > 0:
        print('Yes')
    else:
        print('No')
    

Measured memory_bytes: 8960
#include <bits/stdc++.h>
#define ll long long
/*#define INF 2147483647
#define mem_INF 2139062143
#define ll_INF 9223372036854775807
#define eps 1e-8
#define fuckrand() ( ( rand() << 15 ) ^ rand() )*/
using namespace std;
inline int read() {
	int x = 0,tmp = 1;char ch = getchar();
	while( ch < '0' || ch > '9' ) {if ( ch == '-' ) tmp = -1; ch = getchar();}
	while( ch >= '0' && ch <= '9'){x = x * 10 + ch - '0'; ch = getchar(); }
	return x * tmp;
}
inline ll readll() {
	ll x = 0,tmp = 1;char ch = getchar();
	while( ch < '0' || ch > '9' ) {if ( ch == '-' ) tmp = -1; ch = getchar();}
	while( ch >= '0' && ch <= '9'){x = x * 10 + ch - '0'; ch = getchar(); }
	return x * tmp;
}
int n, m;
int l[210000], r[210000], head, x, lx, lr, rx;
int main() {
	n=read(); m=read();
	head=1; l[1]=0;
	for(int i=2;i<=n;++i){
		l[i]=i-1;
		r[i-1]=i;
	}
	r[n]=0;
	for(int i=1;i<=m;++i){
		x=read();
		if( head == x ) continue;
		lx=l[x]; rx=r[x];
		r[lx]=rx; l[rx]=lx;
		l[head]=x;
		l[x]=0; r[x]=head;
		head=x; 
	} 
	int k=head;
	while(k!=0){
		printf("%d\n",k);
		k=r[k]; 
	}
	return 0;
}

/*#include"testlib.h"
#define __ inf.readSpace()
#define ___ inf.readEoln()
int main()
{
	registerValidation();
	int a = inf.readInt(1, 10, "a");
	inf.readEof();
	return 0;
}*/

Measured memory_bytes: 4768
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin >> a >> b;
    if(a + b == 15){
        cout << "+" <<endl;
    }
    else if(a * b == 15){
        cout << "*" <<endl;
    }
    else{
        cout << "x" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*
          .  .
          |\_|\
          | a_a\
          | | "]
      ____| '-\___
     /.----.___.-'\
    //        _    \
   //   .-. (~v~) /|
  |'|  /\:  .--  / \
 // |-/  \_/____/\/~|
|/  \ |  []_|_|_] \ |
| \  | \ |___   _\ ]_}
| |  '-' /   '.'  |
| |     /    /|:  |
| |     |   / |:  /\
| |     /  /  |  /  \
| |    |  /  /  |    \
\ |    |/\/  |/|/\    \
 \|\ |\|  |  | / /\/\__\
  \ \| | /   | |__
       / |   |____)
       |_/
*/

#include <bits/stdc++.h>

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define mxn 100005
using namespace std;

ll n,m,x,mn = -1,cnt = 0;

void backtrek(int i,vector<vector<ll>> a,vector<ll> c,vector<ll>& ans)
{
    if(cnt >= m)
    {
        if(mn == -1)
            mn = ans[0];
        mn = min(mn,ans[0]);
        return;
    }
    if(i >= n)
        return;

    for(int j = i; j < n; j++)
    {
        for(int k = 0; k < m; k++){
            ans[k + 1] += a[j][k];
            if(ans[k + 1] - a[j][k] < x && ans[k + 1] >= x)
                cnt++;
        }
        ans[0] += c[j];
        backtrek(j + 1,a,c,ans);
        for(int k = 0; k < m; k++){
            ans[k + 1] -= a[j][k];
            if(ans[k + 1] + a[j][k] >= x && ans[k + 1] < x)
                cnt--;
        }
        ans[0] -= c[j];
    }
}

int main()
{
    FLASH
    cin >> n >> m >> x;
    vector<ll> c(n),ans(m + 1);
    vector<vector<ll>> a(n,vector<ll> (m));
    for(int i = 0; i <  n; i++)
    {
        cin >> c[i];
        for(int j = 0; j < m; j++)
        {
            cin >> a[i][j];
        }
    }

    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j <= m; j++)
            ans[j] = 0;
        cnt = 0;
        backtrek(i,a,c,ans);
    }
    cout << mn << endl;
    return 0;
}



Measured memory_bytes: 3684
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<stack>
#include<vector>
#define INFTY 10000000000
using namespace std;

int main(){
  int N,W;
  cin>>N>>W;
  int w[120],v[120];
  long long dp[120][130000];
  for(int i=1;i<=N;i++){
    cin>>w[i]>>v[i];
  }
  for(int i=0;i<120;i++){
    for(int j=0;j<=120000;j++){
      dp[i][j]=INFTY;
    }
  }
  dp[0][0]=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<=120000;j++){
      dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
      if(v[i+1]+j>120000) continue;
      dp[i+1][v[i+1]+j]=min(dp[i+1][v[i+1]+j],dp[i][j]+w[i+1]);
    }
  }
  int ans=0;
  for(int i=0;i<=120000;i++){
    if(dp[N][i]<=W){
      ans=i;
    }
  }
  cout<<ans<<endl;

}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

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

void solve() {
  int n;
  cin >> n;
  vi32 a(n);
  cin >> a;
  map<int, int> cnt;
  rep(i, n) cnt[a[i]] += 1;
  i64 sum = 0;
  rep(i, n) sum += a[i];
  int q;
  cin >> q;
  rep(qi, q) {
    i64 b, c;
    cin >> b >> c;
    sum = sum - b * cnt[b] + c * cnt[b];
    cout << sum << '\n';
    cnt[c] += cnt[b];
    cnt.erase(b);
  }
}


Measured memory_bytes: 6548
import math
N = int(input())
count = 0
for i in range(1, N):
    if i == 1:
        count += N - 1
        continue
    if N % i == 0:
        count += N / i -1
    elif N % i >= 1:
        count += math.floor(N / i)
print(int(count))

Measured memory_bytes: 9028
N = int(input())
A = [int(x) for x in input().split()]
i = j = 0

for x in A:
    if x % 2 == 0:
        i += 1
        if (x % 3 == 0) or (x % 5 == 0):
            j += 1

if i == j:
    print("APPROVED")
    exit(0)
print("DENIED")

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
	char a[5];
	cin>>a;
	if((a[0]==a[1]&&a[1]==a[2])||(a[1]==a[2]&&a[2]==a[3]))
	cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
} 

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

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final String n = scanner.next();
        final boolean answer = IntStream.range(0, n.length())
            .map(i -> n.charAt(i) - '0')
            .sum() % 9 == 0;
        System.out.println(answer ? "Yes" : "No");
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }
    }
}


Measured memory_bytes: 38028
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;
static const int MAX = 21;
static const int INFTY = (1 << 30);
int V;
std::vector<std::pair<int, int> > G[MAX];

int dijkstra(int r, int t) {
    priority_queue<std::pair<int, int> > pq;
    bool visited[MAX];
    int d[MAX];
    for (int i = 0; i < V; i++) {
        visited[i] = false;
        d[i] = INFTY;
    }
    d[r] = 0;
    pq.push({0, r}); //dist from target * -1, current node
    visited[r] = true;

    while ( !pq.empty() ) {
        pair<int, int> f = pq.top(); pq.pop();
        int current = f.second;
        visited[current] = true;

        if (d[current] < f.first * (-1)) continue;

        for (unsigned long i = 0; i < G[current].size(); i++) {
            int target = G[current][i].first;
            if (visited[target]) continue;
            if (d[target] > d[current] + G[current][i].second) {
                d[target] = d[current] + G[current][i].second;
                pq.push({d[target] * (-1), target});
            }
        }
    }
    return d[t];
}

int main()
{
    int E, source, target, cost, back, s, g, VV, P;
    scanf("%d %d", &V, &E);
    for (int i = 0; i < E; i++) {
        scanf("%d,%d,%d,%d", &source, &target, &cost, &back);
        source--; target--;
        G[source].push_back({target, cost});
        G[target].push_back({source, back});
    }
    scanf("%d,%d,%d,%d", &s, &g, &VV, &P);
    s--; g--;
    printf("%d\n", VV-P-dijkstra(s, g)-dijkstra(g, s));
    return 0;
}



Measured memory_bytes: 2604
#include <stdio.h>

int n, m, k;
char S[8][8];

int main()
{
	scanf ("%d %d %d", &n, &m, &k);
	for (int i = 0; i < n; i++) scanf ("%s", S[i]);

	int ans = 0;
	for (int p = 0; p < (1 << n); p++) for (int q = 0; q < (1 << m); q++){
		int cnt = 0;
		for (int i = 0; i < n; i++) if (p & (1 << i)) for (int j = 0; j < m; j++) if (q & (1 << j)){
			if (S[i][j] == '#') cnt++;
		}
		if (cnt == k) ans++;
	}
	printf ("%d\n", ans);

	return 0;
}

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

// 小数点以下桁数
// fixed << setprecision(i)

int main()
{
  int n, a;
  vector<int> b(200000, 0);

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

Measured memory_bytes: 3860
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var count = 0;
        for(var i = 1; i<=N; i++)
        {
            double temp = i % 2;
            if(temp != 0)
            {
                count++;
            }
        }
        Console.WriteLine(1.0 * count / N);
    }


    public string[] ReadInput()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] ConvertIntArray(string[] x)
    {
        var convertedArray = new int[x.Length];
        for (var i = 0; i < x.Length; i++)
        {
            convertedArray[i] = int.Parse(x[i]);
        }

        return convertedArray;
    }

}


Measured memory_bytes: 11092
n=int(input())
l=list(map(int,input().split()))
l.sort()
def nibuta(a,x):
    h=len(a)
    if a[0]>=x:
        return 0
    elif a[h-1]<x:
        return h
    else:
        lo=-1
        up=h-1
        while up-lo>1:
            if a[(lo+up)//2]>=x:
                up=(lo+up)//2
            else:
                lo=(lo+up)//2
        if a[up]>=x:
            return lo+1
        else:
            return up+1
s=0
for i in range(n-2):
    a1=l[i]
    for j in range(i+1,n-1):
        k=a1+l[j]
        s=s+nibuta(l[j+1:],k)
print(s)

Measured memory_bytes: 69560
a = int(input())
b = list(map(int,input().split()))
n = 1

c = 0
d = 0

for i in b:
    if i == 0:
        c += 1
    elif i > 10**18:
        d += 1
        
if c > 0:
    print(0)
    exit()
if d > 1 and c == 0:
    print(-1)
    exit()

for i in b:
  n *= i
  if n > 10**18:
    print(-1)
    exit()
print(n)
    

Measured memory_bytes: 21660
package main

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

const size = 1000000
var reader = bufio.NewReaderSize(os.Stdin,size)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n,_ = strconv.Atoi(NextLine())
  return n
}
func NextIntArray() []int {
  var s []string = strings.Split(NextLine()," ")
  var n int = len(s)
  var a []int = make([]int,n)
  for i:=0;i<n;i++ {
    a[i],_ = strconv.Atoi(s[i])
  }
  return a
}

func main() {
  var n int = NextInt()
  var a []int = NextIntArray()
  var b []int = NextIntArray()
  var c []int = NextIntArray()
  sort.Ints(a)
  sort.Ints(b)
  sort.Ints(c)
  var ia,ib,ic int
  var m int64
  ia = 0
  ic = 0
  m = 0
  for ib=0;ib<n;ib++ {
    for ;ia<n&&a[ia]<b[ib]; {
      ia++
    }
    for ;ic<n&&c[ic]<=b[ib]; {
      ic++
    }
    m += int64(ia)*int64(n-ic)
  }
  fmt.Println(m)
}

Measured memory_bytes: 11392
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>

#define rep(i,x) for(ll i=0;i<(int)(x);i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

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;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    ll n, k;
     cin >> n >> k;

     ll ans = n - (k-1);

     cout << ans << endl;




}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

A, B, C = mi()

if A + B + C > 21:
    print('bust')
else:
    print('win')



Measured memory_bytes: 9116
def iparse():
    return list(map(int, input().split()))

n, k = iparse()
d = iparse()

for i in range(n, 5000000):
    tmp = i
    f = True
    while tmp > 0:
        x = tmp % 10
        if x in d:
            f = False
            break
        tmp //= 10
    if f:
        print(i)
        exit()



Measured memory_bytes: 9000
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, 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 1; } return 0; }

int main() {
    string s;
    cin >> s;
    cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
struct S{
  modint val;
  int size;
};
vector<modint> p;
vector<modint> l;
S op(S s,S t){
  return (S){s.val*p.at(t.size)+t.val,s.size+t.size};
}
S e(){
  return (S){0,0};
}
struct F{
  bool x;
  int d;
};
S app(F f,S s){
  if(!f.x)
    return s;
  return (S){l.at(s.size)*f.d,s.size};
}
F com(F f,F g){
  if(!f.x)
    return g;
  return f;
}
F id(){
  return (F){0,0};
}
int main(){
  modint::set_mod(998244353);
  int n,q;
  cin>>n>>q;
  vector<S> a(n);
  modint b=10;
  modint d=(b-1).inv();
  modint x=1;
  for(int i=0;i<n;i++,x*=b){
    a.at(i)={1,1};
    p.push_back(x);
    l.push_back((x-1)*d);
  }
  lazy_segtree<S,op,e,F,app,com,id> st(a);
  for(int _=0;_<q;_++){
    int l,r,d;
    cin>>l>>r>>d;
    l--;
    st.apply(l,r,(F){1,d});
    cout<<st.all_prod().val.val()<<endl;
  }
}

Measured memory_bytes: 12760