akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

ll calc_count(ll h){
    if(h == 1){
        return 1;
    }
    else{
        return 1 + 2 * calc_count(h / 2);
    }
}

int main(){

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

    ll h; cin >> h;
    cout << calc_count(h) << endl;

    return 0;
}

Measured memory_bytes: 256
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;

int solve() 
{
	//happy coding

	int n;
	cin>>n;
	int x = n%10;
	if(x==2||x==4||x==5||x==7||x==9){
		cout<<"hon"<<endl;
	}else if(x== 3){
		cout<<"bon"<<endl;
	}else{
		cout<<"pon"<<endl;
	}
	

	
	return 0;
}
int main(){
	int test = 1;
	//scanf("%d", &test);
	while (test--)solve();return 0;
}

Measured memory_bytes: 3672
#include <cstdio>
#include <iostream>
using namespace std;
#define mod 1000000007

int a[100010];
long long v[100010];
long long inv[100010];

void getinv(){
  for (int i = 1; i <= 1e5+2; i++) {
    if (i == 1) inv[i] = 1;
    else {
      inv[i] = (mod - (mod / i) * inv[mod % i]) % mod;
      if (inv[i] < 0) inv[i] += mod;
    }
  }
}

int main(){
  int n;
  cin >> n;
  for (int i = 0; i <= n; i++) {
    int k;
    scanf("%lld", &k);
    v[i] = k;
    a[k]++;
  }
  long long w;
  for (int i = 0; i <= n; i++){
    if (a[i] == 2) {
      w = (long long) i;
      break;
    }
  }
  int fr[2];
  int t = 0;
  for (int i = 0; i <= n; i++) {
    if (t == 2) break;
    if (v[i] == w) {
      fr[t] = i;
      t++;
    }
  }
  getinv();
  long long r = 1;
  for (int i = 1; i <= n+1; i++) {
    r = (((r * (n-i+2)) % mod) * inv[i]) % mod;
    while (r < 0) {
      r += mod;
    }
    v[i] = r;
  }
  r = 1;
  v[1] -= r;
  int u = n - (fr[1] - fr[0]);
  for (int i = 1; i <= u; i++) {
    r = (((r * (u-i+1)) % mod) * inv[i]) % mod;
    while (r < 0) {
      r += mod;
    }
    v[i+1] -= r;
    if (v[i+1] < 0) v[i+1] += mod;
  }
  for (int i = 1; i <= n+1; i++) {
    printf("%lld\n", v[i]);
  }
  return 0;
}

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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
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(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int n; cin >> n;
  vector<ll> a(n); cin >> a;
  ll as = 0; rep(i, n)as += a[i];
  ll res = linf;
  ll curr = 0;
  rep(i, n - 1){
    curr += a[i];
    res = min(res, abs(as - curr - curr));
  }
  cout << res << endl;
  return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    set<int> a, b;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        a.insert(x);
    }
    for (int i = 0; i < m; ++i) {
        int x;
        cin >> x;
        b.insert(x);
    }
    int A = 0, B = 0;
    set<int> And, Or;
    for (auto p : a) {
        if (b.count(p)) {
            And.insert(p);
            ++A;
        }
        Or.insert(p);
    }
    for (auto p : b) {
        Or.insert(p);
    }

    cout << And.size() << " " << Or.size() << endl;
    for (auto p : And) {
        cout << p << endl;
    }
    for (auto p : Or) {
        cout << p << endl;
    }
    return 0;
}


Measured memory_bytes: 25912
n,m = map(int,input().split())
d = {str(x):[] for x in range(1,n+1)}
n = str(n)
ans = "IMPOSSIBLE"
for i in range(m):
    t = input().split()
    d[t[0]].append(t[1])

for l1 in d["1"]:
    if l1==n:
        ans="POSSIBLE"
        break
    else:
        for l2 in d[l1]:
            if l2==n:
                ans="POSSIBLE"
                break
print(ans)


Measured memory_bytes: 55652
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static class Price implements Comparable<Price> {
		long price;
		int count;
		
		public Price(long price, int count) {
			this.price = price;
			this.count = count;
		}

		@Override
		public int compareTo(Price arg0) {
			return Long.compare(this.price, arg0.price);
		}
	}
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final int M = sc.nextInt();
			
			Price[] prices = new Price[N];
			for(int i = 0; i < N; i++) {
				prices[i] = new Price(sc.nextLong(), sc.nextInt());
			}
			Arrays.sort(prices);
			
			int rest = M;
			long answer = 0;
			for(final Price price : prices) {
				answer += price.price * Math.min(rest, price.count);
				rest -= Math.min(rest, price.count);
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 45596
#include<iostream>
#define l int64_t
#define c continue;
#define o(a) cout<<a<<endl;
#define r(i,x,y) for(l i=x;i<y;i++){
#define t(a,b,c) t[a][b][c]
using namespace std;
int main(){l m=1e9+7,x,y,z,w,o,p,q,v[93],t[91][91][2],a,b;v[0]=1,v[1]=1;r(i,2,93)v[i]=v[i-1]+v[i-2];}r(i,2,91)r(j,1,i)a=v[i],b=v[i+1];if(j<2){t(i,0,0)=a,t(i,0,1)=b,t(i,j,0)=b,t(i,j,1)=2*b-a;c;}t(i,j,0)=t(i-1,j-1,1),t(i,j,1)=t(i-1,j-1,1)+t(i-1,j-1,0);}}cin>>q;while(q--){cin>>x>>y;if(x>y)swap(x,y);if(y<2){o("1 1")c}r(i,0,93)if(v[i]>x||v[i+1]>y){z=i-1;break;}}o(z)if(z<2){o(x*y%m)c}w=0;r(j,0,z)o=t(z,j,0),p=t(z,j,1);if(o>x||p>y)c w+=(y-p)/o+1;if(x>=p)w+=(x-p)/o+1;}o(w%m)}}

Measured memory_bytes: 4432
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
 
// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
 
using namespace std;
using namespace __gnu_pbds;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define endl "\n"
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
 
const int INF = 2e9;
const double PI = acos(-1);
const int N = 1e6 + 7;
int mod = 998244353;

int dp[102][100005], n, W;
vector<vector<int>> in;

int solve(int item, int weight)
{
    if(weight > W)
        return -INF;
    if(item == n)
        return 0;
    int &res = dp[item][weight];
    if(res != -1)
        return res;
    res = solve(item + 1, weight + in[item][0]) + in[item][1];
    res = max(res, solve(item + 1, weight));
    return res;
}

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

    cin >> n >> W;
    for(int i = 1; i <= n; i++)
    {
        int w, v;
        cin >> w >> v;
        in.pb({w, v});
    }
    memset(dp, -1, sizeof(dp));
    cout << solve(0, 0) << endl;
    return 0;
}

Measured memory_bytes: 80000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Solve(int N, int[] V, int[] C)
        {
            return Enumerable.Range(0, N).Where(i => V[i] - C[i] > 0).Sum(i => V[i] - C[i]);
        }

        static void Main(string[] args)
        {
            int N = ReadInt();
            int[] V = ReadInts();
            int[] C = ReadInts();
            Console.WriteLine(Solve(N, V, C));
        }
    }
}


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

int main() {
	string S, T;
	bool check = false;
	cin >> S >> T;
	for (int i = 0; i < S.size(); i++) {
		if (S == T) check = true;
		char x = S[S.size() - 1];
		S.erase(S.size() - 1, 1);
		S = x + S;
	}
	if (check) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main()
{
    string s,s1,s2,s3;
    cin >> s;
    int i=0;
    
    for(i=0;i<5;++i){
        s1= s1 + s[i];
    }
    for(i=6;i<13;++i){
        s2= s2 + s[i];
    }
    for(i=14;i<19;++i){
        s3= s3 + s[i];
    }
    cout << s1 << " " << s2 << " " << s3<< endl;
    return 0;
    
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod=998244353;
//head
ll modpow(ll a, ll b, ll m) {
    if(b == 0) return 1 % m;
    ll u = modpow(a,b/2,m);
    u = (u*u)%m;
    if(b%2 == 1) {
        u = (u*a)%m;
    }
    return u;
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vll occ(n,0);
    ll a;
    cin >> a;
    if(a != 0) {
        cout << 0 << endl;
        return 0;
    }
    occ[0]++;
    for(int i = 0; i < n - 1; i++) {
        cin >> a;
        occ[a]++;
    }
    if(occ[0] != 1) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    for(ll i = 1; i < n - 1; i++) {
        if(occ[i - 1] == 0 && occ[i] != 0) {
            ans = 0;
        }
        ans *= modpow(occ[i-1],occ[i],mod);
        ans %= mod;
    }
    cout << ans % mod << endl;
    return 0;
}


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

int main(){
    string s;cin>>s;
    long long q;cin>>q;
    long long w=0;
    for(long long i=0;i<q;i++){
        int c;cin>>c;
        if(c==1){
            w++;
        }
        if(c==2){
            int d;cin>>d;
            string a;cin>>a;
            if(d==1){
                if(w%2==0)s.insert(0,a);
                else s.append(a);
            }
            else{
                if(w%2==0)s.append(a);
                else s.insert(0,a);
            }
        }
    }
    if(w%2==1)reverse(s.begin(),s.end());
    cout<<s<<endl;
}

Measured memory_bytes: 3868
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
const long long MAXN=100005;
long long n,m;
vector<int>w[MAXN];
bool vis[MAXN];
long long cl[MAXN];
bool dfs(long long u)
{
	vis[u]=1;
	long long re=1;
	for(long long i=0;i<int(w[u].size());i++)
	{
		long long v=w[u][i];
		if(vis[v])
			re&=(cl[u]!=cl[v]);
		else
		{
			cl[v]=cl[u]^1;
			re&=dfs(v);
		}
	}
	return re;
}
int main()
{
	//freopen("squared.in","r",stdin);
	//freopen("squared.out","w",stdout);
	scanf("%lld %lld",&n,&m);
	for(long long i=1;i<=m;i++)
	{
		long long u,v;
		scanf("%lld %lld",&u,&v);
		w[u].push_back(v);
		w[v].push_back(u);
	}
	long long I=0,O=0,J=0;
	for(long long i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			if(int(w[i].size())==0)
				I++;
			else if(dfs(i))
				O++;
			else
				J++;
		}
	}
	printf("%lld\n",I*I+I*(n-I)*2+O*O*2+J*J+O*J*2);
	fclose(stdin);
	fclose(stdout);;
}

Measured memory_bytes: 10492
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,sum=0;
  cin>>n;
  for(long long int i=1;i<=n;i++)
  {
    if(i%3!=0&&i%5!=0)
    {
      sum=sum+i;
    }
  }
  cout<<sum<<endl;
 
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>

#define ff first
#define ss second

using namespace std;
using pii=pair<int,int>;
using ll=long long;

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

    int n,q;
    cin>>n>>q;
    priority_queue<pair<int,pii>,vector<pair<int,pii>>,greater<pair<int,pii>>> pq;
    for(int i=0; i<n; i++){
        int s,t,x;
        cin>>s>>t>>x;
        pq.push({x,{s,t-1}});
    }
    int idx=0;
    map<int,int> query;
    vector<int> answer(q,-1);
    for(int i=0; i<q; i++){
        int d;
        cin>>d;
        query.insert({d,i});
    }
    while(!pq.empty()){
        auto top=pq.top();
        pq.pop();
        auto itb=query.lower_bound(top.ss.ff-top.ff);
        auto ite=query.upper_bound(top.ss.ss-top.ff);
        for(auto it=itb; it!=ite;){
            answer[it->second]=top.ff;
            it=query.erase(it);
        }
    }
    for(int ans : answer) cout<<ans<<"\n";

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll from;
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RES(a, n) (a).resize(n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = (ll)pow(10,7);
/****** define constant end ********/
/****** define variable start ******/
ll n, m, k;
vl a, b, c, d;
/******* define variable end *******/
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int solve() {
	cin >> n >> m >> k;
	UnionFind friends(n);
	vll fr(n);
	vll bl(n);
	RES(a, m);
	RES(b, m);
	RES(c, k);
	RES(d, k);
	REP(i, m){
		cin >> a[i] >> b[i];
		friends.merge(a[i]-1, b[i]-1);
		fr[a[i]-1].push_back(b[i]-1);
		fr[b[i]-1].push_back(a[i]-1);
	}
	REP(i, k){
		cin >> c[i] >> d[i];
		if(friends.issame(c[i]-1, d[i]-1)){
			bl[c[i]-1].push_back(d[i]-1);
			bl[d[i]-1].push_back(c[i]-1);
		}
	}
	REP(i, n){
		cout << friends.size(i) - 1 - bl[i].size() - fr[i].size() << " ";
	}
	cout << endl;
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 19960
#include<iostream>
#include<vector>
#include<stack>

using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c){
  stack<int> S;
  S.push(r);
  color[r] = c;
  while(!S.empty()){
    int u = S.top();
    S.pop();
    for(int i=0;i<G[u].size();i++){
      int v = G[u][i];
      if(color[v]==NIL){
        color[v] = c;
        S.push(v);
      }
    }
  }
}

void assignColor(){
  int id = 1;
  for(int i=0;i<n;i++) color[i] = NIL;
  for(int u=0;u<n;u++){
    if(color[u]==NIL) dfs(u,id++);
  }
}

int main(){
  int s,t,m,q;
  cin >> n >> m;
  for(int i=0;i<m;i++){
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  assignColor();
  
  cin >> q;

  for(int i=0;i<q;i++){
    cin >> s >> t;
    if(color[s] == color[t]){
      cout << "yes" << endl;
    }else{
      cout << "no" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 8976
#include <bits/stdc++.h>
using namespace std;
int main(){
  int price=0;
  cin>>price;
  int N=10;
  int f=0;
  for(int i=0;i<N;i++){
    if(f*1000-price>=0){
      break;
    }
    f++;
  }
  cout<<f*1000-price<<endl;
}

Measured memory_bytes: 3608
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define ll long long
#define inf 1<<30
#define il inline 
#define in1(a) read(a)
#define in2(a,b) in1(a),in1(b)
#define in3(a,b,c) in2(a,b),in1(c)
#define in4(a,b,c,d) in2(a,b),in2(c,d)
il void readl(ll &x){
    x=0;ll f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
il void read(int &x){
    x=0;int f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
using namespace std;
/*===================Header Template=====================*/
#define N 105
char s[N];
int a[N];
long long k;
int main(){
	int i,len;
	scanf("%s",s+1);
	len=strlen(s+1);
	for(i=1;i<=len;i++) a[i]=s[i]-'0';
	readl(k);
	i=0;
	while(k>0){
		i++;
		if(a[i]==1) k--;
		else k-=pow(a[i],5*1e15-1);
	}
	printf("%d",a[i]);
	return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		System.out.println(Math.max(0, C - (A - B)));
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}

Measured memory_bytes: 23124
using System;
using System.Collections;
					
public class Program
{
	public static long comp = 0;
	public static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		int[] ls = Array.ConvertAll(Console.ReadLine().Trim().Split(' '), int.Parse);
		mergeSort(ls, 0, n);
		Console.WriteLine(comp);
	}
	public static void mergeSort(int[] ls, int left, int right){
		if (left + 1 < right){
			int mid = (left + right)/2;
			mergeSort(ls, left, mid);
			mergeSort(ls, mid, right);
			merge(ls, left, mid, right);
		}
	} 
	public static void merge(int[] ls, int left, int mid, int right){
		int n1 = mid - left, n2 = right - mid;
		int[] L = new int[n1 + 1], R = new int[n2 + 1];
		for(int i = 0; i < n1; i++) L[i] = ls[left + i];
		for(int i = 0; i < n2; i++) R[i] = ls[mid + i];
		L[n1] = R[n2] = int.MaxValue;
		for(int k = left, i = 0, j = 0; k < right; k++) 
			if (L[i] < R[j]){
				ls[k] = L[i++];
			}
			else{
				ls[k] = R[j++];
				comp += n1 - i;
			}
	}
}




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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void yes(){
    p("Yes");
    exit(0);
}

void no(){
    p("No");
    exit(0);
}

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    ll zero_count = 0;
    for(ll a : A){
        if(a==0) zero_count++;
    }
    if(zero_count==N){
        yes();
    }

    map<ll, ll> mp;
    for(ll a : A){
        mp[a]++;
    }

    if(N%3!=0){
        no();
    }

    if(mp.size()==3){
        ll x = 0;
        for(auto pa : mp){
            ll count = pa.second;
            if(count!=N/3){
                no();
            }
            x ^= pa.first;
        }
        if(x==0){
            yes();
        }else{
            no();
        }
    }
    else if(mp.size()==2){
        if(mp[0]==N/3){
            yes();
        }else{
            no();
        }
    }
    else{
        no();
    }

    return 0;
}

Measured memory_bytes: 5760
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		String s = sc.next();
		LinkedList<Character> stack = new LinkedList<>();
		
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if (stack.isEmpty() || c == 'S') {
				stack.push(c);
				continue;
			} 
			if (c == 'T') {
				if (stack.peek() == 'S') { 
					stack.pop(); 
				} else {
					stack.push(c);
				}
			}
		}
		
      	System.out.println(stack.size());
	}
	
    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 27860
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N;
	std::vector<int> A;
	std::cin >> N;
	A.resize(N);
	for (auto& a : A)
		std::cin >> a;
	
	int max = *std::max_element(A.begin(), A.end());
	int min = *std::min_element(A.begin(), A.end());
	std::cout << max-min << "\n";
}


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

int main() {
  string S;
  cin >> S;
  int count = 0;
  int i = 0;
  while(i < S.size()){
    i++;
    if(i > S.size()-1){
      continue;
    }
    if(S.at(i-1) == S.at(i)){
      if(S.at(i-1) == '0' && S.at(i) == '0'){
        S.at(i) = '1';
        i--;
        count++;
      }
      else if(S.at(i-1) == '1' && S.at(i) == '1'){
        S.at(i) = '0';
        i--;
        count++;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 512
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a_list: [i64; n],
    }
    let mut b_sum_list = vec![0; n];
    for i in 0..n {
        let a = a_list[i];
        let prev = if i == 0 { 0 } else { a_list[i - 1] };
        let prev_sum = if i == 0 { 0 } else { b_sum_list[i - 1] };
        b_sum_list[i] = prev_sum + (prev - a).abs();
    }
    let mut f_sum_list = vec![0; n];
    for i in 0..n {
        let ii = a_list.len() - 1 - i;
        let a = a_list[ii];
        let prev = if ii == a_list.len() - 1 { 0 } else { a_list[ii + 1] };
        let prev_sum = if ii == a_list.len() - 1 { 0 } else { f_sum_list[ii + 1] };
        f_sum_list[ii] = prev_sum + (prev - a).abs();
    }

    for i in 0..n {
        let back_sum = if i == 0 { 0 } else { b_sum_list[i - 1] };
        let forward_sum = if i == n - 1 { 0 } else { f_sum_list[i + 1] };
        let back_to_forward_cost = match i {
            0 => 0,
            m if m == n - 1 => 0,
            _ => (a_list[i - 1] - a_list[i + 1]).abs()
        };
        let first_or_last_cost = match i {
            0 => a_list[i + 1].abs(),
            m if m == n - 1 => a_list[i - 1].abs(),
            _ => 0
        };
        let sum = back_sum + forward_sum + back_to_forward_cost + first_or_last_cost;
        println!("{}", sum);
    }
}


Measured memory_bytes: 9340
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String S = br.readLine();
        for (int i=0; i<S.length(); ++i) {
            if (i%2==1 && !checkEven(S.charAt(i))) {
                System.out.println("No");
                return;
            } else if (i%2==0 && !checkOdd(S.charAt(i))) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
    public static boolean checkEven(char a) {
        if (a=='L' || a=='U' || a=='D') return true;
        return false;
    }
    public static boolean checkOdd(char a) {
        if (a=='R' || a=='U' || a=='D') return true;
        return false;
    }
}


Measured memory_bytes: 22484
///created: 12/Jun/2019 19:09:28

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
#define db(x) cerr << "debug: " << #x << " = " << x << '\n';
template<class __Ty> bool minimize(__Ty& a, __Ty b) {
	if (a > b) { a = b; return true; }
	return false;
}
template<class __Ty> bool maximize(__Ty& a, __Ty b) {
	if (a < b) { a = b; return true; }
	return false;
}

const int N = 1e5 + 5;
int n, m;
typedef pair<ii, int> iii;
iii a[N];
ii ans[N];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= m; ++i) {
		cin >> a[i].first.first >> a[i].first.second;
		a[i].second = i;
	}
	sort(a + 1, a + 1 + m);
	for (int i = 1, j = 1; i <= m;) {
		while (j <= m && a[j].first.first == a[i].first.first) ++j;
		for (int k = i; k < j; ++k) {
			ans[a[k].second] = ii(a[k].first.first, k - i + 1);
		}
		i = j;
	}
	for (int i = 1; i <= m; ++i)
		printf("%06d%06d\n", ans[i].first, ans[i].second);
	return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int h, w, n;
	cin >> h >> w >> n;
	
	vector< pair<int, int> > p(n);
	for(int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		p[i] = make_pair(a, i + 1);
	}
	
	sort(p.begin(), p.end());
	
	int cnt = n - 1;
	vector< vector<int> > c(h, vector<int>(w, 0));
	
	for(int i = 0; i < w; ++i) {
		
		if( i % 2 == 0 ) {
			for(int j = 0; j < h; ++j) {
				c[j][i] = p[cnt].second;
				p[cnt].first--;
			
				if( p[cnt].first == 0 ) cnt--;
			}
		} else {
			for(int j = h - 1; j >= 0; --j) {
				c[j][i] = p[cnt].second;
				p[cnt].first--;
			
				if( p[cnt].first == 0 ) cnt--;
			}
		}
	}
	
	for(int i = 0; i < h; ++i) {
		for(int j = 0; j < w; ++j) {
			cout << c[i][j] << " ";
		}
		
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3636
X,N=input().split();
X=int(X);
N=int(N);
if N==0:
  print(X);
  exit();
P=input().split();
P=[int(s) for s in P];
#P.sort();
#print(P);
ans_min=X;
ans_max=X;
for i in range(210):
  x=X-i;
  if not x in P:
    #print(x);
    ans_min=x;
    break;
for i in range(210):
  x=X+i;
  if not x in P:
    #print(x);
    ans_max=x;
    break;

if abs(X-ans_min)<=abs(X-ans_max):
  print(ans_min);
else:
  print(ans_max);

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int a, b;
    cin >> a >> b;

    int cnt = 0;
    for (int i = a; i <= b; i++)
    {
        if ((i / 10000) % 10 == i % 10)
        {
            if ((i / 1000) % 10 == (i / 10) % 10)
            {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
/*
  AOJ 0035
  Title:Is it Convex?
  @kankichi573
*/
#include <stdio.h>
#include <float.h>
double xa,ya,xb,yb,xc,yc,xd,yd;

int side(double x1,double y1,double x2,double y2,double xa,double ya)
{
  double ret;
  int ret1;
  ret=(y1-y2)*(xa-x1)-(x1-x2)*(ya-y1);
  ret1=(ret>0)?1:(-1);
  //printf("%lf %lf %lf %lf %lf %lf %d\n",x1,y1,x2,y2,xa,ya,ret1);
  return  ret1;
}

int opposite_side(double x1,double y1,double x2,double y2,
		  double xa,double ya,double xb,double yb)
{
  int ret1,ret2;
  ret1=side(x1,y1,x2,y2,xa,ya);
  ret2=side(x1,y1,x2,y2,xb,yb);
  
  return (ret1!=ret2)?1:0 ;
}
main()
{
  int i,ret1,ret2;
  
  while(EOF!=scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",
		   &xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd))
    {
      ret1=opposite_side(xa,ya,xc,yc,xb,yb,xd,yd);
      ret2=opposite_side(xb,yb,xd,yd,xa,ya,xc,yc);
      printf("%s\n",(ret1&ret2)?"YES":"NO");
    }
  return(0);
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
int main() {
    int H,W,K;
    cin >> H >> W >> K;
    char a[H][W];
    int ans[H][W];
    int cont = 0;
    
    for(int i = 0; i < H;i++){
        for(int j = 0; j < W;j++){
            cin >> a[i][j];
            ans[i][j] = 0;
            if(a[i][j] == '#')ans[i][j] = ++cont;
        }
    }
    
    for(int i=0; i<H; i++) {
        for(int j=0; j+1<W; j++) {
            if(ans[i][j] > 0 && ans[i][j+1] == 0) ans[i][j+1] = ans[i][j];
        }
    }
    
    // for(int i = 0; i < H;i++){
    //     for(int j = 0; j < W;j++){
    //         cout << ans[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << "############"<<endl;
    for(int i=0; i<H; i++) {
        for(int j=W-1; j>0; j--) {
            if(ans[i][j] > 0 && ans[i][j-1] == 0) ans[i][j-1] = ans[i][j];
        }
    }    
    
    // for(int i = 0; i < H;i++){
    //     for(int j = 0; j < W;j++){
    //         cout << ans[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << "############"<<endl;
    for(int j=0; j<W; j++) {
        for(int i=0; i+1<H; i++) {
            if(ans[i][j] > 0 && ans[i+1][j] == 0) ans[i+1][j] = ans[i][j];
        }
    }
    
    // for(int i = 0; i < H;i++){
    //     for(int j = 0; j < W;j++){
    //         cout << ans[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << "############"<<endl;
    
    for(int j=0; j<W; j++) {
        for(int i=H-1; i>0; i--) {
            if(ans[i][j] > 0 && ans[i-1][j] == 0) ans[i-1][j] = ans[i][j];
        }
    }
    for(int i = 0; i < H;i++){
        for(int j = 0; j < W;j++){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
    
    
    
    
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false);cin.tie(0);
#define setnow clock_t tStart;
#define setTime tStart = clock();
#define time0 (double)(clock() - tStart)/CLOCKS_PER_SEC
#define setin(x) ifstream cin(x);
#define setout(x) ofstream cout(x);
#define NMAX 30
typedef long long ll;
typedef long long int lli;
typedef pair < int, int> dbl;
const int maxInt = 1e9*2;
const lli maxLong = 1e18*2;
bool f[110][10][10];
int p[100][100];
int n;
int binary[11];
void increment(int binary[]){
    for(int i=10;i>=1;i--){
        if(binary[i] == 0){
            binary[i] = 1;
            for(int j=i+1;j<=10;j++){
                binary[j] = 0;
            }
            break;
        }
    }
}
bool notOk(){
    int k = 0;
    for(int i=1;i<=10;i++){
        if(binary[i] == 1)
            k++;
    }
    if(k)
    return(1);
    return(0);
}
int main(){
  //setin("input.in");
  int n;
  cin >> n;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=5;j++){
        for(int k=1;k<=2;k++){
            cin >> f[i][j][k];
            //cout << f[i][j][k];
        }
    }
  }
  //cout << endl;
  for(int i=1;i<=n;i++){
    for(int j=0;j<11;j++){
        cin >> p[i][j];
    }
  }
  int mx = -1e9, mxc = 0;
  for(int it=0;it<1024;it++){
        if(notOk()==0){
            increment(binary);
            continue;
        }
        //for(int j=1;j<=10;j++)
        //    cout << binary[j];
        //cout << endl;
        int curr = 0;
        int c[200];
        memset(c, 0, sizeof(c));
        for(int i=1;i<=n;i++){
            for(int j=1;j<=5;j++){
                for(int k=1;k<=2;k++){
                    if(f[i][j][k] && binary[(j-1)*2+k])
                        //cout << j << ' ' << k << endl;
                        c[i]++;
                }
            }
        }
       // mxc = max(c[1], mxc);
        for(int i=1;i<=n;i++){
            //cout << c[i] << ' ';
            curr+=p[i][c[i]];
        }
        //cout << curr << endl;
        mx = max(curr, mx);
        increment(binary);
  }
  cout << mx;
  return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())

# 最大公約数が1〜Kになるそれぞれの個数を求める
# 大きい方から順に計算して、自分の倍数になるものは除外する

res = [0] * (K+1)
DIV = 10 ** 9 + 7
for x in range(K,0,-1):
  # 最大公約数がxになるものは
  # K//x個ある
  # (K//x)**Nが、個数
  res[x] = pow(K//x,N,DIV)
  for i in range(x*2,K+1,x):
    res[x] -= res[i]
    
ans = 0
for i in range(len(res)):
  ans += res[i] * i
  ans %= DIV
  
print(ans)

Measured memory_bytes: 11132
#define MOD 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define foru(i, k, n) for (int i = k; i < n; i++)
#define ford(i, k, n) for (int i = k; i >= n; i--)
#define pb push_back
#define mp make_pair
#define has(set, x) set.find(x) != set.end()
#define nohas(set, x) set.find(x) == set.end()
#define inc(mpp, x) {if(has(mpp, x)) mpp[x]++; else mpp.insert(mp(x,1));}
#define decc(mpp, x) {if(has(mpp, x)) {if(mpp[x] > 1) mpp[x]--; else mpp.erase(x);}}
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define um unordered_map
#define us unordered_set
#include <iostream>
#include <list>
#include <queue>
#include <vector>
#include <map>
#include <string>
#include <unordered_map>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <fstream>
#include <algorithm>
#include <chrono>
#include <bitset>
using namespace std;
const int INF = 1 << 29;
typedef long long ll;
typedef unsigned long long ull;
inline int two(int n) { return 1 << n; }
ll extgcd(ll a, ll b, ll& x, ll& y) { if (b == 0) { x = 1; y = 0; return a; } else { int g = extgcd(b, a%b, y, x); y -= a / b * x; return g; } }
ll modpow(ll a, ll b) { ll res = 1; a %= MOD; for (; b; b >>= 1) { if (b & 1)res = res * a%MOD; a = a * a%MOD; }return res; }
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const {
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};
ifstream in("input.txt");
ofstream out("output.txt");


int main() {
	fast;
	int t;
	cin >> t;
	t -= 400;
	t /= 200;
	cout << 8 - t << endl;
	return 0;
}

Measured memory_bytes: 3208
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import time
import math
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
sys.setrecursionlimit(10**7)
input=lambda :sys.stdin.readline().rstrip()
N=int(input())
A=list(map(int,input().split()))
A=Counter(A)
for i in range(1,N+1):
    if i in A:
        print(A[i])
    else:
        print(0)


Measured memory_bytes: 120100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f(ll n)
{
	if(n==1) return 1;
	else return f(n/2)*2+1;
}
int main()
{
	ll h;
	cin>>h;
	cout<<f(h)<<"\n";
	return 0;
} 

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

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

	vector<int> A(N);
	for (int i = 0; i < N; ++i)
		cin >> A[i];
	
	bitset<100001> wins;
	for (int k = 1; k <= K; ++k) {
		bool win = false;
		for (int x: A) {
			win |= (k-x < 0 ? false : !wins[k-x]);
		}
		wins[k] = win;
	}
	
	cout << (wins[K] ? "First" : "Second") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a, b, c; cin >> a >> b >> c;
    cout << ((a[a.size()-1]==b[0] && b[b.size()-1]==c[0]) ? "YES" : "NO");
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {
	
	int n;
	int dp[100001] = {};
	int count = INF;
	int point = 0;

	cin >> n;
	
	FOR(i, 0, n) {
		dp[i] = i;
	}
	dp[1] = 1;
	FOR(i, 0, n) {
		FOR(j, 1, 100) {
			if (i + pow(6, j) <= n) {
				dp[i + (int)(pow(6, j))] = min(dp[i] + 1, dp[i + (int)(pow(6, j))]);
			}
			else {
				break;
			}
		}
		FOR(j, 1, 100) {
			if (i + pow(9, j) <= n) {
				dp[i + (int)(pow(9, j))] = min(dp[i] + 1, dp[i + (int)(pow(9, j))]);
			}
			else {
				break;
			}
		}
	}
	/*FOR(i, 1, n) {
		cout << i << " " << dp[i] << endl;
	}*/
	cout << dp[n] << endl;

	return 0;
}

Measured memory_bytes: 640