akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
const ll fact_table = 800008;
double Pi = 3.1415926535897932384626;
 
//vector<ll> G[550010];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
//ll mod = 998244353;
ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k;
ll ans;
ll x[500005], y[500005], z[200005];
char s[500005], t[500005];
bool used[500005];

int main(){
    /*
    cin.tie(0);
    ios::sync_with_stdio(false);
    */
    cin >> n;
    bool dif = false;
    for(ll i=0;i<n;i++){
        cin >> x[i] >> y[i];
        if(x[i] != y[i])dif = true;
    }
    if(!dif){
        p(0);
        return 0;
    }
    vector<ll> v;
    for(ll i=0;i<n;i++){
        if(x[i] <= y[i]){
            ans += y[i];
        }else{
            v.pb(y[i]);
        }
    }
    sort(v.begin(), v.end());
    m = v.size();
    for(ll i=0;i<m-1;i++){
        ans += v[i+1];
    }
    p(ans);


    return 0;
}
 
 










Measured memory_bytes: 16896
#include <bits/stdc++.h>
#define typeof(x) __typeof__(x)
#define int long long int
#define double long double
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector

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

using namespace std;

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

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

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const pair<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const map<T1,T2>& m) {
   s << "{";
   for (auto i = m.begin(); i != m.end(); ++i) {
      s << i->first << ":" << i->second;
      if (next(i) != m.end()) s << ", ";
   }
   s << "}";
   return s;
}

signed main()
{
   int x; cin >> x;
   if (x == 3 || x == 5 || x == 7) {
      cout << "YES" << endl;
   } else {
      cout << "NO" << endl;
   }
   return 0;
}


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

int main() {
  
  int n;
  cin >> n;
  
  vector<int> c(n);
  for(int i=0;i<n;i++){
    cin >> c.at(i);
  }
  int a =0;//初期値
  for ( int i = 0; i < n-1; i++){//i番目のおいしさ
    for(int j = i+1; j < n;j++){ //i+1番目以降のおいしさ
    a += c.at(i)*c.at(j);//ex)1番目＝2~4　2番目＝3・4 3*4　総当たり　
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=200005;
//i_am_noob
int a,b;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> a >> b;
	print1((b-1+a-2)/(a-1));
	return 0;
}

Measured memory_bytes: 256
// 10000以下の全てのnを出す(100 * 100 * 100 > 10000 より、100ぐらいで十分網羅できる) 
// そのあと指定された分だけ答えを出力する 
#include <iostream>
#include <vector>

int main()
{
    int N;
    std::cin >> N;

    std::vector<int> ans(N, 0);

    for(int x=1; x<=100; x++)
    {
        for(int y=1; y<=100; y++)
        {
            for(int z=1; z<=100; z++)
            {
                int fi = (x*x) + (y*y) + (z*z) + (x*y) + (y*z) + (z*x);
                if(fi <= N)
                {
                    //printf("[%d:%d:%d]%d\n", x, y, z, fi);
                    ans[fi - 1]++;
                }
            }
        }
    }

    for(int i=0; i<N; i++)
    {
        std::cout << ans[i] << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define loop(i,L,R) for(int i=(L);i<=(R);i++)
#define rept(i,L,R) for(int i=(L);i<(R);i++)
#define isc(n) scanf("%d",&n)
#define llsc(n) scanf("%lld",&n)
#define dsc(n) scanf("%lf",&n)
#define enl cout<<endl
#define PB(x) push_back(x)
#define xx first
#define yy second
typedef long long ll;
typedef pair<int,int>PI;
typedef pair<pair<int,int>,int>PII;

int main()
{
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    a*=100;
    b*=100;
    set<int>watermake;
    watermake.insert(0);
    bool made=true;
    //cout<<"here"<<endl;
    while(made)
    {
        made=false;
        vector<int>v;
        for(int i:watermake)
        {
            if(i+a<=3000 && watermake.find(i+a)==watermake.end())v.PB(i+a);
            if(i+b<=3000 && watermake.find(i+b)==watermake.end())v.PB(i+b);
        }
        if(v.size())made=true;
        for(int j:v)watermake.insert(j);
    }
   // cout<<"here"<<endl;
    set<int>sugermake;
    sugermake.insert(0);
    made=true;
    while(made)
    {
        made=false;
        vector<int>v;
        for(int i:sugermake)
        {
            if(i+c<=3000 && sugermake.find(i+c)==sugermake.end())v.PB(i+c);
            if(i+d<=3000 && sugermake.find(i+d)==sugermake.end())v.PB(i+d);
        }
        if(v.size())made=true;
        for(int j:v)sugermake.insert(j);
    }
    int du=0,dd=0;
   // cout<<sugermake.size()<<" "<<watermake.size()<<endl;
    for(int i:watermake)
    {
        if(i<=f)
        {
            int cu=min(f-i,e*(i/100));
            int cd=i;
           // cout<<cu<<" "<<cd<<endl;
            int take=0;
            for(int j:sugermake)
            {
                if(j<=cu)take=j;
                else break;
            }
            cu=take;
            cd+=cu;
            if(du*cd<=cu*dd)
            {
                du=cu;
                dd=cd;
            }
        }
        else break;
    }
    cout<<dd<<" "<<du<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int n, w[4010][4010], mod = 1000000007, P[201000][2], res, F[8010],Inv[8010],InvF[8010];
int main(){
    int i, j;
    scanf("%d",&n);
    F[0]=InvF[0]=Inv[1]=1;
    for(i=2;i<=8000;i++){
        Inv[i] = 1ll*Inv[mod%i]*(mod-mod/i)%mod;
    }
    for(i=1;i<=8000;i++){
        F[i]=1ll*F[i-1]*i%mod;
        InvF[i]=1ll*InvF[i-1]*Inv[i]%mod;
    }
    for(i=1;i<=n;i++){
        scanf("%d%d",&P[i][0],&P[i][1]);
        w[2001-P[i][0]][2001-P[i][1]]++;
        res = (res + mod - 1ll*F[(P[i][0]+P[i][1])*2]*InvF[P[i][0]*2]%mod*InvF[P[i][1]*2]%mod)%mod;
    }
    for(i=1;i<=4001;i++){
        for(j=1;j<=4001;j++){
            w[i][j]=(w[i][j]+w[i-1][j]+w[i][j-1])%mod;
        }
    }
    for(i=1;i<=n;i++){
        res = (res+w[2001+P[i][0]][2001+P[i][1]])%mod;
    }
    printf("%lld\n",1ll*res*Inv[2]%mod);
}

Measured memory_bytes: 64512
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);

    	String a=sc.next();
    	String b=sc.next();
    	String c=sc.next();
    	
    	boolean first=a.substring(a.length()-1,a.length()).equals(b.substring(0, 1));
    	boolean last=b.substring(b.length()-1,b.length()).equals(c.substring(0, 1));
    	
    	if(first && last) {
    		System.out.println("YES");
    	}else {
    		System.out.println("NO");
    	}
    }
}


Measured memory_bytes: 21972
// In the name of God

#include <bits/stdc++.h>

using namespace std;

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

	long long total = 0;

	int n;
	cin >> n;

	for(int i = 0; i < n; i++) {
		total += 1ll * (i + 1) * (n - i);
	}

	for(int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		if(u > v) swap(u, v);
		
		total -= 1ll * u * (n - v + 1);

	}

	cout << total;
	
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

struct union_find_t {
  vector<int> parents;

  union_find_t() {}

  explicit union_find_t(int n) : parents(n) {
    for (int i = 0; i < n; i++) {
      parents[i] = i;
    }
  }

  void resize(int n) {
    parents.resize(n);
    for (int i = 0; i < n; i++) {
      parents[i] = i;
    }
  }

  int root(int x) {
    if (parents[x] == x) {
      return x;
    }
    auto const ret = root(parents[x]);
    parents[x] = ret;
    return ret;
  }

  void unite(int x, int y) {
    int const rx = root(x);
    int const ry = root(y);
    if (rx == ry) {
      return;
    }
    parents[rx] = ry;
  }

  bool same(int x, int y) { return root(x) == root(y); }
};

static union_find_t unionFind;

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n;
  std::cin >> n;
  unionFind.resize(n);
  int64_t m;
  std::cin >> m;
  for (int i = 0; i < m; i++) {
    int x;
    int y;
    int z;
    std::cin >> x >> y >> z;
    unionFind.unite(x - 1, y - 1);
  }
  std::unordered_set<int> roots;
  for (int i = 0; i < n; i++) {
    roots.insert(unionFind.root(i));
  }
  std::cout << roots.size() << std::endl;
  return 0;
}


Measured memory_bytes: 4772
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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; }

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

int extgcd(int a, int b, int &x, int &y) {
  int d = a;
  if (b != 0) {
    d = extgcd(b, a%b, y, x);
    y -= (a/b)*x;
  } else {
    x = 1;
    y = 0;
  }
  return d;
}

// m is a large prime integer. Usually 1000000007 is used.
int mod_inverse(int a, int m) {
  int x, y;
  extgcd(a, m, x, y);
  return (m + x%m)%m;
}

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

  int n, x; cin >> n >> x;
  vector<int> s(n);
  rep(i, n) cin >> s[i];
  sort(s.begin(), s.end());

  ll fact = 1;
  for(int i=2; i<n; i++) {
    fact *= i;
    fact %= mod;
  }
  vector<ll> modinv(n);
  for(int i=1; i<n; i++) {
    modinv[i] = mod_inverse(i, mod);
  }

  unordered_map<int, ll> mp;
  unordered_map<int, ll> mp2;

  rep(i, n) {
    auto r = x%s[i];
    mp[r] += fact;
    mp[r] %= mod;
  }

  bool flag = true;
  while(flag) {
    flag = false;
    for(auto e: mp) {
      auto r = e.first;
      auto it = upper_bound(s.begin(), s.end(), r);
      auto k = distance(s.begin(), it);
      if (k==0) {
        mp2[e.first] += mp[e.first];
        mp2[e.first] %= mod;
      }
      for(int i=0; i<k; i++) {
        flag = true;
        auto pos = r%s[i];
        mp2[pos] += e.second * modinv[k];
        mp2[pos] %= mod;
      }
    }
    swap(mp, mp2);
    mp2.clear();
  }

  ll ans = 0;
  for(auto e: mp) {
    ans += e.second*e.first;
    ans %= mod;
  }
  cout << ans << endl;
}


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

int main() {
  
  string s;
  cin >> s ;
  int n= s.size();
  int a=0;
  int b=10000;
  for(int i=0;i<n-2;i++){
    a=abs((s[i]-'0')*100+(s[i+1]-'0')*10 + s[i+2]-'0'-753);
    b=min(a,b);
    
  }  
  cout << b << endl;
}


Measured memory_bytes: 256
from collections import deque
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
N=int(input())
A=[list(map(int,input().split())) for i in range(N-1)]
Q,K=map(int,input().split())
B=[list(map(int,input().split())) for i in range(Q)]
C=[[]for i in range(N)]
for a,b,c in A:
  a-=1
  b-=1
  C[a].append((b,c))
  C[b].append((a,c))
  
Q=[-1 for i in range(N)]
Q[K-1]=0
que=deque()
que.append(K-1)
while que:
  x=que.popleft()
  for i,j in C[x]:
    if Q[i]==-1:
      que.append(i)
      Q[i]=Q[x]+j
for x,y in B:
  print(Q[x-1]+Q[y-1])

Measured memory_bytes: 87896
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
	"unsafe"
)

func main() {
	S := sc.next()
	SArr := strings.Split(S, "")
	var isNG bool
	if len(S)%2 != 0 {
		no()
		return
	}
	for i := 0; i < len(SArr)-1; i = i + 2 {
		if SArr[i] != "h" || SArr[i+1] != "i" {
			isNG = true
			break
		}
	}
	if !isNG {
		yes()
	} else {
		no()
	}
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;

int main(){
    string str;
    cin >> str;
    vector<string> alp={"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
    int num;
    REP(i, SIZE(alp)){
        if(str==alp[i]){
            num = i;
            break;
        }
    }
    cout << alp[num+1];
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}


void execute()
{
    int N;
    cin >> N;
    string S;
    cin >> S;

    int c = 0;
    int l = 0;
    int r = N-1;
    while(l < r)
    {
        while(S[l] == 'R') {l++;if(l==N)break;}
        while(S[r] == 'W') {r--;if(r==-1)break;}
//        cout << l << "," << r << endl;
        if(l!=N && r!=-1 && l < r) c++;
        l++;
        r--;
    }

    cout << c << endl; 
}


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

bool adj[5][5];
int s[5];

int main () {
    int n=4;
    vector<int> v;
    for (int i=0;i<4;++i) {
        v.push_back(i);
        if (i) {
            int a,b;
            cin >> a >> b;
            s[a]++; s[b]++;
            if (s[a] == 3) {
                cout << "NO" << endl;
                return 0;
            }
            if (s[b] == 3) {
                cout << "NO" << endl;
                return 0;
            }
            --a; --b;
            adj[a][b] = true;
            adj[b][a] = true;
        }
    }
    cout << "YES" << endl;
}



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

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

const double PI = acos(-1);
int a, b, x;

int main() {
	read(a), read(b), read(x);
	if (x >= a * a * b / 2) printf("%.10lf\n", atan((2 * a * a * b - 2 * x) * 1.0 / (a * a * a)) * 180.0 / PI);
	else printf("%.10lf\n", atan(a * b * b  * 1.0 / (2 * x)) * 180.0 / PI);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i, n, a,max,min;
	long long int sum;
	max = -1000001;
	min = 1000001;
	sum = 0;
	scanf("%d", &n);

	for (i = 1; i <= n; i++) {
		scanf("%d", &a);
		if (max < a)max = a;
		if (min > a)min = a;
		sum = sum + a;
	}
	printf("%d %d %lld\n",min,max,sum);
	return 0;
}


Measured memory_bytes: 2108
n=int(input())
chrs=[[0]*26 for i in range(n)]
docs=[input() for i in range(n)]
ansl=[0]*26
for i in range(n):
  for j in docs[i]:
    chrs[i][ord(j)-97]+=1
for i in range(26):
  least=100
  for j in range(n):
    if chrs[j][i]<least:
      least=chrs[j][i]
  ansl[i]=least
ans=""
for i in range(26):
  ans+=chr(97+i)*ansl[i]
print(ans)

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	int H, W, ans=0;
	string S[505];

	cin >> H >> W;
	rep(i,H) cin >> S[i];

	vector<int> vx[2][605];
	int sum[2][605][605] = {};
	bool mp[605][605] = {};
	rep(i,H) rep(j,W) if( S[i][j] == '#' ){
		// 左回り45度
		int x = i+j;
		int y = j-i + 300;
		vx[0][x].push_back(y);
		sum[0][x][y+1]++;
		// 右回り45度
		swap(x, y);
		vx[1][x].push_back(y);
		sum[1][x][y+1]++;
		// bool map
		mp[y][x] = true;
	}
	rep(k,2) rep(i,605) rep(j,601) sum[k][i][j+1] += sum[k][i][j];

	rep(k,2) rep(x,605) rep(i,vx[k][x].size()) rep(j,i){
		int y1 = vx[k][x][i];
		int y2 = vx[k][x][j];
		if( y1 < y2 ) swap(y1, y2);
		int r = y1 - y2;
		//cout << k << ": x=" << x << ": " << y1 << " - " << y2 << " : " << r << endl;
		if( x-r >= 0  ) ans += sum[k][x-r][y1+1] - sum[k][x-r][y2];
		if( x+r < 605 ) ans += sum[k][x+r][y1+1] - sum[k][x+r][y2];
	}

	rep(x,605) rep(i,vx[0][x].size()) rep(j,i){
		int y1 = vx[0][x][i];
		int y2 = vx[0][x][j];
		int r = abs(y1 - y2);
		if( x-r >= 0  && mp[x-r][y1] ) ans -= 1;
		if( x-r >= 0  && mp[x-r][y2] ) ans -= 1;
		if( x+r < 605 && mp[x+r][y1] ) ans -= 1;
		if( x+r < 605 && mp[x+r][y2] ) ans -= 1;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4608
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<queue>
#include<iostream>
#include<vector>
#define lson k<<1
#define rson k<<1|1

using namespace std;
typedef long long ll;
typedef double db;

const int INFI = 1000000000;
const int N = 100005;
const ll MOD = 1000000007;
int a[N];

int main()
{
    int n;
    while(scanf("%d",&n)+1)
    {
        a[0]=-10;
        for(int i=1;i<=n;i++) scanf("%d",&a[i]);
        ll res(1),sum(1);
        for(int i=2;i<=n;i++)
        {
            if(a[i]<=sum*2-1||a[i-1]<sum*2-1) {}
            else ++sum;
            res = res*sum%MOD;
//            printf("%d  %d %lld\n",i,a[i],sum);
        }
        cout<<res<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    int n,k;
    cin>>k>>n;
    for(int i=n-k+1;i<=n+k-1;i++){
        if(n!=n+k-1)cout<<i<<" ";
        else cout<<i<<endl;
    }
    return 0;
}

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

namespace ProblemC
{
    class Program
    {
        static void Main()
        {
            const int mod = 26;
            long N = GetLong();

            char[] name = new char[16];

            for(int i = 0; i < 16; i++)
            {
                if (N >= 1)
                {
                    long temp = N % mod;
                    if (temp == 0)
                    {
                        name[i] = 'z';
                    }
                    else
                    {
                        name[i] = (char)('a' + temp - 1);
                    }
                    N = (N - 1) / mod;
                }
                else
                {
                    break;
                }
            }

            for (int i = 16 - 1; i >= 0; i--)
            {
                if(name[i] != '\0')
                {
                    Console.Write(name[i]);
                }
            }
        }

        public static int GetInt() => int.Parse(Console.ReadLine());
        public static int[] GetIntArray() => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static double GetDouble() => double.Parse(Console.ReadLine());
        public static double[] GetDoubleArray() => Console.ReadLine().Split().Select(double.Parse).ToArray();
        public static long GetLong() => long.Parse(Console.ReadLine());
        public static long[] GetLongArray() => Console.ReadLine().Split().Select(long.Parse).ToArray();

    }
}


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

namespace _1617
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string a = Console.ReadLine(); if (a == ".") break;
                string[] s1 = a.Split('"');
                string b = Console.ReadLine();
                string[] s2 = b.Split('"');
                if (a == b) Console.WriteLine("IDENTICAL");
                else if (s1.Count() != s2.Count()) Console.WriteLine("DIFFERENT");
                else
                {
                    int count = 0;
                    for (int i = 0; i < s1.Count(); i++)
                    {
                        if (s1[i] != s2[i])
                        {
                            count += i % 2 == 0 ? 999 : 1;
                        }
                    }
                    Console.WriteLine(count == 1 ? "CLOSE" : "DIFFERENT");
                }
            }
        }
    }
}


Measured memory_bytes: 9272
//BadWaper gg
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define N 20010 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
int a[N],b[N];
char s[N],t[N];
int n;
inline int calc()
{
	int t1=0,t2=0;
	for(register int i=1;i<n;i++)if(s[i]=='0'&&s[i+1]=='1')a[++t1]=i;
	for(register int i=1;i<=n;i++)b[++t2]=0;
	for(register int i=1;i<n;i++)if(t[i]=='0'&&t[i+1]=='1')b[++t2]=i;
	for(register int i=1;i<=n;i++)b[++t2]=n;
	int ans=inf;
	for(register int i=1;i<=t2-t1+1;i++)
	{
		int sum=0;
		for(register int j=1;j<i;j++)sum+=b[j];
		for(register int j=1;j<=t1;j++)sum+=abs(a[j]-b[i+j-1]);
		for(register int j=i+t1;j<=t2;j++)sum+=n-b[j];
		ans=min(ans,sum);
	}
	return ans;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read();
	scanf("%s%s",s+1,t+1);
	if(n<=2)
	{
		int ans=0;
		for(register int i=1;i<=n;i++)ans+=(s[i]!=t[i]);
		printf("%d\n",ans);return 0;
	}
	int ans=calc();
	for(register int i=1;i<=n;i++)s[i]='1'+'0'-s[i];
	for(register int i=1;i<=n;i++)t[i]='1'+'0'-t[i];
	ans=ans+calc();
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3864
//set many funcs
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1145141919
#define llinf 1145141919810364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int a,b,c,d,e,f,s[4096]={0},i,j,k,ms,ma,na;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    ms=0;ma=100*a;
    for(i=0;i<=f;i+=c){
        for(j=0;(i+j)<=f;j+=d){
            s[i+j]=1;
        }
    }
    for(i=0;i<=f;i+=(100*a)){
        for(j=0;(i+j)<=f;j+=(100*b)){
            if(i+j==0){continue;}
            for(k=1;(i+j+k)<=f;k++){
                if(s[k]==0){continue;}
                na=i+j+k;
                if(ms*na<ma*k && k*(100+e)<=na*e){ms=k;ma=na;}
            }
        }
    }
    printf("%d %d\n",ma,ms);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>

using namespace std;

int main(void) {
	map<long long int, int> bar;

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

	auto itr = bar.rbegin();
	long long int w, h;
	for (; itr != bar.rend(); itr++) {
		if (itr->second >= 2) {
			itr->second -= 2;
			w = itr->first;
			break;
		}
	}
	for (; itr != bar.rend(); itr++) {
		if (itr->second >= 2) {
			h = itr->first;
			break;
		}
	}
	if (itr == bar.rend()) cout << 0 << endl;
	else cout << h * w << endl;
	system("pause");
	return 0;
}

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll a ,  b ,  n ;
    cin>>a>>b>>n;

    if(n%b==0){
        cout<<floor((a*(n-1))/b)-a*floor((n-1)/b);
    }  
    else{
        if(n<b){
            cout<<floor((a*(n))/b)-a*floor((n)/b);
        }
        else{
            cout<<floor((a*(b-1))/b);
        }
    }

} 

Measured memory_bytes: 3780
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));



		while(true){
			String str = br.readLine();
			String[] s = str.split(" ");

			int limit = Integer.parseInt(s[0]);
			int num= Integer.parseInt(s[1]);
			int count = 0;

			if((limit == 0)&&(num == 0)){
				break;
			}
			for(int i = 3; i <= limit; i++){
				for(int j = 2; j <= i; j++){
					for(int k = 1; k <= j; k++){
						if((i == j)||(j == k)||(k == i)){
							continue;
						}
						if((i + j + k)==num){
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 24764
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n, d;
    cin >> n >> d;
    vector<vector<ll>> x(n, vector<ll>(d));
    rep(i, n) rep(j, d) cin >> x[i][j];
    int ans = 0;
    set<ll> sq;
    rep(i, 100000) {
        sq.insert((ll)i*i);
    }
    rep(i, n) rep(j, i) {
        ll tmp = 0;
        rep(k, d) tmp += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
        if(sq.count(tmp)) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int getCount(vector<int> &arr, int index, int K, vector<int>& mem){
    if(mem[index] != -1) return mem[index];

    int ans = INT_MAX;

    for(int i = 1; i <= K && index+i < arr.size(); i++){
        ans = min(ans, abs(arr[index] - arr[index+i])+getCount(arr, index+i, K, mem));
    }

    if(ans == INT_MAX)
        ans = 0;
    
    mem[index] = ans;
    return ans;
}
int main(){
    int N, K;
    cin >> N >> K;

    vector<int> arr(N);

    for(int i = 0; i < N; i++)
        cin >> arr[i];

    vector<int> mem(N, -1);

    cout << getCount(arr, 0, K, mem) << endl;

}

Measured memory_bytes: 13272
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])
ans, j = 0, M
for i in range(N + 1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47336
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

fn main() {
    let ss: Vec<char> = read_line().chars().collect();
    let mut used = vec![false; 26];
    for &c in &ss {
        used[c as usize - 'a' as usize] = true;
    }
    for i in 0..26 {
        if ! used[i] {
            for &c in &ss {
                print!("{}", c);
            }
            println!("{}", ((i as u8)+b'a') as char);
            return;
        }
    }
    for i in (0..26).rev() {
        let mut nc = None;
        for k in i+1..26 {
            if ss[i] < ss[k] && ( nc.is_none() || nc.unwrap() > ss[k] ){
                nc = Some(ss[k]);
            }
        }
        if nc.is_some() {
            for k in 0..i {
                print!("{}", ss[k]);
            }
            println!("{}", nc.unwrap());
            return;
        }
    }
    println!("{}", -1);
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
   string s;
   cin>>s;
   int count=0;
  for(int i=0;i< s.size();i++){
    if(s.at(i)=='C'){
      for(int j=i+1;j<s.size();j++){
        if(s.at(j)=='F'){
         count++;
        }
      }
    }
  }
    if(count==0){
      cout<<"No"<<endl;
    }
    if(count>=1){
      cout<<"Yes"<<endl;
    }
  
}

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

(N, M) = map(lambda x: int(x), input().split(' '))
H = [i for i in map(lambda x: int(x), input().split(' '))]
dest_max = [0] * len(H)

for i in range(M):
    (a, b) = map(lambda x: int(x), input().split(' '))
    dest_max[a-1] = max(dest_max[a-1], H[b-1])
    dest_max[b-1] = max(dest_max[b-1], H[a-1])

#print(H)
#print(dest_max)
print(len([1 for i in range(len(H)) if H[i] > dest_max[i] ]))




Measured memory_bytes: 20112
<?php
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (empty($l)) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->N = $a[0];
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
  }
}
asort($a);
$sum=0;
$i=0;
foreach($a as $k) {
  if (($i % 2)==0) {
  $sum += $k;
  }
  $i++;
}
printf("%d\n",$sum);


Measured memory_bytes: 3832
int main() {
    int w, h, x, y, r;
    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
    if (x >= r && x <= w - r && y >= r && y <= h - r) {
        puts("Yes");
    } else {
        puts("No");
    }
}


Measured memory_bytes: 2100
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int H, W, N, A[100000], B[100000];

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

    set<pii> black, center;

    cin >> H >> W >> N;
    rep(i, N) {
        cin >> A[i] >> B[i];
        black.insert({A[i],B[i]});
        for(int y = A[i] - 1; y <= A[i] + 1; ++y)for(int x = B[i] - 1; x <= B[i] + 1; ++x) {
            for(int ny = y - 1; ny <= y + 1; ++ny)for(int nx = x - 1; nx <= x + 1; ++nx) {
                if(ny <= 0 || ny > H || nx <= 0 || nx > W)goto NG;
            }
            center.insert({y,x});
            NG:;
        }
    }

    vll ans(10);
    each(cent, center) {
        int y, x, cnt = 0;
        tie(y, x) = cent;
        for(int ny = y - 1; ny <= y + 1; ++ny)for(int nx = x - 1; nx <= x + 1; ++nx) {
            if(black.count({ny,nx})) {
                cnt++;
            }
        }
        ans[cnt]++;
    }
    ans[0] = (ll)(H-2)*(W-2) - accumulate(all(ans), 0ll);
    rep(i, 10)cout << ans[i] << endl;
}

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

struct SegTree{

    int sz;
    vector<long long> dat,laz;

    SegTree(){
        sz=1<<18;
        dat.resize(sz<<1);
        laz.resize(sz<<1);
    };

    void upd(int id,int l,int r,int ql,int qr,long long val){
        if(qr<l||r<ql)return;
        if(ql<=l&&r<=qr){
            laz[id]+=val;
            dat[id]+=val;
            return;
        }
        laz[id<<1]+=laz[id];
        dat[id<<1]+=laz[id];
        laz[id<<1|1]+=laz[id];
        dat[id<<1|1]+=laz[id];
        laz[id]=0;
        upd(id<<1,l,l+r>>1,ql,qr,val);
        upd(id<<1|1,(l+r>>1)+1,r,ql,qr,val);
        dat[id]=min(dat[id<<1],dat[id<<1|1]);
    }

    long long qry(int id,int l,int r,int ql,int qr){
        if(qr<l||r<ql)return 1e18;
        if(ql<=l&&r<=qr){
            return dat[id];
        }
        laz[id<<1]+=laz[id];
        dat[id<<1]+=laz[id];
        laz[id<<1|1]+=laz[id];
        dat[id<<1|1]+=laz[id];
        laz[id]=0;
        return min(qry(id<<1,l,l+r>>1,ql,qr),qry(id<<1|1,(l+r>>1)+1,r,ql,qr));
    }

    void upd(int l,int r,long long d){
        upd(1,1,sz,l,r,d);
    }

    long long qry(int l,int r){
        return qry(1,1,sz,l,r);
    }
};

int n,m;
int a[200005],b[200005];
SegTree y,x;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=m;i++)y.upd(i,i,-i);
    for(int i=1;i<=n;i++){
        cin>>a[i]>>b[i];
        x.upd(b[i]+1,b[i]+1,min(y.qry(1,b[i])-(-b[i]-1)-x.qry(b[i]+1,b[i]+1),0ll));
        y.upd(b[i]+1,b[i]+1,min(y.qry(1,b[i])-y.qry(b[i]+1,b[i]+1),0ll));
        x.upd(a[i],b[i],1e9);
        y.upd(a[i],b[i],1e9);
        x.upd(1,m,1);
        y.upd(1,m,1);
        if(x.qry(1,m)>=1e9)cout<<"-1\n";
        else cout<<x.qry(1,m)<<'\n';
    }

    return 0;
}


Measured memory_bytes: 21184
import heapq
from collections import deque

N, K=map(int, input().split())
V=list(map(int, input().split()))
limitAB=min(N, K)
ans=0
for num in range(limitAB+1):
  for A in range(num+1):
    B=num-A
    d=deque(V)
    h=[]
    while d and len(h)<A:
      heapq.heappush(h, d.popleft())
    while d and len(h)<A+B:
      heapq.heappush(h, d.pop())
    cnt=0
    while h and h[0]<0 and cnt<K-(A+B):
      heapq.heappop(h)
      cnt+=1
    ans=max(ans, sum(h))
print(ans)

Measured memory_bytes: 3436
PROGRAM ATCODER

implicit none
integer(16) :: n,i,ans
integer(16),allocatable :: a(:)

read*, n
allocate(a(n))
read*, a(1:n)

call hs(n,a)

do i = n-1, 0, -2
  if ( i == 0 ) then
    if ( a(1) /= 0 ) stop
    exit
  end if
  if ( 2*i /= a(i)+a(i+1) ) then
    print'(i0)', 0
    stop
  end if
end do

ans = 1
do i = 1, n/2
  ans = mod(ans*2,10**9+7)
end do

print'(i0)', ans 

contains
!!!!!! サブルーチンは↓
subroutine hs(n,array)
  implicit none
  integer(16),intent(in)::n
  integer(16),intent(inout)::array(1:n)
  
  integer(16)::i,k,j,l,m
  integer(16)::t
  
  if(n.le.0)then
     write(6,*)"Error, at heapsort"; stop
  endif
  if(n.eq.1)return
 
  l=n/2+1
  k=n
  do while(k.ne.1)
     if(l.gt.1)then
        l=l-1
        t=array(l)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k.eq.1) then
           array(1)=t
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j.le.k)
        if(j.lt.k)then
           if(array(j).lt.array(j+1))j=j+1
        endif
        if (t.lt.array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
  enddo
 
  return
end subroutine hs
!!!!!!

END PROGRAM ATCODER

Measured memory_bytes: 2304
N=int(input())
S=input()
flag=1
result=S[1:].count("E")
res=result
for i in range(len(S)-1):
    if(S[i] == S[i+1]):
        if(S[i]=="E"):
            res-=1

            result=min(res,result)
        else:
            res+=1
            result=min(res,result)
print(result)


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
//#define vi vector<int>
#define vb vector<bool>
#define pii pair<int, int>
#define mii map<int, int>
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define tr(container, it) for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define inf (long long)1e18
#define F first
#define S second
#define SZ(x) ((int)(x).size())
//#define rep(i, n) for (int i = 0; i < n; i++)
//#define repd(i,n) for(int i=n-1;i>=0;i--)
//#define rep1(i,n) for(int i=1;i<=n;i++)
const int N = 1e9 + 7;

int pow(int x, int y)
{
    int res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = ((res) * (x));
        res %= N;
        y = y >> 1;
        x = ((x) * (x));
    }
    return res;
}
int powm(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll mxn(ll a, ll b)
{
    if (a > b)
        return a;
    else
    {
        return b;
    }
}
long long minl(long long a, long long b)
{
    if (a < b)
        return a;
    else
    {
        return b;
    }
}

void solve()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll x, y;
    ll g[4];
    g[0] = a * c;
    g[1] = a * d;
    g[2] = b * c;
    g[3] = b * d;
    sort(g, g + 4);
    cout << g[3];
}

int32_t main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // int t;
    // cin >> t;
    // while (t--)
    // {
    solve();
    // }
}

Measured memory_bytes: 3692