akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

  sort(S.begin(), S.end());
  S.erase(unique(S.begin(), S.end()), S.end());

  string ans = "None";

  for (int i = 1; i < S.size(); i++) {
    if (S.at(i) - S.at(i - 1) != 1) {
      ans = S.at(i - 1) + 0x01;
      break;
    }
  }

  cout << ((S.at(0) != 'a') ? "a" : (S.size() == 25 && S.at(24) == 'y') ? "z" : ans) << endl;
}

Measured memory_bytes: 512
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let a: Vec<i64> = sc.vec(n);
    let b: Vec<i64> = sc.vec(n);

    let mut ca = a.clone();
    ca.sort();
    let mut cb = b.clone();
    cb.sort();
    for i in 0..n {
        if ca[i] > cb[i] {
            println!("No");
            return;
        }
    }

    let mut ba = (0..n).map(|i| (b[i], a[i])).collect::<Vec<_>>();
    ba.sort();
    let a = ba.iter().map(|&(_, a)| a).collect::<Vec<_>>();
    let b = ba.iter().map(|&(b, _)| b).collect::<Vec<_>>();
    let mut a = a
        .into_iter()
        .enumerate()
        .map(|(i, a)| (a, i))
        .collect::<Vec<_>>();
    a.sort();
    let mut vis = vec![false; n];
    let mut cur = 0;
    vis[cur] = true;
    loop {
        cur = a[cur].1;
        if vis[cur] {
            break;
        }
        vis[cur] = true;
    }

    if vis.into_iter().any(|a| !a) {
        println!("Yes");
        return;
    }

    for i in 1..n {
        let prev_b = b[i - 1];
        let next_a = a[i].0;
        if prev_b >= next_a {
            println!("Yes");
            return;
        }
    }
    println!("No");
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 16636
#include<stdio.h>
#include<stdlib.h>
int N,Q,S[100005],T,C,i;

int c(int *a,int *b)
{
	return *a-*b;
}
int main()
{
	scanf("%d",&N);
	for(i=0;i<N;i++)
		scanf("%d",S+i);
	scanf("%d",&Q);
	for(i=0;i<Q;i++)
	{
		scanf("%d",&T);
		if(bsearch(&T,S,N,sizeof(int),c)!=NULL)
			C++;
	}
	printf("%d\n",C);
	return 0;
}

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

#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rrep(i,n) for(ll i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)
#define rrep1(i,n) for(ll i = (n); i > 0; i--)

#define ll long long

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  string s;cin>>s;
  ll dp[13];
  rep(i, 13)dp[i]=0;
  dp[0]=1;
  rep( i, s.size() ){
    ll ndp[13];
    rep(j, 13)ndp[j]=0;

    if(s[i]=='?'){
      rep(c, 10){
        rep(from, 13){
          ll to = (from*10+c)%13;
          ndp[to] += dp[from];
          ndp[to] %= MOD;
        }
      }
    }else{
      ll c = (ll)(s[i]-'0');
      rep(from,13){
        ll to = (from*10+c)%13;
        ndp[to] += dp[from];
        ndp[to] %= MOD;
      }
    }
    rep(j, 13)dp[j] = ndp[j]%MOD;

//rep(i, 13)cout<<dp[i]<<' ';cout<<endl;

  }

  cout<<dp[5];

  return 0;
}

Measured memory_bytes: 512
<?php
$count = intval(fgets(STDIN));

$nums = array();
for ($i=0; $i < $count; $i++) { 
	$nums[$i] = explode(" ", trim(fgets(STDIN)));
}

foreach ($nums as $val) {
	$n1 = intval($val[0]);
	$n2 = intval($val[1]);
	$n3 = intval($val[2]);

	if( ($n1 * $n1) + ($n2 * $n2) == ($n3 * $n3) || ($n1 * $n1) + ($n3 * $n3) == ($n2 * $n2) || ($n2 * $n2) + ($n3 * $n3) == ($n1 * $n1) )
		echo "YES\n";
	else
		echo "NO\n";
}

Measured memory_bytes: 7424
#include<bits/stdc++.h>
 
using namespace std;
#define lli long long int 
#define pb push_back
#define fi(i,a,p) for(int i = a; i < p; i++)
#define pp pair<ll , ll>
#define mp make_pair
#define setzero(a) memset(a,0,sizeof(a))
#define setdp(a) memset(a,-1,sizeof(a))


int main(){
	int n,p;
	cin>>n>>p;
	int s=4*n-p;
	int w=p-2*n;
	if(s%2==0&&s>=0&&s/2<=n&&w%2==0&&w>=0){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}


 return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define N 7368794
using namespace std;

int prime[N] = {0};
int n, m, now = 0;

int sprime() {
  int i, j;
  for(i = n; i < N; ++i)
    if(prime[i] == 0) {
      if(now == m) return i;
      ++now;
      for(j = 1; i * j < N; ++j) prime[i * j] = 1;
    }
  return 0;
}

int main() {
  while(1) {
    memset(prime, 0, sizeof(prime));
    cin >> n >> m;
    now = 0;
    if(n + m == 0) break;
    cout << sprime() << endl;
  }
  return 0;
}



Measured memory_bytes: 31844
n,k,q = map(int,input().split())
a=[int(input()) for _ in range(q)]
point=[k-q for i in range(n)]
for i in range(q):
    point[a[i]-1]+=1
 
for i in range(n):
    if(point[i]>0):
        print("Yes")
    else:
        print("No")
 

Measured memory_bytes: 11800
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<=(end);i++)
#define REP(i, n) FOR(i,1,n)
#define IFOR(i, begin, end) for(int i=(end);i>=(begin);i--)
#define IREP(i, n) IFOR(i,1,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())

#define ll long long
using namespace std;

int main()
{
	stringstream ss;
    // 入力
    ll N;
    cin>>N;
    struct data{
    	ll A;
    	ll B;
    	ll dif;
    	bool operator<( const data& right ) const {
    		return dif==right.dif ? A < right.A : dif< right.dif;
    	}
    };
    // ll A[N+1],B[N+1],dif[N+1];
    vector<data> data(N);
    FOR(i,0,N-1){
    	cin>>data[i].A;
    	cin>>data[i].B;
    	data[i].dif=data[i].A+data[i].B;
    }
    sort(data.begin(),data.end());
    ll ans=0;
    IFOR(i,0,N-1){
    	// cout<<i<<" "<<data[i].dif<<endl;
    	if(i%2==(N-1)%2) ans+=data[i].A;
    	else ans-=data[i].B;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main(int argc, char const *argv[])
{
	unsigned int ant[5] = {0};
	unsigned int k;
	
	cin >> ant[0] >> ant[1] >> ant[2] >> ant[3] >> ant[4] >> k;
	
	for(unsigned i = 0; i < 5; ++i) {
		for(unsigned j = i + 1; j < 5; ++j) {
			if(abs((int)(ant[i] - ant[j])) <= k) {
				continue;
			} else {
				cout << ":(" << endl;
				return 0;
			}
		}
	}

	cout << "Yay!" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
A,B,C,D = map(int,input().split())
if A > 10000 or B > 10000 or C > 10000 or D > 10000:
    sys.exit()
if A * B >= C * D:
    print(A*B)
    sys.exit()
if A * B <= C*D:
    print(C*D)
    sys.exit()

Measured memory_bytes: 9072
#include <stdio.h>
#include <math.h>
 
double getsquare(double x1,double y1,
        double x2,double y2,
        double x3,double y3);
 
int main(void) {
    double chouten[20][2];
    double s=0;
    int i;
    int max;
    for(i=0;i<20;i++) {
        if(scanf("%lf,%lf",&chouten[i][0],&chouten[i][1])==-1)break;
    }
    max=i;
    for(i=1;i<max-1;i++) {
        s+=getsquare(chouten[0][0],chouten[0][1],
            chouten[i][0],chouten[i][1],
            chouten[i+1][0],chouten[i+1][1]);
    }
    printf("%f\n",s);
    return 0;
}
 
double getsquare(double x1,double y1,
        double x2,double y2,
        double x3,double y3) {
    double len1,len2,len3;
    double z;
    len1=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    len2=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
    len3=sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
    z=(len1+len2+len3)/2;
    return sqrt(z*(z-len1)*(z-len2)*(z-len3));
}

Measured memory_bytes: 1080
// AOJ 2153: Mirror Cave
// 2017.11.11 bal4u@uu

#include <stdio.h>
#include <string.h>
#define TM 0
#if TM
#include <time.h>
#endif

#define QMAX 100000
typedef struct { char lr, lc, rr, rc; } Q;
Q q[QMAX+2], *top, *end, *qmax = q+QMAX;

char ml[52][52], mr[52][52];
char mk[52][52][52][52];
int mvl[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
int mvr[4][2] = {{-1,0},{0,-1},{1,0},{0,1}};

int main()
{
	int w, h, r, c, lr, lc, rr, rc, i, f;
	int lr2, lc2, rr2, rc2;
#if TM
	clock_t start, finish;
	start = clock();
#endif
	for (r = 0; r <= 51; r++) ml[r][0] = mr[r][0] = '#';
	for (c = 0; c <= 51; c++) ml[0][c] = mr[0][c] = '#';

	while (scanf("%d%d", &w, &h) && w > 0) {
		for (f = 0, r = 1; r <= h; r++) {
			scanf("%s%s", ml[r]+1, mr[r]+1);
			if (f < 3) for (c = 1; c <= w; c++) {
				if (ml[r][c] == 'L') lr = r, lc = c, f |= 1;
				if (mr[r][c] == 'R') rr = r, rc = c, f |= 2;
			}
		}
		for (r = 1; r <= h; r++) ml[r][w+1] = mr[r][w+1] = '#';
		for (c = 1; c <= w; c++) ml[h+1][c] = mr[h+1][c] = '#';

		memset(mk, 0, sizeof(mk));
		q->lr = lr, q->lc = lc, q->rr = rr, q->rc = rc, top = q, end = q+1;
		mk[lr][lc][rr][rc] = 1;
		f = 0;
		while (top != end) {
			lr = top->lr, lc = top->lc, rr = top->rr, rc = top->rc;
			if (++top == qmax) top = q;
			if (ml[lr][lc] == '%' && mr[rr][rc] == '%') { f = 1; break; }
			if (ml[lr][lc] == '%' || mr[rr][rc] == '%') continue;

			for (i = 0; i < 4; i++) {
				lr2 = lr + mvl[i][0], lc2 = lc + mvl[i][1];
				rr2 = rr + mvr[i][0], rc2 = rc + mvr[i][1];
				if (ml[lr2][lc2] == '#') lr2 = lr, lc2 = lc;
				if (mr[rr2][rc2] == '#') rr2 = rr, rc2 = rc;
				if (mk[lr2][lc2][rr2][rc2]) continue;
				mk[lr2][lc2][rr2][rc2] = 1;
				end->lr = lr2, end->lc = lc2, end->rr = rr2, end->rc = rc2;
				if (++end == qmax) end = q;
			}
		}
		puts(f ? "Yes" : "No");
	}
#if TM
	finish = clock();
	printf("time %lf\n", (double)(finish-start)/CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 9164
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] ans=new int[26];
		Arrays.fill(ans, 51);
		for(int i = 0; i < n; i++){
			String a = sc.next();
			int[] tmp =new int[26];
			for(int j = 0; j < a.length(); j++){
				tmp[a.charAt(j)-'a']++;
			}
			for(int k=0; k<26; k++){
				ans[k]=Math.min(ans[k],tmp[k]);
			}
		}
		StringBuilder sb=new StringBuilder();
		for(int i = 0; i < 26; i++){
			for(int j = 0; j < ans[i]; j++){
				sb.append((char)(i+'a'));
			}
		}
		System.out.println(sb);
	}
}

Measured memory_bytes: 21204
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int dp[100100];
vector<vector<int>> g;

int dfs(int now){
    if(dp[now] != -1){
        return dp[now];
    }

    int res = 0;

    for(int i = 0; i < g[now].size(); i++){
        int tmp = dfs(g[now][i]) + 1;
        if(res < tmp) res = tmp;
    }

    dp[now] = res;

    return res;
}

int main(void){
    int n, m;
    cin >> n >> m;

    g.resize(n);

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

        a--;
        b--;

        g[a].push_back(b);
    }

    for(int i = 0; i < n; i++){
        dp[i] = -1;
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
        int tmp = dfs(i);
        if(ans < tmp)ans = tmp;
    }

    cout << ans << endl;

}

Measured memory_bytes: 8192
N,M,Q=map(int, input().split())
ma1=[[0]*501 for i in range(501)]
ma=[[0]*501 for i in range(501)]
inpath=[[int(j) for j in input().split()] for i in range(M)]
inQ=[[int(j) for j in input().split()] for i in range(Q)]

for i, j in inpath:
    ma1[i][j] += 1

for i in range(1, 501):
    for j in range(1, 501):
        ma[i][j] = ma[i][j-1] + ma1[i][j]
 

for fr, to in inQ:
    cnt = 0
    # print("from: {} to: {}".format(fr, to))
    for j in range(fr, to+1):
        cnt += (ma[j][to] - ma[j][j-1])
    print(cnt)


Measured memory_bytes: 116696
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

const ll mod = 1e9 + 7;

int main() {
  ll n;
  cin >> n;

  if (n <= 1) {
    puts("1");
    return 0;
  }

  ll fn = 2;
  ll fn1 = 1, fn2 = 1;
  rep(i, n - 2) tie(fn, fn1, fn2) = T(fn + fn1, fn, fn1);
  cout << fn << endl;

  return 0;
}



Measured memory_bytes: 3104
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower

using namespace std;
using ll = long long;

int main()
{
  ll q, h, s, d, n;
  cin >> q >> h >> s >> d;
  cin >> n;
  ll a = 8 * q, b = 4 * h, c = s * 2;
  ll e = min(a, min(b, min(c, d)));
  ll f = min(a/2, min(b/2, c/2));
  if (n % 2 == 0)
  {
    cout << n * e / 2;
  }
    else
    {
      cout << ((n - 1) / 2) * e + f;
    }
  }



Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;
#define int long long 
int cnt[10];
signed main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int x, y; cin >> x >> y; int flag = 0;
	if (y % 2 != 0) flag = 1;
	else {
		int mm = y / 2; int mi;
		if (y % 4 != 0) {
			y -= 2;
			mi = y / 4 + 1;
		}
		else mi = y / 4;
		if (x<mi || x>mm) flag = 1;
	}
	if (flag == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3132
s = input()
t = ""
last = ""
for i in s:
    if last == "B":
        if i == "C":
            t += "X"
        elif i == "B":
            t += last
        else:
            t += last
            t += i
    else:
        if i != "B":
            t += i
    last = i
count = 0
ans = 0
for i in t[::-1]:
    if i == "X":
        count += 1
    elif i == "A":
        ans += count
    else:
        count = 0
print(ans)

Measured memory_bytes: 3560
#include <iostream>
#include <string>

using namespace std;

int main(void) {
	int ok = 0, len;
	string s;
	cin >> s;
	len = s.size();
	if (s.find('N') < len && s.find('S') < len)
		ok++;
	else if (s.find('N') >= len && s.find('S') >= len)
		ok++;
	if (s.find('W') < len && s.find('E') < len)
		ok++;
	else if (s.find('W') >= len && s.find('E') >= len)
		ok++;
	if (ok == 2)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 256
S = gets.to_s.chomp!
a = S[2..-2]
b = 0
c = 0
a.length.times{|i| if a[i]=="C"
    b=b+1
    c=i
    end
}
T = "#{S}"
U = "#{S.downcase}"
T[0]=T[0].downcase
T[c+2]=T[c+2].downcase
if S.start_with?("A") && T == U && b == 1
    puts "AC"
else
puts "WA"
end

Measured memory_bytes: 1788
import sys
def 解():
    input = sys.stdin.readline
    iN = int(input())
    m4,m2,m1 = 0,0,0

    def fp():
        print("Yes")
    def fn():
        print("No")
    for a in input().split():
        a = int(a)
        if a % 4 ==0:
            m4 += 1
        elif a % 2 == 0:
            m2 += 1
        else:
            m1 += 1
    if m2 :
        if m1 <= m4:
            fp()
        else:
            fn()
    else:
        if m1 <= m4 + 1:
            fp()
        else:
            fn()
解()


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

int main() {
    string s;
    cin >> s;
    int n1 = stoi(s.substr(0, 2));
    int n2 = stoi(s.substr(2));
    bool m1 = (1 <= n1 && n1 <= 12);
    bool m2 = (1 <= n2 && n2 <= 12);
    if (m1 && m2) cout << "AMBIGUOUS" << endl;
    else if (m1) cout << "MMYY" << endl;
    else if (m2) cout << "YYMM" << endl;
    else cout << "NA" << endl;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Text.Printf

main :: IO ()
main = do
  n <- readLn :: IO Double

  when (n > 0) $ do
    s <- map read . words <$> getLine :: IO [Double]
    let
      m = sum s/n
    
    printf "%.8f\n" $ sqrt $ sum (map (\x -> (x-m)**2) s)/n

    main

Measured memory_bytes: 4948
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function () { return this.index < this.max },
        "next": function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { return this.list[this.index++]; } }
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)

const row = (c, x) => {
    for (let i = 0; i < c[x].length; i++) {
        c[x][i] = "r"
    }
}

const col = (c, x) => {
    for (let i = 0; i < c.length; i++) {
        c[i][x] = "r"
    }
}

const gen = (num) => {
    let ans = []
    const helper = (num, sub) => {
        if (num == 0) {
            ans.push(sub)
            return
        } else {
            helper(num - 1, [...sub, 0])
            helper(num - 1, [...sub, 1])
        }
    }
    helper(num, [])
    return ans
}

const count = (c) => {
    let ans = 0
    for (let i = 0; i < c.length; i++) {
        for (let j = 0; j < c[0].length; j++) {
            if (c[i][j] == "#") ans++
        }
    }
    return ans
}

const Main = () => {
    let [h, w, k] = nextIntArray()
    let c = []
    while (hasNext()) {
        c.push(next().split(""))
    }
    let ans = 0
    let rPat = gen(h)
    let cPat = gen(w)
    for (let i = 0; i < rPat.length; i++) {
        for (let j = 0; j < cPat.length; j++) {
            let tmp = JSON.parse(JSON.stringify(c))
            for (let l = 0; l < rPat[i].length; l++) {
                if (rPat[i][l] == 1) {
                    row(tmp, l)
                }
            }
            for (let l = 0; l < cPat[j].length; l++) {
                if (cPat[j][l] == 1) {
                    col(tmp, l)
                }
            }
            let cnt = count(tmp)
            if (cnt == k){
              ans++
            }
        }

    }
    console.log(ans)
}
Main()



Measured memory_bytes: 34520
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,Y;
  cin>>N>>Y;
  int y=Y/1000;
  int a,b,c;
  a=-1; b=-1; c=-1;
  for(int i=0;i<=N;i++){
  for(int j=0;j<=N-i;j++){
  if(9*i+4*j==y-N){
  a=i; b=j; c=N-i-j;
    break;
  }
  }
  
  }cout<<a<<" "<<b<<" "<<c<<endl;
  
   return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	int H,W;

	public void solve() {
		H = nextInt();
		W = nextInt();


		long ans = Long.MAX_VALUE;

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

			long one = (long)i * H;
			{
				long two = (long)(W - i) * (H / 2);
				long three = (long)H * W - one - two;
				long max = Math.max(one,Math.max(two,three));
				long min = Math.min(one,Math.min(two,three));
				ans = Math.min(ans, max - min);
			}
			{
				long two = (long)(W - i)/2 * H;
				long three = (long)H * W - one - two;
				long max = Math.max(one,Math.max(two,three));
				long min = Math.min(one,Math.min(two,three));
				ans = Math.min(ans, max - min);
			}
		}

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

			long one = (long)i * W;
			{
				long two = (long)(H - i) * (W / 2);
				long three = (long)H * W - one - two;

				long max = Math.max(one,Math.max(two,three));
				long min = Math.min(one,Math.min(two,three));
				ans = Math.min(ans, max - min);
			}

			{
				long two = (long)(H - i)/2 * W;
				long three = (long)H * W - one - two;

				long max = Math.max(one,Math.max(two,three));
				long min = Math.min(one,Math.min(two,three));
				ans = Math.min(ans, max - min);
			}
		}

		out.println(ans);

	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 23636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>
 
#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif
 
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define PER(i, N) for(int (i) = (N)-1; (i) >= 0; (i)--)
#define REP(i, N) for(int (i) = 0; (i) < (int)(N); (i)++)
 
using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }
void solve(istream& cin, ostream& cout) {
	ll X;
	cin  >> X;
	for(ll A = -1000; A <= 1000; A++) {
		for(ll B = -1000; B <= 1000; B++) {
			__int128 AA = A;
			__int128 BB = B;
			auto xc = AA*AA*AA*AA*AA-BB*BB*BB*BB*BB;
			if(xc == X) {
				cout << A << " " << B << endl;
				return;
			}
		}
	}
}


int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	solve(cin, cout);
	/*
	{
		istringstream instr("2\n2\n14");
		solve(instr, cout);
	}
 */
	return 0;
}


Measured memory_bytes: 3196
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

void load(void);
void calc(void);
void output(void);

int A, B, res;

int main(){
	load();
	calc();
	output();
	return 0;
}

void load(void){
	cin >> A >> B;
}

void calc(void){
	res = A * B;
}

void output(void){
	cout << res;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long A, B, C;
	cin >> A >> B >> C;
	long long r = 1LL<<60;
	r = min(r, A % 2 == 0 ? 0 : B * C);
	r = min(r, B % 2 == 0 ? 0 : C * A);
	r = min(r, C % 2 == 0 ? 0 : A * B);
	cout << r << endl;
}


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

int main(){
    int n,m;
    cin>>n>>m;
    if(m%n==0) cout<<m/n<<endl;
    else{
        for(int i=m/n;i>=1;i--){
            if(m%i==0){
                cout<<i<<endl;
                return 0;
            }
        }
    }
    
}


Measured memory_bytes: 256
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n = int(input())
    a = list(map(int, input().split()))
    dp = [0]*n
    dp[0] = 1000
    for i in range(n):
        for j in range(i):
            dp[i] = max([dp[j]+dp[j]//a[j]*(a[i]-a[j]), dp[j], dp[i]])
                    
    print(dp[-1])
        
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9208
#include<iostream>

using namespace std;


int main(){
	int m,n,year,money,tempMoney,tan_fuku,interest,commision,maxNum;
	double rate;
	
	cin>>m; //データセット数
	
	for(int i=0;i<m;i++){
		maxNum=0;
		cin>>money>>year>>n; //資金、運用年数、運用種類
		
		for(int j=0;j<n;j++){
			
			interest=0;
			tempMoney=money;
			
			cin>>tan_fuku>>rate>>commision; //単利複利の別、年利率、毎年の手数料
			
			for(int k=0;k<year;k++){
				
				if(tan_fuku==0){    //0なら単利
					interest+=tempMoney*rate;
					tempMoney-=commision;
				}
				else if(tan_fuku==1){	//1なら複利
					interest=tempMoney*rate;
					tempMoney+=interest-commision;
				}
			}
			
			if(tan_fuku==0){
				tempMoney+=interest;
			}
			
			if(tempMoney>maxNum){
				maxNum=tempMoney;
			}
		}
		cout<<maxNum<<endl;
	}
}

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

int main() {
	int N;
	cin >> N;
	vector<double> v(N);
	for (int i = 0; i < N; i++) cin >> v[i];
	sort(v.begin(), v.end());
	double ans = (v[0]+v[1])/2.0;
	for (int i = 2; i < N; i++) {
		ans += v[i];
		ans /= 2.0;
	}
	printf("%f\n", ans);
}


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

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

int main()
{
    int N,x;
    cin >> N;
    x = findsumofDigits(N);
    if(N%x ==0)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}




Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = Counter(list(map(int, input().split())))
Q = int(input())
change = list()
for _ in range(Q):
    b, c = map(int, input().split())
    change.append((b, c))

ans = 0
for num, count in A.items():
    ans += (num * count)

for a, b in change:
    ans -= (a * A[a])
    temp = A[a]
    A[a] = 0
    A[b] += temp
    ans += (b * temp)
    print(ans)


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

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

  
  string a[h];

 
  for(int j=0; j<w+2; j++)cout<<"#";
  cout<<endl;
  
  for(int k=0; k<h; k++){
  cin>>a[k];
    cout<<"#"<<a[k]<<"#"<<endl;
  }
  
  
  
  for (int i=0; i<w+2; i++)cout<<"#";
    cout<<endl;
  
 

 
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int n;
  cin >> n;
  double ans = 0;
  string u;
  double x;

  rep(i,n) {
    cin >> x >> u;
    if (u == "JPY") {
      ans += x;
    } else {
      ans += x * 380000.0;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
n,l = map(int,input().split())

al = []
for i in range(n):
    aji = l + i
    aji_ = abs(aji)
    al += [aji_]

x = abs(l)
an = 0
for i in range(n):
    if al[i] < x:
        x = al[i]
        an = i

ans = (l + l+n-1)*n/2 - (l+an)
print(int(ans))


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
int n;
char s[200005];
int rs[200005];
int main(){
	scanf("%d", &n);
	rs[0] = 0;
	for (int i = 0; i < n; i++){
		scanf(" %c", &s[i]);
		rs[i + 1] = rs[i] + (s[i] == '.');
	}
	int answer = 2000005;
	for (int i = 0; i < n; i++){
		//up to i (not inclusive) all white
		answer = min(answer, i - rs[i] + (rs[n] - rs[i]));
	}
	answer = min(answer, n - rs[n]);
	printf("%d\n", answer);
}

Measured memory_bytes: 1788
#include<cstdio>
#define mod 1000000007
	int n;
	long long f[300005],ans=0;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&f[i]);
	for (int k=0;k<=60;k++)
	{
		int x=0,y=0,cnt=0;
		for (int i=1;i<=n;i++) if (f[i]&(1ll<<k)) ++x;else ++y;
		for (int i=1;i<=n;i++) if (f[i]&(1ll<<k)) cnt=(cnt+y)%mod,--x;else cnt=(cnt+x)%mod,--y;
		ans=(ans+(1ll<<k)%mod*cnt%mod)%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4036
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,int>;
using ll=long long;

int main() {
  int N;
  cin >> N;
  vector<int> B(N);
  for (int i=0; i<N-1; i++) {
    cin >> B[i];
  }
  
  int S=B[0]+B[N-2];
  for (int i=1; i<N-1; i++) {
    S+=min(B[i-1], B[i]);
  }
  cout << S << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};


int main() {
    ll n; cin >> n;
    ll a,b; cin >> a >> b;
    ll ans = 0;
    ans += n/(a+b)*a;
    ll amari = n%(a+b);
    if (amari>=a) ans+=a;
    else ans+=amari;
    cout << ans << endl;
}

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

char s[12],t[12];
int rotate[10][10];
int n,ans;

void solve(int idx,int cost){
	if(idx == n) ans = min(ans,cost);

	if(s[idx] == t[idx]){
		solve(idx+1,cost);
	}
	else{
		for(int i=idx;i<n;i++){
			int r = rotate[s[idx]][t[idx]];
			for(int j=idx;j<=i;j++) s[j] = (s[j] + 10 + r) % 10;
			solve(idx+1,cost+1);
			for(int j=idx;j<=i;j++) s[j] = (s[j] + 10 - r) % 10;
		}
	}
}

int main(void){
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			int d = j - i;
			int x = abs(d);
			if(j < i && x > 10-x)
				d = 10-x;
			else if(j > i && x > 10-x)
				d = -(10-x);

			rotate[i][j] = d;
		}
	}

	while(cin>>n,n){
		cin>>s>>t;
		for(int i=0;i<n;i++){
			s[i] -= '0';
			t[i] -= '0';
		}

		ans = 999999999;
		solve(0,0);
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 876
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
const int mod = 1e9 + 7;
int n, m;
int a[maxn], b[maxn], deg[maxn];
inline int read() {
	int x; scanf("%d", &x); return x;
}
int main() {
	#ifdef LOCAL
		freopen("1.in", "r", stdin);
	#endif
	long long n;
	scanf("%lld", &n);
	vector<char>lst;
	while (n) {
		lst.push_back('a' + (n % 26 == 0 ? 26 : n % 26) - 1); 
		n = n - (n % 26 == 0 ? 26 : n % 26);
		n /= 26;
	}	
	reverse(lst.begin(), lst.end());
	for (auto g : lst) cout << g;
}	

Measured memory_bytes: 3672
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }
    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out){
            int n = in.nextInt();
            int[] arr = new int[n];
            double av  = 0;
            for (int i = 0; i <n; i++) {
                arr[i]=in.nextInt();
                av+=arr[i];
            }
            av/=n;
            double dis = 100;
            int ans = -1;
            for (int i = 0; i <n; i++) {
                if (Math.abs(arr[i]-av) <dis){
                    ans = i;
                    dis=Math.abs(arr[i]-av);
                }
            }
            System.out.println(ans);













        }




    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt(){return  Integer.parseInt(next());}
        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

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

int main(void)
{
  int a, b, d, r;
  double f;
  cin >> a >> b;
  d = a / b;
  r = a % b;
  f = double(a) / double(b);
  printf("%d %d %f\n", d, r, f);
  return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
#define int long long 
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=200005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

int N, A[MAXN];
map<int,int> M;
main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>N;
	FOR(i,1,N)cin>>A[i];
	int ans=0;
	FOR(i,1,N){
		ans += M[i-A[i]];
		M[A[i]+i]++;
	}
	cout<<ans;
}


Measured memory_bytes: 27824
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;

using std::vector;
using std::stack;

vector<bool> dfs(int n, const vector<vector<bool>>& c, int v_init){
    stack<int> stack;
    vector<bool> visited(n, false);
    stack.push(v_init);
    while(!stack.empty()){
        int v = stack.top();
        stack.pop();
        visited[v] = true;
        for(int i = 0; i < n; i++){
            if(c[v][i] && !visited[i]){
                stack.push(i);
            }
        }
    }
    return visited;
}


int main(void){
    int n, m;
    cin >> n >> m;

    vector<int> ea(m);
    vector<int> eb(m);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        ea[i] = a - 1;
        eb[i] = b - 1;
    }


    vector<vector<bool>> c(n, vector<bool>(n, false));
    for(int i = 0; i < m; i++){
        c[ea[i]][eb[i]] = true;
        c[eb[i]][ea[i]] = true;
    }

    int cnt = 0;
    for(int i = 0; i < m; i++){
        c[ea[i]][eb[i]] = false;
        c[eb[i]][ea[i]] = false;

        vector<bool> visited = dfs(n, c, 0);
        cnt += std::count(visited.begin(), visited.end(), true) != n;

        c[ea[i]][eb[i]] = true;
        c[eb[i]][ea[i]] = true;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
const int INF = INT_MAX;

int main(){
    int n, x, ans=0;
    vector<int> a;
    cin >> n >> x;
    a.resize(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    for(int i=0; i<n; i++){
        if(x>=a[i]){
            x -= a[i];
            ans++;
        }
        else{
            break;
        }
        if(i==n-1 && x>0){
            ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void coVec(const Vec1<T> &v){for(T i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n, d, a;
	cin >> n >> d >> a;
	VecP p(n);
	rep(i, n) cin >> p[i].fs >> p[i].sc;
	sort(all(p));
	Vec x(n), h(n);
	rep(i, n){
		x[i] = p[i].fs;
		h[i] = p[i].sc;
	}

	Vec dp(n+1);
	ll ans = 0;
	rep(i, n){
		ll cnt = h[i]/a;
		if(h[i]%a) cnt++;
		if(i) dp[i] += dp[i-1];
		if(cnt > dp[i]){
			cnt -= dp[i];
			dp[i] += cnt;
			ll pos = upper_bound(all(x), x[i]+2*d)-x.begin();
			dp[pos] -= cnt;
			ans += cnt;
		}
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 8064
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

a, b =  map(int, sys.stdin.readline().split())

if b < a:
    print(a - 1)
else:
    print(a)


Measured memory_bytes: 67820
#include<iostream>
#include<set>
#include<string>

using namespace std;

int main(void){
  int N;
  set<string> gacha;
  string s;
  
  cin >> N;
  
  for(int i = 0;i < N;i++){
    cin >> s;
    gacha.insert(s);
  }
  
  cout << gacha.size() << endl;
  
  return 0;
}


Measured memory_bytes: 19236
#include <bits/stdc++.h>
using namespace std;
int n;
long long a[100009];
long long dp[100009];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	dp[2]=abs(a[2]-a[1]);
	for(int i=3;i<=n;i++){
		dp[i]=min(abs(a[i-1]-a[i])+dp[i-1],abs(a[i-2]-a[i])+dp[i-2]);
	}
	cout<<dp[n]<<endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000000

void CountingSort(int *,int *,int);

int result[MAX+1];

int main(){
  int i,l,r,n,arr[MAX],count[10000+1];

  for(i=0;i<=10001;i++) count[i] = 0;
  scanf("%d",&n);
  if(n>MAX) exit(2);
  for(i=0;i<n;i++){
    scanf("%d",&arr[i]);
  }
  CountingSort(arr,count,n);
  for(i=1;i<n+1;i++){
    if(i>1) printf(" ");
    printf("%d",result[i]);
  }
  printf("\n");
  return 0;
}

void CountingSort(int arr[],int count[],int n){
  int i;
  for(i=0;i<n;i++){
    count[arr[i]]++;
  }
  for(i=1;i<=10001;i++){
    count[i] = count[i-1] + count[i];
  }
  for(i=n-1;i>=0;i--){
    result[count[arr[i]]]=arr[i];
    count[arr[i]]--;
  }
}



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

int main(){
  int a,b,ans;
  char op;
  
  while(1){
    cin >> a >> op >> b;    
  if (op == '?') break;
  if (op == '+'){
    ans = a + b;
    cout << ans << endl;
  }
  else if (op == '-'){
    ans = a - b;
    cout << ans << endl;
  }
  else if (op == '*'){
    ans = a * b;
    cout << ans << endl;
  }
  else if (op == '/'){
    ans = a / b;
    cout << ans << endl;
  }
 }
  
  return 0;  
}


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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    int m;
    cin >> m;
    cout << (24 - m) + 24 << endl;
    return 0;
}

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

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

int func(int n) {
    int ret = 1;
    while (n > 0) {
        ret *= 10;
        n--;
    }
    return ret;
}

int main() {
    int n, m;
    cin >> n >> m;

    vector<int> val(n, 0);
    if (n >= 2) {
        val[0] = 1;
    }
    vector<bool> vis(n, false);

    rep(i, 0, m) {
        int s, c;
        cin >> s >> c;
        s--;
        if (n >= 2 & s == 0 & c == 0) {
            cout << -1 << endl;
            return 0;
        }

        if (vis[s] && c != val[s]) {
            cout << -1 << endl;
            return 0;
        }

        val[s] = c;

        vis[s] = true;
    }

    int ans = 0;
    rep(i, 0, n) {
        ans += val[i] * func(n - i - 1);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// finish date: 2018/01/22
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


ll calc(int i, int j, int bi) {
    ll mi = LONG_LONG_MAX;
    ll S1, S2, S3;
    S1 = (ll)(i / 3 + bi) * j;
    S2 = (ll)(i - (i / 3 + bi)) * (j / 2);
    S3 = (ll)j * i - S1 - S2;
    mi = min(mi, max(S1, max(S2, S3)) - min(S1, min(S2, S3)));
    S2 = (ll)j * ((i - (i / 3 + bi)) / 2);
    S3 = (ll)j * i - S1 - S2;
    mi = min(mi, max(S1, max(S2, S3)) - min(S1, min(S2, S3)));
    return mi;
}

int main() {
    int H, W;
    cin >> H >> W;
    if (H % 3 == 0 || W % 3 == 0) {
        cout << 0 << endl;
        return 0;
    }
    ll mi1 = min(calc(H,W,0),calc(H,W,1));
    ll mi2 = min(calc(W,H,0),calc(W,H,1));
    cout<<min(mi1,mi2)<<endl;


    return 0;
}



Measured memory_bytes: 256
from itertools import product, takewhile


def main():
    words = ["eraser", "erase",  "dreamer", "dream"]
    S = input()[::-1]
    for word in words:
        S = S.replace(word[::-1], '')
    # print(S)
    if len(S) > 0:
        print("NO")
    else:
        print("YES")


if __name__ == '__main__':
    main()


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

int main()
{
  int ABCD;
  int s[5];
  int res=0;
  cin >> ABCD;

  s[3] = ABCD%10;
  s[2] = (ABCD/10)%10;
  s[1] = (ABCD/100)%10;
  s[0] = (ABCD/1000)%10;


  for(int i=0;i<(1<<3);i++){
    int op[5]={0};
    for (int k=0;k<5;k++) op[k]=0;
    int sum = s[0];
    for(int j=0;j<3;j++){
      op[j] = i & (1<<j); // 0: add, 1:subtract
      if(op[j]) sum -=s[j+1];
      else sum+=s[j+1];
    }
    if(sum==7) {
      cout << s[0];
      for(int j=0;j<3;j++){
        if(op[j]) cout << "-";
        else cout << "+";
        cout << s[j+1];
      }
      cout << "=7" << endl;
      break;
    }
  }
  
  return 0;
}



Measured memory_bytes: 256