akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main() {
	ios::sync_with_stdio(0);cin.tie(0);
	string s;
	cin >> s;
	int mn = s.size();
	int n = s.size();
	for(int i=0; i<s.size()-1; i++) {
		if(s[i] != s[i+1]) {
			mn = min(mn, max(i+1, n-i-1));
		}
	}
	cout << mn;
}

Measured memory_bytes: 512
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <cmath>
#include <iomanip>

class CColon {
public:
    void solve(std::istream& in, std::ostream& out) {
        double a, b, h, m;
        in >> a >> b >> h >> m;
        double time_mm = h * 60 + m;
        double deg = time_mm * 5.5;
        deg = std::fmod(deg, 360.0);
        deg = std::min(360.0 - deg, deg);
        double squared_ans = a*a + b*b - 2*a*b*cos(deg*acos(-1)/180.0);
        out << std::fixed << std::setprecision(12) << std::sqrt(squared_ans) << std::endl;
    }
};


int main() {
    CColon solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 4252
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define ll long long

int main() {
	int n, m;
	//freopen("output.txt", "w", stdout);
	cin >> n >> m;
	pair<int, int> arr[m];
	map<int, int> mp;
	for (int i = 0; i < m; i++) {
		cin >> arr[i].first >> arr[i].second;

	}
	sort(arr, arr + m);
	for (int i = 0; i < m; i++) {
		if (arr[i].first == 1) {
			mp[arr[i].second] = 1;
		} else
			break;

	}
	for (int i = 0; i < m; i++) {
		if (arr[i].second == n) {
			if (mp[arr[i].first])
				mp[arr[i].first]++;
		}
	}
	for (auto i : mp) {
		if (i.second == 2)
			return cout << "POSSIBLE\n", 0;
	}
	cout << "IMPOSSIBLE\n";
}


Measured memory_bytes: 14372
#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>

using namespace std;

long long N, M, H, W;
long long A[200001];
long long B[200001] = {};
long long x[51][2] = {};
long long y[2][200] = {};
int ayasi[5] = {};
bool r[52] = {};
int check[102][102] = {};
long long result = 0;
string S;
vector <long long>vl;

int main() {
	cin >> N;
	M = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (i == 0) {
			B[i] = A[i];
		}
		else {
			B[i] = B[i - 1] + A[i];

		}
		if (B[i] == 0) {
			M++;
		}

		vl.push_back(B[i]);

	}
	sort(vl.begin(), vl.end());
	/*while (vl.size() >=1) {

		for (int i = 0; i < vl.size(); i++) {
			if (vl[i] != vl[0]) {
				M += i*(i - 1) / 2;
				vl.erase(vl.begin(), vl.begin() + i);
				break;
			}
			if (i == vl.size() - 1) {
				M += i*(i + 1) / 2;
				vl.clear();
				break;
			}

		}

	}*/
	H = 1;
	for (int i = 1; i < N; i++) {
		if (vl[i] != vl[i - 1]) {
			M += H*(H - 1) / 2;
			H = 0;
		}
		H++;
	}
	M += H*(H - 1) / 2;
	cout << M << endl;
	return 0;
}


Measured memory_bytes: 5104
#include<bits/stdc++.h>
const int N=1e5+5;
#define mst(a) memset(a,0,sizeof a) 
typedef long long ll;
using namespace std;
int main(){
	string s;
	while(cin>>s){
	int l=s.size();
	string a=s.substr(0,(l-1)/2),b=s.substr((l+1)/2);
	string  x=s,y=a,z=b;
	reverse(x.begin(),x.end());
	reverse(y.begin(),y.end());
	reverse(z.begin(),z.end());
	if(x==s&&y==a&&z==b)
		puts("Yes");
	else puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Ans[2] = {"No", "Yes"};
string ANS[2] = {"NO", "YES"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int Root(int x, vector<int> &root)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x], root);
}

void Merge(int v, int u, vector<int> &root, vector<int> &sz)
{
    v = Root(v, root), u = Root(u, root);
    if (v == u) return;
    if (sz[v] < sz[u])
    {
        sz[u] += sz[v];
        root[v] = u;
    }
    else
    {
        sz[v] += sz[u];
        root[u] = v;
    }
}

int ok(int x, int n)
{
    return 0 <= x && x < n;
}

void bfs(int v, vi &dist, vector<vi> &graph)
{
    fill(all(dist), -1);
    dist[v] = 0;
    vi q = {v};
    for (int i = 0; i < q.size(); i++)
    {
        for (auto u : graph[q[i]])
        {
            if (dist[u] == -1)
            {
                dist[u] = dist[q[i]] + 1;
                q.push_back(u);
            }
        }
    }
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a, b;
    cin >> a >> b;
    if (a <= 9 && b <= 9) cout << a * b;
    else cout << -1;

}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

void max_self(ll& a, ll b) {
    a = max(a, b);
}


int main() {
    int n;
    scanf("%d", &n);
    
    int base = 1;
    while(base <= n) {
        base *= 2;
    }
    // base is the smallest power of 2 that is not smaller than n
    //vector<ll> tree(2 * base);
    
    vector<ll> tr(2 * n);
    
    vector<int> h(n), a(n);
    for(int i = 0; i < n; ++i) {
        scanf("%d", &h[i]);
        h[i]--;
    }
    for(int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    vector<ll> dp(n + 1);
    // dp[i] - the max total beauty so far if the last taken flower has height i
    for(int flower = 0; flower < n; ++flower) {
        
        //max query in [0, h[flower])
        int l = 0 + n, r = h[flower] + n;
        ll best = 0;
        while(l < r) {
            if(l & 1) best = max(best, tr[l++]);
            if(r & 1) best = max(best, tr[--r]);
            l >>= 1;
            r >>= 1;
        }
        
        // max dp[i] for i in [0, h[flower]-1]
        /*int x = h[flower] + base;
        ll best = 0;
        while(x > 1) {
            if(x % 2 == 1) {
                max_self(best, tree[x-1]);
            }
            x /= 2;
        }*/
        
        dp[h[flower]] = best + a[flower];
        
        // update code
        tr[n + h[flower]] = dp[h[flower]];
        for(int i = n + h[flower]; i > 1; i>>=1) {
            tr[i>>1] = max(tr[i], tr[i^1]);
        }
        
        //for(int i = base + h[flower]; i >= 1; i /= 2) {
          //  max_self(tree[i], dp[h[flower]]);
        //}
        
        //~ for(int i = 0; i < h[flower]; ++i) {
            //~ max_self(dp[h[flower]], dp[i] + a[flower]);
        //~ }
    }
    ll answer = 0;
    for(int i = 0; i <= n; ++i) {
        max_self(answer, dp[i]);
    }
    printf("%lld\n", answer);
}

Measured memory_bytes: 9616
X = int(input())

can = set()
can.add(0)

for i in range(1, 2100):
    for k in range(100, 105+1):
        if (i-k) in can:
            can.add(i)
            break
if (X in can) or (X >= 2100) :
    print(1)
else:
    print(0)

Measured memory_bytes: 3060
#include <stdio.h>
#define min(a, b) a<b?a:b
#define max(a, b) a>b?a:b

long long int ans, n, x;

long long int f();

int main(void)
{
    scanf("%lld%lld", &n, &x);
    
    ans += n;

    ans += f(min(x, n-x), max(x, n-x));

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

}

long long int f(a, b)
long long int a, b;
{   long long int tmp;
    if (b % a) {
        tmp = (b/a)*a*2;
        return tmp + f(b%a, a);
    } else {
        return (b/a)*a*2-a;
    }
}



Measured memory_bytes: 128
import java.util.*;

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

        for (int i=0;i<N;i++) {
            if (i%2==0) nums[i] = D[i];
            else nums[i] = 24-D[i];
        }

        int min = 100;
        for (int i=0;i<N+1;i++) {
            for (int j=i+1;j<N+1;j++) {
                min = Math.min(min, Math.max(nums[i], nums[j])-Math.min(nums[i], nums[j]));
            }
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int a[5],k;
int main(){
	cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>k;
	for(int i=0;i<5;i++){
		for(int j=0;j<i;j++){
			if(abs(a[j]-a[i])>k){
				cout<<":(\n";
				return 0;
			}
		}
	}
	cout<<"Yay!\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  string s,b,n;
  while(cin>>s,s!="."){
    bool f=true;
    int i,j,k,o,m;
    b="";
    while(f){
      f=false;
      o=0;m=0;
      for(i=0;i<s.size();i++){
	if(s[i]=='[') {
	  o++;
	  m=max(m,o);
	}
	if(s[i]==']') o--;
      }
      for(i=0;i<s.size();i++){
	if(s[i]>='A'&&s[i]<='Z'){
	  k=1;j=(s[i]-'A');
	  while(i-k>=0){
	    if(s[i-k]=='+') {
	      j++;
	      s[i-k]=' ';
	      k++;
	      continue;
	    }
	    if(s[i-k]=='-') {
	      j--;
	      s[i-k]=' ';
	      k++;
	      continue;
	    }
	    break;
	  }
	  s[i]='A'+(104+j)%26;
	}
	if(s[i]=='?'){
	  k=1;
	  while(i-k>=0){
	    if(s[i-k]=='+'||s[i-k]=='-') {
	      s[i-k]=' ';
	      k++;
	      continue;
	    }
	    break;
	  }
	  s[i]='A';
	}
      }
      b="";
      for(i=0;i<s.size();i++) if(s[i]!=' ') b+=s[i];
      if(s.size()>b.size()) f=true;
      s=b;

      o=0;
      for(i=0;i<s.size();i++){
	if(s[i]=='['){
	  o++;
	  if(o==m){
	    k=1;
	    while(s[i+k]!=']') k++;
	    n=s.substr(i+1,k-1);
	    //cout << n << endl;
	    reverse(n.begin(),n.end());
	    s.replace(i+1,k-1,n);
	    s[i]=' ';s[i+k]=' ';
	    o--;
	  }
	}
	if(s[i]==']') o--;
	
      }
      b="";
      for(i=0;i<s.size();i++) if(s[i]!=' ') b+=s[i];
      if(s.size()>b.size()) f=true;
      s=b;
      
      //cout << s << endl;
    }
    cout << s << endl;
    s="";
  }
  return 0;
}

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

int main(){
  long long N;
  cin >> N;
  long long ans = N;
  for(long long i = 1; i*i <= N; ++i){
    if(N%i) continue;
    ans = min(ans,i+N/i-2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
string s="aaaaaaaaaa";
int n;
void dfs(int i,int j)
{
	if(i>=n)
	{
		for(int k=0;k<n;k++)putchar(s[k]);
		putchar(10);
		return;
	}
	s[i]='a'-1;
	for(int k=0;k<=j;k++)
	{
		++s[i];
		dfs(i+1,max(k,j-1)+1);
		
	}
}
int main()
{
	scanf("%d",&n);
	dfs(0,0);
	return 0;
}


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

int main() {
  int N,K;
  cin>>N>>K;
  vector<int> vec(N);
 
  for(int i=0; i<N; i++){
    
    int64_t a;
    cin>>a;
    vec.at(i) =a;
    
  }
  for(int i=0; i<N-K; i++){
    if(vec.at(i)<vec.at(i+K))
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
  
}



Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,t;
	cin>>n>>t;
	int ans=(t-1)*(n-1)+(n+1)*n/2;
	if(t>0)
	ans-=1;
	else if(n+t-1<=0)
	ans-=n;
	else
	ans+=(t-1);
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>

using namespace std;

int s[500000];

int cnt;

void merge(int s[], int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    int* L = new int[n1+1];
    int* R = new int[n2+1];
    for(int i = 0; i < n1; i++){
        L[i] = s[left+i];
    }
    for(int i = 0; i < n2; i++){
        R[i] = s[mid+i];
    }
    L[n1] = 1000000001;
    R[n2] = 1000000001;
    int i = 0;
    int j = 0;
    for(int k = left; k < right; k++){
        cnt++;
        if(L[i] <= R[j]){
            s[k] = L[i];
            i++;
        }
        else{
            s[k] = R[j];
            j++;
        }
    }
    delete[] L;
    delete[] R;
}

void mergeSort(int s[], int left, int right){
    if(left + 1 < right){
        int mid = (left + right) / 2;
        mergeSort(s, left, mid);
        mergeSort(s, mid, right);
        merge(s, left, mid, right);
    }
}

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

    mergeSort(s, 0, n);

    for(int i = 0; i < n; i++){
        if(i){
            printf(" %d", s[i]);
        }
        else{
            printf("%d", s[i]);
        }
    }
    printf("\n");
    printf("%d\n", cnt);
}


Measured memory_bytes: 6364
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int N,i;
  cin >> N;
  vector<int> A(N),B(N);
  for(i=0;i<N;i++)cin >> A.at(i);
  for(i=0;i<N;i++)B.at(A.at(A.at(i)-1)-1)=A.at(i);
  for(i=0;i<N;i++)cout << B.at(i) << " ";
  cout << endl;
}

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

int main() {
  int h,n;
  cin>>h;
  cin>>n;
  int A[100000];
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  
  int sum=0;
   for(int i=0;i<n;i++){
     sum+=A[i];
   }
 
  
  if(sum >= h){cout<<"Yes"<<endl;}
  else{ cout<<"No"<<endl;}
     
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

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


Measured memory_bytes: 3132
n_turn = int(input())
t_point = h_point = 0
for i in range(n_turn):
    t_card, h_card = input().split()
    if t_card > h_card:
        t_point += 3
    elif t_card == h_card:
        t_point += 1
        h_point += 1
    else:
        h_point += 3
print("{} {}".format(t_point, h_point))

Measured memory_bytes: 7632
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int x = scn.nextInt(), n = scn.nextInt();
		int[] arr = new int[102];
		for (int i = 0; i < n; i++) {
			arr[scn.nextInt()] = 1;
		}
		if (arr[x] == 0) {
			System.out.println(x);
		} else {
			int left = x - 1, right = x + 1;
			int ans = Integer.MAX_VALUE;
			while (left >= 0 && right < arr.length) {
				if (arr[left] == 0) {
					ans = left;
					break;
				} else {
					left--;
				}
				if (arr[right] == 0) {
					ans = right;
					break;
				} else {
					right++;
				}
			}
			while (left < 0 && right < arr.length) {
				if (arr[right] == 0) {
					ans = right;
					break;
				} else {
					right++;
				}
			}
			while (right >= arr.length && left >= 0) {
				if (arr[left] == 0) {
					ans = left;
					break;
				} else {
					left--;
				}
			}
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 35932
local n, x = io.read("*n", "*n")
n = n + 1
local len, pat = {1}, {1}
for i = 2, n do
  len[i] = len[i - 1] * 2 + 3
  pat[i] = pat[i - 1] * 2 + 1
end
local total_pat = 0
for i = n, 2, -1 do
  if x == 1 then
    x = 0
    break
  elseif x == len[i] then
    total_pat = total_pat + pat[i]
    x = 0
    break
  elseif x < (len[i] + 1) // 2 then
    x = x - 1
  elseif x == (len[i] + 1) // 2 then
    total_pat = total_pat + 1 + pat[i - 1]
    x = 0
    break
  else
    total_pat = total_pat + 1 + pat[i - 1]
    x = x - len[i - 1] - 2
  end
end
if x ~= 0 then total_pat = total_pat + 1 end
print(total_pat)


Measured memory_bytes: 760
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N = in_n()

    for a in range(1, 3500):
        for b in range(a, 3500):
            t1 = N * a * b
            t2 = 4 * a * b - N * (a + b)
            if t2 == 0:
                continue
            else:
                c = t1 / t2
                if c.is_integer() and 1 <= c:
                    print(a, b, int(c))
                    exit()


if __name__ == '__main__':
    main()


Measured memory_bytes: 65936
import java.util.Scanner;


public class Main{
	static int turn=0;
	static int dfs(int sum) {
		if(0<=sum && sum<=9) {
			return 1;
		}
		return dfs(sum/10)+1;
	}
    public  static void main(String[] args) {
    	try (Scanner sc = new Scanner(System.in)) {
    		while(sc.hasNext()) {
    			int a=sc.nextInt();
    			int b=sc.nextInt();
    			int sum=a+b;
    			System.out.println(dfs(sum));
    		}
    	}
    }
}


Measured memory_bytes: 26456
#include <iostream>
#include <string>
using namespace std;
string s;
int main(){
    cin>>s;
    int ans=0;
    for (int x=0;x<(s.size()>>1);x++){
        if (s[x]!=s[s.size()-x-1]) ans++;
    }
    
    printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372037ll;

void solve()
  {
    int s,w;
    cin>>s>>w;
    if(w>=s)
       cout<<"unsafe";
    else
       cout<<"safe";
  } 
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
   /*int t;
   cin>>t;
   while(t--)*/
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

typedef long long lli;
typedef pair<lli, lli> P;

const lli N = 2005;
const lli M = 100005;
const lli INF = 1e12;

lli n, m, l, K[N], S[M+1], dp[N][N], cum[M+1];
P vec[N];

lli calc(lli a, lli b){
	//if(vec[a].first > vec[b].first) swap(a, b);
	//return (cum[vec[b].second] - cum[vec[a].second-1]) / l;
	return (cum[K[a]] - cum[K[b]-1]) / l;
}

int main(){
	cin >> n >> m >> l;
	for(lli i=0;i<n;i++) cin >> K[i];
	for(lli i=1;i<=m;i++) cin >> S[i];
	cum[0] = 0;
	for(lli i=1;i<=m;i++) cum[i] = cum[i-1] + S[i];
	for(lli i=0;i<n;i++) vec[i] = make_pair(S[K[i]], K[i]);
	//sort(vec, vec+n);
	//reverse(vec, vec+n);
	sort(K, K+n);
	reverse(K, K+n);
	fill(dp[0], dp[N], INF);
	dp[0][0] = 0;
	for(lli i=0;i<n;i++){
		for(lli j=0;j<=i;j++){
			if(dp[i][j] >= INF) continue;
			//dp[i+1][j] = min(dp[j][i+1], dp[i][j] + calc(i, i+1));
			//dp[i+1][i] = min(dp[i+1][i], dp[i][j] + calc(j, i+1));
			dp[i+1][j] = min(dp[i+1][j], dp[i][j] + (cum[K[i]] - cum[K[i+1]-1]) / l);
			dp[i+1][i] = min(dp[i+1][i], dp[i][j] + (cum[K[j]] - cum[K[i+1]-1]) / l);
		}
	}
	lli ans = INF;
	for(lli i=0;i<n;i++){
		ans = min(ans, dp[n-1][i] + (cum[K[i]] - cum[K[n-1]-1]) / l);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 34192
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  ll N;
  cin >> N;

  vector<int> ret;
  if(N == 0){
    ret.push_back(0);
  } else {
    int k = 1;
    ll p = 1;
    ll base_p = 1;
    ll base_m = 1;
    ll flg = 1;

    ll keta = 0;
    ll rank = 0;
    while(true){
      if(flg == 1){
        if(base_p <= N && N < base_p + p){
          keta = k;
          rank = N - base_p;
          break;
        }
        base_p += p;
      }else{
        if(-(base_m + p) < N && N <= -base_m){
          keta = k;
          rank = (-base_m) - N;
          break;
        }
        base_m += p;
      }
      p *= 2;
      k++;
      flg = 1 - flg;
    }

    vector<int> tmp;
    int M = rank;
    while(M>0){
      tmp.push_back(M&1);
      M >>= 1;
    }
    while(tmp.size() < keta) tmp.push_back(0);
    rep(i,tmp.size()){
      if(N < 0){
        if(i%2==0){
          if(tmp[i]==1) tmp[i] = 0;
          else tmp[i] = 1;
        }
      }else{
        if(i%2==1){
          if(tmp[i]==1) tmp[i] = 0;
          else tmp[i] = 1;
        }
      }
      if(i == tmp.size()-1) tmp[i] = 1;
    }
    reverse(ALLOF(tmp));
    
    ret = tmp;
  }

  rep(i,ret.size()){
    cout << ret[i];
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#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 FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    map<string, int> mp;
    rep(i,n) {
        string s; cin>>s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << '\n';
    cout << "WA x " << mp["WA"] << '\n';
    cout << "TLE x " << mp["TLE"] << '\n';
    cout << "RE x " << mp["RE"] << '\n';
    return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n,m;
  cin >> n >> m;
  vector<int64> x(n), y(n), z(n);
  REP(i,n)cin >> x[i] >> y[i] >> z[i];
  vector<int64> xyz(n);
  int64 ans = 0;
  for(int32 mask = 0; mask < (1 << 3); mask++){
    REP(i,n)
      xyz[i] = ((mask & 1)?1:-1) * x[i] + (((mask >> 1) & 1)?1:-1) * y[i] + (((mask >> 2) & 1)?1:-1) * z[i];
    sort(ALL(xyz),greater<int64>());
    int64 sum = 0;
    REP(i,m){
      sum += xyz[i];
    }
    ans = max(ans, sum);
  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    vector<string> s(n);
    VI t(n);
    FOR(i, 0, n)cin >> s[i] >> t[i];
    string x; cin >> x;

    int ans = 0;
    bool k = true;
    FOR(i, 0, n) {
        if (s[i] == x) {
            k = false;
            continue;
        }
        if (k)continue;
        ans += t[i];
    }
    cout << ans << "\n";
}


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

typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vector<vector<int>> can(n, vector<int>(n));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> can[i][j];
        }
    }    
    // i -> j
    vector<int> dp(1 << n);
    dp[0] = 1;
    for (int mask = 0; mask < (1 << n) - 1; ++mask) {
        // representing subsets as a mask
        int a = __builtin_popcount(mask);
        for (int b = 0; b < n; ++b) {
            if (can[a][b] && !(mask & (1 << b))) {
                // mask means women that have not been matched yet
                int m2 = mask ^ (1 << b);
                dp[m2] += dp[mask];
                dp[m2] %= MOD;
            }
        }
    }
    cout << dp[(1 << n) - 1] << '\n'; // all women have been matched
    return 0;
}

Measured memory_bytes: 8448
#include <stdio.h>

int main(){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    while(1){
	c=c-b;
	if(c<=0)break;	
	a=a-d;
	if(a<=0)break;
	}
	if(a<c)
    puts("No");
    else
    puts("Yes");
    return 0;
}    

Measured memory_bytes: 1652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
//modは桁ごとに計算できる
const int n = 13;
ll dp[n];//dp[k]->13で割った余りがｋのパターン
ll nextDP[n];
int main(){
    string s;cin >> s;
    dp[0] = 1;
    for(int i = 0; i < s.length(); i++){
        char c = s[i];
        if(c=='?'){
            for(int k = 0; k < 10; k++){
                for(int j = 0; j < n ;j++){
                    nextDP[((j*10)+k)%n] += dp[j];
                    nextDP[((j*10)+k)%n] %= MOD;
                }
            }
        }else{
            int k = s[i]-'0';
            for(int j = 0; j < n ;j++){
                nextDP[((j*10)+k)%n] += dp[j];
                nextDP[((j*10)+k)%n] %= MOD;
            }
            
        }
        for(int j = 0; j < 13; j++){
            dp[j] = nextDP[j];
            nextDP[j] = 0;
        }
    }

    cout << dp[5] << endl;
    return 0;

}

Measured memory_bytes: 512
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(a) (a).begin(),(a).end()
#define SIZE(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())

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

typedef pair<int,int> P;
struct edge {
  int to, cost;
};

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

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " ";
  }
  return s;
}


signed main()
{
  int N; cin >> N;
  vector<int> a(N);
  int amax = -INF, amin = INF;
  int max_i = -1, min_i = -1;
  rep(i, 0, N) {
    cin >> a[i];
    if (amax < a[i]) {
      amax = a[i];
      max_i = i;
    }
    if (amin > a[i]) {
      amin = a[i];
      min_i = i;
    }
  }

  cout << 2*N - 1 << endl;

  if (abs(amax) < abs(amin)) {
    rep(i, 0, N) {
      cout << min_i +1 << " " << i +1 << endl;
    }
    rrep(i, 1, N) {
      cout << i +1 << " " << i-1 +1 << endl;
    }
  } else {
    rep(i, 0, N) {
      cout << max_i +1 << " " << i +1 << endl;
    }
    rep(i, 0, N-1) {
      cout << i +1 << " " << i+1 +1 << endl;
    }
  }


  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	ll m=n;
	bool ok=true;
	int a, b=0, c=0;
	while(m>0){
		if(m/10==0){
			a=m;
		}
		else if(m%10!=9){
			ok=false;
		}
		b+=m%10;
		++c;
		m/=10;
	}
	cout<<(ok ? b : a-1+(c-1)*9)<<'\n';
	return 0;
}


Measured memory_bytes: 256
/*
    Code written by Talant I.D.
*/
   
#include <bits/stdc++.h>
   
using namespace std;
   
typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;
   
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod (int)1e9+7
#define eps (double)1e-9
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);
#define curMod 998244353

map <int, vector<int> > graph;
map <int, int> rem, counter, used;

void dfs(int v){
	counter[v] += rem[v];
	used[v] = 1;
	int i, to;
	
	for(i = 0; i < graph[v].size(); i++){
		to = graph[v][i];
		
		if(!used[to]){
			rem[to] += rem[v];
			dfs(to);
		}
	}
}

int main(){
		//do_not_disturb
		int n, m, x, y, i;
		cin >> n >> m;
		
		for(i = 0; i < n-1; i++){
			cin >> x >> y;
			graph[x].pb(y);
			graph[y].pb(x);
		}
		for(i = 0; i < m; i++){
			cin >> x >> y;
			rem[x] += y;
		}
		
		dfs(1);
		
		for(i = 1; i <= n; i++){
			cout << counter[i] << ' ';
		}
  cout << endl;
		
    return 0;
} // What is to be written here?


Measured memory_bytes: 71168
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
    int64_t n, k;
    cin >> n >> k;

    vector<int64_t> a(n);
    for (auto&& aa : a) {
        cin >> aa;
    }

    if (k == 1) {
        cout << 0 << endl;
        return 0;
    }

    int64_t offset = 0;
    unordered_map<int64_t, int64_t> m;
    int64_t ans = 0;
    vector<int64_t> b(n);
    for (auto i : irange(0L, n)) {
        b[i] = (1 - offset + k) % k;
        ++m[b[i]];

        ans += m[(a[i] - offset + k) % k];

        offset = (offset + 1 + a[i] * (k - 1)) % k;
        if (i - (k - 2) >= 0) {
            --m[b[i - (k - 2)]];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 11592
#include <stdio.h>
#include <math.h>

int main(void){
  double x,h,S;
  while(1){
    scanf("%lf",&x);
    scanf("%lf",&h);

    if(x==0 && h==0)break;
    S=0;
    S+=x*x;
    S+=2*x*sqrt(h*h+(x*x/4));
    printf("%lf\n",S);
  }
  return 0;
}



Measured memory_bytes: 2052
N,K=map(int,input().split())
dic={}
for i in range(N):
  a,b=map(int,input().split())
  if a in dic:
    dic[a]+=b
  else:
    dic[a]=b
    
dic=sorted(dic.items(),key=lambda x:x[0])
for d in range(len(dic)):
  amount=dic[d][1]
  if amount>=K:
    print(dic[d][0])
    exit(0)
  else:
    K-=amount
  

Measured memory_bytes: 15072
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
using namespace std;
using ll = long long;

const int MOD = 1000000007;

struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  vector<int> b(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  vector<vector<mint>> dp1(n + 1, vector<mint>(m + 1));
  vector<vector<mint>> dp2(n + 1, vector<mint>(m + 1));  
  dp1[0][0] = 1;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      dp2[i][j] += dp1[i][j];
      if (j < m) {
        dp1[i][j + 1] += dp1[i][j];
      }
      if (i < n) {
        dp2[i + 1][j] += dp2[i][j];
      }
      if (i < n && j < m && a[i] == b[j]) {
        dp1[i + 1][j + 1] += dp2[i][j];
      }
    }
  }
  cout << dp2[n][m] << '\n';
}


Measured memory_bytes: 31744
import sys
input = sys.stdin.readline
import math

n = int(input())
a_list = []
b_list = []
for _ in range(n):
    tmp_a, tmp_b = map(int, input().split())
    a_list.append(tmp_a)
    b_list.append(tmp_b)

z = zip(b_list, a_list)
z = sorted(z)
b_list, a_list = zip(*z)

count = 0
flag = True
for a, b in zip(a_list, b_list):
    count += a

    if b < count:
        flag = False
        break

print('Yes') if flag else print('No')

Measured memory_bytes: 49184
import collections
from collections import deque
N=int(input())
D=list(map(int,input().split()))
c=collections.Counter(D)
count0=1
count12=0
zeroflag=0
l=[]
if c[12]>0:
    count12=c[12]
if c[0]>0:
    count0=count0+c[0]
#print(l,count0,count12)
#print(n)
allmax=0
q=deque()
l=[]
if (count0==1)and(zeroflag==0):
    q.append([0])
else:
    zeroflag=1

if (count12==1)and(zeroflag==0):
    length=len(q)
    j=0
    while j<length:
        buf1=[]
        l=q.popleft()
        buf1.extend(l)
        l.append(12)
        q.append(l)
        j=j+1
elif count12>1:
    zeroflag=1

if zeroflag==0:
    for i in range(1,12):
        length=len(q)
        j=0
        if c[i]==0: continue
        if c[i]==1:
            while j<length:
                buf1=[]
                buf2=[]
                l=q.popleft()
                buf1.extend(l)
                buf1.append(i)
                buf2.extend(l)
                buf2.append(24-i)
                q.append(buf1)
                q.append(buf2)
                j=j+1
        if c[i]==2:
            while j<length:
                buf3=[]
                l=q.popleft()
                buf3.extend(l)
                buf3.extend([i,24-i])
                q.append(buf3)
                j=j+1
        if c[i]>2:
            zeroflag=1
            break
        #print(q)
#print(q)

if zeroflag==0:
    for l in q:
        l.sort()
        mi=100
        n=len(l)
        for j in range(n-1):
            mi=min(mi,l[j+1]-l[j],24-l[j+1]+l[j])
        mi=min(mi,l[n-1],24-l[n-1])
        #print(mi)
        allmax=max(allmax,mi)
else:
    allmax=0
print(allmax)

Measured memory_bytes: 70824
Imports System

Module practiceA
    Sub Main()
        Call test2()


    End Sub

    Sub test1()
        Dim S, W As Integer
        Dim arr(2) As String
        arr = Split(Console.ReadLine())
        S = arr(0)
        W = arr(1)

        If S > W Then
            Console.Write("safe")

        Else
            Console.Write("unsafe")
        End If

    End Sub

    Sub test2()
        Dim A, B, C, D, HP_A, HP_B As Integer
        Dim arr(4) As String
        arr = Split(Console.ReadLine())
        A = arr(0)
        B = arr(1)
        C = arr(2)
        D = arr(3)

        HP_B = C - B


        If HP_B <= 0 Then
            Console.Write("Yes")
            Exit Sub
        End If

        HP_A = A - D

        If HP_A <= 0 Then
            Console.Write("No")
            Exit Sub
        End If

        While True

            HP_B = HP_B - B

            If HP_B <= 0 Then
                Console.Write("Yes")
                Exit While
            End If

            HP_A = HP_A - D

            If HP_A <= 0 Then
                Console.Write("No")
                Exit While
            End If

        End While

    End Sub

End Module


Measured memory_bytes: 28336
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int S;
  std::cin >> S;
  int a = S/100;
  int b = S%100;
  string ans;
  if(a>=1&&b>=1&&a<=12&&b<=12) ans = "AMBIGUOUS";
  else if(a>=1&&a<=12) ans = "MMYY";
  else if(b>=1&&b<=12) ans = "YYMM";
  else ans = "NA";
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 29;
constexpr lint   INFL = 1LL << 61;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n;
  cin >> n;
  vector<string> s(n);
  rep (i, n) cin >> s[i];
  vector<vector<int>> alp(n, vector<int>(26));
  rep (i, n) {
    allrep (c, s[i]) alp[i][c - 'a']++;
  }
  map<vector<int>, int> cnt;
  rep (i, n) cnt[alp[i]]++;
  lint ans = 0;
  allrep (p, cnt) {
    if (p.second > 1) ans += (lint)p.second * (p.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 37760
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std; 
typedef long long LL;
const int MAXN=1E5+10;
int q[MAXN],tong[MAXN],a[MAXN];
long long sumans;
string name(LL N) {
	N-=1;
	LL pw=26,i=1;
	while(N>=pw) {
		N-=pw;
		pw*=26;
		++i;
	}
//	printf("%lld %lld %lld\n",N,pw,i);
	string names="";
	while(N>0) {
		LL r=N%26;
		names=char(r+'a')+names;
		N/=26;
	}
	int x=names.length();
	if(x!=i) {
		names=string(i-x,'a')+names;
	}
	return names;
}
int main() {
	LL N;
	scanf("%lld",&N);
	printf("%s",name(N).c_str());
	return 0;
} 

Measured memory_bytes: 3292
n = int(input())
c = [int(input()) for _ in range(n)]
m = 10**9+7

dp = [-1] * n
dp[0] = 1
last_dic = {}
for i in range(n):
    if c[i] in last_dic.keys() and i - last_dic[c[i]] >= 2:
        dp[i] = (dp[i-1] + dp[last_dic[c[i]]]) % m
    elif i:
        dp[i] = dp[i-1]
    last_dic[c[i]] = i
print(dp[-1])

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

int main(){
  int n, count, p;
  int a[100001] = {0};
  int x[100001] = {0};
  x[0] = 1;
  
  cin >> n;
  for ( int i = 0; i < n; i++){
    cin >> a[i];
  }
  p = 1;
  count = 0;
  while(1){
    p = a[p- 1];
    count++;
    if(p == 2){
      cout << count << endl;
      return 0;
    }else if(x[p-1] == 0){
      x[p-1]++;
    }else{
      cout << -1 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;

int N,A,B;
ll v[55];
double ans;

ll C[51][51]; // C[n][k] -> nCk
ll cnt;
void comb_table(int N){
    for(int i=0;i<=N;++i){
        for(int j=0;j<=i;++j){
            if(j==0 or j==i){
                C[i][j]=1LL;
            }else{
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}


int main() {
    cin>>N>>A>>B;
    REP(i,0,N){
        cin>>v[i];
    }

    comb_table(N);
    sort(v,v+N);
    reverse(v,v+N);

    REP(i,0,A){
        ans += v[i];
    }
    ans /= A;

    int a_th_val_num=0,a_th_val_pos=0;
    for(int i=0;i<N;++i){
        if(v[i]==v[A-1]){
            a_th_val_num++;
            if(i<A){
                a_th_val_pos++;
            }
        }
    }
    if(a_th_val_pos==A){
        for(a_th_val_pos=A;a_th_val_pos<=B;++a_th_val_pos){
            cnt += C[a_th_val_num][a_th_val_pos];
        }
    }
    else{
        cnt += C[a_th_val_num][a_th_val_pos];
    }

    printf("%.7lf\n", ans);
    p(cnt);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  ll n, m;
  cin >> n >> m;
  ll ans;
  if(n >= 2 && m >= 2){
    ans = (n - 2) * (m - 2);
  } else if(n == 1 && m == 1){
    ans = 1;
  }else if(n >= 2){
    ans = (n - 2);
  }else{
    ans = (m - 2);
  }
  cout << ans << endl;
  return 0;
}

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

lli seg[800010];

void update(lli in,lli l,lli r,lli ind,lli val){
    if(l==r && l==ind){
        seg[in]=val;
        return;
    }
    lli mid=(l+r)/2;
    if(ind<=mid)
    update(2*in,l,mid,ind,val);
    else
    update(2*in+1,mid+1,r,ind,val);
    
    seg[in]=max(seg[2*in] , seg[2*in+1]);
}

lli func(lli in,lli lt,lli rt,lli l,lli r){
    if(lt>rt) return 0;
    if(l==lt && r==rt) return seg[in];
    lli mid=(l+r)/2;
    if(rt<=mid) return func(2*in , lt,rt,l,mid);
    else if(lt>mid) return func(2*in+1,lt,rt,mid+1,r);
    else{
        return max(func(2*in,lt,mid,l,mid) , func(2*in+1,mid+1,rt,mid+1,r));
    }
}

int main(){
    lli n;
    cin>>n;
    lli a[n];
    lli dp[n+1]={0};
    lli i,j,l;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    lli b[n];
    for(i=0;i<n;i++){
        cin>>b[i];
    }
    //lli mx[n+1]={0};
    for(i=0;i<n;i++){
        l=func(1,1,a[i]-1,1,n);
        //cout<<"ok"<<endl;
        //cout<<i<<" "<<l<<" "<<b[i]<<endl;
        dp[a[i]] = max(dp[a[i]] ,b[i] + l);
        update(1,1,n,a[i],dp[a[i]]);
        //for(j=1;j<=2*n;j++) cout<<seg[j]<<" ";
        //cout<<endl;
        //cout<<"  ok"<<endl;
    }
    
    lli ans=0;
    for(i=n;i>0;i--){
        ans=max(ans,dp[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11008
#include <stdio.h>
#include <math.h>

int main(void) {
	int r,n;
	while(scanf("%d%d",&r,&n)==2 && (r!=0 || n!=0)) {
		int i,j;
		double answer = 1000.0;
		/* -20 [0] -19 [1] -18 ... -1 [19] 0 [20] 1 [21] 2 ... 19 [39] 20 */
		int tatemono[40];
		for(i=0;i<40;i++)tatemono[i]=0;
		for(i=0;i<n;i++) {
			int x,y,h;
			if(scanf("%d%d%d",&x,&y,&h)!=3)return 1;
			for(j=x+20;j<y+20;j++) {
				if(h>tatemono[j])tatemono[j]=h;
			}
		}
		for (i=-r+1;i<r;i++) {
			double offset=r-sqrt(r*r-i*i);
			double candidate=offset+tatemono[i<0?i+19:i+20];
			if(candidate<answer)answer=candidate;
		}
		/* i==0, left */
		if(tatemono[19]<answer)answer=tatemono[19];
		printf("%.15f\n",answer);
	}
	return 0;
}

Measured memory_bytes: 640