akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;

int main(void)
{

    ll n,k,s;
    cin >> n >> k >> s;

    vector<ll> aa;

    for(int i=0;i<k;i++)
        aa.push_back(s);

    for(int i=0;i<abs(n-k);i++){

            if(s==1000000000)
            aa.push_back(1);
            else
        aa.push_back(s+1);

    }

    for(auto &it: aa)
        cout << it << " ";

	return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for (int i = a; i <= (b); i++)
#define ROF(i, a, b) for (int i = a; i >= (b); i--)

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

int main() {
    string s; cin >> s;
    int k; cin >> k;
    FOR(i, 0, k - 1) {
        if (s[i] != '1')
            return cout << s[i] << endl, 0;
    }
    cout << 1 << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include<boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P& element1, const P& element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P& element1, const P& element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P& element1, const P& element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P& element1, const P& element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(int n)
{
	int count = 0;
	while (n > 0)
	{
		n /= 10;
		count++;
	}
	return count;
}
ll combination(ll n, ll r)
{
	if (r * 2 > n)
		r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i)
	{
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}
vector<int> divisor(int n)
{
	vector<int> value;
	FOR(i, 1, pow(n, 0.5) + 1)
	{
		if (i <= sqrt(n))
		{
			if (n % i == 0)
			{
				value.push_back(i);
				if (i * i != n)
				{
					value.push_back(n / i);
				}
			}
		}
	}
	return value;
}

int main()
{
	int n;
	cin >> n;
	vector<cpp_int>alpha(n);
	rep(i, n) {
		string s;
		cin >> s;
		cpp_int tmp = 0;
		rep(j, s.size()) {
			int t = s[j] - 97;
			//cout << t << endl;
			cpp_int m = 1;
			rep(k, t) {
				m *= 10;
			}
			tmp += m;
		}
		alpha[i] = tmp;
	}
	ll ans = 0;
	sort(all(alpha));
	ll cnt = 0;
	rep(i, n-1) {
		if (alpha[i] == alpha[i + 1]) {
			cnt++;
		}
		else {
			ans += cnt * (cnt + 1) / 2;
			cnt = 0;
		}
	}
	ans += cnt * (cnt + 1) / 2;
	cout << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN
#define INF         100000000000000000
#define PI          3.1415926535897932384626433832795l



#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)






// struct mycomp {
//     bool operator() (const pair<int,int> &a, const pair<int,int> &b) const{
//         if (a.second-a.first != b.second-b.first)
//         return (a.second-a.first > b.second-b.first);
//         return a.first < b.first;
//     }
// };



/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}	
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}


///////////////////////////BFS//////////////////////////////////
void bfs(vector<int>& distance, vector<int> a[], vector<bool>& visited, int u, vector<int>& parent)
{
	visited[u]=true;
	parent[u]=-1;
	distance[u]=0;
	queue<int> q;

	q.push(u); 
    while (!q.empty()) { 
  
        int f = q.front(); 
        q.pop(); 
  		for(int i =0; i < a[f].size(); i++)
  		{
  			if(visited[a[f][i]]==false)
  			{
  				distance[a[f][i]]=distance[f]+1;
  				parent[a[f][i]]=f;
  				visited[a[f][i]]=true;
  				q.push(a[f][i]);
  			}
  		}
    } 

}

void solve()
{

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

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	int n;
	cin>>n;
	if(n<1200)
		p("ABC");
	else p("ARC");
	return 0;
}	

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

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

using Int = long long;
int mo = 1e9+7;
int inf = 1e9;

int N, T;
int dp[6010];

signed main()
{
    cin >> N >> T;

    vector<pair<int, int>> menu;

    rep(i, N) {
        int a, b; cin >> a >> b;
        menu.push_back(pair<int, int>(a, b));
    }

    sort(begin(menu), end(menu));

    memset(dp, -1, sizeof(dp));
    dp[0] = 0;

    rep(i, N) {
        int t = menu[i].first, v = menu[i].second;
        for (int j = T + t - 1; j - t >= 0; --j) {
            if (dp[j - t] != -1) {
                dp[j] = max(dp[j], dp[j - t] + v);
            }
        }
    }


    int ma = 0;
    for (int i = 0; i <= 6005; ++i) {
        ma = max(ma, dp[i]);
    }

    cout << ma << endl;

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
	string x;
int judge(int start,int end){
	while(start<end){
		if(x[start++]!=x[end--]){
			return 0;
		}
	}
}
int main(){

	cin>>x;
	int start=0;
	int l=x.length();
	if(judge(0,l-1)&& judge(0,(l-1)/2-1)&&judge((l+3)/2-1,l-1)) cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

void show(int* x, int n);

int main()
{
  int n=0, r=0;
  while(cin >> n >> r && n > 0){
    int cards[n];
    for(int i=0; i<n; i++){
      cards[i] = n-i;
    }
    for(int i=0; i<r; i++){
      int p, c;
      cin >> p >> c;
      rotate(cards, cards + p - 1, cards + p + c - 1);
    }
    cout << cards[0] << endl;
  }
}

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

int main() {
    string s;
    cin >> s;
    cout << s.substr(0, s.length() - 8) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define vi vector<int>
#define vii vector<int, int>
#define po pop_back
#define hell 1000000007
using namespace std;
 
void solve(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int a[3][n];
	memset(a,0,sizeof(a));
	for(int i=n-1;i>-1;i--){
		if(i<n-1){
			a[0][i] = a[0][i+1];
			a[1][i] = a[1][i+1];
			a[2][i] = a[2][i+1];
		}
		if(s[i]=='R') a[0][i]++;
		if(s[i]=='G') a[1][i]++;
		if(s[i]=='B') a[2][i]++;
	}
	ll ans = 0;
	for(int i=0;i<n-2;i++){
		for(int j =i+1;j<n-1;j++){
			if(s[i]!=s[j]){
				if(((s[i]=='R') && (s[j]=='G')) || ((s[i] == 'G')&& (s[j] == 'R'))){
					ans+=a[2][j+1];
					if(j+(j-i)<n && s[j+(j-i)]=='B') ans--;
				} 
				if(((s[i]=='R') && (s[j]=='B')) || ((s[i] == 'B')&& (s[j] == 'R'))){
					ans+=a[1][j+1];
					if(j+(j-i)<n && s[j+(j-i)]=='G') ans--;
				} 
				if((((s[i]=='B') && (s[j]=='G')) || ((s[i] == 'G')&& (s[j] == 'B')))){
					ans+=a[0][j+1];
					if(j+(j-i)<n && s[j+(j-i)]=='R') ans--;
				} 
			}
		}
	}
	cout<<ans<<endl;
}
 
int main(){
	int t = 1;
	//cin>>t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 3636
N,x=map(int,input().split())
a=input().split()
numbers=[int(b) for b in a]
count=0
n=len(numbers)
if numbers[0]>x:
    count = numbers[0] - x
    numbers[0]=x
for c in range(n-1):
    if numbers[c] + numbers[c+1]>x:
        count+=numbers[c+1]-(x-numbers[c])
        numbers[c+1]=x-numbers[c]
print(count)


Measured memory_bytes: 14540
#include<bits/stdc++.h>
using namespace std;
int main(){
	
	
	long long a,b,c,d,y,z;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	z=a*b;
	y=c*d;
	if(z>y){
		printf("%lld",z);
	}
	else
	if(y>z){
		printf("%lld",y);
	}
	else
	printf("%lld",z);
	return 0;
}

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

struct node{
	int u,v,w;
};
node a[65];

int main()
{
	int L,n=1,s=0;
	scanf("%d",&L);
	int t=1,m=--L;
	while(t<=m){
		a[s++]=node{n,n+1,t};
		a[s++]=node{n,n+1,0};
		++n;
		m-=t;	t<<=1;
	}
	if(m){
		int xi=t,p=t/2,k=n-1;
		while(k>=1){
//			cout<<"# "<<p-1<<" "<<m<<" "<<xi<<" "<<k<<endl;
			if(p<=m){
				a[s++]=node{k,n,xi};
				xi+=p;	m-=p;
			}
			p/=2;	--k;
		}
		if(xi==L)	a[s++]=node{1,n,xi};
	}
	printf("%d %d\n",n,s);
	for(int i=0;i<s;++i)
		printf("%d %d %d\n",a[i].u,a[i].v,a[i].w);
	
	return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    ll n;
    cin >> n;
    ll a[200500];
    ll sum[200050];
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
    }
    ll ans = 1e17;
    for(int i = 1; i < n; i++) {
        ans = min(ans, abs(sum[i] - (sum[n] - sum[i])));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
N = int(input())
A = list(map(int, input().split()))


mx = max(A)
x = [0] * (mx + 1) # len(x)
for i in A:
    x[i] += 1
for i in range(1, mx + 1):
    if x[i] != 0:
        for j in range(2 * i, mx + 1, i):
            x[j] = 0
    if x[i] > 1:
        x[i] = 0
print(sum(x))

Measured memory_bytes: 31992
const main = stdin => {
  const input = stdin.trim().split('\n')
  const [a, b] = input[0].split(' ')

  const c = parseInt(a + b)
  for (let i = 1; i <= c / 2; i++) {
    if (i * i === c) {
      console.log('Yes')
      return
    }
  }
  console.log('No')
}


// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 32156
#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 <iomanip>
using namespace std;
typedef long long unsigned int ll;

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

// https://beta.atcoder.jp/contests/abc065/tasks/abc065_b

int main() {
    int N; cin >> N;
    bool arr[100005] = {};
    int a[N+5]; REP(i, N) cin >> a[i];

    int cnt = 1;
    int current = a[0];
    while(true) {
        if (current == 2) {
            cout << cnt << "\n";
            return 0;
        }
        if (arr[current]) {
            cout << -1 << "\n";
            return 0;
        }
        arr[current] = true;

        current = a[current-1];
        cnt++;
    }

    cout << -1 << "\n";

    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ii pair<int, int>
#define iii tuple<int, int, int>
#define iiii tuple<int, int, int, int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define fi first
#define se second
#define eb emplace_back

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int M = 1 << 20, N = 51;
int n, m;
vi edge_bit(N), in(N);
vector<ll> dp(M);
vector<vector<ii>> g(N);

int edge_set(int u, int e, int j) {
    if (u == e) return 1;
    if (in[u]) return 0;
    in[u] = 1;
    for (auto ev : g[u]) {
        int v = ev.fi, i = ev.se;
        if (edge_set(v, e, j)) {
            if (u > v) swap(u, v);
            edge_bit[i] |= (1 << j);
            return 1;
        }
    }
    return 0;
}

void solve() {
    cin >> n;
    for (int i = 1; i < n; ++i) {
        int u, v;
        cin >> u >> v;
        if (u > v) swap(u, v);
        g[u].eb(ii{v, i});
        g[v].eb(ii{u, i});
    }
    cin >> m;
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        in.assign(N, 0);
        edge_set(u, v, i);
    }
    dp[0] = 1;
    for (int i = 1; i < n; ++i)
        for (int msk = (1 << m) - 1; msk >= 0; --msk)
            dp[msk | edge_bit[i]] += dp[msk];

    cout << dp[(1 << m) - 1] << '\n';
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}

Measured memory_bytes: 8448
N,K=map(int,input().split())
A=sorted(list(map(int,input().split())),reverse=True)
MOD=10**9+7
if N==K:
    ans=1
    for i in A:
        ans=ans*i%MOD
    print(ans)
    exit()
if K==1:
    print(A[0]%MOD)
    exit()
if K%2==1 and A[0]==0:
    print(0)
    exit()
if K%2==1 and A[0]<0:
    ans=1
    for i in range(K):
        ans=ans*A[i]%MOD
    print(ans)
    exit()
if N-A.count(0) <K:
    print(0)
    exit()
if A[-1]>=0:
    ans=1
    for i in range(K):
        ans=ans*A[i]%MOD
    print(ans)
    exit()
l=0
r=N-1
t=[]
c=0
if K%2==1:
    tk=K-1
    flg=True
else:
    tk=K
    flg=False
while c<tk:
    if A[l]*A[l+1]<=A[r]*A[r-1]:
        t.append(A[r])
        t.append(A[r-1])
        r-=2
        c+=2
    else:
        t.append(A[l])
        t.append(A[l+1])
        l+=2
        c+=2
if flg:
    t.append(A[l])
ans=1
for i in t:
    ans=ans*i%MOD
print(ans)

Measured memory_bytes: 33160
#include <bits/stdc++.h>
#define INF 1e9
#define all(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define max(v) *max_element(v.begin(), v.end())
#define min(v) *min_element(v.begin(), v.end())
using namespace std;

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

    while(true){
        int h, w;
        cin>>h>>w;
        if(h == 0 && w == 0){
            break;
        }
        rep(i, h){
            rep(j, w){
                if((i+j)%2 == 0){
                    cout<<"#";
                }
                else{
                    cout<<".";
                }
                if(j == w-1){
                    cout<<endl;
                }
            }
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3160
N,K=map(int,input().split(' '))
R,S,P=map(int,input().split(' '))
h = {'r':P,'p':S,'s':R}
T=input()
hands=[1]*N
ans = 0
for i in range(N-K):
    if T[i] != T[i+K] and hands[i]:
        ans += h[T[i]]
    elif hands[i]:
        hands[i+K]=0
        ans +=h[T[i]]
for i in range(N-K,N):
    if hands[i]:
        ans += h[T[i]]
print(ans)

Measured memory_bytes: 4212
using System;
using System.Linq;

namespace ARC073
{
    class C
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = a[0];
            var T = a[1];
            var res = T;
            var t = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 0; i < N - 1; i++)
            {
                var tempt = t[i + 1] - t[i];
                if (T <= tempt) res += T;
                else res += tempt;
            }
            Console.WriteLine(res);
        }
    }
}

Measured memory_bytes: 28384
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

void solve(long long N, std::vector<long long> a) {
  bool isSecondWin = true;
  rep(n, N) {
    if (a[n] % 2 != 0) {
      isSecondWin = false;
      break;
    }
  }

  if (isSecondWin) {
    print("second");
  } else {
    print("first");
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve(N, std::move(a));
  return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys
from collections import deque
INF = float("inf")


class Graph(object):
    def __init__(self, N):
        self.N = N
        self.E = [[] for _ in range(N)]

    def add_edge(self, edge):
        """辺を加える。edgeは(始点, 終点、重み)からなるリスト
        重みがなければ、重み1とする。
        """
        if len(edge) == 2:
            edge.append(1)
        elif len(edge) != 3:
            print("error in add_edge")

        s, t, w = edge
        self.E[s].append([t, w])
        self.E[t].append([s, w])


def solve(N: int, Q: int, a: "List[int]", b: "List[int]", p: "List[int]", x: "List[int]"):
    g = Graph(N)
    for aa, bb in zip(a, b):
        g.add_edge([aa-1, bb-1, 1])

    P = [0]*N
    for pp, xx in zip(p, x):
        P[pp-1] += xx

    visit = deque()
    visit.append((0, None))
    counter = [0]*N
    while len(visit) > 0:
        # print(visit)
        curr, par = visit.popleft()
        counter[curr] += P[curr]
        for t, w in g.E[curr]:
            if t == par:
                continue
            visit.append((t, curr))
            counter[t] += counter[curr]
    print(*counter)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    a = [int()] * (N-1)  # type: "List[int]"
    b = [int()] * (N-1)  # type: "List[int]"
    for i in range(N-1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    p = [int()] * (Q)  # type: "List[int]"
    x = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        p[i] = int(next(tokens))
        x[i] = int(next(tokens))
    solve(N, Q, a, b, p, x)


if __name__ == '__main__':
    main()


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int n, t; scanf("%d%d", &n, &t);
	long long ans = 0, last = -1;
	for (int i = 0; i < n; ++i) {
		int x; scanf("%d", &x);
		if (last == -1) {
			last = x;
			continue;
		}
		if (x-last > t) {
			ans += t;
		} else {
			ans += x-last;
		}
		last = x;
	}
	ans += t;
	printf("%lld", ans);
}

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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
main()
{
  string s;
  int l;
  cin>>s;
  l=s.length();
  if(s[l-1]=='s')
    s.append("es",2);
  else
    s.append("s",1);
  cout<<s;
  return 0;
}
  


Measured memory_bytes: 3632
program d
 integer(8) :: a(0:9)=(/0,1,2,4,7,12,20,29,38,52/),f(10)=0
 read(*,*) n
 f(3)=1
 do i=4,n
  f(i)=f(i-1)*(a(i-2)+a(i-3)+1)
 enddo
 do i=1,n
  do j=1,n
   write(*,*) merge(0_8,f(max(i,j))*a(min(i,j))+1,i==j)
  enddo
 enddo
end program d

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

int main() {
  int N, l, r, i;
  int sum = 0;
  cin >> N;
  
  for(i = 0; i < N; i++){
    cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum << endl;
}


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

typedef long long ll;
#define int ll

using namespace std;

const int N=2e5+100;
int a[N];

signed main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int ans=0;
    for(int i=0,j=0,x=0;i<n;i++)
    {
        while(j<n&&!(x&a[j]))
            x|=a[j++];
        ans+=j-i;
        x&=~a[i];
    }
    cout<<ans;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
#define MAX 1000

int main(){
    int n;
    int i, j=0, sum;
    int score[MAX];
    double ave, tmp;
    double dev[MAX];

    while(1){
        scanf("%d", &n);
        if(n==0)break;
        sum=0;
        for(i=0;i<n;i++){
            scanf("%d", &score[i]);
            sum+=score[i];
        }
        ave=(double)sum/(double)n;
        tmp=0.0;
        for(i=0;i<n;i++){
            tmp+=pow(score[i]-ave, 2);
        }
        dev[j++]=sqrt(tmp/(double)n);
    }
    for(i=0;i<j;i++){
        printf("%f\n", dev[i]);
    }
    return 0;
}


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

signed main() {
  int N;
cin >> N;

int heikin = 0;
vector<int> A(N);
for( int i = 0; i < N; i++ ){
cin >> A.at(i);
heikin += A.at(i);
}


int sa = 1000;
int ans;
for( int i = 0; i < N; i++ ){
if( abs( heikin - N*A.at(i) ) < sa ){
ans = i;
sa = abs( heikin - N*A.at(i) );
}
}

cout << ans << endl;




            
}


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

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

    if (a < b){
        if (b < c){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file 
//#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define pb push_back
#define ff first
#define ss second
#define ii insert
#define ld long double
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define ppb pop_back
#define nuenxfiu ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define TT int testcases;cin>>testcases;while(testcases--)
#define mk make_pair
#define MAX ((int)2e9+17)
#define mod ((int)1e9+7)
#define MOD 1000003
//int fact[1000007]={0};
#define N (int)1e6+10
int fpow(int n, int k, int p = mod) {int r = 1; while(k > 0) {if (k & 1) r = r * n%p; n = n * n%p; k = k >> 1;} return r;}
int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
int inv(int x) {return expo(x, mod-2);}
using namespace std;



void solve()
{
	string s;
	cin>>s;
	if(s=="ABC")
	cout<<"ARC"<<endl;
	else
	cout<<"ABC"<<endl;
	
	
}
signed main()
{
    
	nuenxfiu
	//TT
	solve();
     return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,m,ans;
	cin >> n >> m;
	ans = pow(2,m)*(m*1900+(n-m)*100);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

#define mod 1000000007

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

int N;

int main(){
    cin>>N;
    if(N/100==N%10){
        out("Yes");
    }
    else{
        out("No");
    }

}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan=new Scanner(System.in);
		//恐らくO(logN)orO(1)だと思う
		long a=scan.nextLong();
		long ans=0;
		for(long i=1;;i++) {//iはあまりの数
			if(i*i>=a-i) {
				break;
			}
			if((a-i)%i==0) {
				ans+=(a-i)/i;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	
	int main()
	{
		std::ios::sync_with_stdio(false);
		int T = 1;
		//cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			int N,K;
			cin>>N>>K;
			int count[N] = {0};
			int ans = 0;
			for(int i=0;i<K;i++)
			{
				int d;
				cin >>d;
				for(int i=0;i<d;i++)
				{
					int temp;
					cin>>temp;
					count[temp - 1]++;
				}
			}
			for(int i=0;i<N;i++)
			{
				if(count[i] == 0)
					ans++;
			}
			cout<<ans;
		}
		return 0;
	}


Measured memory_bytes: 3604
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;

//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int A1,A2,A3;
  cin >> A1 >> A2 >> A3;
  if(A1 + A2 + A3 >= 22){
  	cout << "bust" << endl;
  }
  else{
  	cout << "win" << endl;
  }
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

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

string s;
int p;
int value[128];

int multiply(int x, int y) {
  if(x == 2 && y == 2) return 2;
  else if(min(x,y) == 0) return 0;
  else return 1;
}

int add(int x, int y) {
  if(x == 0 && y == 0) return 0;
  else if(max(x,y) == 2) return 2;
  else return 1;
}

int form() {
  if(s[p] == '-') {
    ++p;
    return 2-form();
  } else if(s[p] == '(') {
    ++p;
    int x = form();
    char c = s[p++];
    int y = form();
    ++p;
    if(c == '*') { // *
      return multiply(x,y);
    } else { // +
      return add(x,y);
    }
  } else {
    return value[s[p++]];
  }
}

int main() {
  value['0'] = 0;
  value['1'] = 1;
  value['2'] = 2;
  while(cin >> s && s != ".") {
    s += "$";
    int res = 0;
    for(int P = 0; P <= 2; ++P) {
      for(int Q = 0; Q <= 2; ++Q) {
        for(int R = 0; R <= 2; ++R) {
          value['P'] = P;
          value['Q'] = Q;
          value['R'] = R;
          p = 0;
          res += form() == 2;
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}

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

using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	vector<int> peaks(n);
	for(int i=0;i<n;i++){
		cin>>peaks.at(i);
	}

	vector<bool> best(n,true);

	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;

		if(peaks.at(a-1)>=peaks.at(b-1)) best.at(b-1)=false;
		if(peaks.at(a-1)<=peaks.at(b-1)) best.at(a-1)=false;
	}

	int ans=0;

	for(auto a:best){
		if(a) ans++;
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3788
def a2c(name):
	c = name[0]
	boin=['a','i','u','e','o']
	for i, b in enumerate(name[:-1]):
		if b in boin:
			c += name[i+1]
	
	return c

	
while True:
	n = int(raw_input())
	
	if n == 0:
		break
	
	names = []
	length = -1
	for i in xrange(n):
		tmp = a2c(raw_input())
		#print tmp
		names.append(tmp)
		length = max(length, len(tmp))
	
	names = set(names)
	if len(names) != n:
		print -1
		continue
	
	for i in xrange(1, length+1):
		s = set([name[:min(i, len(name))] for name in names])
		if len(s) == n:
			print i
			n = 0
			break
			
	if n != 0:
		print -1

Measured memory_bytes: 6324
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"

using namespace std;
typedef long long ll;

int main()
{
  string s;
  cin >> s;
  string t;
  bool ans = false;
  int size = s.size();
  for (int i = 0; i < 7; i++)
  {
    t = "";
    for (int j = 0; j < i; j++)
    {
      t += s[j];
    }
    for (int j = size - 7 + i; j < size ; j++)
    {
      t += s[j];
    }
    if (t == "keyence")
    {
      ans = true;
      break;
    }
  }
  if (ans)
  {
    cout << "YES" << "\n";
  }
  else
  {
    cout << "NO" << "\n";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ls (o << 1)
#define rs (o << 1 | 1)
#define mid ((L + R + 1) >> 1)
using namespace std;
const int MAXN = 100050;
const int mod = 998244353;
typedef long long LL;
int n;
bool f[MAXN];
char s[MAXN];
int main() {
#ifdef TEST
	freopen("input.txt", "r", stdin);
#endif
	cin >> n >> s;
	s[n] = s[0];
	s[n + 1] = s[1];
	n += 2;
	for (int T = 0; T < 4; ++T) {
		f[0] = T & 1;
		f[1] = T >> 1;
		for (int i = 2; i < n; ++i) {
			if (!f[i - 1]) {
				f[i] = f[i - 2] ^ (s[i - 1] == 'x');
			} else {
				f[i] = f[i - 2] ^ (s[i - 1] == 'o');
			}
		}
		if (f[0] == f[n - 2] && f[1] == f[n - 1]) {
			n -= 2;
			for (int i = 0; i < n; ++i) {
				putchar("SW"[f[i]]);
			}
			return 0;
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
#define fi first
#define se second
#define upb upper_bound
#define lwb lower_bound
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y){
    if(y<=0) return 1;
    ll ans = 1;
    x %= mod;
    while(y){
        if(y&1)
            ans = (x * ans) % mod;
        x = (x * x) % mod;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = (a - b); if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = (a + b); if(c >= mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

//const ll N = 2e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);

	ll n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		
	}
	ll pref[n] = {0};
	pref[0] = 0;
	for(int i=1;i<n;i++){
		pref[i] = add(pref[i-1], a[i-1]);
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		ans = add(ans, mul(pref[i], a[i]));
	}
	cout<<ans;


    return 0;
}


Measured memory_bytes: 6796
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>

ll h;
int n;
ll a[111111];

int main(){
    cin>>h>>n;
    rep(i,n)cin>>a[i];
    ll cnt=0;
    rep(i,n)cnt+=a[i];
    if(cnt>=h)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int a = 0;
  	int b = 0;
	a = sc.nextInt();
	b = sc.nextInt();
	String aB = "";
  	String bA = "";
 
  	for (int i= 0; i<b; i++){
      aB = aB + String.valueOf(a);
    }
    for (int i= 0; i<a; i++){
      bA = bA + String.valueOf(b);
    }
    
  	if(a<b){
      	System.out.println(aB);
    }else{
     	System.out.println(bA); 
    }
  
	}
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

constexpr ll mod = 1000000007;

class modint {
	static constexpr std::int_fast64_t Modulus = 1e9 + 7;
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
};

void dfs(int leftTop, vector<vector<int>>& data, int start) {
	int range = data[leftTop].size() - leftTop;
	if (range == 0) return;
	for (int i = leftTop; i < leftTop+range; i++) {
		data[leftTop][i] = start + i - leftTop;
	}
	for (int i = leftTop+1; i <= leftTop+range; i++) {
		data[i][leftTop] = start + i - leftTop - 1;
	}
	dfs(leftTop + 1, data, start + range);
}

void solve(int n) {
	for (int i = 1; i * (i + 1) <= 2 * n; i++) {
		if (i * (i + 1) == 2 * n) {
			int width = i;
			int height = i + 1;
			vector<vector<int>> answer(height, vector<int>(width, -1));
			dfs(0, answer, 1);
			cout << "Yes" << endl;
			cout << height << " ";
			for (auto p : answer) {
				cout << p.size() << " ";
				for (auto d : p) {
					cout << d << " ";
				}
				cout << endl;
			}
			return;
		}
	}
	cout << "No" << endl;
}

int main() {
	int n;
	cin >> n;
	solve(n);
	return 0;
}



Measured memory_bytes: 4388
#include<bits/stdc++.h>
using namespace std;
 
#pragma GCC                   target ("avx2")
#pragma GCC                   optimize("Ofast")
#pragma GCC                   optimization ("O3")
#pragma GCC                   optimization ("unroll-loops")
#pragma GCC                   target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define mod                   1000000007
#define INF                   1000000000000000000
#define int                   long long
#define PI                    3.14159265359
#define Author                std::ios_base::sync_with_stdio(0);
#define ABHISHEK_SHARMA       cout.tie(0);
#define IIIT_ALLAHABAD        cin.tie(0);
#define all(v)                v.begin(),v.end()
#define pb(a)                 push_back(a)
#define lb(v,t)               lower_bound(all(v),t)-v.begin()
#define ub(v,t)               upper_bound(all(v),t)-v.begin()
 
clock_t time_p=clock();
 
void abhishhh1(){
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(double)(time_p)/(1.0*CLOCKS_PER_SEC)<<"\n";
}
 
void solve() {
    int n;
    cin>>n;
    char d=(char)((int)'0'+n%10);
    if(d=='3'){
        cout<<"bon";
    }
    else if(d=='0' || d=='1' || d=='6' || d=='8'){
        cout<<"pon";
    }
    else{
        cout<<"hon";
    }
}
 
signed main(){
    //file reader-writer
#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
#endif
    //Booster
    Author
    ABHISHEK_SHARMA
    IIIT_ALLAHABAD
    //Driver Code here
    int t=1;
    //cin>>t;
    for(int i=1; i<=t; i++){
        //cout<<"Case #"<<i<<": ";
        solve();
    }
    abhishhh1();
}

Measured memory_bytes: 3796
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n = ni()
    e = [[] for _ in range(n)]
    for _ in range(n - 1):
        x, y = ns()
        x -= 1
        y -= 1
        e[x].append(y)
        e[y].append(x)

    # dp[i][0]:i番目のノードが白のときの組み合わせの数
    # dp[i][1]:i番目のノードが黒のときの組み合わせの数
    dp = [[1, 1] for _ in range(n)]
    visited = [False for _ in range(n)]

    def dfs(vi, prnt):
        if visited[vi]:
            return
        visited[vi] = True

        for chld in e[vi]:
            if chld == prnt:
                continue
            dfs(chld, vi)

            # 親が白なら子は白でも黒でもいい
            dp[vi][0] *= dp[chld][0] + dp[chld][1]
            dp[vi][0] %= MOD
            # 親が黒田と子は白じゃないとダメ
            dp[vi][1] *= dp[chld][0]
            dp[vi][1] %= MOD

    dfs(0, -1)
    print((dp[0][0] + dp[0][1]) % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 138872
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random,resource

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    l,r,d = LI()

    return r // d - (l-1) // d


print(main())




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

signed main(){
  int N;cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  sort(v.begin(),v.end());
  int cnt=0;
  for(int i=0;i<N-1;i++){
    if(v[i]==v[i+1])cnt++;
  }
  if(cnt%2==1)cnt++;
  cout<<N-cnt<<endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#define max 100000

int n,k;
int w[max];
int cheak(long long int P){
    int i=0,j;
    for(j=1;j<=k;j++){
        int s=0;
        while(s+w[i]<=P){
            s+=w[i];
            i++;
            if(i==n)return n;
        }
    }
    return i;
}

int main(){
    scanf("%d %d",&n,&k);
    int i;
    for(i=0;i<=n-1;i++)scanf("%d",&w[i]);
    
    long long int left=0,right=100000*10000;
    
    while(left+1<right){
        long long int mid=(left+right)/2;
        int v=cheak(mid);
        if(v<n){
            left=mid;
        }else{
            right=mid;
        }
    }
    printf("%lld\n",right);
    
    return 0;
}


Measured memory_bytes: 2248
# coding: utf-8

import math
import sys

def insertionSort(a, n, g):
    ct = 0
    for i in range(g, n):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j = j - g
            ct += 1
            a[j+g] = v
    return ct

n = int(input())
a = list(map(int, sys.stdin.readlines()))
cnt = 0
m = 0
h = 0
g = []

while True:
    h = 3*h + 1
    if h > n:
        break
    g.insert(0, math.ceil(h))

for i in g:
    cnt += insertionSort(a, n, i)

print(len(g))
print(*g, sep=" ")
print(cnt)
print(*a, sep="\n")

Measured memory_bytes: 118672
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   int ans = 0;
   f(i,1,n+1) ans += i*(n-i+1);
   f(i,1,n){
      int u,v;
      cin >> u >> v;
      if(u > v) swap(u,v);
      ans -= u*(n-v+1);
   }
   cout << ans << '\n';
   return 0;
} 


Measured memory_bytes: 3580
N = gets.to_i
A = gets.split.map(&:to_i)

counter = Hash.new(0)

A.each do |a|
  counter[a] += 1
end

ans = 0

counter.each do |v, cnt|
  if v > cnt
    ans += cnt
  else
    ans += cnt - v
  end
end

puts ans


Measured memory_bytes: 14468
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vi V(n);
    for (int i = 0; i < n; ++i) cin >> V[i];
    ll total = 0, last = 0;
	for (int i = 0; i < n; ++i) {
		total += abs(V[i] - last);
		last = V[i];
	}
	total += abs(V[n-1] - 0);
	for (int i = 0; i < n; ++i) {
		int l = i == 0 ? 0 : V[i-1];
		int r = i == n-1 ? 0 : V[i+1];
		cout << total - abs(V[i]-l) - abs(V[i]-r) + abs(l-r) << "\n";
	}
    return 0;
}

Measured memory_bytes: 2048
using System;
using System.Collections.Generic;
namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            string input;
            Dictionary<string, int> blood = new Dictionary<string, int>{
                {"A" , 0 },
                {"B" , 0 },
                {"AB", 0 },
                {"O" , 0 },
            };
            while((input = Console.ReadLine()) != null){
                ++blood[input.Split(',')[1]];
            }
            Console.WriteLine("{1}{0}{2}{0}{3}{0}{4}", System.Environment.NewLine, blood["A"], blood["B"], blood["AB"], blood["O"]);
        }
    }
}

Measured memory_bytes: 5700
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define f1 first
#define s2 second
#define pb push_back
#define mp make_pair
#define ll long long
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);
const int N=1e5+4;

int ans;
string str;


int main(){
	//fri("in.txt");
	//fro("out.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>str;
	for(int i=0;i<str.length()/2;i++){
		if(str[i]!=str[str.length()-i-1])ans++;
	}
	cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
n = int(input())

a = []
for i in range(2):
    a.append(list(map(int, input().split())))

def solve():
    top = a[0][0]
    bottom = sum(a[1])

    mx = 0
    for i in range(n):
        top =    sum(a[0][0:i+1])
        bottom = sum(a[1][i:n])
        mx = max(top+bottom, mx)

    print(mx)

solve()

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {
    string Sa,Sb,Sc;
    cin >> Sa >> Sb >> Sc;

    char now = 'a';
    while(1){
        if (now == 'a') {
            if (Sa.empty()) {
                cout << "A" << endl;
                return 0;
            }
            now = Sa.front();
            Sa.erase(Sa.begin(), Sa.begin()+1);
        }else if (now == 'b') {
            if (Sb.empty()) {
                cout << "B" << endl;
                return 0;
            }
            now = Sb.front();
            Sb.erase(Sb.begin(), Sb.begin() + 1);
        }
        else if (now == 'c') {
            if (Sc.empty()) {
                cout << "C" << endl;
                return 0;
            }
            now = Sc.front();
            Sc.erase(Sc.begin(), Sc.begin() + 1);
        }
    }

    return 0;
}

Measured memory_bytes: 256
N=gets.to_i
a = 1
b = 0
l = 100000
while a < (N / 2) + 1 && b < N do
  b = N - a
  m = 0
  n = (a.to_s + b.to_s).split""
  n.each do |k|
    m += k.to_i
  end
  l = m if m < l
  a += 1
end
puts l


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

int main() {
  int n;
  while (cin >> n) {
    int ans = 0;
    for (int a = 0; a <= 9; ++a) {
      for (int b = 0; b <= 9; ++b) {
        for (int c = 0; c <= 9; ++c) {
          for (int d = 0; d <= 9; ++d) {
            if (a + b + c + d == n) { ++ans; }
          }
        }
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1160