akhauriyash/Code-Regression huggingface dataset:
val fact = Array(200010) { 1L }
val invfact = Array(200010) { 1L }

val MOD = 1000000007L;

fun comb(n: Long, m: Long): Long {
    if ( n < m )
        return 0L

    return fact[n.toInt()] * invfact[(n - m).toInt()] % MOD * invfact[m.toInt()] % MOD
}

fun powMod(n: Long, l: Long): Long {
    var k = l
    var a = 1L;
    var m = n
    while (k > 0) {
        if (k % 2 == 1L) {
            a = (a * m) % MOD;
        }
        m = (m * m) % MOD;
        k /= 2L
    }

    return a
}

fun invMod(n: Long): Long {
    return powMod(n, MOD - 2)
}

fun f(n: Long, m: Long): Long {
    var res = 0L
    val p = invMod(comb(n * m, 2))

    for (i in 1L until n) {
        res += (n - i) * i % MOD * m % MOD * m % MOD * p % MOD
        res %= MOD
    }

    return res
}

fun main(args: Array<String>) {
    val (N, M, K) = readLine()!!.split(" ").map { s -> s.toLong() }

    for(i in 1 until 200010) {
        fact[i] = fact[i - 1] * i % MOD
        invfact[i] = invfact[i - 1] * invMod(i.toLong()) % MOD
    }

    val a = K * (K - 1) % MOD * invMod(2) % MOD
    val b = f(N, M) * a % MOD
    val c = f(M, N) * a % MOD

    val res = (b + c) % MOD * comb(N * M, K) % MOD

    println(res)
}

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

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

n,k = LI()
x = LI()
ans = inf
for i in range(k,n+1):
    l,r = x[i-k],x[i-1]
    if l <= 0 and r <= 0:
        ans = min(ans, abs(l))
    elif l <= 0 and r > 0:
        ans = min(ans, 2*r+abs(l))
        ans = min(ans, 2*abs(l)+r)
    elif l > 0 and r > 0:
        ans = min(ans,r)
print(ans)

Measured memory_bytes: 58736
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}

int vis[30009];

 main()

{
    fast
    int n;
    cin>>n;
    int sum=0;
    vector<int>vec;
    int cnt=0;
    for(int i=1;i<=30000;i++)
    {
        if(i%2==0 || i%3==0)
        {
            if(cnt==(n-1))
            {
                break;
            }
            else
            {
                vec.pb(i);
                sum+=i;
                vis[i]=1;
                cnt++;
            }
        }
    }
    for(int i=1;i<=30000;i++)
    {
        if(vis[i])continue;
        int val=sum+i;
        if(__gcd(sum,i)>1 && val%6==0)
        {
            vec.pb(i);
            break;
        }
    }
    for(auto x:vec)
    {
        cout<<x<<" ";
    }
    cout<<endl;
    return 0;

}













Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

void insertion_sort(pair<int, string> p[], int n) {
    for (int i = 1; i < n; i++) {
        pair<int, string> k = p[i];
        int j = i - 1;
        while (j >= 0 && p[j].first < k.first) {
            p[j + 1] = p[j];
            j--;
        }
        p[j + 1] = k;
    }
    return;
}

int main() {
    bool flag = false;
    int n;
    while (cin >> n && n) {
        if (flag) cout << endl;
        flag = true;
        string s;
        int w, l, d;
        pair<int, string> p[n];
        for (int i = 0; i < n; i++) {
            cin >> s >> w >> l >> d;
            p[i] = { 3 * w + d, s };
        }
        insertion_sort(p, n);
        for (int i = 0; i < n; i++) {
            cout << p[i].second << ',' << p[i].first << endl;
        }
    }
}


Measured memory_bytes: 3040
#[allow(dead_code)]
fn main() {
    let aa = i::str();
    let aa1:Vec<char> =aa.as_str().chars().collect();
    let bb = i::str();
    let bb1:Vec<char> =bb.as_str().chars().collect();
    let len =aa.len();
    let lensa:i32=(aa.len() as i32)-(bb.len() as i32);
    for x1 in 0..(len) {
        let mut xa=x1 as i32;
        let mut aa=aa1[x1] as i32;
        let mut bb=bb1[x1] as i32;
        if (lensa!=0){
            if (lensa>0){
                if (lensa>xa){
                    bb=0;
                }else{
                    bb=bb1[(xa-lensa ) as usize ] as i32;
                }
            }else{
                if ((-lensa)>xa){
                    aa=0;
                }else{
                    aa=aa1[(xa+lensa) as usize] as i32;
                }
            }
        }
        if ((aa)>(bb)){
            println!("GREATER");
            return;
        }
        if ((aa)<(bb)){
            println!("LESS");
            return;
        }
    }
    println!("EQUAL");
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

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

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define ll long long
#define pb push_back
#define pm make_pair
#define fi first
#define se second
using namespace std;
const int MAX = 500 + 5;
int a[MAX][MAX],n,m,q; 
ll dp[MAX][MAX];
int main()
{
	cin>>n>>m>>q;
	int l,r;
	while(m--) {
		scanf("%d%d",&l,&r);
		a[l][r]++;
	}
	for(int l = n; l>0; l--) {
		for(int r = 1; r<=n; r++) {
			dp[l][r] = a[l][r] + dp[l+1][r] + dp[l][r-1] - dp[l+1][r-1];
		}
	}
	while(q--) {
		ll ans = 0;
		scanf("%d%d",&l,&r);
		printf("%lld\n",dp[l][r]);
	}
	return 0 ;
 }


Measured memory_bytes: 3840
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
#define LL long long
LL N,X;
LL f(LL a,LL b)
{
    if(a==0)return -b;
    return f(b%a,a)+2*a*(b/a);
}
int main()
{
    scanf("%lld%lld",&N,&X);
    printf("%lld",f(X,N-X)+N);
}


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

using namespace std;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")

#define fastio               \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
//#define int long long
#define ll long long
#define endl "\n"
#define inf ULLONG_MAX
#define gcd __gcd
#define deb(x) cout << #x << " " << x << endl;
#define pr(x) cout << x << endl;

#define sz(a) ((ll)(a).size())
#define all(v) (v).begin(), (v).end()
#define tr(c, it) for (auto(it) = (c).begin(); (it) != (c).end(); it++)
#define pres(c, val) ((c).find(val) != (c).end())
#define cpres(c, val) (find(all(c), val) != (c).end())
#define dec greater<ll>()
#define sortv(x) sort(all(x))
#define revsortv(x) sort(all(x), dec)
#define com(x) ((x) * (x + 1) / 2)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bg begin()
#define ed end()
#define bs binary_search // to find if an element is present or not in Ologn time, return a boolean
#define ub upper_bound   // to find an element strictly greater than the given no.
#define lb lower_bound   // lb(v,begin(), v.end(), n) gives the iterator

#define fo(n) for (ll i = 0; i < n; i++)
#define fo1(n) for (ll i = 1; i < n; i++)
#define fo2(i, n) for (ll i = 0; i < n; i++)
#define fo3(i, a, b) for (ll i = a; i < b; i++)
#define fors(a) cin >> a[i]
#define forp(a) cout << a[i] << " "
#define prv(a, n)  \
    fo(n) forp(a); \
    cout << endl;
#define fob(i, a, b) for (ll i = (b); i >= (a); i--)

typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef unordered_map<string, ll> umsl;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;

#define scan(v, n)   \
    vl v;            \
    fo(n)            \
    {                \
        ll item;     \
        cin >> item; \
        v.pb(item);  \
    }

const ll INF = 0xFFFFFFFFFFFFFFFL;;
const ll N = 1e9 + 7;
void swap1(ll a,ll b){
    ll temp;
    temp=a;
    a=b;
    b=temp;
}
void solve()
{
ll n;
cin>>n;
char str[20]; 
    int i = 0; 
    while (n > 0) { 
        
        int remain = n % 26; 
  
        
        if (remain == 0) { 
            str[i++] = 'z'; 
            n = (n / 26) - 1; 
        } 
        else  
        { 
            str[i++] = (remain - 1) + 'a'; 
            n = n / 26; 
        } 
    } 
    str[i] = '\0'; 
    reverse(str, str + strlen(str)); 
    cout << str << endl; 
  

}



int32_t main(int32_t argc, char **argv)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    freopen("inputf.txt", "r", stdin);
    freopen("outputf.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif*/

    ll t;
   // cin >> t;
    t=1;
   while (t--)
        solve();

    cerr << endl
         << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

    return 0;
}

Measured memory_bytes: 3780
#include<stdio.h>
int main(void){
  int n, i, temp, j, x=0, y=0;
  scanf("%d", &n);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d", &a[i]);
  }
  for(i=0; i<n; i++){
      for(j=n-1; j>i; j--){
        if(a[j] < a[j-1]){
          temp = a[j];
          a[j] = a[j-1];
          a[j-1] = temp;
        }
      }
    }
  for(i=n-1;i>=0;i-=2){
    x+=a[i];
  }
  for(i=n-2;i>=0;i-=2){
    y+=a[i];
  }
  printf("%d\n", x-y);
  return 0;
}


Measured memory_bytes: 128
import math
n = int(input())

def div(m):
  d = {}
  temp = int(math.sqrt(m))+1
  for i in range(2, temp):
    while m%i== 0:
      m //= i
      if i in d:
        d[i] += 1
      else:
        d[i] = 1
  if d == {}:
    d[m] = 1
  else:
    if m in d:
      d[m] += 1
    elif m != 1:
      d[m] =1
  return d

from collections import Counter

d = {}
for i in range(2, n+1):
  d = dict(Counter(d)+Counter(div(i)))
#print(d)
ans = 1
for i in d.values():
  ans *= (i+1)
  ans %= 10**9+7
print(ans)



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

namespace _20192abc3
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s1 = Console.ReadLine().Split(' ');
            string[] s = Console.ReadLine().Split(' ');

            int N = int.Parse(s1[0]);
            int M = int.Parse(s1[1]);

            int TA;
            var li = new List<int>();


            for (int i = 0; i < M; i++)
            {
                TA = int.Parse(s[i]);
                li.Add(TA);
            }

            li.Sort();

            var sali = new List<int>();

            for(int i = 0; i < M-1; i++)
            {
                sali.Add(li[i +1] - li[i]);

            }

            sali.Sort();

            int idou = 0;

            for(int i=0;i< M - N; i++)
            {
                idou += sali[i];
            }

            Console.WriteLine(idou);

        }
    }
}


Measured memory_bytes: 18784
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){
    string s;
    cin >> s;
    int res = INF;
    int n = s.length();
    int tmp = 0;
    REP(i,n){
        if(i%2 == 0){
            if(s[i] != '0') tmp ++; 
        }
        else{
            if(s[i] != '1') tmp ++;
        }
    }
    res = tmp;
    tmp = 0;
    REP(i,n){
        if(i%2 == 1){
            if(s[i] != '0') tmp ++; 
        }
        else{
            if(s[i] != '1') tmp ++;
        }
    }
    res = min(res,tmp);
    cout << res << endl;


}


Measured memory_bytes: 512
N = int(input())
dic = {}
for _ in range(N):
    s = input()
    if not s in dic.keys():
        dic[s] = 0
    dic[s]+=1
list2 = sorted(dic.items(),key=lambda x:-x[1]) 

max1 = list2[0][1]
anslist = []
for d in list2:
    if d[1] == max1:
        anslist.append(d[0])
    else:
        break

anslist2 = sorted(anslist,key=lambda x:x)
for d in anslist2:
    print(d)

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

#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;


int main(){
  ll n;
  string s;

  cin >> s;
  n = s.size();
  
  rep(i,n){
    cout << "x";
  }
  
  
  cout << endl;
}



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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin >> n;

  vll h(n);
  REP(i, n)
    cin >> h[i];

  REP(i, n-1){
    if(i == 0 && h[i] >= h[i+1])
      h[i]--;
    else if(h[i] >= h[i+1] && h[i-1] < h[i])
      h[i]--;

  }

  bool ans = true;
  REP(i, n-1){
    if(h[i] > h[i+1])
      ans = false;
  }
  
  if(ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
}


Measured memory_bytes: 1024
import java.util.*;

/**
 * C
 */
public class Main {
    public static void main(String[] args) {
        
        int prime = 0;
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int array[] = new int[n];

        for(int i=0; i<n; i++) {
            array[i] = sc.nextInt();
        }

        sc.close();

        for(int num : array) {
            if(isPrime(num) == true) {
                prime++;
            }
        }

        /*IN : for (int num : array) {
            for (int j = 2; j<num; j++) {
                if (num % j == 0) {
                    continue IN;
                }
            }
            prime++;
        }
        
        これでだめだったから悲しいよなぁ。。。
        巨大な数が来た時に計算速度がバカ落ちる。

        */

        System.out.println(prime);

    }


    // 判定メソッドを作ったほうがいい
    public static boolean isPrime(int num) {

        if (num < 2) {
            return false;
        } else if (num == 2) {
            return true;
        } else if (num % 2 == 0) {
            return false; // 偶数はあらかじめ除く
        }

        double sqrtNum = Math.sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2) {
            if (num % i == 0) {
                // 素数ではない
                return false;
            }
        }

        // 素数である
        return true;
    }
}


Measured memory_bytes: 41384
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int n,m;
  while(cin >> n>>m, n||m) {
    int h[n+1];
    int hoge = 0;
    h[0] = 0;
    REP(i,n) {
      int tmp;
      cin >> tmp;
      hoge += tmp;
      h[i+1] = hoge;
    }

    vector<int> aa(1600000);
    REP(i,n+1) {
      REP(j,i) {
//        cout << h[i]-h[j] << endl;
        aa[h[i]-h[j]]++;
      }
    }
    int w[m+1];
    w[0] = 0;
    hoge = 0;
    REP(i,m) {
      int tmp;
      cin >> tmp;
      hoge += tmp;
      w[i+1] = hoge;
    }

    vector<int> bb(1600000);
    REP(i,m+1) {
      REP(j,i) {
        bb[w[i]-w[j]]++;
      }
    }
    long long res = 0;
    REP(i,1600000) {
      res += aa[i]*bb[i];
    }
    cout << res << endl;
  }
}

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

int main(){

    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: 3920
use std::io::*;
use std::str::FromStr;

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

fn main(){
    let n: usize = read();
    let mut a: Vec<i32> = (0..n).map(|_| read()).collect();

    let mut sum = 0;
    a.insert(0, 0);
    a.insert(n+1, 0);
    for i in 0..a.len()-1 {
        sum += (a[i+1] - a[i]).abs();
    }
    
    for i in 1..a.len()-1 {
        let ans:i32  = sum 
        + (a[i-1]-a[i+1]).abs() 
        - ((a[i-1] - a[i]).abs() + (a[i] - a[i+1]).abs());
        println!("{}",ans);
    }


}


Measured memory_bytes: 5244
#B
N = int(input())
S = [""] * N
P = [0] * N
P2 = [""] * N
NUM = [0] * N
for i in range(0, N):
    S[i], P2[i] = map(str, input().split())
    P[i] = int(P2[i])
    NUM[i] = i + 1
for i in range(0, N):
    for j in range(1, N):
        if S[j] < S[j-1]:
            S[j-1], S[j] = S[j], S[j-1]
            P[j-1], P[j] = P[j], P[j-1]
            NUM[j-1], NUM[j] = NUM[j], NUM[j-1]
        if S[j] == S[j-1]:
            if P[j] > P[j-1]:
                S[j-1], S[j] = S[j], S[j-1]
                P[j-1], P[j] = P[j], P[j-1]
                NUM[j-1], NUM[j] = NUM[j], NUM[j-1]
for i in range(0,N):
    print(NUM[i])

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

int main() {
    
  int N;
  int count=0;
  cin >> N;
    string a="a",b="b",c="c",d="d";
  for(int i=0;i<N;i++){
    string S;
    cin>>S;
    if(S=="P"&&a!="P"){
      a="P";
      count++;
    }
    else if(S=="W"&&b!="W"){
      b="W";
      count++;
    }
    else if(S=="G"&&c!="G"){
      c="G";
      count++;
    }
    else if(S=="Y"&&d!="Y"){
      d="Y";
      count++;
    }
  }
      if(count==3){
    cout<<"Three"<<endl;
  }
  if(count==4){
    cout<<"Four"<<endl;
  }
    
    
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a==0){
            if(b==100) printf("101");
            else if(b<100)printf("%d \n",b);
    }
    else if(b<100) printf("%d \n ",(int)pow(100,a) * b);
    else if(b==100) printf("%d \n",(int)pow(100,a) * (b+1));
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
x = list(map(int, input().split()))

ans = 10000000000000000
for i in range(N - K + 1):
    l = x[i]
    r = x[i+K-1]
    ans = min([ans, abs(l) + r - l, abs(r) + r - l])

print(ans)

Measured memory_bytes: 14384
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[5]={-1,0,1,0,0};
int dy[5]={0,-1,0,1,0};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------
const ll MAX_N=1<<17;
ll nn,dat[4*MAX_N];
void init(ll n1){
    nn=1;
    while(nn<n1)
        nn*=2;
    for(ll i=0;i<2*nn-1;i++)
        dat[i]=2147483647;
}
void update(ll k,ll a){
    k+=nn-1;
    dat[k]=a;
    while(k>0){
        k=(k-1)/2;
        dat[k]=mmin(dat[k*2+1],dat[k*2+2]);
    }
}
ll query(ll a,ll b,ll k,ll l, ll r){
    if(r<=a||b<=l)
        return 2147483647;
    if(a<=l&&b>=r)
        return dat[k];
    else{
        ll vl=query(a,b,k*2+1,l,(l+r)/2);
        ll vr=query(a,b,k*2+2,(l+r)/2,r);
        return mmin(vl,vr);
    }
}
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    ll n,q;cin>>n>>q;
    init(n);
    for(ll i=0;i<q;i++){
        ll co,x,y;cin>>co>>x>>y;
        if(co==1){
            cout<<query(x,y+1,0,0,nn)<<endl;
        }  
        else{
            update(x,y);
        }
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------


















































Measured memory_bytes: 5172
def main():
    import sys
    import heapq

    X,Y,A,B,C=list(map(int,sys.stdin.readline().split()))
    
    P=list(map(int,sys.stdin.readline().split()))
    Q=list(map(int,sys.stdin.readline().split()))
    R=list(map(int,sys.stdin.readline().split()))

    P.sort(reverse=True)
    Q.sort(reverse=True)
    R.sort(reverse=True)

    RE=P[:X]
    QE=Q[:Y]

    heapq.heapify(RE)
    heapq.heapify(QE)

    for r in R:
        if RE[0]<QE[0]:
            if RE[0]<r:
                heapq.heappushpop(RE,r)
        else:
            if QE[0]<r:
                heapq.heappushpop(QE,r)

    print(sum(list(RE))+sum(list(QE)))




main()

Measured memory_bytes: 22720
#include<bits/stdc++.h>
#define ll long long
#define db double
#define lowbit(p) (p&(-p))
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define A first
#define B second
using namespace std;
void read(int &x){
	x=0; char c=getchar(); int p=1;
	for (;c<48;c=getchar())if (c=='-')p=-1;
	for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=p;
}
void read(ll &x){
	x=0; char c=getchar(); int p=1;
	for (;c<48;c=getchar())if (c=='-')p=-1;
	for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=p;
}
void Min(int &x,int y){
	if (x>y)x=y;
}
void Max(int &x,int y){
	if (x<y)x=y;
}
void Min(ll &x,ll y){
	if (x>y)x=y;
}
void Max(ll &x,ll y){
	if (x<y)x=y;
}
#define M 200005
int a[M],n,nx[M];
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
//	freopen("1.in","r",stdin);
	read(n);
	int i,k,tmp;
	for (i=1;i<=n;i++){
		read(a[i]);	
		nx[i]=n;
	}
	nx[n+1]=n+1;
	for (k=0;k<20;k++){
		tmp=n+1;
		for (i=n;i>=1;i--){
			if ((a[i]>>k)&1){
				Min(nx[i],tmp-1);
				tmp=i;
			}	
			else {
				Min(nx[i],nx[tmp]);
			}
		}/*
		for (i=1;i<=n;i++){
			printf("%d ",(a[i]>>k)&1);	
		}
		printf("\n");
		for (i=1;i<=n;i++){
			printf("%d ",nx[i]);	
		}
		printf("\n");*/
	}
	ll res=0;
	for (i=1;i<=n;i++){
//		printf("%d ",nx[i]);
		res+=nx[i]-i+1;
	}
//	printf("\n");
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 1792
import itertools

n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]


dist = 0
f = 0
for v in itertools.permutations(l, n):
    f += 1
    for i in range(1, n):
        x1, y1 = v[i-1]
        x2, y2 = v[i]
        dist += ((x1-x2)**2 + (y1-y2)**2)**0.5
res = round(dist/f, 10)
print(res)

Measured memory_bytes: 9368
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>

using namespace std;

#define ll long long

int main()
{
	int a, b, q;
	cin >> a >> b >> q;
	vector<ll> s(a), t(b);
	for (int i = 0; i < a; i++)
		cin >> s[i];
	for (int i = 0; i < b; i++)
		cin >> t[i];
	
	for (int i = 0; i < q; i++)
	{
		ll pos;
		cin >> pos;

		//	*itr >= pos
		auto itr = lower_bound(s.begin(), s.end(), pos);
		ll sl, sr;
		if (itr == s.end())
		{
			sr = 1000000000000;
			sl = *(--itr);
		}
		else if (itr == s.begin())
		{
			sr = *(itr);
			sl = -1000000000000;
		}
		else
		{
			sr = *(itr--);
			sl = *itr;
		}

		itr = lower_bound(t.begin(), t.end(), pos);
		ll tl, tr; 
		if (itr == t.end())
		{
			tr = 1000000000000;
			tl = *(--itr);
		}
		else if (itr == t.begin())
		{
			tr = *(itr);
			tl = -1000000000000;
		}
		else
		{
			tr = *(itr--);
			tl = *itr;
		}
	
		vector<ll> r(6);
		r[0] = sr > tr ? sr - pos : tr - pos;	//	右移動
		r[1] = sl > tl ? pos - tl : pos - sl;	//	左移動
		r[2] = (sr - tl) + (pos - tl);
		r[3] = (tr - sl) + (pos - sl);
		r[4] = (sr - pos) + (sr - tl);
		r[5] = (tr - pos) + (tr - sl);
		
		printf("%lld\n", *min_element(r.begin(), r.end()));
	}

	return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;


vector<int>  dx = {1,-1,0,0};
vector<int>  dy = {0,0,1,-1};


int main() {

	int A,B,C; cin >> A >> B >> C;
	vector<int> v = {A,B,C};

	sort(v.begin(), v.end());

	int ans = 0;
	
	ans += v[2] - v[1];
	v[0] += v[2] - v[1];
	if ((v[2] - v[0] ) % 2 == 1) {
		ans += ((v[2] - v[0]) / 2) + 2;
	}else {
		ans += ((v[2] - v[0]) / 2);
	}

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();

		if(y >= r && y <= H-r && x >=r && x <= W-r){
			System.out.printf("Yes\n");
		}else{
			System.out.printf("No\n");
		}
	}
}





Measured memory_bytes: 26344
#include <iostream>
#include <vector>

using namespace std;

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

	long long ans = 0;
	for (int i = 0; i < n; i++) {
		while (a[i] % 2 == 0) {
			ans++;
			a[i] /= 2;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
int main()
{
	char a,b;
	std::cin>>a>>b;
	if(a=='H'&&b=='H')
	{
		std::cout<<"H";
		return 0;
	}
	else if(a=='D'&&b=='H')
	{
		std::cout<<"D";
	}
	else if(a=='H'&&b=='D')
	{
		std::cout<<"D";
	}
	else
	{
		std::cout<<"H";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string S;
  vector<string> T={"Sunny","Cloudy","Rainy"};
  cin>>S;
  if(S==T.at(0))cout<<T.at(1)+"\n";
  else if(S==T.at(1))cout<<T.at(2)+"\n";
  else cout<<T.at(0)+"\n";
}

Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))

edge = [[] for _ in range(n)]

## 接している各頂点をまとめる
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)

cnt = 0

for node in range(n):
    good = True 
    for neighbor in edge[node]:
        if h[node] <= h[neighbor]:
            good = False
    
    if good:
        cnt += 1

print(cnt)

Measured memory_bytes: 29516
from collections import deque

def main():
    N, K = map(int, input().split())
    edge = [[] for _ in range(N)]
    MOD = 10 ** 9 + 7
    for _ in range(N-1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        edge[a].append(b)
        edge[b].append(a)
    
    
    ans = K
    visited = [False] * N
    q = deque([[0,K]])
    while q:
        s, color = q.popleft()
        if visited[s]:
            continue
        visited[s] = True
        cnt = 0
        for v in edge[s]:
            if visited[v]:
                continue
            ans *= color - 1 - cnt
            ans %= MOD
            cnt += 1
            q.append([v,K-1])

    print(ans)

    



if __name__ == "__main__":
    main()

Measured memory_bytes: 73760
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
  long long n;
  long long ans=1e12+1;
  cin>>n;
  for(int i=1;i<=sqrt(n);i++){
    if(n%i==0)ans=min(ans,i+n/i);
  }
  ans-=2;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {

        //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        FastScanner fs = new FastScanner();
        long d, x, y, total = 0;
        int n = fs.nextInt();
        d = fs.nextLong();
        d *= d;
        for (int i = 0; i < n; i++) {
            x = fs.nextInt();
            y = fs.nextInt();
            long cal = (x * x) + (y * y);
            if (cal <= d) {
                total++;
            }
        }
        System.out.println(total);
        bw.flush();
    }
//==============================================//
//==============================================//

    static void sort(int[] a) {
        ArrayList<Integer> l = new ArrayList<>();
        for (int i : a) {
            l.add(i);
        }
        Collections.sort(l);
        for (int i = 0; i < a.length; i++) {
            a[i] = l.get(i);
        }
    }

    static class FastScanner {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }

    static class Pair implements Comparable<Pair> {

        int a, b;

        public Pair(int x, int y) {
            a = x;
            b = y;
        }

        @Override
        public int compareTo(Pair p) {
            return a - p.a;
        }
    }

    static void forl_0(int n, int[] array, Scanner sc) {
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static void forl_1(int n, int[] array, Scanner sc) {
        for (int i = 1; i <= n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static boolean isPrime(long n) {
        if (n < 2) {
            return false;
        } else if (n == 2 || n == 3) {
            return true;
        } else if (n % 2 == 0 || n % 3 == 0) {
            return false;
        }
        long sqrtN = (long) Math.sqrt(n) + 1;
        for (long i = 6L; i <= sqrtN; i += 6) {
            if (n % (i - 1) == 0 || n % (i + 1) == 0) {
                return false;
            }
        }
        return true;
    }

    public static long gcd(long a, long b) {
        return (b == 0) ? a : gcd(b, a % b);
    }

    public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
    }
}


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

const int maxn=1e5+5;

int n,tot;
int now[maxn],pre[maxn<<1],son[maxn<<1];

int read() {
    int x=0,f=1;char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
    for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
    return x*f;
}

void add(int a,int b) {
    pre[++tot]=now[a];
    now[a]=tot,son[tot]=b;
}

int dfs(int fa,int u) {
    int res=0;
    for(int p=now[u],v=son[p];p;p=pre[p],v=son[p])
        if(v!=fa)res+=dfs(u,v);
    if(res>=2)return res;
    else return res^1;
}

int main() {
    n=read();
    for(int i=1;i<n;i++) {
        int a=read(),b=read();
        add(a,b),add(b,a);
    }
    if(dfs(0,1))puts("First");
    else puts("Second");
    return 0;
}


Measured memory_bytes: 2176
/* 
 * Author: pawanmsr
 */

// #include <iostream>
// #include <iomanip>
// #include <string>
// #include <vector>
// #include <algorithm>
// #include <queue>
// #include <deque>
// #include <bitset>
// #include <iterator>
// #include <list>
// #include <stack>
// #include <map>
// #include <set>
// #include <functional>
// #include <numeric>
// #include <utility>
// #include <limits>
// #include <fstream>
// #include <cstring>

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

// Macro //
#define X first
#define Y second
#define pii pair<int,int>
#define pll pair<ll,ll>

// Global //
int k, n, a[200002];

// Functions //


// Main //
int main(int argc, char const *argv[])
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    
    /* code */
    cin >> k >> n;
    for (int i=0; i<n; i++) cin >> a[i];
    int mx = 0;
    for (int i=0; i<n; i++) {
        int dist = abs(a[(n+i)%n] - a[(n+i-1)%n]);
        if (dist > k/2) dist = k - dist;
        if (dist > mx) mx = dist;
    }
    cout << k - mx << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void)
{
	int x;
	int	y;

	while(1)
	{
		scanf("%d %d",&x,&y);

		if((x == 0)&&(y == 0))
		{
			break;
		}
		if(x>y)
		{
			printf("%d %d\n",y,x);
		}
		else
		{
			printf("%d %d\n",x,y);
		}
	}
	return 0;
}

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


int main() {

    string b;
    cin >> b;
    if (b == "A") cout << "T" << endl;
    else if (b == "T") cout << "A" << endl;
    else if (b == "C") cout << "G" << endl;
    else if (b == "G") cout << "C" << endl;
    return 0;
}

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

using namespace std;

int main()
{
	int t;
	t=1;
	while(t--)
	{
	
	
	string s;
	cin>>s;
	
	long long int i,j,k,n;
	
	long long int sum=0;
	n=s.length();
	for(i=0;i<n;i++)
	sum=sum+(s[i]-'0');
	
//	cout<<sum<<" ddd \n";
	
	if(sum%9==0)
	cout<<"Yes\n";
	
	else
	cout<<"No\n";
	
	
	
	}



}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset((a), v, sizeof(a))
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

const int N = 200005;

int n, k;
int dat[N];

int main() {
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++) scanf("%d", &dat[i]);
	for (int i = k; i < n; i++) {
		if (dat[i] > dat[i-k]) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 4464
/*▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄█████████████  █▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐*/
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)
// #define endl '\n'
#define all(x) x.begin(), x.end()
#define int long long
#define mk(a, b) make_pair(a, b)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
// typedef tuple<int, int, int> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<int> > vvi;
typedef vector<char> vc;

const ll INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1000000007;
// const ll MAXN = 3e5;
const ld eps = 1e-6;
const ld eps2 = 1e-9;
const ll MOD2 = 998244353;
const ll dosz = 5e5;
const ll SZ = (1<<18);
const ld PI = atan2l(0, -1);


void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
        // freopen("a.in", "r",stdin);
#else
       // freopen("sum.in", "r", stdin);
       // freopen("sum.out", "w", stdout);
#endif
}


void solve(){
    int a, b;
    cin >> a >> b;
    if(b>=a){
        cout << "unsafe" << endl;
    } else{
        cout << "safe" << endl;
    }
} 
 

signed main() {
    fast_io();
    int q = 1;
    // cout << fixed;
    // cin >> q;
    while(q--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define stt static
#define rg register
#define ll long long
#define db double
#define pii pair<int,int>
#define mp make_pair
#define fst first
#define snd second
#define pb push_back
#define y1 substitute_of_y1
#define DEBUG(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

template<typename T> T rd(){
	T nmb=0;int sgn=0;char chr=getchar();
	while(!isdigit(chr)){if(chr=='-')sgn=1;chr=getchar();}
	while(isdigit(chr)){nmb=(nmb<<3)+(nmb<<1)+chr-'0';chr=getchar();}
	return sgn?-nmb:nmb;
}
template<typename T> void wt(T nmb){
	if(nmb>9)wt(nmb/10);
	putchar(nmb%10+'0');
}
template<typename T> void cmax(T &x,T y){x=x>y?x:y;}
template<typename T> void cmin(T &x,T y){x=x<y?x:y;}
void proc_status(){
	ifstream t ("/proc/self/status");
	cerr<<string(istreambuf_iterator<char>(t),istreambuf_iterator<char>())<<endl;
	/*freopen("/proc/self/status","r",stdin);
	char ch[100];
	while(scanf("%s",ch)!=EOF)cerr<<ch<<endl;*/
}

const int N=20,K=(1<<16)+10;
const int P=1e9+7;

int pwr(int x,int y){
	int z=1;
	for(;y;y>>=1,x=(ll)x*x%P)
		if(y&1)z=(ll)z*x%P;
	return z;
}

int fac[K],inv[K];
void getfac(int n){
	fac[0]=1;
	for(int i=1;i<=n;++i)
		fac[i]=(ll)fac[i-1]*i%P;
	inv[n]=pwr(fac[n],P-2);
	for(int i=n;i;--i)
		inv[i-1]=(ll)inv[i]*i%P;
}
int C(int n,int m){
	if(n<0||m<0||n<m)return 0;
	return (ll)fac[n]*inv[m]%P*inv[n-m]%P;
}

int Lg[K];
void getLg(int n){
	Lg[1]=0;
	for(int i=2;i<=n;++i)
		Lg[i]=Lg[i>>1]+1;
}

int n,m,All;
int a[N];
int dp[N][K];

#define lowbit(x) ((x)&(-(x)))

void Init(){
	n=rd<int>(),m=rd<int>();
	for(int i=1;i<=m;++i)
		a[i]=rd<int>();
	sort(a+1,a+m+1);
	All=(1<<n)-1;
	getfac(All);
	getLg(All);
}

void Solve(){
	dp[m+1][0]=1;
	for(int i=m;i;--i){
		for(int S=0;S<=All;++S){
			(dp[i][S]+=dp[i+1][S])%=P;
			for(int T=S;T;T^=lowbit(T)){
				int t=lowbit(T);
				(dp[i][S]+=(ll)dp[i+1][S^t]*C((1<<n)-(S^t)-a[i],t-1)%P*fac[t]%P)%=P;
			}
		}
	}
	int Ans=0;
	for(int S=0;S<=All;++S)
		(Ans+=(ll)((__builtin_popcount(S)&1)?P-1:1)*dp[1][S]%P*fac[All-S]%P)%=P;
	Ans=(ll)Ans*(1<<n)%P;
	printf("%d\n",Ans);
}

int main(){
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 5120
N = int(input())
L = list(map(int, input().split()))

L = sorted(L)

import bisect

count = 0
for i in range (0, len(L)-2):
	for j in range (i+1, len(L)-1):
		count+= bisect.bisect_left(L[j+1:], L[i]+L[j])

print(count)

Measured memory_bytes: 74832
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int n;
	cin >> n;
	vector<ll> v(n);
	rep(i,n) cin >> v[i];
	ll ans = 0;
	map<ll, int> mp;
	rep(i,n) {
		mp[i + 1 - v[i]]++;
	}
	rep(i,n) {
		ll x = v[i] + i + 1;
		ans += mp[x];
	}
	cout << ans << endl;
}

Measured memory_bytes: 27348
from heapq import heappush, heappop

n, d, a = map(int, input().split())
actions = []
for _ in range(n):
    x, h = map(int, input().split())
    heappush(actions, (x, 0, (h + a - 1) // a))
cnt = 0
bomb = 0
current_bomb = 0
while cnt < n:
    a, c, b = heappop(actions)
    if c:
        current_bomb -= b
        continue
    else:
        HP = b
        if HP <= current_bomb:
            cnt += 1
            continue
        else:
            HP -= current_bomb
            cnt += 1
            current_bomb += HP
            bomb += HP
            heappush(actions, (a + 2 * d, 1, HP))
print(bomb)


Measured memory_bytes: 35672
#include<stdio.h>

/* 値を入れ替える関数 */
void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int h[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (h[i] < h[pivot]);
    do { j--; } while (h[pivot] < h[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&h[i], &h[j]); }
  } while (i < j);

  swap(&h[pivot], &h[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int h[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(h, left, right);
    quick_sort(h, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(h, pivot+1, right);
  }
}

int main(void){
  int N,K,i;
  scanf("%d %d",&N,&K);
  int h[N];
  for(i=0;i<N;i++){
    scanf("%d",&h[i]);
  }
  
  quick_sort(h, 0, N-1);
  
  int min=h[K-1]-h[0];
  for(i=K;i<N;i++){
    if(min>h[i]-h[i-K+1]){
      min=h[i]-h[i-K+1];
    }
  }
  printf("%d",min);
  return 0;
}

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


// bool isPrime(int n) {
// 	if (n <= 1) {
// 		return false;
// 	}

// 	// Check from 2 to n-1
// 	for (int i = 2; i < n; i++) {
// 		if (n % i == 0) {
// 			return false;
// 		}
// 	}

// 	return true;
// }
int main()
{
	// string S, T;
	// cin >> S >> T;
	// cout << T << S << endl;

	// long long A, B, K;
	// cin >> A >> B >> K;
	// long long ans_A, ans_B;
	// if (A <= K) {
	// 	ans_A = 0;
	// 	if (B <= K - A) {
	// 		ans_B = 0;
	// 	} else {
	// 		ans_B = B - (K - A);
	// 	}
	// } else {
	// 	ans_A = A - K;
	// 	ans_B = B;
	// }
	// cout << ans_A << " " << ans_B << endl;
	// int X;
	// cin >> X;

	// while (true) {
	// 	if (isPrime(X)) {
	// 		break;
	// 	}
	// 	X++;
	// }
	// cout << X << endl;

	int N, K, R, S, P;
	string T;
	cin >> N >> K;
	cin >> R >> S >> P;
	cin >> T;

	int sum = 0;

	vector<int> result(N, 0);

	for (int i = 0; i < N; i++) {
		int score;
		if (i <= K - 1) {
			if (T.at(i) == 'r') {
				score = P;
			} else if (T.at(i) == 's') {
				score = R;
			} else if (T.at(i) == 'p') {
				score = S;
			}
		} else {
			if (T.at(i - K) == 'r') {
				if (T.at(i) == 'r') {
					if (result.at(i - K) == 0) {
						score = P;
					} else {
						score = 0;
					}
				} else if (T.at(i) == 's'){
					score = R;
				} else if (T.at(i) == 'p') {
					score = S;
				}
			} else if (T.at(i - K) == 's') {
				if (T.at(i) == 's') {
					if (result.at(i - K) == 0)
					{
						score = R;
					}
					else
					{
						score = 0;
					}
				}
				else if (T.at(i) == 'r')
				{
					score = P;
				}
				else if (T.at(i) == 'p')
				{
					score = S;
				}
			}
			else if (T.at(i - K) == 'p') {
				if (T.at(i) == 'p')
				{
					if (result.at(i - K) == 0)
					{
						score = S;
					}
					else
					{
						score = 0;
					}
				}
				else if (T.at(i) == 'r')
				{
					score = P;
				}
				else if (T.at(i) == 's')
				{
					score = R;
				}
			}
		}
		// cout << score << endl;
		result.at(i) = score;
		sum += score;
	}
	cout << sum << endl;
}


Measured memory_bytes: 896