akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int x,y; cin>>x>>y;
    cout<<x+y/2<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	string s;
	cin >> s;
	vi cnt(30, 0);
	ll ans = 1;
	rep(i, s.size()){
		cnt[s[i] - 'a']++;
		ans += i + 1 - cnt[s[i] - 'a'];
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/



Measured memory_bytes: 720
#include<stdio.h>

int parent[100001];
int count[100001];
int root[10000][10000];
int flag[100001];
int depth(int);

int main()
{
  int i,n,k,id,c,node;

  scanf("%d",&n);
  
  for(i=0; i<n; i++){
    parent[i] = -1;
    flag[i] = 1;
  }
  
  for(i=0; i<n; i++){
    scanf("%d %d",&id,&k);
    count[id]=k;
    node=0;
    while(k-->=1){
      scanf("%d",&c);
      root[id][node++]=c;
      parent[c]=id;
      flag[id]=0;
    }
  } 
    
    for(i=0; i<n; i++){
      int j,l;
      printf("node %d: parent = %d, depth = %d, ",i,parent[i],depth(i));
      if(flag[i]==1 && depth(i)==0){
	printf("root, []\n");
      }

      else if(flag[i] == 1)
	printf("leaf, []\n");

      else if(depth(i) == 0){
	printf("root, [");
	for(j=0; j<count[i]-1; j++){
	    printf("%d, ",root[i][j]);
	    }
	  printf("%d]\n",root[i][j]);
	  l=j+1;
      }

      else{
	printf("internal node, [");
	for(j=0; j<count[i]-1; j++){
	    printf("%d, ",root[i][j]);
	    }
	  printf("%d]\n",root[i][j]);
      }
    }
    return 0;
}

int depth(int i){
  if(parent[i] == -1)return 0;
  else return depth(parent[i])+1;
}




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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ordered_set tree<ll int, null_type,less<ll int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  2000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,m,n;
        cin>>n;
        vi v(n);
        cin>>v;
        vi l(n),r(n);
        l[0]=v[0];
        for(i=1;i<n;i++)
            l[i]=max(l[i-1],v[i]);
        r[n-1]=v[n-1];
        for(i=n-2;i>=0;i--)
            r[i]=max(r[i+1],v[i]);
        for(i=0;i<n;i++)
        {
            if(i==0)
            {
                cout<<r[1]<<endl;
                continue;
            }
            if(i==n-1)
            {
                cout<<l[n-2]<<endl;
                continue;   
            }
            cout<<max(l[i-1],r[i+1])<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 6272
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b)
    {
        if(b==c)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
    }
    else
    {
        if(a==c)
            cout<<"Yes"<<endl;
        else if(b==c)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
// C - Go Home
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ote(x) cout<<(x)<<endl

int main(){
	ll x;
	cin>>x;

	ll ans = 0;
	ll n = 0;
	for(ll i=1; i<=x; i++){
		n += i;
		if(n>=x){
			ans = i;
			ote(ans);
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N, K, a;
ll DP[100001], S[100002];

int main() {
	cin >> N >> K;
	DP[0] = 1;
	for (int i = 0; i != N; ++i) {
		cin >> a;
		for (int i = 0; i != K + 1; ++i) {
			S[i + 1] = DP[i] + S[i];
		}
		for (int i = 0; i != K + 1; ++i) {
			DP[i] = (S[i + 1] - S[max(i - a, 0)]) % mod;
		}
	}
	cout << DP[K] << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

//累積和
// vectorっぽく使う
template <typename T>
struct cumulative_sum {
    // data[i]:元の数列
    vector<T> data;
    // sum[i]:[0,i)の和
    vector<long long int> sum;
    //要素数を指定して初期化
    cumulative_sum(const int n) {
        data.assign(n, 0);
    }
    T& operator[](const int k) {
        return data[k];
    }
    // dataに基づいてsumを構築
    void build() {
        sum.assign(data.size() + 1, 0);
        for (int i = 0; i < (int)data.size(); i++) {
            sum[i + 1] = sum[i] + data[i];
        }
    }
    //[a,b)の和を求める
    long long int query(const int a, const int b) {
        return sum[b] - sum[a];
    }
};

int main() {
    int n;
    cin >> n;
    cumulative_sum<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(all(a.data));
    a.build();
    int ans = 1;
    // i番目のやつが行けるかみる
    for (int i = n - 2; i >= 0; i--) {
        if (a.sum[i + 1] * 2 >= a[i + 1]) {
            ans++;
        } else {
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


int main(void){

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

    int M;
    cin >> M;
    int P[M], X[M];
    for(int j = 0; j < M; j++){
        cin >> P[j] >> X[j];
    }
 
    for(int  j = 0; j < M; j++){
        int sum = 0;
        for(int i = 0; i < N; i++){
            if((i+1) == P[j]){
                sum += X[j];
            }else{
                sum += T[i];
            }
        }
        cout << sum << endl;
        sum = 0;
    }

    return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read

N, A, B, *P = map(int, read().split())

a = 0
b = 0
c = 0
for i in P:
    if i <= A:
        a += 1
    elif A < i <= B:
        b += 1
    else:
        c += 1

print(min(a, b, c))


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

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int i = 0, j = n - 1;
    int ans = 0;
    while(j > i){
        if(s[i] != s[j]){
            if(s[i] == 'x'){
                ans++;
                j++;
            }
            else if(s[j] == 'x'){
                ans++;
                i--;
            }
            else{
                cout << -1 << endl;
                return 0;
            }
        }
        i++;
        j--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
		cin.tie(0);
		cout.tie(0);
	 string s,p;
	 cin>>s>>p;
	 int dp[s.length()+1][p.length()+1];
	 memset(dp,0,sizeof(dp));
	 for(int i=1;i<=s.length();i++)
	 {
	 	for(int j=1;j<=p.length();j++)
	 	{
	 		if(s[i-1]!=p[j-1])
	 		dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
	 		else
	 		dp[i][j]=1+dp[i-1][j-1];
	 
		 }
	 }
	 int k=dp[s.length()][p.length()];
	 char r[k];
	 int i=s.length();
	 int j=p.length();
	 while(i>0 && j>0){
         if(s[i-1] ==p[j-1]){
           r[k-1] = s[i-1]; // Put current character in result
          i--; j--; k--;
        }else if (dp[i-1][j]>dp[i][j-1])
          i--;
        else
          j--;
       }
	
	 for(char c:r)
	 cout<<c;
	
}

Measured memory_bytes: 35456
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 

int main(){
	int N,a,b;
	long long K,count[100010]={};
	cin >> N >> K;

	for(int i=0; i<N; i++){
		cin >> a >> b;
		count[a]+=b;
	}

	for(int j=0; j<=100000; j++){
		if(K<=count[j]){
			cout << j << endl;
			return 0;
		}
		K -= count[j];
	}
}

Measured memory_bytes: 1024
#define REP(i,n) for (int i=0;i<(n);i++)

#include <iostream>
using namespace std;
const int MAX = 8;


int set,n;
int sx,sy;
char field[MAX][MAX];

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


void dfs (int x,int y){
	field[x][y] = '0';
	REP(i,12){
		int nx = x + dx[i], ny = y + dy[i];
			if (0 <= nx && nx < MAX && 0 <= ny && ny < MAX && field[nx][ny] == '1') 
				dfs(nx,ny);
		}
	return ;
}


void solve(){
	dfs(sy,sx);
	REP(i,MAX){
		REP(j,MAX){
				cout << field[i][j];
		}
		cout << endl;
	}
}

int main(){
	cin >> n;
	REP(set,n){
		REP(i,MAX){
			REP(j,MAX){
				cin >> field[i][j];
				}
			}
		cin >> sx >> sy;
		sx --; sy --;
		cout << "Data " << set+1 << ":" << endl;
		solve();
	}
}

Measured memory_bytes: 2984
xn = list(map(int, input().split()))
pn = list(map(int, input().split()))

for i in range(100):
    if(not ((xn[0] - i) in pn)):
        print(xn[0] - i)
        break
    if(not ((xn[0] + i) in pn)):
        print(xn[0] + i)
        break

Measured memory_bytes: 9188
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    int a[n];
    int min_cnt = 0;
    bool z_flg = false;
    for( int i = 0; i < n; ++i ) {
        cin >> a[i];
        if( a[i] < 0 ) ++min_cnt;
        if( !a[i] ) z_flg = true;

    }

    LL res = 0;
    LL tmp = 0;
    if( z_flg ) {
        for( int i = 0; i < n; ++i ) res += abs( a[i] );
        
    } else {
        if( !( min_cnt % 2 ) ) {
            for( int i = 0; i < n; ++i ) res += abs( a[i] );

        } else {
            int min_pos, min_v = INF;
            for( int i = 0; i < n; ++i ) {
                if( min_v > abs( a[i] ) ) {
                    min_v = abs( a[i] );
                    min_pos = i;

                }
            }

            for( int i = 0; i < n; ++i ) {
                if( i != min_pos ) res += abs( a[i] );
                else {
                    if( a[i] < 0 ) res += a[i];
                    else res += -a[i];

                }
            }
        }
    }


    cout << res << endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
using namespace std;

long long upperP2(long long a){
    long long r = 2;
    while (r <= a)
    {
        r *= 2;
    }
    return r;
}

int main(){
    int n;
    map<long long, int> m;

    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        long long a;
        scanf("%lld", &a);
        m[a] += 1;
    }

    int r = 0;

    for (auto i = m.rbegin(), e = m.rend(); i != e; ++i) {
        long long a = i->first;
        int c = i->second;
        if(c == 0){
            continue;
        }
        long long s = upperP2(a) - a;
        if(a == s){
            r += c / 2;
        }else{
            auto f = m.find(s);
            if(f != m.end()){
                int u = min(c, f->second);
                r += u;
                f->second -= u;
            }
        }
    }

    printf("%d\n", r);

    return 0;
}

Measured memory_bytes: 12800
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;


int main() {
	int a, b;
	cin >> a >> b;
	if (a!=2&&b!=2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

bool valid[1005];

int main() {
  valid[1] = true;
  for(int i = 2; i <= 1000; i++) {
    for(int j = i*i; j <= 1000; j *= i) {
      valid[j] = true;
    }
  }
  int n;
  scanf("%d", &n);
  while(!valid[n]) n--;
  printf("%d\n", n);
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD =1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1LL;}return res%p;}
const int N=1e6+2,M=1e6+2;
map<int,bool> vis;
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	// freopen("out10.txt","w",stdout);
	#endif
	int k;
	cin>>k;
	vector<int> v;
	for(int i=1;i<=9;i++)
	{
		v.pb(i);
	}
	int cnt=0;
	while(v.size())
	{
		sort(all(v));
		vector<int> temp;
		for(auto x:v)
		{
			cnt++;
			// cout<<x<<" ";
			if(cnt==k)
			{
				cout<<x;
				return 0;
			}
		}
		for(auto x:v)
		{
			int lol=x%10;
			int pos1=-1,pos2=-1,pos3=-1;
			if(lol-1>=0)
			{
				pos1=x*10+(lol-1);
			}
			if(lol+1<=9)
			{
				pos2=x*10+(lol+1);
			}
			pos3=x*10+lol;
			if(vis.count(pos3)==0)
			{
				vis[pos3]=true;
				temp.pb(pos3);
			}
			if(pos1!=-1)
			{
				if(vis.count(pos1)==0)
				{
					vis[pos1]=true;
					temp.pb(pos1);
				}
			}
			if(pos2!=-1)
			{
				if(vis.count(pos2)==0)
				{
					vis[pos2]=true;
					temp.pb(pos2);
				}
			}
		}
		swap(temp,v);
	}

}
// Don't be afraid to fail. Be afraid not to try.
// "Become grindian instead of greendian" - aryanc403
// When you want to succeed as bad as you want to breathe, only then you’ll Be Successful!
// No Matter,How Fast You Are Driving If You Are Driving in a Wrong Direction You Will Never Reach Your Destination
// When failures hit you, you hit the failures back with Bounce Back!
// When you face failures, Don’t change your goal, Change your strategy!

Measured memory_bytes: 14072
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int main(){
	int N,K,a[5000],s[5000],cnt=0;
	cin>>N>>K;
	rep(i,N) cin>>a[i];
	rep(i,N) s[i]=K;
	rep(i,N)rep(j,N)if(i!=j){
		if(s[i]>=a[j]) s[i]-=a[j];
	}
	rep(i,N)if(s[i]>a[i])cnt++;
	cout<<cnt<<endl;
}

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

struct node{
	int Next,y;
}Pth[200005];
int n,k,cnt,head[100005];
inline void add(int x,int y){
	cnt++;
	Pth[cnt]={head[x],y};
	head[x]=cnt;
}
ll mod=1000000007;

ll dfs(int x,int colors,int fa){
	ll cc=colors,val=1;
	for (int i=head[x];i;i=Pth[i].Next){
		int y=Pth[i].y;
		if (y==fa) continue;
		val*=(cc--)*dfs(y,max(colors-1,k-2),x)%mod;
		val%=mod;
	}
	return val;
}

int main(){
	cin>>n>>k;
	for (int i=1;i<n;++i){
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	cout<<k*dfs(1,k-1,0)%mod<<endl;
	return 0;
}

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

int main() {
    //input
    string str;
    cin >> str;

    char a = 'a';
    char b = 'b';
    char c = 'c';

    int sum = 0;
    for(char c : str){
        sum += c;
    }
    if(a+b+c == sum){
        cout << "Yes";
    }else{
        cout << "No";
    }

    return 0;
}

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

int main(){
    int H, W;

    while (1) {
        cin >> H >> W;

        if (H == 0 && W == 0)break;

        for (int i = 1; i <= H; i++){
            for (int j = 1; j <= W; j++){
                if ((i + j) % 2 == 0){
                    cout << "#";
                } else {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <string>
#include <stdio.h>
#include <sstream>

using namespace std;
void swap(int &a, int &b);

int main()
{
	int num;
	cout << fixed << setprecision(9);
	int x[100], y[100];
	
	cin >> num;
	for (int i = 0; i < num; ++i)
		cin >> x[i];
	for (int i = 0; i < num; ++i)
		cin >> y[i];
	
	double d1 = 0.0, d2 = 0.0, d3 = 0.0, dinf = 0.0;

	for (int i = 0; i < num; ++i)
	{
		double temp = fabs(x[i] - y[i]);
		d1 += temp;
		d2 += temp*temp;
		d3 += temp*temp*temp;
		if (dinf < temp)
			dinf = temp;
	}

	cout << d1 << endl
		<< sqrt(d2) << endl
		<< pow(d3, 1.0 / 3.0) << endl
		<< dinf << endl;

	return 0;
}





Measured memory_bytes: 3444
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        long h = sc.nextLong();
        ArrayList<Long> a = new ArrayList<>();
        ArrayList<Long> b = new ArrayList<>();
        for(int i = 0; i < n; i++){
            a.add(sc.nextLong());
            b.add(sc.nextLong());
        }
        Collections.sort(a,Comparator.reverseOrder());
        Collections.sort(b,Comparator.reverseOrder());
        int ans = (int)Math.ceil((double)h/(double)a.get(0));
        int cnt = 0;
        for(long v : b){
            cnt++;
            h -= v;
            if(h < 0) h = 0;
            ans = Math.min(ans, cnt + (int)Math.ceil((double)h/(double)a.get(0)));
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

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

    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 49940
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>


#include <map>

using namespace std;

typedef long long LL;

LL n, m, p[100010], nump, ans;

void getp() {
    p[0] = 2;
    for (int x = 3; x <= m; ++x) {
        bool succ = true;
        for (int j = 0; j <nump && succ; ++j) {
            if (x % p[j] == 0) succ = false;
        }
        if (succ) p[++nump] = x;
    }
}

int main() {
    cin >> n >> m;
    
    LL b = LL(sqrt(m));

    for (LL i = 1; i <= b; ++i) {
        if (m % i == 0) {
            if (i * n <= m)
            ans = max(i, ans);
            LL ii = m / i;
            if (ii * n <= m)
            ans = max(ii, ans);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import collections


def comb(n):
    return n * (n-1)/2


s = input()
ans = 0
lst_mod = [0]*2019  # O(N)で回した連続値のmod(2019)の値
lst_mod[0] += 1
num, dim = 0, 1
for char in reversed(s):
    num += int(char)*dim
    num %= 2019
    dim *= 10
    dim %= 2019  # サイズを大きくしたくないからmod(2019)を使う
    lst_mod[num] += 1

for mod in lst_mod:
    ans += comb(mod)
print(int(ans))


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

using namespace std;
typedef long long ll;

int main(){
    string s;
    getline(cin, s);
    ll ans = 1000;
    for(int i = 0; i < s.size() - 2; ++i){
        ll num = 
            100 * (s.at(i) - '0') +
            10 * (s.at(i + 1) - '0') +
            (s.at(i + 2) - '0');
        ans = min(ans, abs(num - 753));
    }
    cout << ans << endl;
    return 0;
}


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
typedef pair<int, int> the;

const int INF = 1 << 29;
const ll LINF = 1LL << 60;

int main()
{
	int n, w;
	cin >> n >> w;
	vector<int> W(n, 0), V(n, 0);
	rep(i, n)  cin >> W[i] >> V[i];

	vector<vector<ll>> dp(n + 1, vector<ll>(w + 1, 0));  //初期化
	//dp[0][i] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= w; j++) {
			chmax(dp[i + 1][j], dp[i][j]);
			if (j - W[i] >= 0)  chmax(dp[i + 1][j], dp[i][j - W[i]] + V[i]);
		}
	}
	cout << dp[n][w] << endl;
}

Measured memory_bytes: 80256
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-9;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int t[110];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		int c;scanf("%d",&c);
		for(int j=0;j<c;j++){
			int d;scanf("%d",&d);d--;
			t[d]++;
		}
	}
	int ret=0;
	for(int i=0;i<a;i++)if(!t[i])ret++;
	printf("%d\n",ret);
}

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

const int INF=1e9;
int dx[2]={1,0};
int dy[2]={0,1};
int main(){
    int h,w;
    cin >> h >>w;
    vector<string> s(h);
    rep(i,h){
        cin >> s[i];
    }
    vector<vector<int>> dp(h, vector<int>(w,INF));
    if(s[0][0]=='#') dp[0][0]=1;
    else dp[0][0]=0;
    rep(i,h){
        rep(j,w){
            char now = s[i][j];
            rep(k,2){
                int nx,ny;
                nx=i+dx[k];ny=j+dy[k];
                if(nx<h&&ny<w){
                    if(s[nx][ny]!=now)dp[nx][ny]=min(dp[i][j]+1,dp[nx][ny]);
                    else dp[nx][ny]=min(dp[i][j],dp[nx][ny]);
                }
            }
        }
    }
    if(s[h-1][w-1]=='#')dp[h-1][w-1]++;
    cout << dp[h-1][w-1]/2 << endl;
    return 0;
}

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

int main() {
#ifdef _DEBUG
	freopen("in" , "r", stdin );
	//freopen("out", "w", stdout);
#endif
	string s; cin >> s;
	for (int i = 0; i < (int) s.size() - 1; i++) {
		if (s[i] != s[i + 1]) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
}

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

int main(){
    int a[10];
    for(int i=0;i<10;i++){
        cin >> a[i];
    }
    sort(a,a+10,greater<int>());
    for(int i=0;i<3;i++){
        cout << a[i] << endl;
    }
    return 0;
}

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

int main(){
  double W,H,x,y;
  cin >> W >> H >> x >> y;
  
  double ans = W/2*H;
  
  int num = (W==2*x && H==2*y) ? 1 : 0;
  
  printf("%.10f %d\n",ans ,num);
  
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 3e3 + 5;
const int mod = 998244353;
const int inf = 1e9 + 9;
 
int a[N], dp[N][N], endat[N][N];

signed main() {
    IOS;
    int n, s;
    cin >> n >> s;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    int ans = 0;
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++){
        endat[i][a[i]] += i;
        for(int j = 0; j <= s; j++){
            dp[i][j] = dp[i-1][j];
            endat[i][j] += endat[i-1][j];
            if(a[i] <= j){
                dp[i][j] += dp[i-1][j-a[i]];
                endat[i][j] += endat[i-1][j-a[i]];
            }
            endat[i][j] %= mod;
            //cout << endat[i][j] << " ";
        }
        //cout << endl;
    }
    for(int i = 1; i <= n; i++){
        ans += ((endat[i][s] - endat[i-1][s] + mod)*(n-i+1)) % mod;
        ans %= mod;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 141312
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i,j,k,l,a,b,c,t,m;
    string s;
    cin>>s;
    if(s[0]=='7'||s[1]=='7'||s[2]=='7')
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int x;
	cin >> x;
	cout << x / 500 * 1000 + x % 500 / 5 * 5 << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
int main()
{
	int x=0,y=0,m=0;
	char c[1000000];
	scanf("%s",&c);
	int n=strlen(c);
	for(int i=0;i<n;i++)
	if (x<=y)
	{
		x++;
		if (c[i]=='p')
		m--;
	}
	else
	{
		y++;
		if (c[i]=='g')
		m++;
	}
	printf("%d\n",m);
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
s = 0
t = 0
for i in range(n):
    t = t + l[i]
m = abs(t - s)

for i in range(n):
    s = s + l[i]
    t = t - l[i]
    if abs(m) > abs(t - s):
        m = abs(t - s)

print(m)

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

#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000000

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;

    cin >> n;

    if(n%2){
        cout << 0 << endl;
        return 0;
    }

    ll st = 10;
    ll ans = 0;
    while((n/st) > 0){
        ans += (n/st);

        st = st*5;
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
n=int(input())
ki=[[] for _ in range(n)]
for i in range(n-1):
  a,b,c=map(int,input().split())
  ki[a-1].append([b-1,c])
  ki[b-1].append([a-1,c])
q,k=map(int,input().split())
s=[0]*n
from collections import deque
d=deque()
d.append(k-1)
while d:
  g=d.popleft()
  for i in ki[g]:
    if s[i[0]]:
      continue
    d.append(i[0])
    s[i[0]]=s[g]+i[1]
for i in range(q):
  x,y=map(int,input().split())
  print(s[x-1]+s[y-1])

Measured memory_bytes: 93472
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a) //追加//
#define pp() pop_back() //削除//
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())

signed main(){
  int n,m;
  cin>>n>>m;
  
  int ans=0;
  V<int> b(m,0);
  for(int i=0; i<n; i++){
    int k;
    cin>>k;
    
    fo(j,k){
      int a;
      cin>>a;
      b[a-1]++;
    }

  }
  fo(i,m){
    if(b[i]==n)
      ans++;
  }
  cout<<ans<<endl;
}


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

max_a = max(a)
dp = [0] * (max_a + 1)

for i in a:
    for j in range(i, max_a+1, i):
        dp[j] += 1
        
print([dp[i] for i in a].count(1))

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

ll dp[100005][4];
int main(){
    string s;
    cin >> s;
    for(int i = s.size(); i >= 0; i--){
        for(int j = 3; j >= 0; j--){
            if(i == s.size()) dp[i][j] = j == 3 ? 1 : 0;
            else{
                dp[i][j] = dp[i+1][j] * (s[i] == '?' ? 3LL : 1LL);
                if(j < 3 && (s[i] == '?' || s[i] == "ABC"[j])) dp[i][j] += dp[i+1][j+1];
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[0][0] << endl;
    return 0;
}

Measured memory_bytes: 3584
import sys
input = sys.stdin.readline
n,m,q = map(int,input().split())
def func(a):
    return int(a)-1
grid = [[0]*n for i in range(n)]
pq = [0]*q
for i in range(m):
    l,r = map(func,input().split())
    grid[l][r] += 1
for i in range(q):
    pq[i] = list(map(func,input().split()))

s = [[0]*n for i in range(n)]
s[0][0] = grid[0][0]
for i in range(1,n):
    s[i][0] = s[i-1][0] + grid[i][0]
for i in range(1,n):
    s[0][i] = s[0][i-1] + grid[0][i]

for i in range(1,n):
    for j in range(1,n):
        s[i][j] = s[i-1][j] + s[i][j-1] - s[i-1][j-1] + grid[i][j]

anslist = [0]*q
for i in range(q):
    anslist[i] = s[pq[i][1]][pq[i][1]] - s[pq[i][1]][pq[i][0]-1] - s[pq[i][0]-1][pq[i][1]] + s[pq[i][0]-1][pq[i][0]-1] if pq[i][0] > 0 else s[pq[i][1]][pq[i][1]]
#print(grid)
#print(s)
for ans in anslist:
    print(ans)


Measured memory_bytes: 68188
#include <stdio.h>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, s, t, a, b, now, ans, max = 0;
  scanf("%lld%lld%lld", &n, &s, &t);
  --s, --t;
  vector<ll> vec[n];
  ll d[n], be[n];
  for(i = 0; i < n - 1; ++i) {
    scanf("%lld%lld", &a, &b);
    vec[--a].push_back(--b);
    vec[b].push_back(a);
  }
  for(i = 0; i < n; ++i) d[i] = -1;
  d[t] = 0, be[t] = t;
  queue<ll> q;
  q.push(t);
  while(q.size()) {
    now = q.front(), q.pop();
    for(i = 0; i < vec[now].size(); ++i) if(d[vec[now][i]] == -1) 
      be[vec[now][i]] = now, d[vec[now][i]] = d[now] + 1, q.push(vec[now][i]);
  }
  ans = d[s] / 2;
  now = (d[s] - 1) / 2;
  for(i = 0; i < now; ++i) s = be[s];
  t = be[s];
  for(i = 0; i < n; ++i) d[i] = -1;
  d[s] = 0, d[t] = 0;
  q.push(s);
  while(q.size()) {
    now = q.front(), q.pop();
    if(d[now] > max) max = d[now];
    for(i = 0; i < vec[now].size(); ++i) if(d[vec[now][i]] == -1) 
      d[vec[now][i]] = d[now] + 1, q.push(vec[now][i]);
  }
  printf("%lld", ans + max);
  return 0;
}

Measured memory_bytes: 7936
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	var s string
	fmt.Fscan(r, &n)
	fmt.Fscan(r, &s)

	ans := make([]byte, len(s))
	for i := 0; i < len(s); i++ {
		ans[i] = convert(s[i], n)
	}

	fmt.Println(string(ans))
}

func convert(c byte, n int) byte {
	ret := c + byte(n)
	if ret > 'Z' {
		ret -= 26
	}
	return ret
}

Measured memory_bytes: 896
#include<stack>
#include<iostream>
#include<vector>
#include<map>
#include<unordered_map>
#include<string>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(int) (n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
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; }
using namespace std;
int main(){
int n;
cin >> n;
int digit=n%10;
if(digit==3){cout << "bon" << endl;}
else if(digit==0 || digit==1 || digit==6 || digit==8){cout << "pon" << endl;}
else cout << "hon" << endl;
return 0;
}

Measured memory_bytes: 3636
#include <iostream> 
#include <bits/stdc++.h>
#include <vector> 
#include <algorithm> 
#include <string>
#include <cmath>
#include <iomanip> 
#include<climits> 
#include <utility>   
#include <set>
#include <numeric> 
#include <iterator>
#include <map> 
using namespace std; 
#define ll unsigned long long int
typedef pair<ll,ll> p; 
 

int main() {
ll n,m;
cin>>n>>m;
if(n==m)
    cout<<"Yes"<<endl;
else
cout<<"No"<<endl;

    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        if(x <= W-r&&x >= r&&y<=H-r&&y>=r){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
        
        sc.close();
    }
}


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

int main(){
  string S; cin >> S;
  int n = S.size()-1;
  long long ans=0;
  
  for(int bit=0; bit<(1<<n); bit++){
    int j=0;
    for(int i=0; i<n; i++){
      if(bit & (1<<i)){
        long long num = stoll(S.substr(j,i+1-j).c_str());
        ans += num;
        j=i+1;
      }
    }
    ans += stoll(S.substr(j).c_str());
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>



#define rep(i,p,q) for(int i = p;i < q;i++)
#define ll long long

ll CONS = 1e9 + 7;

using namespace std;

//ABC 103 D

int main(void) {
	ll n, m;
	cin >> n >> m;
	vector<pair<ll, ll>> ba = vector<pair<ll, ll>>(m);
	rep(i, 0, m) {
		ll a, b;
		cin >> a >> b;
		ba[i] = make_pair(b, a);
	}
	sort(ba.begin(), ba.end());
	ll bridge = -1;
	ll count = 0;
	rep(i, 0, m) {
		if (ba[i].second <= bridge) {
			
		}
		else {
			count++;
			bridge = ba[i].first - 1;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define N 200010
using namespace std;
long long n,a,qsum[N]={},qxor[N]={},i,j,sum=0,x,y;
int main(){
	cin>>n;
	qsum[0]=qxor[0]=0;
	for(i=1;i<=n;i++)
	{
		cin>>a;
		qsum[i]=qsum[i-1]+a;
		qxor[i]=qxor[i-1]^a;
	}
	j=1;
	for(i=1;i<=n;i++)
	{
		x=qsum[i]-qsum[j-1];
		y=qxor[i]^qxor[j-1];
		if(x==y)
		{
			sum+=(i-j+1);
			continue;
		}
		while(j<i)
		{
			x=qsum[i]-qsum[j-1];
			y=qxor[i]^qxor[j-1];
			if(x==y)
			{
				sum+=(i-j);
				break;
			}
			j++;
		}
		sum++;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3328
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int n = 0;
		for (int i = 1; i <= 1000001; i++) {
			n = 10 * n + 7;
			if (n % K == 0) {
				System.out.println(i);
				return;
			}
			n %= K;
		}
		System.out.println(-1);
	}
}


Measured memory_bytes: 35644
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int main(){
    string s,t="FESTIVAL";
    cin>>s;
    cout<<s.substr(0,SZ(s)-SZ(t))<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MAX 1000001
using namespace std;
int n, x;
int isprime[MAX];
int w[30];
int dp[MAX];
int main() {
    memset(isprime, 1, sizeof(isprime));
    isprime[0]=isprime[1]=0;
    for (int i=2; i<MAX; i++) {
        if (isprime[i]) {
            for (int j=i*2; j<MAX; j+=i) isprime[j]=0;
        }
    }
    while (scanf("%d%d",&n,&x)) {
        if (n==0&&x==0) break;
        memset(dp, 0, sizeof(dp));
        for (int i=0; i<n; i++) scanf("%d",&w[i]);
        dp[0]=1;
        for (int i=0; i<=x; i++) {
            if (dp[i]) {
                for (int j=0; j<n; j++) {
                    if (i+w[j]<=x) dp[i+w[j]]=1;
                }
            }
        }
        int res=-1;
        for (int i=x; i>0; i--) {
            if (dp[i]&&isprime[i]) {
                res=i;
                break;
            }
        }
        if (res==-1) puts("NA");
        else printf("%d\n",res);
    }
}

Measured memory_bytes: 8576
//use itertools::Itertools;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        edge: [(usize1,usize1);n-1]
    }

    let mut ans = 0;

    //println!("{:?}", edge);

    let mut tree = vec![vec![]; n];
    for (i, &(a, b)) in edge.iter().enumerate() {
        tree[a].push((b, i));
        tree[b].push((a, i));
    }

    let mut color_num = 0;
    for i in 0..n {
        color_num = cmp::max(color_num, tree[i].len());
    }
    println!("{:?}", color_num);

    let mut edge_colors = vec![0; n - 1];
    dfs(&tree, &mut edge_colors, color_num, 0, MAX);

    for i in 0..n - 1 {
        println!("{}", edge_colors[i]);
    }
}

fn dfs(
    tree: &[Vec<(usize, usize)>],
    edge_color: &mut [usize],
    color_num: usize,
    target: usize,
    parent: usize,
) {
    let mut used: HashSet<usize> = HashSet::new();
    for &(v, e) in &tree[target] {
        if v == parent {
            used.insert(edge_color[e]);
            break;
        }
    }

    let mut color = 1;
    for &(v, e) in &tree[target] {
        if v == parent {
            continue;
        }
        while used.contains(&color) {
            color += 1;
        }
        edge_color[e] = color;
        color += 1;
        dfs(tree, edge_color, color_num, v, target);
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 59772
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;


const int MAX = 400400, MOD = 1e9+7;
long long fac[MAX], finv[MAX], inv[MAX];
// 前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数の計算
long long COM(int n, int k){
    if (n < 0 || k < 0 || n < k) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    COMinit();
    ll ans = COM(2*n-1,n);
    if(k < n-1){
        loop(i,k+1,n){
            ans -= COM(n,i)*COM(n-1,n-1-i)%MOD;
            ans += MOD;
            ans %= MOD;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 13012
#include<cstdio>
#include<vector>
int tot=3;
int add(int i,int j){
	int k=tot++;
	printf("+ %d %d %d\n",i,j,k);
	return k;
}
int cmp(int i,int j){
	int k=tot++;
	printf("< %d %d %d\n",i,j,k);
	return k;
}
int pw[33];
std::vector<int>bin(int x){
	std::vector<int>res;
	for(int i=30;i--;)res.push_back(0);
	int sum=2;
	x=add(x,*pw);
	for(int i=30;i--;){
		int tmp=res[i]=cmp(add(sum,pw[i]),x);
		for(int j=i;j--;)tmp=add(tmp,tmp);
		sum=add(sum,tmp);
	}
	return res;
}
int mul01(int x,int y){
	return cmp(cmp(x,*pw),y);
}
int main(){
	puts("3900");
	pw[0]=cmp(2,add(0,1));
	for(int i=1;i<30;i++)pw[i]=add(pw[i-1],pw[i-1]);
	std::vector<int>A=bin(0),B=bin(1),C;
	for(int i=0;i<A.size();i++){
		for(int j=0;j<B.size();j++){
			while(i+j>=C.size())C.push_back(2);
			C[i+j]=add(C[i+j],mul01(A[i],B[j]));
		}
	}
	for(int i=C.size()-1;i--;)C[i]=add(C[i],add(C[i+1],C[i+1]));
	printf("+ %d %d %d\n",2,C[0],2);
}

Measured memory_bytes: 3096