akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
	"sort"
)

type Entry struct {
	name  string
	value int
}
type List []Entry

func (l List) Len() int {
	return len(l)
}

func (l List) Swap(i, j int) {
	l[i], l[j] = l[j], l[i]
}

func (l List) Less(i, j int) bool {
	return (l[i].value < l[j].value)
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	ar := make(map[string]int, n)
	for i:=0; i<n; i++ {
		var v string
		fmt.Scan(&v)
		ar[v]++
	}

	al := List{}
	for k, v := range ar {
		e := Entry{k, v}
		al = append(al, e)
	}

	if len(al) <= k {
		fmt.Println(0)
		return
	}

	sort.Sort(al)
	
	cnt := 0
	for len(al) > k {
		cnt += al[0].value
		al = al[1:]
	}

	fmt.Println(cnt)
}

Measured memory_bytes: 38272
#include <stdio.h>

int main(void)
{
    int a, b, c;
    int flag=0;

    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);

    if(c >= a && c <= b){
        flag = 1;
    }
    if(c >= b && c <= a){
        flag = 1;
    }

    if(flag == 1){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 128
/*input
3 8
4 2 1
2 3 1
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=400005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){

    if(b<=0) return 1;
    if(a<=0) return 0;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
ll arr[maxn],f[maxn];
int n;
ll k;
bool wk(ll mid){
    ll z=k;
    REP(i,n){
        if(arr[i]*f[n-i-1]>mid){
            z-=(arr[i]-mid/(f[n-i-1]));
        }
    }
    if(z>=0) return true;
    return false;
}
int main(){
    cin>>n>>k;
    REP(i,n) cin>>arr[i];
    REP(i,n) cin>>f[i];
    sort(arr,arr+n);
    sort(f,f+n);
    ll l=0,r=1e12+1;
    while(l<r){
        ll mid=(l+r)/2;
        if(wk(mid)) r=mid;
        else l=mid+1;
    }
    cout<<r;
}

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



int main(){
  ll n;
  cin >> n;
  string s;
  cin >> s;
  
  vector<ll>b(n),w(n);
  
  for(ll i=0; i<n; i++){
    if(s[i]=='#'){
      break;
    }
    s[i]='0';
  }
  
  for(ll i=n-1; i>=0; i--){
    if(s[i]=='.'){
      break;
    }
    s[i]='0';
  }
  
  for(ll i=1; i<n; i++){
    if(s[i]=='.')w[0]++;
  }
  
  ll ans = w[0];
  
  for(ll i=1; i<n; i++){
    w[i]=w[i-1];
    b[i]=b[i-1];
    if(s[i]=='.') w[i]--;
    if(s[i-1]=='#') b[i]++;
    ans = min(ans,b[i]+w[i]);
    //cout << ans << endl;
    
  }
  
  
  //for(int i=0; i<n; i++)cout << s[i];
  //cout << w[0] << endl;
  
  cout << ans << endl;
  
  
  
  
}
       
        
      
  
    

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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
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;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

int n, r;


int main(){
    cin >> n >> r;
    if(10<=n)cout << r << endl;
    else cout << (r+(100*(10-n))) << endl;
    return 0;
}

Measured memory_bytes: 256
import math
from fractions import gcd

a,b,c,d = map(int, input().split())

l = c * d // gcd(c,d)

def count_prime(x):
    return (b // x) - ((a-1) // x)

print((b-a+1) - (count_prime(c) + count_prime(d) - count_prime(l)))


Measured memory_bytes: 5436
# -*- coding: utf-8 -*-

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

H, W = MAP()

cnt = 0
for i in range(H):
    row = input()
    cnt += row.count('#')

if cnt == H+W-1:
    print('Possible')
else:
    print('Impossible')


Measured memory_bytes: 5284
function Main(input) {
  input = input.trim()
  input = input.split(" ").map(Number);
var a= input[0]-input[1];
  if(a>=0){
  console.log(a)
  }else{
    console.log(0)
  }
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

import collections

a=int(input())
cc=collections.Counter(prime_factorize(a))
cc=cc.values()
ans=0
for k in cc:
    j=1
    while k>=0:
        k=k-j
        ans+=1
        j+=1
    ans=ans-1
print(ans)

Measured memory_bytes: 9468
#include<bits/stdc++.h>
using namespace std;
bool solve(int*data,int ans,vector<char>ope,int count){
  if(count==4){
    if(ans==7){
      cout<<data[0]<<ope[1]<<data[1]<<ope[2]<<data[2]<<ope[3]<<data[3]<<"=7"<<endl;
      return true;
    }
    return false;
  }
  ope[count]='+';
  if(solve(data,ans+data[count],ope,count+1))return true;
  ope[count]='-';
  if(solve(data,ans-data[count],ope,count+1))return true;
  return false;
}
int main(void){
  int a=0;
  cin>>a;
  int data[4];
  data[0]=a/1000;
  a%=1000;
  data[1]=a/100;
  a%=100;
  data[2]=a/10;
  a%=10;
  data[3]=a;
  vector<char>ope(4);
  solve(data,data[0],ope,1);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)
const int N = 5e5 + 4;
int a[N] , lst[N] , c[N] , n , q;
struct Node{
   Node *lf , *rt;
   ll sum;
   Node() : lf(nullptr) , rt(nullptr) , sum(0ll){}
   Node(ll val) : lf(nullptr) , rt(nullptr) , sum(val){}
   Node(Node *l , Node *r) : lf(l) , rt(r) , sum(0ll){
      if(l) sum += l->sum;
      if(r) sum += r->sum;
   }
};

Node* build(int l , int r){
   if(l == r){
      return new Node(a[l]);
   }
   int mid = (l + r) / 2;
   Node *p1 = build(l , mid);
   Node *p2 = build(mid + 1 , r);
   return new Node(p1 , p2);
}

ll sum(Node *p , int l , int r , int i , int j){
   if(r < i || l > j)
      return 0;
   if(l >= i && r <= j)
      return p->sum;
   int mid = (l + r) / 2;
   ll p1 = sum(p->lf , l , mid , i , j);
   ll p2 = sum(p->rt , mid + 1 , r , i , j);
   return p1 + p2;
}

Node* update(Node *p , int l , int r , int pos , int val){
   if(pos < l || pos > r)
      return p;
   if(l == r){
      return new Node(val);
   }
   int mid = (l + r) / 2;
   Node *p1 = update(p->lf , l , mid , pos , val);
   Node *p2 = update(p->rt , mid + 1 , r , pos , val);
   return new Node(p1 , p2);
}

int main() {
#ifndef ONLINE_JUDGE
#endif
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   cin >> n >> q;
   Node* root = build(0 , n);
   vector<Node*> roots(n);
   memset(lst , -1 , sizeof(lst));
   for(int i = 0 ; i < n ; ++i) {
      cin >> c[i];
      if(~lst[c[i]])
         root = update(root , 0 , n , lst[c[i]] , 0);
      root = update(root , 0 , n , i , 1);
      roots[i] = root;
      lst[c[i]] = i;
   }

   while(q--){
      int l , r;
      cin >> l >> r;
      l-- , r--;
      cout << sum(roots[r] , 0 , n , l , r) << "\n";
   }
}

Measured memory_bytes: 666160
#include <iostream>
#include <cstdio>

using namespace std;
int a, b, ans;
int main() {
	cin >> a >> b;
	if(a < 1 || b < 1 || a > 9 || b > 9) cout << -1 << endl;
	else cout << a*b << endl;
	return 0;
}


Measured memory_bytes: 384
s = input()
t = input()
ds = {}
dt = {}

for i in range(len(s)):
    if(s[i] in ds):
        ds[s[i]] += 1
    else:
        ds[s[i]] = 1

for i in range(len(t)):
    if(t[i] in dt):
        dt[t[i]] += 1
    else:
        dt[t[i]] = 1

s_ = sorted(list(ds.values()))
t_ = sorted(list(dt.values()))
if(s_ != t_):
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
typedef long long LL;
const int N = 172;
LL dt[N];
int k;
int s(LL x){
    int sum=0; 
    while(x) sum+=x%10, x/=10;
    return sum; 
}

int main() {
    dt[0]=0;
    LL x=1;
    for(int i=1;i<N;i++) {
        dt[i]=dt[i-1]+x;
        if(i!=1 && (i-10)%9==0) x=x*10LL;
    }
    cin>>k;
    LL now = 1;
    for(int i=1;i<=k;i++) {
        printf("%lld\n", now);
        double mn=1e16; int bst=-1;
        for(int j=1;j<N;j++) {
            double tmp = 1.0*(now+dt[j])/s(now+dt[j]);
            if(tmp<mn) mn=tmp, bst=j;
        }
        now=now+dt[bst];
    }
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    Scanner(System.`in`).use {
        val a = it.nextInt()
        val b = it.nextInt()
        if (a % 2 != 0 && b % 2 != 0) {
            println("Yes")
        } else {
            println("No")
        }
    }
}


Measured memory_bytes: 29356
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    while(1){
        int N,M;
        cin >> N >> M;
        if(N == 0) break;
        vector<P> suzu(N);
        for(int i=0; i<N; i++){
            cin >> suzu[i].second >> suzu[i].first;
        }
        sort(suzu.begin(),suzu.end(),greater<P>());
        for(int i=0; i<N; i++){
            if(M > suzu[i].second){
                M -= suzu[i].second;
                suzu[i].second = 0;
            }else{
                suzu[i].second -= M;
                M = 0;
                break;
            }
        }
        ll ans = 0;
        for(int i=0; i<N; i++){
            ans += suzu[i].first * suzu[i].second;
        }
        cout << ans << enld;
    }
    return 0;
}


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

using namespace std;

#define MOD 10000

int main()
{
	int N, K, A, B;

	cin >> N >> K;

	vector<int> P(N, 0);

	for (int i = 0; i < K; i++)
	{
		cin >> A >> B;

		P[A - 1] = B;
	}

	vector<vector<vector<int> > > dp(N, vector<vector<int> >(3, vector<int>(2, 0)));

	if (P[0] != 0)
	{
		dp[0][P[0] - 1][0] = 1;
	}
	else
	{
		dp[0][0][0] = 1;
		dp[0][1][0] = 1;
		dp[0][2][0] = 1;
	}

	for (int i = 1; i < N; ++i)
	{
		if (P[i] == 0)
		{
			for (int j = 0; j < 3; ++j)
			{
				int j1, j2;

				if (j == 0) { j1 = 1; j2 = 2; }
				if (j == 1) { j1 = 0; j2 = 2; }
				if (j == 2) { j1 = 0; j2 = 1; }

				dp[i][j][0] = (dp[i - 1][j1][0] + dp[i - 1][j1][1] + dp[i - 1][j2][0] + dp[i - 1][j2][1]) % MOD;

				dp[i][j][1] = dp[i - 1][j][0];
			}
		}
		else
		{
			int j = P[i] - 1;

			int j1, j2;

			if (j == 0) { j1 = 1; j2 = 2; }
			if (j == 1) { j1 = 0; j2 = 2; }
			if (j == 2) { j1 = 0; j2 = 1; }

			dp[i][j][0] = (dp[i - 1][j1][0] + dp[i - 1][j1][1] + dp[i - 1][j2][0] + dp[i - 1][j2][1]) % MOD;

			dp[i][j][1] = dp[i - 1][j][0];
		}
	}

	int Ans = (dp[N - 1][0][0] + dp[N - 1][0][1] + dp[N - 1][1][0] + dp[N - 1][1][1] + dp[N - 1][2][0] + dp[N - 1][2][1]) % MOD;

	cout << Ans << endl;

	return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

template<typename T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return (a * b) / gcd(a, b);
}

int main()
{
    ll Q, H, S, D; cin >> Q >> H >> S >> D;
    ll N; cin >> N;
    Q *= 4, H *= 2;
    ll ans;
    while (N) {
        if (N >= 2) {
            ans += min(Q * 2, min(H * 2, min(S * 2, D)));
            N -= 2;
        }
        else {
            ans += min(Q, min(H, S));
            N--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
typedef long long ll;
using namespace std;
ll const MAX = 100005;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main(){
   int n;
   string s;
   cin>>n>>s;
   for (int i = 0; i < s.size(); i++)
   {
       cout<<(char)('A'+(s[i]-'A'+n)%26);
   }
   cout<<endl;
   
    return 0;
}

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




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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b.begin(), b.end());
  for (int i = 0; i < n; i++)
  {
    if (a[i] == b[n - 1])
    {
      cout << b[n - 2] << endl;
    }
    else
    {
      cout << b[n - 1] << endl;
    }
  }
}


Measured memory_bytes: 4824
#include <bits/stdc++.h>
const long long MOD = 1e9+7;
using namespace std;
#define ll long long
#define ar array

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

	int x;
	cin >> x;

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

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N,K;
ll a[100005];
ll ans=0;

vector<int> G[100005];
ll height[100005];

void solve(int pos){
  height[pos]=0;
  for(int to:G[pos]){
    solve(to);
    height[pos]=max(height[pos],height[to]+1);
  }
  
  if(height[pos]+1==K && a[pos]!=0){
    ans++;
    a[pos]=0;
  }
  if(a[pos]==0){
    height[pos]=-1;
  }
}

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

  for(int i=1;i<N;i++){
    G[ a[i] ].push_back(i);
  }
  solve(0);
  cout<< ans <<endl;
  return 0;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const ll mod = 998244353;
const int N = 500006;
const ll INF = 1e18;
int n, q;
vector<ll> pw;
vector<ll> pre;

struct seg_tree {
    int B;
    vector<ll> sum, lazy;


    void init(int n) {
        B = 1;
        while(B < n) {
            B *= 2;
        }
        sum.resize(B * 2);
        lazy.assign(B * 2, -1);
    }

    ll merge(ll a, ll b) {
        return (a + b) % mod;
    }

    void build(int node, int l, int r) {
        if(l + 1 == r) {
            if(l < n) {
                sum[node] = pw[n - l - 1] % mod;
            } else {
                sum[node] = 0;
            }
            return;
        }

        int mid = (l + r) / 2;
        build(node * 2 + 1, l, mid);
        build(node * 2 + 2, mid, r);
        sum[node] = merge(sum[node * 2 + 1], sum[node * 2 + 2]);
    }
    void build() {
        build(0, 0, B);
    }

    ll ask(int a, int b) {
        if(a == 0) {
            return pre[b];
        }

        ll ans = pre[b];
        ans -= pre[a - 1];
        ans %= mod;
        ans += mod;
        ans %= mod;

        return ans;
    }

    void propagate(int node, int l, int r) {

        if(lazy[node] == -1) {
            return;
        }

        if(l + 1 == r) {
            lazy[node] = -1;
            return;
        }

        int mid = (l + r) / 2;

        // l .. mid - 1


        for(int t : {2 * node + 1, 2 * node + 2}) {

            int x, y;
            if(t == 2 * node + 1) {
                x = l, y = mid;
            } else {
                x = mid, y = r;
            }

            sum[t] = lazy[node] * ask(n - y, n - x - 1);
            sum[t] %= mod;
            sum[t] += mod;
            sum[t] %= mod;
            lazy[t] = lazy[node];
        }

        lazy[node] = -1;
    }
    void upd(int node, int l, int r, int lf, int rg, int x) {
        
        propagate(node, l, r);

        if(l >= lf && r <= rg) {
            sum[node] = ask(n - r, n - l - 1) * x;
            sum[node] %= mod;
            sum[node] += mod;
            sum[node] %= mod;    
            lazy[node] = x;
            return; 
        }

        if(l >= rg || r <= lf) {
            return;
        }

        int mid = (l + r) / 2;

        upd(node * 2 + 1, l, mid, lf, rg, x);
        upd(node * 2 + 2, mid, r, lf, rg, x);
        sum[node] = merge(sum[node * 2 + 1], sum[node * 2 + 2]);

    }

    void upd(int l, int r, int dig) {
        upd(0, 0, B, l, r, dig);
    }

};


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

    pw.resize(n + 10);
    pre.resize(n + 10);

    pw[0] = 1;
    pre[0] = pw[0];

    for(int i = 1; i <= n + 6; i++) {
        pw[i] = (pw[i - 1] * 10LL) % mod;
        pre[i] = (pre[i - 1] + pw[i]) % mod;
    }

    
    seg_tree st;
    st.init(n + 6);

    st.build();

    while(q--) {
        int l, r, dig;
        cin >> l >> r >> dig;
        l--;
        st.upd(l, r, dig);
        cout << st.sum[0] << '\n';
    }
    return 0;
}



Measured memory_bytes: 14420
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a, b;
  cin >> a >> b;
  
  reverse(b.begin(), b.end());
  
  if (a == b){
    cout << "YES" << endl;
  }else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
a= list(map(int,input().split()))
b= list(map(int,input().split()))
c= list(map(int,input().split()))
lst=a+b+c
ans=[lst.count(i) for i in range(1,5)]
ans.sort()
if ans == [1,1,2,2]:
    print("YES")
else:
    print("NO")


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

const int MAX_N = 100001;
int N, L;
int A[MAX_N];
int T[MAX_N];

int rec(int p) {
  int &res = T[p];
  if(res == -1) {
    int wait = 0;
    for(int d = -1; d <= 1; d += 2) {
      int np = p + d;
      if(np < 0 || np >= N) continue;
      if(A[p] < A[np]) wait = max(wait,rec(np));
    }
    res = wait + L - A[p];
  }
  return res;
}

int solve() {
  int ans = 0;
  fill(T,T+N,-1);
  for(int i = 0; i < N; ++i) ans = max(ans, rec(i));
  return ans;
}

int main() {
  cin >> N >> L;
  for(int i = 0; i < N; ++i) cin >> A[i];
  cout << solve() << endl;
  return 0;
}

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

#define FAST ios_base:: sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define sz(a) ll((a).size())
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())

typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

int main(){
	FAST;
	ll n;
	cin >> n;
	cout << 180*(n-2);
}





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

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

// ---------------------------------------------

int main(){
    ll n, k;
    cin>>n>>k;
    bool a[n];
    for(ll i=0;i<n;++i){
        a[i] = false;
    }
    for(ll i=0;i<k;++i){
        ll d;
        cin>>d;
        for(ll j=0;j<d;++j){
            ll b;
            cin>>b;
            b--;
            a[b] = true;
        }
    }
    ll ans = 0;
    for(ll i=0;i<n;++i){
        if(a[i] == false){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;

namespace practice
{
    class MainClass
    {
        public static List<int> ConvertToInt(string[] strs)
        {
            List<int> list = new List<int>();
            for (int i = 0; i < strs.Length; i++)
            {
                list.Add(int.Parse(strs[i]));
            }
            return list;
        }

        public static int Max(List<int> nums)
        {
            int max = -1000000;
            for (int i = 0; i < nums.Count; i++)
            {
                if (max < nums[i])
                {
                    max = nums[i];
                }
            }
            return max;
        }

        public static int Min(List<int> nums)
        {
            int min = 1000000;
            for (int i = 0; i < nums.Count; i++)
            {
                if (min > nums[i])
                {
                    min = nums[i];
                }
            }
            return min;
        }
        public static long Sum(List<int> nums)
        {
            long sum = 0;
            for(int i =0;i < nums.Count; i++)
            {
                sum += nums[i];
            }
            return sum;
        }


        public static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] input2 = Console.ReadLine().Split(' ');
            List<int> nums = ConvertToInt(input2);

            int min = Min(nums);
            int max = Max(nums);
            long sum = Sum(nums);

            Console.WriteLine(min + " " + max + " " + sum);
        }

    }
}


Measured memory_bytes: 17996
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define DBG(X) cout<<" "<<#X<<" : "<<X<<endl
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;

const int INF = 1e9;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;

struct Input
{
	int n;char c;char str[1024];string s;ll l;double d;
	int nextInt(){scanf("%d", &n);return n;}
	ll nextLong(){scanf("%lld", &l);return l;}
	double nextDouble(){scanf("%lf", &d);return d;}
	char nextChar(){scanf("%c", &c);return c;}
	string next(){scanf("%s", str);return string(str);}
	string nextLine(){getline(cin, s);return s;}
};
Input in;

struct Edge{
	int to, cost;
	Edge(){};
	Edge(int to, int cost) : to(to), cost(cost){};
};

vector<Edge> es[100010];
int d[100010];

int main(){
	int n = in.nextInt();
	rep(i, n){
		int p = in.nextInt();
		if(p == 0){
			for(int j = 1; j <= 6; j++) es[i].pb({i+j, 1});
		}
		else es[i].pb({i+p, 0});
	}
	auto dijkstra =[&]{
		typedef pair<int, int> P;
		for(int i = 0; i < n + 6; i++) d[i] = INF;
		d[0] = 0;
		priority_queue<P> q;
		P p;
		q.push({0, 0});
		while(!q.empty()){
			p = q.top(); 	q.pop();
			int from = p.se, c = -p.fi;
			for(auto& e : es[from]){
				int to = e.to, cost = c + e.cost;
				if(d[to] > cost){
					d[to] = cost;
					q.push({-cost, to});
				}
			}
		}
	};
	dijkstra();
	int ans = INF;
	for(int i = n -1; i < n + 6; i++) ans = min(ans, d[i]);
	cout<<ans<<endl;
}

Measured memory_bytes: 10588
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    class UnionFind():
        def __init__(self,n):
            self.par=[i for i in range(n)]
            self.siz=[1]*n
            
        def root(self,x):
            while self.par[x]!=x:
                self.par[x]=self.par[self.par[x]]
                x=self.par[x]
            return x
        
        def unite(self,x,y):
            x=self.root(x)
            y=self.root(y)
            if x==y:
                return False
            if self.siz[x]<self.siz[y]:
                x,y=y,x
            self.siz[x]+=self.siz[y]
            self.par[y]=x
            return True
        
        def is_same(self,x,y):
            return self.root(x)==self.root(y)
        
        def size(self,x):
            return self.siz[self.root(x)]
    
    N,M,K=map(int,input().split())
    ans=[-1]*N
    u=UnionFind(N)
    for _ in range(M):
        A,B=map(lambda x: int(x)-1,input().split())
        u.unite(A,B)
        ans[A]-=1
        ans[B]-=1
        
    for _ in range(K):
        C,D=map(lambda x: int(x)-1,input().split())
        if u.is_same(C,D):
            ans[C]-=1
            ans[D]-=1
    
    for i in range(N):
        ans[i]+=u.size(i)
    print(*ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61216
#include<bits/stdc++.h>
using namespace std;
int  lft[200005], rght[200005];
char str[200005];
bool ok[200005];
int main()
{
    int n, k, c;
    scanf("%d %d %d %s", &n, &k, &c, str+1);
    int prev= 0;
    for(int i=1; i<=n; i++)
    {
        if(str[i]=='x')continue;
        lft[i]= prev++;
        for(int j=i+1; j<=i+c && j<=n; j++)lft[j]= prev;
        i+= c;
    }
    prev= 0;
    for(int i=n; i>0; i--)
    {
        if(str[i]=='x')continue;
        rght[i]= prev++;
        for(int j=i-1; j>=i-c && j>0; j--)rght[j]= prev;
        i-= c;
    }
    for(int i=1; i<=n; i++)
    if(str[i]=='o' && (lft[i]+rght[i])<k)
    printf("%d\n", i);
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  vector <string> a(3);
  a = {"Sunny", "Cloudy", "Rainy"};
  for (int i = 0; i<3; i++) {
    if (S == a[i]) cout << a[(i+1)%3] << endl;
  }
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

typedef int weight_t;
const weight_t INF=1<<29;

struct edge{
  int v;
  weight_t w;
};

//returns which vertex come in. -1 if root.
vector<int> minimum_spanning_arborescence(const vector<vector<edge> > &G,int root){
  const int N=G.size();
  vector<int> prev(N,-1),weight(N,INF);
  for(int i=0;i<N;i++){
    for(auto e:G[i]){
      if(e.v!=root&&e.w<weight[e.v]){
	weight[e.v]=e.w;
	prev[e.v]=i;
      }
    }
  }
  vector<int> check(N,N);
  int cycle_len=0;
  vector<char> in_cycle(N);
  for(int i=0;i<N;i++){
    for(int j=i;j>=0;){
      if(check[j]<i)break;
      if(check[j]==i){
	for(int k=j;;){
	  cycle_len++;
	  in_cycle[k]=true;
	  k=prev[k];
	  if(k==j)goto found;
	}
      }
      check[j]=i;
      j=prev[j];
    }
  }
  return prev;
 found:
  int nN=N-cycle_len+1;
  vector<int> newv(N),oldv(N);
  for(int i=0,idx=0;i<N;i++){
    if(!in_cycle[i]){
      oldv[idx]=i;
      newv[i]=idx++;
    }else{
      newv[i]=nN-1;
    }
  }
  vector<vector<edge> > nG(nN);
  vector<int> in(N,-1),out(N,-1);
  vector<weight_t> in_val(N,INF),out_val(N,INF);
  for(int i=0;i<N;i++){
    for(auto e:G[i]){
      int nc=e.w-weight[e.v];
      if(!in_cycle[i]){
	if(!in_cycle[e.v]){
	  nG[newv[i]].push_back({newv[e.v],nc});
	}else{
	  if(nc<in_val[i]){
	    in_val[i]=nc;
	    in[i]=e.v;
	  }
	}
      }else{
	if(!in_cycle[e.v]){
	  if(nc<out_val[e.v]){
	    out_val[e.v]=nc;
	    out[e.v]=i;
	  }
	}
      }
    }
  }
  for(int i=0;i<N;i++){
    if(in_val[i]<INF){
      nG[newv[i]].push_back({nN-1,in_val[i]});
    }
    if(out_val[i]<INF){
      nG[nN-1].push_back({newv[i],out_val[i]});
    }
  }
  auto r=minimum_spanning_arborescence(nG,newv[root]);
  vector<int> rv(N);
  for(int i=0;i<nN-1;i++){
    if(r[i]<0){
      rv[oldv[i]]=r[i];
    }else if(r[i]<nN-1){
      rv[oldv[i]]=oldv[r[i]];
    }else{
      rv[oldv[i]]=out[oldv[i]];
    }
  }
  int v_into_cycle=oldv[r[nN-1]];
  int v_in_cycle=in[v_into_cycle];
  rv[v_in_cycle]=v_into_cycle;
  int x=prev[v_in_cycle];
  for(int i=0;i<cycle_len-1;i++){
    rv[x]=prev[x];
    x=prev[x];
  }
  return rv;
}

int main(){
  int V,E,r;
  cin>>V>>E>>r;
  vector<vector<edge> > G(V);
  for(int i=0;i<E;i++){
    int s,t,w;
    cin>>s>>t>>w;
    G[s].push_back({t,w});
  }
  auto msa=minimum_spanning_arborescence(G,r);
  for(auto e:msa){
    //    cout<<e<<endl;
  }
  int ans=0;
  for(int i=0;i<G.size();i++){
    for(auto e:G[i]){
      if(msa[e.v]==i){
	ans+=e.w;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
/*bool cmp(vector<int>:: iterator it1,vector<int>:: iterator it2)
{
    if(*it1>*it2)
    return true;
    else
    return false;
}*/
/*bool cmp(int a, int b)
{
    if(abs(a)>abs(b))
    return true;
    else
    return false;
}*/
/*ll int gcd(ll int a,ll int b)
{
    if(a==0)
    return b;
    else return gcd(b%a,a);
}*/
/*bool cmp(pair<int,int> p1,pair<int,int> p2)
{
    if(p1.first<=p2.first)
    return true;
    else
    return false;
}*/
/*
ll int dcount(ll int n)
{
    if(mp[n])
    return mp[n];
    ll int ct=1;
    for(ll int i=2;i<=n;i++)
    {
        if(n%i==0)
        ct++;
    }
    mp[n]=ct;
    return ct;
}*/
/*bool equ(string s)
{   if(s.length()==1)
return true;
    for(int i=0;i<s.length()-1;i++)
    {
        if(s[i]!=s[i+1])
        return false;
    }
    return true;
}*/
int main() {
    
    // For getting input from input.txt file 
   //freopen("input.txt", "r", stdin); 
    // Printing the Output to output.txt file 
  // freopen("output.txt", "w", stdout); 
  string s;
  cin>>s;
  if(s[s.length()-1]=='s')
  cout<<s<<"es"<<"\n";
  else
  cout<<s<<'s'<<"\n";
return 0;
}

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

int main(){
	int64_t k;
	cin >> k;
	int n = 50;
	cout << n << endl;
	int64_t a[n];
	for(int i = 0; i < n; i++) a[i] = i + k / n;
	for(int i = 0; i < k % n; i++){
		a[i] += n;
		for(int j = 0; j < 50; j++) if(i != j) a[j]--;
	}
	for(int i = 0; i < 50; i++) cout << a[i] << ' ';
	return 0;
}


Measured memory_bytes: 256
let () =
    let main () =
        let n = int_of_string (read_line ()) in
        let k = if n < 10 then n else
                if n < 1000 then 9 + max 0 (n - 99) else
                if n < 100000 then 909 + max 0 (n - 9999) else
                    90909
        in
        Printf.printf "%d\n" k
    in
    main ()

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

int main(int argc, char **argv)
{
    ll a, b, k;
    cin >> a >> b >> k;
    ll ca = 0;
    ll cb = 0;
    // cout << boost::format("lcm(%d,%d)=%d\n") % a % b % lcm(a,b);
    // cout << boost::format("gcd(%d,%d)=%d\n") % a % b % gcd(a,b);
    if (k > a)
    {
        ca = 0;
        k -= a;
        cb = b - k > 0 ? b - k : 0;
    }
    else
    {
        ca = a - k;
        cb = b;
    }
    cout << ca << " " << cb << endl;
}


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

using namespace std;
const int MAXN = 100010;

int n;

namespace Tree {
	int head[MAXN], nxt[MAXN<<1], to[MAXN<<1], eidx = 0;
	void init() {
		memset( head, -1, sizeof(head) );
	}
	void adde( int u, int v ) {
		to[eidx] = v, nxt[eidx] = head[u], head[u] = eidx++;
		to[eidx] = u, nxt[eidx] = head[v], head[v] = eidx++;
	}
}

void input() {
	scanf( "%d", &n );
	Tree::init();
	for( int i = 0; i < n-1; ++i ) {
		int u, v;
		scanf( "%d%d", &u, &v );
		Tree::adde(u, v);
	}
}

void dfs( int u, int fa, int d, int *dis ) {
	using namespace Tree;
	dis[u] = d;
	for( int i = head[u]; ~i; i = nxt[i] ) {
		int v = to[i];
		if( v == fa ) continue;
		dfs(v, u, d+1, dis);
	}
}

int dis1[MAXN], disn[MAXN];
int disu[MAXN], disv[MAXN];
void solve() {
	dfs(1, 0, 0, dis1);
	dfs(n, 0, 0, disn);
	int u = 1, v = n;
	for( int i = 1; i <= n; ++i )
		if( dis1[i] + disn[i] == dis1[n] ) {
			if( dis1[i] <= disn[i] && dis1[i] > dis1[u] )
				u = i;
			if( dis1[i] > disn[i] && disn[i] > disn[v] )
				v = i;
		}
	memset( disu, 0, sizeof(disu) );
	memset( disv, 0, sizeof(disv) );
	dfs(u, v, 1, disu);
	dfs(v, u, 1, disv);
	int cntu = 0, cntv = 0;
	for( int i = 1; i <= n; ++i )
		if( disu[i] ) ++cntu;
		else ++cntv;
	puts( cntu > cntv ? "Fennec" : "Snuke" );
}

int main() {
	input(), solve();
	return 0;
}


Measured memory_bytes: 8448
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long ll;
#define print(x) cout<<(x)<<endl


#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


// DONT USE "int", USE "ll" !!!!!!!!!!!!
int main() {
	int N;
	cin >> N;
	ll l0 = 2; ll l1 = 1;
	ll out = l1;

	for (int i = 0; i+1 < N; i++) {
		out = l0 + l1;
		l0 = l1;
		l1 = out;
	}
	print(out);






	return 0;
}

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

typedef pair<int, int>pi;

int main()
{
    int n;
    int v[100005];
    pi u[2][100005] = {};
    int cnt = 0;
    int ans = 0;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> v[i];

        u[i % 2][v[i]].first++;
        u[i % 2][v[i]].second = v[i];
    }

    sort(u[0], u[0] + 100005, greater<pi>());
    sort(u[1], u[1] + 100005, greater<pi>());

    int i = 0;
    while (u[0][i].second == u[1][0].second) i++;
                                                 
    int j = 0;
    while (u[0][0].second == u[1][j].second) j++;

    cout << min((n / 2 - u[0][i].first) + (n / 2 - u[1][0].first),
                (n/2 - u[0][0].first) + (n / 2 - u[1][j].first)) << endl;

    return 0;
}


Measured memory_bytes: 2176
from itertools import accumulate
def gen_prime(n):
    seq = list(range(2, n))
    while len(seq) > 0:
        prime = seq.pop(0)
        yield prime
        if n ** 0.5 >= prime:
            seq = [i for i in seq if not i % prime == 0]


N = 10 ** 5
primes = list(gen_prime(N + 1))
is_prime = [False] * (N + 1)
for i in primes:
    is_prime[i] = True

n_2017 = [is_prime[i] and is_prime[(i + 1) // 2] for i in range(0, N + 1)]
sum_n = list(accumulate(n_2017))
#%% query
Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(sum_n[r] - sum_n[l - 1])

Measured memory_bytes: 9240
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] s = new int[M];
    int[] c = new int[M];
    for(int i=0; i<M; i++){
      s[i] = sc.nextInt();
      c[i] = sc.nextInt();
    }
    int[] num = new int[N];
    for(int i=0; i<N; i++){
    	num[i] = 10;
    }
    int ans = 0;
    int numInt = 0;
    boolean isTrue = true;
    for(int i=0; i<M; i++){
      int keta = s[i] - 1; //いじる桁 0-2 配列走査するので-1
      if(num[keta] != 10 && num[keta] != c[i]){
          isTrue = false;
          break;
      } else{
        num[keta] = c[i];
      }
    }
     if(N != 1 && num[0] == 0) isTrue = false;
     for(int i=0; i<N; i++){
        if(num[i] == 10) num[i] = 0; 
     }
     
     if(isTrue == false) {ans = -1;}
     else{
        if( N > 1 && num[0] == 0) num[0] = 1;
		if(N == 3){
          ans = num[0] * 100 + num[1] * 10 + num[2];
        } else if(N == 2){
          ans = num[0] * 10 + num[1]; 
        } else ans = num[0];
     }
 
    System.out.println(ans); 
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
const ll mod = 1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = a; i >= (b); --i)
#define all(x) x.begin(), x.end()
#define pb  push_back
#define mb  make_pair
#define itn int
#define fi first
#define se second

void solve()
{
    ll s, w;
    cin >> s >> w;
    if(w >= s)
    {
        cout << "unsafe";
    }
    else
        cout << "safe";
}

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

	solve();
	return 0;
}


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

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int d8x[8] = {0,1,1,1,0,-1,-1,-1};
int d8y[8] = {1,1,0,-1,-1,-1,0,1};

int m[55][55];
int w,h;

void dfs(int i, int j){
	m[i][j] = 0;
	rep(c,8){
		int dy = i+d8y[c], dx = j+d8x[c];
		if(1<=dx && dx<=w && 1<=dy && dy<=h && m[dy][dx] == 1){
			dfs(dy,dx);
		}
	}
	return ;
}

int main(){
	while(true){
		int ans = 0;
		cin>>w>>h;
		if(w == 0 && h == 0)break;
		REP(i,h)REP(j,w)cin>>m[i][j];
		REP(i,h)REP(j,w){
			if(m[i][j] == 1){
				++ans;
				dfs(i,j);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 1000000007
#define INF ((1LL<<62LL) - 1)

int mul(int a, int b){
    return (a*b)%M;
}

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

    int n; cin >> n;
    int x = 1;
    for(int i=1;i<=n;i++) x = mul(x, 10LL);

    int y = 2;
    for(int i=1;i<=n;i++) y = mul(y, 9LL);

    int z = 1;
    for(int i=1;i<=n;i++) z = mul(z, 8LL);

    int ans = (x - y + z)%M;
    ans+=M;
    ans%=M;

    cout << ans << "\n";

}


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

int n;
vector<int> x, y;
vector<char> dir;

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

// l:左にくるdirection
// r:右にくるdirection
int collision_time(char l, char r, function<int(int, int)> group, function<int(int, int)> eval,
                   function<int(int)> dist) {
    int res = INT_MAX;
    map<int, set<int>> intercepts;
    for (int i = 0; i < n; i++) {
        if (dir[i] == r) {
            intercepts[group(x[i], y[i])].insert(eval(x[i], y[i]));
        }
    }
    for (int i = 0; i < n; i++) {
        if (dir[i] == l) {
            auto right = intercepts[group(x[i], y[i])].upper_bound(eval(x[i], y[i]));
            if (right != intercepts[group(x[i], y[i])].end()) {
                chmin(res, dist(*right - eval(x[i], y[i])));
            }
        }
    }
    return res;
}

int main() {
    cin >> n;
    x.resize(n);
    y.resize(n);
    dir.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> dir[i];
    }
    int res = INT_MAX;
    auto gr_45 = [](int x, int y) { return y - x; };
    auto gr_135 = [](int x, int y) { return y + x; };
    auto gr_0 = [](int x, int y) { return y; };
    auto gr_90 = [](int x, int y) { return x; };
    auto eval_x = [](int x, int y) { return x; };
    auto eval_y = [](int x, int y) { return y; };
    auto mul_5 = [](int d) { return d * 5; };
    auto mul_10 = [](int d) { return d * 10; };
    chmin(res, collision_time('U', 'L', gr_45, eval_x, mul_10));
    chmin(res, collision_time('R', 'D', gr_45, eval_x, mul_10));
    chmin(res, collision_time('R', 'U', gr_135, eval_x, mul_10));
    chmin(res, collision_time('D', 'L', gr_135, eval_x, mul_10));
    chmin(res, collision_time('R', 'L', gr_0, eval_x, mul_5));
    chmin(res, collision_time('U', 'D', gr_90, eval_y, mul_5));
    if (res == INT_MAX) {
        cout << "SAFE" << endl;
    } else {
        cout << res << endl;
    }
}

Measured memory_bytes: 32620
#include<bits/stdc++.h>
using namespace std;
 
typedef    long long          ll;
typedef    vector<long long>    vi; 
typedef    vector<vi>         vvi; 
typedef    pair<long,long>      ii; 
#define    sz(a)              long((a).size()) 
#define    pb                 push_back 
#define    mp                   make_pair
#define    all(c)             (c).begin(),(c).end() 
#define    tr(c,i)            for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define    present(c,x)       ((c).find(x) != (c).end()) 
#define    cpresent(c,x)      (find(all(c),x) != (c).end())  
#define    input(v,n)           for(ll i = 0 ; i<n ; i++) cin>>v[i]
#define    output(v,n)          for(ll i = 0 ; i<n ; i++) cout<<v[i]<<" "
#define    ff           first
#define    ss           second

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

    ll d,t,s;
    cin>>d>>t>>s;
    ll dd = t*s;
    if(dd<d)
    {
      cout<<"No";
    }
    else {
      cout<<"Yes";
    }

  return 0;
}

Measured memory_bytes: 3612
'use strict'

const main = input => {
	const args = input.split('\n').map(t => t.split(' '))
	const n = parseInt(args[0][0], 10)
	const t = parseInt(args[0][1], 10)
	const rows = args.slice(1, n + 1)
	let ans = Infinity
	
	for (let i = 0; i < n; i++) {
		const _c = parseInt(rows[i][0], 10)
		const _t = parseInt(rows[i][1], 10)
		if (_t > t) continue
		ans = Math.min(ans, _c)
	}

	if (ans === Infinity) console.log('TLE')
	else console.log(ans)
}

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


Measured memory_bytes: 21064
var lines = [];
var B_counter, S, H, W
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    A = Number(lines[0].split(" ")[0]);
    B = Number(lines[0].split(" ")[1]);
    C = Number(lines[0].split(" ")[2]);
    X = Number(lines[0].split(" ")[3]);
    Y = Number(lines[0].split(" ")[4]);

    // 戦略として，
    // 1. A,Bピザのみ買う
    // 2. ABピザをMath.min(2*A,2*B)枚購入し，残りをA or Bピザを購入する
    // 3. ABピザのみ買う

    // 上記のどちらかが金額最小だと思う

    var a = A * X + B * Y;
    var b = Math.min(2 * X, 2 * Y) * C; b += (X < Y ? B * (Y - X) : A * (X - Y))
    var c = Math.max(2 * X, 2 * Y) * C

    console.log(Math.min(a, b, c));
});

Measured memory_bytes: 7628
import Data.List
import Data.List.Split

main = interact $ unlines.map (handCheck.map read.splitOn ",").lines
handCheck cards
    | isFourCard cards = "four card"
    | isFullHouse cards = "full house"
    | isStraight cards  = "straight"
    | isThreeCard cards = "three card"
    | isTwoPair cards   = "two pair"
    | isOnePair cards   = "one pair"
    | otherwise         = "null"

isFourCard cds = 4 == (maximum.map length.group.sort $ cds)
isFullHouse cds = 2 == (length.group.sort $ cds)
isStraight cds = case mincds of
                   1 -> [mincds..mincds+4] == scds || (tail scds) == [10..13]
                   otherwise -> [mincds..mincds+4] == scds
                   where scds = sort cds
                         mincds = head scds
isThreeCard cds = 3 == (maximum.map length.group.sort $ cds)
isTwoPair cds = 3 == (length.group.sort $ cds)
isOnePair cds = 2 == (maximum.map length.group.sort $ cds)

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

int main(){
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    int xi[n], yi[m];
    for(int i=0;i<n;i++)
        cin>>xi[i];
    for(int i=0;i<m;i++)
        cin>>yi[i];
    sort(xi,xi+n);
    sort(yi,yi+m);
    for(int i=x+1;i<=y;i++){
        if(i>xi[n-1] && i<=yi[0]){
            cout<<"No War";
            return 0;
        }
    }
    cout<<"War";
    return 0;
}


Measured memory_bytes: 256
/* -*- C -*- */

#include <stdio.h>


area(int x,int y){
    return x*y;
}

perimeter(int x,int y){
    return 2*x+2*y;
}

int main()
{
    int length,breadth;

    scanf("%d %d",&length,&breadth);
    while(length<1 || breadth>100){
            scanf("%d %d",&length,&breadth);
    }
    
    printf("%d %d\n",area(length,breadth),perimeter(length,breadth));
    
    return 0;
}

Measured memory_bytes: 1860