akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val pw = PrintWriter(System.out)
fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    // 回答をここに書く
    val n = nextInt()
    println(if(n < 1000) "ABC" else "ABD")
}

// 入力取得
fun next() = br.readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }

// 約数のList
fun divisor(value : Long) : List<Long> {
    val max = Math.sqrt(value.toDouble()).toLong()
    return (1..max)
            .filter { value % it == 0L }
            .map { listOf(it, value / it) }
            .flatten()
            .sorted()
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from : Long, to : Long = from) : List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j ->  i % j != 0L }
    }
}

// 素因数分解
fun decom(value : Long) : List<Long>{
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a : Long, b : Long) : Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base : String, a : String, b : String) : String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 31272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[300003];
int main() {
	scanf("%s",s);
	string last="";
	string cur;
	int k=0;
	for(int i=0;s[i];++i){
		cur+=s[i];
		if(cur!=last){
			++k;
			last=cur;
			cur="";
		}
	}
	cout<<k<<endl;
	return 0;
}

Measured memory_bytes: 1020
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
string s;
int main(){
    cin>>s;
    int n=s.size();
    while(n--)putchar('x');
    puts("");
    return 0;
}


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

int main(void)
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int sum = 0;
	if (A <= B) {
		sum += A;
	}
	else {
		sum += B;
	}
	if (C <= D) {
		sum += C;
	}
	else {
		sum += D;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int X,Y,Z;
	int *px,*py,*pz;
	scanf("%d",&X);
	scanf("%d",&Y);
	scanf("%d",&Z);
	px = &Z;
	py = &X;
	pz = &Y;
	printf("%d %d %d",*px,*py,*pz);
} 

Measured memory_bytes: 1696
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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 left(int x ,map<int,bool> &p){
    int pos = x;
    while(p[pos])--pos;
    return pos;
}

int right(int x , map<int,bool> &p){
    int pos = x;
    while(p[pos])++pos;
    return pos;
}

//ミョ(-ω- ?)
int main() {
    int x,n;
    cin >> x >> n;
    map<int,bool> m;
    rep(i,n){
        int p;
        cin >> p;
        m[p] = true;
    }
    int l = left(x,m);
    int r = right(x,m);
    if(abs(l -x ) <= abs(r - x)){
        cout << l << endl;
    }else cout << r << endl;
    return 0;
}

Measured memory_bytes: 3628
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<1000000007>;

//--------------------------- Solve ---------------------------//

mint dp[100005][2];

void solve() {
    string s; cin >> s;
    int n = s.size();
    s = '#' + s;
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        if (s[i] == '0') {
            dp[i][0] = dp[i-1][0];
            dp[i][1] = dp[i-1][1] * 3;
        }
        if (s[i] == '1') {
            dp[i][0] = dp[i-1][0] * 2;
            dp[i][1] = dp[i-1][1] * 3 + dp[i-1][0];
        }
    }
    cout << dp[n][0] + dp[n][1] << '\n';
}

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

    solve();

    return 0;
}

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


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

            bool ok = false;
            if (a % 3 == 0) ok = true;
            if (b % 3 == 0) ok = true;
            if ((a+b) % 3 == 0) ok = true;
            WriteLine(ok ? "Possible" : "Impossible");
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define DIVCEIL(A,B) ((A+(B-1))/B)
using namespace std;

void solve(long long n, std::vector<std::string> S){
    vector<map<char, long long>> cnts(n);
    for(int i=0; i<n; i++)for(auto c:S[i])cnts[i][c]++;

    vector<char> ans;
    auto s = S[0];
    sort(s.begin(), s.end());
    for(auto c:s){
        if(all_of(cnts.begin(), cnts.end(), [c](auto cnt){
            return cnt.find(c) != cnt.end() && cnt[c]>0;
        })){
            for(auto &cnt:cnts)cnt[c]--;
            ans.push_back(c);
        }
    }
    for(auto c:ans)cout << c;
    cout << endl;
}

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


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll n;
ll K;
ll a[50][50];
ll res[50][50];
ll tmp[50][50];

int main() {
    cin >> n >> K;
    rep(i,n) rep(j,n) cin >> a[i][j];
    rep(i,n) rep(j,n) res[i][j] = 0;
    rep(i,n) res[i][i] = 1;
    while (K) {
        if (K&1) {
            rep(i,n) rep(j,n) tmp[i][j] = res[i][j];
            memset(res, 0, sizeof(res));
            rep(i,n) rep(j,n) rep(k,n) res[i][j] = (res[i][j] + a[i][k]*tmp[k][j])%MOD;
        }
        rep(i,n) rep(j,n) tmp[i][j] = a[i][j];
        memset(a, 0, sizeof(a));
        rep(i,n) rep(j,n) rep(k,n) a[i][j] = (a[i][j] + tmp[i][k]*tmp[k][j])%MOD;
        K /= 2;
    }
    ll ans = 0;
    rep(i,n) rep(j,n) ans = (ans + res[i][j]) % MOD;
    cout << ans << endl;
}



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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    string S;
    cin >> S;
    
    ll red = 0;
    ll blue = 0;
    rep (i, N) {
        if (S[i] == 'R') {
            red++;
        } else {
            blue++;
        }
    }

    if (red > blue) {
        Yes;
    } else {
        No;
    }
    return 0;
}


Measured memory_bytes: 256
def readinput():
    n=int(input())
    l=list(map(int,input().split()))
    return n,l

def main(n,a):
    MOD=10**9+7
    hist=[0]*61
    bs=[]
    for i in range(n):
        # s=list(reversed(bin(a[i])[2:]))
        # for j in range(len(s)):
        #     if s[j]=='1':
        #         hist[j]+=1
        # bs.append(s)
        s=bin(a[i])[2:]
        for j in range(len(s)):
            if s[j]=='1':
                hist[len(s)-j-1]+=1

    #print(bs)
    #print(hist)
    sum=0
    # for i in range(n-1):
    #     s=bs[i]
    #     b=1
    #     for j in range(len(s)):
    #         if s[j]=='0':
    #             sum=(sum+hist[j]*b)%MOD
    #         else:
    #             sum=(sum+( n-i-hist[j] )*b)%MOD
    #             hist[j]-=1
    #         b*=2
    #     for j in range(len(s),61):
    #         sum=(sum+hist[j]*b)%MOD
    #         b*=2
    b=1
    for j in range(61):
        sum=(sum+( hist[j]*(n-hist[j])*b )%MOD )%MOD
        b*=2

    return sum

if __name__=='__main__':
    n,l=readinput()
    ans=main(n,l)
    print(ans)


Measured memory_bytes: 50916
#include <iostream>

using namespace std;

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

Measured memory_bytes: 256
H,W = map(int,input().split())
A = []
count = 0

#行削除
for i in range(H):
  a0 = input()
  a1 = set(a0)
  a1 = list(a1)
  if(len(a1) != 1):
   a = list(a0)
   A.append(a) 
   count += 1
  else:
    if(a1[0] != '.'):
     a = list(a0)
     A.append(a) 
     count += 1 
    
#列削除   
j_pop = []
for j in range(W):
 B = [] #Aを縦にカットしたもの
 for i in range(count):  
  B.append(A[i][j])
 B = set(B)
 B = list(B)  
 #カットすべき列
 if(len(B) == 1):
  if(B[0] == '.'):
    j_pop.append(j)  


for i in range(count): 
 ans ='' 
 for j in range(W):
  if(j in j_pop):
    continue
  else:
    ans += A[i][j]
 print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>

using namespace std;

char S[10];


int main()
{
  cin >> S;
  
  if(S[0]=='S')
  {
    cout << "Cloudy" ;
  }
  else if(strcmp(S,"Cloudy")==0)
  {
    cout << "Rainy";
  }
  else if(S[0]=='R')
  {
    cout << "Sunny";
  }
  

  
  
 return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n;
	cin>>n;
	vp in(n);
	rep(i,n)cin>>in[i].second>>in[i].first;
	rep(i,n)in[i].first*=-1;
	sort(all(in));
	int l=0,r=n+1;
	while(r-l>1){
		ll h=(l+r)/2;
		ll sum=0;
		priority_queue<int>q;
		bool H=false;
		rep(i,n){
//		cout<<l<<" "<<r<<" "<<sum<<endl;
			if(i<h){
				sum+=in[i].second;
				q.push(in[i].second);
			}else{
				int t=q.top();
				q.pop();
				sum+=in[i].second-t;
				q.push(in[i].second);
			}
			if(i+1>=h&&sum<=(-in[i].first)*h)H=true;
		}
		if(H)l=h;
		else r=h;
	}
	cout<<l<<endl;
}

Measured memory_bytes: 8276
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bs binary_search
#define pb push_back
#define pp pair<ll,ll>
#define F first 
#define S second 
#define lc "\n"
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
ll MAX=1e18 , MIN=-1e18 , MOD=1000000007;
int main() 
{
    fastio
    int k,a,b; cin>>k>>a>>b;
    if((b)/k-(a-1)/k>=1) cout<<"OK";
    else cout<<"NG";
    return 0;
}

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

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

    int N = 0;
    int remain = L;
    while (L > 0)
    {
        N++;
        L /= 2;
    }
    remain -= 1 << (N - 1);

    vector<vector<int>> edges;
    for (int i = 1; i < N; i++)
    {
        edges.push_back(vector<int>{i, i + 1, 0});
        edges.push_back(vector<int>{i, i + 1, 1 << (N - i - 1)});
    }

    bitset<32> b(remain);
    int w = 1 << (N - 1);
    for (int i = 25; i >= 0; i--)
    {
        if (b[i])
        {
            edges.push_back(vector<int>{1, N - i, w});
            w += 1 << i;
        }
    }

    cout << N << " " << edges.size() << endl;
    for (auto itr = edges.begin(); itr != edges.end(); itr++)
    {
        cout << (*itr)[0] << " " << (*itr)[1] << " " << (*itr)[2] << endl;
    }
}


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

int main(){
	int A,B;
	int cnt;
	cin >> A >> B;
	cnt=B/100-A/100+1-2;
	if( A%100 <= A/10000+(A/1000)%10*10 ){
		cnt++;
	}
	if( B/10000+(B/1000)%10*10 <= B%100 ){
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

ll D = 365;
vec c(26);
mat s(D, vec(26));
vec last(26, 0);


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    clock_t start = clock();

    cin >> D;
    Rep (i, 26) {
        cin >> c[i];
    }
    Rep (i, D) {
        Rep (j, 26) {
            cin >> s[i][j];
        }
    }

    vec t(D);

    ll tmp = 0;
    Rep (i, D) {
        ll ans = 0;
        ll best = -inf;
        Rep (j, 26) {
            ll score = 0;
            score += s[i][j];
            Rep (k, 26) {
                if (k != j) score -= c[k] * (i+1-last[k]);   
            }
            if (score > best) {
                ans = j;
                best = score;
            }
        }

        last[ans] = i+1;
        tmp += s[i][ans];
        Rep (j, 26) {
            tmp -= c[j] * (i+1-last[j]);
        }

        t[i] = ans;
    }

    vector<set<ll>> days(26);
    Rep (i, 26) {
        days[i].insert(-1);
        days[i].insert(D);
    }
    Rep (i, D) {
        days[t[i]].insert(i);
    }

    random_device rnd;
    mt19937 mt(rnd());
    uniform_int_distribution<> randd(0, 364), randq(0, 25);

    ll cnt = 0;

    while (1.0 * (clock() - start) / CLOCKS_PER_SEC < 1.0) {
        cnt++;
        ll d = randd(mt);
        ll q = randq(mt);

        ll oldscore = tmp;

        tmp -= s[d][t[d]];
        tmp += s[d][q];
        auto old2 = days[t[d]].upper_bound(d);
        old2--;
        old2--;
        auto old1 = old2;
        old2++;
        old2++;
        auto new2 = days[q].lower_bound(d);
        auto new1 = --new2;
        new2++;
        // cout << *old1 << " " << *old2 << " " << *new1 << " " << *new2 << "\n";
        tmp += c[q] * (d-*new1) * (*new2 - d);
        tmp -= c[t[d]] * (d-*old1) * (*old2 - d);

        if (tmp > oldscore) {
            days[t[d]].erase(d);
            days[q].insert(d);
            t[d] = q;
        }
    }

    Rep (i, D) {
        cout << t[i] + 1 << "\n";
    }

    // cout << (double)(clock() - start) / CLOCKS_PER_SEC << "\n";
    // cout << cnt << "\n";
}

Measured memory_bytes: 3804
K=int(input())
a=[]
if K==0:
    print("2")
    print("1 1")

elif K==1:
    print("3")
    print("1 1 3")

elif K>1 and K<=50:
    N=K
    print(K)
    for _ in range(N):
        a.append(str(N))
    print(" ".join(a))
else:
    N=50
    print("50")
    p=K%N
    for _ in range(p):
        a.append(str(N-1+(K//N)+N-p+1))
    for _ in range(p,N):
        a.append(str(N-1+(K//N)-p))
    print(" ".join(a))

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

typedef long long ll;

#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back

const long double PI = acos(-1);

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll GetDigit(ll num) {return log10(num)+1;}

int main(){
  string s;
  cin >> s;
  
  vector<ll> rlpoint(0, 0);
  for(ll i = 0; i < s.size(); i++){
    if(s[i] == 'R' && s[i+1] == 'L') rlpoint.pb(i);
  }

  vector<ll> ans(s.size()+1, 0);
  ll index = 0;
  for(ll i = 0; i < s.size(); i++){
    if(rlpoint[index] < i && index < rlpoint.size()) index++;

    if(s[i] == 'R'){
      if(abs(rlpoint[index] - i) % 2 == 0){
        ans[rlpoint[index]]++;
      }else{
        ans[rlpoint[index] + 1]++;
      }
    }else{
      if(abs(rlpoint[index-1] - i) % 2 == 0){
        ans[rlpoint[index-1]]++;
      }else{
        ans[rlpoint[index-1] + 1]++;
      }
    }
  }

  for(ll i = 0; i < s.size(); i++){
    if(i < s.size()-1) cout << ans[i] << " ";
    else cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1912
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll mod = 1e9+7;
int main(){
  int n;
  cin >> n;
  vector<vector<int>> g(n);
  rep(i,n-1) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    g[u].emplace_back(v);
    g[v].emplace_back(u);
  }
  vector<vector<ll>> dp(n,vector<ll>(2,-1));
  vector<int> check(n,0);
  auto func = [&](auto &&f, int p, int u)->void{
    if (check[u]) return;
    check[u] = 1;
    dp[u][0] = 1;
    dp[u][1] = 1;
    for (auto v : g[u]) {
      if (p == v) continue;
      f(f,u,v);
      dp[u][1] *= dp[v][0];
      dp[u][0] *= (dp[v][0] + dp[v][1]);
      dp[u][1] %= mod;
      dp[u][0] %= mod;
    }
  };
  func(func,-1,0);
  cout << (dp[0][0] + dp[0][1]) % mod << endl;
  return 0;
} 

Measured memory_bytes: 15232
#if defined(__GNUC__)
#include <bits/stdc++.h>
#define __int32 __int32_t
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); ++(i))
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); ++(i))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(ALL(x), greater<decltype(x)::value_type>())
#define RSORT2(x, T) sort(ALL(x), greater<T>())
#define REVERSE(x) reverce(ALL(x))
#define ACM(x, y) accumulate(ALL(x), y)

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)
#define FCT(x) [](int a) -> int {int r = 1; REP(i, a){r *= i;} return r;}(x)

// デバッグ用
#define PUT_LIST(x, y) std::copy(ALL(x), ostream_iterator<decltype(x)::value_type>(cout, y))

const int kMod = 1e9 + 7;

itn main() {
	ios::sync_with_stdio(false);

	int h, w;

	cin >> h >> w;
  
  if(w == 1 || h == 1){
    cout << 1;
    return 0;
  }

	int res = (h * w + 1) / 2;
  
  cout << res;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

int k;
int main() {
    cin>>k;
    if(k%2==0) cout<<k*k/2/2<<endl;
    else cout<<(k/2)*(k/2+1)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
using namespace std;
static const int MAX = 200000;
int main()
{
  int n,R[MAX];
  cin >> n;
  for(int i = 0; i < n ; i++ )cin >> R[i];
  int maxv = -10000000000;
  int minv = R[0];
  for(int i = 1; i < n ; i++)
  {
    if((R[i] - minv) > maxv)maxv = (R[i] - minv);
    if(minv > R[i])minv = R[i];
  }
  cout << maxv << endl;
  return 0;
}



Measured memory_bytes: 3864
X,Y,Z,K = map(int, input().split())
cakes = [list(map(int, input().split())) for _ in range(3)]
 
cakes = list(map(lambda x : sorted(x, reverse=True), cakes))
ans = list()
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1)>K:
                break
            ans.append(cakes[0][i] + cakes[1][j] + cakes[2][k])
ans.sort(reverse=True)
print("\n".join(map(str, ans[:K])))


Measured memory_bytes: 47212
# abc152_b.py
# https://atcoder.jp/contests/abc152/tasks/abc152_b

# B - Comparing Strings /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# 1桁の正整数 a ,b が与えられます。
# 整数 a を b 回繰り返してできる文字列と 整数 b を a回繰り返してできる文字列のうち、辞書順で小さい方を答えてください。

# 制約
#     1≤a≤9
#     1≤b≤9
#     a,bは整数

# 入力
# 入力は以下の形式で標準入力から与えられる。
# a b

# 出力
# 2つの文字列のうち辞書順で小さい方を出力せよ。(2つの文字列が等しいときは、そのうちどちらかを出力せよ。)

# 入力例 1
# 4 3

# 出力例 1
# 3333

# できる 2つの文字列は、444 と 3333 です。このうち辞書順で小さい文字列は 3333 です。

# 入力例 2
# 7 7

# 出力例 2
# 7777777


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    a, b = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    result = min(str(a)*b, str(b)*a)

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['4 3']
        lines_export = ['3333']
    if pattern == 2:
        lines_input = ['7 7']
        lines_export = ['7777777']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9028
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

const int dir[][2] = {
	1, 0,
	0, 1,
	-1, 0,
	0, -1
};

void dfs( VS &board, set<char> &chars, int &count, int y, int x )
{
	if ( !( 0 <= y && y < board.size() && 0 <= x && x < board[0].size() ) )
	{
		return;
	}

	if ( board[y][x] == '#' )
	{
		return;
	}

	if ( board[y][x] != '.' )
	{
		chars.insert( board[y][x] );
		return;
	}

	board[y][x] = '#';
	count++;

	REP( d, 0, 4 )
	{
		dfs( board, chars, count, y + dir[d][0], x + dir[d][1] );
	}

	return;
}

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

	while ( true )
	{
		int w, h;
		cin >> w >> h;

		if ( !( w | h ) )
		{
			break;
		}

		VS board( h );

		EACH( line, board )
		{
			cin >> line;
		}

		map<char,int> res;

		REP( i, 0, h )
		{
			REP( j, 0, w )
			{
				set<char> chars;
				int count = 0;

				dfs( board, chars, count, i, j );

				if ( chars.size() == 1 )
				{
					res[ *chars.begin() ] += count;
				}
			}
		}

		cout << res['B'] << ' ' << res['W'] << endl;
	}

	return 0;
}

Measured memory_bytes: 1496
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
//#define ivorysi
#define MAXN 100005
typedef long long int64;
using namespace std;
template<class T>
void read(T &res) {
	res = 0;char c = getchar();T f = 1;
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
int N,dp[100005];
char s[100005];
void add(int u,int v) {
	out(u);space;out(v);enter;
}
void Solve() {
	scanf("%s",s + 1);
	N = strlen(s + 1);
	for(int i = 1 ; i <= N ; ++i) dp[i] = s[i] - '0';
	if(!dp[1] || dp[N]) {puts("-1");return;}
	for(int i = 2 ; i <= N - 1 ; ++i) {
		if(dp[i]) {
			if(!dp[N - i]) {puts("-1");return;}
		}
	}
	int p = 1,rt = 1;
	for(int i = 2 ; i <= N / 2 ; ++i) {
		if(dp[i]) {
			add(rt,++p);rt = p;
			while(p < i) {add(rt,++p);}
		}
	}
	add(rt,++p);rt = p;
	while(p < N) {add(rt,++p);}
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Solve();
}


Measured memory_bytes: 1920
//  SMOKE SHISHA PLAY FIFA  // 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
#define lp(start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	ll n;
	cin >> n;
	//ll ans=0;
	ll arr[n+1];
	for(ll i=1;i<=n;i++)
		cin >> arr[i];
	sort(arr+1,arr+n+1);
	ll ans = arr[n];
//	ans += arr[n-1];
	ll c=n-1;
	for(ll i=3;i<=n;i++)
	{
		if(i&1)
		{
			ans+=arr[c];
		}	
		else 
		{
			ans+=arr[c];
			c--;
		}
	}
	cout << ans << endl;
	return 0;	
}


Measured memory_bytes: 5224
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cctype>
using namespace std;

int main() {
  string line;
  while (true) {
    cin >> line;
    if (line[0] == '0') {
      break;
    }

    int sum(0);
    for (size_t i = 0; i < line.size(); i++) {
      sum += line[i] - '0';
    }
    cout << sum << endl;
  }
  return 0;
}



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

typedef long long ll;
typedef long double ld;

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

    int n;
    cin >> n;
    vector<ll> a(n);

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

    bool re = false;

    ll ans = pow(10, 18);

    ll count = 0;

    ll sum = 0;

    for(int i = 0; i < n; i++) {
        sum += a[i];
        if(re) {
            if(sum <= 0) {
                count -= sum - 1LL;
                sum = 1LL;
            }
        } else {
            if(sum >= 0) {
                count += sum + 1LL;
                sum = -1LL;
            }
        }
        re = !re;
    }

    ans = min(ans, count);

    re = true;

    count = 0;

    sum = 0;

    for(int i = 0; i < n; i++) {
        sum += a[i];
        if(re) {
            if(sum <= 0) {
                count -= sum - 1LL;
                sum = 1LL;
            }
        } else {
            if(sum >= 0) {
                count += sum + 1LL;
                sum = -1LL;
            }
        }
        re = !re;
    }

    ans = min(ans, count);

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long dp[101][100001];
long long maxProfit(vector<int>&w,vector<int>&v,int n,int W){
    if(n==0 || W==0) return 0;
    if(dp[n][W]!=-1) return dp[n][W];
    if(w[n-1]<=W)
      return dp[n][W]=max(v[n-1]+maxProfit(w,v,n-1,W-w[n-1]),maxProfit(w,v,n-1,W));
    return dp[n][W]=maxProfit(w,v,n-1,W);  

}
int main()
{  ios::sync_with_stdio(false);
   cin.tie(0);  
   int n,W;
   cin>>n>>W;
   vector<int>w(n);
   vector<int>v(n);
   for(int i=0;i<n;i++)  cin>>w[i]>>v[i];
   memset(dp,-1,sizeof(dp));
   cout<<maxProfit(w,v,n,W);
     return 0;
}


Measured memory_bytes: 82536
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se seoncd
#define pb push_back
#define mp make_pair
using namespace std;
typedef bitset<50001> bits;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=100005;
int x[N],y[N],v[N],ans[N],n,m,T,a,b;
bits f[N>>1];
vi id[N];

int main(){
	read(n),read(m),read(T);
	if(T==1){
		rep(i,1,n) f[i].set(i);
		rep(i,1,m){
			read(x[i]),read(y[i]);
			f[x[i]]|=f[y[i]],f[y[i]]|=f[x[i]];
		}
		rep(k,1,n){
			if(f[k].count()<n) continue;
			v[k]=1;
			per(i,m,1){
				if(v[x[i]]) v[y[i]]=1,ans[i]=1;
				else v[x[i]]=v[y[i]];
			}
			rep(i,1,m) putchar(ans[i]?'^':'v');
			return 0;
		}
		puts("-1");
		return 0;
	}
	if(n==2){
		puts("-1");
		return 0;
	}
	rep(i,1,m){
		read(x[i]),read(y[i]);
		id[x[i]].pb(i),id[y[i]].pb(i);
	}
	rep(i,1,n){
		reverse(id[i].begin(),id[i].end());
	}
	a=x[1],b=(y[1]==n?n-1:y[1]+1);
	if(a==b) a--;
	rep(i,1,m){
		int ca=(a==x[i]||a==y[i]);
		int cb=(b==x[i]||b==y[i]);
		if(!ca&&!cb) continue;
		assert(ca+cb==1);
		while(!id[a].empty()&&id[a].back()<=i) id[a].pop_back();
		while(!id[b].empty()&&id[b].back()<=i) id[b].pop_back();
		int ka=id[a].empty()?-1:id[a].back();
		int kb=id[b].empty()?-1:id[b].back();
		int k=min(ka,kb),f=(k==-1||a!=x[k]||b!=y[k]);
		if(cb) swap(a,b);
		if((y[i]==a)^f) a=x[i],ans[i]=1;
		else a=y[i];
		if(a>b) swap(a,b);
	}
	rep(i,1,m) putchar(ans[i]?'^':'v');
	return 0;
}

Measured memory_bytes: 309760
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;
 
int main(void) {
  string S;
  cin >> S;
 
  ll cnt[26];
  REP(i, 0, 26) cnt[i] = 0;
  REP(i, 0, S.size()) cnt[S[i] - 'a']++;
 
  ll ans = S.size() * (S.size() - 1) / 2 + 1;
  REP(i, 0, 26) ans -= cnt[i] * (cnt[i] - 1) / 2;
  cout << ans << endl;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll x = in(), y = in(), z = in();
	cout << (x - z) / (y + z) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
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; }
typedef long long ll;
const int INF = 1e9;

int a,b,c,x,y;

int main(){
    cin >> a >> b >> c >> x >> y;
    int ans = 0;
    int m = min(x,y);
    if(a+b > c*2){
        ans += m * c * 2;

        if(x > y){
            if(a > c * 2) ans += c * 2 * (x-y);
            else ans += a * (x-y);
        } else if(x < y) {
            if(b > c * 2) ans += c * 2 * (y-x);
            else ans += b * (y-x);
        }
    } else {
        ans = a * x + b * y;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int ma=3005;
ll dp[ma][ma];
ll s[ma][ma];
const int MOD = (1e9 + 7);
int add(int a, int b)
{
    a+=b;
    while(a>=MOD) a-=MOD;
    return a;
}
int sum(int i, int l, int r)
{
    if(l>r) return 0;
    if(l==0) return s[i][r];
    else return add(s[i][r],MOD-s[i][l-1]);
}
void solve(){
    int n;
    string st;
    cin>>n>>st;
    dp[0][0]=1;
    s[0][0]=1;
    for(int i=1;i<n;i++){
        for(int j=0;j<=i;j++){
            if(st[i-1]=='<'){
                dp[i][j]=sum(i-1,0,j-1);
            }
            else{
                dp[i][j]=sum(i-1,j,i-1);
            }
        }
        for(int j=0;j<=i;j++){
            s[i][j]=dp[i][j];
                s[i][j]=add(s[i][j],s[i][j-1]);
        }
    }
    int ans=0;
    for(int i=0;i<n;i++) ans=add(ans,dp[n-1][i]);
    cout<<ans<<endl;

}
int main(){
    int t=1;

    while(t--)solve();

}


Measured memory_bytes: 139520
n=int(input())
s=list(input())
a=[]
for i in range(n-1):
  x=[s[j] for j in range(i+1)]
  y=[s[k] for k in range(i+1,n)]
  x=list(set(x))
  c=0
  for l in x:
    if l in y:c+=1
  a.append(c)
print(max(a))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#define int long long
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (long long i = l; i < r; i++)
using namespace std;
int memoh[2000][2000],memow[2000][2000];
signed main() {
    int h,w;
    cin>>h>>w;
    rep(i,h){
        rep(j,w){
            char c;
            cin>>c;
            if(i==0&&c=='.')memow[i][j]=1;
            if(j==0&&c=='.')memoh[i][j]=1;
            if(i!=0&&c=='.')memow[i][j]=memow[i-1][j]+1;
            if(j!=0&&c=='.')memoh[i][j]=memoh[i][j-1]+1;

        }
    }

    for(int i=h-1;i>=0;i--){
        for(int j=w-1;j>=0;j--){
            if(i!=h-1){
                if(memow[i+1][j]!=0&&memow[i][j]!=0){
                    memow[i][j]=memow[i+1][j];
                }
            }
            if(j!=w-1){
                if(memoh[i][j+1]!=0&&memoh[i][j]!=0){
                    memoh[i][j]=memoh[i][j+1];
                }

            }
        }
    }
    int ans=0;
    rep(i,h){
        rep(j,w){
            if(memow[i][j]!=0&&memoh[i][j]!=0)ans=max(ans,memow[i][j]+memoh[i][j]-1);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 31488
func main() {
    let s = readLine()!
    var maxCount = 0
    var count = 0
    for character in s {
        if character == "R" {
            count += 1
            if maxCount <= count {
                maxCount = count
            }
        } else {
            count = 0
        }
    }
    print(maxCount)
}

main()


Measured memory_bytes: 7632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Globalization;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        SetOut(sw);
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";


    void solve()
    {
        var a = cin.next;
        for (int i = 0; i < a.Length; i++)
        {
            if (a[i] == ',')
            {
                Write(" ");
            }
            else
            {
                Write(a[i]);
            }
        }
        WriteLine();
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 2776
#include <bits/stdc++.h>
using namespace std;
int main(){
  bool a=false;
  int x=1;
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for (int i=0; i<N; i++) {
    cin >> vec[i];
    if (vec[i]==1) a=true;
    if (vec[i]==x) {
      x++;
    }
  }
  
  if (a==false) {
    cout << -1 << endl;
    return 0;
  }
  
  cout << N-x+1 << endl;
  
  
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    return b;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;

    int A, B; cin >> A >> B;
    cout << A * B << endl;

}

Measured memory_bytes: 3616
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <string.h> 
#include <stack>
#include <bitset>
#include <map>
#include <cmath>
#include <climits>
#include <queue>

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

using namespace std;

int main() {
	int A, B, C, D, i = 1;
	scanf("%d %d %d %d", &A, &B, &C, &D);
	while (true) {
		// Aoki
		if (i % 2 == 0) A -= D;
		// Takahashi
		else C -= B;

		i++;

		if (A <= 0) {
			printf("No\n");
			break;
		}
		else if (C <= 0) {
			printf("Yes\n");
			break;
		}
	}
}

Measured memory_bytes: 3724
import sys
import math

def main():
    input = sys.stdin.readline
    
    L = [int(input()) for i in range(5)]
    
    #最後の注文を決める
    last_orders = [10 - (i % 10) for i in L if i % 10 != 0]
    last_order = 0 if not last_orders else max(last_orders)
    
    #一の位を切り上げ
    all_order = sum([math.ceil(i / 10) * 10 for i in L])
    
    print(all_order - last_order)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
n, m, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

C = [0]
D = [0]
for a in A:
    C.append(C[-1] + a)
for b in B:
    D.append(D[-1] + b)

p = n
for i in range(n + 1):
    if C[i] > k:
        p = i - 1
        break

_max = p
keep = 0
for i in range(p, -1, -1):
    for j in range(keep, m + 1):
        if C[i] + D[j] > k:
            keep = j - 1
            break
        elif _max < i + j:
            _max = i + j
    if j == m:
        break
print(_max)

Measured memory_bytes: 47668
#include <iostream>
using namespace std;
int main(){
	int n, a[20], b[20], c[19], last, satis = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> a[i];
	for (int i = 0; i < n; ++i) cin >> b[i];
	for (int i = 0; i < n-1; ++i) cin >> c[i];
	last = a[0];
	for (int i = 0; i < n; ++i){
		satis += b[a[i]-1];
		if (last == a[i]-1){
			satis += c[a[i]-2];
		}
		last = a[i];
	}
	cout << satis << '\n';
}

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

using namespace std;
#define INF (1LL<<26)

int col[108000];
bool ok[1080000];
int n, m, a, b;
int bias;
int dist[1080][1080];
void ng(){
	cout << -1 << endl;
	exit(0);
}
void dfs(int x){
	for(int i = 1;i <= n;i++){
		if(x == i)continue;
		if(dist[x][i] == 1)continue;
		if(col[i] > 0 && col[i] == col[x])ng();
		if(col[i] == 0){
			col[i] = 3 - col[x];
			dfs(i);
		}
	}
}

int calc(int x){
	return x * (x-1) / 2 + (n-x)* (n-x-1) / 2;
}

int main(){
	ok[0] = true;
	cin >> n >> m;
	for(int i = 0;i < 700;i++)
		for(int j = 0;j < 700;j++)
			dist[i][j] = INF;
	for(int i = 0;i < m;i++){
		cin >> a >> b;
		dist[a][b] = dist[b][a] = 1;
	}
	for(int i = 0;i < n;i++)
		for(int j = 0;j < n;j++)
			for(int k = 0;k < n;k++)
				dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
	for(int i = 1;i <= n;i++){
		if(col[i])continue;
		col[i] = 1;
		dfs(i);
		int tmp1 = 0, tmp2 = 0;
		for(int j = 1;j <= n;j++){
			if(col[j] == 0)continue;
			if(col[j] == 1)tmp1++;
			if(col[j] == 2)tmp2++;
			col[j] = -1;
		}
		int dif = abs(tmp1 - tmp2);
		bias += min(tmp1, tmp2);
		for(int j = 700;j - dif >= 0;j--){
			ok[j] |= ok[j-dif];
		}
	}
	int res = INF;
	for(int i = 0;i <= n;i++){
		if(!ok[i])continue;
		res = min(res, calc(bias + i));
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(void) {
	int n, max, min;
	int x[200000];
	int i, j;

	scanf("%d", &n);

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

	max = x[1] - x[0];
	min = x[0];

	if (n != 2) {
		for (i = 1; i < n; i++) {
			if (min > x[i]) {
				min = x[i];
			}
			else {
				if (max < x[i] - min) {
					max = x[i] - min;
				}
			}
			
		}
	}
	
	printf("%d\n", max);
	return 0;
}



Measured memory_bytes: 2528
#include<cstdio>
#include<iostream>
#include <string>
#include<algorithm>
using namespace std;

int main()
{
    int x,a,b;
    cin >> x >> a >> b;
    int num = 0;
    int num1 = 0;
    
    if(x>a)
    {
        num = x-a;
    }
    else
    {
        num = a-x;
    }
    
    if(x>b)
    {
        num1 = x - b;
    }
    else
    {
        num1 = b - x;
    }
    
    if(num > num1)
    {
        cout << "B";
    }
    else
    {
        cout << "A";
    }
    
    
    
}




Measured memory_bytes: 3040
#include <iostream>
#include <algorithm>
 
using namespace std;
 
 
int main(void) {
  int score[21], cscore[21], n, a, b;
 
  cin >> n;
 
  for(int i = 1; i < 21; i++) {
    score[i] = 0; cscore[i] = 0;
  }
 
  for(int i = 1; i < n+1; i++) {
    cin >> a >> b;
    score[a] = b;
  }
 
  for(int i = 1; i < n+1; i++) {
    cscore[i] = score[i];
    score[i] *= 1000;
    score[i] += i*10;
  }
   
  sort(score+1, score + n + 1);
 
  for (int i = 1; i < n+1; i++) {
    if(cscore[i] == score[n]/1000) {
      cout << i << " " << cscore[i] << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 1180
n=int(input())
p=list(map(int, input().split()))
cnt=0

for i in range(1, n-1):
    if p[i-1] <= p[i] and p[i+1] >= p[i]:
        cnt+=1
    elif p[i-1] >= p[i] and p[i+1] <= p[i]:
        cnt+=1

print(cnt)

Measured memory_bytes: 3060