akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
    long long N, K;
    long long A[4100];
    long long int mod = 1000000007;
    long long int ans;
    long long int suma=0, sumb=0;
    long long int allsum;

    scanf("%lld %lld", &N, &K);
    for(int i=0; i<N; i++){
        scanf("%lld", &A[i]);
        A[i+N] = A[i];
    }

    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            if(A[i]>A[j]){
                suma++;
            }
        }
        for(int j=N; j<2*N; j++){
            if(A[i]>A[j]){
                sumb++;
            }
        }
    }

    ans = (suma * K)%mod;
    allsum = ((K*(K-1))/2)%mod;
    ans = (ans + sumb*allsum)%mod;
    

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

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>

template <typename F>
class FixPoint : F {
public:
  explicit constexpr FixPoint(F &&f) noexcept : F(std::forward<F>(f)) {}

  template <typename... Args>
  constexpr decltype(auto)
  operator()(Args &&... args) const {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};

template <typename F>
static inline constexpr decltype(auto) makeFixPoint(F &&f) noexcept {
  return FixPoint<F>{std::forward<F>(f)};
}

namespace null_null {

void main_() {
  size_t N;
  std::cin >> N;
  std::vector<std::vector<intmax_t>> child(N);
  for (size_t i = 0; i < N - 1; i++) {
    intmax_t a;
    std::cin >> a;
    a--;
    child[a].push_back(i + 1);
  }

  auto result = makeFixPoint([](auto dfs, auto &child, int n) -> intmax_t {
    std::vector<int> v;
    for (auto x : child[n]) {
      v.push_back(dfs(child, x));
    }
    std::sort(v.begin(), v.end(), std::greater<intmax_t>());

    int res = 0;
    for (size_t i = 0; i < v.size(); i++) {
      res = std::max(res, (int)(v[i] + i + 1));
    }

    return res;
  });

  std::cout << result(child, 0) << std::endl;
  return;
}

} // namespace null_null

int main() {
  null_null::main_();
  return 0;
}


Measured memory_bytes: 12288
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

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

  ll n;
  cin >> n;

  if (n & 1) {
    cout << 0 << en;
    return 0;
  }

  if (n == 0) {
    cout << 0 << en;
    return 0;
  }

  n /= 2;
  ll res = 0;
  while (n) {
    res += n / 5;
    n /= 5;
  }

  cout << res << en;

  return 0;
}

Measured memory_bytes: 256
import math

N, D = map(int, input().split())

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

ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        tmp = 0
        for k in range(D): 
            tmp +=(X[i][k]-X[j][k])**2
        tmp = math.sqrt(tmp)
        if (tmp.is_integer()): ans += 1
print(ans)        
        



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

int main() {
  int n;
  int l[100];
  int x;
  int bound=1;
  int curx=0;

  cin >> n >> x ;

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

  for(int i=0;i<n;i++){
    curx+=l[i];
    if(curx<=x){
      bound++;
    }
  }

  cout << bound << endl;


  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], n;
    
    cin >> n;
    for ( int i = 0; i < n; i++ ) cin >> R[i];
    
    int maxv = -2000000000;  
    int minv = R[0];
    
    for ( int i = 1; i < n; i++ ) {     
        maxv = max(maxv, R[i] - minv);  
        minv = min(minv, R[i]);        
    }
    
    cout << maxv << endl;
    
    return 0;
}


Measured memory_bytes: 3884
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cmath>
using namespace std;
const double pi=3.1415926535897932384;
int main()
{
    double a,b,h,m;
    scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
    double short_=30*(h+m/60.0);
    double long_=6.0*m;
    double angle=fabs(long_-short_);
    if(angle>180.0) angle=360.0-angle;
    angle=angle*pi/180.0;
    double ans=sqrt(a*a+b*b-2*a*b*cos(angle));
    printf("%.12lf\n",ans);
    return 0;
}


Measured memory_bytes: 4320
import java.util.*;
import java.io.*;
public class Main
{
    static BufferedWriter bw;
    static BufferedReader br;
    static void solve()throws Exception
    {
        int r = Integer.parseInt(br.readLine());
        double result = 2 * 22/7.0 * r;
        bw.write(Double.toString(result));
        bw.newLine();
    }
    public static void main(String []args)throws Exception
    {
        br=new BufferedReader(new InputStreamReader(System.in));
        bw=new BufferedWriter(new OutputStreamWriter(System.out));
        // int t = Integer.parseInt(br.readLine());
        // for(int i=0;i<t;i++)
        // {
        //     bw.write("Case #"+(i+1)+": ");
            solve();
        // }
        br.close();
        bw.close();
    }
}


Measured memory_bytes: 25524
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main() {
    int m,d;cin >>m >> d;
    int ans = 0;
    for(int i = 1;i<=m;i++){
        for(int j = 1;j<=d;j++){
            int d1 = j % 10;
            int d2 = j / 10;
            if(d1 >=2 && d2 >=2 && d1 * d2 == i)
            ans++;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

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

    int n[4];
    bool flg_1, flg_9, flg_7, flg_4;

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

    flg_1 = flg_9 = flg_7 = flg_4 = false;
    for (int i = 0; i < 4; ++i) {
        switch (n[i]) {
            case 1: flg_1 = true; break;
            case 9: flg_9 = true; break;
            case 7: flg_7 = true; break;
            case 4: flg_4 = true; break;
        }
    }

    if (flg_1 && flg_9 && flg_7 && flg_4) {
        cout << "YES";
    } else {
        cout << "NO";
    }
    cout << endl;

    return 0;
}


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

int main() {

int n,k ;
cin>>n>>k;
int arr[n];

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

int dp[n] ;

dp[0] = 0;

for(int i = 1 ; i<n; i++){

  dp[i] = INT_MAX ;
  for(int j = i-1 ; j >= 0 && (i-j) <= k; j-- ){
    
    dp[i] = min(dp[i] , abs(arr[i] - arr[j])+ dp[j]);
  }
}

cout<<dp[n-1];

return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,pair<int,int>> plpii;
ll N, D;
vector<ll> A;
vector<plpii> edges;
constexpr ll LARGE(int i) {return (i==0) ? 1 : (LARGE(i-1)*10);}

void addEdges(int l, int r){
    edges.emplace_back(plpii(D*abs(l-r)+A[l]+A[r], pair<int,int>(l,r)));
}

void solve(int l, int r){
    if (l+1==r) return;
    int half = (l+r)/2;
    solve(l,half); solve(half,r);
    {
        ll huge = LARGE(20);
        int pos = -1;
        for (int i(half); i < r; ++i){
            if (i*D+A[i] < huge){
                huge = i*D+A[i];
                pos = i;
            }
        }
        for (int i(l); i < half; ++i){
            addEdges(i,pos);
        }
        {
            ll huge = LARGE(20);
            int pos = -1;
            for (int i(l); i < half; ++i){
                if ((-i)*D+A[i] < huge){
                    huge = (-i)*D+A[i];
                    pos = i;
                }
            }
            for (int i(half); i < r; ++i){
                addEdges(i,pos);
            }
        }
    }
}

int find(vector<pii>& v, int i){
    if (v[i].first != i)
        v[i].first = find(v,v[i].first);
    return v[i].first;
}

void Union(vector<pii>& v, int a, int b){
    int pa = find(v,a);
    int pb = find(v,b);
    if (pa==pb) return;
    if (v[pa].second < v[pb].second)
        v[pa].first = pb;
    else if (v[pa].second > v[pb].second)
        v[pb].first = pa;
    else{
        v[pb].first = pa;
        v[pa].second += 1;
    }
}

ll mst(vector<plpii> e, int N){
    vector<pii> cities(N);
    ll weight(0);
    for (int n(0); n < N; ++n){
        cities[n].first = n;
        cities[n].second = 0;
    }
    for (int i(0); i < e.size(); ++i){
        int a = find(cities, e[i].second.first);
        int b = find(cities, e[i].second.second);
        if (a!=b){
            Union(cities,a,b);
            weight += e[i].first;
        }
    }
    return weight;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> D;
    for (int i(0); i < N; ++i){
        ll a; cin >> a;
        A.push_back(a);
    }
    solve(0,N);
    sort(edges.begin(), edges.end());
    cout << mst(edges,N);
    return 0;
}

Measured memory_bytes: 115804
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int ans = (N-1) / (K-1);
        ans += (N-1) % (K-1) == 0 ? 0 : 1;
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 21844
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cmath>		
#include <stdio.h>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < int(n); i++)
#define mod 1000000007
#define fst first
#define pb push_back

int main()
{
	string s;
	cin >> s;
	int a = s.length();
	bool can = false;
	for (int i = 0; i < a; i++) {
		if ((i+1) % 2 == 0) {
			if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D') {
				can = true;
			}
			else {
				can = false;
				break;
			}
		}
		else if ((i + 1) % 2 != 0) {
			if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D') {
				can = true;
			}
			else {
				can = false;
				break;
			}
		}
	}
	if (can) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

int func1(int n){
  int ans=0;
  while(n>0){
    ans+=n%10;
    n/=10;
  }
  return ans;
}

int main(){
  int N,A,B;
  cin>>N>>A>>B;
  int res=0;
  int counter =0;
  
  for (int i=1;i<=N;++i){
    res=func1(i);
    if (A<=res && res<=B) counter+=i;
  }
  cout<<counter<<endl;
}
    
      

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int x[]={0,0,0,0,0};
  int i,j;
  
  scanf("%d",&x[0]);
  scanf("%d",&x[1]);
  scanf("%d",&x[2]);
  scanf("%d",&x[3]);
  scanf("%d",&x[4]);
  
  for(i=0;i<5;i++){
    if(x[i] ==0){
       printf("%d",i+1);
       break;
    }
  }
  return 0;
}

Measured memory_bytes: 1736
/*よくばりセット2019/07/13 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
typedef long long int ll;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int max(int x,int y){return x>y?x:y;}
int min(int x,int y){return x>y?y:x;}
ll llmax(ll x,ll y){return x>y?x:y;}
ll llmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}

int main(){
    static int n,a[400000];
    static int list[400000],list_n[400000]={};

    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        list[i]=a[i];
        list_n[a[i]-1]++;
    }
    qsort(list,n,sizeof(int),desc);

    //for(int i=0;i<n;i++)printf(">%d\n",list[i]);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){     
            if(list[j]!=a[i]){
                printf("%d\n",list[j]);
                break;
            }else{
                if(list_n[a[i]-1]>1){
                    printf("%d\n",list[j]);
                    break;
                }
            }
        }
        
    }
    return 0;


}

Measured memory_bytes: 4716
def fun():
    x, n = list(map(int, input().split()))
    if n == 0: return x
    num_list = list(map(int, input().split()))
    hashmap = {num: True for num in num_list}
    if x not in hashmap: return x
    a = []
    i = 1
    answer = float('inf')
    for _ in range(n):
        for dif in (-1*i, +1*i):
            if x+dif not in hashmap:
                a.append(x + dif)
            if len(a) == 2:
                break
        if len(a) == 2:
            break
        i += 1
    #print(a)
    answer = min([(abs(num-x), num) for num in a])
    return answer[1]
    
print(fun())


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

int main() {
  string S;
  cin >> S;

  int len = S.size() - 1;
  for (int i{}; i < (1 << len); ++i) {
    ostringstream oss;
    int num = S[0] & 0xF;
    oss << S[0];
    for (int j{}; j < len; ++j) {
      int d = S[j+1] &0xF;
      if (i & (1 << j)) {
        num += d;
        oss << '+';
      } else {
        num -= d;
        oss << '-';
      }
      oss << S[j+1];
    }
    if (num == 7) {
      oss << "=7";
      cout << oss.str() << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
 
int main()
{
  std::string str;
  std::cin >> str;

  std::vector<std::string> strRep;
  {
    std::string str2;
    for (int i = 0; i < str.size(); i++)
    {
      if (str[i] == 'A') { str2.push_back('A'); }
      else if (str[i] == 'B' && i != str.size() - 1 && str[i + 1] == 'C')
      {
        str2.push_back('X'); i += 1;
      }
      else
      {
        if (!str2.empty()) { strRep.push_back(str2); }
        str2.clear();
      }
    }
    if (!str2.empty()) { strRep.push_back(str2); }
  }

  long long count = 0;
  for(const auto& s : strRep)
  {
    long long localPosX = 0;
    long long countX = 0;
    bool foundA = false;
    for(int i=0; i<s.length(); i++)
    {
      if( s[i]=='A' ) { foundA = true; continue; }
      localPosX += i;
      countX += 1;
    }
    if( ! foundA || (countX==0) ) { continue; }
    count += localPosX - ( countX-1 ) * countX / 2;
  }
  std::cout << count;
}

Measured memory_bytes: 3196
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 10000000)

func main() {
        var n, count int
        var a, b []int

        fmt.Scan(&n)
        a = SplitInt(readLine())
        b = SplitInt(readLine())

        for i := range b {
                var x = a[i] - b[i]
                if x >= 0 {
                        count += b[i]
                } else {
                        var y = a[i + 1] + x
                        if y >= 0 {
                                count += b[i]
                                a[i + 1] = y
                        } else {
                                count += a[i] + a[i + 1]
                                a[i + 1] = 0
                        }
                }
        }

        fmt.Println(count)

}

func readLine() string {
        buf := make([]byte, 0, 10000000)
        for {
                l, p, e:= rdr.ReadLine()
                if e != nil {
                        panic(e)
                }

                buf = append(buf, l...)
                if !p {
                        break
                }
        }
        return string(buf)

}

func SplitInt(str string) []int {
        stringSplited := strings.Split(str, " ")
        var array []int
        for i:= range stringSplited {
                var a int
                var err error
                a, err = strconv.Atoi(stringSplited[i])
                if err != nil {
                        return array
                }
                array = append(array, a)
        }
        return array
}

Measured memory_bytes: 31232
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using i64 = long long;



int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);

  int N;
  cin>>N;
  for (int i=0; 4*i<=N; ++i) {
    if ((N-4*i)%7==0) {
      cout<<"Yes\n";
      return 0;
    }
  }

  cout<<"No\n";
}


Measured memory_bytes: 256
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.IntMap as IM
main=print.solve.unfoldr(B.readInt.B.dropWhile isSpace)=<<B.getContents
solve=IM.foldrWithKey f 0.IM.fromListWith(+).map(flip(,)1).tail
f k v r=r+if k>v then v else v-k

Measured memory_bytes: 18276
import numpy as np

N = int(input())
A = list(map(int, input().split()))

nA = np.array(A)
ans = 0
while True:
    if all(i % 2 == 0 for i in nA):
        nA = nA // 2
        ans += 1
    else:
        break

print(ans)

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int Q;
    cin >> Q;

    vector<ll> res(Q);
    for (int i=0; i<Q; ++i) {
        ll a, b;
        cin >> a >> b;
        ll pro = a * b;
        ll ok = 0, ng = pro;
        while (abs(ok - ng) > 1) {
            ll mid = (ok + ng) / 2;
            if (min(a, b) <= (mid+1) / 2) {
                ll num = (mid + 2) / 2;
                if ((mid%2 == 0 && num <= (pro - 1) / num) || (mid%2 == 1 && num < (pro - 1) / num)) ok = mid;
                else ng = mid;
            } else {
                ll num = (mid + 1) / 2;
                if ((mid%2 == 0 && num < (pro - 1) / num) || (mid%2 == 1 && num <= (pro - 1) / num)) ok = mid;
                else ng = mid;
            }
        }
        cout << ok << '\n';
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


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

int main(){
  int X;
  cin >> X;
  int ans = 1;
  for (int b = 2; b <= X; b++){
    int power = b * b;
    for (int p = 2;; p++){
      if (power > X) break;
      ans = max(ans, power);
      power *= b;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] lucasnum = new long[87];
        lucasnum[0] = 2;
        lucasnum[1] = 1;
        for (int i = 2; i < 87; i++) {
            lucasnum[i] = lucasnum[i - 1] + lucasnum[i - 2];
        }
        System.out.println(lucasnum[n]);
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#pragma optimise("-O3")
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
// x^y≡x^(y%(p-1))mod p
// but there is a condition that x needs to be coprime to p
///assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set; */
typedef long long int ll;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
#define  pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define tests() int test_cases ; cin >> test_cases ; while(test_cases--)
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define MAXN 100010
#define N 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define sp " "
#define nl '\n'
#define MS(x,y) fill_n(*x, sizeof x / sizeof **x, y);
#define mem(x,y) memset(x,y,sizeof(x));
#define INF 1000000000000000000
#define IO                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);
#define debug(x) cerr << (#x) << " is " << (x) << endl;

#ifndef ONLINE_JUDGE
#define cerr if(true)cerr
#endif

template<int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
static_assert(D >= 1, "Vector dimension must be greater than zero!");
template<typename... Args>
	Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
	}
};
template<typename T>
struct Vec<1, T> : public vector<T> {
	Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {
	}
};

ll power(ll x, ll y,ll p)
{
    ll res = 1;     // Initialize result
    x = x % p;
    if (y==0)return 1;
    if(x==0)return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; // y = y/2
        x = (x*x) % p;  // Change x to x^2
    }
    return res;
}
// int gcd(int a, int b) { if (a == 0)return b;return gcd(b % a, a);}

ll modinv(ll a,ll p){return power(a,p-2,p);}

/*
 
REMOVE DEBUG STATEMENTS
CHECK FOR DUPLICATES (SET -> MULTISET)
CLEAR EVERYTHING BEFORE EVERY TESTCASE
ceil(x/2.0)
floor(x/2.0)
 
*/
const int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};

template<class T> bool ckmin(T&a, T&b) { bool B = a > b; a = min(a,b); return B; }
template<class T> bool ckmax(T&a, T&b) { bool B = a < b; a = max(a,b); return B; }

void solve(){
    string s,t;
    cin>>s>>t;
    ll n = s.size();
    ll cnt = 0;
    f(i,0,n){
        if (s[i]!=t[i])
        {
            cnt++;
        }
    }
    cout<<cnt<<nl;
    return ;
}
int main()
{
    IO;
    int T=1;
	// cin >> T;
	f(c,0,T){
		solve();
	}
    return 0;
}//multiset m make_pair make_tuple  tuple<int,int,int> continue resize insert count size else true isValid second first false erase double priority_queue 
//cout<<setprecision(12);

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

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());

            long count = 0;

            Dictionary<string, long> dic = new Dictionary<string, long>();
            for (int i = 0; i < n; i++)
            {
                // 文字列の入力
                string s = Console.ReadLine();

                if (dic.ContainsKey(s))
                {
                    dic[s]++;
                }
                else
                {
                    dic.Add(s, 1);
                }

                if (dic[s] > count)
                {
                    count = dic[s];
                }
            }

            List<string> results = new List<string>();
            foreach (var kv in dic)
            {
                if (kv.Value == count)
                {
                    results.Add(kv.Key);
                }
            }

            results.Sort(StringComparer.OrdinalIgnoreCase);

            foreach (var result in results)
            {
                Console.WriteLine(result);
            }

            Console.Out.Flush();
        }
    }
}


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

int main(){
  int n,m;
  cin>> n >> m;
  int l,r,left=1,right=n;
  for (int i=0; i<m; i++){
    cin>> l >> r;
    left=max(left,l);
    right=min(right,r);
  }
  int ans=right-left+1;
  if (ans<0) ans=0;
  cout<< ans <<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define pi pair<ll, ll>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define fall(i, a, b) for (int i = a; i < b; i++)
#define sz(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define ed cout << "ed";
#define time_passed 1.0 * clock() / CLOCKS_PER_SEC
ll MOD = 1e9 + 7;
ll MOD1 = 1e9 + 123;
ll MOD2 = 1e9 + 321;

int main()
{
    fio;
    ll t, a, n, q, k, i, l, m, c, u, f, j, p, x, y, b, d;
  
    cin>>x>>k>>d;
    x=abs(x);
if((ull)k*d>x)
{
    k-=x/d;
    x=x%d;
    if(k%2==0)cout<<x;
    else cout<<abs(x-d);
}
else {
cout<<x-k*d<<endl;
}



    return 0;
}


Measured memory_bytes: 3644
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve(n):
    if n % 2 != 0:
        return 0

    total = 0
    now = 5
    while now <= n:
        total += n // (now * 2)
        now *= 5

    return total


def main():
    N = int(input())
    print(solve(N))


if __name__ == '__main__':
    main()


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

int main(){
    int l,r;
    cin >> l >> r;
    if((r-l)/2019>0) cout << 0 << endl;
    else{
        int max1 = 2019;
        for(long long int i=l;i<r;i++){
            for(long long int j=i+1;j<r+1;j++){
                long long int ans = (i*j)%2019;
                if(max1>ans) max1 = ans;
            }
        }
        cout << max1 << endl;
    }
}


Measured memory_bytes: 256
a, b = list(map(int, input().split()))

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

aset = set(prime_factorize(a))
bset = set(prime_factorize(b))

print(len(aset & bset) + 1)

Measured memory_bytes: 3064
import numpy as np

if __name__ == "__main__":
  a,b,h,m = map(int,input().split())
  rad_a = 2*np.pi*((60*h+m)/720)
  rad_b = 2*np.pi*(m/60)

  angle = min(np.abs(rad_a-rad_b), 2*np.pi-np.abs(rad_a-rad_b))
  ans_sq = a*a + b*b - 2*a*b*np.cos(angle)
  print(np.sqrt(ans_sq))


Measured memory_bytes: 27032
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    
    if ( (a + b) % 2  == 0 ) {
        cout << (a + b) / 2  << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
    
}


Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int N=scan.nextInt();
    scan.nextLine();
    String[] W=new String[N];
    for(int i=0;i<N;i++){
      W[i]=scan.nextLine();
    }
    
    for(int i=0;i<N-1;i++){
      for(int j=i+1;j<N;j++){
        if(W[i].equals(W[j])){
          System.out.println("No");
          System.exit(0);
        }
      }
    }
      for(int i=0;i<N-1;i++){
        int j=i+1;
        String A=W[i].substring(W[i].length()-1);
        String B=W[j].substring(0,1);
        if(!A.equals(B)){
          System.out.println("No");
          System.exit(0);
        }
      }
      System.out.println("Yes");
    }
  }


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    set<int> colors;
    int free = 0;
    rep(i,n){
        int a;
        cin >> a;
        a /= 400;
        if(a >= 8){
            a = 8;
            free++;
        }
        colors.insert(a);
    }

    int m, M;
    if(free > 0){
        m = max(1, (int)colors.size() - 1);
        M = colors.size() + free - 1;
    }else{
        m = colors.size();
        M = colors.size();
    }

    cout << m << " " << M << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int x[101];
int main(){
    int n,k,sum=0;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>x[i];
    }
    for(int i=1;i<=n;i++){
        if(x[i]<=k/2) sum+=x[i]*2;
        else sum+=(k-x[i])*2;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;
ll N;

int main(){
    int ans = 0;
    int A, B,C;
    cin >> A >> B >> C;
    vector <int > a(3, 0);
    a[0] = A;
    a[1] = B;
    a[2] = C;
    sort(a.begin(), a.end()); 
    if(A == a[0] && B == a[2]){
        cout << "Yes" << endl;
    }else if(A == a[2] && B == a[0]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ljc 998244353
using namespace std;
#define gc getchar
inline ll read(){
    register ll x=0,f=1;char ch=gc();
    while (!isdigit(ch)){if (ch=='-') f=-1;ch=gc();}
    while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}
    return (f==1)?x:-x;
}
struct edge{
	int to,nxt;
}g[1010101];
int indo[1010101],head[1010101],tot,a[1010101];
inline void made(int from,int to){
	g[++tot].to=to;g[tot].nxt=head[from];head[from]=tot;
	indo[to]++;
}
inline void fail(){
	puts("NO");exit(0);
}
int f[1010101],n;
void dfs(int u,int faa){
	if (indo[u]==1) return (void)(f[u]=a[u]);
	int sum=0,mx=0;
	for (int i=head[u];i;i=g[i].nxt){
		int v=g[i].to;
		if (v==faa) continue;
		dfs(v,u);
		if (mx<f[v]) mx=f[v];
		sum+=f[v];
	}
	f[u]=2*a[u]-sum;
	if (f[u]<0||sum<a[u]) fail();
	if (mx*2>sum){
		int tmp=sum-mx;
		if (tmp<sum-a[u]) fail();
	}
}
signed main(){
	n=read();
	for (int i=1;i<=n;i++) a[i]=read();
	if (n==2){
		puts(a[1]==a[2]?"YES":"NO");
		return 0;
	}
	for (int i=1;i<n;i++){
		int x=read(),y=read();
		made(x,y);made(y,x);
	}
	int R;
	for (int i=1;i<=n;i++){
		if (indo[i]!=1){
			R=i;break;
		}
	}
	dfs(R,0);
	if (f[R]!=0) fail();
	puts("YES");
	return 0;
}



Measured memory_bytes: 13104
require "prime"

def _divisors(primes, k)
  Enumerator.new do |y|
    if primes.size == k
      y << 1
    else
      p, e = primes[k]
      _divisors(primes, k + 1).each {|d|
        (e + 1).times {|e1|
          y << p ** e1 * d
        }
      }
    end
  end
end

def divisors(n)
  _divisors(Prime.prime_division(n), 0).to_a.sort
end

n=gets.to_i
l=divisors(n)
puts l[l.size/2].to_s.size

Measured memory_bytes: 2300
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	String str = "";	
	while(true){
	    str = scan.next();
	    if(str.equals("#END")){
		return;
	    }else{
		System.out.println(rs(str));
	    }	    
	}
    }
    public static String rs(String str){
	char[] chr = str.toCharArray();
	int cl = chr.length;
	int[][] m = new int[cl][cl];
	String RS = "";
	char[] c_RS = new char[cl/2 + 1];
	int RSl = 0;
	for(int k = 0; k < cl; k++) m[k][0] = 0;
	for(int k = 0; k < cl; k++) m[0][k] = 0;
	
	int i = 1;
	int j = 1;
	for(int split = 1; split < cl; split++){
	    for(int k = 0; k < cl/2 + 1; k++) c_RS[k] = ' ';
	    i = 1;
	    while(i <= split){
		j = 1;
		while(j <= cl - split){
		    if(chr[i-1] == chr[j-1+split]) m[i][j] = m[i-1][j-1] + 1;
		    else m[i][j] = Math.max(m[i-1][j],m[i][j-1]);
		    j++;
		}
		i++;
	    }

	    i--;
	    j--;
	    RSl = m[i][j];
	    if(RSl > RS.length()){
		RS = "";
		while(i > 0 && j > 0){
		    if(m[i][j] == m[i][j-1])j--;
		    else if(m[i][j] == m[i-1][j])i--;
		    else{
			c_RS[m[i][j]] = chr[i-1];
			i--;
			j--;
		    }
		}
		for(int k = 1; k <= RSl; k++){
		  RS += c_RS[k];
		}
	    }
	}
	return RS;
    }
}

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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

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

  vector<ll> sums(n + 1, 0);
  for (int i = 1; i <= n; ++i) sums[i] = sums[i - 1] + a[i - 1];

  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    ll tmp = a[i] * ((sums[n] - sums[i + 1]) % MOD);
    tmp %= MOD;
    ans += tmp;
    ans %= MOD;
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 6356
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    int h, n;
    cin >> h >> n;
    vector<int> a(n), b(n);
    rep(i, 0, n) {
        cin >> a[i] >> b[i];
    }

    vector<vector<int>> dp(n, vector<int>(h+1, INT_MAX));

    rep(i, 0, n) dp[i][0] = 0;

    rep(i, 0, n) {
        rep(k, 1, h+1) {
            if (k <= a[i]) {
                dp[i][k] = b[i];
                if (i != 0) dp[i][k] = min(dp[i-1][k], dp[i][k]);
            } else {
                dp[i][k] = dp[i][k - a[i]] + b[i];
                if (i != 0) dp[i][k] = min(dp[i-1][k], dp[i][k]);
            }
        }
    }

    cout << dp[n-1][h] << endl;
}


Measured memory_bytes: 39424
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<ll, ll>;
 
#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  ll x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
const ll MOD = 998244353;
// const ll MOD = 1e9 + 7;
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  ll n;
  std::cin>>n;

  std::vector<ll> pow(n/2,1),conv(n/2,1),inv(n/2,1);

  rep(i,2,n/2){
    inv[i]=(inv[MOD%i]*(MOD-MOD/i))%MOD;
  }

  rep(i,1,n/2){
    pow[i]=(pow[i-1]*2)%MOD;
    conv[i]=(((conv[i-1]*(n+1-i))%MOD)*inv[i])%MOD;
  }

  ll sum=0;

  rep(i,0,n/2){
    sum=(sum+(conv[i]*pow[i])%MOD)%MOD;
  }

  sum=(sum*2)%MOD;

  std::cout<<(pow_mod(3,n,MOD)-sum+MOD)%MOD;

  
 
  return 0;
}

Measured memory_bytes: 117504
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
    { for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
    { os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
    { cerr << " " << H; debug_out(T...); }
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    string s;
    cin >> n >> s;
    string t = s.substr(0, n / 2);
    string u = s.substr(n / 2, n - (n / 2));
    if (t == u) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

const string YES = "YES";
const string NO = "NO";

void solve(long long N, std::vector<long long> A)
{
    set<long long> tmp;
    rep(i, N) { tmp.insert(A[i]); }
    if (tmp.size() == N)
    {
        cout << YES << endl;
    }
    else
    {
        cout << NO << endl;
    }
}

int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int damage[26];
int step[1010];
char ba[100][100];

int dp[2][1<<12];                   // dp[i][j] = 集合jのポーションを使ったときの体力の最大

int main() {
  int HPini, HPmax;
  while(cin>>HPini>>HPmax,HPini||HPmax) {
    int r,c;
    cin >> r >> c;
    REP(i,r) REP(j,c) cin>>ba[i][j];
    int t;cin >> t;
    REP(i,t) {
      char c; int m;
      cin >> c >> m;
      damage[c-'A'] = m;
    }
    int s; cin >> s;
    int num = 1;
    step[0] = damage[ba[0][0]-'A'];
    int y=0, x=0;
    const int dx[] = {0,1,0,-1};
    const int dy[] = {-1,0,1,0};
    REP(i,s) {
      char c; int m;
      cin >> c >> m;
      int d = 0;
      if (c=='D') d=2;
      else if (c=='L') d=3;
      else if (c=='R') d=1;
      REP(i,m) {
        y += dy[d];
        x += dx[d];
        step[num++] = damage[ba[y][x]-'A'];
      }
    }
    int P; cin >> P;
    int p[P];
    REP(i,P) cin >> p[i];

    memset(dp,0,sizeof(dp));
    dp[0][0] = HPini;
    REP(i,num) {
      //cout << step[i] << endl;
      REP(S,1<<P) dp[(i+1)%2][S] = 0;
      REP(S,1<<P) {
        if (dp[i%2][S] == 0) continue; // 死んでる
        // ポーションを使わない
        dp[(i+1)%2][S] = max(dp[(i+1)%2][S], dp[i%2][S]-step[i]);
        // ポーションを使う
        REP(j,P) {
          if (S>>j&1) continue;
          dp[(i+1)%2][S|1<<j] = max(dp[(i+1)%2][S|1<<j], min(HPmax, dp[i%2][S]+p[j])-step[i]);
        }
      }
    }
    bool ans = 0;
    REP(S,1<<P)
      if (dp[num%2][S] > 0) {
        ans = 1;
        //cout << bitset<5>(S) << endl;
      }
    cout << (ans?"YES":"NO") << endl;
  }
}

Measured memory_bytes: 900
#include<iostream>
#include<algorithm> 
#include<cstdio>
#include<cctype>
#include<string>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const int maxn= 2e5+5;
const double pi = acos(-1.0);
const ll mod = 1e9+7;
int main(){
   
    int n;
    scanf("%d",&n);
    n=n%10;
    if(n==2||n==4||n==5||n==7||n==9){
    	cout<<"hon"<<endl; 
	}else if(n==0||n==1||n==6||n==8){
		cout<<"pon"<<endl;
	}else if(n==3)cout<<"bon"<<endl;
     return 0;
 }

Measured memory_bytes: 3760
N,A,B,C,D=map(int,input().split())
S=list(input())

if A<B<C<D:
    a=True
    for i in range(A-1,D-2):
        if S[i]==S[i+1]=="#":
            print("No")
            a=False
            break
    if a==True:
        print("Yes")
elif A<C<B<D:
    a=True
    for i in range(A-1,C-2):
        if S[i]==S[i+1]=="#":
            print("No")
            a=False
            break
    if a==True:
        for i in range(B-1,D-2):
            if S[i]==S[i+1]=="#":
                print("No")
                a=False
                break
    if a==True:
        print("Yes")
elif A<B<D<C:
    a=True
    for i in range(A-1,C-2):
        if S[i]==S[i+1]=="#":
            b=True
            a=False
            break
    if a==True:
        b=True
        for i in range(B-2,D-2+1):
            if S[i]==S[i+1]==S[i+2]:
                b=False
                break
    if b==False:
        print("Yes")
    elif b==True:
        print("No")

Measured memory_bytes: 61424
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
#define mp make_pair
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
const int  COMMAX = 510000;

long long fac[COMMAX], finv[COMMAX], inv[COMMAX];

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcd(int a,int b){return a*b / gcd(a,b);}
// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < COMMAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;
  int num;
  UnionFind(int N) : par(N) , rank(N) { //最初は全てが根であるとして初期化
    num = N;
    for(int i = 0; i < N; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    if(rank[rx] < rank[ry]){
      par[rx] = ry;  
    }else{
      par[ry] = rx;
      if(rank[rx] == rank[ry])rank[rx]++;
    }
    num--;
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
};

const int MS = 2;
const long long mod[] = {999999937LL, 1000000007LL}, base = 9973;
struct rolling_hash {
    int n;
    vector<long long> hs[MS], pw[MS];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < MS; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mod[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
            }
        }
    }

    long long hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i]; }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }

    bool match(int l, int r, long long h[]) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l,r,i)==h[i];
        return ret;
    }
};
vector<LL> h;
int main(){
  LL n,k;
  cin >> n >> k;
  rep(i,0,n){
    LL a;
    cin >> a;
    h.pb(a);
  }
  sort(all(h));
  reverse(all(h));
  LL res = 0;
  rep(i,k,n){
    res += h[i];
  }
  cout << res << endl;
  return 0;
}


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

int main()
{
    double a, b;
    cin >> a >> b;
    double ed = a / 0.08;
    double eu = (a + 1) / 0.08;
    double td = b / 0.10;
    double tu = (b + 1) / 0.10;

    if(ed < tu && td < eu)
    {
        cout << static_cast<int>(ed < td ? ceil(td) : ceil(ed)) << endl;
    }
    else
    {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<map>
using namespace std;
typedef long long ll;
ll a[110000];
ll sum[110000];
map<ll,ll>cnt;
int main()
{
    ll n,m;
    sum[0]=0;
    scanf("%lld%lld",&n,&m);
    for(ll i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        sum[i]=(sum[i-1]+a[i])%m;
    }
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
            ans+=cnt[sum[i]];
            cnt[sum[i]]++;
    }
    printf("%lld\n",ans+cnt[0]);
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vch = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
template<class T> inline bool chmin(T& a, T b){if(a > b){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;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);

int main(){
  ll n, m;
  cin >> n >> m;
  vll h(n);
  vvll graph(n);
  vin(h);
  rep(i, 0, m){
    ll a, b;
    cin >> a >> b;
    a--; b--;
    graph.at(a).push_back(b);
    graph.at(b).push_back(a);
  }

  ll ans = 0;
  rep(i, 0, n){
    ll check = true;
    vrep(j, graph.at(i)) if(h.at(i) <= h.at(j)) check = false;
    if(check) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 9808