akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

int main(){
  while(1){
    int a,b;
    cin >> a >> b;
    if(a == 0 && b == 0){
      break;
    }
    if(a > b){
      cout << b << " " << a << endl;
    }else{
      cout << a << " " << b << endl;
    }
  }
  return 0;
}



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

void Main() {
    // input
    u_int64_t N, K;
    cin >> N >> K;


    // translate
    u_int64_t ans = 0;
    for (u_int64_t i = K; i <= N+1; i++) {
        // max - min + 1 で値の個数
        // O(n^2) は怖いので, 和の公式を使う
        // 初項 a から i 個足すとき
        // a + … + a + (i - 1) = i/2 * (a + a + i - 1)
        // 
        // max は大きい方から i 個選択
        // N, N - 1 , … , N - (i - 1)
        // 整数同士の除算を挟む場合, 順番に注意
        u_int64_t max = i * ((N - i + 1) + N) / 2;
        // min は小さい方から i 個選択
        u_int64_t min = i * (0 + 0 + i - 1) / 2;
        u_int64_t count = max - min + 1;
        count %= 1000000000 + 7;
        ans += count;
        ans %= 1000000000 + 7;
        // cout << i << "-selected - > " << count << endl;
    }

    ans %= 1000000000 + 7;

    // output
    cout << ans << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <climits>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

#define loop(i, times) for(int i = 0; i < times; i++)
#define seloop(i, start_index, end_index) for(int i = start_index; i < end_index; i++)
#define eqseloop(i, start_index, end_index) for(int i = start_index; i <= end_index; i++)

long Sum(vector<pair<int, int>>& collection, int min_index, int max_index)
{
	long sum = 0;
	for (int i = min_index; i < max_index; i++)
		sum += get<0>(collection[i]);
	return sum;
}

int main()
{
	int n; cin >> n;
	vector<int> odd_collection(n / 2, 0), even_collection(n / 2, 0);

	loop(i, n / 2)
	{
		cin >> odd_collection[i];
		cin >> even_collection[i];
	}

	vector<pair<int, int>> count_odd_collection;
	count_odd_collection.resize(100000);
	for (const auto& e : odd_collection)
	{
		get<0>(count_odd_collection[e % 100000])++;
		get<1>(count_odd_collection[e % 100000]) = e % 10000;
	}
	sort(count_odd_collection.begin(), count_odd_collection.end(), greater<pair<int, int>>());

	vector<pair<int, int>> count_even_collection;
	count_even_collection.resize(100000);
	for (const auto& e : even_collection)
	{
		get<0>(count_even_collection[e % 100000])++;
		get<1>(count_even_collection[e % 100000]) = e % 10000;
	}
	sort(count_even_collection.begin(), count_even_collection.end(), greater<pair<int, int>>());

	long min = 0;
	if (get<1>(count_odd_collection[0]) == get<1>(count_even_collection[0]))
	{
		if (get<0>(count_odd_collection[1]) < get<0>(count_even_collection[1]))
		{
			min += Sum(count_odd_collection, 1, count_odd_collection.size());
			min += get<0>(count_even_collection[0]);
			min += Sum(count_even_collection, 2, count_even_collection.size());
		}
		else
		{
			min += get<0>(count_odd_collection[0]);
			min += Sum(count_odd_collection, 2, count_odd_collection.size());
			min += Sum(count_even_collection, 1, count_even_collection.size());

		}
	}
	else
	{
		min += Sum(count_odd_collection, 1, count_odd_collection.size());
		min += Sum(count_even_collection, 1, count_even_collection.size());
	}

	if (min == 0 && odd_collection[0] == even_collection[0])
		min = n / 2;

	cout << min;

	return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
long long a,b;
using namespace std;
int main(){
	scanf("%lld%lld",&a,&b);
	int l=0,r=61;
	int ans=1;
	while(l<=r){
		int mid=(l+r)>>1;
		long long num=1ll<<mid;
		if(b/num>=a)l=mid+1,ans=mid;
		else r=mid-1;
		
		//cout<<l<<" "<<r<<" "<<mid<<endl;
	}
	cout<<ans+1<<endl;
	return 0;
}

Measured memory_bytes: 256
//=======================================
// abc145b
//
//  2019/11/16
//=======================================

#include <bits/stdc++.h>
using namespace std;

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

  int n; cin >> n;
  string s; cin >> s;
  if(n%2!=0)
  {
    cout << "No" << endl;
    return 0;
  }

  int n2=n/2;
  for(int i=0; i<n/2; ++i)
  {
    if(s[i] != s[n2+i])
    {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}

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

int n;
string s1,s2;
int s1_cnt = 0, s2_cnt = 0;

int main(){
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> s1 >> s2;
    if(s1 > s2){
      s1_cnt += 3;
    }else if(s1 < s2){
      s2_cnt += 3;
    }else{
      s1_cnt++;
      s2_cnt++;
    }

  }
  cout << s1_cnt << " " << s2_cnt << endl;
}

Measured memory_bytes: 3148
n,q=map(int,input().split())

par=[-1 for i in range(n)]

def root(a):
    if par[a]<0:
        return a
    else:
        return root(par[a])

def size(a):
    return -par[root(a)]

def connect(a,b):
    a=root(a)
    b=root(b)
    if a==b:
        return False
    if size(a)<size(b):
        a,b=b,a
    par[a]+=par[b]
    par[b]=a
    return True

for i in range(q):
    a,b,c=map(int,input().split())
    if a==0:
        connect(b,c)
    else:
        if root(b)==root(c):
            print(1)
        else:
            print(0)

Measured memory_bytes: 95976
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int thrdDigit = Integer.parseInt(String.valueOf(n).substring(0, 1));
        List<String> nList = Arrays.asList(String.valueOf(n).split(""));
        int repdigit = thrdDigit * 100 + thrdDigit * 10 + thrdDigit;

        if (n <= repdigit) {
            System.out.println(repdigit);
            return;
        }
        int nextRepDigit = (thrdDigit + 1) * 100 + (thrdDigit + 1) * 10 + thrdDigit + 1;
        System.out.println(nextRepDigit);

    }

}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define hell  1000000007
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb   push_back


int main()
{
	ios;
	ll n,k,cnt=0;
	cin>>n>>k;
	ll arr[n+10]={0};
	ll d,x;
	while(k--)
	{
		cin>>d;
		for(ll i=0;i<d;i++)
		{
			cin>>x;
			arr[x]++;
		}
	}
	for(ll i=1;i<=n;i++)
	{
		if(arr[i]==0)cnt++;
	}
	cout<<cnt;
}

Measured memory_bytes: 3656
# import fractions as math
import math

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

N, M = [int(i) for i in input().split()]
A = [int(i)//2 for i in input().split()]
lcm_A = 1
for a in A:
    lcm_A = lcm(lcm_A, a)
    if((lcm_A//a)%2==0):
        print(0)
        break
else:
    print(math.ceil((M//lcm_A)/2))



Measured memory_bytes: 63984
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
#define repr(i ,n) for(int i=n;i>(int)(n);--i)
#define rep1(i ,n) for(int i=1;i<=(int)(n);++i)
#define ALL(a) a.begin(), a.end()
#define RSORT(a) sort(ALL(a),greater<>())
#define SORT(a) sort(ALL(a))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define PRINT(x) cout << (x) << endl;
#define ENDL cout << endl;
using namespace std;
typedef long long int i64;
typedef unsigned long long u64;
template<class T> using V = vector<T>;
using VI = V<int>;
const int INF = 2e9;
const i64 MOD = 1e9 + 7;

template <class T> inline bool chmin(T& a, T b){if(a>b){a=b; return true;} return false;}
template <class T> inline bool chmax(T& a, T b){if(a<b){a=b; return true;} return false;}
struct Init_On{
    Init_On(){
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(16);
    }
};

signed main(){
    int c[3][3];
    rep(i , 3){
        rep(j ,3){
            cin >> c[j][i];
        }
    }
    int a[3] , b[3];
    b[0] = 0;
    rep(i , 3) a[i] = c[0][i] - b[0];
    rep(i , 3) b[i] = c[i][0] - a[0];
    bool ans = true;
    rep(i , 3){
        rep(j ,3){
            if( a[i] + b[j] != c[j][i]) ans = false;
        }
    } 
    cout << ( ans ? "Yes" : "No") << endl;
}

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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define endl "\n"
#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007
//グリッドグラフの範囲チェック
bool range_validation(int y,int x,int h,int w){
    return y>=0 && y<h && x>=0 && x < w;
}
//ビットカウント
int popcount(long bits){
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n,k;
  cin >> n >> k;
  int min_a = 100000000;
  int a[n];
  REP(i,n){
    cin >> a[i];
    chmin(min_a,a[i]);
  }

  vector<bool> win(k+1,false);

  REP(i,k+1){
    REP(j,n){
      if(i+a[j] <= k){
        win[i+a[j]] = win[i+a[j]] | !win[i];
      }
    }
  }
  string out;
  if(win[k]){
    out = "First";
  }else{
    out = "Second";
  }

  cout << out << endl;
  return 0;
}


Measured memory_bytes: 3600
N,M = map(int,input().split())
a = [ int(input()) for i in range(M)]
Sum = [0]*(N+1)
Sum[0] = 1
Judge = [True]*(N+1)
for i in range(M):
    Judge[a[i]] = False
for k in range(1,N+1):
    if Judge[k]:
        Sum[k] = Sum[k-1] + Sum[k-2]
    else:
        Sum[k] = 0
print(Sum[N]%1000000007)

Measured memory_bytes: 460788
#include <cstdio>
#include <string>
#include <bits/stdc++.h>

using namespace std;

int main(){
	char S[6];
	int len;
	scanf(" %s",S);
    len = strlen(S);
    if(len == 2)
    	for(int i = 0; i< len ;i++){
    		printf("%c",S[i]);
    		}
    		if(len == 3)
    			for(int i = len - 1;i>=0; i--)
    				printf("%c",S[i]);
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
	char C;
	cin >> C;
	char ans = C + 1;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	string S;
	cin >> S;
	int N;
	cin >> N;

	for (int i = 0; i < S.length(); i++) {
		if (i == 0) {
			cout << S[i];
		}else if(i % N == 0) {
			cout << S[i];
		}
	}
	cout << endl;

	
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define VI vector<int> 
#define SI set<int>
#define QI queue<int> 
#define PII pair<int, int>
#define MP make_pair
#define PB push_back
#define REP(i,a,b) for(int i = a; i < b; ++i)
#define F for(int i = 0; i < n; ++i)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define M 1000000007
using namespace std;

int main()
 {  
    FIO
    int x,n,temp; cin>>x>>n;
    if (n == 0)
    {
        cout<<x;
        return 0;
    }
    bool arr[105]={false}; 
    REP(i,0,n) {
        cin>>temp;
        arr[temp] = true;
    }
    int c=500;;
    REP(i,x,105) {
        if (!arr[i])
        {
            c = i;
            break;
        }
    }
    for (int i = x; i >= 0; --i)
    {
        if (!arr[i])
        {
            abs(c-x) < abs(x-i) ? : c = i;
            break;
        }
    }

    cout<<c;
    
    return 0;
}

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

long inf = 1000000007;


int main() {
	string s, t, u;
	int a, b;

	cin >> s >> t;
	cin >> a >> b;
	cin >> u;

	if (u == s) {
		a--;
	}
	else {
		b--;
	}

	cout << a <<' ' << b << endl;
}
	


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


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

    int first = 0;
    int second = 0;

    for(int j=0; j<N; j++){
        if(first < A[j]){
            first = A[j];
        }
        else if(second < A[j]){
            second = A[j];
        }
    }

    for(int k=0; k<N; k++){
        if(A[k] == first){
            cout << second << endl;
        }
        else{
            cout << first << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 2432
#include "bits/stdc++.h"
using namespace std;
#define test int t; cin >> t; while (t--)
#define fast ios::sync_with_stdio(NULL); cin.tie(NULL)
#define mod 1000000007
#define endl "\n"
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/GCD(m,n))
#define all(v) v.begin(),v.end()
#define ll long long
typedef vector<ll> vecll;
typedef vector<int> veci;
typedef vector<char> vecc;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
#define pb push_back
#define mp make_pair
#define time 1.0 * clock() / CLOCKS_PER_SEC


int main(){
    fast;
    // test{
    //     ll n,s=0;cin>>n;
    //     vecll a(n);
    //     set <ll> se;
    //     for(auto &x:a){cin>>x;s+=x;se.insert(x);}
    //     vecll pra,prb;
    //     pra.pb(a[0]),prb.pb(s);
    //     for(int i=1;i<n;i++){
    //         pra.pb(a[i]+pra[i-1]);
    //         prb.pb(prb[i-1]-a[i-1]);
    //     }
    //     ll c=0,z=1;
    //     for(auto x:se){
    //         if(x!=z){c=1;break;}
    //         z++;
    //     }
    //     if(c)cout<<0<<endl;
    //     else{
    //         vecll ans;
    //         for(int i=0;i<n-1;i++){
    //             if(s-pra[i] == ((n-i)*(n-i-1))/2 and pra[i]==((i+1)*(i+2))/2){ans.pb(i+1);}
    //         }   
    //         for(int i=n-1;i>=0;i--){
    //             if(s-prb[i] == ((n-i)*(n-i-1))/2 and prb[i]==((i+1)*(i+2))/2){ans.pb(i+1);}
    //         }
    //         cout<<ans.size()<<endl;
    //         for(auto x:ans)cout<<x<<" "<<n-x<<endl;
    //     }


    // }
    ll n;cin>>n;
    ll i=1,sum=1,c=0;
    while(sum<=n){
        if(i%3!=0 and i%5!=0 )c+=i;
        sum++;;
        i++;
    }
    cout<<c;
    return 0;
}


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

int main(void)
{
    char buffer[600];
    int n, input[100], counter=0, i;
    char *ptr;
    
    fgets(buffer, 5, stdin);
    sscanf(buffer, "%d", &n);
   
    fgets(buffer, 600, stdin);
    ptr = strtok(buffer, " ");
    while(ptr!=NULL)
    {
        sscanf(ptr, "%d", &input[counter]);
        ptr = strtok(NULL, " ");
        counter++;
    }
    for(i=counter-1; i>=0; i--)
    {
        printf("%d", input[i]);
        if(i!=0) putchar(' ');
        else putchar('\n');
    }
    return(0);
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int m;
    cin >> m;
    vector<vector<int>> matrix(n,vector<int>(m));
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            cin >> matrix[i][j];
        }
    }
    vector<int> b(m);
    for(int i = 0; i < m; i++)
        cin >> b[i];
    for(int i = 0; i < n; i++)
    {
        int c = 0;
        for(int j = 0; j < m; j++)
        {
            c += matrix[i][j]*b[j];
        }
        cout << c << '\n';
    }
	return 0;
}



Measured memory_bytes: 3176
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MOD 1000000007
typedef long long  ll;

using namespace std;

int ans, cnt;

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

	string S, T;
	cin >> S >> T;
	int ans = 0;
	rep(i, S.size()) {
		if (S[i] != T[i]) ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3880
import java.util.*;
public class Main {
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	long k = sc.nextLong();
    	long a[] = new long[n];
      for (int i=0; i<n;i++) {
        a[i]= sc.nextLong();
      }
   	long L = Long.MIN_VALUE;
    	long R = Long.MAX_VALUE;
    	Arrays.sort(a);

    	while (L + 1 < R) {
    		long MID = (L + R) / 2;
    		long cnt = 0;
    		for (int i = 0; i < n; i++) {
    			if (a[i] < 0) {
    				int l = i;
    				int r = n;
    				while (l + 1 < r) {
    					int mid = (l + r) / 2;
    					if (a[i] * a[mid] <= MID) {
    						r = mid;
    					} else {
    						l = mid;
    					}
    				}
   					cnt += n - r;
    			} else {
    				int l = i;
    				int r = n;
    				while (l + 1 < r) {
    					int mid = (l + r) / 2;
    					if (a[i] * a[mid] <= MID) {
    						l = mid;
    					} else {
    						r = mid;
    					}
    				}
   					cnt += l - i;
    			}
    		}
    		if (cnt < k) {
    			L = MID;
    		} else {
    			R = MID;
    		}
    	}
    	System.out.println(R);
	}
}





Measured memory_bytes: 83160
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef long double ld;

template <class T>
using lim = numeric_limits<T>;

const int maxT = 10e5;


int tv[31][maxT+2];
int sweep[maxT+2];
int main() {
	ios_base::sync_with_stdio(false) ;
	cin.tie(0);
	
	memset(tv, 0, sizeof tv);
	memset(sweep, 0, sizeof sweep);
	int N, C;
	cin >> N >> C;
	
	//difference array for individual channels
	//merge consecutive shows
	for (int i = 0; i < N; i++){
		int s, t, c;
		cin >> s >> t >> c;
		tv[c][s]++;
		tv[c][t]--;
	}
	
	//combine all channels and line sweep
	for (int i = 1; i <= C; i++){
		for (int j = 0; j < maxT+2; j++){
			if (tv[i][j] < 0) sweep[j+1]+=tv[i][j];
			else sweep[j]+=tv[i][j];
		}
	}
	
	int ans = 0;
	int prefix = 0;
	for (int i = 0; i < maxT+2; i++){
		prefix += sweep[i];
		ans = max(ans,prefix);
	}
	
	cout << ans << endl;
	
}


Measured memory_bytes: 125312
import java.util.Scanner;
/**
 * HelloWorld
 */
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int area=a*b;
        int length=2*a+2*b;
        System.out.println(area + " " + length);
        sc.close();
    }
}


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

int main(){
	double a,b;
	cin >> a >> b;
	double k=(a+b)/2;
	if(floor(k)==k){
		cout << (int)k << endl;
	}else{
		cout << "IMPOSSIBLE" << endl;
	}return 0;
}


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

typedef long long ll;
#define mod 1000003LL
const ll base = 9973LL;

char table[mod][15];

ll hash(char *str) {
  ll h = 0, p = 1;
  int len = strlen(str);
  int i, j;

  for(i = 0; i < len; i++) {
    h = (h + str[i])*p % mod;
    p *= base; p %= mod;
  }
  
  return h;
}

ll rehash(ll hash) {
  return (hash+1) % mod;
}

void insert(char *str) { 
  int h = hash(str);
  int i;
  
  while(strlen(table[h]) > 0) h = rehash(h);

  strcpy(table[h], str);
}

int find(char *str) {
  int h = hash(str);
  while(1) {    
    if(strcmp(table[h], str) == 0) return 1;
    else if(strlen(table[h]) == 0) return 0;
    h = rehash(h);
  }
  return 0;
}

int main() {
  int n;
  char cmd[256], str[256];
  int i;

  for(i = 0; i < mod; i++) table[i][0] = '\0';
    
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%s %s", cmd, str);
    if(strcmp(cmd, "insert") == 0) {      
      insert(str);
    } else if(strcmp(cmd, "find") == 0) {
      int flag = find(str);
      puts((flag ? "yes" : "no"));
    }
  }
  
  return 0;
}

Measured memory_bytes: 15256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int H,W;
int ans,limit;

bool check(int table[20][20]){

	for(int row = 1; row <= H-1; row++){
		for(int col = 1; col <= W-1; col++){
			if(table[row-1][col-1] == 0 || table[row-1][col] == 0 || table[row][col-1] == 0 || table[row][col] == 0)continue;

			if(table[row-1][col-1] != table[row-1][col] && table[row-1][col-1] != table[row][col-1] && table[row-1][col-1] != table[row][col] &&
				table[row-1][col] != table[row][col-1] && table[row-1][col] != table[row][col] && table[row][col-1] != table[row][col])return false;

		}
	}
	return true;
}

void recursive(int count,int row,int col,int table[20][20]){ //重複計上を防ぐため、行ごとに畳を並べる
	if(row == H){
		if(count == limit+1)ans++;
		return;
	}
	if(col == W){ //次の行へ
		recursive(count,row+1,0,table);
		return;
	}

	if(table[row][col] != 0){ //既に畳が敷いてある(縦)
		if(col <= W-2){
			recursive(count,row,col+1,table);
		}else{ //col == W-1
			recursive(count,row+1,0,table); //次の行へ
		}
		return;
	}

	if(col <= W-2 && table[row][col+1] == 0){ //右に敷ける場合
		int next_table[20][20];
		for(int a = 0; a < H; a++){
			for(int b = 0; b < W; b++)next_table[a][b] = table[a][b];
		}
		next_table[row][col] = count;
		next_table[row][col+1] = count;

		if(check(next_table)){
			recursive(count+1,row,col+2,next_table);
		}
	}
	if(row <= H-2 && table[row+1][col] == 0){ //縦に敷ける場合
		int next_table[20][20];
		for(int a = 0; a < H; a++){
			for(int b = 0; b < W; b++)next_table[a][b] = table[a][b];
		}
		next_table[row][col] = count;
		next_table[row+1][col] = count;

		if(check(next_table)){
			recursive(count+1,row,col+1,next_table);
		}

	}

}


int main(){

	int first_table[20][20];

	while(true){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0)break;

		if((H*W)%2 == 1){
			printf("0\n");
			continue;
		}

		ans = 0;
		limit = (H*W)/2; //limit枚の畳が敷けるはず

		for(int row = 0; row < H; row++){
			for(int col = 0; col < W; col++){
				first_table[row][col] = 0;
			}
		}
		recursive(1,0,0,first_table);

		printf("%d\n",ans);
	}

	return 0;
}



Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
 
int main() {
  int n,k,x,y;
  cin>>n>>k>>x>>y;
  if(n<=k){
    cout<<n*x;
  }
  else{
    cout<<k*x+(n-k)*y;
  }
 
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
def input():
	return sys.stdin.readline()[:-1]

INF = 10**5
n, m = map(int, input().split())
e = [INF for _ in range(n)]
e[n-1] = 0
adj = [[] for _ in range(n)]
farthest = [0 for _ in range(n)]
for _ in range(m):
	s, t = map(int, input().split())
	adj[s-1].append(t-1)

for x in range(n-2, -1, -1):
	if adj[x] == [n-1]:
		e[x] = 1		
	else:		
		su = 0
		for v in adj[x]:
			su += e[v]
			farthest[x] = max(farthest[x], e[v])
		e[x] = su/len(adj[x]) + 1

ans = e[0]

for i in range(n-1):
	f = e
	if len(adj[i]) == 1:
		f[i] = INF
	else:
		f[i] = ((e[i] - 1) * len(adj[i]) - farthest[i]) / (len(adj[i]) - 1) + 1

	for x in range(i-1, -1, -1):
		if adj[x] == [n-1]:
			f[x] = 1		
		else:		
			su = 0
			for v in adj[x]:
				if f[v] == INF:
					f[x] = INF
					break
				su += f[v]
			else:
				f[x] = su/len(adj[x]) + 1
	ans = min(ans, f[0])

print(ans)

Measured memory_bytes: 54364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846264338327950288
#define mt make_tuple

struct comparator {
 bool operator()(ll i, ll j) {
 return i < j;
 }
};

void love() {
	ll n, m;
	cin>>n>>m;

	int tmp;
	priority_queue<ll, std::vector<ll>, comparator> a;
	for(int i = 0; i<n; i++) cin>>tmp, a.push(tmp);

	ll xx;
	while(a.top() > 0 and m > 0) {
		xx = a.top() / 2;
		m--;
		a.pop();
		a.push(xx);
	}

	ll ans = 0;
	while (!a.empty()) {
        ans += a.top();
        a.pop();
    }
	cout<<ans<<endl;

}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	love();
	return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
string st;
int main(void)
{
	cin>>st;
	for(int i=0;i<st.size()-2;i++)
	  if(st[i]==st[i+1]&&st[i]==st[i+2])
	  {
	  	cout<<"Yes"<<endl;
	  	return 0;
	  }
	cout<<"No";
	puts("");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    vector<int> t(N + 1), x(N + 1), y(N + 1);
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;
    REP(i, N) { cin >> t[i + 1] >> x[i + 1] >> y[i + 1]; }
    REP(i, N) {
        int time = t[i + 1] - t[i];
        int dx = x[i + 1] - x[i];
        int dy = y[i + 1] - y[i];
        int cy = abs(dy) % 2;
        int cx = abs(dx) % 2;
        if(time % 2 == (cy + cx) % 2 and time >= abs(dx) + abs(dy)) {
            continue;
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
using ll = long long;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
// vector<vector<ll>> vec(100000,vector<ll>(3,0));
string s;
int main(){
  ll sum=0;
  cin >> s;
  ll len = s.length();
  char tmpc = '\n';
  ll tmp=0;
  rep(i,len){
    if(s[i] == tmpc){
      tmp++;
    }else{
      tmpc = s[i];
      sum += tmp / 3 * 2 + (tmp%3 > 0);
      if(tmp % 3 == 2){tmpc = '\n';}
      tmp=1;
    }
  }
  sum += tmp / 3 * 2 + (tmp%3 > 0);
  cout << sum;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

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

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class A_164_Sheep_and_Wolves
    {
        public static void Main(string[] args)
        {
            // https://atcoder.jp/contests/abc164/tasks/abc164_a
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var Array = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int s = Array[0];
            int w = Array[1];

            if (s > w == true)
            {
                Console.WriteLine("safe");
            }
            else
            {
                Console.WriteLine("unsafe");
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28280
import java.util.*;
import java.lang.*;

class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N  = sc.nextInt();
        int maxA[] = new int[N];
        int B[] = new int[N-1];
        int sumOfA = 0;

        for(int i = 0; i < N-1; i++){
            B[i] = sc.nextInt();
        }

        maxA[0] = B[0];
        for(int i = 1; i < N-1; i++){
            maxA[i] = Math.min(B[i-1],B[i]);
        }
        maxA[N-1] += B[N-2];

        for(int i = 0; i < N; i++){
            sumOfA += maxA[i];
        }


        System.out.println(sumOfA);

    }
}





Measured memory_bytes: 21972
h=int(input())
w=int(input())
n=int(input())
num=0
ans=0
flag=0
x=0
if h>=w:
    l=h
    s=w
else:
    l=w
    s=h
for i in range(l):
    if flag==1:
        num+=s-x
        ans=1
    if flag==0:
        for j in range(s):
            num+=l
            ans+=1
            if num>=n:
                x=num
                flag=1
                break
    if num>=n:
        break
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define mp make_pair
#define rep(i,n)  for (int i = 0; i < n; i++)
#define loop(i,a,n)  for (int i = a; i <= n; i++)
#define deb(x) cout << #x << " = " << x <<'\n'
typedef long long ll;
 
int main(){
    int r;
    cin >> r;
    cout << 2*3.14159265359*r << endl;
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    ll x;
    cin >> x;
    ll count = x/11;
    x -= 11*(x/11);
    if(x==0)COUT(2*count);
    else if(x<=6)COUT(2*count+1);
    else COUT(2*count+2);
    return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)

ans = [0]*n
for i in range(n-1):
    if s[i:i+2] == "RL":
        for j in range(i , -1, -1):
            if s[j] == "R":
                ans[i + (i-j) % 2] += 1
            else:
                break
        for j in range(i+1, n):
            if s[j] == "L":
                ans[i + (j-i) % 2] += 1
            else:
                break
            
print(" ".join(map(str, ans)))

Measured memory_bytes: 10484
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
AB = []
for i in A:
    for j in B:
        AB.append(i + j)


AB = sorted(AB, reverse=True)[:K]
C = sorted(C, reverse=True)
ans = []
for i in C:
    for j in AB:
        ans.append(i + j)

ans = sorted(ans, reverse=True)[:K]
for i in ans:
    print(i)






Measured memory_bytes: 140820
from math import sqrt

N = int(input())
max_val = int(sqrt(N))


def memo():
    n = 0
    mm = {}
    for x in range(1, max_val):
        for y in range(1, max_val):
            for z in range(1, max_val):
                n = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if mm.get(n) is None:
                    mm[n] = [(x, y, z)]
                else:
                    mm[n].append((x, y, z))
                if n > N:
                    break
    return mm


mm = memo()
for i in range(1, N+1):
    c = mm.get(i)
    if c is None:
        print(0)
    else:
        print(len(c))


Measured memory_bytes: 29836
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        String tmp = "";

        while(N>0) {
            --N;
            tmp += (char)('a' + (N%26));
            N /= 26;
        }
        StringBuffer sb = new StringBuffer(tmp);
        String res = sb.reverse().toString();
        System.out.println(res);
    }
}


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

#define pb push_back
#define mp make_pair

#define fi first
#define se second

typedef long long ll;

using namespace std;

int n, m;

bool u[100500];

vector<int> g[100500];

deque<int> q;

void bfs() {

u[1] = 1;
q.pb(1);

for(int i = 1; i <= n; i++) {
    int v = q.front();
    for(int j = 0; j < g[v].size(); j++) {
        int to = g[v][j];
        if(!u[to]) {
            q.push_front(to);
            u[to] = 1;
            break;
        }
    }
    v = q.back();
    for(int j = 0; j < g[v].size(); j++) {
        int to = g[v][j];
        if(!u[to]) {
            q.pb(to);
            u[to] = 1;
            break;
        }
    }
}
cout << q.size() << '\n';
while(!q.empty()) {
    cout << q.back() << ' ';
    q.pop_back();
}
}


int main(){

cin >> n >> m;
for(int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    g[a].pb(b);
    g[b].pb(a);
}
bfs();

return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    int N;
    cin >> N;
    vector<int> A(N);
    int odd = 0, even = 0;
    for (auto &&i : A) {
        cin >> i;
        if (i % 2 == 0)
            even++;
        else
            odd++;
    }
    if (odd % 2 == 0) {
        std::cout << "YES" << '\n';
    } else {
        std::cout << "NO" << '\n';
    }

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,f[3009],dp[3002][3002],z,x;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a;
	for(b=1; b<=a; b++){
		cin>>f[b];
	}
	for(b=1; b<=a; b++){
		for(c=1; c<=a-b+1; c++){
			if(b==1){
				if((a-b)%2==0) dp[c][c+b-1]=f[c]; else dp[c][c+b-1]=-f[c];
			}else{
				if((a-b)%2==0) z=f[c]; else z=-f[c];
				if((a-b)%2==0) x=f[c+b-1]; else x=-f[c+b-1];
				dp[c][c+b-1]=z+dp[c+1][c+b-1];
				if((a-b)%2==0) dp[c][c+b-1]=max(dp[c][c+b-1],x+dp[c][c+b-2]); else dp[c][c+b-1]=min(dp[c][c+b-1],x+dp[c][c+b-2]);
			}
		}
	}
	cout<<dp[1][a];
	return 0;
} 

Measured memory_bytes: 70016
N, M = map(int, input().split())
ls = []
for i in range(M):
    p, y = map(int, input().split())
    ls.append([i, p, y])
ls.append([float('inf'), float('inf'), 1])
ls.sort(key=lambda x: x[1])
rem = []
ans = []
cur_p = -1
for i in range(M+1):
    if ls[i][1] == float('inf'):
        rem.sort(key=lambda x: x[2])
        for j in range(len(rem)):
            rem_j = rem[j][:]
            rem_j.append('0'*(6-len(str(rem_j[1]))) + str(rem_j[1]) + '0'*(6-len(str(j+1))) + str(j+1))
            ans.append(rem_j)
        break
    if cur_p != ls[i][1]:
        if len(rem) != 0:
            rem.sort(key=lambda x: x[2])
            for j in range(len(rem)):
                rem_j = rem[j][:]
                rem_j.append('0'*(6-len(str(rem_j[1]))) + str(rem_j[1]) + '0'*(6-len(str(j+1))) + str(j+1))
                ans.append(rem_j)
            cur_p = ls[i][1]
            rem = []
            rem.append(ls[i])
        else:
            rem.append(ls[i])
            cur_p = ls[i][1]
    else:
        rem.append(ls[i])
ans.sort(key=lambda x: x[0])
for x in ans:
    print(x[-1])

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

int main() {
    int N;
    cin >> N;
    long long sum = 0;
    for(int i=1; i<=N; ++i) {
        sum += i;
        if(sum >= N) {
            for(int j=1; j<=i; ++j) {
                if(j == sum - N) continue;
                cout << j << endl;
            }
            return 0;
        }
    }
}

Measured memory_bytes: 384
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    int N;
    cin >> N;
    int a[N];
    REP(i,N) cin >> a[i];
    sort(a,a+N);
    int num[8]={0};
    int act=0;
    int res=0;
    int nokori=0;
    int tmp=0;
    while(res<8){
        while(tmp<N && a[tmp]<=(res+1)*400-1 && a[tmp]>=res*400){
            num[res]=num[res]+1;
            ++tmp;
    }
    ++res;    
    }
    int color=0;
    REP(i,8){
        act+=num[i];
        if(num[i]>0){
            ++color;
        }
    }
    nokori=N-act;
    int num_max=0,num_min=0;
    if(color>0){
    num_min=color;
    num_max=color+nokori;
    }
    else{
        if(nokori>=0){
        num_min=1;
        num_max=nokori+color;
    }
    }
    cout << num_min << " " << num_max;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

s, w = MAP()
if s <= w:
    print('unsafe')
else:
    print('safe')

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

/*
	Name:A - Can't Wait for Holiday
	Author: Xia Ruize
	Date:28/11/19 19:46
*/

/*
bool is_prime(int x)
{
	if(x<2)
		return false;
	for(int i=2;i*i<=x;i++)
	{
		if(x%i==0)
		{
			return false;
		}
	}
	return true;
}
*/

int main()
{
	string s;
	cin>>s;
	if(s=="SUN")
	{
		cout<<"7"<<endl;
		return 0;
	}
	if(s=="SAT")
	{
		cout<<"1"<<endl;
		return 0;
	}
	if(s=="FRI")
	{
		cout<<"2"<<endl;
		return 0;
	}
	if(s=="THU")
	{
		cout<<"3"<<endl;
		return 0;
	}
	if(s=="WED")
	{
		cout<<"4"<<endl;
		return 0;
	}
	if(s=="TUE")
	{
		cout<<"5"<<endl;
		return 0;
	}
	if(s=="MON")
	{
		cout<<"6"<<endl;
		return 0;
	}
	return 0;
}


Measured memory_bytes: 256
function Main(input){
  var N = parseInt(input.split(' ')[0]);
  var A = parseInt(input.split(' ')[1]);
  var B = parseInt(input.split(' ')[2]);

  var p1 = A * N;
  var p2 = B;

  var result = p1 <= p2 ? p1 : p2;
  console.log(result);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using ll = long long;
using ull = unsigned long long;

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

    ll a;
    int bint;
    int bdec;

    cin >> a;
    cin >> bint;
    cin.get();
    cin >> bdec;

    int bb = bint * 100 + bdec;
    cout << (a * bb / 100) << "\n";

    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define abs abs_

using namespace std;

const int N=500005;

template<class I>void gi(I&x){
	static char c;
	for(c=getchar();c<'0'||c>'9';c=getchar());
	for(x=0;c<='9'&&c>='0';c=getchar())x=x*10+(c&15);
}
inline int abs(int x){return x<0?-x:x;}

int n,D,d[N],v[N],g[N],Q,m;

int main(){
	gi(n),gi(D),v[0]=D;
	for(int i=1;i<=n;i++)
		gi(d[i]),v[i]=min(v[i-1],abs(v[i-1]-d[i]));
	g[n+1]=1;
	for(int i=n;i>=1;i--)
		if(abs(g[i+1]-d[i])<g[i+1])
			g[i]=g[i+1]+d[i];
		else
			g[i]=g[i+1];
	gi(Q);
	while(Q--){
		gi(m);
		if(g[m+1]<=v[m-1])
			puts("YES");
		else
			puts("NO");
	}
	return 0;
}

Measured memory_bytes: 7808
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0], 10);
  input = input[1].split(" ");
  var ans = 0;
  var flg = 0;
  for (var i = 0; i < n; i++) {
    flg = 0;
    if (i == 0) {
      ans++;
    } else {
      for(var j = 0; j < i; j++) {
        if (parseInt(input[i], 10) < parseInt(input[j], 10)){
          flg = 1;
          break;
        }
      }
      if(flg == 0) {
        ans++;
      }
    }
  }
  console.log('%d',ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iterator>
#include <list>
#include <algorithm>
#include <iostream>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <sstream>
#include <iomanip>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
using namespace std;

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

  int ans = 0;
  for (int i = 0; i < N; i++) {
    int h; cin >> h;

    if (h >= K)
      ++ans;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

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

    int a_max = 0;
    vector<int> b_v(N, 0);
    int b_sum = 0;
    for(int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        a_max = max(a_max, a);
        b_v[i] = b;
        b_sum += b;
    }
    sort(b_v.begin(), b_v.end(), greater<int>());
    int count = 0;
    for(int i = 0; i < N; i++) {
        if(b_v[i] < a_max) H -= a_max;
        else H -= b_v[i];
        count++;
        //cout << H << endl;
        if(H <= 0) {
            cout << count << endl;
            return 0;
        }
    }
    //cout << H << "," << a_max << "," << count << endl;
    count += (H + (a_max-1))/a_max;
    cout << count << endl;
    return 0;
}

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

int main()
{
    string s;
    cin >>s;
    if (s=="RRR"){cout <<3;}
    else if (s=="RRS" || s=="SRR"){cout <<2;}
    else if (s=="RSS" || s=="SRS" || s=="SSR" || s=="RSR"){cout <<1;}
    else {cout <<0;}
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vp = vector<P>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvb = vector<vb>;
const int INF = 1e9;
const int MOD = 1e9+7;

ll bpow(ll a, ll n)
{
    ll res = 1;
    while(n > 0)
    {
        if(n & 1) res *= a;
        a *= a;
        res %= MOD;
        a %= MOD;
        n >>= 1;
    }
    return res;
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    ll N; cin >> N;
    vl A(N); REP(i, N) cin >> A[i];
    vector<map<ll, ll>> t(N);
    REP(i, N)
    {
        int m = A[i];
        for(int j = 2; j * j <= A[i]; j++)
        {
            while(m % j == 0)
            {
                t[i][j]++;
                m /= j;
            }
        }
        t[i][m]++;
    }

    vl d(1000001);
    REP(i, N)
    {
        for(auto itr = t[i].begin(); itr != t[i].end(); itr++)
        {
            d[itr->first] = max(d[itr->first], itr->second);
        }
    }

    ll lcm = 1;
    for(int i = 2; i < 1000001; i++)
    {
        lcm *= bpow(i, d[i]);
        lcm %= MOD;
    }

    ll ans = 0;
    REP(i, N)
    {
        ans += lcm * bpow(A[i], MOD-2);
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12416