akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> pii;
typedef long long ll;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e9;
const ll MOD=1e9+7;
struct edge{
    int to;
    int cost;
};
int main(){
    int N;cin>>N;
    vector<ll> A(N);
    for(int i=0;i<N;++i) cin>>A[i];
    bool p=true,n=true;
    for(int i=0;i<N;++i){
        if(A[i]<0) p=false;
        if(A[i]>0) n=false;
    }
    int cnt=0;
    vector<ii> ans;
    if(!p&&!n){
        int mn=1,mx=-1;
        int imx=-1,imn=-1;
        for(int i=0;i<N;++i){
            if(mx<A[i]){
                mx=A[i];
                imx=i;
            }
            if(mn>A[i]){
                mn=A[i];
                imn=i;
            }
        }
        if(abs(mx)>=abs(mn)){
            for(int i=0;i<N;++i){
                A[i]+=mx;
                cnt++;
                ans.push_back(ii(imx+1,i+1));
            }
            p=true;
        }else{
            for(int i=0;i<N;++i){
                A[i]+=mn;
                cnt++;
                ans.push_back(ii(imn+1,i+1));
            }
            n=true;
        }
    }
    if(p){
        for(int i=1;i<N;++i){
            cnt++;
            ans.push_back(ii(i,i+1));
        }
    }
    if(n){
        for(int i=N;i>1;--i){
            cnt++;
            ans.push_back(ii(i,i-1));
        }
    }
    cout<<cnt<<endl;
    for(int i=0;i<(int)ans.size();++i){
        cout<<ans[i].first<<' '<<ans[i].second<<endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <bitset>

#define rep(i, n) for (int i = 0; i < n; i++)
#define Rep(i, m, M) for (int i = m; i < M; i++)

typedef long long ll;

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;


int main()
{
    int N;
    cin >> N;
    vint A(N + 1);
    vvint x(N + 1);
    vector<vector<bool>> y(N + 1);
    int c = 0;
    vector<int> ans(N + 1, -1), cons(N + 1, -1); //i番目が正直かどうか
    for (int i = 1; i <= N; i++)
    {
        cin >> A[i];
        x[i].resize(A[i] + 1);
        y[i].resize(A[i] + 1);
        for (int j = 1; j <= A[i]; j++)
        {
            int k;
            cin >> x[i][j];
            x[i][j];
            cin >> k;
            y[i][j] = (bool)k;
        }
    }
    for (int bit = 1; bit < (1 << N); bit++)
    {
        bool ok = true;
        ans = cons;
        for (int k = 0; k < 2;k++)
        {
            for (int i = 1; i <= N; i++)
            {
                if (bit & (1 << (i - 1)) or ans[i] == 1)
                {
                    ans[i] = 1;
                    for (int j = 1; j <= A[i]; j++)
                    {

                        if (ans[x[i][j]] == -1)
                            ans[x[i][j]] = y[i][j];
                        else if (ans[x[i][j]] != y[i][j])
                        {
                            ok = false;
                        }
                    }
                }
                else if ((bit & (1 << (i - 1))) == 0)
                {
                    if (ans[i] == -1)
                        ans[i] = 0;
                }
            }
        }
        if (ok)
            c = max(c, (int)bitset<16>(bit).count());
    }
    cout << c;
}


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

int const mod = 1000000007;

int main() {
	int N;
	cin >> N;
	vector<int> A(N);

	int x = 0;
	long long ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		ans += (long long)x * A[i] % mod;
		x = ((long long)x + A[i]) % mod;
	}

	ans %= mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3992
from itertools import accumulate

n, k = map(int,input().split())
l = list(map(int,input().split()))
#print(l)

p = [0] + list(accumulate(l))

#print(p)

q = []
for i in range(n-k+1):
    q.append((p[i+k] - p[i] + k)/2)

print(max(q))


Measured memory_bytes: 25152
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <string>
#include <map>
#include <string.h>

using namespace std;

int main()
{
    string s;
    cin >> s;

    int g=0,p=0;
    for (int i=0;i<s.size();++i) {
        if (s[i]=='g') g++;
        else p++;
    }

    cout << (g - p)/2 << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  int r, g, b;
  cin >> r >> g >> b;
  if((10*g + b) % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <limits>
#include <vector>
#include <algorithm>
#include <functional>
#include <cctype>
#include <sstream>

typedef long long lint;

using namespace std;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);++i)
#define all(x) (x).begin(),(x).end()
#define sl(c) (('a')<=(c)&&(c)<=('z'))
#define ll(c) (('A')<=(c)&&(c)<=('Z'))
#define makeupper(t) transform(all(t),t.begin(),::toupper);
#define makelower(t) transform(all(t),t.begin(),::tolower);
lint* arr1(lint x) {
	lint *array = new lint[x];
	rep(i, x)array[i] = 0;
	return array;
}
lint** arr2(lint x, lint y) {
	lint **array = new lint*[x];
	rep(i, x)array[i] = new lint[y];
	rep(i, x)rep(j, y)array[i][j] = 0;
	return array;
}
vector<string> split(const string &s, char delim) {
	vector<string> elems;
	stringstream ss(s);
	string item;
	while (getline(ss, item, delim)) {
		if (!item.empty()) {
			elems.push_back(item);
		}
	}
	return elems;
}

int main() {
	int n,m,ta=0,ha=0;
	cin >> n;
	rep(i,n){
		string s, t;
		cin >> s>>t;
		if (s>t)ta += 3;
		if (s<t)ha += 3;
		if (s==t) { ta++; ha++; }
	}
	cout << ta << " " << ha<<"\n";
}


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

#define FOR(i,b,e) for (int i = (b); i <= (e); i++)
#define FORD(i,b,e) for (int i = (b); i >= (e); i--)
#define SIZE(c) ((int) (c).size())

#define pb push_back
#define st first
#define nd second

using namespace std;


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

typedef vector <int> VI;
typedef vector <ll> VL;
typedef vector <bool> VB;
typedef vector <pii> VP;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;


int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    map <int,int> cnt;

    FOR(_,1,n) {
        int x;
        cin >> x;

        cnt[x]++;
    }

    VI keys;
    for (auto &e : cnt) {
        keys.pb(e.st);
    }

    bool ans;
    if (SIZE(keys) == 1) {
        ans = keys[0] == 0;
    } else if (SIZE(keys) == 2) {
        int x = max(keys[0], keys[1]);
        ans = (cnt[x] == 2 * cnt[0]);
    } else if (SIZE(keys) == 3) {
        int x = keys[0], y = keys[1], z = x ^ y;
        ans = (keys[2] == z) && (cnt[x] == cnt[y]) && (cnt[y] == cnt[z]);
    } else {
        ans = false;
    }

    cout << (ans ? "Yes" : "No");

    return 0;
}

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

#define Fast           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO             freopen("in.txt", "r", stdin)
#define FC             freopen("out.txt", "w", stdout)
#define aise           cout<<"aise"<<endl
#define pb             push_back
#define pf             push_front
#define ppb            pop_back
#define ppf            pop_front
#define mp             make_pair
#define ll             long long
#define all(x)         x.begin(), x.end()
#define mset(v, a)     memset(v, a, sizeof(v))
#define pll            pair< ll, ll >
#define pd             pair< double, double >
#define ff             first
#define ss             second
#define pi             acos(-1.0)
#define mxN            2010
#define inf            1e14
#define mod            1000000007
#define tc             ll tc;scanf("%lld",&tc);while(tc--)

//NCR iterative
/*voidcomb_table(intN)
{
    for(inti=0; i<=N; ++i)
    {
        for(intj=0; j<=i; ++j)
        {
            if(j==0or j==i)
            {
                C[i][j]=1LL;
            }
            else
            {
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}*/


//NCR recursive
/*ll dp[55][55];

ll NCR(ll n,ll r)
{

    if(n==r)
        return dp[n][r]=1;
    if(r==0)
        return dp[n][r]= 1;
    if(r==1)
        return dp[n][r]=n ;
    if(dp[n][r] != -1)
        return dp[n][r];
    return dp[n][r] = NCR(n-1,r)+NCR(n-1,r-1);
}*/

//Sieve:
/*bool Flag[1000010];
vector<ll> Prime;

void sieve()
{

    ll val=sqrt(1000010);
    for(ll i=4;i<=1000005; i+=2) Flag[i]=1;
    for(ll i=3;i <= val;i+=2)
    {

        if(Flag[i]==0)
        {

            for(ll j=i*i;j<=1000005;j+=i) Flag[j]=1;
        }
    }
    Flag[1]=1;
    for(ll i=1;i<=1000000;i++)
        if(Flag[i]==0) Prime.pb(i);
}*/


//Conversion
/*string bin(ll x)
{

    string ret;
    while(x)
    {

        ll t=x%2;
        char c;
        if(t==1)
            c='1';
        else
            c='0';
        ret.pb(c);
        x/=2;
    }
    reverse(all(ret));
    return ret;
}*/

/*ll lcm(ll x, ll y)
{

    ll ret=__gcd(x,y);
    return (x*y)/ret;
}*/

/*ll dx[]= {0,0,1,-1};
ll dy[]= {1,-1,0,0};*/

int main()
{

    ll n;
    cin >> n;
    vector<ll> v;
    for(ll i=0;i<n;i++)
    {

        ll x;
        cin >> x;
        v.pb(x);
    }
    sort(all(v));
    ll ans=0;
    for(ll i=0;i<v.size();i++)
    {

        for(ll j=i+1;j<v.size();j++)
        {

            if(v[i]==v[j]) continue;
            for(ll k=j+1;k<v.size();k++)
            {

                if(i!=k && j!=k && v[i] !=v[k] && v[j] != v[k])
                {

                    if(v[i]+v[j] > v[k] && v[i]+v[k] > v[j] && v[j]+v[k] > v[i])
                    {

                        ans++;
                        //cout << v[i] << " " << v[j] << " " << v[k] << endl;
                    }
                }
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int selectionSort(vector<int>& vector_array,int n){
    int counter = 0;
    rep(i,n-1){
        int minj = i;
        for(int j = i;j < n;j++){
            if(vector_array[j] < vector_array[minj]) minj = j;
        }
        if(minj > i) {
            swap(vector_array[i],vector_array[minj]);
            counter++;
        }
    }
    return counter;
}

int main(){
    int n;
    cin >> n;
    vector<int> num_array(n,0);
    rep(i,n){
        cin >> num_array[i];
    }
    int counter = selectionSort(num_array,n);
    rep(i,n){
        cout << num_array[i];
        if(i < n-1) cout << " ";
    }
    cout << "\n" << counter << "\n";

    return 0;   
}


Measured memory_bytes: 3088
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const long long MOD = 1000000007;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

template <i64 mod = MOD>
struct ModInt{
    i64 p;

    ModInt() : p(0){}
    ModInt(i64 x){p = x >= 0 ? x % mod : x + (-x + mod - 1) / mod * mod;}

    ModInt& operator+=(const ModInt& y){p = p + *y - ((p + *y) >= mod ? mod : 0); return *this;}
    ModInt& operator-=(const ModInt& y){p = p - *y + (p - *y < 0 ? mod : 0); return *this;}
    ModInt& operator*=(const ModInt& y){p = (p * *y) % mod; return *this;}
    ModInt& operator%=(const ModInt& y){if(y)p %= *y; return *this;}

    ModInt operator+(const ModInt& y) const{ModInt x = *this; return x += y;}
    ModInt operator-(const ModInt& y) const{ModInt x = *this; return x -= y;}
    ModInt operator*(const ModInt& y) const{ModInt x = *this; return x *= y;}
    ModInt operator%(const ModInt& y) const{ModInt x = *this; return x %= y;}

    friend ostream& operator<<(ostream& stream, const ModInt<mod>& x){
        stream << *x;
        return stream;
    }

    friend ostream& operator>>(ostream& stream, const ModInt<mod>& x){
        stream >> *x;
        return stream;
    }

    ModInt& operator++(){p = (p + 1) % mod; return *this;}
    ModInt& operator--(){p = (p - 1 + mod) % mod; return *this;}

    bool operator==(const ModInt& y) const{return p == *y;}
    bool operator!=(const ModInt& y) const{return p != *y;}

    const i64& operator*() const{return p;}
    i64& operator*(){return p;}

};

using mint = ModInt<>;

auto mpow = [](auto x, i64 y){
    if(y < 0)
        return mint(0);
 auto z = x;
 decltype(x) val = y & 1 ? x : decltype(x)(1);
 while(z *= z, y >>= 1)
  if(y & 1)
   val *= z;
 return val;
};


void solve(long long n, std::vector<long long> c){
    sort(c.begin(), c.end());
    mint ans = 0;
    for(int i = 0; i < n; ++i){
        int k = n - i - 1;
        mint val = 0;
        val += mint(k) * mpow(mint(2), k - 1) * mpow(mint(2), i);
        val += mpow(mint(2), n - 1);

        ans += val * c[i];
        // ans += val * mpow(mint(2), n - 1);
    }
    cout << ans * mpow(mint(2), n) << endl;
}


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


Measured memory_bytes: 1792
import Data.List
import Control.Monad
main :: IO ()
main = do
  ae <- replicateM 5 readLn
  let b = span (\x -> x `mod` 10 == 0) $ sortOn (`mod` 10) ae
  let c = if snd b /= [] then head (snd b) : map (\x -> (x `div` 10 + 1) * 10) (tail $ snd b) else []
  print $ sum (fst b) + sum c



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

template<class T> inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    string s, t;
    cin >> s >> t;

    vector<int> s_table(26, -1);
    vector<int> t_table(26, -1);

    rep(i, s.size()) {
        int a = s[i] - 'a';
        int b = t[i] - 'a';

        if(s_table[a] != -1 || t_table[b] != -1) {
            if(s_table[a] != b || t_table[b] != a) {
                cout << "No" << endl;
                return 0;
            }
        }

        s_table[a] = b;
        t_table[b] = a;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3788
#include <iostream>

int main() {
        int h, w;
        while (1) {
                std::cin >> h >> w;
                if (h == 0 && w == 0) break;
                for (int i = 0; i < h; i++) {
                        for (int j = 0; j < w; j++) {
                                if (i == 0 || j == 0 || i == h - 1 || j == w - 1)
                                        std::cout << "#";
                                else
                                        std::cout << ".";
                        }
                        std::cout << std::endl;
                }
                std::cout << std::endl;
        }
        return 0;
}



Measured memory_bytes: 3084
n=int(input(''))
a=input('')
a=a.split(' ')
for i in range(n-1):
    a[i]=int(a[i])

l=[]
for i in range(n):
    l.append(0)

for i in range(n-1):
    l[a[i]-1]+=1

for i in l:
    print(i)

Measured memory_bytes: 25864
#include <stdio.h>
int n, x, y, z;
int a[100000];
int main() {
	scanf("%d", &n);
	x = n;
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i);
		if (a[i] < x)x = a[i];
		if (a[i] > y)y = a[i];
	}
	if (y - x > 1) {
		printf("No\n");
		return 0;
	}
	if (y == x) {
		if (y == n - 1)printf("Yes\n");
		else if (y <= n / 2)printf("Yes\n");
		else printf("No\n");
		return 0;
	}
	for (int i = 0; i < n; i++) {
		if (a[i] == x)z++;
	}
	if (z < y && y <= z + (n - z) / 2)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 2020
A, B = STDIN.gets.split(' ').map{|s|s.to_i}

a1 = (A / 0.08).ceil
a2 = if ((A + 1) / 0.08) % 1 == 0
       ((A + 1) / 0.08) - 1
     else
       ((A + 1) / 0.08).floor
     end
b1 = (B / 0.1).ceil
b2 = if ((B + 1) / 0.1) % 1 == 0
       ((B + 1) / 0.1) - 1
     else
       ((B + 1) / 0.1).floor
     end

#puts "a1:#{a1} a2:#{a2} b1:#{b1} b2:#{b2}"

if b2 < a1
  puts '-1'
elsif a2 < b1
  puts '-1'
elsif a1 <= b1
  puts b1
elsif b1 <= a1
  puts a1
end



Measured memory_bytes: 1788
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException
    {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] arr = new int[N];
        for(int i=0;i<N;i++)
            arr[i] = sc.nextInt();
        Arrays.sort(arr);

        long comfort = arr[N-1];
        int x = N-2;
        int y = N-5;
        for(int i=N-3;i>=0;i--)
        {
            if(i==y)
            {
                x--;
                y = i-2;
            }
            comfort += arr[x];
        }

        System.out.println(comfort);
    }
}

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

using namespace std;

unsigned long long n, m;

int main()
{
    cin>>n>>m;
    if (n==1 && m==1)
    {
        cout<<1;
    }
    else
    {
        if (n==1 || m==1)
        {
            cout<<n*m-2;
        }
        else
        {
            cout<<(n-2)*(m-2);
        }
    }
    return 0;
}


Measured memory_bytes: 256
/*--------------------------"SABUJ-JANA"------"JADAVPUR UNIVERSITY"--------*/
/*-------------------------------@greenindia-----------------------------------*/
//
//		  _____       _           _        _
//		 / ____|     | |         (_)      | |
//		| (___   __ _| |__  _   _ _       | | __ _ _ __   __ _
//		 \___ \ / _` | '_ \| | | | |  _   | |/ _` | '_ \ / _` |
//		 ____) | (_| | |_) | |_| | | | |__| | (_| | | | | (_| |
//		|_____/ \__,_|_.__/ \__,_| |  \____/ \__,_|_| |_|\__,_|
//		                        _/ |
//		                       |__/
/*---------------------- Magic. Do not touch.-----------------------------*/
/*------------------------------God is Great/\---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//cout<<fixed<<showpoint<<setprecision(12)<<ans<<endl;
#define int long long int
#define double long double
#define PI acos(-1)

void print1d(const vector<int>& vec) {for (auto val : vec) {cout << val << " ";} cout << endl;}

void print2d(const vector<vector<int>>& vec) {for (auto row : vec) {for (auto val : row) {cout << val << " ";} cout << endl;}}

signed main() {
 
	crap;

	int n;
	cin >> n;

	vector<int> arr(n), dp(n, INT_MAX);
	for (int i = 0; i < n; ++i){
		cin >> arr[i];
	}


	dp[0] = 0;
	dp[1] = abs(arr[0] - arr[1]);

	for (int i = 2; i < n; ++i){
		for (int j = 1; j <= 2; ++j){
			dp[i] = min(dp[i], dp[i-j] + abs(arr[i] - arr[i - j]));
		}
	}

	// print1d(dp);
	cout << dp[n-1] << endl;

	

	 

	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll power(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)

//your code here!

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

    //例外
    ll t1=0, t2=0, j=0;
    while(S[j]!='\0' && S[j]=='>') {t1++; j++;}
    while(S[j]!='\0' && S[j]=='<') {t2++; j++;}
    if(S[j]=='\0') {
        printf("%lld\n", t1*(t1+1)/2 + t2*(t2+1)/2);
        return 0;
    }

    ll i=0, ans1=0, ans2=0, ans=0;
    if(S[i]=='>') while(S[i++]=='>') ans1++;
    ans += ans1*(ans1+1)/2;
    ans1=0;

    while(S[i]!='\0') {
        if(S[i]=='<') ans1++;
        else          ans2++;

        if(S[i]=='>' && S[i+1]=='<') {
            ll MM=max(ans1, ans2), mm=ans1+ans2-MM-1;
            ans1=ans2=0;
            ans += MM*(MM+1)/2 + mm*(mm+1)/2;
        }

        i++;
    }

    ll MM=max(ans1, ans2), mm=ans1+ans2-MM-1;
    ans1=ans2=0;
    ans += MM*(MM+1)/2 + mm*(mm+1)/2;

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    for (int i=0;i<=4;i++)
    {
        int a;
        cin >> a;

        if (a==0)
        {
            cout << i+1 << endl;
        }
    }

    return 0;
}

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

int main() {
  int r = 0, D = 0;
  vector<int> x(11, 0);
  cin >> r >> D >> x[0];
  
  // d = D / (r - 1);
  
  for (int i = 1; i < 11; i++) {
    x[i] = r * x[i - 1] - D;
    cout << x[i] << endl;
  }
  
  return 0; 
}

Measured memory_bytes: 256
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn main() {
    let nm = readn::<usize>(" ");
    let n = nm[0];
    let m = nm[1];
    let h = readn::<usize>(" ");
    let mut good = vec![1; n];

    for _ in 0..m {
        let ab = readn::<usize>(" ");
        let a = ab[0] - 1;
        let b = ab[1] - 1;
        if good[a] == 1 {
            if h[b] >= h[a] { good[a] = 0; }
        }
        if good[b] == 1 {
            if h[a] >= h[b] { good[b] = 0; }
        }
    }

    let ans = good.iter().sum::<usize>();
    println!("{}", ans);
}

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

int main()
{
       ll a,b;
       cin>>a>>b;
       if(a%b==0)
       {
           cout<<0<<endl;
       }
       else
       {
           cout<<1<<endl;
       }


    return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(long long i=(l);i<(r);i++)
#define dec(i, l, r)   for(long long i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int cum[1005][1005][2];
int sum[1005][1005][2];

inline int sf(int i, int j, int k) {
    if(i < 0 || j < 0) return 0;
    return sum[i][j][k];
}

int f(int i, int j, int fi, int fj, int k) {
    return sf(i+1, j+1, k)-sf(i+1, fj, k)-sf(fi, j+1, k)+sf(fi, fj, k);
}

int main() {
    std::ios::sync_with_stdio(false);
    int n, k;cin >> n >> k;
    vector<int> x(n), y(n);
    vector<char> c(n);
    inc(i, 0, n) cin >> x[i] >> y[i] >> c[i];
    map<pair<pair<int, int>, char>, int> st;
    mset(cum, 0);
    mset(sum, 0);
    inc(i, 0, n){
        int m = x[i]/k + y[i]/k;
        char cc = c[i];
        if(m%2 != 0){
            if(cc == 'B'){
                cc = 'W';
            }else{
                cc = 'B';
            }
        }
        st[{{x[i]%k, y[i]%k}, cc}]++;
    }

    for(auto kv : st){
        auto s = kv.fi;
        int v = kv.se;
        int x = s.fi.fi;
        int y = s.fi.se;
        int c = s.se == 'B' ? 1 : 0;
        cum[x][y][c] += v;
    }

    inc(i, 1, 1005){
        inc(j, 1, 1005){
            sum[i][j][0] = sum[i][j-1][0] + sum[i-1][j][0] - sum[i-1][j-1][0] + cum[i-1][j-1][0];
            sum[i][j][1] = sum[i][j-1][1] + sum[i-1][j][1] - sum[i-1][j-1][1] + cum[i-1][j-1][1];
        }
    }

    //inc(i, 0, 10){
        //inc(j, 0, 10){
            //cout << cum[i][j][0] << " ";
        //}
        //cout << endl;
    //}
    //cout << endl;

    //inc(i, 0, 10){
        //inc(j, 0, 10){
            //cout << cum[i][j][1] << " ";
        //}
        //cout << endl;
    //}

    int ans = 0;
    inc(i, 0, k+1){
        inc(j, 0, k+1){
            int a1 = f(k-1, k-1, i, j, 1)+f(i-1, j-1, 0, 0, 1)
                    +f(k-1, j-1, i, 0, 0)+f(i-1, k-1, 0, j, 0);
            int a2 = f(k-1, k-1, i, j, 0)+f(i-1, j-1, 0, 0, 0)
                    +f(k-1, j-1, i, 0, 1)+f(i-1, k-1, 0, j, 1);
            //if(i<5 && j<5) cout << i << j << " " << a1 << " " << a2<< endl;
            ans = max({ans, a1, a2});
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 23040
import math
while True:
    n=int(input())
    if n==0:
        break
    
    lis=list(map(int,input().split()))
    m=sum(lis)/n
    s=0
    for i in range(n):
        s+=(lis[i]-m)*(lis[i]-m)
    a=math.sqrt(s/n)
    print("{:10f}".format(a))
    


Measured memory_bytes: 5700
#include <stdio.h>

int main(){
  int t,n,i,a[100],Max,Min;
  scanf("%d",&t);
  while(t--){
    scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf("%d",&a[i]);
    }
    Max = Min = a[1] - a[0];
    for(i=1;i<n-1;i++){
      if(Max < a[i+1]-a[i])Max = a[i+1]-a[i];
      if(Min > a[i+1]-a[i])Min = a[i+1]-a[i];
    }
    if(Max >= 0 && Min <= 0) printf("%d %d\n",Max,-Min);
    if(Max < 0) printf("%d %d\n",0,-Min);
    if(Min > 0) printf("%d %d\n",Max,0);
  }
  return 0;
}

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

#define INF (i64)(1e18)
#define MOD (i64)(1e9+7)
#define REP(i, n) for(i64 i = 0; i < (n); i++)
#define RREP(i, n) for(i64 i = (n)-1; i >= 0; i--)
#define RANGE(i, a, b) for(i64 i = (a); i < (b); i++)
#define RRANGE(i, a, b) for(i64 i = (b)-1; i >= (a); i--)
#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) ((i64)(v).size())
template<class T> inline void chmax(T &a, const T &b) { if (a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if (a > b) a = b; }

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  REP(i, h) cin >> s.at(i);
  vector<vector<int>> l(h, vector<int>(w)), r(h, vector<int>(w)), d(h, vector<int>(w)), u(h, vector<int>(w));
  REP(i, h) {
    int cnt = 0;
    REP(j, w) {
      if (s[i][j] == '.') {
        cnt++;
        l[i][j] = cnt;
      } else if (s[i][j] == '#') {
        cnt = 0;
      }
    }
  }
  REP(i, h) {
    int cnt = 0;
    RREP(j, w) {
      if (s[i][j] == '.') {
        cnt++;
        r[i][j] = cnt;
      } else if (s[i][j] == '#') {
        cnt = 0;
      }
    }
  }
  REP(j, w) {
    int cnt = 0;
    REP(i, h) {
      if (s[i][j] == '.') {
        cnt++;
        d[i][j] = cnt;
      } else if (s[i][j] == '#') {
        cnt = 0;
      }
    }
  }
  REP(j, w) {
    int cnt = 0;
    RREP(i, h) {
      if (s[i][j] == '.') {
        cnt++;
        u[i][j] = cnt;
      } else if (s[i][j] == '#') {
        cnt = 0;
      }
    }
  }
  int ans = 0;
  REP(i, h) {
    REP(j, w) {
      chmax(ans, l[i][j] + r[i][j] + d[i][j] + u[i][j] - 3);
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
    int a,b;

    cin >> a >> b;

    string s = to_string(a);
    string t = to_string(b);

    string sa = "", sb="";

    rep(i,b) sa += s;
    rep(i,a) sb += t;

    string ans;
    if (sa <= sb) ans = sa;
    else ans = sb;

    cout << ans << endl;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b)
{
    return b ? gcd(b, a % b) : a;
}
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

void func(long long N, long long M)
{
    if (N - M == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int main()
{
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    func(N, M);
    return 0;
}


Measured memory_bytes: 256
n,c=map(int,input().split())
ls=[[set(),set()] for i in range(30)]
l=[0]*(10**5+1)
for i in range(n):
    s,t,c=map(int,input().split())
    if s in ls[c-1][1]:ls[c-1][1].remove(s)
    else:ls[c-1][0].add(s-1)
    if t-1 in ls[c-1][0]:ls[c-1][0].remove(t-1)
    else:ls[c-1][1].add(t)
for i in ls:
    for j in i[0]:
        l[j]+=1
    for j in i[1]:
        l[j]-=1
for i in range(10**5):
    l[i+1]+=l[i]
print(max(l))

Measured memory_bytes: 18604
#include <iostream>

using namespace std;

int main() {
  int x,y;
  cin >> x >> y;
  int l,s;
  l = max(x,y);
  s = min(x,y);
  while (s != 0) {
    int mod = l % s;
    l = s;
    s = mod;
  }

  cout << l << endl;
  return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    int sum = 0;
    for (int i = 0; i < k; ++i) {
        sum += p[i];
    }
    int ans = sum;
    for (int i = k; i < n; ++i) {
        sum += p[i];
        sum -= p[i - k];
        ans = max(ans, sum);
    }
    cout << setprecision(30) << (double)(ans + k) / 2.0 << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


void solve(long long X){
    lint x, y;
    for(x = -2000; x <= 2000; x++){
        for(y = -2000; y <= 2000; y++){
            if ( (x*x*x*x*x - y*y*y*y*y) == X){
                cout << x << " " <<  y << endl;
                return;
            }
        }
    }
}

int main(){

    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}



Measured memory_bytes: 3676
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
const ll fact_table = 800008;
double Pi = 3.1415926535897932384626;
 
//vector<ll> G[550010];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
//ll mod = 998244353;
ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k;
ll ans;
ll x[200005], y[500005], z[200005];
bool used[500005];
char s[500005];
ll query;

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

    cin >> n >> m;
    ll num = 1;
    for(ll i=0;i<n;i++){
        cin >> x[i];
        x[i] /= 2;
        num = num * x[i] / gcd(num , x[i]);
        if(num > 1000000000ll){
            p(0);
            return 0;
        }
        x[i] *= 2;
    }
    for(ll i=0;i<n;i++){
        if(num % x[i] == 0){
            p(0);
            return 0;
        }
        
    }
    ll ans = m / num;
    ans = (ans + 1) / 2;
    p(ans);


    return 0;
}











Measured memory_bytes: 13952
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge
{
    ll to, cost, val;
};
template <class T, class U>
bool chmin(T &a, const U &b)
{
    if (a <= b)
        return false;
    a = b;
    return true;
}
template <class T, class U>
bool chmax(T &a, const U &b)
{
    if (a >= b)
        return false;
    a = b;
    return true;
}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll


signed main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    ll M,V,P;
    cin>>N>>M>>V>>P;

    vector<ll> A(N);
    for(int i=0;i<N;i++) cin>>A[i];
    A.push_back(INF);
    sort(A.rbegin(),A.rend());
    int ans=0,count=0,NN;
    ll sum=0;
    for(int i=1;i<=N;i++,ans++){
        if(i<=P-1) continue;
        if(i==P){
            sum+=A[i];
            NN=A[i];
            count++;
            continue;
        }
        ll x=V-(N-i+1)-(P-1);
        if(x<0) x=0;
        ll r=(count-x)*M;
        //cout<<r<<" "<<sum-A[i]*count<<endl;
        if(NN-A[i]>M) break;
        if(sum-A[i]*count>r) break;
        sum+=A[i]; 
        count++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main() {
 int n;
  cin>>n;
  int a[n];
  rep(i, n)cin>>a[i];
  
  int sum=0;
  rep(i, n)sum+=a[i];
  
  cout<<sum-n<<endl;
}

Measured memory_bytes: 256
using System;

namespace _158
{
  class Program
  {
    static void Main(string[] args)
    {
      var scan = new Scanner();

      var A = scan.nextInt();
      var B = scan.nextInt();
      var C = scan.nextInt();

      var e = (A + B + 1) > C ? C : (A + B + 1);

      Console.WriteLine(B + e);
    }
  }

  class Scanner
  {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
      s = new string[0];
      i = 0;
    }

    public string next()
    {
      if (i < s.Length) return s[i++];
      string st = Console.ReadLine();
      while (st == "") st = Console.ReadLine();
      s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
      if (s.Length == 0) return next();
      i = 0;
      return s[i++];
    }

    public int nextInt()
    {
      return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
      int[] Array = new int[N];
      for (int i = 0; i < N; i++)
      {
        Array[i] = nextInt() + add;
      }
      return Array;
    }

    public long nextLong()
    {
      return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
      long[] Array = new long[N];
      for (int i = 0; i < N; i++)
      {
        Array[i] = nextLong() + add;
      }
      return Array;
    }

    public double nextDouble()
    {
      return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0)
    {
      double[] Array = new double[N];
      for (int i = 0; i < N; i++)
      {
        Array[i] = nextDouble() + add;
      }
      return Array;
    }
  }

}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int N, A; cin >> N >> A;

  auto ans = N*N - A;
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<algorithm>
#include<iterator>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#define lli long long int
#define mp make_pair
#define ULTRA_INSTINCT ios_base::sync_with_stdio(false); cin.tie(0)
#define PI  3.141592653589793
#define fo(i,n) for(lli i=0;i<(n);i++)
#define FO(i,x,n) for(lli i=(x);i<(n);i++)
#define pb push_back
#define FI first
#define SE second
#define vi vector<lli>
#define pi pair<lli,lli>
#define vii vector<pi >
#define Endl endl
#define ITA 200005
#define ROH 100005
using namespace std;
lli mod = 1e9 +7,test; 
lli max(lli a,lli b){return a>b?a:b;}
lli min(lli a,lli b){return a>b?b:a;}

lli gcd(lli a, lli b) { 
   if (b == 0) return a; 
   return gcd(b, a % b);  
} 

lli n;
vi g[ROH];
lli par[ROH];
void fill_par(lli curr , lli p){
    par[curr] = p;
    for(lli to : g[curr]){
        if(to!= p){
            fill_par(to , curr);
        }
    }
}

vector<vi >dp(ROH , vi(2 , -1));


lli dfs(lli curr, lli col){
    if(dp[curr][col] != -1){
        return dp[curr][col];
    }
    lli here = 1;
    for(lli to : g[curr]){
        if(to != par[curr]){
            if(col==0){
                here *= (dfs(to , 0) + dfs(to , 1));
            }else{
                here *= (dfs(to , 0));
            }
            here %= mod;
        }
    }
    dp[curr][col] = here;
    return max(here , 1);
}

void solve(){
    cin>>n;
    lli l,r;
    fo(i,n-1){
        cin>>l>>r; --l , --r;
        g[l].pb(r);
        g[r].pb(l);
    }
    fill_par(0,-1);
    lli ans = dfs(0 , 0) + dfs(0,1);
    ans %= mod;
    // 0 for white.. 1 for black
    cout<<ans<<Endl;
}

int main(){
    ULTRA_INSTINCT;
    lli t =1;
    // cin>>t;
    fo(i,t){
        solve();
    }
    return 0;

}

Measured memory_bytes: 18944
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdio>
using namespace std;

class state {
public:
  double cost;			// 所要時間
  int pp;                       // 前の位置
  int np;			// 今の位置
  int v;			// 速度
  state(double _cost, int _pp, int _np, int _v) {
    cost = _cost;
    pp = _pp;
    np = _np;
    v = _v;
  }
  bool operator > (const state &s) const {
    return cost > s.cost;
  }
};

int main() {
  int n, m;
  while (true) {
    cin >> n >> m;
    if (n == 0 && m == 0) {
      break;
    }

    int s, g;
    cin >> s >> g;
    s--; g--;
    if (m == 0) {
      std::cout << "unreachable" << std::endl;
      continue;
    }

    vector <int> graph[n];
    double cost[n][n];
    double dist[n][n];
    for (int i = 0; i < m; i++) {
      int x, y;
      double d, c;
      cin >> x >> y >> d >> c;
      x--; y--;
      graph[x].push_back(y);
      graph[y].push_back(x);
      cost[x][y] = c;
      cost[y][x] = c;
      dist[x][y] = d;
      dist[y][x] = d;
    }

    double memo[n][n][32];		// prev now v
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
	for (int k = 0; k < 32; k++) {
	  memo[i][j][k] = -1;
	}
      }
    }

    priority_queue <state, vector<state>, greater<state> > pque;
    for (int i = 0; i < graph[s].size(); i++) {
      int np = graph[s][i];
      double nt = dist[s][np];
      memo[s][np][1] = nt;
      pque.push(state(nt, s, np, 1));
    }
    while(!pque.empty()) {
      state p = pque.top(); pque.pop();

      for (int i = 0; i < graph[p.np].size(); i++) {
	int np = graph[p.np][i];
        if (p.pp == np) {
          continue;
        }
	for (int j = -1; j <= 1; j++) {
	  int v = p.v+j;
	  if (v <= 0 || v > cost[p.np][np]) {
	    continue;
	  }

	  double nt = p.cost+dist[p.np][np]/double(v);

	  if (memo[p.np][np][v] == -1 ||
	      memo[p.np][np][v] > nt) {
	    memo[p.np][np][v] = nt;
	    pque.push(state(nt, p.np, np, v));
	  }
	}
      }
    }

    double ans = -1;
    for (int i = 0; i < n; i++) {
      if (memo[i][g][1] == -1) {
        continue;
      }
      if (ans == -1 ||
          memo[i][g][1] < ans) {
        ans = memo[i][g][1];
      }
    }

    if (ans == -1) {
      std::cout << "unreachable" << std::endl;
    }else {
      printf("%.5f\n", ans);
    }
  }
}

Measured memory_bytes: 2028
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}

int main() {
    int n;
    cin >> n;
    vector<pair<string,ll>>a(n),b(n);
    for(int i=0;i<n;i++){
        string t; ll z;
        cin >>t >> z;
        z*=-1;
        a.at(i)=make_pair(t,z);
        b.at(i)=a.at(i);
    }
    sort(b.begin(),b.end());
    for(int i=0;i<n;i++){
       for(int j=0;j<n;j++){
           if(b.at(i)==a.at(j)){
               cout<<j+1<<endl;
           }
       }
    }
}
    



Measured memory_bytes: 3612
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>



int main(){
  int N; cin >> N;
  ll MOD = 1000000007;
  ll ans = 1;

  map< ll, int > ret;
  for (int n0=1;n0<=N;n0++){
    ll n = n0;
    for(ll i = 2; i * i <= n; i++) {
      while(n % i == 0) {
        ret[i]++;
        n /= i;
      }
    }
    if(n != 1) ret[n]++;
  }
  /*
  for (auto c : ret){
    cout << c.first << " " << c.second << endl;
  }
  */
 for (auto c : ret){
  (ans *= c.second+1) %= MOD;
  }
  cout << ans << endl;
  


  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3624
line = list(map(int,input().split()))
lin = []
ans1 = line[0]*line[3]
ans2 = line[0]*line[2]
ans3 = line[1]*line[3]
ans4 = line[1]*line[2]

lin.append(ans1)
lin.append(ans2)
lin.append(ans3)
lin.append(ans4)

print(max(lin))

Measured memory_bytes: 9188
#define _[2<<17]
n,i,flag;A _,B _,T _,F _;long M,D _,P _,R _;s(u,i,p,I){i?s(u,T[i],p),R[i]=(I=B[i])-p?s(I,F[I],u),D[u]=D[u]*-~D[I]%M:D[u]:++D[u];}S(u,x,p,i,I){for(i=F[u];I=B[i];I-p?S(I,R[i]*x%M+1,u),x=x*-~D[I]%M:0)i=T[i];P[u]=x%M;}main(u,v){for(;~scanf("%d%d",&u,&v);)i++?A[i-1]=B[i]=u,B[i-1]=A[i++]=v:(n=u,M=v);for(;--i;F[A[i]]=i)T[i]=F[A[i]];s(*R=1,F[1]);for(S(1,1);i++<n;)printf("%d ",P[i]);}

Measured memory_bytes: 14592
import java.util.Scanner;
class Main{
  public static void main(String args[]){
    int N;
    int M;
    int X;
    int i;
    int a = 0;
    int b = 0;
    int[] A =new int[99];
    Scanner sc = new Scanner(System.in);
    N = sc.nextInt();
    M = sc.nextInt();
    X = sc.nextInt();
    i = M;
    for(i=1;i<=M;i++){
      A[i] = sc.nextInt();
      if(A[i] > X){
        a++ ;
    }else{
        b++ ;
      }
    }

    if(a <= b){
      System.out.println(a);
    }else{
      System.out.println(b);
    }
  }
}


Measured memory_bytes: 22868