akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	ll n;
	string s, t;
	ll ans = 0;

	cin >> n >> s >> t;

	ll cnts = 0;

	RREP(i, t.size()) {
		if (s.substr(cnts, i + 1) == t.substr(0, i + 1)) {
			ans = n * 2 - 1 - i;
			break;
		}
		cnts++;
	}

	if (ans == 0) {
		ans = n * 2;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
typedef long long L;
int n,k;
L T[MAX];
int check(L P){
  int i=0,j;
  L s;
  for(j=0;j<k;j++){
     s=0;
    while(s+T[i]<=P){
      s+=T[i];
      i++;
      if(i==n)return n;
    }
  }
  return i;
}
 
int solve(){
  L left=0,right=MAX*10000,mid;
  int v;
  while(right>left+1){
    mid=(right+left)/2;
    v=check(mid);
    if(v>=n)right=mid;
    else left=mid;
  }
  return right;
}
int main(){
  int i;
  L ans;
  scanf("%d %d",&n,&k);
  for(i=0;i<n;i++)scanf("%d",&T[i]);
  // ans=solve();
  printf("%llu\n",solve());
  return 0;
}

Measured memory_bytes: 2608
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int R,G;
vector <int > H;





int main()
{

	cin >> R>>G;

	cout << G*2-R <<endl;



}





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

int main() {
    int a,b;
    cin>>a>>b;
    if(a==b) cout<<a+b<<endl;
    else if(a>b) cout<<a+a-1<<endl;
    else cout<<b+b-1<<endl;
}

Measured memory_bytes: 384
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

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

using namespace std;

int main() {
    int n,m,k;
    cin >> n >> m >> k;
    
    for(int i = 0;i <= n;i++)
    {
        for(int j = 0;j <= m;j++)
        {
            auto s = (m - j) * i + (n - i) * j;
            if(s == k)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <stack>
#include <queue>
#include <tuple>
#include <regex>
#include <cmath>
#include <map>
#include <set>
#include <functional>
#include <cstring>

using namespace std;

template<typename T> bool chmax( T &a, const T b ) { if ( a <= b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, const T b ) { if ( a >= b ) { a = b; return ( true ); } else { return ( false ); } }

using ll = long long;
using Pint = pair<int, int>;
using Pll  = pair<ll, ll>;

#define eb emplace_back
#define pb push_back
#define mp make_pair

#define F first
#define S second

#define popcnt __builtin_popcountll

#define rep( i, n ) for ( ll i = 0; i < (ll)( n ); ++i )
#define reps( i, n ) for ( ll i = 1; i <= (ll)( n ); ++i )
#define rrep( i, n ) for ( ll i = (ll)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( ll i = (ll)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

template<typename T = ll> constexpr T MAX = numeric_limits<T>::max();
template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }
template<typename T> T lcm( const T a, const T b ) { return ( a / gcd( a, b ) * b ); }


int main()
{
	ll n; cin >> n;
	cout << ( n ^ 1 ) << endl;

	return ( 0 );
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b && a > c){
        cout << b + c << endl;
    }
    else if(b > a && b > c){
        cout << a + c << endl;
    }
    else{
        cout << a + b << endl;
    }
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> s;
	a = 0;
	for(i=0;i<s.size();i++) {
		if (s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T') {
			a++;
		} else {
			ans = max(ans , a);
			a = 0;
		}
	}
	ans = max(ans , a);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3552
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
	int N,ant[200000],i;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&ant[i]);
	}
	sort(ant,ant+N);
	for(i=1;i<N;i++){
		if(ant[i]==ant[i-1]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}


Measured memory_bytes: 3880
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using Entry = pair<string, int>;

int main() {
  string s;
  int K;
  cin >> s >> K;
  auto comp = [](const auto& a, const auto& b) { return a.first > b.first; };
  priority_queue<Entry, vector<Entry>, decltype(comp)> qs(comp);
  for(int i = 0; i < s.size(); ++i) {
    qs.push(make_pair(s.substr(i, 1), i)); //
  }
  map<string, int> ck;
  while(!qs.empty()) {
    auto crnt = qs.top();
    qs.pop();
    // cout << crnt.first << " len:" << crnt.first.length() << endl;

    auto v = s.substr(crnt.second, crnt.first.length());
    ck[v]++;
    // cout << v << "," << ck[v] << endl;

    if(ck.size() == K) {
      cout << v << endl;
      return 0;
    }
    if(crnt.second + crnt.first.length() + 1 <= s.size()) {
      auto next = s.substr(crnt.second, crnt.first.length() + 1);
      qs.push(make_pair(next, crnt.second));
    }
  }

  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define ld long double
    #define vll vector<ll>
    #define mll map<ll,ll>
    #define pll pair<ll,ll>
    #define ff first
    #define ss second
    #define pb push_back
    #define deb(x) cout<<#x<<" : "<<x<<endl;
    #define deb2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
    #define deb3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;
    #define deb4(w,x,y,z) cout<<#w<<" : "<<w<<"\t"<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;
    #define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define printv(a)  for(ll i=0;i<a.size();i++)  cout<<a[i]<<" ";
   
   
    const int mod=998244353.;
    const int N=1e6+5; 
   
    bool sortbysec(const pair<pair<ll,ll>,ll> &a, 
                      const pair<pair<ll,ll>,ll> &b) 
        { 
            return (a.second > b.second); 
        } 
        ll powermod(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;
        }
       
        bool isprime(int n) 
        { 
            if (n <= 1)  return false; 
            if (n <= 3)  return true; 
            if (n%2 == 0 || n%3 == 0) return false; 
            for (int i=5; i*i<=n; i=i+6) 
                if (n%i == 0 || n%(i+2) == 0) 
                   return false; 
           return true; 
        }
        
        int main()
        {
            FAST;
            ll a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
            ll k;
            cin>>k;
            cout<<a[k-1];
            return 0;
        }

Measured memory_bytes: 384
N,Q = map(int,input().split())

adj = [list() for _ in range(N)]
for _ in range(N-1):
    a,b = map(int,input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)

memo = [0]*N
for _ in range(Q):
    p,x = map(int,input().split())
    memo[p-1] += x

stack = [(None,0)]
while stack:
    p,v = stack.pop()
    for u in adj[v]:
        if u == p:
            continue
        memo[u] += memo[v]
        stack.append((v,u))

print(*memo)

Measured memory_bytes: 135464
#include "cstdio"
#include "algorithm"
using namespace std;
int s[100005],i,j,n,k,c,ss;
int A(){
    int a=0,k=1;char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-') k=-1;c=getchar();
    }
    while(c>='0'&&c<='9'){
        a=a*10+c-'0';c=getchar();
    }
    return a*k;
}
int main(){
	n=A(),c=A(),k=A();
	for(i=1;i<=n;i++)
	s[i]=A();
	sort(s+1,s+1+n);
	for(i=1;i<=n;i++){
		for(j=i;j<=n&&j<=i+c-1&&s[j]<=s[i]+k;j++);i=j-1;
		ss++;
	}
	printf("%d\n",ss);
}

Measured memory_bytes: 512
from collections import defaultdict, deque
N, M = list(map(int, input().split()))
graph = defaultdict(list)

for _ in range(M):
    u, v = list(map(int, input().split()))
    graph[u-1].append(v-1)
    graph[v-1].append(u-1)

ans = [-1] * N
# vertex, prev
queue = deque([(0, 0)])
visited = set([0])
while queue:
    v, prev = queue.popleft()
    ans[v] = prev
    for nv in graph[v]:
        if nv not in visited:
            visited.add(nv)
            queue.append((nv, v))

if -1 in ans:
    print('No')
    exit()
    
for i, v in enumerate(ans):
    if i == 0:
        print('Yes')
    else:
        print(v + 1)
        



Measured memory_bytes: 117864
N, T = list(map(int, input().split(" ")))

min_c = 1001
min_c_i = 0

for i in range(N):
    c, t = list(map(int, input().split(" ")))
    
    if t <= T:
        if c <= min_c:
            min_c = c
            #min_c_i = i
            
if min_c < 1001:
    print(min_c)
else:
    print("TLE")

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define nn '\n'
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int N;
    string S;
    cin >> N >> S;
    REP(i,S.size()){
        int b = (int)S.at(i); /*b := Sのi文字目のアスキーコード*/
        b = b + N; /*bをN文字ズラす*/
        if(b > (int)'Z') b = b - 26; /*Zよりも後になってしまったら26文字戻す*/
        S.at(i) = (char)b; /*Sの元の文字と置き換え*/
    }
    cout << S << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  
  int cnt = 0;
  for(int i = 0; i < n; i++) {
    int minj = i;
    for(int j = i; j < n; j++) {
      if (a.at(j) < a.at(minj))
        minj = j;
    }
    swap(a.at(i), a.at(minj));
    if(i != minj) cnt++;
  }
  
  for(int i = 0; i < n-1; i++)
    cout << a.at(i) << " ";
  cout << a.at(n-1) << "\n";
  cout << cnt << "\n";

}




Measured memory_bytes: 3180
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int N, A[1 << 19];
int B[1 << 18], L;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> A[i];
	for (int i = 1; i <= N; i++) {
		int pos1 = lower_bound(B, B + L, -A[i] + 1) - B;
		B[pos1] = -A[i];
		if (pos1 == L) { L++; }
	}
	cout << L << endl;
	return 0;
}

Measured memory_bytes: 4384
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            char[] s = Console.ReadLine().ToCharArray();
            long k = long.Parse(Console.ReadLine());

            if(s[0] != '1')
            {
                Console.WriteLine(s[0]);
                return;
            }
            for(long i=0;i<k && i < s.Length ;i++)
            {
                if(s[i] != '1')
                {
                    Console.WriteLine(s[i]);
                    return;
                }
            }
            Console.WriteLine("1");
            return;
        }
    }
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    int ans = 0;
    int N, K;
    cin >> N >> K;
    int A[N];
    REP(i, N)
    {
        cin >> A[i];
    }

    ans += 1;
    if (N - K > 0)
    {
        ans += (N - K) / (K - 1);
        if ((N - K) % (K - 1) != 0) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
		int[] b = new int[2];
		for(int i=0;i<3;i++){
			a[i] = sc.nextInt();
		}
		for(int i=0;i<2;i++){
			b[i] = sc.nextInt();
		}
		int c=2000,d = 2000;
		for(int i=0; i<3;i++){
			if(a[i]<c){
				c = a[i];
			}
		}
		for(int i=0; i<2;i++){
			if(b[i]<d){
				d = b[i];
			}
		}
		
		
		System.out.printf("%d%n", c+d-50);
	}
}

Measured memory_bytes: 26116
#include <stdio.h>
#include <string.h>
#include <ctype.h>
char *tolowerstr(char *s) {
    int i=0;
    while(s[i]!='\0'){
         s[i]=tolower(s[i]);
         i++;
    }
    return s;
}
int main(void) {
	char w[10],n[100];
	int cnt=0;
	scanf("%s",w);
	tolowerstr(w);
	while(scanf("%s",n)!=EOF && strcmp(n,"END_OF_TEXT")){
		tolowerstr(n);
		if(!strcmp(n,w)){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 552
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

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

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
	if (y == 0) 
		return 1; 
	ll p = power(x, y/2) % MOD; 
	p = (p * p) % MOD; 
  
	return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

	READV(N);
	ll ans=N+1;
	for(ll i=1;i*i<=N;i++)
	{
		if(N%i==0)
		{
			ans=min(ans,i+N/i);
		}
	}
	cout<<ans-2<<endl;

	return 0;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
a = []
an = [0] * (N + 1)

for i in range(Q):
    a.append(list(map(int, input().split())))

for i in range(len(S)):
    an[i+1]=an[i]
    if S[i:i + 2] == "AC":
        an[i+1] += 1
# print(an)

for i in range(Q):
    print(an[a[i][1]-1] - an[a[i][0] - 1])

Measured memory_bytes: 30712
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
//~ #pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(),x.end()
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define erase_duplicates(x) sort(all(x)); (x).resize(distance((x).begin(), unique(all(x))));


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

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long double LD;
typedef pair<LD,LD> PLD;
typedef vector<LD> VLD;
typedef vector<PLD> VPLD;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<" = "<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<" = "<<h<<", "; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#define cerr if(0)cout
#endif

const int maxn = (1e6)+7;
const int maxk = 20;
const int inf = (1e9)+7;
const LL LLinf = ((LL)1e18)+7LL;
const LD eps = 1e-9;
const LL mod = 1e9+7;

// ***************************** CODE ***************************** //

int main()
{
	_upgrade
  int n, a, b;
  cin>>n>>a>>b;
  cout<<min(a, b)<<" "<<max(0, a + b - n);

	return 0;
}


Measured memory_bytes: 256
#include <string>
#include <cassert>
#include <iostream>


int main()
{
	int	A,B,X;

	std::cin >> A >> B >> X;

	assert( A >= 1 && A <= 100 );//	1 <= A <= 100
	assert( B >= 1 && B <= 100 );//	1 <= B <= 100
	assert( X >= 1 && X <= 200 );//	1 <= X <= 200

	//	Bの中の猫の数 X-Aが1～Bであれば良い
	const	int	XA = X - A;
	if( XA >= 0 && XA <= B ){
		std::cout << "YES" << std::endl;
	}
	else{
		std::cout << "NO" << std::endl;
	}

	return 0;
}



Measured memory_bytes: 256
N,W = map(int,input().split())
v,w,m = [0]*N,[0]*N,[0]*N
for i in range(N):
    v[i],w[i] = map(int,input().split())

gra = [0]*(W+1)

for i in range(N):
    for j in range(1,W+1):
        if j>=w[i]:
            gra[j] = gra[j-w[i]]+v[i] if gra[j-w[i]]+v[i]>=gra[j] else gra[j]

print(max(gra))

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

long long com(long long N, long long R) {
    if (R < 0 || R > N) return 0;
    if (R == 1) return N;
    else if (R == 2) return N * (N-1) / 2;
    else return N * (N-1) * (N-2) / 6;
}

long long pow(long long N, long long k) {
    long long res = 1;
    for (int i = 0; i < k; ++i) res *= N;
    return res;
}

string S;
int N, K;

long long solve(int i, int k, int smaller) {
    if (i == N) {
        if (k == 0) return 1;
        else return 0;
    }
    if (k == 0) return 1;
    
    if (smaller) return com(N-i, k) * pow(9, k);
    else {
        if (S[i] == '0') return solve(i+1, k, false);
        else {
            long long zero = solve(i+1, k, true);
            long long aida = solve(i+1, k-1, true) * (S[i] - '1');
            long long icchi = solve(i+1, k-1, false);
            return zero + aida + icchi;
        }
    }
}

int main() {
    cin >> S >> K;
    N = S.size();
    cout << solve(0, K, false) << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const ll INF = 1e15;
const int Nmax = 1000000;
const int Mmax = 2000000;
ll L[Mmax], R[Mmax], D[Mmax], N, M;

ll dfs(int v, vector<vector<pair<int, ll> > > &graph, vector<ll> &position){
	for(int i=0; i<graph[v].size(); i++){
		int u = graph[v][i].first;
		ll d = graph[v][i].second;
		if(position[u] == -INF){
			position[u] = position[v]+d;
			//cout << u << " " << position[u] << endl;
			ll diff = dfs(u, graph, position);
			if(diff != 0){
				position[u] = -INF;
				return diff;
			}
		}
		else if(position[u] != position[v]+d){
			return position[v]+d-position[u];
		}
	}
	return 0;
}

int main(){
	cin >> N >> M;
	for(int i=0; i<M; i++){
		cin >> L[i] >> R[i] >> D[i];
		L[i]--; R[i]--;
	}

	vector<vector<pair<int, ll> > > graph(N);
	for(int i=0; i<M; i++){
		graph[L[i]].push_back(make_pair(R[i], D[i]));
		graph[R[i]].push_back(make_pair(L[i], -D[i]));
	}

	vector<ll> position(N, -INF);
	for(int i=0; i<N; i++){
		if(position[i] > -INF) continue;
		position[i] = 0;
		ll diff = dfs(i, graph, position);
		//cout << diff << endl;
		if(diff != 0){
			position[i] = -diff;
			diff = dfs(i, graph, position);
			//cout << " " << diff << endl;
			if(diff != 0){
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 28160
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<iomanip>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) // <a> must be sorted in advance

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}


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

    int X, Y, Z;
    cin >> X >> Y >> Z;

    int x = X - Z;
    cout << x / (Y+Z) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
vector<int>tree[100005];
map<pi,int>m;
vector<pi>edge;
bool visited[100005];

void dfs(int curr, int used_color){
	visited[curr] = true;
	int color = 1;
	for(int i=0; i<tree[curr].size(); i++){
		int child = tree[curr][i];
		if(!visited[child]){
			if(color==used_color) color++;
			m.insert(make_pair(pi(curr,child),color));
			m.insert(make_pair(pi(child,curr),color));
			dfs(child,color++);
		}
	}
}
int main(){
	int n;
	cin>>n;
	for(int i=1; i<n; i++){
		int a,b;
		cin>>a>>b;
		tree[a].push_back(b);
		tree[b].push_back(a);
		edge.push_back(pi(a,b));
	}
	int mx = 0;
	for(int i=1; i<=n; i++) mx = max(mx,(int)tree[i].size());
	dfs(1,0);
	cout<<mx<<'\n';
	for(int i=0; i<edge.size(); i++){
		cout<<m.find(pi(edge[i].first,edge[i].second))->second<<'\n';
	}
}

Measured memory_bytes: 21936
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>	
using namespace std;
typedef long long ll;
#define bay_bay return 0;
#define fori(n) for(int i=0;i<n;++i)
#define for1(n) for(int i=1;i<=n;i+=3)
#define all(v) ((v).begin()), ((v).end())	
#define sz(v) v.size()
#define endl "\n"
constexpr auto EPS = 1e-9;
#define ff fflush(stdout);
const int mod = 1000000007LL;
clock_t T;
#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl
void GOAT()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("output.txt", "w	", stdout);
#else
#endif
}
ll arr[100009],dp[100009], n,k;

int main()
{
	//GOAT();
	cin >> n >> k;
	for (int i = 1; i <= n;i++)
		cin >> arr[i];
	memset(dp, -1, sizeof dp);
	dp[1] = 0;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= k; j++)
		{
			if (i + j <= n)
			{
				ll ch = dp[i] + abs(arr[i] - arr[i + j]);
				if (ch < dp[i + j] || dp[i + j] == -1)dp[i + j] = ch;
			}
		}
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

k = int(input())

def gcd(a, b):
    while b: a, b = b, a % b
    return a

ans = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        for m in range(1 , k + 1):
            ans += gcd(gcd(i, j), m)

print(ans)


Measured memory_bytes: 73900
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)
	s := make([]int, 0, 3)
	s = append(s, a, b, c)
	var cnt5, cnt7 int
	for _, num := range s {
		if num == 5 {
			cnt5++
		} else if num == 7 {
			cnt7++
		}
	}
	if cnt5 == 2 && cnt7 == 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

const ll mod = 998244353;
const int N = 3005;
ll ways[N][N];

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n, s; cin >> n >> s;
  ways[0][0] = 1;
  for (int i = 0; i < n; i++) {
    int a; cin >> a;
    for (int x = 0; x <= s; x++) {
      ways[i + 1][x] += 2 * ways[i][x];
      if (x + a <= s) {
        ways[i + 1][x + a] += ways[i][x];
      }
    }
    for (int x = 0; x <= s; x++) {
      ways[i + 1][x] %= mod;
    }
  }
  cout << ways[n][s] << endl;

  return 0;
}


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

#define int long long

int memo[51][2501][51];
int n, a[51], A;

int dp(int i, int W, int cnt) {
	if(W < 0 or cnt < 0) {
		return 0;
	}
	if(i == n and W == 0 and cnt == 0) {
		return 1;
	}
	if(i == n) {
		return 0;
	}

	int &ans = memo[i][W][cnt];
	if(ans != -1) {
		return ans;
	}

	return ans = dp(i+1, W - a[i], cnt - 1) +  dp(i+1, W, cnt);
}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	memset(memo, -1, sizeof(memo));
	cin >> n >> A;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int cnt = 0;
	for(int i = 1; i <= n; i++) {
		if(dp(0, A*i, i) > 0) {
			cnt += dp(0, A*i, i);
		}
	}

	cout << cnt << '\n';
				
	return 0;
}


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

int main() {
    int n[4][4];
    for (int i=0; i<3; i++) {
        cin >> n[i][0] >> n[i][1] >> n[i][2];
    }

    int num;
    cin >> num;

    int b[20];
    for (int i=0; i<num; i++) {
        cin >> b[i];
    }

    int bingo[4][4];
    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++) {
            for (int k=0; k<num; k++) {
                if (n[i][j] == b[k]) {
                    bingo[i][j] = 100;
                }
            }
        }
    }

    int result = 0;

    //横判断
    for (int i=0; i<3; i++) {
        if (bingo[i][0] + bingo[i][1] + bingo[i][2] == 300) {
            result = 1;
        }
    }

    //縦判断
    for (int j=0; j<3; j++) {
        if (bingo[0][j] + bingo[1][j] + bingo[2][j] == 300) {
            result = 1;
        }
    }

    //斜め判断
    if (bingo[0][0] + bingo[1][1] + bingo[2][2] == 300) {
        result = 1;
    }
    if (bingo[0][2] + bingo[1][1] + bingo[2][0] == 300) {
        result = 1;
    }

    if (result == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0:
        break
    a = list(map(int, input().split()))
    b = []
    cnt = 0
    while True:
        for m in a:
            b.append(a.count(m))
        if a == b:
            break
        cnt += 1
        a = b
        b = []
    print(cnt)
    print(' '.join(map(str,b)))

Measured memory_bytes: 7564
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <type_traits>
using namespace std;

#define INF 1e18
#define int long long

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

    if(a % 2 == 0 && a == b && b == c) {
        cout << -1 << endl;
        return 0;
    }

    int ans = 0;
    while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
        int temp_a = a;
        int temp_b = a;
        a = (b + c) / 2;
        b = (c + temp_a) / 2;
        c = (temp_a + temp_b) / 2;
        ans++;
    }

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


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

int main() {
  ll n, m;
  cin >> n >> m;
  ll ans = 0;
  ans += min(n, m/2);
  n -= ans; m -= 2*ans;
  ans += m/4;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

string S;

int flag = -1;
vector<pair<LL,LL>> ans;

void solve(){
	int N = S.size();
	if(S[0]!='1' || S[N-1]!='0') return;
	for(int i=0;i<=(N-2)/2;i++){
		if(S[i]!=S[N-2-i]) return;
	}
	flag = 1;

	int focus = 1;
	int counter = 2;
	for(int i=0;i<=N-2;i++){
		ans.push_back(pair<LL,LL>(focus,counter));
		if(S[i]=='1') focus = counter;
		counter++;
	}
}

int main(){
    cin >> S;

    solve();
    if(flag==-1){
    	cout << -1 << endl;
    	return 0;
    }
    for(int i=0;i<ans.size();i++)cout << ans[i].first << " " << ans[i].second << endl;
    return 0;
}

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

const long long INF = 1LL << 60;

int N;
long long a[409];
long long dp[409][409];

int main() {
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> a[i];
        a[i] += a[i - 1]; // 累積和を取る
    }

    for(int i = 0; i < 409; i++) {
        for(int j = 0; j < 409; j++)
            dp[i][j] = INF;
        dp[i][i] = 0;
    }

    for(int bit = 1; bit < N; bit++) {
        for(int l = 1; l + bit <= N; l++) {
            int r = l + bit;
            for(int i = l; i < r; i++)
                dp[l][r] = min(dp[l][r], dp[l][i] + dp[i + 1][r] + a[r] - a[l - 1]);
        }
    }

    cout << dp[1][N] << endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(b-a==c-b)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 764
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = min(a) + min(b)

for i in range(M):
    x, y, c = map(int, input().split())
    cost = a[x-1] + b[y-1] -c
    if ans > cost:
        ans = cost

print(ans)



Measured memory_bytes: 18736
n,m = map(int, input().split())
H = list(map(int, input().split()))
a = []
b = []
cnt  = [0]*n
sum = 0
for i in range(m):
    a_tmp,b_tmp = map(int, input().split())
    a.append(a_tmp)
    b.append(b_tmp)
for i in range(m):
    if H[a[i]-1]<H[b[i]-1]:
        cnt[a[i]-1] += 1
    if H[a[i]-1]>H[b[i]-1]:
        cnt[b[i]-1] += 1
    if H[a[i]-1] == H[b[i]-1]:
        cnt[a[i]-1] += 1
        cnt[b[i]-1] += 1
print(cnt.count(0))

Measured memory_bytes: 22984
from operator import itemgetter


def solve(array1, array2):
    set_ = set()
    stand = 0
    pos1 = 0
    pos2 = 0
    ans = 0
    cnt = 0
    n = len(array1)
    while True:
        if cnt == n:
            break
        while True:
            if array1[pos1][0] in set_:
                pos1 += 1
            else:
                i, l, r = array1[pos1]
                set_.add(i)
                if l <= stand <= r:
                    pass
                elif r < stand:
                    ans += stand - r
                    stand = r
                else:
                    ans += l - stand
                    stand = l
                cnt += 1
                break
        if cnt == n:
            break
        while True:
            if array2[pos2][0] in set_:
                pos2 += 1
            else:
                i, l, r = array2[pos2]
                set_.add(i)
                if l <= stand <= r:
                    pass
                elif r < stand:
                    ans += stand - r
                    stand = r
                else:
                    ans += l - stand
                    stand = l
                cnt += 1
                break
    return ans + abs(stand)


n = int(input())
info = [tuple([i] + list(map(int, input().split()))) for i in range(n)]

info1 = sorted(info, key = itemgetter(1), reverse = True)
info2 = sorted(info, key = itemgetter(2), reverse = True)
info3 = sorted(info, key = itemgetter(1))
info4 = sorted(info, key = itemgetter(2))

ans = 0
ans = max(ans, solve(info1, info2))
ans = max(ans, solve(info1, info3))
ans = max(ans, solve(info1, info4))
ans = max(ans, solve(info2, info3))
ans = max(ans, solve(info1, info4))
ans = max(ans, solve(info3, info4))
ans = max(ans, solve(info1, info1))
ans = max(ans, solve(info2, info2))
ans = max(ans, solve(info3, info3))
ans = max(ans, solve(info4, info4))
ans = max(ans, solve(info2, info1))
ans = max(ans, solve(info3, info1))
ans = max(ans, solve(info4, info1))
ans = max(ans, solve(info3, info2))
ans = max(ans, solve(info4, info2))
ans = max(ans, solve(info4, info3))
print(ans)

Measured memory_bytes: 124240
#include<stdio.h>

int main(void)
{
	int i,a=0,b=0,c=0;
	char s[4];
	scanf("%s",s);
	for(i=0;i<3;i++){
		if(s[i]=='a')
			a++;
		if(s[i]=='b')
			b++;
		if(s[i]=='c')
			c++;
	}
	if(a*b*c==0)
		printf("No");
	else
		printf("Yes");
	return 0;
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);

        int sum=0;
        Long a = stdIn.nextLong();
        int valLen = String.valueOf( a ).length();
        int max;
        for(long i=1; i*i<=a; i++){
            if(a % i == 0){
                long b = a/i;
                if(b>i){
                    max = String.valueOf( b ).length();

                }else{

                    max = String.valueOf( i ).length();
                }
                if(max<valLen){
                    valLen = max;
                }


            }
        }
        System.out.println(valLen);

    }
    }

Measured memory_bytes: 21972
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		String a=s.next();
		a=a+".00";
		String b=s.next();
	
		BigDecimal aa=new BigDecimal(a);
		BigDecimal bb=new BigDecimal(b);
		
		BigDecimal qw=aa.multiply(bb);
		
		String ans=qw.toString();
		
		for(int i=0;i<ans.length();i++)
		{
			if(ans.charAt(i)=='.')
				break;
			else
			{
				System.out.print(ans.charAt(i));
			}
		}
		
	}
	
}

Measured memory_bytes: 38940
import java.util.*;
public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    
    if (K == 1) {
      System.out.println(0);
      return;
    }
    
    int remain = N - K;
    
    System.out.println(remain);
  }
}

Measured memory_bytes: 21844
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
		 static int a_dist[];
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();
	        long K = sc.nextInt();
	        long[] a = new long[N];
	        for (int i=0 ; i<N; i++) {
	            a[i] = Long.parseLong(sc.next());
	        }	        
	        
	        long left=0;
	        long right=mod;
	        while(right-left>1) {
	        	long mid = left + (right-left)/2;
	        	long cnt =0;
	        	for(int i=0;i<N;i++) {	        			
	        		cnt=cnt+a[i]/mid-1;
	        		if(a[i]%mid!=0)cnt++;
	        	}
	        	if(cnt>K) {
	        		left=mid;
	        	} else {
	        		right=mid;
	        	}
	        }
	        
	        
	        
	        System.out.println(right);
		 }
		 
	}

Measured memory_bytes: 61420
/*
	Author: Luis Manuel D?az Bar?n (LUISMO)
	Problem: Independent Set
	Online Judge:
	Idea: DP + Combinatorics + Tree
*/
#include<bits/stdc++.h>
// Types
#define ll long long
#define ull unsigned long long
// IO
#define sf scanf
#define pf printf
#define mkp make_pair
#define fi first
#define se second
#define endl "\n"

using namespace std;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll inf = 1e16 + 3;
const int mod = 1e9 + 7;
const int lim = 2e5 + 17 ;

int N, xi, yi;

vector<int> adj[lim];

ll dp[lim][2];
bool mark[lim][2];

// 0-white, 1-black

ll DFS(int idx, int father, int color)
{
	if(mark[idx][color])
		return dp[idx][color];

	ll curr = 1;
	
	for(int i = 0; i < adj[idx].size(); i++)
	{
		int nxt = adj[idx][i];
		if(nxt != father)
		{
			ll aux = DFS(nxt, idx, 0);

			

			if(!color)
			{
				ll aux2 = DFS(nxt, idx, 1);
				// rule of sum
				aux = (aux + aux2) % mod;				
			}
			// rule of product
			curr = (curr * aux) % mod;
		}
	}
	mark[idx][color] = true;
	dp[idx][color] = curr;

	return dp[idx][color];
}


void solve()
{
	cin >> N;
	for(int i = 0; i < N - 1; i++)
	{
		cin >> xi >> yi;
		adj[xi].push_back(yi);
		adj[yi].push_back(xi);
	}
	
	// starting the coloring with white
	ll a1 = DFS(1, -1, 0);
	// starting the coloring with black
	ll a2 = DFS(1, -1, 1);
	// rule of sum
	ll answ = (a1 + a2) % mod;
	cout << answ << endl;
}


void fastIO()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
}

void IO()
{
	if(fopen("d:\\lmo.in","r") != NULL)
	{
		freopen("d:\\lmo.in","r",stdin);
	}
	else if(fopen("/media/Beijing/lmo.in","r") != NULL)
	{
		freopen("/media/Beijing/lmo.in", "r", stdin);
	}
}

int main()
{
	IO();

	fastIO();

	solve();
}


Measured memory_bytes: 19712
use std::io::*;
use std::str::FromStr;

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let mut red: Vec<usize> = Vec::new();
    let mut blue: Vec<usize> = Vec::new();
    for i in 0..s.len() {
        match s[i] {
            '0' => {
                red.push(i);
                red.push(i);
            },
            '1' => {
                red.push(i);
                blue.push(i);
            },
            _ => {
                blue.push(i);
                blue.push(i);
            }
        }
    }
    
    let mo: i64 = 998244353;
    let mut dp: Vec<Vec<i64>> = vec![vec![0; 2*s.len()+1]; 2*s.len()+1];
    dp[0][0] = 1;
    for i in 0..red.len()+1 {
        for j in 0..blue.len()+1 {
            dp[i][j] %= mo;
            let m = i + j;
            if i < red.len() && red[i] <= m {
                dp[i+1][j] += dp[i][j];
            }
            if j < blue.len() && blue[j] <= m {
                dp[i][j+1] += dp[i][j];
            }
        }
    }
    println!("{}", dp[red.len()][blue.len()] % mo);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 151804
#include<stdio.h>

int main(void) {
	int n, t, i, d;
	scanf("%d %d", &n, &t);
	int a[n];
	for (i = 0; i < n; i++) scanf("%d", &a[i]);
	int x = 0;
	for (i = 0; i < n - 1; i++) {
		d = a[i + 1] - a[i];
		if (d < t) x += d;
		else x+= t;
	}
	x += t;
	printf("%d", x);
	return 0;
}

Measured memory_bytes: 896
import java.util.*;
public class Main{
  	public static long power(long x,long y){
      if (y == 0) {
        return 1; 
      }
      long a = power(x,y/2)%1000000007;
      if (y % 2 == 0) {
          return  ((a %1000000007)*(a %1000000007))%1000000007;
      }
      else{
          return ((x%1000000007)*(a%1000000007)*(a%1000000007))% 1000000007; 
      }
    }
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String[] s = scan.next().split("");
      	long total = 0;
      	long m = 1000000007;
      	long mt = 1;
      	for (int i=0;i<s.length;i++){
          if (s[i].equals("1")){
            total = (total%m+(mt*power(3,s.length-i-1))%m)%m;
            mt = (mt*2)%m;
          }
        }
      	System.out.println((total+mt)%m);
	}
}

Measured memory_bytes: 34660
#include <iostream>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){
  stack<int> S1;
  stack<pair<int,int> > S2;
  char ch;
  int sum=0;
  for(int i=0;cin >> ch;i++){
    if(ch=='\\') S1.push(i);
    else if(ch=='/'&&S1.size()>0){
      int j=S1.top(); S1.pop();
      sum+=i-j;
      int a=i-j;
      while(S2.size()>0&&S2.top().first>j){
        a+=S2.top().second; S2.pop();
      }
      S2.push(make_pair(j,a));
    }
  }
  vector<int> ans;
  while(S2.size()>0){
    ans.push_back(S2.top().second);
    S2.pop();
  }
  reverse(ans.begin(),ans.end());
  cout << sum << endl;
  cout << ans.size();
  for(int i=0;i<ans.size();i++){
    cout << " ";
    cout << ans[i];
  }
  cout << endl;
}

Measured memory_bytes: 3164
# from sys import exit, stderr
# from inspect import currentframe
# def debug(*args):
#     names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
#     print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args), file=stderr)
#     return
N, D = [int(n) for n in input().split()]
# a = [int(input()) for _ in range(N)]
# S = str(input())
# L = len(S)
# INF = 10000000002
# EPS = 1e-9
# exit()
D *= 2
D += 1
ans = 0
while(N>0):
    N-= D
    ans+=1
print(ans)


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

int main() {
  int n, m;
  cin >> n >> m;

  int k;
  cin >> k;

  bool yes = false;

  for(int i=0;i<=n;i++) {
    for(int j=0;j<=m;j++) {
      int white = n * m - i * m - j * n + 2 * i * j;
      if(n * m - white == k) {
        yes = true;
        break;
      }
    }
    if(yes) break;
  }

  if(yes) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){

	while(1){

		int n,i,k,a[10000]={0},b[100]={0};
		
		scanf("%d",&n);

		if(n==0)break;

		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
			for(k=0;k<10;k++){
				if(k==a[i])
					b[k]++;
			}
		}
		for(i=0;i<10;i++){
			if(b[i]==0)
				printf("-");
			else
				for(k=0;k<b[i];k++){
					printf("*");
				}
			printf("\n");
		}
	}
return 0;
	
}

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

using namespace std;

int main() {
	string s; cin >> s;
	int cnt = 0;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == 'o') cnt++;
	}
	if (15 - s.size() >= 8 - cnt)cout << "YES";
	else cout << "NO";

	return 0;
}

Measured memory_bytes: 384
import fractions
from functools import reduce

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm, numbers, 1)


n = int(input())
l = [int(_) for _ in input().split()]
x = lcm_list(l)
ans = 0
for i in range(n):
    ans += x // l[i]
ans %= (10**9 + 7)
print(ans)

Measured memory_bytes: 6108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    int a, b;
    cin >> a >> b;
    for (int i = 1; i <= 3; i++)
    {
        if (i != a && i != b)
        {
            cout << i << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    while(cin>>s)

    {

    int a=s.size()-1;
        if(s[a]=='2'||s[a]=='4'||s[a]=='5'||s[a]=='7'||s[a]=='9')
        {
            cout<<"hon"<<endl;
        }
        else if(s[a]=='3')cout<<"bon"<<endl;
        else cout<<"pon"<<endl;



    }











    return 0;
}


Measured memory_bytes: 3572
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp1 = input[0].split(" ");
	tmp2 = input[1].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var n = parseInt(tmp1[0], 10);
	var k = parseInt(tmp1[1], 10);
	
	// var tmp = input[1].split(" ");
     var i = 0;               //横数字から配列作成
   var a = [];
for (var i = 0; i < n ; i++){
  var r= parseInt(tmp2[i], 10);
    a[i] = r;}
 // console.log(a);


 
var result = a.filter( function( value ) {     //配列の要素を条件で抽出
 
   ///kよりも大きな数値だけを抽出
    return value >= k;
 
})
 
//console.log( result );

console.log(result.length);


	//出力

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 27712