akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

signed main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int x = c - a, y = d - b;

	rep(i, x) {
		if (x > 0) cout << "R";
		else cout << "L";
	}
	rep(i, y) {
		if (y > 0) cout << "U";
		else cout << "D";
	}

	rep(i, x) {
		if (x > 0) cout << "L";
		else cout << "R";
	}
	rep(i, y) {
		if (y > 0) cout << "D";
		else cout << "U";
	}

	if (y > 0) cout << "D";
	else cout << "U";
	rep(i, x + 1) {
		if (x > 0) cout << "R";
		else cout << "L";
	}
	rep(i, y + 1) {
		if (y > 0) cout << "U";
		else cout << "D";
	}
	if (x > 0) cout << "L";
	else cout << "R";
	if (y > 0) cout << "U";
	else cout << "D";
	rep(i, x + 1) {
		if (x > 0) cout << "L";
		else cout << "R";
	}
	rep(i, y + 1) {
		if (y > 0) cout << "D";
		else cout << "U";
	}
	if (x > 0) cout << "R";
	else cout << "L";
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
map <string,int> mp;
map<string,int>::iterator it;
string s;
int ma=-1;
int main(){   
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		cin>>s;
		mp[s]++;
		if(mp[s]>ma) ma=mp[s];
	}
	for(map<string,int>::iterator it = mp.begin(); it != mp.end(); it++){
		if(it->second==ma) cout<<it->first<<endl;
	}
    return 0;
}

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

int main(void){
    int n;
    cin >> n;
    int num[n];
    int ans[n];
    for(int i = 0; i < n; i++){
        cin >> num[i];
        ans[num[i]-1] = i+1;
    }
    for(int i = 0; i < n; i++)
        cout << ans[i] << ' ';
    cout << endl;
    return 0;
}

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

#define N 2000000 //size of array
const ll MOD = 1e9+7;

ll fac[N], inv[N], finv[N];

void com_init() {
  fac[0] = 1; fac[1] = 1;
  finv[0] = 1; finv[1] = 1;
  inv[1] = 1;
  for (int i=2; i<N; 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;
  }
}

ll combination(int a, int b) {
  if (a < b)
    return 0;
  if (a < 0 || b < 0)
    return 0;
  return fac[a] * (finv[b] * finv[a-b] % MOD) % MOD;
}

int main() {
  int K;
  string S;
  cin >> K >> S;
  int n = S.size();
  ll p = 1, ans = 0;
  com_init();
  for (int i=0; i<K; i++) {
    p *= 25;
    p %= MOD;
  }
  for (int i=0; i<=K; i++) {
    ans += combination(n+K-i-1, n-1) * p % MOD;
    ans %= MOD;
    p *= 26;
    p %= MOD;
    p *= inv[25];
    p %= MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 51228
package main
import (
  "fmt"
)
func main() {
  var n int
  fmt.Scanf("%d", &n)
  a := make([]int, n)
  for i := range a {
    fmt.Scanf("%d", &a[i])
  }
  fmt.Println(solve(n, a))
}

// xxxxxi[xxxxxx]jxxxxxxx

func solve(n int, a []int) int {
  //
  dp := make([][]int, n)
  for i:=range dp {
    dp[i] = make([]int, n)
  }
  //
  for i:=n-1;i>=0;i-- {
    for j:=i;j<n;j++ {
      if i==j {
        dp[i][j] = a[i]
      } else {
        // dp[i][j] 表示a[i:j+1] 的先手最大收益
        dp[i][j] = max(a[i]-dp[i+1][j], a[j]-dp[i][j-1])
      }
    }
  }
  return dp[0][n-1]
}

func max(a, b int) int {
  if a>b {
    return a
  }
  return b
}

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

int  main()
{
	int A,B,H,M;
	cin >> A >> B >> H >> M;
	double k;
	double l = M*6; //長針
	double s = (H*30) + (0.5*M); //短針
	k = abs(s - l);
	double pi = 2.0 * asin(1.0); //円周率 3.14159265358979.......
	double deg = k * (pi / 180); //角度(ラジアン) = n ＊ (π / 180);
	double ans = (double)(A*A + B*B) - (double)2*A*B*cos(deg);

	printf("%.12f\n", sqrt(ans));

	return (0);
}


Measured memory_bytes: 4048
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

K, X = list(map(int, sys.stdin.readline().split()))

l = max(-1000000, X - K + 1)
r = min(1000000, X + K - 1)

print(*range(l, r + 1))


Measured memory_bytes: 22832
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unrolled-loops")
#define y1 hoainambimaysolokill
#define fi first
#define se second
#define PII pair<int,int>
#define PII2 pair<int,pair<int,int> >
#define PII3 pair<pair<int,int>,int >
int l[100010],r[100010],ans[100010];
string s;
void solve()
{
    cin>>s;
    int n=s.size(),res;
    for(int i=0;i<n;i++)
        if(s[i]=='R')res=i;
        else r[i]=i-res;
    for(int i=n-1;i>=0;i--)
        if(s[i]=='L')res=i;
        else l[i]=res-i;
    for(int i=0;i<n;i++){
        int pos;
        if(s[i]=='L'){
           pos=i-r[i];
           //cout<<pos<<endl;
           if((i-pos)&1)ans[pos+1]++;
           else ans[pos]++;
        }
        else{
           pos=l[i]+i;
           //cout<<pos<<endl;
           if((i-pos)&1)ans[pos-1]++;
           else ans[pos]++;
        }
    }
    for(int i=0;i<n;i++)cout<<ans[i]<<" ";
}
main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);cout.tie(0);

    //freopen("TBC.inp", "r", stdin);
    //freopen("FORMMAU.out", "w", stdout);

    //int t;cin>>t;while(t--)

    solve();
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
string a;
int g,p,ans;
int main ( ){
    cin>>a;
    for(int i=0;i<a.length();i++)
        if(a[i]=='g')
            if(g>=p+1)ans++,p++;
            else g++;
        else
            if(g>=p+1)p++;
            else g++,ans--;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
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; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int main() {
	int N, K, ans;
	scanf("%d %d", &N, &K);

	ans = K* (int)pow(K - 1, N - 1);
	printf("%d\n", ans);

#ifdef DEBUGF
	getch();
#endif
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main()
{
	int h, a;
	cin >> h >> a;
	int ans = 0;
	while (1){
		if (h <= 0) break;
		ans++;
		h -= a;
	}
	cout << ans << endl;

}



Measured memory_bytes: 256
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define add(x) accumulate(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end() 
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
const long double pie = 3.141592653589793238;
//
//
                void solve(){
                        long double r;
                        cin>>r;
                        cout<<fixed<<setprecision(10)<<2*pie*r;
                }
                int main(){ 
                        hs;
                        ll t;
                        t=1;
                        // cin>>t;
                        for (int i=1; i<=t; i++){
                                //cout<<"Case #"<<i<<": ";
                                solve();
                         }
        return 0; 
}         
 

Measured memory_bytes: 3800
using System;
using System.Collections.Generic;
using System.Text;


namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            //????????????????????????
            string s = Console.ReadLine();

            //????????´??°??¨??????
            int n = int.Parse(s);


            //????????§??°?????????
            for (int i = 1; i <= n; i++)
            {
                //i??????????????°??????i????????? 
                if (i % 3 == 0)
                {
                    Console.Write(' ');
                    Console.Write(i);
                }

                else
                {
                    string a = i.ToString();

                    int findIndex = a.IndexOf("3");
                    if (findIndex >= 0)
                    {
                        Console.Write(' ');
                        Console.Write(i);
                    }
                }

            }
            Console.Write("\n");
        }
    }
}

Measured memory_bytes: 20568
#include <iostream>
#include <algorithm>
#include <cstring>
#define rep(i,o,u) for(i = o;i <= u; i++)
using namespace std;

int a[101];
int main(){
	int n;
	int i,j;
	cin >> n;
	rep(i,1,n) cin >> a[i];
	rep(i,1,n) {
		sort(a+1,a+1+i);
		rep(j,1,n-1) cout << a[j] << " ";
		cout << a[j] << endl;
	}
	return 0;
}

Measured memory_bytes: 3156
x, n = map(int, input().split())
p_list = list(map(int, input().split()))

p_hash = {}
for p in p_list:
  p_hash[p] = True

i = 0
while True:
  left = x - i
  if p_hash.get(left) is None:
    print(left)
    break
  right = x + i
  if p_hash.get(right) is None:
    print(right)
    break
  i = i + 1

Measured memory_bytes: 9192
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 998244353

int d[100005];
int cnt[100005];

int main() {
	int n;
	cin >> n;
	if(n < 1000)cout << "ABC" << endl;
	else cout << "ABD" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void insertion_sort(int *A, int N){
    int i;
    for (i=1;i<N;i++){
        int v=A[i];
        int j=i-1;
        while(j>=0 && A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        int k;
        for(k=0;k<N-1;k++){
        printf("%d ",A[k]);
        }
        printf("%d\n",A[N-1]);
    }
}

int main(){
    int N;
    scanf("%d", &N);
    int A[N];
    int i;
    for (i=0;i<N;i++){
        scanf("%d", &A[i]);
    }
    for (i=0;i<N-1;i++){
        printf("%d ",A[i]);
    }
    printf("%d\n",A[N-1]);
    insertion_sort(A,N);
    return 0;
}


Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
char S[110];
int main()
{
	scanf("%s",S);
	int l=strlen(S);
	for(int i=0;i<l;i++)
	{
		if(S[i]=='C')
		{
			for(int j=i+1;j<l;j++)
			{
				if(S[j]=='F')
				{
					printf("Yes\n");
					return 0;
				}
			}
		}
	}
	printf("No\n");
	return 0;
}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

# 拡張ユークリッドの互除法(ax+by=gcd(a, b)の解を求める)
def extgcd(a, b, x, y):
    if b == 0:
        x = 1
        y = 0
        return (y, x)
    else:
        x, y = extgcd(b, a%b, y, x)
        y -= a // b * x
        return (y, x)

a, b = MAP()

y, x = extgcd(a, b, 0, 0)
print(x, y)



Measured memory_bytes: 5636
require 'scanf'
require 'date'

wd = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ]

while line = gets do
  m, d = line.split.map(&:to_i)
  break if m == 0 || d == 0
  puts wd[Date.new(2004,m,d).wday-1]
end

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

int main() {
	int N,M,c=0;
	map<string,int> s;
	string t;

	cin >> N;
	rep(i,N) {
		cin >> t;
		if(s.count(t))
			++s.at(t);
		else
			s[t] = 1;
	}

	cin >> M;
	rep(i,M) {
		cin >> t;
		if(s.count(t))
			--s.at(t);
	}

	for(auto p : s)
		c = max(c, p.second);
	cout << c << endl;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    string _S;
    cin >> _S;
    ll Q;
    cin >> Q;
    ll rev = 0;
    deque<char> S;
    REP(i,0,SZ(_S)) S.push_back(_S[i]);
    REP(i,0,Q) {
        ll t;
        cin >> t;
        if(t == 1) rev = 1 - rev;
        else {
            ll f;
            char c;
            cin >> f >> c;
            if((rev + f-1) % 2 == 0) S.push_front(c);
            else S.push_back(c);
        }
    }
    if(rev == 0) {
        while(!S.empty()) {
            cout << S.front();
            S.pop_front();
        }
    }
    else {
        while(!S.empty()) {
            cout << S.back();
            S.pop_back();
        }
    }

    return 0;
}

/*



*/

Measured memory_bytes: 3996
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

#define int long long

#define VI vector<int> 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数定義や変数宣言
int n,q;

bool bs(int* S, int key){

int right=n;
int left=0;

while(left<right){

	int middle=(right+left)/2;

	if( S[middle]==key){return true;}
	else if(S[middle]>key){ right=middle; }
	else { left=middle+1; }

}

return false;

}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

cin>>n;
int S[n];
REP(i,n){cin>>S[i];}
cin>>q;
int T[q];
REP(i,q){cin>>T[i];}

int cnt=0;

for( auto t:T)
{
	if( bs(S,t) ){ cnt++;}
}




cout<<cnt<<endl;










































}


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

int n;
vector<long long> v;

long long solve();

int main() {
  cin >> n;
  v.resize(n);
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    v[--x] = i;
  }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  for(int i = 0; i < n; ++i) {
    long long cnt = 0, now = v[i];
    while(i < n && now <= v[i]) {
      now = v[i];
      ++cnt;
      ++i;
    }
    if(i != n) --i;
    ans = max(ans, cnt);
  }
  return n - ans;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		int min = n;
		for (int i=0;i<n-1;i++) {
			if(s.charAt(i) != s.charAt(i+1)) {
				min = Math.min(min, Math.max(i+1, n-i-1));
			}
		}
		System.out.println(min);
	}

}


Measured memory_bytes: 26068
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  int p=0;
  int ans=0;
  REP(i,N){
    int a;
    cin>>a;
    if(a==p){
      p=0;
      ans++;
    }else{
      p=a;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC87 D
#重み付きUnion-Find

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

def root(x):
    if x == par[x]:
        return par[x]
    y = root(par[x])
    wei[x] += wei[par[x]]
    par[x] = y
    return y

def union(x,y,w):
    rx = root(x)
    ry = root(y)
    if rank[rx] < rank[ry]:
        par[rx] = ry
        wei[rx] = w - wei[x] + wei[y]
    else:
        par[ry] = rx
        wei[ry] = -w - wei[y] + wei[x]
        if rank[rx] == rank[ry]:
            rank[rx] += 1


n,m = LI()
par = [i for i in range(n)]
rank = [0]*n
wei = [0]*n
for i in range(m):
    l,r,w = LI()
    if root(l-1) != root(r-1):
        union(l-1,r-1,w)
    else:
        if wei[l-1] - wei[r-1] != w:
            print('No')
            quit()
print('Yes')


Measured memory_bytes: 87584
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
const int inf = 1000000000; //10^9
using ll = long long;
using P = pair<int,int>;
//加算代入演算子は+=！！！！！

int main() {
    int n, l;
    cin >> n >> l;
    vector<string> vec(n);
    rep(i,n) cin >> vec.at(i);
    sort(vec.begin(), vec.end());
    rep(i, n) cout << vec.at(i);
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define FT() int t; scanf("%d",&t); while(t--)
#define pb push_back
#define nl printf("\n")
#define fi(i,start,end) for(int i=start; i < (int)end ; ++i)
#define ip(n)   scanf("%d",&n)
#define mz(a)   memset(a,0,sizeof(a))
#define inpArr(A,n) fi(i,0,n)   ip(A[i]);
#define print(a)  for(auto i : a)   cout<<i<<" "; nl;
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
ll max(ll a,ll b) { return a>b?a:b;}
ll min(ll a,ll b) { return a<b?a:b;}

void solve()
{
    
}
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    //std::cout << std::fixed;
    //std::cout << std::setprecision(6);
    
    int n;
    cin>>n;
    int rem = n%1000;
    if(rem!=0)
      cout<<(1000 - rem);
    else
      cout<<0;    

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
    #endif
    
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    int n, m; cin >> n >> m;
    vector<vector<pair<int, int>>> edge(n);
    FOR(i, 0, m) {
        int l, r, d; cin >> l >> r >> d;
        l--, r--;
        edge[l].push_back(make_pair(r, d));
        edge[r].push_back(make_pair(l, -d));
    }

    VI x(n, INF + 1);
    FOR(i, 0, n) {
        if (x[i] != INF + 1)continue;
        x[i] = 0;
        queue<int> bfs;
        bfs.push(i);
        while (!bfs.empty()) {
            int from = bfs.front(); bfs.pop();
            for (auto to : edge[from]) {
                if (x[to.first] != INF + 1) {
                    if (x[to.first] != x[from] + to.second) {
                        cout << "No\n";
                        return 0;
                    }
                    else continue;
                }
                x[to.first] = x[from] + to.second;
                bfs.push(to.first);
            }
        }
    }
    cout << "Yes\n";
}


Measured memory_bytes: 9344
#include<stdio.h>
#include<string.h>

int main(){
		int h,w,i,j;
		char s[26][26][6];
		scanf("%d%d",&h,&w);
		for(i=0;i<h;i++){
				for(j=0;j<w;j++){
						scanf("%s",s[i][j]);
				}
		}
		for(i=0;i<h;i++){
				for(j=0;j<w;j++){
						if(strcmp(s[i][j],"snuke")==0){
								printf("%c%d\n",'A'+j,i+1);
								return 0;
						}
				}
		}
}								


Measured memory_bytes: 128
module Main where

import Data.List.Split
import Debug.Trace

allDigitsEqual :: Int -> Bool
allDigitsEqual n
  | n < 10 = True
  | otherwise = let
                  x = n `div` 10
                  y = x `mod` 10
                  z = n `mod` 10
                  in y == z && allDigitsEqual x

algorithm :: Int ->  Int
algorithm n = head [x | x <- [n..], allDigitsEqual x]

process :: [String] -> String
process ls = show $ algorithm (read (head ls))

main :: IO ()
main = do
  input <- getContents
  putStrLn $ process (lines input)

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


WORDS = ["dream", "dreamer", "erase", "eraser"]


def can_construct(s):
    while len(s) > 0:
        for word in WORDS:
            i = s.rfind(word)
            if i != -1 and len(s) == i + len(word):
                s = s[:i]
                break
        else:
            return False
    return True


def main():
    print("YES" if can_construct(input()) else "NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> S(n);
    rep(i, n) cin >> S[i];
    int q;
    cin >> q;
    int ans = 0;
    rep(i, q){
        int qi;
        cin >> qi;
        if ( *lower_bound(S.begin(), S.end(), qi) == qi) ans++;
    }
    cout << ans << endl;
}




Measured memory_bytes: 3132
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);++i)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;--i)
#define FOR(i,s,n) for(int i = s;i < (int)n;++i)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;--i)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline void out(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e18;

signed main(){
	int N,K;
	cin >> N >> K;
	vector<int>a(N);
	REP(i,N){
		cin >> a[i];
	}
	sort(ALL(a));
	vector<int>b = a;
	reverse(ALL(b));
	auto f =[&](int x)->bool{
		int sum = 0;
		auto f =[&](int y,int i)->bool{
			if(a[i] < 0)return x < b[y]*a[i];
			else return x < a[y]*a[i];
		};
		int cnt = 0;
		REP(i,N){
			int l = -1,r = N;
			while(r - l > 1){
				int c = (l + r) / 2;
				if(f(c,i)) r = c;
				else l = c;
			}
			sum += r;
			if(a[i]>=0&&i<r)cnt++;
			if(a[i]<0&&(N-i-1)<r)cnt++;
		}
		return (sum-cnt)/2>=K;
	};
	int l = -1e18-1, r = 1e18 + 1;
	while(r - l > 1){
		int c = (l + r) / 2;
		if(f(c)) r = c;
		else l = c;
	}
	cout << r << endl;
}

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

int c[3], n, ans, tmp;

int main(){
	cin >> c[0] >> c[1] >> c[2] >> n;
	sort(c, c+3);
	ans = 0;
	for (int i = 0; i <= n/c[1]; ++i){
		for (int j = 0; j <= (n-i*c[1])/c[2]; ++j){
			tmp = n - i*c[1] - j*c[2];
			if (tmp < 0) break;
			else if (tmp % c[0] == 0) ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[]={1,4,1,4,1,2,1,2};
  int b[8];
  while(cin>>b[0]){
    int p=0,c=0,p2=0;
    for(int i=1;i<8;i++)cin>>b[i];
      for(int i=0;i<8;i++){
        int sum=0,p1=0;
        for(int j=i,k=0;k<8;k++,j++){
          p1*=10;
          if(a[j%8]<=b[k])sum+=a[j%8],p1+=a[j%8];
          else sum+=b[k],p1+=a[j%8];
        }
        //cout<<p1<<endl;
        if(sum>c){
          c=sum;
          p=i;
          p2=p1;
        }
        else if(sum==c){
          if(p1<p2){
            c=sum;
            p=i;
            p2=p1;
          }
        }
      }
    for(int j=p,k=0;k<8;k++,j++){
      if(k)cout<<' ';
      cout<<a[j%8];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 3080
import decimal
decimal.getcontext().prec = 100
def sum1(pre,l,r):
    l=max(l,0)
    if(l==0):
        return pre[r]
    return pre[r] - pre[l - 1]

x=int(raw_input())
ans=0
if(x<=9):
    ans=x
elif(x>=10 and x<100):
    ans=9
elif(x>=100 and x<1000):
    ans=9+x-99
elif(x>=1000 and x<10000):
    ans=9+900
elif(x>=10000 and x<100000):
    ans=9+900+x-9999
elif(x>=100000):
    ans=9+900+90000
print ans        


# a,b,c=map(int,raw_input().split())
# if(b+c<=a):
#     print 0
#     exit()
# print c-(a-b)
# # t=1
# # while(t!=0):
# #     t=t-1

Measured memory_bytes: 4268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll a(n);
    vll cnt(100001, 0);
    rep(i, n){
        cin >> a[i];
        cnt[a[i]]++;
    }
    sort(ALL(a));
    dump(a);
    ll p1 = 1, p2 = 100000;
    while(1){
        while(p1 <= 100000 && cnt[p1] < 2) p1++;
        while(p2 >= 1 && cnt[p2] < 2) p2--;
        if(p1 > p2) break;
        if(p1 == p2){
            while(cnt[p1] > 1) cnt[p1] -= 2;
            break;
        }else{
            while(min(cnt[p1], cnt[p2]) > 1){
                cnt[p1]--;
                cnt[p2]--;
            }
            if(cnt[p1] == 1) p1++;
            if(cnt[p2] == 1) p2--;
        }
    }
    ll ans = 0;
    repr(i, 1, 100001){
        ans += (cnt[i] >= 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    rep(i, x)cin >> a[i];
    rep(i, y)cin >> b[i];
    rep(i, z)cin >> c[i];
    sort(rall(a));
    sort(rall(b));
    sort(rall(c));
    vector<ll> ans(k);
    priority_queue<tuple<ll, ll, ll, ll>> que;
    que.push(make_tuple(a[0] + b[0] + c[0], 0, 0, 0));
    ll ma = 0, mb = 0, mc = 0;
    map<tuple<ll, ll, ll>, ll> mp;
    rep(i, k){
        tuple<ll, ll, ll, ll> now = que.top();
        que.pop();
        ll pa = get<1>(now), pb = get<2>(now), pc = get<3>(now);
        if(mp[make_tuple(pa, pb, pc)]){
            i--;
            continue;
        }
        ans[i] = get<0>(now);
        mp[make_tuple(pa, pb, pc)]++;
        if(pa < x-1)que.push(make_tuple(a[pa+1] + b[pb] + c[pc], pa+1, pb, pc));
        if(pb < y-1)que.push(make_tuple(a[pa] + b[pb+1] + c[pc], pa, pb+1, pc));
        if(pc < z-1)que.push(make_tuple(a[pa] + b[pb] + c[pc+1], pa, pb, pc+1));
    }
    rep(i, k)cout << ans[i] << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
long long n, a, b, ans;
int main(){
	scanf("%lld%lld%lld", &n, &a, &b);
	ans = n / (a + b) * a;
	ans += min(n%(a+b),a);
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n;
	cin>>n;
	multiset<int> arr;
	while(n--) {
		int val;
		cin>>val;
		arr.insert(val);
	}
	int m;
	cin>>m;
	while(m--) {
		int val;
		cin>>val;
		if(arr.find(val)!=arr.end()) {
			arr.erase(arr.find(val));
		} else {
			cout<<"NO";
			return;
		}
	}
	cout<<"YES";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 13012
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
using namespace std;
int main(){
  int n;
  cin>>n;
  cout<<800 * n - (n / 15) * 200;
  system ("pause");
  return 0;
  }
  

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

namespace _0369
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            double ret = 0;
            for (int i = 0; i < x[0]; i++)
            {
                double[] a = Console.ReadLine().Split().Select(double.Parse).ToArray();
                ret = Math.Max(ret,x[1] * a[1] / a[0]);
            }
            Console.WriteLine(ret);
        }
    }
}


Measured memory_bytes: 9876
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	          int i,j;

	      	  cin.tie(0);  ios_base::sync_with_stdio(false);

	      	  ll N,M;
	      	  cin >> N >> M;

	      	  if(N==1 && M==1){
	      		  cout << 1 << endl;
	      		  return 0;
	      	  }

	      	  if(N==1 || M==1){
	      		  ll a=max(M,N);
	      		  cout << a-2 << endl;
	      		  return 0;
	      	  }

	      	  cout << (N-2)*(M-2) << endl;

	      	  return 0;

}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int c=0,i,j,k,n, x;

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

		if (n == 0 && x == 0) {
			break;
		}

		for (i = 1; i <= n - 2; i++) {
			for (j = i + 1; j <= n - 1; j++) {
				for (k = j + 1; k <= n; k++) {
					if (x == i + j + k) {
						c++;
					}
				}
			}
		}

		printf("%d\n", c);
		c = 0;
	}

	return;
}


Measured memory_bytes: 2076
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	int a[110];
	while (cin >> n) {
		for (int i=0; i<n; ++i) cin >> a[i];
		sort(a, a+n);
		for (int i=1; i<n; ++i) a[i] += a[i-1];
		int res = 0;
		for (int i=0; i<n; ++i) res += a[i];
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REP1(i, n) for(ll i = 1;i < n;i++)
#define REPR(i, n) for(ll i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())

#define ll long long
#define ALL(a)  (a).begin(),(a).end()

#define pb(a) push_back(a)
#define MOD 1000000007

int now,n,a,b,c,d;


int main(){
  cin >> n >> a>>b>>c>>d;
  a--;
  b--;
  c--;
  d--;
  string s;cin>>s;
  int lf=a;
  int rt=max(c,d);
  //まず岩が2連続でおかれてないか
  int cnt=0;
  for(int i=lf;i<rt+1;i++){
    if (s[i]=='#'){
      cnt++;
      if (cnt==2){
        cout<<"No"<<endl;
        return 0;
      }
    }else{
      cnt=0;
    }
  }

  //次にd<cのとき追い抜けるか
  if (d<c){
    //b～dの追い越し区間で一つ岩が置ければ良い
    for(int i=b;i<d+1;i++){
      if (s[i]=='.'){
        int flg=0;
        if (i>0){
          if (s[i-1]=='#'){
            flg++;
          }
        }

        if (i<n-1){
          if (s[i+1]=='#'){
            flg++;
          }
        }
        if (flg==0){
          cout<<"Yes"<<endl;
          return 0;
        }


      }
    }
    cout<<"No"<<endl;
    return 0;

  }else{
        cout<<"Yes"<<endl;
        return 0;
  }





  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

struct Sieve {
	int n;
	vector<int> f, primes;
	Sieve(int n = 1) :n(n), f(n + 1) {
		f[0] = f[1] = -1;
		for (ll i = 2; i <= n; ++i) {
			if (f[i]) continue;
			primes.push_back(i);
			f[i] = i;
			for (ll j = i * i; j <= n; j += i) {
				if (!f[j]) f[j] = i;
			}
		}
	}
	bool isPrime(int x) { return f[x] == x; }
	vector<int> factorList(int x) {
		vector<int> res;
		while (x != 1) {
			res.push_back(f[x]);
			x /= f[x];
		}
		return res;
	}
	vector<P> factor(int x) {
		vector<int> fl = factorList(x);
		if (fl.size() == 0) return {};
		vector<P> res(1, P(fl[0], 0));
		for (int p : fl) {
			if (res.back().first == p) {
				res.back().second++;
			}
			else {
				res.emplace_back(p, 1);
			}
		}
		return res;
	}
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n = 100000;
	Sieve si(n);
	vector<int> rec(100005);
	for (int i = 1; i <= n; i++) {
		if (si.isPrime(i) && si.isPrime((i + 1) / 2)) rec[i]++;
		rec[i + 1] += rec[i];
	}
	int q;
	cin >> q;
	while (q--) {
		int l, r;
		cin >> l >> r;
		cout << rec[r] - rec[l - 1] << endl;
	}
	return 0;
}


Measured memory_bytes: 4256
import java.util.Scanner;
public class Main {
		static void solve() {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int x = sc.nextInt();
			int sum = 0;
			int res = 0;
			int[] array = new int [n];
			for(int i = 0;i<n;i++) {
				int l = sc.nextInt();
				sum+=l;
				if(sum<=x) {
					res++;
				}
			}
			System.out.println(res+1);
			sc.close();
		}
		public static void main(String[] args) {
			solve();

	}

}


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

vector<int> sho(vector<int> &p){
    int nm = log2(p.size());
    int m = pow(2,nm);
    vector<int> ans(p.size() - m + 1);
    vector<vector<int>> rui(p.size() + 1, vector<int>(2));
    rui[0][0] = 0;
    rui[0][1] = 0;
    repp(j,p.size() + 1,1){
        if (p[j-1] == 1){
            rui[j][0] = rui[j-1][0] + 1;
            rui[j][1] = rui[j-1][1];
        }
        else if (p[j-1] == 2){
            rui[j][1] = rui[j-1][1] + 1;
            rui[j][0] = rui[j-1][0];
        }
        else{
            rui[j][0] = rui[j-1][0];
            rui[j][1] = rui[j-1][1];
        }
    }
    rep(i,ans.size()){
        if (rui[i+m][0] - rui[i][0] == 0){
            if ((rui[i+m][1] - rui[i][1]) % 2 == 1){
                ans[i] = 2;
            }
            else{
                ans[i] = 0;
            }
        }
        else if ((rui[i+m][0] - rui[i][0]) % 2 == 1){
            ans[i] = 1;
        }
        else{
            ans[i] = 0;
        }
    }
    return ans;
}

int main(){
    int n;
    cin >> n;
    vector<int> bit(n);
    string s;
    cin >> s;
    int a;
    string ss;
    rep(i,n){
        ss = s.at(i);
        a = atoi(ss.c_str());
        bit[i] = a-1;
    }
    vector<int> nans = bit;
    while (nans.size() > 1){
        nans = sho(nans);
    }
    cout << nans[0] << endl;
}

Measured memory_bytes: 65540
#if __has_include("../library/Basic/Debug.hpp")

#include "../library/Basic/Debug.hpp"

#else

/* ----- Header Files ----- */
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>
#include <cstdint>


/* ----- Type Alias ----- */
using Bool = bool;
using Int = long long int;
using Real = long double;
using Char = char;
using String = std::string;
template <class T, class U>
using Pair = std::pair<T, U>;
template <class... Ts>
using Tuple = std::tuple<Ts...>;

template <class T>
using Vector = std::vector<T>;
template <size_t N>
using Bits = std::bitset<N>;
template <class T>
using Queue = std::queue<T>;
template <class T>
using Stack = std::stack<T>;
template <class T>
using Deque = std::deque<T>;

template <class T>
using MaxHeap = std::priority_queue<T>;
template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T>
using Set = std::set<T>;
template <class T, class U>
using Map = std::map<T, U>;

template <class T, class... Us>
using Func = std::function<T(Us...)>;

template <class T>
T genv(T v) { return v; }

template <class T, class... Ts>
auto genv(size_t l, Ts... ts) {
    return Vector<decltype(genv<T>(ts...))>(l, genv<T>(ts...));
}

template <class Cost = Int>
struct Edge {
    Int src, dst;
    Cost cost;
    Edge(Int src = -1, Int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = Int>
using Edges = Vector<Edge<Cost>>;
template <class Cost = Int>
using Graph = Vector<Vector<Edge<Cost>>>;

#endif

/* ----- Misc ----- */
void fastio() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

struct Fout {
    Int precision;
    Fout(Int precision) : precision(precision) {}
};
std::ostream& operator<<(std::ostream& os, const Fout& fio) {
    os << std::fixed << std::setprecision(fio.precision);
    return os;
}


/* ----- Constants ----- */
// constexpr Int INF = std::numeric_limits<Int>::max() / 3;
// constexpr Int MOD = 1000000007;
// constexpr Real PI = acos(-1);
// constexpr Real EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));

int main() {
    Int n;
    std::cin >> n;

    Vector<Real> v(n);
    for (auto& x : v) std::cin >> x;
    std::sort(v.begin(), v.end());

    Real ans = v[0];
    for (Int i = 1; i < n; ++i) {
        ans = (ans + v[i]) / 2;
    }

    std::cout << Fout(10) << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll W,H,x,y;
    cin >> W >> H >> x >> y;
    bool flg = true;
    if(x * 2 == W && y * 2 == H){
        flg = true;
    }else{
        flg = false;
    }
    double S = (double) W * (double) H / 2.0;
    if(flg){
        cout << setprecision(10) << S << " " << "1" << endl;
    }else{
        cout << setprecision(10) << S << " " << "0" << endl;
    }
    

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  ll n,m;
  cin>>n>>m;
  vector<ll> ret;
	for(int i=1 ; i*i<=m; ++i)
	{
		if(m%i == 0)
		{
			ret.push_back(i);
			if(i*i!=m)
			{
				ret.push_back(m/i);
			}
		}
	}
  sort(ret.begin(),ret.end());
  
  for(int i = ret.size() - 1; i > -1; i--)
  {
    if(n * ret[i] <= m) {
      cout << ret[i] << endl;
      return 0;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256