akhauriyash/Code-Regression huggingface dataset:
N = int(input())
S = list((x.encode()[0] - "a".encode()[0] for x in input()))
alb = [-1] * 26
ala = [-1] * 26
Sc = [0] * (len(S)+1)
for i, c in enumerate(S):
    if alb[c] == -1:
        alb[c] = i+1
        Sc[alb[c]] += 1
    else:
        if ala[c] >= 0:
            Sc[ala[c]] += 1
        ala[c] = i+1
        Sc[ala[c]] -= 1

for i, v in enumerate(ala):
    if v == -1 and alb[i] >= 0:
        Sc[alb[i]] -= 1

x = 0
m = 0
for c in Sc[:N]:
    x += c
    m = max(x, m)

print(m)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

#define MAX_N 100000

int dp[MAX_N + 1][3];

signed main(){
	int n;
	cin >> n;
	int a[n], b[n], c[n];
	REP(i,n){
		cin >> a[i] >> b[i] >> c[i];
	}
	for(int i = 0; i < n; i++){
		dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a[i];
		dp[i + 1][1] = max(dp[i][0], dp[i][2]) + b[i];
		dp[i + 1][2] = max(dp[i][0], dp[i][1]) + c[i];
	}
	cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
	return 0;
}

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

using namespace std;

int n;
string s;
vector<int> V;
int ans;
int s_sum;

void input(){

  cin >> n;
  cin >> s;
  int m;
  cin >> m;
  while(m--){
    int in;
    cin >> in;
    V.push_back(in);
  }
}

void solve(int odd, int even, int sum){

  if(odd+even > 0){
    for(int i = 0; i < V.size(); i++){
      if(odd > 0) solve(odd-1,even,sum+V[i]);
      else if(even > 0) solve(odd,even-1,sum+(V[i]*2)/10+(V[i]*2)%10);
    }
  }else{
    // cout << "ans " << s_sum+sum << endl;
    if((s_sum+sum)%10 == 0) ans++;
  }
}


int main(){

  input();
  int num = 0, odd = 0,even = 0;
  reverse(s.begin(),s.end());

  for(int i = 0; i < s.length(); i++){
    if(i%2 == 0){
      if(s[i] == '*') odd++;
      else s_sum += s[i]-'0';
    }else{
      if(s[i] == '*') even++;
      else{
	int tmp = s[i]-'0';
	tmp *= 2;
	s_sum += tmp/10;
	s_sum += tmp%10;
      }
    } 
  }

  solve(odd,even,0);
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1356
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>

using namespace std;

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

const int SIZE = 310;

int x[SIZE*SIZE];
int y[SIZE*SIZE];
int sum[SIZE*SIZE];

int main() {
  int H, W, D;
  cin >> H >> W >> D;
  REP(h,H) REP(w,W) {
    int a; cin>>a;
    x[a] = w;
    y[a] = h;
  }
  for(int i = 1; i <= D; i++) {
    for(int j = i + D; j <= H*W; j += D) {
      int tmp = abs(x[j]-x[j-D]) + abs(y[j]-y[j-D]);
      sum[j] = sum[j-D] + tmp;
    }
  }
  //  REP(i,H*W) {                                                                      
  //    cout << i << " " << sum[i] << endl;;                                            
  //  }                                                                                 
  int Q; cin>>Q;
  while (--Q >= 0) {
    int	L, R; cin>>L>>R;
    int ans = sum[R] - sum[L];
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

double sum = 0, a, b;

int main(){
	while (cin >> a){
		sum += a;
		REP(i, 4){
			b = a * 2;
			sum += b;
			a = b / 3;
			sum += a;
		}
		printf("%.10lf\n", sum + a * 2);
		sum = 0;
	}
}

Measured memory_bytes: 1236
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>

using namespace std;

int main(){

    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(Q);
    vector<int> point(N, K-Q);
    for (int i = 0; i < Q; i++){
        cin >> A[i];
        A[i]--;
    }

    for (int i = 0; i < Q; i++){
        point[A[i]]++;
    }

    for (int i = 0; i < N; i++){
        if (point[i] > 0){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}


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

using namespace std;

typedef long long ll;

#define MOD (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()

ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}



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

ll n,temp;
cin>>n;

vl a(n+1);

map<ll,ll>m1,m2;

for(int i=1;i<=n;i++)
  {
    cin>>temp;
    if(i&1)m1[temp]++;
    else m2[temp]++;
  }
  vector<pll>v1,v2;

  for(auto x:m1)
  {
    v1.pb({x.ss,x.ff});   // count:value/number
  }
   for(auto x:m2)
  {
  //  cout<<x.ff<<endl;
    v2.pb({x.ss,x.ff});
  }

v1.pb({0,0});
v2.pb({0,0});

//for(auto x:v2)cout<<x.ff<<" "<<x.ss<<endl;

ll ans=n;

sort(v1.rbegin(),v1.rend());

sort(v2.rbegin(),v2.rend());

ll a1=v1[0].ff;
ll b1=v1[0].ss;

ll a2=v2[0].ff;
ll b2=v2[0].ss;

if(b1==b2)
{
  ll b3=v1[1].ff;
  ll b4=v2[1].ff;

ll z=max(b3+a2,b4+a1);

//cout<<b4<<"\n";

ans-=z;

}

else ans=ans-a1-a2;

//cout<<b1<<" "<<b2<<"\n";

cout<<ans<<"\n";



return 0;

}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  int ans = a[0];
  REP(i,n) ans = __gcd(ans, a[i]);
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)

int main(void)
{
    int a, b;
    cin >> a >> b;
    ll ans = 0;
    if (a > b)
        rep(i, 0, a) ans = 10 * ans + b;
    else
        rep(i, 0, b) ans = 10 * ans + a;
    cout << ans << endl;
}


Measured memory_bytes: 256
a, b, k = map(int, input().split(' '))
if b - a + 1 < 2 * k:
  for i in range(a, b + 1):
    print(i) 
else:
  for i in range(a, a + k):
    print(i)
  for i in range(b - k + 1, b + 1):
    print(i)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int a,b,x,y,r;
	while(1){
		cin>>a>>b;
		if(cin.eof())	break;
		x=a;	y=b;
		while(1){
			if(b>a)	swap(a,b);
			r=a%b;
			if(r==0)	break;
			a=b;
			b=r;
		}
		cout<<b<<" "<<(long long)x*y/b<<endl;
	}
	return 0;
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
typedef vector <pair<int,int>> vpii;
typedef pair <int,int> pii;

int n, k;
vector<int> A, T;
priority_queue <int> mx;
vector <int> B;

int X(int ps){
	int i = ps + (k * 2), w = 0;
	if(T[ps] == 0) i--;
	if(ps == B.size()) return 0;
	if(i >= (int)B.size()) i = B.size() - 1;
	if(ps == 0) w = max(w, B[i]);
	else
	w = max(w, (B[i] - B[ps - 1]));
	w = max(w, X(ps + 1));
	return w;
}

int main() {
	cin >> n >> k;
	string x;
	cin >> x;
	char t = x[0]; int c = -1;
	for(int i = 0; i < n; i++){
		if(t != x[i] || i == 0){
			A.push_back(1);
			T.push_back(x[i] - '0');
			c++;
		}
		else{
			A[c]++;
		}
		t = x[i];
	}

	B.push_back(A[0]);
	for(int i = 1; i < (int)A.size(); i++) B.push_back(B[i - 1] + A[i]);
	cout << X(0) << endl;
	return 0;
}


Measured memory_bytes: 4916
import java.util.*;

public class Main {
    static boolean[][] canPass;
    static int n;
    static int count = 0;
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        int m = sc.nextInt();
        int[] p = new int[m];
        int[] q = new int[m];
        canPass = new boolean[n][n];
        Boolean[] visited = new Boolean[n];
        Arrays.fill(visited, false);
        
        for (int i = 0; i < m; i++) {
            p[i] = sc.nextInt() - 1;
            q[i] = sc.nextInt() - 1;
            canPass[p[i]][q[i]] = true;
            canPass[q[i]][p[i]] = true;
        }
        
        dfs(0, visited);
        
        System.out.println(count);
    }
    
    public static void dfs(int p, Boolean[] visited) {
        if (visited[p]) return;
        
        // Deepコピー、値渡しのコピー
        Boolean[] copyVisited = visited.clone();
        copyVisited[p] = true;
        
        boolean notAllVisited = Arrays.asList(copyVisited).contains(false);
        if (!notAllVisited) count++;
        
        for (int q = 0; q < n; q++) {
            if (canPass[p][q]) {
                dfs(q, copyVisited);
            }
        }
    }
}

Measured memory_bytes: 23124
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct S {//辺の情報を入れる変数
	int from, to, cost;
};
struct H {
	int x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(ld a, ld b, ld c, ld d) {
	return sqrt(pow(a - c, 2) + pow(b - d, 2));
}//rad＝座標上の2点間の距離
int ari(int a, int b, int c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int n, s = 1;
	cin >> n;
	for (int i = 0; i <= sqrt(n) + 10; i++) {
		if (i*i <= n)
			s = i*i;
	}
	cout << s << endl;
	getchar(); getchar();
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007LL;

int main(void) {
    int r, D;
    ll x;
    cin >> r >> D >> x;
    for (int i=0;i<10;i++) cout << (x = r*x - D) << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func stringToStrings(s string) (strings []string) {
	strings = make([]string, len(s))
	for i, r := range s {
		strings[i] = string(r)
	}
	return
}

func main() {
	var s0, s1, s2 string
	fmt.Scan(&s0, &s1, &s2)
	ans := stringToStrings(s0)[0] + stringToStrings(s1)[1] + stringToStrings(s2)[2]
	fmt.Println(ans)
}


Measured memory_bytes: 512
#C
S = input()
N = len(S) + 1
A = [0]*N
for i in range(N-1):#前から
    if S[i] == "<":
        A[i+1] = max(A[i]+1, A[i+1])
for i in range(N-2, -1, -1):#後ろから
    if S[i] == ">":
        A[i] = max(A[i], A[i+1]+1)
print(sum(A))


Measured memory_bytes: 23348
#include <iostream>
#include <map>

char input()
{
    char result;
    std::cin >> result;
    return result;
}

int main()
{
    auto in = input();
    std::map<char,char> solver;
    solver['A'] = 'T'; solver['T'] = 'A';
    solver['C'] = 'G'; solver['G'] = 'C';
    std::cout << solver[in] << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(int i=a;i<b;i++)
#define rFor(i,a,b) for(int i=a;i>b;i--)
#define sort(a,b) sort(a.begin(),b.end())
#define reverse(a,b) reverse(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//vector<vector<int>> data(a,vector<b>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数
//ceil(log10(a)) aの10進法での桁数

int main() {
  string a,b;
  ci(a);
  b="Yes";
  for(int i=0;i<a.size();i+=2)
    if(a[i]!='R'&&a[i]!='U'&&a[i]!='D')
      b="No";
  for(int i=1;i<a.size();i+=2)
    if(a[i]!='L'&&a[i]!='U'&&a[i]!='D')
      b="No";
  co(b);
}

Measured memory_bytes: 256
#!/usr/bin/ruby
require'rational'
n,m=gets.split.map(&:to_i)
a=m.times.map{gets}
if a[0].split.length>1
	a=a[0].split.map(&:to_i)
else
	a=a.map(&:to_i)
end
puts a.reduce(n.to_i){|n,e|n=n.gcd(e%n)}==1?'Yes':'No'

Measured memory_bytes: 29412
#include <iostream>
#include <string>
#include <cctype>
#include <fstream>

using namespace std;

int main(){

    int n;
    string taroA, hanakoA;
    int taroS=0,hanakoS=0;

    cin >> n;
    for(int i=0;i<n;i++){
        cin >> taroA >> hanakoA;

        if(taroA < hanakoA){hanakoS+=3;}
        else if(taroA > hanakoA){taroS+=3;}
        else{taroS +=1;hanakoS+=1;}
    }

    cout << taroS << " " << hanakoS << endl;

    return 0;
}


Measured memory_bytes: 3144
def main():
    n = int(input())
    # m*(m+1)/2 = n
    # 2n = m^2+m
    x = 0
    for i in range(n+1):
        if n <= i*(i+1)//2:
            x = i
            break
    for i in range(1, x+1):
        if i == x*(x+1)//2 - n:
            continue
        print(i)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
const double pi=acos(-1.0);
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int main(void){
    int n;
    cin>>n;
    int a;
    for(int i=0;i<12;++i){
        a=1000*i;
        if(a-n>=0){
            cout<<a-n<<endl;
            return 0;
        }
    }
    
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        Scanner sc = new Scanner(System.in);
        int a=0,b= 0;
        
        a = sc.nextInt();
        b = sc.nextInt();
        String[] str = new String[a];
        for (int i=0; i<a; i++){
            str[i] = sc.next();
        }
        
        
            for (int j=0;j<b+2;j++){
                System.out.print("#");
            }
            System.out.println();
            for(int i= 0;i<a;i++){
                System.out.println("#"+ str[i] + "#");
            }
        for (int j=0;j<b+2;j++){
                System.out.print("#");
        }
    }
}


Measured memory_bytes: 21844
from bisect import bisect
a,b,q = map(int, input().split())
s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]

inf = float('INF')
for _ in range(q):
    x = int(input())
    # print('x', x)
    ss = bisect(s, x)
    tt = bisect(t, x)
    ans = inf
    for i in range(max(ss-1,0),min(ss+1,a)):
        for j in range(max(tt-1,0),min(tt+1,b)):
            ii,jj = abs(s[i] - x) + abs(s[i] - t[j]), abs(t[j] - x) + abs(s[i] - t[j])
            tmp = min(ii,jj)
            if ans > tmp:
                ans = tmp
    print(ans)



Measured memory_bytes: 12072
(let* ((k (read-line))
       (a 0))
  (defun parse-int-ex (n)
    (cond ((stringp n) (parse-integer n))
          ((char= n #\1) 1)
          ((char= n #\2) 2)
          ((char= n #\3) 3)
          ((char= n #\4) 4)
          ((char= n #\5) 5)
          ((char= n #\6) 6)
          ((char= n #\7) 7)
          ((char= n #\8) 8)
          ((char= n #\9) 9)
          ((char= n #\0) 0)))
  (setq a (reduce #'+ (mapcar #'parse-int-ex (concatenate 'list k))))
  (if (= 0 (mod (parse-integer k) a))
      (princ "Yes")
      (princ "No")))

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

int main() {
  long n,absmax=0,absmaxi=0;
  cin >> n;
  vector<long> a(n),ans1,ans2;
  for(long i=0;i<n;i++) cin >> a[i];
  
  for(long i=0;i<n;i++) {
    if(absmax<abs(a[i])) {
      absmax=abs(a[i]);
      absmaxi=i;
    }
  }
  for(long i=0;i<n;i++) {
    if(i==absmaxi) continue;
    ans1.push_back(absmaxi+1);
    ans2.push_back(i+1);
  }
  if(a[absmaxi]>0) {
    for(long i=0;i<n-1;i++) {
      ans1.push_back(i+1);
      ans2.push_back(i+2);
    }
  } else if(a[absmaxi]<0) {
    for(long i=n-2;i>=0;i--) {
      ans1.push_back(i+2);
      ans2.push_back(i+1);
    }
  }
  cout << ans1.size() << endl;
  for(long i=0;i<ans1.size();i++) cout << ans1[i] << " " << ans2[i] << endl;
}

Measured memory_bytes: 3628
#include<iostream>

using namespace std;


int main()
{
	int hiroiwa;
	int hiroyama;

	int keniwa;
	int kenyama;

	int iwap;
	int yamap;

	int iwabo;
	int yamabo;

	int hirop;
	int kenp;

	cin >> hiroiwa >> hiroyama;
	cin >> keniwa >> kenyama ;

	cin >> iwap >> yamap >> iwabo >> yamabo ;

	hirop = hiroiwa*iwap + hiroyama*yamap + hiroiwa / 10 * iwabo + hiroyama / 20 * yamabo;
	kenp = keniwa*iwap + kenyama*yamap + keniwa / 10 * iwabo + kenyama / 20 * yamabo;

	if (hirop < kenp)
	{
		cout << "kenjiro" << endl;
	}
	else if (hirop > kenp)
	{
		cout << "hiroshi" << endl;
	}
	else if (hirop == kenp)
	{
		cout << "even" << endl;
	}

	return 0;
}


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

string s;
int gNum,pNum,Ans,Len;

int main ()
{
	cin >> s;
	Len=s.length ();
	for (int i=0;i<Len;++i) 
		if (s[i]=='g') 
			if (gNum>pNum) pNum++, Ans++;
			else gNum++;
		else 
			if (gNum>pNum) pNum++;
			else gNum++, Ans--;
	cout << Ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int maxn = 200000 + 10;
const int MOD = 1000000007;

inline int inc(int a, int b) { return (a + b >= MOD) ? (a + b - MOD) : (a + b); }
inline int dec(int a, int b) { return (a >= b) ? (a - b) : (a + MOD - b); }
inline int mul(int a, int b) { return 1LL * a * b % MOD; }

inline int power(int x, int k) {
	int tmp = 1;
	while(k) {
		if(k & 1) tmp = mul(tmp,x);
		x = mul(x,x);
		k >>= 1;
	}
	return tmp;
}

int n;
struct BIT{
	int c[maxn];
	inline void init() { memset(c,0,sizeof(c)); }
	inline int lowbit(int k) { return k & - k; }
	inline void add(int x, int k) {
		for(int i = x;i <= n;i += lowbit(i)) c[i] = inc(c[i],k);
	}
	inline int query(int x) {
		int tmp = 0;
		if(x <= 0) return 0;
		for(int i = x;i;i -= lowbit(i)) tmp = inc(tmp,c[i]);
		return tmp;
	}
	inline int query(int l, int r) {
		if(l > r) return 0;
		return dec(query(r),query(l - 1));
	}
}B1, B2;

int a[maxn], cnt[maxn], pre[maxn], num[maxn], val[maxn], ival[maxn];
int main() {
  scanf("%d", &n);
	for(int i = 1;i <= n;i ++) scanf("%d", &a[i]);
	for(int i = 1;i <= n;i ++) cnt[a[i]] ++;
	cnt[n + 1] = 0;
	for(int i = n;i >= 1;i --) cnt[i] += cnt[i + 1];
	for(int i = 1;i <= n;i ++) cnt[i] -= n - i;
	int Ans = 0, sum = 1;
	for(int i = 1;i <= n;i ++) sum = mul(sum,cnt[i]);
	B1.init(); B2.init();
	val[0] = pre[0] = 1;
  for(int i = 1;i <= n;i ++) {
    int now = mul(cnt[i] - 1,power(cnt[i],MOD - 2));
		if(!now) {
			num[i] = num[i - 1] + 1;
			pre[num[i]] = i;
			val[i] = val[i - 1];
		}
		else {
			num[i] = num[i - 1];
			val[i] = mul(val[i - 1],now);
		}
		ival[i] = power(val[i],MOD - 2);
	}
	int inv2 = power(2,MOD - 2);
	for(int i = 1;i <= n;i ++) {
		int now = mul(B1.query(pre[num[a[i]]],a[i]),val[a[i]]);
		now = mul(now,mul(sum,inv2));
		Ans = inc(Ans,now);
		B1.add(a[i],ival[a[i]]);
	}
	B1.init();
	for(int i = n;i >= 1;i --) {
		int t1 = mul(B1.query(pre[num[a[i]]],a[i] - 1),val[a[i]]);
		int t2 = mul(B2.query(1,a[i] - 1),sum);
		t1 = mul(t1,mul(sum,inv2));
		int now = dec(t2,t1);
		Ans = inc(Ans,now);
		B1.add(a[i],ival[a[i]]);
		B2.add(a[i],1);
	}
	printf("%d\n", Ans);
	return 0;
}	


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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
#define pii pair<int, int>
#define all(a) a.begin(),a.end()
template <typename T>
inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }

int main(){
    int n, k;
    cin >> n >> k;
    for(int i=0; i<n; ++i){
        int x;
        cin >> x;
    }

    n = n-k;
    cout << 1 + (n+k-2)/(k-1);
}

Measured memory_bytes: 3556
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;
int main(){
    int n,m,a[200000],b[200000],C[1000][1000];
    cin>>n>>m;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int j=0;j<m;j++) cin>>b[j];
    long long ans=1,INF=1000000007;
    long long x=0,y=0;
    sort(a,a+n,greater<int>());
    sort(b,b+m,greater<int>());
    if(a[0]!=n*m||b[0]!=n*m) ans=0;
    for(int i=0;i<n-1;i++) if(a[i]==a[i+1]) ans=0;
    for(int i=0;i<m-1;i++)
if(b[i]==b[i+1]) ans=0;
    for(int i=n*m;i>0;i--){
        if(i==a[x+1]) x=x+1;
        if(i==b[y+1]) y=y+1;
        if(i==a[x]&&i==b[y]) ans=ans;
        else if(i==a[x]) ans=(ans*(y+1))%INF;
        else if(i==b[y]) ans=(ans*(x+1))%INF;
        else ans=(ans*((x+1)*(y+1)-(n*m-i)))%INF;
    }
    cout<<ans;
}

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

using namespace std;

int r[111111], w[111111];
int n, m;

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%d%d",&n,&m);
	r[1] = 1;
	for(int i = 1; i <= n; ++i) w[i] = 1;
	while (m--){
		int a, b;
		scanf("%d%d",&a,&b);
		if (r[a]) r[b] = 1;
		++w[b];
		if (--w[a] == 0) r[a] = 0;
	}
	int an = 0;
	for(int i = 1; i <= n; ++i) an += r[i] == 1;
	printf("%d",an);
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int n=s.size();
  int ans=0;
  for(int i=1;i<(n+1)/2;i++){
    int c=0;
    for(int j=1;j<=i;j++){
      if(s.at(j-1)!=s.at(i+j-1)){
        c++;
      }
    }
    if(c==0){
      ans=max(ans,2*i);
    }
  }
  cout << ans << endl;
}
      


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<map>

using namespace std;
#define endl '\n'
#define pb push_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1e9 + 7)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define REP(i,n) for(int i = 0;i < (n);i++)
#define FOR(i,a,b) for(int i = (a);i <= (b);i++)
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl


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

template <class T = int> T in() { T x; cin >> x; return (x); }
template <class T = int> void out(T x) { cout << (x) << endl; }

int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

ll sum(ll n) {
	if (n == 1) return 1;
	return n + sum(n - 1);
}

void solve() {

	ll n, m;
	cin >> n >> m;
	vector<ll> a(n);
	vector<ll> sr(n + 1);
	REP(i, n) {
		cin >> a[i];
		sr[i + 1] = (sr[i] + a[i]) % m;
	}

	map<int, ll> cr;
	ll ans = 0;
	cr[0] = 1;
	FOR(i, 1, n) {
		cr[sr[i]]++;
		ans += cr[sr[i]];
	}

	ans -= n;

	out(ans);

	return;

}

int main() {

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

	solve();

	return 0;

}

Measured memory_bytes: 5760
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
using namespace std;

#define ll long long

#define debug_message 0
#define debug if (debug_message)

#define sz(x) (int)x.size()

int i,t,j;
int n,m,nt;
string s,a[5];
bool ok;

int main() {
	cin>>s;

	if (sz(s)<5) ok=0;
	else {
		a[1]="dreamer";
		a[2]="eraser";
		a[3]="dream";
		a[4]="erase";

		ok=1;
		t=sz(s);
		while(t>0 && ok) {
			ok=0;
			for (i=1; i<=4; ++i) {
				if (t-sz(a[i])<0) continue;
				
				if (s.substr(t-sz(a[i]),sz(a[i]))==a[i]) {
					ok=1;
					t-=sz(a[i]);
				}
			}
		}
	}
	
	if (ok==0) printf("NO\n");
	else printf("YES\n");

	return 0;
}
/*

*/

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

int main(){

  int x,y,z;
  
  cin >> x >> y >> z;
  
  cout << z << " " << x << " " << y << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
                                        #include<iostream>
                                        #include<cstdio>
                                        #include<vector>
                                        #include<queue>
                                        #include<map>
                                        #include<cstring>
                                        #include<string>
                                        #include <math.h>
                                        #include<algorithm>
                                    //    #include <boost/multiprecision/cpp_int.hpp>
                                        #include<functional>
                           //     #define int long long
                                        #define inf  1000000007
                                        #define pa pair<int,int>
                                        #define ll long long
                                        #define pal pair<double,pa>
                                        #define ppa pair<int,int>
                                        #define ppap pair<pa,pa>
                                        #define ssa pair<string,int>
                                        #define  mp make_pair
                                        #define  pb push_back
                                        #define EPS (1e-10)
                                        #define equals(a,b) (fabs((a)-(b))<EPS)
                                  #define VI vector<int>
                                        using namespace std;
                                        
                                  class pas{
                                    	public:
                                    	int x,y;
                                    	pas(int x=0,int y=0):x(x),y(y) {}
                                    	pas operator + (pas p) {return pas(x+p.x,y+p.y);}
                                    	pas operator - (pas p) {return pas(x-p.x,y-p.y);}
                                    	pas operator * (int a) {return pas(x*a,y*a);}
                                    	pas operator / (int a) {return pas(x/a,y/a);}
                                    //	double absv() {return sqrt(norm());}
                                    	int norm() {return x*x+y*y;}
                                    	bool operator < (const pas &p) const{
                                    		return x != p.x ? x<p.x: y<p.y;
                                    	}
                                    	bool operator == (const pas &p) const{
                                    		return x==p.x && y==p.y;
                                    	}
                                    };
int a[60]={0};
           signed main(){
     string s,t;
           	cin>>s>>t;
           	sort(t.begin(),t.end());
           	sort(s.begin(),s.end());
           	reverse(t.begin(),t.end());
           	if(s<t)cout<<"Yes"<<endl;
           	else cout<<"No"<<endl;
           }
             

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

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

int main() {
    // get values from input
    int N, M;
    cin >> N >> M;
    
    vector<int> A(N);
    REP(i, N) {
        READ(A[i]);
    }

    // main procedure
    double sum = accumulate(ALL(A), 0);
    int requirement = ceil(sum / (4 * M));
    
    bool ans = true;
    sort(ALL(A), greater<int>());
  
    REP(i, M){
        if (A[i] < requirement) {
            ans = false;
            break;
        }
    }

    // output
    WRITE_N(ans ? "Yes" : "No");

    return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++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 comb(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;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    LL h;
    cin >> h;

    LL t = 0;
    while( h >= 1 ) {
        h >>= 1;
        ++t;

    }
    cout << (1ll << (t)) - 1 << endl;
    return 0;
}



Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;
import java.util.StringTokenizer;
 
public class Main
{
    public static final long MOD = 1_000_000_007;
    public static void main(String[] args) throws IOException {
//        BufferedReader in = new BufferedReader(new FileReader("pathsonagrid.txt"));
        Scanner in = new Scanner(System.in);
 
//        StringTokenizer line = new StringTokenizer(in.readLine());
        StringTokenizer line = new StringTokenizer(in.nextLine());
 
        int n = Integer.parseInt(line.nextToken());
        int m = Integer.parseInt(line.nextToken());
        
        char[][] grid = new char[n][m];
        for (int i = 0; i < n; i++)
//            grid[i] = in.readLine().trim().toCharArray();
            grid[i] = in.nextLine().trim().toCharArray();
        
        long[][] paths = new long[n][m];
        paths[0][0] = 1;
        for (int r = 0; r < n; r++) {
            for (int c = 0; c < m; c++) {
                if (grid[r][c] == '#')
                    continue;
                try { //look above
                    paths[r][c] += paths[r-1][c] % MOD;
                } catch (Exception e) {}
                try { //look left
                    paths[r][c] += paths[r][c-1] % MOD;
                } catch (Exception e) {}
            }
        }
        
        System.out.println(paths[n-1][m-1] % MOD);
    }
}

Measured memory_bytes: 62516
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let ans = 1000 - (n % 1000);
    if ans == 1000 {
        println!("{}", 0);
    } else {
        println!("{}", ans);
    }
}


Measured memory_bytes: 2140
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <queue>
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

int main(void) {
  int h, w;
  cin>>h>>w;
  vector<string> v;
  for(int i=0; i<h; i++) {
    string s;
    cin>>s;
    v.push_back(s);
  }
  queue<vector<int>> q;
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      if(v[i][j] == '#') {
	vector<int> vv(3);
	vv[0] = 0;
	vv[1] = i;
	vv[2] = j;
	q.push(vv);
      }
    }
  }
  int d[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
  int cnt=0;
  while(!q.empty()) {
    vector<int> vv = q.front();
    q.pop();
    for(int i=0; i<4; i++) {
      int ny = vv[1] + d[i][0];
      int nx = vv[2] + d[i][1];
      if(0<=ny and ny<h and 0<=nx and nx<w
	 and v[ny][nx] == '.') {
	vector<int> nv(3);
	nv[0]=vv[0]+1;
	nv[1]=ny;
	nv[2]=nx;
	q.push(nv);
	v[ny][nx] = '#';
	cnt = max(cnt, nv[0]);
      }
    }
  }
  std::cout << cnt << std::endl;
  return 0;
}



Measured memory_bytes: 56756
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define M 1000010
ll f(ll a,ll b){
	ll ans=1;a=a%md;
	while(b){
		if(b&1)ans=(ans*a)%md;
		a=(a*a)%md;
		b/=2;
	}
	return ans;
}
ll fa[M],iv[M];
ll C(ll n,ll r){
	if(n==r)return 1;
	if(r<0 or n-r<0)return 0;
	ll ans=1;
	ans=fa[r]*fa[n-r];
	ans=f(ans,md-2)%md;
	ans=(ans*fa[n])%md;
	return ans;
}
int main(){
	IOS;
	fa[0]=1;
	rep(i,1,M)fa[i]=(fa[i-1]*i)%md;
	ll x,y;cin>>x>>y;
	ll t=x+y;
	ll ans=0;
	if(t%3!=0)ans=0;
	else{
		ll s=t/3;
		ll fx=s,fy=(t-s);
		if(x<fx)ans=0;
		else{
			ans=C(s,x-fx);	
		}
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 9728
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int main() {

	ll K;
	char S[123];

	scanf("%s%lld", S, &K);

	int l = strlen(S);
	rep(i, l) {
		if (S[i] != '1') {
			l = i;
		}
	}


	printf("%c\n", (K <= l) ? '1' : S[l]);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

// 入力
int N, M;
vector<vector<int> > G; // グラフ

// メモ化再帰
int dp[100100];
int rec(int v) {
    if (dp[v] != -1) return dp[v]; // 既に更新済み
    
    int res = 0;
    for (auto nv : G[v]) {
        chmax(res, rec(nv) + 1);
    }
    return dp[v] = res; // メモしながらリターン
}


int main() {
    // 入力受け取り
    cin >> N >> M;
    G.assign(N, vector<int>());
    for (int i = 0; i < M; ++i) {
        int x, y; cin >> x >> y;
        --x, --y; // 0-indexed にする
        G[x].push_back(y);
    }
    
    // 初期化
    for (int v = 0; v < N; ++v) dp[v] = -1;
    
    // 全ノードを一通り更新する
    for (int v = 0; v < N; ++v) {
        rec(v);
    }
    
    // 答え
    int res = 0;
    for (int v = 0; v < N; ++v) chmax(res, rec(v));
    cout << res << endl;
}

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

typedef long long ll;

int main(){
    priority_queue<pair<int,int>> pq;
    
    ll h;
    int n, a, b;
    cin >> n >> h;

    for(int i = 0; i < n; i++){
        cin >> a >> b;

        pq.push({a, 1});
        pq.push({b, 0});
    }

    int ans = 0;
    ll accum = 0;
    while(1){
        auto x = pq.top();  pq.pop();

        if(x.second == 1){
            ans += (h-accum+x.first-1) / x.first;
            accum = h;
        }else{
            ans++;
            accum += x.first;
        }

        if(accum >= h)  break;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  ll n;
  cin >> n;
  vector<ll> A(n);
  vector<ll> B(n);
  rep(i, n) cin >> A[i];
  rep(i, n) cin >> B[i];
  ll bowl = 0;
  ll need = 0;
  rep(i, n){
    if(A[i] > B[i]){
      need += A[i] - B[i];
    }else{
      bowl += (B[i] - A[i]) / 2;
    }
  }
  if(bowl >= need) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}
  
  

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
   long n,k,sum=0;
   cin >> n >>k;
   vector <int> a(n);
   for (auto i=0; i<n; i++)
   {
       cin >> a[i];
   }
   sort (a.begin(), a.end());
   for (auto i=0; i<k; i++)
   {
       sum=sum+a[i];
   }
   cout << sum;
   return 0;
}

Measured memory_bytes: 3592
h,w = map(int,input().split())
board = [input() for _ in range(h)]

def inb(x, y):
    return 0 <= x < h and 0 <= y < w

def count(x, y):
    if board[x][y] == '#':
        return '#'
    ret = 0
    for i in [-1, 0, 1]:
        for j in [-1, 0, 1]:
            if i == 0 and j == 0:
                continue
            nx, ny = x + i, y + j
            if not inb(nx, ny):
                continue
            if board[nx][ny] == '#':
                ret += 1
    return str(ret)

ret = [['?' for _ in range(w)] for _ in range(h)]
for i in range(h):
    for j in range(w):
        ret[i][j] = count(i, j)
for i in ret:
    print(''.join(i))

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

int main(){
	int x,y,w,h,r;
	cin >> w >> h >> x >> y >> r;
	
	if((x<=w-r)&&(x>=r)&&(y<=h-r)&&(y>=r )) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}



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

#define LL long long

int factor(int x){
	int res=0;
	while(x%2 == 0){
		res++;
		x/=2;
	}
	return res;
}

int main(){
	

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

	int n;
	cin>>n;

	int ans=0;
	for(int i=0;i<n;i++){
		int a;cin>>a;
		ans = ans + factor(a);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Aug  2 17:58:28 2020

@author: Paras
"""

n = int(input())
s = input()

i = 0
j = n-1
count = 0
while i<j:
    while i<n and s[i]=='R':
        i+=1
    while j>=0 and s[j]=='W':
        j-=1
    if i>=j:
        break
    count+=1
    i+=1
    j-=1
    
print(count)

Measured memory_bytes: 9280
import java.util.Scanner;

public class Main {
    private static final int INF = 10000;
    private static int[][] memo;

    private static int solve(int d, int g, int[] p, int[] c, int used) {
        if(memo[g][used] != 0) return memo[g][used];

        int res = INF;
        for(int i = 0; i < d; i++) {
            int bit = (int) Math.pow(2, i);
            if((used / bit) % 2 == 1) continue;

            if((i + 1) * (p[i] - 1) >= g) {
                res = Math.min(res, (int) Math.ceil(1.0 * g / (i + 1)));
            }else if ((i + 1) * p[i] + c[i] >= g) {
                res = Math.min(res, p[i]);
            }else {
                res = Math.min(res, p[i] + solve(
                    d, g - ((i + 1) * p[i] + c[i]), p, c, used + bit
                ));
            }
        }
        memo[g][used] = res;
        return res;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int d = sc.nextInt();
        int g = sc.nextInt() / 100;

        int[] p = new int[d];
        int[] c = new int[d];
        for(int i = 0; i < d; i++) {
            p[i] = sc.nextInt();
            c[i] = sc.nextInt() / 100;
        }

        memo = new int[105501][1024];
        System.out.println(solve(d, g, p, c, 0));

        sc.close();
    }
}

Measured memory_bytes: 615504
N, M = map(int, input().split())
H = list(map(int, input().split()))

# N,M=O(10^5)なので、O(N+M)で解く
# 各ノードについて、隣接する展望台の高さの最大値を更新する
neighbor_max = [0] * N
for _ in range(M):
  A, B = map(int, input().split())
  neighbor_max[A - 1] = max(neighbor_max[A - 1], H[B - 1])
  neighbor_max[B - 1] = max(neighbor_max[B - 1], H[A - 1])

# 各ノードについて、自身の高さと、隣接する展望台の高さの最大値を比較する
# 接続を一つも持たないノードについても、計算は正しい
ans = 0
for i in range(N):
  if H[i] > neighbor_max[i]: ans += 1
    
print(ans)

Measured memory_bytes: 20100
def solve():
    import math
    K = int(input())
    ans = 0
    for i in range(1, K+1):
        for j in range(1, K+1):
            for k in range(1, K+1):
                ans += math.gcd(math.gcd(i,j), k)
    print(ans)

if __name__ == "__main__":
    solve()

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

int main(){
    int a,b,c;
    cin >>a>>b>>c;
    if (a*b*c==175) cout <<"YES"<<endl;
    else cout << "NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
P = list(map(int, input().split()))

INF = 10 ** 18
A = [0] * N
mn = INF
for i, p in enumerate(P):
    if p < mn:
        mn = p
        A[i] = p
    else:
        A[i] = mn

ans = 0
for i, p in enumerate(P):
    if A[i] >= p:
        ans += 1
print(ans)

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

using namespace std;
using ll = long long;

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

int main() {
  int n, k;
  cin >> n >> k;
  int v[n];
  rep(i, n) cin >> v[i];
  vector<int> l(n + 1), r(n + 1);
  rep(i, n) {
    l[i + 1] = l[i] + v[i];
    r[i + 1] = r[i] + v[n - i - 1];
  }

  int ans = 0;
  for (int a = 0; a <= min(n, k); ++a) {
    for (int b = 0; b <= min(n, k); ++b) {
      if (a + b > min(n, k)) break;
      int sum = 0;
      vector<int> neg;
      rep(i, a) {
        if (v[i] >= 0)
          sum += v[i];
        else
          neg.push_back(v[i]);
      }
      rep(i, b) {
        if (v[n - i - 1] >= 0)
          sum += v[n - i - 1];
        else
          neg.push_back(v[n - i - 1]);
      }
      sort(neg.begin(), neg.end());
      rep(i, neg.size()) {
        if (i + (k - (a + b)) >= (int)neg.size()) break;
        sum += neg[i + (k - (a + b))];
      }
      ans = max(ans, sum);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int long long

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1,i,j;
    //cin>>t;
    while(t--)
    {
        int n,m,flag=0,count=0,sum=0,maxi=0,mini=1e18;
        cin>>n;

        int a[n],b[n];
        for(i=0;i<n;i++)
        {
            cin>>a[i]>>b[i];
        }
        sort(a,a+n);
        sort(b,b+n);
        if(n%2)
        {
            cout<<b[n/2]-a[n/2]+1;
        }
        else
        {
            int temp=(a[n/2]+a[n/2-1]);
            int tempp=(b[n/2]+b[n/2-1]);
            int c=(a[n/2]+a[n/2-1])/2;
            int d=(b[n/2]+b[n/2-1])/2;
            if(temp%2!=0 && tempp%2==0)
            {
                cout<<(d-c)*2;
            }
            else if(temp%2==0 && tempp%2!=0)
            {
                cout<<(d-c+1)*2;
            }
            else if((tempp%2!=0 && temp%2!=0))
            {
                cout<<(d-c)*2+1;
            }
            else
            {
                cout<<(d-c)*2+1;
            }
        }
    }
}

Measured memory_bytes: 6780
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String str = scanner.next();

        int count = 0;
        for (int i = 0; i < n - 1; ++i) {
            if (str.charAt(i) != str.charAt(i + 1)) {
                ++count;
                ++i;
                continue;
            }
        }
        System.out.println(count);
    }
}



Measured memory_bytes: 29764
// {{{ by WangYenJen
#include <bits/stdc++.h>
using namespace std;
// types
typedef long long ll;
typedef pair<int,int> pii;
// macro
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin() , (x).end()
#define REP(i , n) for(int i = 0; i < int(n); i++)
#define REP1(i , a , b) for(int i = a; i <= int(b); i++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define LC o<<1 , l , m
#define RC o<<1|1 , m + 1 , r
#define MS(x , v) memset(x , (v) , sizeof(x))
// input
inline bool SR(int &x) {
	return scanf("%d",&x) == 1;
}
inline bool SR(ll &x) {
	return scanf("%lld",&x) == 1;
}
inline bool SR(double &x) {
	return scanf("%lf",&x) == 1;
}
inline bool SR(char *s) {
	return scanf("%s",s) == 1;
}
inline bool RI() {
	return true;
}
template<typename I , typename... T> inline bool RI(I &x , T&... tail) {
	return SR(x) && RI(tail...);
}
// output
inline void SP(const int x) {
	printf("%d",x);
}
inline void SP(const ll x) {
	printf("%lld",x);
}
inline void SP(const double x) {
	printf("%.16lf",x);
}
inline void SP(const char *s) {
	printf("%s",s);
}
inline void PL() {
	puts("");
}
template<typename I , typename... T> inline void PL(const I x , const T... tail) {
	SP(x);
	if(sizeof...(tail)) putchar(' ');
	PL(tail...);
}
// debug
#define WangYenJen
#ifdef WangYenJen
template<typename I> void _DOING(const char *s , I&& x) {
    cerr << s << " = " << x << endl;
}
template<typename I , typename... T> void _DOING(const char *s , I&& x , T&&... tail) {
    int c = 0;
    while(*s != ',' || c != 0) {
        if(*s == '(' || *s == '[' || *s == '{') c++;
        if(*s == ')' || *s == ']' || *s == '}') c--;
        cerr << *s++;
    }
    cerr << " = " << x << " , ";
    _DOING(s + 1 , tail...);
}
#define debug(...) \
do {\
    fprintf(stderr , "%s:%d - ",__PRETTY_FUNCTION__,__LINE__);\
    _DOING(#__VA_ARGS__ , __VA_ARGS__);\
} while(0);
#else
#define debug(...)
#endif
// random function
inline int RAND() {
	static int x = 880301;
	return (x = x * 0xdefaced + 1) & 0x7fffffff;
}
// }}}

const int MAX_N = 1000 + 10;
char s[MAX_N];
int main() {
    RI(s);
    int n = strlen(s);
    int a = 0 , b = 0 , c = 0 , d = 0;
    REP(i , n) {
        if(s[i] == 'N') a = 1;
        else if(s[i] == 'S') b = 1;
        else if(s[i] == 'E') c = 1;
        else d = 1;
    }
    if(a == b && c == d) PL("Yes");
    else PL("No");
    return 0;
}


Measured memory_bytes: 256