akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

int main()
{
    int n;
    std::cin >> n;

    std::vector<int> h(n);
    for (int i = 0; i < n; i++) {
        std::cin >> h[i];
    }

    std::vector<int> dp(n, std::numeric_limits<int>::max());
    dp[0] = 0;

    for (int i = 0; i < n; i++) {
        if (i + 1 < n) {
            dp[i + 1] = std::min(dp[i + 1], std::abs(h[i + 1] - h[i]) + dp[i]);
        }

        if (i + 2 < n) {
            dp[i + 2] = std::min(dp[i + 2], std::abs(h[i + 2] - h[i]) + dp[i]);
        }
    }

    std::cout << dp[n - 1] << std::endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){

        int n,k;
         cin>>n>>k;


       map<int,int>g;

         for(int i=1;i<=n;i++)
          g.insert(pair<int,int>(i,0));

          for(int i=1;i<=k;i++){

                 int di;
                 cin>>di;

               for(int j=1;j<=di;j++){
                   int x;
                    cin>>x;

                   auto itr = g.find(x);
                    itr->second =itr->second +1;
               }
          }
        int count = 0;

          for(int i=1;i<=n;i++){
              auto itr = g.find(i);

                if(itr->second ==0)
                 count++;
          }
         cout<<count;
}


Measured memory_bytes: 3632
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int n;
    cin >> n;

    switch (n % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        break;

    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;

    case 3:
        cout << "bon" << endl;
        break;

    default:
        break;
    }

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
#include<iomanip>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef vector<string> vstring;
typedef vector<vector<string>> vvstring;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<long double> vdouble;
typedef vector<vector<long double>> vvdouble;
typedef vector<vector<vector<long double>>> vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define DIVIDER 1000000007


//
// struct Node{
//   vint children;
//   ll index;
//   ll prop;
// };
// struct edge{ll to; ll cost;};



int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0,};

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }

// ll gcd(ll m, ll n){
//   if(m<n) swap(m,n);
//   if(n==0) return m;
//   return gcd(n, m%n);
// }

// ll get_pow(ll x, ll y){
//   ll ret=0;
//   ll temp = y;
//   while(true){
//     if(x<=temp) break;
//     ret++;
//     temp *= 2;
//   }
//   return ret;
// }






int main() {
  cout<<fixed<<setprecision(10);

  ll K;cin>>K;

  // if(K==0){
  //   cout << 2 << endl;
  //   cout << "1 1" << endl;
  // }

  cout << 50 << endl;
  ll ai = 49 - K%50;
  string out = "";
  rep(i,50){
    out = to_string(ai+K/50) + " " + out;
    ai = (ai-1+51)%51;
  }

  cout << out;
  cout << endl;



}

















//


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main(){
    	int a, b;
      	cin >> a >> b;
      	if(a <= b){
          	cout << "unsafe" << endl;
        }else{
    		cout << "safe" << endl;
        }
      	
      	return 0;
    }

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define debug(x) cerr<<#x<<" "<<x<<endl;

signed main() {
  int n;cin>>n;
  int s,t;
  cin>>s>>t;
  for(int i=0;i<n-1;++i){
    int p,q;cin>>p>>q;
    int tmp = max((s+p-1)/p, (t+q-1)/q);
    s=tmp*p;
    t=tmp*q;
  }
  cout<<s+t<<endl;
  return 0;
}


Measured memory_bytes: 256
def solve():
    for i in range(1, b+1):
        if (a * i) % b == c:
            print("YES")
            return 
    print("NO")
    return

if __name__ == '__main__':
    a, b, c = map(int, input().split())
    if a == 1:
        print("YES")
    else:
        solve()

Measured memory_bytes: 3316
#import sys
#input = sys.stdin.readline

n = int(input())

for i in range(n):
    if i == 0:
        dp = [int(i) for i in input().split()]
    else:
        abc = [int(i) for i in input().split()]
        dp[0], dp[1], dp[2] = abc[0] + max(dp[1], dp[2]), abc[1] + max(dp[0], dp[2]), abc[2] + max(dp[0], dp[1])
    
print(max(dp))



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

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

  for (int i = 1; i<=n; i++){
    if ( i % 3 == 0){
      cout << " " << i;
    }

    else {
      for ( int x = i; x!=0;){
        if (x % 10 ==3){
          cout << " " << i;
          break;
        }
        else{
          x /= 10;
        }
      }
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;


int main(){
    long long int a,b,c,ans;cin >> a >> b >> c;
    if(c-b<=2 || a<=(b-2)){
        ans = 1+a;
    }else{
        if((a-b+1)%2 == 0){
            ans = b + ((c-b)*((a-b+1)/2));
        }else{
            ans = b + ((c-b)*((a-b)/2))+1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
input_line = input()
def check():
  num = 1
  for i in input_line:
      if num % 2 == 1 and i == 'L':
          return 'No'
          break
      elif num % 2 == 0 and i == 'R':
          return 'No'
          break
      elif num % 2 == 1 and i == 'R' or i == 'U' or i == 'D':
          pass
      elif num % 2 == 0 and i == 'L' or i == 'U' or i == 'D':
          pass
      num += 1

if check() == 'No':
  print('No')
else:
  print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, a, b;
    cin >> n >> a >> b;
    if (a+b > n+1){
        cout << -1 << endl;
        return 0;
    }
    if (a*b < n){
        cout << -1 << endl;
        return 0;
    }
    vector<int> ans(n);
    int st = 1;
    vector<pair<int, int> > blocks;
    for (int i=n-1; i >= 0; i-=a){
        int S = max((int) 0, i-a+1);
        int diff = i-S+1;
        for (int j=S; j <= i; j++){
            ans[j] = st + (j-S);
        }
        st += diff;
        blocks.push_back(make_pair(S, i));
    }
    reverse(blocks.begin(), blocks.end());
    b -= (n+a-1) / a;
    int u = 0;
    while (b > 0){
        int sz = blocks[u].second - blocks[u].first + 1;
        if (sz-1 <= b){
            b-=sz-1;
            vector<int> h;
            for (int j=blocks[u].first; j <= blocks[u].second; j++) h.push_back(ans[j]);
            reverse(h.begin(), h.end());
            for (int j=blocks[u].first; j <= blocks[u].second; j++) ans[j] = h[j - blocks[u].first];
        }
        else{
            vector<int> h;
            for (int j=blocks[u].second; j > blocks[u].second - b; j--) h.push_back(ans[j]);
            for (int j=blocks[u].first; j <= blocks[u].second - b; j++) h.push_back(ans[j]);
            for (int j=blocks[u].first; j <= blocks[u].second; j++) ans[j] = h[j - blocks[u].first];
            b = 0;
        }
        u++;
    }
    for (int i=0; i < n; i++) cout << ans[i] << " ";
    return 0;
}


Measured memory_bytes: 4724
/*
[dp] L - Deque
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 3000;

int N;
ll a[MAX_N];
ll dp[MAX_N + 1][MAX_N + 1];

ll solve() {
    for (int i = 1; i <= N; i++) {
        for (int l = 0; l + i <= N; l++) {
            int r = l + i;
            if ((N - i) % 2 == 0) {
                dp[l][r] = max(dp[l + 1][r] + a[l], dp[l][r - 1] + a[r - 1]);
            } else {
                dp[l][r] = min(dp[l + 1][r] - a[l], dp[l][r - 1] - a[r - 1]);
            }
        }
    }

    return dp[0][N];
}

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

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 70016
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<algorithm>
typedef long long ll;
int main() {
	int n = 0;
	int ansf = 0;
	int ans = 0;
	char f;
	int counttypel = 0;
	int counttyper = 0;
	std::map<char, int> ml;
	std::map<char, int> mr;
	std::string str;
	std::cin >> n >> str;
	for (int i = 0; i < n-1; i++) {
		for (int j = 0; j < i+1; j++) {
			f = str[j];
			if (ml[f] == 0) {
				counttypel++;
			}
			ml[f]++;
		}
		for (int j = i + 1; j < n; j++) {
			f = str[j];
			if (mr[f] == 0&&ml[f]>0) {
				counttyper++;
			}
			mr[f]++;
		}
		mr = {};
		ml = {};
		ansf = std::min(counttypel, counttyper);
		ans = std::max(ans, ansf);
		ansf = 0;
		counttypel = 0;
		counttyper = 0;
	}
	std::cout << ans << std::endl;
	return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n  ;
  cin >> n ;
  int T = 0 ;
  int X = 0 ;
  int Y = 0 ;
  string ans = "Yes" ;
  
  rep(i,n){
    int t , x , y ;
    cin >> t >> x >> y ;
    
    if( abs(T-t) >= abs(X-x) + abs(Y-y)){
      if((abs(T-t) - abs(X-x) -abs(Y-y)) % 2 !=0){
        ans = "No";
      }
    }
   else ans = "No";
   
   T = t ;
   X = x ;
   Y = y ;
    
  }  
  cout << ans ;


}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int H, W;
  cin>>H>>W;
  vector<string> arr(H);
  for(int i=0;i<H;++i) cin>>arr[i];
  for(int i=0;i<W+2;++i) cout<<"#";
  cout<<endl;
  for(int i=0;i<H;++i) {
    cout<<"#";
    cout<<arr[i];
    cout<<"#"<<endl;
  }
  for(int i=0;i<W+2;++i) cout<<"#";
  cout<<endl;
}



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

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

using namespace std;

int main(){
	int a,b; cin>>a>>b;
	cout<<(a%3==0||b%3==0||(a+b)%3==0?"Possible":"Impossible")<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a<b){
      cout<<"a < b"<<endl;
  }    
  if(a>b){
      cout<<"a > b"<<endl;
  }
  if(a==b){
      cout<<"a == b"<<endl;
  }
}  




Measured memory_bytes: 3072
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int main() {
  int N;
  vector<int> A;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    A.push_back(tmp);
  }

  int max = -1;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
        int tmp = A[i] - A[j];
        if (tmp < 0) { tmp *= -1; }
        if (tmp > max) {
          max = tmp;
        }
    }
  }
  cout << max << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll H, W; cin >> H >> W;
  ll N; cin >> N;
  vector<ll> color;
  for (ll i = 0; i < N; i++) {
    ll a; cin >> a;
    for (ll j = 0; j < a; j++) {
      color.push_back(i+1);
    }
  }
  for (ll i = 0; i < H; i++) {
    for (ll j = 0; j < W; j++) {
      if (i%2 == 0) {
        cout << color[i*W+j] << " ";
      } else {
        cout << color[i*W+W-1-j] << " ";
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 512
import Data.List
import Text.Printf

main = getContents >>= mapM_ (printf "%.6f\n" . grey_area) . read' . lines
 where
  read' ("0 0":_) = []
  read' (nw:xs) = ((n,w), map read vs) : read' xs'
   where
    [n,w] = map read (words nw)
    (vs,xs') = splitAt n xs

grey_area :: ((Int, Int), [Int]) -> Double
grey_area ((n,w),vs) = sum (zipWith (*) darkness amount) + 0.01
 where
  darkness = [1.0,(1.0-d)..]
   where d = 1.0 / fromIntegral (div (maximum vs) w)
  amount = map ((/ (fromIntegral maxlen)) . fromIntegral . length) vs'
   where
    maxlen = maximum (map length vs')
    vs' = unfoldr equali (0,(sort vs))
    equali (n,vs)
     | null vs = Nothing
     | otherwise = let (vs1,vs2) = span (\v -> div v w == n) vs in Just (vs1,(n+1,vs2))

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define ll long long
#define el '\n'

using namespace std;

int a, b, a2, b2, x;

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

    cin >> a >> b >> a2 >> b2 >> x;
    int awal = a * 60 + b;
    int akhir = a2 * 60 + b2;
    cout << akhir - awal - x << el;

    return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<pair<int,int>> ab(n);
    for(int i=0;i<n;i++) cin>>ab[i].first>>ab[i].second; 

    int cnt=0;
    for(int day=1;day<=31;day++){
        int bestId=-1;
        for(int j=0;j<ab.size();j++){
            if(ab[j].first<=day && day<=ab[j].second){
                if(bestId==-1 || ab[j].second<ab[bestId].second){
                    bestId=j;
                }
            }
        }
        if(bestId!=-1){
            ab.erase(ab.begin()+bestId);
            cnt++;
        }
    }

    cout<<(31-cnt)*50+cnt*100<<endl;
    
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#define re read()
#define ll long long
using namespace std;
inline int read() {
    int ret = 0, f = 1;char ch = getchar();
    while (ch < '0' || ch  >'9') {if (ch == '-') f = -f; ch = getchar();}
    while (ch >= '0' && ch <= '9') ret =ret * 10 + ch - '0', ch = getchar();
    return ret*f;
}
int main() {
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int a, b, c;
	a = re, b = re, c = re;
	if(b * 2 == a + c)
		puts("YES\n");
	else puts("NO\n"); 
	//fclose(stdin);
	//fclose(stdout);
	return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	h, w, n = LI()
	black_points = []
	for i in range(n):
		a, b = LI()
		add_list = ((a-2,b-2),(a-2,b-1),(a-2,b),(a-1,b-2),(a-1,b-1),(a-1,b),(a,b-2),(a,b-1),(a,b))
		for c, d in add_list:
			if 1 <= c <= h-2 and 1 <= d <= w-2:
				black_points.append((c,d))
	counter = Counter(black_points)
	count_list = list(counter.values())
	counter2 = Counter(count_list)
	ans_list = [counter2[i] for i in range(1,10)]
	ans_list = [(h-2)*(w-2)-sum(ans_list)] + ans_list
	for ans in ans_list:
		print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 196472
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

const ll MOD=998244353ll;

ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k>0){
        if(k%2==1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k/=2;
    }
    return ans;
}

int main()
{
  string s;
  cin>>s;
  int n=s.size();
  if(n==2){
    if(s[0]==s[1]) cout<<1<<endl;
    else cout<<2<<endl;
    return 0;
  }else if(n==3){
    if(s[0]==s[1] && s[1]==s[2]){
      cout<<1<<endl;
    }else if(s[0]!=s[1] && s[1]!=s[2] && s[2]!=s[0]){
      cout<<3<<endl;
    }else if(s[0]==s[2]){
      cout<<7<<endl;
    }else{
      cout<<6<<endl;
    }
    return 0;
  }
  int m=0;
  bool diff=1;
  bool same=1;
  for(int i=0; i<n; i++){
    m+=(s[i]-'a');
    m%=3;
    if(i+1<n && s[i]==s[i+1]) diff=0;
    if(i+1<n && s[i]!=s[i+1]) same=0;
  }
  if(same){
    cout<<1<<endl;
    return 0;
  }
  ll ans=powmod(3ll, (ll)(n-1))+MOD-powmod(2ll, (ll)(n-1));
  if(n%3==0){
    if(m==0){
      ans-=powmod(2ll, (ll)(n/3));
      ans+=MOD;
    }else{
      ans+=powmod(2ll, (ll)(n/3-1));
    }
  }
  ans%=MOD;
  if(diff){
    ans++;
    ans%=MOD;
  }
  cout<<ans<<endl;
	return 0;
}

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

int main(){
  int a,b,c; cin>>a >>b >>c;
  if(a<c&&b>c){
    cout<<"Yes"<<endl;
    return 0;
  }else if(b<c&&a>c){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    ll p = 1, q = 1;
    for(ll i=0;i<n;++i){
        ll t, a;
        cin>>t>>a;
        ll k = max((p+t-1)/t, (q+a-1)/a);
        p = t * k;
        q = a * k;
    }
    ll ans = p + q;
    cout<<ans<<endl;

    return 0;
}

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

template <class T>
T gcd(T a, T b) {
    if (a < b) std::swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}

int main() {
    long long a,b,c,d,t;

    std::cin >> t;
    for (;t--;) {
        std::cin >> a >> b >> c >> d;
        if (b > a || b > d) {
            std::cout << "No\n";
        } else if (c >= b) {
            std::cout << "Yes\n";
        } else {
            auto g = gcd(b, d);
            auto n = b - g + a % g;
            std::cout << (n > c ? "No\n" : "Yes\n");
        }
    }

    std::cout << std::flush;

    return 0;
}


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

int main ( void )
{
	int a, b, c;
	cin >> a;
	cin >> b;
	cin >> c;
	if ( ( a > 0 ) && ( a <= 100 ) ){
		if ( ( b > 0 ) && ( b <= 100 ) ){
			if ( ( c > 0 ) && ( c <= 100 ) ){
				swap ( a, b );
				swap ( a, c );
				printf ( "%d %d %d\n", a, b, c );
			}
		}
	}
	return 0;
}

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

struct mint{
    // 自動的にmodを取ってくれるクラスです。
    ll x;
    mint(ll x = 0):x(x%mod){}
    mint& operator+=(const mint a){
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a){
        if((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if(!t) return 1;
        mint b = pow(t/2);
        b *= b;
        if(t%2 == 1) b *= *this;
        return b;
    }

    mint inv() const{
        return pow(mod-2);
    }
    mint& operator/=(const mint a){
        (*this) *= a.inv();
        return *this;
    }
    mint operator/(const mint a) const{
        mint res(*this);
        return res/=a;
    }
};

int main(){
    int s;
    cin >> s;
    vector<mint> dp(2005,0);
    dp.at(0) = mint(1);
    rep(i,2005){
        rep(j,i-2){
            dp.at(i) += dp.at(j);
        }
    }
    cout << dp.at(s).x << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += b % mod) %= mod; if (a < 0) a += mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n;
  cin >> n;
  cout << n * n * n << endl;
}


Measured memory_bytes: 3652
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int x = sc.nextInt();
      int y = sc.nextInt();
      
      long cost = 0;
      if(a + b >= c * 2) {
        int min = Math.min(x, y);
        cost = c * 2 * min;
        x -= min;
        y -= min;
      }
      cost += x * Math.min(a, c * 2);
      cost += y * Math.min(b, c * 2);
      
      System.out.println(cost);
  }
}

Measured memory_bytes: 23124
import java.math.BigInteger;
import java.util.Scanner;
import java.util.*;
public class Main {
	public static void main(String[] args) {
		BigInteger a,b;
		Scanner cin=new Scanner(System.in);
		a=cin.nextBigInteger();
		b=cin.nextBigInteger();
		System.out.println(a.subtract(b));
	}
}



Measured memory_bytes: 75208
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let x = read::<i64>();
    let d = (0..n)
        .map(|_| (x - read::<i64>()).abs() as usize)
        .collect::<Vec<_>>();

    let mut g = d[0];
    for i in 1..d.len() {
        g = gcd(g, d[i])
    }
    println!("{}", g);

    fn gcd(a: usize, b: usize) -> usize {
        if b == 0 {
            a
        } else {
            gcd(b, a % b)
        }
    }
}


Measured memory_bytes: 4352
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

x, k, d = LI()
if d*k <= abs(x):
    print(abs(x) - d*k)
else:
    y = abs(x) // d
    if (k - y) % 2:
        print(abs(abs(x) - d*(y+1)))
    else:
        print(abs(x) - d*y)


Measured memory_bytes: 65356
//写一个将二维数组传入函数的函数
#include<stdio.h>
long long sum,h;
int n;
int main(void)
{
    scanf("%lld%d",&h,&n);
    while(n--){
        int f;
        scanf("%d",&f);
        sum+=f;
    }
    if(sum>=h)
        printf("Yes");
    else
        printf("No");
    return 0;
}

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

void solve()
{
    int d;cin>>d;
    int c[26];REP(i,26)cin>>c[i];
    int s[d][26];REP(i,d)REP(j,26)cin>>s[i][j];
    vector<int>cnt(26,0);
    ll ans=0;
    REP(i,d){
        int t;cin>>t;t--;cnt[t]=-1;
        ans+=s[i][t];
        REP(j,26)cnt[j]++,ans-=cnt[j]*c[j];
        cout<<ans<<endl;
    }
}

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

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

int main()
{
	int n, q;

	cin >> n >> q;

	deque<deque<int>> v(n);

	for (int i = 0; i < q; i++) {
		int command, t;
		cin >> command >> t;

		if (command == 0) {
			int x;
			cin >> x;

			v[t].push_back(x);
		}		
		else if (command == 1 && !v[t].empty()) {
			cout << v[t][0] << endl;
		}
		else if (command == 2 && !v[t].empty()) {
			v[t].pop_front();
		}
	}

	return 0;
}



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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>


using namespace std;

/////////////////////////////////////////////////////
#define INF 1e15
ll A,B,Q,s[101010],t[101010];
ll ans,mk[10];
ll i, j, k;

ll bs(ll a,ll b,ll* v){
    ll l = 0, r = b - 1;
    while(l<=r){
        ll c = (l + r) / 2;
        if(v[c]>a){
            r = c-1;
        }else{
            l = c+1;
        }
    }
    return r;
}
ll minn(ll a,ll b){
    return a < b ? a : b;
}

int main(){
    scanf("%lld%lld%lld", &A,&B,&Q);
    fornum(i,0,A){
        scanf("%lld", &s[i+1]);
    }
    fornum(i,0,B){
        scanf("%lld", &t[i+1]);
    }
    s[0] = t[0] = -INF;
    s[A+1] = t[B+1] = INF;
    s[A+2] = t[B+2] = INF*2;
    A += 3;
    B += 3;
    fornum(i,0,Q){
        ll x;
        ll ans = INF;
        scanf("%lld", &x);
        ll a = bs(x, A, s);
        ll b = bs(s[a], B, t);
        
        ans = minn(ans, x - t[b]);
        ans = minn(ans, x - s[a] * 2 + t[b + 1]);
        //printf("%lld,%lld,%lld\n", a, b,ans);
        a++;
        b = bs(s[a], B, t);
        ans = minn(ans, s[a] * 2 - t[b] - x);
        ans = minn(ans, t[b + 1] - x);
        //printf("%lld,%lld,%lld\n", a, b,ans);

        b = bs(x, B, t);
        a = bs(t[b], A, s);
        ans = minn(ans, x - s[a]);
        ans = minn(ans, x - t[b] * 2 + s[a + 1]);
        //printf("%lld,%lld,%lld\n", a, b,ans);
        b++;
        a = bs(t[b], A, s);
        ans = minn(ans, t[b] * 2 - s[a] - x);
        ans = minn(ans, s[a+1]-x);
        //printf("%lld,%lld,%lld\n", a, b,ans);
        printf("%lld\n", ans);
    }

    return 0;
}

Measured memory_bytes: 2944
use std::io::Read;
use std::str::SplitWhitespace;
use std::str::FromStr;

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

pub trait Parse<T> {
    fn parse(&mut self) -> T;
}

impl<'a, T> Parse<T> for SplitWhitespace<'a>
where
    T: FromStr,
{
    fn parse(&mut self) -> T {
        let word = self.next().unwrap();
        word.parse().ok().unwrap()
    }
}

fn binary_search_position(v: &[u32], x: u32) -> usize {
    let len = v.len();
    if len == 1 {
        return 0;
    }
    let i = len / 2;
    if v[i] < x {
        binary_search_position(&v[i..], x) + i
    } else {
        binary_search_position(&v[..i], x)
    }
}

fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let n: usize = iter.parse();
    let size = 2_u32.pow(n as u32) as usize;
    let mut v: Vec<u32> = (0..size).map(|_| iter.parse()).collect();
    v.sort();

    let last = v.len() - 1;
    let mut ss = Vec::with_capacity(size);
    ss.push(v[last]);
    v.remove(last);

    for i in 0..n {
        let s = 2_u32.pow(i as u32) as usize;
        for j in 0..s {
            let mut index = binary_search_position(&v, ss[j]);
            index = if index == v.len() { index - 1 } else { index };
            if v[index] < ss[j] {
                ss.push(v[index]);
                v.remove(index);
            } else {
                println!("No");
                return;
            }
        }
    }

    println!("Yes");
}

Measured memory_bytes: 10488
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

x = iinp()

ans = 0

ans += (x//500)*1000

x = x%500

ans += (x//5)*5

x = x%5

print(ans)

Measured memory_bytes: 3064
import std.stdio,std.math,std.string,std.conv,std.typecons,std.format;
import std.algorithm,std.range,std.array;
 
T[] readarr(T=long)(){return readln.chomp.split.to!(T[]);}
void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;}
 
//END OF TEMPLATE
 
void main(){
    ulong k;
    k.scan;
    char[] ans;
    if(k<10)
        ans=k.to!(char[]);
    else{
        ans=k.solve;
    }
    ans.writeln;
}
 
struct Queue{
    public:
    string[] list;
    auto enq(char c){list~=c.to!string;}
    auto enq(char[] c){list~=c.to!string;}
    auto deq(){auto d=list[0];list=list.length==1?[]:list[1..$];return d;}
}
 
char[] co(char c){
    if(c=='0')
        return ['0','1'];
    if('1'<=c&&c<='8')
        return [to!char(c-1),c,to!char(c+1)];
    if(c=='9')
        return ['8','9'];
    assert(0);
}
 
auto solve(ulong k){
    Queue q;
    foreach(c;'1'.to!char..('9'+1).to!char)q.enq(c);
    foreach(i;0..k-1){
        auto tmp=q.deq;
        foreach(s;tmp[$-1].co)
            q.enq(tmp.dup~s);
    }
    return q.deq.dup;
}

Measured memory_bytes: 19196
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
const double pi=3.1415926535897932384626;
int main(){
    ll l,r;
    std::cin >> l>>r;
    ll ans=INF;
    rrep(i,l,min(r,l+2019)){
        rrep(j,i+1,min(r+1,l+2020)){
            ans=min(ans,(ll(i)*j)%2019);
        }
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
int d[100010],f[333][333][2],fact[310],ifact[310];
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	int n=gi(),mx=0;
	for(int i=1;i<=n;++i)cxk(mx,d[i]=gi());
	fact[0]=1;for(int i=1;i<=n;++i)fact[i]=1ll*fact[i-1]*i%mod;
	ifact[n]=pow(fact[n],mod-2);for(int i=n;i;--i)ifact[i-1]=1ll*ifact[i]*i%mod;
	if(mx==2)printf("%d\n",1ll*(mod+1>>1)*fact[n-1]%mod),exit(0);
	f[1][0][0]=1;
	for(int i=1;i<=n;++i){
		for(int j=0;j<i;++j)
			for(int k=0;k<2;++k)
				if(f[i][j][k]){
					inc(f[i+1][j][k],1ll*ifact[d[i]-1]*f[i][j][k]%mod);
					if(d[i]>=2)inc(f[i+1][j+1][k],1ll*ifact[d[i]-2]*f[i][j][k]%mod);
					if(!k&&d[i]>=3)inc(f[i+1][j+1][1],1ll*ifact[d[i]-3]*f[i][j][k]%mod);
				}
	}
	int ans=0;for(int i=3;i<n;++i)inc(ans,1ll*fact[n-i-1]*f[n+1][i][1]%mod*fact[i-1]%mod);
	printf("%d\n",1ll*ans*(mod+1>>1)%mod);
	return 0;
}


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

int main() {
    int N; cin >> N;
    vector<int> v(N);
    for (int i = 0; i < N; i++) cin >> v[i];
    sort(v.begin(), v.end());

    cout << v[v.size()-1] - v[0] << endl;
}

Measured memory_bytes: 256
S=input()
T=input()
'''
if((len(S)+1)!=(len(T))):
    print('No')
    exit()
i=0
for i in range(len(S)):
    if(S[i]!=T[i]):
        print('No')
        exit()

print('Yes')

'''

if(S[0:len(S)]==T[0:len(T)-1]):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 61828
S = list(input())
T = list(input())

count = 0
if S[0] == T[0]:
    count = count +1
else:
        pass
if S[1] == T[1]:
    count = count +1
else:
        pass
if S[2] == T[2]:
    count = count +1
else:
        pass
  
print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<queue>
#include<functional>
using namespace std;
#pragma warning(disable: 4996)
long long n;
int main() {
	cin >> n;
	for (int i = 1; i <= 3500; i++) {
		for (int j = 1; j <= 3500; j++) {
			long long A = 4LL * i*j - n*(i + j);
			long long B = n*i*j;
			if (A >= 1 && B%A == 0) {
				cout << i << " " << j << " " << B / A << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define MN 100000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,head[MN+5],cnt=0,f[MN+5],v[MN+5],ans=0;
struct edge{int to,next;}e[MN*2+5];
inline void ins(int f,int t)
{
	e[++cnt]=(edge){t,head[f]};head[f]=cnt;
	e[++cnt]=(edge){f,head[t]};head[t]=cnt;	
}
void dfs(int x,int fa)
{
	int has=0,bad=0;
	for(int i=head[x];i;i=e[i].next)
		if(e[i].to!=fa)
		{
			dfs(e[i].to,x);
			bad|=(has&f[e[i].to]);
			has|=f[e[i].to];
		}
	for(v[x]=16;~v[x];--v[x]) if(bad&(1<<v[x])) break;
	for(++v[x];has&(1<<v[x]);++v[x]);
	f[x]=(has&((1<<17)-(1<<v[x])))|(1<<v[x]);
	ans=max(ans,v[x]);
}

int main()
{
	n=read();
	for(int i=1;i<n;++i) ins(read(),read());
	dfs(1,0);cout<<ans;
	return 0;
}



Measured memory_bytes: 7552
n=int(input())
a=[int(input()) for i in range(n)]

res=max(a)
ans=[res]*n
s=[i for i, x in enumerate(a) if x ==res]
a.sort()
res2=a[-2]
for i in s:
    ans[i]=res2
for i in range(n):
    print(ans[i])

Measured memory_bytes: 23076
#n == 1でバグるけど2が返ってくるのでヨシ！
from sys import setrecursionlimit
setrecursionlimit(10 ** 9)

n = int(input())
X = [[int(i) for i in input().split()] for j in range(n-1)]
p = 10 ** 9 + 7

V = [[] for i in range(n+1)]
for x, y in X:
    V[x].append(y)
    V[y].append(x)

w = 0
b = 1
DP = [[0] *  2 for i in range(n+1)]

def dfs(i):
    if DP[i] != [0, 0]:
        return 0
    DP[i][w] = 1
    DP[i][b] = 1
    for v in V[i]:
        if dfs(v) == 0:
            continue
        DP[i][w] *= DP[v][w] + DP[v][b]
        DP[i][b] *= DP[v][w]
        DP[i][w] %= p
        DP[i][b] %= p

dfs(1)
print(sum(DP[1]) % p)        

Measured memory_bytes: 121888
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
#include <limits.h>
//#include <math.h>

#define Max(a, b) ((a>b)?a:b)

int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  for (int i=0; i<n; i++)
    scanf("%d", a+i);
  long dp[n][2];
  dp[0][0] = 0;
  dp[0][1] = a[0];
  dp[1][0] = 0;
  dp[1][1] = Max(dp[0][1], a[1]);
  for (int i=2; i<n; i++) {
    if (i%2) {
      dp[i][0] = Max(dp[i-1][0], dp[i-2][0]+a[i]);
      dp[i][1] = Max(dp[i-1][1], dp[i-2][1]+a[i]);
    } else {
      dp[i][0] = Max(dp[i-1][1], dp[i-2][0]+a[i]);
      dp[i][1] = dp[i-2][1]+a[i];
    }
  }
  printf("%ld\n", dp[n-1][(n+1)%2]);
  return 0;
}


Measured memory_bytes: 5624
main(a,b,c,p,q,r,s,S,i,j){for(;scanf("%d%d%d",&a,&b,&c),a;){
if(!c)a==1&&b<0?printf("1 0 %d %d\n",a,b):printf("%d %d 1 0\n",a,b);
else{
	for(r=1;r*r<=a;r++)if(a%r==0)for(p=a/r,S=1;S*S<=abs(c);S++)if(c%S==0){
		s=S;
		for(j=0;j<2;j++,s=c/s)for(i=0;i<2;i++,s=-s)if(q=c/s,p*s+q*r==b){
			p==r&&q<s?printf("%d %d %d %d\n",r,s,p,q):printf("%d %d %d %d\n",p,q,r,s);
			goto next;
		}
	}
	puts("Impossible");
}next:;}exit(0);}

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

int main() {
  int A;
  cin >> A;
    
   int count =0;
   for (int b = 0; b <= 25;b++) {
     for (int c = 0; c <= 14;c++) {
       int total = 4*b + 7*c; 
       if (total == A) {
         count++;
       } 
     }
   }
  
 if (count > 0) {
   cout << "Yes" << endl;
 }
  else {
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    char c; cin >> c; c++;

    dunk(c);
}

Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0:
        break

    s = list(map(int, input().split()))

    sum_s = sum(s)
    avg_s = (float)(sum_s / n)
    div = 0
    for v in s:
        div += (v - avg_s) ** 2 / n
    print("{:.10f}".format(div ** 0.5))


Measured memory_bytes: 5664
#include<iostream>
#include<string>
using namespace std;
 
int main(){
 string s;
 cin>>s;
 s=s.substr(0, s.size() - 1);
 int len;
 for(len = s.size()/2;len>0;len--){
 	if(s.substr(0,len) == s.substr(len,len)){
 		break;
	 }
 }
 cout<< len * 2<<endl;
 return 0;
}

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

int main(){
  long n,k;
  cin >> n >> k;
  long mod = INF;
  long ans = 0;
  for(long ki=k;ki<=n+1;ki++){
    ans += n*(n+1)/2 - (n-ki)*(n-ki+1)/2 - ki*(ki-1)/2 + 1;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int a[25];
int n, q;

bool solve(int i, int m) {
  if (m == 0) return true;
  if (i >= n) return false;
  bool res = solve(i+1, m) || solve(i+1, m-a[i]);
  return res;
}

int main() {
  cin >> n;
  rep(i,n) cin >> a[i];
  cin >> q;
  vector<int> ms(q);
  rep(i,q) cin >> ms[i];

  rep(i,q) {
    int m = ms[i];
    if (solve(0, m)) cout << "yes" << endl;
    else cout << "no" << endl;
  }
  return 0;
}



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

#define Max 2000000
#define Infty (1<<30)

int h, a[Max + 1];

void maxHeapify(int i){
  int l, r, largest, n;
  l = 2 * i;
  r = 2 * i + 1;

  if(l <= h && a[l] > a[i]) largest = l;
  else largest = i;

  if(r <= h && a[r] > a[largest]) largest = r;

  if(largest != i){
    n = a[i];
    a[i] = a[largest];
    a[largest] = n;

    maxHeapify(largest);
  }
}

int extract(){
  int maxv;
  if(h < 1) return -Infty;
  maxv = a[1];
  a[1] = a[h--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key){
  int n;

  if(key < a[i]) return;
  a[i] = key;
  while(i > 1 && a[i / 2] < a[i]){
    n = a[i];
    a[i] = a[i / 2];
    a[i / 2] = n;
    i = i / 2;
  }
}

void insert(int key){
  h++;
  a[h] = -Infty;
  increaseKey(h, key);
}


int main(){
  int key;
  char com[10];

  while(1){
    scanf("%s", com);
    if(com[0] == 'e' && com[1] == 'n') break;
    if(com[0] == 'i'){
      scanf("%d", &key);
      insert(key);
    }
    else{
      printf("%d\n", extract());
    }
  }

  return 0;
}


Measured memory_bytes: 5580
func readTwoInts(separator: String.Element = " ") -> (a: Int, b: Int) {
    let ints = readLine()!.split(separator: separator).map { Int($0)! }
    return (a: ints[0], b: ints[1])
}

func readInts(separator: String.Element = " ") -> [Int] {
    return readLine()!.split(separator: separator).map { Int($0)! }
}

func mainD() {
    let (N, K) = readTwoInts()
    let telepoter = readInts()

    var position = 1
    var positions = Set<Int>()
    var iCount = 1

    var isUnRoop = true
    for i in 1...K {
        let nextPosition = telepoter[position - 1]
        let previousCount = positions.count
        positions.insert(nextPosition)

        if previousCount == positions.count {
            iCount = i
            isUnRoop = false
            break
        }

        position = nextPosition
    }

    if isUnRoop {
        print(position)
        return
    }

    var roop = Set<Int>()
    var roopPositions: [Int] = []
    while true {
        let nextPosition = telepoter[position - 1]
        let previousCount = roop.count
        position = nextPosition
        roop.insert(nextPosition)
        roopPositions.append(nextPosition)

        if previousCount == roop.count {
            // 修正
            let cycle = roop.count

            let answerIndex = (K - (iCount - cycle)) % cycle
            print(roopPositions[answerIndex])
            break
        }
    }
}
mainD()

Measured memory_bytes: 19256
import numpy as np

n = input()
n = int(n)
a_list = input().split()
a_list = [int(a) for a in a_list]

a_dict = dict()
for a in a_list:
    if a in a_dict:
        a_dict[a] += 1
    else:
        a_dict[a] = 1


l = []
for k,v in a_dict.items():
    l.append([k,v])
ar = np.array(l)

menseki = 1
for i in range(2):
    ar = ar[ar[:,1]>=2]
    if len(ar) == 0:
        menseki = 0
        break
    else:
        saidai = ar[:,0].max()
        menseki *= saidai
        ar[ar[:,0]==saidai,1] -=2
print(menseki)

Measured memory_bytes: 33940
import java.util.*;
public class Main {
	public static void main(String[] args){
		int x, y;
		String s;
		Scanner sc = new Scanner(System.in);
		x = sc.nextInt();
		s = sc.next();
		y = sc.nextInt();
		//System.out.println(x + s + y);
		
		if(s.equals("+")){
			System.out.println(x+y);
		}else{
			System.out.println(x-y);
		}
	}
}


Measured memory_bytes: 9044
#include<iostream>
using namespace std;
const int N=2e5+10;
int q[N];
int main(){
    int n;
    cin>>n;
    long long res=0;
    cin>>q[0];
    for(int i=1;i<n;i++){
        cin>>q[i];
        if(q[i]<q[i-1]){
            res+=q[i-1]-q[i];
            q[i]=q[i-1];
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 4316