akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	vector<int>w(N);
	for (auto &i : w)cin >> i;
	queue<int>Q;
	for (int i = 0; i < N; i++) {
		int p = (i + N - 1) % N;
		int n = (i + 1) % N;
		if (v[i] > w[i]) {
			cout << -1 << endl;
			return 0;
		}
		if (w[p] + w[n] < w[i]) {
			Q.push(i);
		}
	}
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		int p = (cn + N - 1) % N;
		int n = (cn + 1) % N;
		int num = (w[cn] - max(w[p], w[n])) / (w[p] + w[n]) + !!((w[cn] - max(w[p], w[n])) % (w[p] + w[n]));
		if (v[cn] >= max(w[p], w[n])) {
			if ((w[cn] - v[cn]) % (w[p] + w[n])) {
				cout << -1 << endl;
				return 0;
			}
			num = min(num, (w[cn] - v[cn]) / (w[p] + w[n]));
		}
		K += num;
		w[cn] -= num * (w[p] + w[n]);
		if (w[cn] < v[cn]) {
			cout << -1 << endl;
			return 0;
		}
		int pp = (p + N - 1) % N;
		int nn = (p + 1) % N;
		if (w[pp] + w[nn] < w[p])Q.push(p);
		pp = (n + N - 1) % N;
		nn = (n + 1) % N;
		if (w[pp] + w[nn] < w[n])Q.push(n);
	}
	for (int i = 0; i < N; i++) {
		if (v[i] != w[i]) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << K << endl;
}



Measured memory_bytes: 2304
#include <stdio.h>

int main(void) {
   
   int X,Y;
   
   scanf("%d %d",&X,&Y);
   
   int sum = 0;
   
   if (X == 3) {
      sum = 100000;
   }
   else if (X == 2) {
      sum = 200000;
   }
   else if (X == 1) {
      sum = 300000;
   }
   else {
      sum = 0;
   }
   
   if (Y == 3) {
      sum += 100000;
   }
   else if (Y == 2) {
      sum += 200000;
   }
   else if (Y == 1) {
      sum += 300000;
   }
   else {
      sum += 0;
   }
   
   if (X == 1 && Y == 1) {
      sum += 400000;
   }
   
   printf("%d\n",sum);
   
   return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
#include <map>
#define pb push_back
using namespace std;
int main(){
  int n,T;
  int t[200001];
  scanf ("%d%d",&n,&T);
  for (int i=0;i<n;i++){
    scanf("%d",&t[i]);}
  int tot=0;
  for (int i=0;i<n-1;i++){
    if ((t[i+1]-t[i])>T) tot+=T;
    else tot+=(t[i+1]-t[i]);
  }
  printf ("%d", (tot+T));
  return 0;
}


Measured memory_bytes: 1024
// Jump, and you will find out how to unfold your wings as you fall.

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxn=2e5+10,mod=1e9+7;
const ll inf=1e18;

vector<int>v[maxn],dp[maxn];

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int H,W,n;cin>>H>>W>>n; swap(H,W);
    for(int i=0;i<n;i++){
	int x,y;cin>>x>>y;  swap(x,y);
	v[x].PB(y);
    }
    int ans=W;
    sort(v[1].begin(),v[1].end()); v[1].PB(W+1);
    for(int i=0;i<sz(v[1]);i++){
	if(i==0) dp[1].PB(1),ans=min(ans,v[1][0]-1);
	else dp[1].PB(v[1][i]);
    }
    for(int i=2;i<=H;i++){
	sort(v[i].begin(),v[i].end()); v[i].PB(W+1);
	int pt=0,st=0;
	for(int j=0;j<sz(v[i]);j++){
	    while(pt<sz(v[i-1]) && v[i-1][pt]<=st+1)
		++pt;
	    int num=v[i][j];
	    while(pt<sz(v[i-1]) && v[i-1][pt]<=v[i][j])
		num=min(num,(dp[i-1][pt]+1<v[i-1][pt] ? max(dp[i-1][pt]+1,st+1) : v[i][j]) ),++pt;
	    if(pt<sz(v[i-1]))
		num=min(num,(dp[i-1][pt]+1<v[i-1][pt] ? max(dp[i-1][pt]+1,st+1) : v[i][j]) );
	    dp[i].PB(num);
	    st=v[i][j];
	    if(num<st)
		ans=min(ans,st-1);
	}
    }
    return cout<<ans<<endl,0;
}
// Deathly mistakes:
//  * Read the problem curfully.
//  * Check maxn.
//  * Overflows.


Measured memory_bytes: 22528
F=->z,c{r=[0,c];G[c].map{|e|e!=z&&(x,y=F[c,e];r=[r,[x+4[G[c].size],y]].max)};r}
G=(0..gets.to_i).map{[]}
$<.map{|e|a,b=e.split.map &:to_i;G[a]<<b;G[b]<<a}
p~-G.count{|x,y|!y}+F[0,F[0,1][1]][0]

Measured memory_bytes: 15764
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

int sa[100010], sb[100010];
const int mod = 1e9 + 7;

signed main(){
    int n, m;
	cin >> n >> m;
	vector<int> x(n), y(m);
	rep(i, 0, n) cin >> x[i];
	rep(i, 0, m) cin >> y[i];
	vector<int> a(n - 1), b(m - 1);
	rep(i, 0, n - 1){
		a[i] = x[i + 1] - x[i];
	}
	rep(i, 0, m - 1){
		b[i] = y[i + 1] - y[i];
	}
	sa[0] = a[0];
	rep(i, 1, n - 1){
		sa[i] = sa[i - 1] + a[i]; 
	}
	sb[0] = b[0];
	rep(i, 1, m - 1){
		sb[i] = sb[i - 1] + b[i];
	}
	rep(i, 1, n - 1){
		sa[i] += sa[i - 1];
		sa[i] %= mod;
	}
	rep(i, 1, m - 1){
		sb[i] += sb[i - 1];
		sb[i] %= mod;
	}
	int ta = sa[n - 2], tb = sb[m - 2];
	int la = ta, lb = tb;
	rep(i, 0, n - 1){
		la -= a[i] * (n - 1 - i);
		la = (la + mod) % mod;
		ta += la;
		ta %= mod;
	}
	rep(i,0, m - 1){
		lb -= b[i] * (m - 1 - i);
		lb = (lb + mod) % mod;
		tb += lb;
		tb %= mod;
	}
	cout << ta * tb % mod << endl;
}

Measured memory_bytes: 4992
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005

using namespace std;

int solve(){
    int n;
    cin>>n;
	int a[n+1],cnt=0,ans[n+1]={0};
	rep(i,1,n+1)cin>>a[i];
	repd(i,n,1){
		int p=i,t=a[i];
		while(p<=n){
			//cout<<i<<" "<<p<<" "<<t<<endl;
			p+=i;
			if(p>n)break;
		 	if(ans[p]==1&&t==0)t=1;
			else if(ans[p]==1&&t==1)t=0;
		}
		if(t==0)ans[i]=0;
		else ans[i]=1;
		if(ans[i]==1)cnt++;
	}
	cout<<cnt<<endl;
	rep(i,1,n+1)if(ans[i]==1)cout<<i<<" ";
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define int long long 
using namespace std;
signed main(){
  string s[200],a;
  int n,l;
  cin>>n>>l;
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
  sort(s,s+n);
  for(int i=0;i<n;i++){
    a+=s[i];
  }

  cout<<a<<"\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

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

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define sz(x) int(x.size())
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;

int a[12][12];
vi c(12);
int main(){
    int n,m,x;
    cin>> n>> m>> x;
    rep(i, n){
        cin>> c[i];
        rep(j,m) cin >> a[i][j];
    }
    int INF=100100000;
    int ans=INF;
    rep(s, 1<<n){ 
        int cost=0;
        vi d(m);
        rep(i, n){
            if (s>>i&1){
                cost+=c[i];
                rep(j,m) d[j]+=a[i][j];
            }
        }
        bool flag=true;
        rep(j,m) if(d[j]<x) flag=false;
        if (flag) ans = min(ans, cost);
    }
    if(ans==INF) cout<< -1<< endl;
    else cout<< ans<< endl;
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>

// #include <string>
// #include <iomanip>
// std::cout << std::fixed << std::setprecision(5);

int main()
{
    int a, b; std::cin >> a >> b;
    if (a > b) std::cout << a * 2 - 1 << std::endl;
    else if (a < b) std::cout << b * 2 - 1 << std::endl;
    else std::cout << a * 2 << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

typedef struct {
	char word[50];
	char page[1001];
} BOOK;

void bubble_sort(BOOK *ptr, int n)
{
	int i, j, k;
	char temp[50];
	for (i = 0; i < n - 1; i++){
		for (j = 0; j < n - i - 1; j++){
			if (strcmp(ptr[j].word, ptr[j + 1].word) > 0){
				strcpy(temp, ptr[j].word);
				strcpy(ptr[j].word, ptr[j + 1].word);
				strcpy(ptr[j + 1].word, temp);
				
				for (k = 0; k < 1001; k++){
					ptr[j].page[k] ^= ptr[j + 1].page[k];
					ptr[j + 1].page[k] ^= ptr[j].page[k];
					ptr[j].page[k] ^= ptr[j + 1].page[k];
				}
			}
		}
	}
}

int main(void)
{
	BOOK index[200];
	int i, j, s;
	int flag, temp;
	char str[31];
	
	i = 0;
	while (scanf("%s%d", str, &temp) != EOF){
		getchar();
		flag = 1;
		for (j = 0; j < i; j++){
			if (strcmp(str, index[j].word) == 0){
				flag = 0;
				break;
			}
		}
		
		if (flag == 1){
			memset(index[i].page, 0, sizeof(index[i].page));
			strcpy(index[i].word, str);
			index[i].page[temp] = 1;
			i++;
		}
		else {
			index[j].page[temp] = 1;
		}
	}
	s = i;
	
	bubble_sort(index, s);
	
	for (i = 0; i < s; i++){
		printf("%s\n", index[i].word);
		flag = 0;
		for (j = 1; j < 1001; j++){
			if (index[i].page[j] == 1){
				if (flag == 1){
					printf(" ");
				}
				printf("%d", j);
				flag = 1;
			}
		}
		printf("\n");
	}
	
	return (0);
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A == B) {
    cout << C << endl;
  } else if (A == C) {
    cout << B << endl;
  } else {
    cout << A << endl;
  }
}


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

int main(){
  int n, data, max,min;
  int sum;

  while( cin>>n,n ){
    min = 10000, max = -1;
    sum = 0;
    for( int i=0;i<n;i++ ){
      cin >> data;
      if( data>max ) max = data;
      if( data<min ) min = data;
      sum += data;
    }
    sum = sum - max -min;
    cout << sum/(n-2) << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s; cin >> s; int total = 0;
	for(auto& ch : s)
	{
		total += ch - '0';
	}
	if(total%9)
	{
		cout << "No";
	}
	else cout << "Yes";
	return 0;
	
}

Measured memory_bytes: 3720
n,a,b = map(int, input().split())
count = 0
for i in range(1,n+1):
    i = str(i)
    c = 0
    for j in range(len(i)):
        c += int(i[j])
    if (a<=c and c<=b):
        count += int(i)
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
inline void read (int &x) {
	char ch = getchar(); x = 0;
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
}
char ch[12][1024];
int h, w, k, res = 1e9, s[1024][12];
vector<int> vec;
inline int work () {
	int tmp = vec.size() - 1, la = 0; 
	vec.push_back (h); int num[12] = {};
	for (int i = 1; i <= w; ++i) {
		for (int j = 1; j < vec.size(); ++j) {
			num[j] += s[i][vec[j]] - s[i][vec[j - 1]];
			if (num[j] > k) {
				if (i == la + 1) { vec.pop_back (); return 1e9; }
				la = i - 1, ++tmp;
			    memset (num, 0, sizeof (num));
			    --i; break;
			}
		}
	} vec.pop_back (); 
	return tmp;
}
void dfs (int now) {
	if (now == h) { res = min (res, work()); return; }
	dfs (now + 1), vec.push_back (now), dfs (now + 1), vec.pop_back();
}
signed main() {
	scanf ("%d %d %d", &h, &w, &k);
	for (int i = 1; i <= h; ++i) scanf ("%s", ch[i] + 1);
	for (int i = 1; i <= w; ++i)
		for (int j = 1; j <= h; ++j) s[i][j] = s[i][j - 1] + ch[j][i] - 48;
	vec.push_back (0); dfs (1);
	return printf ("%d\n", res), 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String U = sc.next();
		if (U.equals(S)) {
			A = A - 1;

		} else if (U.contentEquals(T)) {
			B = B - 1;

		}
		System.out.print(A + " " + B);
	}
}

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

using namespace std;

int nCk(int n, int k ){
	if (n == 1) {
		return 0;
	}
	if (k > n) return 0;
	if (k * 2 > n) k = n-k;
	if (k == 0) return 1;

	int result = n;
	for( int i = 2; i <= k; ++i){
		result *= (n-i+1);
        	result /= i;
	}
	return result;
}

int main() {
	int M,N;
	cin >> N >> M;
	int ans = 0, p_n = 0, p_m = 0;
	if (M == 1) {
		ans = nCk(N, 2);
	}else if (N == 1) {
		ans = nCk(M, 2);
	}else{
		ans = nCk(N, 2) + nCk(M, 2);
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n, W;
    cin >> n >> W;
    int v[n];
    int w[n];
    for(int i = 0; i < n; i++){
        cin >> v[i] >> w[i];
    }
    int table[n + 1][W + 1];
    for(int i = 0; i < n + 1; i++){
        for(int j = 0; j < W + 1; j++){
            table[i][j] = 0;
        }
    }
    
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < W + 1; j++){
            if(j < w[ i - 1]){
                table[i][j] = table[i - 1][j];
            }else{
                if(table[i - 1][j] > table[i - 1][j - w[i - 1]] + v[i - 1]){
                    table[i][j] = table[i - 1][j];
                }else{
                    table[i][j] = table[i - 1][j - w[i - 1]] + v[i - 1];
                }
            }
        }
    }
    cout << table[n][W] << endl;
    return 0;
}

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


int main(void){
  char S[3];
  char T[3];
  scanf("%s", S);
  scanf("%s", T);

  int ans = 0;
  int i;

  for (i = 0; i < 3; i++) {
    if (S[i] == T[i]) {
      ans++;
    }
  }
  printf("%d", ans);


}


Measured memory_bytes: 128
#include <iostream>

int main()
{
	int W, H, x, y, r;
	std::cin >> W >> H >> x >> y >> r;

	if (x + r > W || x - r<0 || y + r>H || y - r < 0) {
		std::cout << "No" << std::endl;
	}
	else std::cout << "Yes" << std::endl;
	
    return 0;
}

Measured memory_bytes: 3124
#include <stdio.h>
#include <stdlib.h>

int main(){

  int a,i,j,tmp,n,x,A[100000];

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);

  x = A[n-1];
  i = -1;
  for(j=0;j<n-1;j++){
    if(A[j] <= x){
      i++;
      tmp = A[j];
      A[j] = A[i];
      A[i] = tmp;
    }
  }
  tmp = A[n-1];
  A[n-1] = A[i+1];
  A[i+1] = tmp;
  a = i+1;
  for(i=0;i<n;i++){
    if(i)printf(" ");
    if(i==a)printf("[%d]",A[i]);
    else printf("%d",A[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2124
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


bool func(pair<ll,ll> a, pair<ll,ll> b){
    return a.first > b.first;
}


pair<bool, ll> cal(vector<pair<ll,ll> > &V){
    pair<bool, ll> ans = mp(false, 0);
    ll cnt = 0;
    rep(i, V.size()){
        cnt += V[i].first;
        if(cnt < 0) return ans;
        cnt += V[i].second;
        if(cnt < 0) return ans;
    }
    
    ans.first = true;
    ans.second = cnt;
    return ans;
}

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

    ll N ; cin >> N ;
    vector<pair<ll,ll> > P, M;

    
    rep(i, N){
        string inp; cin >> inp;

        ll cnt = 0;
        ll min_cnt = 0;
        
        rep(j, inp.size()){
            if(inp[j] == ')') cnt --;
            else cnt ++;
            
            min_cnt = min(cnt, min_cnt);
        }
        
        if(cnt > 0) P.pb(mp(min_cnt, cnt - min_cnt));
        else{
            cnt = 0;
            min_cnt = 0;
            for(ll j = inp.size() - 1; j >= 0; j--){
                if(inp[j] == ')') cnt ++;
                else cnt --;
                
                min_cnt = min(cnt, min_cnt);
            }
            
            M.pb (mp(min_cnt, cnt - min_cnt));
        }
    }
    
    sort(all(P), func);
    sort(all(M), func);

    pair<bool, ll> p = cal(P);
    pair<bool, ll> m = cal(M);
    
    if(!p.first or !m.first or p.second != m.second){
        cout << "No" << endl;
    }
    else cout << "Yes" << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 19024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

    if(x == 1 || x == 2*N-1){
        cout << "No" << endl;
        return 0;
    }

    if(N == 2){
        cout << "Yes" << endl;
        for(int i=1; i<=3; i++) cout << i << endl;
        return 0;
    }

    vector<int> ans(2*N+1, 0);
    if(x != 2){
        ans[N-1] = x-1;
        ans[N]   = x;
        ans[N+1] = x+1;
        ans[N+2] = x-2;

        int id = 0;
        for(int i=1; i<=2*N-1; i++){
            if(i == N-1 || i == N || i == N+1 || i == N+2) continue;

            id++;
            if(id == x-2) id = x+2;
            ans[i] = id;
        }

        cout << "Yes" << endl;
        for(int i=1; i<=2*N-1; i++) cout << ans[i] << endl;
    }
    else{
        ans[N-1] = x+2;
        ans[N]   = x;
        ans[N+1] = x-1;
        ans[N+2] = x+1;

        int id = 0;
        for(int i=1; i<=2*N-1; i++){
            if(i == N-1 || i == N || i == N+1 || i == N+2) continue;

            id++;
            if(id == x-1) id = x+3;
            ans[i] = id;
        }

        cout << "Yes" << endl;
        for(int i=1; i<=2*N-1; i++) cout << ans[i] << endl;
    }
}

Measured memory_bytes: 2304
#include<iostream>
using namespace std;
int main()
{
	int W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
	if(x-r>=0&&y-r>=0&&x+r<=W&&y+r<=H)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}	
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	vector<int> n(3);
	for (int i = 0; i < 3; i++) {
		cin >> n[i];
	}
	ssort(n);
	cout << n[2] * 10 + n[1] + n[0];

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

class MyClass
{
    static void Main(string[] args)
    {
        double[] time500 = { 35.5, 37.5, 40.0, 43.0, 50.0, 55.0, 70.0 };
        double[] time1000 = { 71.0, 77.0, 83.0, 89.0, 105.0, 116.0, 148.0 };
        string[] kyu = { "AAA", "AA", "A", "B", "C", "D", "E" };
        string str;
        while ((str = Console.ReadLine()) != null)
        {
            string[] str2 = str.Split(' ');
            double a = double.Parse(str2[0]);
            double b = double.Parse(str2[1]);
            bool owari = false;
            for (int i = 0; i < 7; i++)
            {
                if (a < time500[i] && b < time1000[i])
                {
                    Console.WriteLine(kyu[i]);
                    owari = true;
                    break;
                }
            }
            if (!owari)
            {
                Console.WriteLine("NA");
            }
        }
    }
}


Measured memory_bytes: 5692
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep2(i, x, n) for (int i = x; i < n; ++i)

int main()
{
    int m, k;
    cin >> m >> k;
    int n = pow(2,m);

    if(m==0 && k==0)
        cout << "0 0" << endl;
    else if(m==1 && k==0)
        cout << "0 0 1 1" << endl;
    else if(m>=2 && k<n)
    {
        rep(i,n)
        {
            if(i==k) continue;
            cout << i << " ";
        }
        cout << k << " ";
        rep(i,n)
        {
            if(n-i-1==k) continue;
            cout << n-i-1 << " ";
        }
        cout << k << endl;
    }
    else
        cout << -1 << endl;

    return 0;
}

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

int main(){
	int n;
	cin>>n;
	vector<int>arr(n);
	for(int i=0; i<n; i++) cin>>arr[i];
	for(int i=0; i<n; i++) arr.push_back(arr[i]);
	sort(arr.begin(),arr.end());
	reverse(arr.begin(),arr.end());
	arr.erase(arr.begin());
	long long ret = 0;
	for(int i=0; i<n-1; i++) ret+=arr[i];
	cout<<ret;
}

Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d;
    cin>>n>>d;
    d=d*2+1;
    if(n%d==0)
        printf("%d\n",n/d);
    else printf("%d\n",n/d+1);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n;
  string s,t;

  cin >> n >> s >> t;

  rep(i, n) {
    cout << s[i] << t[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
n,m,q=map(int,input().split())
S=[[0 for i in range(n+1)] for j in range(n+1)]
for i in range(m):
    l,r=map(int,input().split())
    S[l][r]+=1

for i in range(1,n+1):
    for j in range(1,n):
        S[i][j+1]+=S[i][j]

for i in range(q):
    a,b=map(int,input().split())
    ans=0
    for y in range(a,b+1):
        ans+=S[y][b]-S[y][a-1]
    print(ans)


Measured memory_bytes: 53592
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef pair<double,double> P;
typedef complex<double> CP;
typedef long long ll;

int a[1010][1010]={0};
ll b[1010][1010]={0};

int main(){
	int n;
	string s;
	while(cin>>n,n){
		/*
		rep(i,n){
			rep(j,n){
				b[i][j]=0;
			}
		}
		*/
		rep(i,n){
			cin>>s;
			rep(j,n){
				if(s[j]=='.'){
					a[i+1][j+1]=0;
				}
				else a[i+1][j+1]=1;
				
			}
		}
		
		rep(i,n){
			rep(j,n){
				if(j==0&&i==0){
					b[1][1]=a[1][1];
				}
				else if(j==0){
					b[i+1][1]=b[i][1]+a[i+1][1];
				}
				else if(i==0){
					b[1][j+1]=b[1][j]+a[1][j+1];
				}
				else{
					b[i+1][j+1]=b[i+1][j]+b[i][j+1]-b[i][j]+a[i+1][j+1];
				}
				//printf("%3d",b[i+1][j+1]);
			}
			//cout<<endl;
		}
		//cout<<endl;
		//cout<<b[n][n]<<endl;
		ll res=0;
		for(int i=0;i<n;i++){
			if(n-i<res) break;
			for(int j=0;j<n;j++){
				if(n-j<res) break;
				ll M=0;
				while(1){
					if(!(i+M+1<=n&&j+M+1<=n)){
						break;
					}
					if(b[i+M+1][j+M+1]-b[i+M+1][j]-b[i][j+M+1]+b[i][j]==0){
						M++;
					}
					else{
						break;
					}
				}
				res=max(res,M);
				//cout<<i<<" "<<j<<" "<<M-1<<endl;
			}
		}
		cout<<res<<endl;
				
	}
	return 0;
}
		

Measured memory_bytes: 13120
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;

const int mod = 1000000007;
struct mint{
    ll x;
    mint(ll x=0):x(x%mod){}
    mint& operator+=(const mint a){
        if ((x+= a.x) >= mod) x-= mod;
        return *this;
    }
    mint& operator-=(const mint a){
        if ((x+= mod - a.x) >= mod) x-= mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x*=a.x)%=mod;
        return *this;
    }
    mint operator+(const mint a) const{
        mint ans(*this);
        return ans+= a;
    }
    mint operator-(const mint a) const{
        mint ans(*this);
        return ans-= a;
    }
    mint operator*(const mint a) const{
        mint ans(*this);
        return ans*= a;
    }
};



int main(){
    int N;
    string s;
    cin >> N >> s;
    int cr = 0;
    int cb = 0;
    rep(i,N){
        if (s[i] == 'R'){
            cr++;
        }
        else{
            cb++;
        }
    }
    cout << (cr>cb?"Yes":"No");
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	string s;
	cin >> s;
	if (s[0] == '9' || s[1] == '9') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif
ll n;
ll dp[65][2][2][2];
ll calc(int ps,int lss,int cry,int mjr){
  if(ps<0) return (mjr==0&&cry==0);
  ll &ret = dp[ps][lss][cry][mjr];
 // printf("%lld\n",ret);
  if(ret==-1){
    int t = (lss)?1:((n>>ps)&1);
    ret=0;
   // printf("gg\n");
    REP(pl,t+1){
      REP(a,2) REP(b,2) if(a>=b){
        if(mjr&&(a==0||b==0)) continue;
        if(!mjr&&a==1&&b==1) continue;
        REP(nmjr,2) REP(ncry,2){
          int z = (a^b)+nmjr+ncry;
         // printf("%d\n",z);
          if((z>>1)!=cry) continue;
          if((z&1)!=pl) continue;
          ret+=calc(ps-1,lss|(pl<t),ncry,nmjr);
        }
      }
    }
    ret%=mod;
  }
  //printf("%d %d %d %d %lld\n",ps,lss,cry,mjr,ret);
  return ret;
}
int main(){
  scanf("%lld",&n);
  FILL(dp,-1);
  ll ans = calc(61,0,0,0);
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 256
import Data.Functor( (<$>))

main = do
    ls <- (takeWhile ("0 0"/=)) . lines <$> getContents
    let
	hws = (read <$>) . words <$> ls
	printRect [h,w] = putStrLn `mapM_` rect >> putStrLn ""
	  where
	    top = take w $ repeat '#'
	    bottom = top
	    mid = '#':(take (w-2) $ repeat '.')++"#"
	    rect = top:
		    (take (h-2) $ repeat mid)
		    ++[bottom]

    printRect `mapM_` hws



Measured memory_bytes: 4024
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define EQ(a,b) (abs((a)-(b))<EPS)
using namespace std;
typedef long double D;
const D EPS = 1e-8;

D getTime(D dx, D dy, D v, D fpx, D fpy, D fvx, D fvy){
  D px = fpx-dx, py = fpy-dy;
  D a = fvx*fvx + fvy*fvy - v*v;
  D b = 2*fvx*px + 2*fvy*py;
  D c = px*px + py*py;

  if(EQ(a,0)){
    if(EQ(b,0))return EQ(c,0)?0:-1;
    else return (-c/b<-EPS)?-1:-c/b;
  }else{
    D d = b*b - 4*a*c;
    if(d < -EPS)return -1;
    if(EQ(d,0))return (-b/2/a<-EPS)?-1:-b/2/a;
    D t1 = (-b-sqrt(d))/2/a, t2 = (-b+sqrt(d))/2/a;
    if(t1<-EPS)return (t2<-EPS)?-1:t2;
    return t1;
  }
}

int main(){
  int n,m;
  while(scanf("%d%d",&n,&m),n){
    vector<D> dx(n),dy(n),v(n);
    rep(i,n)scanf("%Lf%Lf%Lf",&dx[i],&dy[i],&v[i]);

    vector<int> cnt(n,0);
    rep(i,m){
      D fpx, fpy, fvx, fvy;
      scanf("%Lf%Lf%Lf%Lf",&fpx,&fpy,&fvx,&fvy);
      
      D minT = 1e10, minID = -1;
      vector<D> t(n);
      rep(i,n){
	t[i] = getTime(dx[i],dy[i],v[i], fpx,fpy,fvx,fvy);
	if(t[i]>-EPS && minT > t[i] + EPS){
	  minT = t[i]; minID = i;
	}
      }

      cnt[minID]++;
      rep(i,n){
	if(t[i]>-EPS){
	  D sx = fpx+fvx*t[i] - dx[i], sy = fpy+fvy*t[i] - dy[i];
	  D absS = sqrt(sx*sx + sy*sy);
	  if(EQ(absS,0))continue;
	  sx /= absS; sy /= absS;
	  dx[i] += sx * v[i] * minT; dy[i] += sy * v[i] * minT;
	}
      }
    }
    rep(i,n)printf("%d%c",cnt[i],i==n-1?'\n':' ');
  }
}

Measured memory_bytes: 1228
#include<iostream>
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: 3624
#include <iostream>
using namespace std;
int n,k,cnt;
 
int main() {
	cin>>n>>k;
	cnt = 0;
    for (int i = 1,x; i <= n; i++) {
        cin>>x;
        if (x >= k) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from typing import Callable, List, NoReturn

import numpy as np


def main() -> NoReturn:
    readline: Callable[[], str] = sys.stdin.readline
    n: int = int(readline().rstrip())
    a: np.ndarray = np.array(tuple(int(_) for _ in readline().rstrip().split()))

    xor_all: int = 0
    for a_n in a:
        xor_all ^= a_n

    values = np.bitwise_xor(a, xor_all)
    print(" ".join(tuple(str(v) for v in  values)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 49704
#include <stdio.h>

#define MIN(A,B) \
  ( (B) < (A) ? (B) : (A) )
#define MAX(A,B) \
  ( (B) > (A) ? (B) : (A) )

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{

  for ( ; ; )
  {
    int mx = 0, mn = 500;
    int n;

    scanf ( "%d", &n );
    if ( !( n ) ) break ;

    while ( n-- )
    {
      int a, b, c, d, e;

      scanf ( "%d%d%d%d%d", &a, &b, &c, &d, &e );
      d += a + b + c + e;

      mx = MAX( mx, d );
      mn = MIN( mn, d );
    }

    printf ( "%d %d\n", mx, mn );
  }

  return ( 0 );
}

Measured memory_bytes: 0
using System;

namespace AOJ0080
{
    class Program
    {
        public void Proc()
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) continue;
                int q = int.Parse(input);
                if (q == -1) break;

                double res = q / 2.000000;

                while ((res * res * res - q <= - 0.00001 * q)||(res * res * res - q >= 0.00001 * q))
                {
                    res = res - ((res * res * res - q) / (3 * res * res));
                }

                decimal output = Math.Round((decimal)res, 6);
                Console.WriteLine(output);
            }
            
        }
        static void Main(string[] args)
        {
            Program prg = new Program();
            prg.Proc();
        }
    }
}

Measured memory_bytes: 9484
// CODE by Kazhybay Askar

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

/*
find_by_order(k);
order_of_key(k);
ordered_set(int) s;
*/

/*
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
rng();
shuffle(permutation.begin(), permutation.end(), rng);
*/

/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC    optimize("Ofast")
#pragma GCC    target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#define F      first
#define S      second
#define pb     push_back
#define pf     push_front
#define ppb    pop_back
#define ppf    pop_front
#define Speed  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz     size()
#define all(x) x.begin(),x.end()
#define cont   continue
#define r0     return 0
#define nl     '\n'
#define ordered_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>

typedef unsigned long long ull;
typedef long long ll;
typedef long double   ld;
typedef pair<ll,ll>   pll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;

const int MAXN  = 5e5  + 7;
const int MOD   = 1e9  + 7;
const int INF   = 1e9  + 7;
const ll  MINF  = 1e18 + 7;
const int EPS   = 1e-6;
const int dx[]  = {0, 0, 1, -1, -1, -1, 1, 1};
const int dy[]  = {1, -1, 0, 0, -1, 1, -1, 1};
const double pi = acos(-1.0);

ll n,a[MAXN],k;

void solve(){
    cin>>n>>k;
    ll s = 0;
	for(ll i = k;i <= n;i++){
		s += n * (n + 1) / 2;
		s -= ((n - i) * (n - i + 1) / 2);
		s -= (i * (i - 1) / 2);
		++s;
		s %= MOD;
	}
	++s;
	s %= MOD;
	cout << s;
}



int main(){
    //freopen("A.in","r",stdin);
    //freopen("A.out","w",stdout);
    Speed;
    ll T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    r0;
}


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

int main(void){
  long n, t, a, h, diff = LONG_MAX, ans;
  cin >> n >> t >> a;
  for(int i = 0; i < n; i++){
    cin >> h;
    if(diff > abs(a*1000-t*1000+h*6)){
      diff = abs(a*1000-t*1000+h*6);
      ans = i+1;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debug(x) cerr<<#x<<" -> "<<x<<'\n'
#define debug2(x,y) cerr<<#x<<" -> "<<x<<" "<<#y<<" -> "<<y<<'\n'
#define debug3(x,y,z) cerr<<#x<<" -> "<<x<<" "<<#y<<" -> "<<y<<" "<<#z<<" -> "<<z<<'\n'

 
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;

using ordered_set = tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T>
struct CMP {
	bool operator() (const T& lhs, const T& rhs) const{
		return lhs < rhs;
	}
};

template <typename T>
T power(T a, T n){
	T res = 1;
	while(n > 0){
		if(n & 1) res = (res * a);
		a = (a * a);
		n >>= 1;
	}
	
	return res;
}

template <typename T>
T power(T a, T n, long long mm){
	T res = 1;
	while(n > 0){
		if(n & 1) res = (res * a) % mm;
		a = (a * a) % mm;
		n >>= 1;
	}
	
	return res;
}



struct S{
	ll all;
	ll black;
};

const ll N = 1e5+7;
const ll MOD = 1e9+7;
const ll INF = 2e14+7;

vector<int> edges[N];
S dp_down[N], dp_up[N];

void calc_down(int s, int p){
	
	dp_down[s] = {1, 1};
	
	for(auto v: edges[s]){
		if(v == p) continue;
		calc_down(v, s);
		dp_down[s].all = (dp_down[s].all * dp_down[v].all) % MOD;
		dp_down[s].black = (dp_down[s].black * ((dp_down[v].all - dp_down[v].black + MOD) % MOD))% MOD;
	}
	
	dp_down[s].all = (dp_down[s].all + dp_down[s].black) % MOD;
	
}



void testcase(){
	
	int n;
	cin>>n;
	int u, v;
	for(int i = 1; i < n; i++){
		cin>>u>>v;
		edges[u].pb(v);
		edges[v].pb(u);
		
	}
	
	calc_down(1, 0);
	cout<<(dp_down[1].all)<<'\n';
	
	
}

signed main(){
	fast;
	
	int t = 1;
	//cin>>t;
	while(t--){
		testcase();
	}
	
	return 0;
}


Measured memory_bytes: 14208
#include<stdio.h>

typedef long long int LL;

LL dp[1000][1000];
char map[1001][1001];
LL mod = 1000000007;

class solution {
private:
	int h, w;
	LL serc(int x, int y) {
		if (x == h - 1 && y == w - 1) return 1;
		if (dp[x][y] != -1) return dp[x][y];
		dp[x][y] = 0;
		if (x + 1 < h && map[x + 1][y] == '.') dp[x][y] = (dp[x][y] + serc(x + 1, y)) % mod;
		if (y + 1 < w && map[x][y + 1] == '.') dp[x][y] = (dp[x][y] + serc(x, y + 1)) % mod;
		return dp[x][y];
	}
	void reset() {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				dp[i][j] = -1;
			}
		}
	}
public:
	solution() {
		scanf("%d %d", &h, &w);
		for (int i = 0; i < h; i++) {
			scanf("%s", map[i]);
		}
		reset();
		printf("%lld\n", serc(0, 0));
	}
};

#ifndef L0C4L
int main() {
	solution();
	return 0;
}
#endif

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

int main() {
  int H, W, N;
  cin >> H >> W >> N;
  
  int a1 = 0, a2 = 0;
  int sum1 = 0, sum2 = 0;
  while (sum1 < N) {
    sum1 += H;
    a1++;
  }
  while (sum2 < N) {
    sum2 += W;
    a2++;
  }
  
  int ans;
  if (a1 <= a2)
    ans = a1;
  else
    ans = a2;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int mod = 1e9 + 7;
ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

int P[200001];
ll kotae = 0;
int N;
int to[400001], ne[400001], he[200001];
int dfs(int v, int prev) {
	int kazu = 1;
	int honsuu = 0;

	for (int u = he[v]; u; u = ne[u]) {
		if (to[u] != prev) {
			int k = dfs(to[u], v);
			kazu += k;
			honsuu++;
			kotae += P[k] - 1;
			if (kotae >= mod) kotae -= mod;
		}
	}
	
	kotae += P[N - kazu];
	if (kotae >= mod) kotae -= mod;

	return kazu;
}

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


	N = getint();
	int k = 1;
	rep(i, N - 1) {
		int a = getint(), b = getint();
		to[k] = b;
		ne[k] = he[a];
		he[a] = k++;
		to[k] = a;
		ne[k] = he[b];
		he[b] = k++;
	}
	P[0] = 1;
	rep1(i, N) {
		P[i] = P[i - 1] * 2;
		if (P[i] >= mod) P[i] -= mod;
	}

	dfs(1, 0);

	ll igai = ll(P[N - 1]) * N % mod;
	kotae = (igai - kotae + mod) % mod;
	kotae = kotae * modpow(P[N], mod - 2) % mod;

	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b){
  if(a%b == 0){
    return b;
  }else{
    return gcd(b, a%b);
  }
}
int lcm(int a, int b){
  return a*b / gcd(a, b);
}

int main(void){
    long long int i=0,j,a,b,c,d,p,q,f,g,h,t,z,m,aa;
    cin >> a >> b >> c >> d;
    q=lcm(c,d);
    p=b/c;
    aa=b/d;
    f=b/q;
    g=(a-1)/c;
    h=(a-1)/d;
    t=(a-1)/q;
    z=p+aa-f;
    m=g+h-t;
    a=a-1;
    cout << b-z+m-a << endl;
    
    return 0;

}


Measured memory_bytes: 3536
int main(){
	char S[3];
	char T[3];
	int count=0; 
	scanf("%s",S);
	scanf("%s",T);
	for(int i=0;i<3;i++){
		if(S[i]==T[i]){
			count++;
		}
	}
	printf("%d",count);
	return 0;
}

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

namespace AtTest.M_Solutions_2020
{
    class A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int x = ReadInt();
            int cnt = 1;
            if (x <= 599)
            {
                cnt++;
            }
            if (x <= 799)
            {
                cnt++;
            }
            if (x <= 999)
            {
                cnt++;
            }
            if (x <= 1199)
            {
                cnt++;
            }
            if (x <= 1399)
            {
                cnt++;
            }
            if (x <= 1599)
            {
                cnt++;
            }
            if (x <= 1799)
            {
                cnt++;
            }
            WriteLine(cnt);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
        #define eprintf(...) 42
#endif

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

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

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

vector<pair<int, double>> g[1010];

int main()
{
  int xs, ys, xt, yt, n;
  cin >> xs >> ys >> xt >> yt >> n;

  vl x(n+1), y(n+1), r(n+1);
  repi(i, 1, n+1) cin >> x[i] >> y[i] >> r[i];
  x[0] = xs; y[0] = ys; r[0] = 0;
  x.pb(xt); y.pb(yt); r.pb(0);

  rep(i, n+2) repi(j, i+1, n+2){
    double d = sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
    d = max(0.0, d-r[i]-r[j]);
    g[i].pb(mp(j, d));
    g[j].pb(mp(i, d));
  }

  priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> que;
  vector<double> dist(n+2, linf);
  que.push(mp(0.0, 0));
  dist[0] = 0;
  while(!que.empty()){
    pair<double, int> p = que.top();
    int v = p.second;
    que.pop();

    if(dist[v] < p.first) continue;
    for(auto e : g[v]){
      if(dist[e.first] > dist[v] + e.second){
        dist[e.first] = dist[v] + e.second;
        que.push(mp(dist[e.first], e.first));
      }
    }
  }

  printf("%.12f\n", dist[n+1]);

  return 0;
}


Measured memory_bytes: 21872
#include<bits/stdc++.h>
using namespace std;
void dfs(vector<vector<int>>&mp,int curr,vector<int>& cache){
  if(cache[curr]>0){
    return ;
  }
  
  if(mp[curr].size()==0){
    cache[curr] = 1;
    return ;
  }
  
  for(int i=0;i<mp[curr].size();++i){
    dfs(mp,mp[curr][i],cache);
    cache[curr] = max(cache[mp[curr][i]]+1,cache[curr]);
  }
}
int main(){
  int n,m;
  cin>>n>>m;
  vector<int> cache(n+1,0);
  vector< vector<int> > mp(n+1);
  int from,to;
  for(int i=0;i<m;++i){
    cin>>from>>to;
    mp[from].push_back(to);
  }
  int result = 0;
  for(int i=1;i<=n;++i){
      dfs(mp,i,cache);
  }
  for(int i=1;i<=n;++i){
    result = max(result,cache[i]);
    //cout<<cache[i]-1<<" ";
  }
  //cout<<endl;
  cout<<result-1<<endl;
  return 0;
}


Measured memory_bytes: 8192
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;


int main()
{
	
	const int num=100000;
	int n,m;
	cin>>n>>m;
	int a,b;
	int cnt[num]={};
	vector<int>ts;
	vector<vector<int>>way(n,vector<int>(1,-1));
	vector<int>queue;
	for(int i=0;i<m;i++)
	{
		cin>>a>>b;
		way[a-1].pop_back();
		way[a-1].push_back(b-1);
		way[a-1].push_back(-1);
		cnt[b-1]++;
	}
	for(int i=0;i<n;i++)
	{
		if(cnt[i]==0)
			queue.push_back(i);
	}
	for(int i=0;i<n;i++)
	{
		ts.push_back(queue[0]);
		for(int j=0;;j++)
		{
			if(way[queue[0]][j]==-1)
				break;
			if(--cnt[way[queue[0]][j]]==0){
				queue.push_back(way[queue[0]][j]);
			}
		}
		queue.erase(queue.begin());
	}
	int dp[num];
	for(int i=n-1;i>=0;i--)
	{
		int mx=-1;
		for(int j=0;;j++)
		{
			if(way[ts[i]][j]==-1)
				break;
			mx=max(mx,dp[way[ts[i]][j]]);
		}
		dp[ts[i]]=mx+1;
	}
	int mxa=-1;
	for(int i=0;i<n;i++)
	{
		mxa=max(mxa,dp[i]);
	}
	cout<<mxa<<endl;

}
	

Measured memory_bytes: 7416
N,M = map(int,input().split())
s = [list(map(int,input().split())) for i in range(M)]
p = list(map(int,input().split()))
l = [False] * (N+1) #l[1] is True when lightbulb 1 is on and False when off
ans = 0
for i in range(2**N):
    for j in range(N):
        if ((i >> j)&1):
            l[j+1] = True
        else:
            l[j+1] = False
    for k in range(M):
        cnt = 0
        for m in range(1,s[k][0]+1):
            if l[s[k][m]] == True:
                cnt += 1
        if cnt % 2 != p[k]:
            break
        if k == M-1:
            ans += 1
print(ans)
        

Measured memory_bytes: 9220