akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        init();
        int n = nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) a[i] = nextLong();
        int[][] bits = new int[n][62];

        for (int j = 0; j < bits[0].length; j++) {
            long twoPow = (1L << j);
            for (int i = 0; i < n; i++) {
                long num = a[i];
                bits[i][j] = (int)((num & twoPow)>>j);
            }
        }

        long[][] numOf = new long[62][2];

        long mod = 1000000007;
        for (int j = 0; j < numOf.length; j++) {
            for (int i = 0; i < n; i++) {
                int bit = bits[i][j];
                numOf[j][bit]++;
            }
        }

        long ans = 0;
        for (int j = 0; j < numOf.length; j++) {
            long sum = (numOf[j][0] * numOf[j][1]) % mod;
            long twoPow = (1L << j);
            sum = (sum * (twoPow % mod)) % mod;
            ans = (ans + sum) % mod;
        }

        System.out.println(ans);
//        System.out.println(bruteForce(a, mod));
    }

//    private static long bruteForce(long[] nums, long mod) {
//        long ans = 0;
//        for (int i = 0; i < nums.length; i++) {
//            for (int j = i + 1; j < nums.length; j++) {
//                ans = (ans + (nums[i] ^ nums[j])) % mod;
//            }
//        }
//        return ans;
//    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

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

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

Measured memory_bytes: 132536
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
using namespace std;

int main(){
    long long N;
    cin >> N;
    
    vector<long long> P(N);
    for(int i=0; i<N; i++){
        cin >> P[i];
    }
    long long count = 0;
    long long min = N;
    bool flag = true;
    for(int i=0; i<N; i++){
        if (P[i] <= min){
            min = P[i];
            count++;
        }
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(void)
{
  long int N,i,j,A;
  scanf("%ld",&N);
  
  i=1;
  while(N>i*i){
    i++;
  }
  
  j=i;
  while(N%j!=0){
    j--;
  }
  
  A=j+(N/j)-2;
  
  printf("%ld",A);
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define powerof2 ()
#define mp make_pair
#define pi acos(-1)
using ll = long long;
const ll M = 1000000007;
const ll M1= 998244353;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
ll power(ll x,ll y){
	if(y==0)
		return 1;
	ll res=power(x,y/2);
	res=(res*res);
	if(y&1)
		res=(res*x);
	return res;
}
 
ll powermod(ll x,ll y,ll mod){
	if(y==0)
		return 1;
	ll res=powermod(x,y/2,mod);
	res=(res*res)%mod;
	if(y&1)
		res=(res*x)%mod;
	return res;
}
/*ll binarysearch(ll va)
{
	ll n=1;
	ll l=va+1,u=n;
	ll st=num.order_of_key(va);
	while(l+1<u)
	{
		m=(l+u)/2;
		ll in=num.order_of_key(m);
		if(in-st==m-va)
		{
			l=m;
		}
		else
		{
            u=m;
		}
	}
	if(num1.find(l)==num1.end())
		return l;
	return u;
}*/
void solve(){
	int n;
	cin >>n;
	int c_a=0,c_w=0,c_r=0,c_t=0;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		if(s=="AC") c_a++;
		else if(s=="WA") c_w++;
		else if(s=="RE") c_r++;
		else c_t++;
	}
	cout<<"AC x "<<c_a<<"\n";
	cout<<"WA x "<<c_w<<"\n";
	cout<<"TLE x "<<c_t<<"\n";
	cout<<"RE x "<<c_r<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
 
    for(int i=1;i<=t;i++)
    {//cout<<"Case #"<<i<<": ";
    solve();}
    return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int main() {
    int n; 
    cin >> n;
    vector<int> v(n, 0);
    for(int i=0; i<n; i++) {
        cin >> v[i];
    }
    int longest = *max_element(v.begin(), v.end());
    int sum = accumulate(v.begin(), v.end(), 0);
    if(sum - longest > longest) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m,r;
	cin>>n>>m>>r;
	vvi cost(n,vi(n,inf));
	rep(i,n)cost[i][i]=0;
	vi in(r);
	rep(i,r)cin>>in[i];
	sort(all(in));
	rep(i,m){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		cost[a][b]=cost[b][a]=c;
	}
	rep(k,n)rep(i,n)rep(j,n)
		cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
	int out=inf;
	do{
		int sum=0;
		rep(i,r-1)sum+=cost[in[i]-1][in[i+1]-1];
		out=min(out,sum);
	}while(next_permutation(all(in)));
	cout<<out<<endl;
}








Measured memory_bytes: 384
#ifdef LOCAL111
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

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

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int r;
	while(cin >> r) {
		cout << 3 * r * r << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
const long long INF = numeric_limits<long long>::max();
template <class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    ll A, B;
    cin >> A >> B;

    bool isOdd = ((A % 2) && (B % 2));
    cout << (isOdd ? "Odd" : "Even") << endl;
    return 0;
}

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


void solve(long long H, long long A){
    int ret = H /A ;
    if (A*ret < H){
        printf("%d\n",ret+1);
    }else{
        printf("%d\n",ret);
    }

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long H;
    scanf("%lld",&H);
    long long A;
    scanf("%lld",&A);
    solve(H, A);
    return 0;
}


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

const ll infll=9223372036854775806;
const int inf=2147483646;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a,b;
	cin>>a>>b;
	cout<<max(a,b)+max(max(a,b)-1,min(a,b));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    s64 x, y;
    cin >> x >> y;

    s64 ans = 0;
    if (x == 0)
    {
        if (y < 0) ans = 1 - y;
        else ans = y;
    }
    else if (y < x)
    {
        if (x <= 0)
        {
            ans = 1 + x - y + 1;
        }
        else if (y <= 0)
        {
            if (-x > y)
            {
                ans = -y - x + 1;
            }
            else
            {
                ans = 1 + y + x;
            }
        }
        else
        {
            ans = 1 + x - y + 1;
        }
    }
    else
    {
        if (y <= 0)
        {
            ans = y - x;
        }
        else if (x <= 0)
        {
            if (y < -x)
            {
                ans = -y - x + 1;
            }
            else
            {
                ans = 1 + y + x;
            }
        }
        else
        {
            ans = y - x;
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int k,i,j,s,e,f;
  cin>>k;
  vector<int64_t> a(k+1);
  s=1;e=9;
  for (i=s;i<=e;i++) {
    if (i>k) break;
    a.at(i)=i;
  }
  f=0;
  while(f==0) {
    for(j=s;j<=e;j++) {
      if (a.at(j)%10>0) {
        if (i>k) {f=1;break;}
        a.at(i)=a.at(j)*10+a.at(j)%10-1;
        i++;
      }
      if (i>k) {f=1;break;}
      a.at(i)=a.at(j)*10+a.at(j)%10;
      i++;
      if (a.at(j)%10<9) {
        if (i>k) {f=1;break;}
        a.at(i)=a.at(j)*10+a.at(j)%10+1;
        i++;
      }
    }
    s=e+1;e=i-1;
  }
  cout<<a.at(k)<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int N;
cin >> N;
bool ans = false;
for (int i = 1;i < 10;i++) {
    for (int j = 1;j < 10;j++) {
        if (i*j == N) ans = true;

    }
}
if (ans == true) cout << "Yes" << endl;
else cout << "No" << endl;

return 0;
}

Measured memory_bytes: 256
// http://yumai6.hatenablog.com/entry/2015/12/21/222930

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

//---------------------------------------------------------------
//---------------------------------------------------------------

int N, X[100], Y[100], H[100];

signed main(){
	scanf("%d", &N);
	tuple<int, int, int>G = make_tuple(-1, -1, -1);
	REP(i, N) {
		scanf("%d %d %d", &X[i], &Y[i], &H[i]);
		if(H[i] > 0)	G = make_tuple(X[i], Y[i], H[i]);
	}
	int hh, wk;
	bool flag;
	REP(cx, 101) {
		REP(cy, 101) {
			// cx, cy から高さ hh を計算する
			hh = get<2>(G) + abs(cx - get<0>(G)) + abs(cy - get<1>(G));
			flag = true;
			REP(i, N) {
				wk = hh - abs(cx - X[i]) - abs(cy - Y[i]);
				wk = max(wk, 0);
				if(wk != H[i]) {
					flag = false;
					break;
				}
			}
			if(flag) {
				printf("%d %d %d\n", cx, cy, hh);
				return 0;
			}
		}
	}
	cout << "NG" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n,k,count=0;
    cin>>n>>k;
    int arr[n] = {0};
    for(int i=0;i<k;i++){
        int d;
        cin>>d;
        int a;
        for(int j=0;j<d;j++){
            cin>>a;
            arr[a-1] += 1;
        }
    }
    for(int i=0;i<n;i++)
        if(arr[i] == 0) count++;
    cout<<count;
    return 0;
}


Measured memory_bytes: 3596
import itertools

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

aa, bb = 0, 0
for i in range(n):
    aa *= 10
    aa += a[i]
    bb *= 10
    bb += b[i]

p = [i for i in range(1, n+1)]
na, nb = 0, 0
cnt = 0
for v in itertools.permutations(p, n):
    cnt += 1
    vv = 0
    for i in range(n):
        vv *= 10
        vv += v[i]
    if aa == vv:
        na = cnt
    if bb == vv:
        nb = cnt

print(abs(na-nb))

Measured memory_bytes: 9228
#include <stdio.h>

int main(void)
{
    int N;
    
    scanf("%d", &N);
    
    if (N / 100 == 7 ||
        N % 100 / 10 == 7 ||
        N % 100 % 10 == 7) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    
    return 0;
}

Measured memory_bytes: 1660
// B - String Rotation

#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const long double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using P = pair<lli, lli>;
// vector<P> vp;
// vp.emplace_back(a[i], b[i]);
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t, d, e, f, g;
  cin >> s;
  cin >> t;
  rep(i, 0, s.size())
  {
    if (s[i] == t[0])
    {
      count = i;
      // cout << "count: " << count << endl;
      rep(j, 0, t.size())
      {
        if (t[j] == s[count % s.size()])
        {
          ans++;
        }
        count++;
        // cout << "j: " << j
        //      << " count: " << count << endl;
      }
      // cout << "ans: " << ans << endl;
      if (ans == s.size())
      {
        cout << "Yes" << endl;
        return 0;
      }
      ans = 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
constexpr ll MOD = 1000000007;
 
#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " (" << x.first << " : " << x.second << ")" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "["; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "(" << obj.first << ", " << obj.second << ")"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print_sim_py(void) {cout << endl;}
template <class Head> void print_sim_py(Head&& head) {cout << head;print_sim_py();}
template <class Head, class... Tail> void print_sim_py(Head&& head, Tail&&... tail) {cout << head << " ";print_sim_py(forward<Tail>(tail)...);}
 
#define print(...) print_sim_py(__VA_ARGS__);
#else
#define print(...);
#endif


int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    ll ans = 0, c=0, b=0;
    
    string s;
    cin >> s;

    for(ll i=0; i<3;i++){
        if(s[i] == 'R'){
            c++;
        }else{
            ans = max(ans,c);
            c=0;
        }
    }
    ans = max(ans,c);
    
    cout << ans << endl;
 
    return 0;
}



Measured memory_bytes: 3648
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

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

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

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define 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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	vector<pair<int, string>> a(n);

	for (int i = 0; i < n; i++) {
		string s; int x; cin >> s >> x;

		a[i].first = x;
		a[i].second = s;
	}

	sort(a.begin(), a.end());

	int q; cin >> q;

	vector<string> order(q);

	for (int i = 0; i < q; i++) {
		cin >> order[i];
	}

	int index = 0;
	int weight = -1;
	for (int i = 0; i < n; i++) {
		if (a[i].second == order[index] && weight!=a[i].first) {
			index++;

			if (index == q) {
				cout << "Yes" << endl;
				return 0;
			}
			weight = a[i].first;
		}
	}

	cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 20852
#include <iostream>
#include <cmath>
#define INF 100000000000000000
#define ll long long
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  ll a[n], b[n], c[m], d[m];
  for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
  for(int i = 0; i < m; i++) cin >> c[i] >> d[i];
  for(int i = 0; i < n; i++){
    ll min = INF;
    int ans = -1;
    for(int j = 0; j < m; j++){
      ll dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if(min > dist){
        min = dist;
        ans = j + 1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    
    int S, h, m, s;
    scanf("%d", &S);
    h = S / 3600;
    s = S % 60;
    m = S % 3600 / 60;
    printf("%d:%d:%d\n", h, m, s);
    
    return 0;
    
}


Measured memory_bytes: 2036
import numpy as np
from numba import njit, i8


@njit(i8(i8, i8, i8[:]), cache=True)
def solve(N, S, A):
    MOD = 998244353
    dp = np.zeros((N + 1, S + 1), dtype=np.int64)
    dp[0][0] = 1
    for i in range(N):
        for j in range(S + 1):
            dp[i + 1][j] += 2 * dp[i][j]
            dp[i + 1][j] %= MOD
            if j + A[i] <= S:
                dp[i + 1][j + A[i]] += dp[i][j]
                dp[i + 1][j + A[i]] %= MOD
    return dp[-1][-1]


N, S = map(int, input().split())
A = np.array(input().split(), dtype=np.int64)
print(solve(N, S, A))


Measured memory_bytes: 176928
#include <bits/stdc++.h>
using namespace std;
int main()
{
 int i,r;
 double k,n,s;
 s=0.0;
 cin >> n >> k;
 if(n>=k)
 s+=(n-k+1.0)/n;
 for(i=1;i<=min(n,k-1);i++)
 {
  r=(int)ceil(log2(ceil(k/i)));
  s+=1.0/(n*pow(2,r));
 }
 cout << std::fixed << std::setprecision(12) << s;
 return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] x = new int[n + 1];
		int[] y = new int[n + 1];
		int t, xidx = 1, yidx = 1;
		x[0] = 0;
		y[0] = 0;
		for (int i = 1; i < n + 1; i++) {
			t = sc.nextInt();
			if (t == 0) {
				k--;
			} else if (t > 0) {
				x[xidx] = t;
				xidx++;
			} else if (t < 0) {
				y[yidx] = t;
				yidx++;
			}
		}

		long xcost, ycost, min = Long.MAX_VALUE;
		for (int i = 0; i <= k; i++) {
			if (k - i < xidx && 0 < yidx - i) {
				xcost = x[k - i];
				ycost = Math.abs(y[yidx - i]);
				if (xcost >= ycost) {
					ycost = 2 * ycost;
				} else {
					xcost = 2 * xcost;
				}
				min = Math.min(min, xcost + ycost);
			}
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 61100
<?php

$sc = new Scanner();

$n = $sc->nextInt();
$m = $sc->nextInt();

$list = [];

for ($i = 0; $i < $m; $i++) {
    $p = $sc->nextInt();
    $y = $sc->nextInt();
    $list[$p][$y] = $i + 1;
}
$ans_list = [];
foreach($list as $k => $v) {
    ksort($v);
    $first_id = str_pad($k, 6, '0', STR_PAD_LEFT);
    $i = 1;
    foreach($v as $a) {
        $last_id = str_pad($i++, 6, '0', STR_PAD_LEFT);
        $ans_list[$a] = $first_id . $last_id;
    }
}
ksort($ans_list);

echo implode(PHP_EOL, $ans_list) . PHP_EOL;

class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}


Measured memory_bytes: 57844
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define Inf 1000000000
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int main() {
	ll N, K;
	cin >> N >> K;
	vl H(N);
	rep(i, N) {
		cin >> H[i];
	}
	sort(H.begin(), H.end(), less<ll>());
	ll K1 = N - K;
	K1 = max((ll)0, K1);
	ll ans = 0;
	rep(i, K1) {
		ans += H[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int isprime(int x){
  if(x==2)return true;
  if(x%2==0 || x<2)return false;
  int i=3;
  while(i<=sqrt(x)){
    if(x%i==0)return false;
    i+=2;
  }
  return true;
}
int main(){
  int n;
  cin >>n;
  for(int i=n;;i++){
    if(isprime(i)){
      cout << i <<endl;
      break;
    }
  }
}

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

#define _GLIBCXX_DEBUG

int main() {
  int k, a, b;
  int count = 0;

  cin >> k >> a >> b;
  
  for(int i = a; i <= b; i++) {
    if(i % k == 0) {
      cout << "OK" << endl;
      count++;
      break;
    }
    else {
      continue;
    }
  }
  
  if(count == 0) {
    cout << "NG" << endl;
  }
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
int N, M, parent[100010], urank[100010], pn[100010];
int x, y, one, two;
int ufind(int a)
{    if (parent[a] == a) return a;
    return ufind(parent[a]);	}
void uSet(int a, int b)
{	int x,y;
    x=ufind(a);
    y=ufind(b);
    if (x==y) return;
    if (urank[x]>urank[y])         parent[y] = x;
    else if (urank[x]==urank[y]) {
        parent[y]=x;
        urank[x]++;
    }
    else parent[x]=y;	}
int main()
{
    scanf("%d %d", &N, &M);
    for(int i=1;i<=N;i++) scanf("%d", &pn[i]);
    for(int i=0; i<=N; i++) { parent[i] = i; urank[i] = 1; }
    for(int i=0; i<M; i++) {
        scanf("%d %d", &one, &two);
		uSet(one, two);
    }
    int ans=0;
    for(int i=1;i<=N;i++){
    	if(ufind(pn[i])==ufind(i)) ans++;
	}
	printf("%d",ans);
    return 0;
}


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

int main(){
	int N;
	cin >> N;
	vector<int> Ass(N);
	
	for(int i = 0;i<N;i++){
		cin >> Ass.at(i);
	}
	
	sort(Ass.begin(),Ass.end());
	reverse(Ass.begin(),Ass.end());
	
	int diffs = 0;
	
	for(int j = 0;j<N;j++){
		int c = Ass.at(j);
		
		if(j%2 == 0)
			diffs = diffs + c;
		else
			diffs = diffs - c;
	}
	
	cout << diffs << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<utility>
#include<tuple>
#include<algorithm>

using ui = unsigned int;

struct data{
	ui p, y, i, y_order;
};


int main() {
	ui n, m;
	std::cin >> n >> m;
	std::vector< data > nation;

	nation.reserve(m);
	
	for (ui i{}; i < m; ++i) {
		data di;
		std::cin >> di.p >> di.y;
		di.i = i + 1;
		nation.push_back( di );
	}

	std::sort(std::begin(nation), std::end(nation)
		, [](auto&x, auto&y) {
		return 
		x.p == y.p ?
			x.y < y.y : x.p < y.p;
	});
	
	nation[0].y_order = 1;

	for (ui i{1}; i < m; ++i) {
		auto& pre = nation[i - 1];
		auto& here = nation[i];
		
		if (pre.p == here.p) {
			here.y_order = pre.y_order + 1;
		}
		else {
			here.y_order = 1;
		}

	}

	std::sort(std::begin(nation), std::end(nation),
		[](auto&a, auto& b) {
		return a.i < b.i;
	});

	for (const auto&e : nation) {
		std::string
			ps{std::to_string(e.p)}
		, y_order_s{ std::to_string(e.y_order) };

		while (ps.size() != 6) {
			ps = "0" + ps;
		}
		while (y_order_s.size() != 6) {
			y_order_s = "0" + y_order_s;
		}
		std::cout << ps << y_order_s << "\n";
	}

	//for (auto&e : nation)
	//	std::cout << e.i << " " << e.p << " " << e.y << "\n";



	return 0;
}

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

int main(){
	int n;
	cin >> n;
	int ans = 1000 - n % 1000;
	if(ans == 1000) ans = 0;
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
using namespace std;

typedef long long ll;

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



Measured memory_bytes: 256
S=input()

if len(S)%2==1:
    print('No')
else:
    flag=0
    ans=len(S)/2
    for i in range(int(len(S)/2)):
        if S[2*i]=='h' and S[2*i+1]=='i':
            flag+=1
    if flag==ans:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> card(n);
    int r, l;
    for (int i = 0; i < m; i++)
    {
        cin >> r >> l;
        card[r-1]++;
        card[l]--;
    }
    int ans = 0, num=0;
    for (int i = 0; i < n; i++)
    {
        num+=card[i];
        if(num == m) ans++;
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repk(i,k, n) for (int i = k; i < (int)(n); ++i)
#define MAX 500010
typedef long long int ll;

using namespace std;


int main() {
	ll N, M;
	cin >> N >> M;

	priority_queue<ll> pque;
		
	for (ll i = 0; i < N; i++) {
		ll temp;
		cin >> temp;
		pque.push(temp);
	}

	rep(i,M){
		ll temp = pque.top();
		pque.pop();
		pque.push(temp / 2);
	} 

	ll ans=0;

	while (!pque.empty()) {
		ans += pque.top();
		pque.pop();
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1000000007;
main(){
    ll N,M,cnt;
    cin >> N >> M;
    if(N > M/2){
        cnt = M / 2;
    }else{
        cnt = N;
        M -= N * 2;
        cnt += M / 4;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
word = input().lower()
number = 0
while True:
    line = input()
    if line == 'END_OF_TEXT':
        break
    line = line.replace('.', ' ').replace("'", " ").replace('"', ' ').replace('?',' ').replace('!', ' ').replace(',',' ')
    wordlist = list(line.lower().split())
    number += wordlist.count(word)
print(number)

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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

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

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n,k;
int p[252521];

const int N = 1<<18;
pii seg[2*N];
int rmin(int l, int r, int a, int b, int k){
    if(r<=a || b<=l)return 1e9;
    if(l<=a && b<=r)return seg[k].first;
    int m = (a+b)/2;
    return min(rmin(l,r,a,m,2*k+1), rmin(l,r,m,b,2*k+2));
}
int rmax(int l, int r, int a, int b, int k){
    if(r<=a || b<=l)return -1e9;
    if(l<=a && b<=r)return seg[k].second;
    int m = (a+b)/2;
    return max(rmax(l,r,a,m,2*k+1), rmax(l,r,m,b,2*k+2));
}

pair<bool,pii> seg2[2*N];
pair<bool,pii> merge(pair<bool,pii> a, pair<bool,pii> b){
    if(!a.first || !b.first)return make_pair(false, pii(0,0));
    if(a.second.second > b.second.first)return make_pair(false, pii(0,0));
    return make_pair(true, pii(a.second.first, b.second.second));
}
pair<bool,pii> rsorted(int l, int r, int a, int b, int k){
    if(r<=a || b<=l)return make_pair(true, pii(1e9, -1e9));
    if(l<=a && b<=r)return seg2[k];
    int m = (a+b)/2;
    return merge(rsorted(l,r,a,m,2*k+1), rsorted(l,r,m,b,2*k+2));
}

int dat[252521];
int root(int x){
    return dat[x]<0?x:dat[x]=root(dat[x]);
}
void unite(int a, int b){
    a=root(a);b=root(b);
    if(a==b)return;
    dat[a] += dat[b];
    dat[b] = a;
}

int main(){
    scanf("%d%d",&n,&k);
    REP(i,n)scanf("%d",p+i);

    REP(i,n)seg[i+N-1] = pii(p[i],p[i]);
    FORR(i,0,N-1){
        seg[i].first = min(seg[2*i+1].first, seg[2*i+2].first);
        seg[i].second = max(seg[2*i+1].second, seg[2*i+2].second);
    }

    int C = n-k+1;
    fill(dat,dat+C,-1);
    REP(i,C-1){
        if(p[i] == rmin(i,i+k,0,N,0) && p[i+k] == rmax(i+1,i+k+1,0,N,0)){
            unite(i,i+1);
        }
    }

    // partially sorted
    REP(i,N)seg2[i+N-1] = make_pair(false, pii(0,0));
    REP(i,n)seg2[i+N-1] = make_pair(true, pii(p[i],p[i]));
    FORR(i,0,N-1){
        seg2[i] = merge(seg2[2*i+1], seg2[2*i+2]);
    }
    int origid = -1;
    REP(i,C){
        if(rsorted(i,i+k,0,N,0).first){
            if(origid == -1){
                origid = i;
            }else{
                unite(origid, i);
            }
        }
    }

    int ans = 0;
    REP(i,C)if(root(i)==i)ans++;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 11520
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int a = s[0];
            int b = s[1];
            int c = s[2];

            var ls = new List<int>();

            for (int i = 0; i < 3; i++)
            {
                if (s.Max() != s[i]) ls.Add(s[i]);
            }
            if (ls.Count == 0)
            {
                WriteLine(0);
            }
            else if (ls.Count == 1)
            {
                if ((s.Max() - ls[0]) %2 ==0)
                {
                    WriteLine((s.Max() - ls[0]) / 2);
                }
                else
                {
                    int ans = (s.Max() - ls[0]) / 2;
                    ans += 2;
                    WriteLine(ans);
                }
            }
            else
            {
                int ans = 0;
                int max = ls.Max();
                int min = ls.Min();

                ans += s.Max() - max;
                min += ans;

                if ((s.Max() - min) %2 == 0)
                {
                    ans += (s.Max() - min) / 2;
                    WriteLine(ans);
                }
                else
                {
                    ans += (s.Max() - min) / 2;
                    ans += 2;
                    WriteLine(ans);
                }

            }
        }
        
    }



}

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

int main()
{
    long long n,m,ans,a;

    scanf("%lld %lld",&n,&m);

    if(n>1 && m>1)
    {
        a=2*(n+m)-4;
        ans=n*m-a;
    }

    else
    {
         if(n==1 && m==1) ans=1;
         else if(n<=2 && m<=2) ans=0;        
         else ans=n*m-2;
    }

    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include <cassert>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::max;
using std::min;
using std::abs;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 5000000000000;
//typedef std::pair<int, int> P;
struct edge { int to;double cost; };
#define VMAX 1010

     ll N,M;
     ll A[100010],B[100010];
     ll K[11],S[11],P[11];
     ll ans;

int main() {
    cin>>N>>M;
    REP(i,M){
        cin>>K[i];
        int a=0,b;
        REP(k,K[i]){
            cin>>b;
            a|=1<<(b-1);
        }
        S[i]=a;
    }
    REP(i,M)cin>>P[i];
    REP(Bit,1<<N){
        bool f=true;
        REP(i,M){
            int size=__builtin_popcount(S[i]&Bit);
            if(size%2!=P[i]){f=false;break;}
        }
        if(f)ans++;
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main(){
    string s,t;
    cin >> s >> t;
    int ans = 0;
    for(int i=0; i<3 ; i++){
        if(s[i] == t[i]){
            ans ++;
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;


bool solve(){
	
	vector<double> x(4);
	vector<double> y(4);
	for(int i=0;i<4;i++){
		cin>> x[i]>> y[i];
	}
	double a,b;
	a = (y[1]-y[0]) / (x[1]-x[0]);
	b = (y[3]-y[2]) / (x[3]-x[2]);
	
	if(a==b){
		cout<< "YES"<< endl;
	}else{
		cout<< "NO"<< endl;
	}
	

	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	int n;
	cin>> n;
	for(int i=0;i<n;i++){
		solve();
	}

	return 0;
}

 

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
constexpr auto INF = INT_MAX/2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

ll lpow(int p, int q) {
	ll ans = 1;
	ll pp = p;
	while (q) {
		if (q % 2) {
			ans *= pp;
			ans %= MOD;
		}
		q /= 2;
		pp *= pp;
		pp %= MOD;
	}
	return ans;
}
V<ll> fac, invfac;
void precom(int n) {
	fac.resize(0);invfac.resize(0);
	rep(i, n + 1) {
		if (i == 0)fac.push_back(1);
		else fac.push_back((fac[i - 1] * i) % MOD);
		invfac.push_back(lpow(fac[i], MOD - 2));
	}
	return;
}
ll com(int n, int r) {
	if (n < r || n < 0 || r < 0)return 0;
	int k = n - r;
	ll ans = fac[n];
	ans *= invfac[r];
	ans %= MOD;
	ans *= invfac[k];
	ans %= MOD;
	return ans;
}

int main() {

	int n, k;
	cin >> n >> k;

	precom(2 * n);
	if (k >= n) { cout << com(2 * n - 1, n) << endl;return 0; }

	ll ans = 0;
	rep(i, k + 1) {
		ll ansi = 1;
		ansi *= com(n, i);
		ansi %= MOD;
		ansi *= com(n - 1, i);
		ansi %= MOD;
		ans += ansi;
		ans %= MOD;
	}

	cout << ans << endl;

}

Measured memory_bytes: 10592
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
bool rev(long long int a,long long int b)
{
    if(a>b)return true;
    else return false;
}
bool compa(pair<string,pair<int,int>>a,pair<string,pair<int,int>>b)
{
    if(a.first==b.first)
    {
        if(a.second.first>b.second.first)
        return true;
        else
        return false;
    }
    if(a.first<b.first)
    return true;
    else 
    return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    long long int n;
    cin>>n;
    long long int ans=0;
    for(long long int i=0;i<n;i++)
    {
        long long int num;cin>>num;
        ans+=num-1;
    }
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int N;
std::string S;

int check(int l) {
  int res = 0, tmp = 0;
  for(int i = 0; i < N-l; ++i) {
    if(S[i] == S[i+l]) ++tmp;
    else { res = std::max(res, tmp); tmp = 0; }
  }
  return std::max(res, tmp);
}

int main() {
   std::cin >> N >> S;
  int ans = 0;
  for(int l = N/2; l > ans; --l) {
    ans = std::max(ans, std::min(l, check(l)));
    if(l != N-l) ans = std::max(ans, check(N-l));
  }
  fin(ans);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define N 2000000
#define INF 50000000

int H,a[N+1];

void maxh(int);
void swap(int *,int *);
int extract();
void incrk(int,int);
void insert(int);

int main(){
  int key;
  char str[10];

  while(1){
    scanf("%s",str);
    if(strcmp(str,"end")==0 ) break;
    else if(str[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }else{
      printf("%d\n",extract());
    }

  }

}

void maxH(int i){
  int l,r,b;
  l=2*i;
  r=2*i+1;
    if(l<=H&&a[l] >a[i]) b =l;
    else b = i;

    if(r<=H&&a[r]>a[b]) b =r;
  if(b!=i){
    swap(&a[i],&a[b]);
    maxH(b);
    
  }
}

void swap(int *a,int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
  return;
}

int extract(){
  int mv;
  if(H<1)return -INF;
  mv = a[1];
  a[1] = a[H--];
  maxH(1);
  return mv;

}

void incrk(int i,int k){
  if(k<a[i]) return;
  a[i]=k;
  while(i>1&&a[i/2]<a[i]){
    swap(&a[i],&a[i/2]);
    i=i/2;
  }
}

void insert(int k){

  H++;
  a[H]= -INF;
  incrk(H,k);

}



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

int main(){
  	int y, m, d;
  	char a,b;
  	cin >> y >> a >> m >> b >> d;
  	string ans;
  	if(y < 2019){
    	ans = "Heisei";
    }else if(m < 4){
      	ans = "Heisei";
    }else if(m == 4 && d <= 30){
    	ans = "Heisei";
    }else{
    	ans = "TBD";
    }
  	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import itertools
import pprint
input = lambda: sys.stdin.readline().rstrip()

H, W, K = map(int, input().split())
S = [[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    S[i] = list(map(int, input()))

Stsum = [[0 for _ in range(W + 1)] for _ in range(H + 1)]
for i in range(H):
    for j in range(W):
        Stsum[i + 1][j + 1] = Stsum[i + 1][j] + S[i][j]
for j in range(W):
    for i in range(H):
        Stsum[i + 1][j + 1] += Stsum[i][j + 1]


def count_white(l, r, u, b):
    return Stsum[b][r] - Stsum[u][r] - Stsum[b][l] + Stsum[u][l]


def solve():

    comb = list(itertools.product(range(2), repeat=H - 1))

    ans = 10 ** 9 + 7
    for c in comb:

        hc = [0] + [i + 1 for i, x in enumerate(c) if x == 1] + [H]
        l, w = 0, 1
        cut_count = 0
        search = False
        p_cut = True

        while w <= W:
            cut = True
            for h in range(0, len(hc) - 1):
                if count_white(l, w, hc[h], hc[h + 1]) > K:
                    cut = False
                    break
            else:
                search = True

            if not cut:
                if search:
                    l = w - 1
                    cut_count += 1
                    search = False
                else:
                    p_cut = False
                    break
            else:
                w += 1

        if p_cut:
            ans = min(ans, cut_count + len(hc) - 2)

    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 4080
#include <stdio.h>
int main(){
    int X, Y;
    scanf("%d %d", &X, &Y);
    if(Y<2*X){
        printf("No");
    }else if(4*X<Y){
        printf("No");
    }else if(((Y-2*X)%2==0)&&((4*X-Y)%2==0)){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i=0; i<n; i++) cin >> h[i];

    vector<int> hc(n,0);
    vector<int> in(n);
    iota(in.begin(), in.end(), 0);
    auto c = [&](const int& i){return h[i]!=hc[i];};
    int ans = 0;
    while(any_of(in.begin(), in.end(), c)) {
        int i = 0;
        ans++;
        while(h[i] == hc[i]) i++;
        while(i<n && h[i] != hc[i]) hc[i++]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256