akhauriyash/Code-Regression huggingface dataset:
def resolve():
    # 最長の辺の長さ < 他の辺の長さの合計 で三角形
    N = int(input())
    lines = map(int, input().split())
    #N = 100
    #from random import randint
    #lines = [randint(1, 10 ** 9) for x in range(N)]
    from itertools import combinations
    count = 0
    for c in combinations(lines, 3):
        if len(set(c)) != 3:
            continue
        if max(c) < sum(c)-max(c):
            count += 1
    print(count)
resolve()

Measured memory_bytes: 73948
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define INF 1000000000001
#define se second
#define mod 1000000007
int main()
{
	
	ll x,n,ans;
	cin>>x>>n;
	ll a[n];
	map<ll,ll> ma;
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		ma[a[i]]++;
	}
	ll j=0;
	while(1)
	{
		if(ma[x-j]==0)
		{
			ans=x-j;
			break;
		}
		else if(ma[x+j]==0)
		{
			ans=x+j;
			break;
		}
		else
		{
			j++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long int
#define dbg(x) cout<<"( "<<#x<<" -> "<<x<<" )"<<endl;
using namespace std;
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if (a+b+c>=22)
    printf("bust\n");
    else
    printf("win\n");
    return 0;
}

Measured memory_bytes: 3660
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int s[n+1],i,sum=0,min=1000;
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
    sum+=s[i];
    if(min>s[i] && s[i]%10!=0)
      min=s[i];
  }
  if(sum%10==0 && min==1000)
    printf("%d\n",0);
  else if(sum%10==0)
    printf("%d\n",sum-min);
  else
    printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 1688
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n;
    cin >> n;
    ll l, r;
    cin >> l >> r;
    rep(i, n-1){
        ll t, a;
        cin >> t >> a;
        if(l <= t && r <= a)l =t, r = a;
        else {
            ll x , y;
            x = l/t, y = r/a;
            if(l%t!=0)x++;
            if(r%a!=0)y++;
            l = t*max(x, y), r = a*max(x, y);
        }
    }
    cout << l+r << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
constexpr ll mod=1e9+7;
ll mpow(ll x, ll n){ //x^n(mod) ←普通にpow(x,n)では溢れてしまうため，随時mod計算 2分累乗法だから早い
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}
ll inv_mod(ll a){return mpow(a,mod-2);}
class Factorial{//階乗とその逆元を求めて計算に利用するクラス
 private:
    vector<ll> fac;
    vector<ll> ifac;
 public:
    
    Factorial(ll N){
        fac.push_back(1);
        REP(i,N) fac.push_back(fac[i]*(i+1)%mod);
        ifac.resize(N+1);
        ifac[N]=inv_mod(fac[N]);
        REP(i,N) ifac[N-1-i]=(ifac[N-i]*(N-i))%mod;
    }

    ll fact(ll a){return fac[a];}
    ll ifact(ll a){return ifac[a];}

    ll cmb(ll a,ll b){
        if(a==0&&b==0) return 1;
        if(a<b||a<0||b<0) return 0;
        ll tmp =ifact(a-b)*ifact(b)%mod;
        return tmp*fac[a]%mod;
    }
    ll per(ll a,ll b){
        if(a==0&&b==0) return 1;
        if(a<b||a<0||b<0) return 0;
        return fac[a]*ifac[a-b]%mod;
    }
};
int main(){
    int N,K;
    cin>>N>>K;
    Factorial get(2001);
    REP(i,K){
        if(N==K) cout<<(i?0:1)<<endl;
        else cout<<get.cmb(K-1,i)*
             ((get.cmb(N-K-1,i+1)+2*get.cmb(N-K-1,i)+get.cmb(N-K-1,i-1))%mod)%mod<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
const int mod = 1000 * 1000 * 1000 + 7;
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;
 
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;
 
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int a[105];

int main(){
   ll n,k;
   cin>>n>>k;
   if(n%k==0)
      return cout<<0<<endl,0;
   cout<<min(k-(n%k),n)<<endl;
   return 0;
}

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,d,a,ans=0;
	cin>>n>>d>>a;
	vii vs(n);
	for(int i=0;i<n;++i){
		cin>>vs[i].ff>>vs[i].ss;
	}
	sort(all(vs));
	ll s=0;
	queue<ii> q;
	for(int i=0;i<n;++i){
		while(!q.empty() && q.front().ff <vs[i].ff){
			s-=q.front().ss;q.pop();
		}
		vs[i].ss=max(0LL,vs[i].ss-s);
		ll k = (vs[i].ss+a-1)/a;
		ans+=k;
		s+=a*k;
		q.push({vs[i].ff+2*d,a*k});
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6656
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<set>
#include<tuple>
using namespace std;

int abc109_b(){
    // 入力
    int n;
    cin >> n;
    vector<string> v;
    set<string> st;
    for (int i=0; i<n; ++i) {
        string a;
        cin >> a;
        v.push_back(a);
        st.insert(a);
    }
    
    //処理
    if(v.size() != st.size()){
        cout << "No" << endl;
        return 0;
    }
    for(int i=0 ; i<n-1 ; ++i){
        string str1 = v[i];
        string str2 = v[i+1];
        string laststr1 = str1.substr(str1.length()-1,1);
        string firststr2 = str2.substr(0,1);
        if(laststr1 != firststr2){
            cout << "No" << endl;
			return 0;
        }
    }
    
    //出力
    cout << "Yes" << endl;
    return 0;
}

int main() {
    abc109_b();
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Arrays;
import java.util.Collections;


public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String in[] = br.readLine().split(" ");
		Long arr[] = new Long[n];
		Long backward = 0L, forward = 0L;
		HashMap<Long, Long> map = new HashMap<>();
		for(int i=0;i<n;i++) {
		    arr[i] = Long.parseLong(in[i]);
		    backward += arr[i];
		}
		Long temp = 0L;
		Long ans = 10000000000007L ;
		for(int i=0; i<n-1; i++) {
		    forward += arr[i];
		    backward -= arr[i];
		    if(forward >= backward) {
		        temp = forward - backward;
		    }
		    else {
		        temp = backward - forward;
		    }
		    ans = Math.min(ans, temp);
		    
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 65148
using System;
using System.Linq;

namespace AtCoder
{
    class Program2
    {

        static void Main(string[] args)
        {
            var valores = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();

            int ovejas = valores[0];
            int lobos = valores[1];

            if (lobos >= ovejas)
                Console.WriteLine("unsafe");
            else
                Console.WriteLine("safe");
        }
    }
}

Measured memory_bytes: 28240
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(int N,L;cin>>N>>L,N;){
    const int UOT=86400;
    int ws[UOT]={};
    double l=0,h=1e7;
    for(int i=0;i<N;i++){
      int s,t,u;
      cin>>s>>t>>u;
      for(;s<t;s++){
	ws[s]=u;
	l+=u*1./UOT;
      }
    }
    for(int i=0;i<99;i++){
      double m=(l+h)/2;
      double lb=0,ht=0;
      double sh=L;
      for(int j=0;j<UOT;j++){
	ht+=-ws[j]+m;
	if(ht<0){
	  lb+=-ht;
	  sh+=ht;
	  ht=0;
	}
	ht=min<double>(ht,L);
	sh=min(sh,L-ht);
      }
      if(sh>=0&&lb<=L&&lb<=ht){
	h=m;
      }else{
	l=m;
      }
    }
    cout.precision(9);
    cout<<fixed<<l<<endl;
  }
}

Measured memory_bytes: 1568
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
char s[333];
int n,m,k,now,a[333][333],ans[333][333],S,c[333];
int main(){
	cin>>n>>m>>k;
	FOR(i,1,n){
		scanf("%s",s+1);
		FOR(j,1,m) a[i][j]=(s[j]=='#');
	}
	FOR(i,1,n) FOR(j,1,m) c[i]+=a[i][j];
	FOR(i,1,n) if (c[i]>0){S=i;break;}
	FOR(i,S,n)
		if (c[i]>0){
			++now;
			int t=0;
			FOR(j,1,m){
				if (a[i][j]){++t;if (t!=1) ++now;}
				ans[i][j]=now;
			}
		}
		else{
			FOR(j,1,m) ans[i][j]=ans[i-1][j];
		}
	FORD(i,S-1,1) FOR(j,1,m) ans[i][j]=ans[i+1][j];
	FOR(i,1,n){
		FOR(j,1,m) printf("%d ",ans[i][j]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 1536
#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;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=305,mod=1e9+7;
int n,m,l[N],r[N],x[N],dp[N][N][N];
vi v[N];
int fun(int ind,int red,int blue,int green)
{
  if(ind==n+1) return 1;
  if(dp[red][blue][green]!=-1) return dp[red][blue][green];
  int ans=0;
  bool ok=true;
  //give red
  for(int idx:v[ind])
    {
      int l1=l[idx],r1=r[idx],x1=x[idx],cnt=1;
      if(blue>=l1 && blue<=r1) cnt++;
      if(green>=l1 && green<=r1) cnt++;
      if(cnt!=x1) ok=false;
    }
  if(ok) ans=fun(ind+1,ind,blue,green);
  //give blue
  ok=true;
  for(int idx:v[ind])
    {
      int l1=l[idx],r1=r[idx],x1=x[idx],cnt=1;
      if(red>=l1 && red<=r1) cnt++;
      if(green>=l1 && green<=r1) cnt++;
      if(cnt!=x1) ok=false;
    }
  if(ok) ans=(ans+fun(ind+1,red,ind,green))%mod;
  //give green
  ok=true;
  for(int idx:v[ind])
    {
      int l1=l[idx],r1=r[idx],x1=x[idx],cnt=1;
      if(red>=l1 && red<=r1) cnt++;
      if(blue>=l1 && blue<=r1) cnt++;
      if(cnt!=x1) ok=false;
    }
  if(ok) ans=(ans+fun(ind+1,red,blue,ind))%mod;
  return dp[red][blue][green]=ans;
}
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  memset(dp,-1,sizeof(dp));
  cin>>n>>m;
  rep(i,1,m+1) cin>>l[i]>>r[i]>>x[i],v[r[i]].pb(i);
  cout<<fun(1,0,0,0)<<endl;
  return 0 ;
}


Measured memory_bytes: 111104
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;



int main(){
    int r;
    cin >> r;
    cout<<3*r*r<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
  
int a[8]={},b[8]={},c[15]={},d[15]={},ans[8][8]={};
void dfs(int);
  
int main(){
  int n,r,c1;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>r>>c1;
    ans[r][c1]=1;
  }
  dfs(0);
  return 0;
}
void dfs(int x){
  if(x==8){
  for(int i=0;i<8;i++)
    for(int j=0;j<8;j++)
      if(ans[i][j]==1)
    if(a[i]!=j)return;
  
  for(int i=0;i<8;i++){
    for(int j=0;j<8;j++)
      if(a[i] == j)cout<<'Q';
      else cout<<'.';
    cout<<endl;
  }
    return;
  }
  
  for(int i=0;i<8;i++){
    if(b[i]==1||c[x+i]==1||d[x-i+7]==1)continue;
    a[x]=i;
    b[i]=c[x+i]=d[x-i+7]=1;
    dfs(x+1);
    a[x]=b[i]=c[x+i]=d[x-i+7]=0;
  }
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

vector<string> yui;

void kyoko(string st)
{
    yui.pb(st);
    sort(all(yui)); 
    auto res = unique(all(yui));
    yui.erase(res, yui.end());
    if (yui.size() > 7) {
        yui.erase(yui.begin() + 7, yui.end());
    }
}

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

    string st; cin >> st;
    Int(k);

    Rep(i, 6) {
        rep(j, st.size()) {
            string tmp = st.substr(j, i);
            kyoko(tmp);
        }
    }

    cout << yui[k-1] << endl;

    return 0;
}




Measured memory_bytes: 256
import itertools
n = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

N = [i for i in range(1,n+1)]

N_dict = {v:(i+1) for i,v in enumerate(itertools.permutations(N, n))}
#print(N_dict)

print(abs(N_dict[P] - N_dict[Q]))

Measured memory_bytes: 16148
# cook your dish here
n  =  int(input())
a= list(map(int,input().split()))

a.sort()
ass = []
ans  =[]
d = 0

for i in range(n-1):
    if a[i] == a[i+1]:
        ass.append(a[i])
        d += 1
        if d == 3:
            ans.append(a[i])
    else:
        d = 0
ass = list(set(ass))
ass.sort()

if ans != []:
    if max(ans)==max(ass):
        print(max(ans)*max(ans))
    else:
        print(ass[len(ass)-1]*ass[len(ass)-2])
else:
    if len(ass) == 0 or len(ass) == 1:
        print(0)
    else:
        print(ass[len(ass)-1]*ass[len(ass)-2])

Measured memory_bytes: 14864
#include<iostream>
#include<vector>
#include<set>
#include<string>

using namespace std;

int n,m;
vector<int> came;
string str[11];
set<string> ans;

void serch(int loop,string sans)
{
	if(loop==m)
	{
		ans.insert(sans);
		return ;
	}
	
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<came.size();j++)
		{
			if(i==came[j])
			{
				i++;
				j=-1;
			}
		}
		if(i==n)
			break;
		came.push_back(i);
		serch(loop+1,sans+str[i]);
		came.pop_back();
	}
	return ;
}

int main()
{
	int i,j;
	for(;;)
	{
		cin >> n >> m ;
		if(n==0 && m==0)
			break;
		
		ans.clear();
		
		for(i=0;i<n;i++)
			cin >> str[i] ;
		
		serch(0,"");
		
		cout << ans.size() << endl;
	}
}

Measured memory_bytes: 0
require 'prime'
q = gets.chomp.to_i
l, r = q.times.map{gets.split.map(&:to_i)}.transpose

MAX = 10**5
a = Array.new(MAX+1, false)

1.upto(MAX).each do |i|
  a[i] = i.prime? && ((i+1)/2).prime?
end

dp = Array.new(MAX+1)
dp[0] = 0
1.upto(MAX).each do |i|
  dp[i] = dp[i-1]
  dp[i] += 1 if a[i]
end

l.zip(r).each do |l, r|
  puts dp[r] - dp[l-1]
end

Measured memory_bytes: 15356
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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 int INF = 100000000;
int ten(int n){
    if(n == 0){
        return 1;
    }
    return ten(n-1)*10;
}
int main(){
    int n, m;
    cin >> n >> m;
    vector<int> s(m), c(m);
    for(int i = 0; i < m; i++){
        cin >> s[i] >> c[i];
    }
    for(int i = 0; i < m; i++){
        if(n != 1 && s[i] == 1 && c[i] == 0){
            cout << -1 << endl;
            return 0;
        }
    }
    for(int i = 0; i < m; i++){
        for(int j = i+1; j < m; j++){
            if(s[i] == s[j]){
                if(c[i] != c[j]){
                    cout << -1 << endl;
                    return 0;
                }else{
                    c[j] = 0;
                }
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < m; i++){
        ans += c[i] * ten(n-s[i]);
    }

    if(ans >= ten(n-1)){
        cout << ans << endl;
    }else{
        if(n >= 2){
            ans = ten(n-1) + ans;
            cout << ans << endl;
        }else{
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>

#define MAXN 1005
#define MOD 1000000007

using namespace std;

char mat[MAXN][MAXN];
int dp[MAXN][MAXN];

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

    memset(dp, -1, sizeof(dp));

    int h, w;
    cin >> h >> w;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> mat[i][j];
        }
    }
    for(int y = 0; y < h; y++) {
        for(int x = 0; x < w; x++) {
            if(y == 0 && x == 0) dp[y][x] = 1;
            else if(mat[y][x] == '#') dp[y][x] = 0;
            else if(y == 0) dp[y][x] = dp[y][x - 1];
            else if(x == 0) dp[y][x] = dp[y - 1][x];
            else dp[y][x] = (dp[y - 1][x] + dp[y][x - 1]) % MOD;
        }
    }
    cout << dp[h - 1][w - 1] << '\n';

    return 0;
}

Measured memory_bytes: 8572
#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 long long int ll;
typedef pair<ll,ll> pp;
typedef long double ld;
typedef vector<pp> vpl;
//typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 

 
const ll N = 1000004;
const ll mod = 998244353;
const long long int inf = 10000000000;

#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++) 
#define mtrace(i,a) for(auto i=a.begin();i!=a.end();i++)  cout<<i->first<<" "<<i->second<<endl;   
 
const ld pi = 3.14159265359;

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

 
void fastIO(void);
void decimal(int);
inline ll modmulti(ll, ll);
inline ll modadd(ll, ll);
ll modpower(ll, ll);
ll gcd(ll, ll );
ll modinv(ll);




int main(){
	fastIO();
	ll a,b;
	cin>>a>>b;
	if(b>=a) cout<<"unsafe\n";
	else cout<<"safe\n";
}
	


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
inline ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
inline ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a){
   return modpower(a,mod-2);
}

Measured memory_bytes: 3600
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int main(){
  int k;
  cin >> k;
  int even = k / 2;
  int odd = k - even;
  cout << even * odd;
  return 0;
}


Measured memory_bytes: 256
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       mut N: usize,
       a: [usize;N+1],
    }
    N += 1;
    if a[0] > 1 {
        echo!(-1);
        return;
    }

    let mut tmp = vec![(0, 0); N];
    tmp[0] = (1, 1);
    tmp[N - 1] = (a[N - 1], a[N - 1]);
    for i in (1..N - 1).rev() {
        let b = a[i];
        let (c, d) = tmp[i + 1];
        let e = (c + 1) / 2 + b;
        let f = d + b;
        tmp[i] = (e, f);
    }
    mydbg!(tmp);
    let mut ans = vec![0; N];
    ans[0] = 1;
    for i in 1..N {
        let b: usize = ans[i - 1];
        let (c, d) = tmp[i];
        if b.saturating_sub(a[i - 1]) * 2 < c {
            echo!(-1);
            return;
        }
        let e = min((b - a[i - 1]) * 2, d);
        let f = max(c, e);
        ans[i] = f;
    }

    mydbg!(ans);
    echo!(ans.iter().fold(0, |a, x| a + x));
}


Measured memory_bytes: 5932
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n; string s; cin >> n >> s;
    int ans = 0;
    REP(i, s.size() - 2){
        if(s.substr(i, 3) == "ABC") ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
K = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
m = int(input())

print(K[m-1])

Measured memory_bytes: 2940
num = int(input())
num_list = list(map(int,input().split()))

sum = 0
for i in range(0,num):
  sum = sum + num_list[i]
  
p = int(round(sum/num,0))

ans = 0
for i in range(0,num):
  ans = ans + (p-num_list[i])**2
  
print(ans)

Measured memory_bytes: 3064
n = gets.to_i
a = gets.split.map(&:to_i)
result = []

if n.odd?
  middle = a.delete_at(0)
end

a.length.times do |i|
  if i.odd?
    result.unshift(a[i])
  else
    result.push(a[i])
  end
end

if middle
  result.insert(n / 2, middle)
end

puts result.join(' ')


Measured memory_bytes: 25440
using System;
namespace q1
{
  class q2
  {
    static void Main()
    {
      int[] kosuu = new int[2];
      string[] kosuumae = Console.ReadLine().Split();
      kosuu[0] = int.Parse(kosuumae[0]);
      kosuu[1] = int.Parse(kosuumae[1]);
      string[] nedanmae = Console.ReadLine().Split();
      int[] nedan = new int[kosuu[0]];
      for (int x = 0;x < kosuu[0];x++)
      {
        nedan[x] = int.Parse(nedanmae[x]);
      }
      Array.Sort(nedan);
      int z = 0;
      for (int xx = 0;xx < kosuu[1];xx++)
      {
        z = z + nedan[xx];
      }
      Console.WriteLine(z);
    }
  }
}


Measured memory_bytes: 27652
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  string S;
  cin >> S;
  int N = S.size();
  vector<int> cnt(2019);
  ll tmp = 0;
  ll pow = 1;
  ll ans = 0;
  cnt[0] = 1;
  rrep(i, N) {
    (tmp += int(S[i]-'0') * pow) %= 2019;
    ans += cnt[tmp];
    cnt[tmp]++;
    (pow *= 10) %= 2019;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3720
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>

using namespace std;
long long dp[11];
int r,d,x;

void solve(){
    dp[0] =x;
    for(int i=1;i<=10;i++){
        dp[i] = r*dp[i-1] -d;
    }
    for(int i=1;i<=10;i++){
        cout << dp[i] << endl;
    }
}

int main(){
    cin >> r >> d >> x;
    solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int K,S;
  cin>>K>>S;
  int ans=0;
  for(int i=0;i<=K;i++){
  for(int j=0;j<=K;j++){
  if(0<=S-i-j && S-i-j<=K)
    ans++;
  }
  }cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
 
if __FILE__ == $0
  while line = STDIN.gets
    tokens = line.chomp!.split.map!(&:to_i)
    a, b = tokens[0], tokens[1]
    if a > b
      puts "a > b"
    elsif a < b
      puts "a < b"
    else
      puts "a == b"
    end
  end
end

Measured memory_bytes: 8584
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort(reverse=True)
    visited = [False]*(2**n)
    visited[0] = 0
    now = [a[0]]
    for i in range(n):
        new = []
        now2 = 0
        for j, i in enumerate(a):
            if visited[j]:
                continue
            if now[now2] > i:
                now2 += 1
                new += [i]
                visited[j] = True
                if now2 == len(now):
                    now += new
                    now.sort(reverse=True)
                    break
        else:
            print("No")
            return

    print("Yes")


main()

Measured memory_bytes: 34676
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  string s,t;
  cin >> s >> t;
  int a,b;
  cin >> a >> b;
  string u;
  cin >> u;
  if(s == u) {
    a--;
  } else {
    b--;
  }
  cout << a << " " << b << endl;
  return 0;
}

Measured memory_bytes: 256
def solve(S,T):
    n,m=len(S),len(T)
    i,j=0,m-1
    diff=0
    for k in range(i,j+1):
        if S[k]!=T[k]:
            diff+=1
    best=diff
    i+=1
    j+=1
    while j<n:
        diff=0
        for k,t in enumerate(T):
            if S[i+k]!=t:
                diff+=1
        best=min(diff,best)
        i+=1
        j+=1
    return best

S=input()
T=input()
print(solve(S,T))

Measured memory_bytes: 67588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int N = 400010;
const double pi = acos(-1.0);

struct vec
{
    int x, y;
    double angle;
};
bool cmp(vec w, vec v){ return w.angle < v.angle; }

vec a[N];
ll ans = 0, n, x = 0, y = 0;
int pointer = 0;

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i].x >> a[i].y;
        a[i].angle = atan2(a[i].y, a[i].x);
    }
    a[0].x = a[0].y = 0;
    sort(a + 1, a + n + 1, cmp);
    for (int i = 1; i <= n; i++)
    {
        a[i + n] = a[i];
        a[i + n].angle = a[i].angle + pi * 2;
    }
    for (int i = 1; i <= n; i++)
    {
        x -= a[i - 1].x; y -= a[i - 1].y;
        ans = max(ans, 1LL * x * x + 1LL * y * y);
        while (pointer + 1 - i + 1 <= n && pointer + 1 <= 2 * n && a[pointer + 1].angle - a[i].angle <= pi)
        {
            pointer ++;
            x += a[pointer].x;
            y += a[pointer].y;
            ans = max(ans, 1LL * x * x + 1LL * y * y);
        }
    }
    cout << fixed << setprecision(12) << (double)sqrt(ans) << endl;
    return 0;
}

Measured memory_bytes: 384
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	string s;
	cin>>s;
	ll ans = 0;
	rep(i,s.size()){
		rep(j,i+1){
			ll t;
			convert(s.substr(j,i-j+1), t);
			if(j) t *= (1<<(j-1));
			if(i<s.size()-1) t *= (1<<(s.size()-2-i));
			ans += t;
		}
	}
	cout<<ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 384
import math
def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m
def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y
def combination(n, r, mod=10**9+7):
  r = min(r, n-r)
  res = 1
  for i in range(r):
      res = res * (n - i) * modinv(i+1, mod) % mod
  return res

def COMint():
  fac[0]=1
  fac[1]=1
  finv[0]=1
  finv[1]=1
  inv[1]=1
  for i in range(2,N+1):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD
def com(n,k):
  if n<k:
    return 0
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
MOD=10**9+7
#繰り返し２乗法を使う場合
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n,a,b=[int(x) for x in input().split()]
ans1 = pow(2,n,MOD)
N = n
a1=combination(n,a)
b1 = combination(n,b)
if ans1-a1%MOD-b1%MOD<0:
  print(((ans1-a1%MOD-b1%MOD)%MOD+MOD)%MOD-1)
else:
  print(ans1-a1%MOD-b1%MOD-1)


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

using namespace std;

using ll = long long;

constexpr ll mod = 1e9 + 7;
constexpr int kMaxS = 1e4 + 5;

struct box {
  int w, s, v;
  bool operator< (const box& b) const {
    return s + w < b.s + b.w;
  }
};

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

  int n;
  cin >> n;

  vector<box> boxes(n);
  for (int i = 0; i < n; ++i) {
    int w, s, v;
    cin >> w >> s >> v;

    boxes[i] = {w, s, v};
  }

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

  for (const auto& b: boxes) {
    cerr << b.w << ' ' << b.s << ' ' << b.v << '\n';
  }

  vector<ll> dp(2 * kMaxS);
  for (int i = 0; i < n; ++i) {
    vector<ll> new_dp(dp);
    for (int w = boxes[i].s; w >= 0; --w) {
      new_dp[w + boxes[i].w] = max(new_dp[w + boxes[i].w], dp[w] + boxes[i].v);
    }
    swap(dp, new_dp);
  }

  cout << *max_element(dp.begin(), dp.end()) << '\n';

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{string s,ss="",ss1="";cin>>s;
 long long n=s.size();
 for(long long i=0;i<(n-1)/2;i++)
 {ss+=s[i];}
 for(long long i=((n+3)/2)-1;i<n;i++)
 {ss1+=s[i];}
 string a=s,b=ss,c=ss1;
 reverse(s.begin(),s.end());
 reverse(ss.begin(),ss.end());
 reverse(ss1.begin(),ss1.end());
 if(a==s && ss==b && ss1==c)cout<<"Yes";
 else cout<<"No";
 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
int main(){
std::vector<int>l(1);
std::vector<int>r(1);
int n,m,l_max,r_min,a;
std::cin >> n >> m;
l_max = 0;
r_min = n;
    for(int t = 0; t < m; t++){
        std::cin >> l.at(t);
        std::cin >> r.at(t);
        l.emplace_back(t+1);
        r.emplace_back(t+1);

}

    for(int i = 0; i<m; i++){
//std::cout<<l.at(i)<<std::endl;
    if(l_max<l.at(i)){
        l_max = l.at(i);
}


}
    for(int i = 0; i<m; i++){
    if(r_min>r.at(i)){
        r_min = r.at(i);
}
}
//std::cout<<r_min<<l_max<<std::endl;
a = r_min - l_max;
//std::cout<<a<<std::endl;
if(a<0){
a = -1;
}
std::cout<<a + 1<<std::endl;
}

Measured memory_bytes: 1276
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		boolean followRulesFlg = true;
		ArrayList<String> strings = new ArrayList<>();
		
		for(int a = 0; a<N; a++){
			strings.add(sc.next());
		}
		sc.close();
		for(int a = 0; a<strings.size()-1; a++){
			int b = a+1;
			if(strings.get(a).charAt(strings.get(a).length()-1)!=strings.get(b).charAt(0)){
				followRulesFlg=false;
			}
		}
		Collections.sort(strings);
		for(int a = 0; a<strings.size()-1; a++){
			int b = a+1;
			if(strings.get(a).equals(strings.get(b))){
				followRulesFlg=false;
			}
		}
		System.out.println(followRulesFlg? "Yes" : "No");
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
using namespace std;
int main(void){
  string S,T;
  
  cin >> S;
  cin >> T;
  
  //途中まで同じかどうか判定
  string Result;
  
  bool Flag=true;
  for (int i = 0;i < S.size();i++){
    if (S[i] != T[i]){
      Flag = false;
    }
  }
  
  if (Flag == false){
    Result = "No";
  }else{
    Result = "Yes";
  }
  
  cout << Result << endl;
  
}

Measured memory_bytes: 3132
n,k = map(int,input().split())
h = list(map(int,input().split()))

dp = [0,abs(h[1]-h[0])]
for i in range(2,n):
    u = []
    for j in range(1,min(i,k)+1):
        u.append(dp[i-j]+abs(h[i]-h[i-j]))
    dp.append(min(u))

print(dp[n-1])

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

int main(){
    int h, w, k;
    cin >> h >> w >> k;

    vector<string> s(h);
    for(int i=0; i<h; i++){
        cin >> s[i];
    }

    int ans = 0;
    for(int bit=0; bit<(1<<(h+w)); bit++){
        int count = 0;
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                if((bit >> i & 1) 
                && (bit >> (h+j) & 1)
                && s[i][j] == '#'){
                    count += 1;
                }
            }
        }
        if(count == k) ans += 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>

int main(){
  int sx, sy, tx, ty;
  std::cin >> sx >> sy >> tx >> ty;
  for(int i = 0; i < tx - sx; i++) std::cout << 'R';
  for(int i = 0; i < ty - sy; i++) std::cout << 'U';
  for(int i = 0; i < tx - sx; i++) std::cout << 'L';
  for(int i = 0; i < ty - sy; i++) std::cout << 'D';
  std::cout << 'D';
  for(int i = 0; i < tx - sx + 1; i++) std::cout << 'R';
  for(int i = 0; i < ty - sy + 1; i++) std::cout << 'U';
  std::cout << 'L';
  std::cout << 'U';
  for(int i = 0; i < tx - sx + 1; i++) std::cout << 'L';
  for(int i = 0; i < ty - sy + 1; i++) std::cout << 'D';
  std::cout << 'R' << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

void Eratosthenes(int prime[],int n){
    prime[0]=0;
    prime[1]=0;
    for(int i=2; i<=sqrt(n); i++){
        if (prime[i]){
            for (int j=0; i*(j+2)<n; j++){
                prime[i*(j+2)]=0;
            }
        }
    }
}

int main(){
    int n=100001;
    int prime[n];
    for (int i=0; i<n; i++){
        prime[i]=1;
    }
    Eratosthenes(prime,n);
    int resemble[100001]={0};
    for (int i=3; i<n; i++){
        if (i%2==1){
            if(prime[i]&&prime[(i+1)/2]){
                resemble[i]++;
            }
        }
        resemble[i]+=resemble[i-1];
    }
    int q;
    cin >> q;
    for (int i=0; i<q; i++){
        int l,r;
        cin >> l >> r;
        cout << resemble[r]-resemble[l-1]<<endl;
    }
}

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

int main() {
    int n, q, t;
    string name;
    queue< pair<string, int> > Q; // ???????????????
    
    cin >> n >> q;
    
    for ( int i = 0; i < n; i++ ) {
        cin >> name >> t;
        Q.push( make_pair(name, t) );
    }
    
    pair<string, int> u;
    int elaps = 0, a;
    
    while ( !Q.empty() ) {
        u = Q.front(); Q.pop();
        a = min( q, u.second );
        u.second -= a;
        elaps += a;
        if ( u.second > 0 ) {
            Q.push( u );
        } else {
            cout << u.first << " " << elaps << endl;
        }
    }
    
    return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<long long> A(n);
    vector<long long> B(m), C(m);
    vector<pair<long long, long long>> v;
    long long ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
        ans += A[i];
    }
    for (int i = 0; i < m; i++)
    {
        cin >> B[i] >> C[i];
        v.emplace_back(make_pair(C[i], B[i]));
    }
    sort(A.begin(), A.end());
    sort(v.rbegin(), v.rend());
    int i = 0;
    for (auto p : v)
    {
        for (int j = 0; j < p.second; j++)
        {
            if (A[i] < p.first)
            {
                ans += p.first - A[i];
                i++;
            }
            if (i == n || A[i] >= p.first)
            {
                cout << ans << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4724
#include<cstdio>
#include<algorithm>
#define MAXL 10
using namespace std;
int n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int t,last1=0,last2=0;	//假?last1>last2
		bool flag=0;
		for(int j=1;j<=10;j++){
			scanf("%d",&t);
			if(last1<t)	last1=t;
			else
				if(last2<t)	last2=t;
				else flag=1;
			if(last1<last2)	swap(last1,last2);
		}
		if(flag==0)printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 2504
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;

int x[10], y[10];
double dist(int i, int j) {
	double dx = x[i] - x[j];
	double dy = y[i] - y[j];
	return pow(dx*dx + dy*dy, 0.5);
} 

int main() {
	int n;
	cin >> n;
	rep(i, n) cin >> x[i] >> y[i];
	vector<int> v(n);
	rep(i, n) v[i] = i+1;
	double sum = 0;
	do
	{
		rep(i, n-1) sum += dist(v[i]-1, v[i+1]-1);
	} while (next_permutation(v.begin(), v.end()));
	int fact = 1;
	for (int i = 2; i <= n; i++) fact *= i;
	sum /= fact;
	cout << fixed << setprecision(10) << sum << endl;
	return 0;
}

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

typedef long long int ll;
#define INF 10000000000000
using namespace std;


int main()
{
	int X, t;

	cin >> X >> t;
	
	if (X > t)
		cout << X - t << endl;
	else
		cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N_MAX 131072
#define A(I)  (edge[(I)]/N_MAX)
#define B(I)  (edge[(I)]%N_MAX)
void QSort(int left,int right);
char* ans(void);
long edge[200001];
int main(void){
  printf("%s",ans());
  return 0;
}
char* ans(void){
  int N,M,wait_v[100001]={},index[100001],v4[2],temp,temp2,j,num_v4=0;
  scanf("%d %d",&N,&M);
  for(int i=1;i<=M;i++){
    scanf("%d %d",&temp,&temp2);
    edge[i]=(long)temp*N_MAX+temp2;
    edge[i+M]=(long)temp2*N_MAX+temp;
    wait_v[temp]++;
    wait_v[temp2]++;    
  }
  for(int i=1;i<=N;i++){if(wait_v[i]%2==1){return "No";}}
  for(int i=1;i<=N;i++){if(wait_v[i]>=6){return "Yes";}}
  for(int i=1;i<=N;i++){if(wait_v[i]==4){v4[num_v4++]=i;}}
  if(num_v4>=3){return "Yes";}
  else if(num_v4==2){
    QSort(1,2*M);
    j=1;
    for(int i=1;i<=N;i++){
      while(A(j)!=i){j++;}
      index[i]=j;
    }
    for(int i=0;i<3;i++){
      temp=B(index[v4[0]]+i);
      temp2=v4[0];
      while((temp!=v4[0])&&(temp!=v4[1])){
        if(B(index[temp])==temp2){
          temp2=temp;
          temp=B(index[temp]+1);
        }
        else{
          temp2=temp;
          temp=B(index[temp]);
        }
      }
      if(temp==v4[0]){return "Yes";}
    }
  }
  return "No";
}

void QSort(int left,int right)
{
  int i,j;
  long a_center,temp;
  i=left;
  j=right;
  a_center=edge[(left+right)/2];
  while(1){
      while(edge[i]<a_center){i++;}
      while(a_center<edge[j]){j--;}
      if(i>=j){break;}
      temp=edge[i];
      edge[i]=edge[j];
      edge[j]=temp;
      i++;
      j--;
  }
  if (left<i-1){QSort(left,i-1);} 
  if (j+1<right){QSort(j+1,right);}
}


Measured memory_bytes: 2560
using System;

namespace _4_C
{
    class Program
    {
        static void Main(string[] args)
        {
            bool[] x = new bool[244140700];
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                string[] s = Console.ReadLine().Split();
                int now = 0;
                int a = 1;
                for (int j = 0; j < s[1].Length; j++)
                {
                    switch (s[1][j])
                    {
                        case ('A'):
                            {
                                now += a;
                                break;
                            }
                        case ('C'):
                            {
                                now += a * 2;
                                break;
                            }
                        case ('G'):
                            {
                                now += a * 3;
                                break;
                            }
                        case ('T'):
                            {
                                now += a * 4;
                                break;
                            }
                    }
                    a *= 5;
                }
                if (s[0] == "insert")
                {
                    x[now] = true;
                }
                else
                {
                    Console.WriteLine(x[now] ? "yes" : "no");
                }
            }
        }
    }
}

Measured memory_bytes: 374268
#include<iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
  int x[52] = {0};
  char t;
  int n,num;
  cin >> n;

  for(int i=0;i<n;i++){
    cin >> t >> num;

    if(t=='S'){
      x[num-1] = 1;
    }else if(t=='H'){
      x[num+12] = 1;
    }else if(t=='C'){
      x[num+25] = 1;
    }else if(t=='D'){
      x[num+38] = 1;
    }else{}

  }


  for(int i=0;i<52;i++){
    if(x[i]==1)continue;
    if(i < 13){
      cout << "S " << (i+1) << endl;
    }else if(i<26){
      cout << "H " << (i+1-13) << endl;
    }else if(i<39){
      cout << "C " << (i+1-26) << endl;
    }else if(i<52){
      cout << "D " << (i+1-39) << endl;
    }else{}
  }

}



Measured memory_bytes: 3088
#include<stdio.h>
 
int main(void){
  int X,Y;
  scanf("%d %d",&X,&Y);
  for(int i=0;i<=X;i++){
    if((2*i+(X-i)*4)==Y){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}

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

int main(){
    int N;
    int A[100000];
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> A[i];
    }
    int oddcount = 0;
    for (int i = 0; i < N; i++){
        if (A[i] % 2 == 1) oddcount++;
    }
    if (oddcount % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;
int main() {
	while (true) {
		int a, b;
		cin >> a >> b;
		if (a == 0 && b == 0)break;
		for (int i = 0; i < a; i++) {
			for (int j = 0; j < b; j++) {
				if (i == 0 || i == a - 1 || j == 0 || j == b - 1)cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3092