akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    ll n;
    cin>>n;
    vector<ll> yakusu(n);

    for(ll i=1;i<=n;i++){
        for(ll j=1;i*j<=n;j++){
            yakusu[i*j]++;
        }
    }

    ll ans = 0;
    for(ll i=1;i<=n;i++){
        ans += i*yakusu[i];
    }

    cout<<ans<<endl;
}

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

int main(void)
{
	char str[1002];
	char *pp;
	int i, n;
	
	scanf("%d ", &n);
	
	for(i = 0;i < n;i++){
		fgets(str, sizeof(str), stdin);
		pp = str;
		while((pp = strstr(pp, "Hoshino")) != NULL){
			pp += 6;
			*pp ='a';
		}
		printf("%s", str);
	}
	
	return 0;
}

Measured memory_bytes: 608
import math

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

a_min = math.ceil(A * 100 / 8)
a_max = math.ceil((A + 1) * 100 / 8)
b_min = math.ceil(B * 100 / 10)
b_max = math.ceil((B + 1) * 100 / 10)

set_a = {i for i in range(a_min, a_max)}
set_b = {i for i in range(b_min, b_max)}
i = set_a.intersection(set_b)
if len(i) > 0:
    print(min(i))
else:
    print(-1)

Measured memory_bytes: 38640
#include <iostream>

using namespace std;

int main()
{
	int y, m, d;
	
	while ( cin >> y >> m >> d ) {
		if ( y >= 1990 ) {
			cout << "heisei " << y-1988 << " " << m << " " << d << endl;
		} 
		else if ( y == 1989 ) {
			if ( m>=2 || d>=8 ) {
				cout << "heisei " << y-1988 << " " << m << " " << d << endl;
			}
			else {
				cout << "showa " << y-1925 << " " << m << " " << d << endl;
			}
		}
		else if ( y >= 1927 ) {
			cout << "showa " << y-1925 << " " << m << " " << d << endl;
		}
		else if ( y == 1926 ) {
			if ( m==12 && d>=25 ) {
				cout << "showa " << y-1925 << " " << m << " " << d << endl;
			}
			else {
				cout << "taisho " << y-1911 << " " << m << " " << d << endl;
			}
		}
		else if ( y >= 1913 ) {
			cout << "taisho " << y-1911 << " " << m << " " << d << endl;
		}
		else if ( y == 1912 ) {
			if ( m>=8 || (m==7 && d>=30) ) {
				cout << "taisho " << y-1911 << " " << m << " " << d << endl;
			}
			else {
				cout << "meiji " << y-1867 << " " << m << " " << d << endl;
			}
		}
		else if ( y >= 1869 ) {
			cout << "meiji " << y-1867 << " " << m << " " << d << endl;
		}
		else if ( y == 1868 ) {
			if ( m>=10 || (m==9 && d>=8) ) {
				cout << "meiji " << y-1867 << " " << m << " " << d << endl;
			}
			else {
				cout << "pre-meiji" << endl;
			}
		}
		else {
			cout << "pre-meiji" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 2968
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int sum_2017[100002];
int primes[100002];
bool isPrime[100002];
const int limit=100002;
void prime_list(){
  int size=3;
  for(int i=0; i<6; i++){
    isPrime[i]=false;
  }
  primes[0]=2, primes[1]=3,primes[2]=5;
  isPrime[2]=true, isPrime[3]=true, isPrime[5]=true;
  sum_2017[0]=0,sum_2017[1]=0,sum_2017[2]=0;
  sum_2017[3]=1,sum_2017[4]=1,sum_2017[5]=2;
  for(int i=6; i<limit; i++){
    if( (i%2) == 0 ){
      sum_2017[i] = sum_2017[i-1];
      continue;
    }
    isPrime[i]=true;
    int max = sqrt(i);
    for(int j=0; j<size; j++){
      if((i%primes[j]) == 0){
	isPrime[i]=false;
	break;
      }
    }
    if( isPrime[i] ){
      primes[size]=i;
      size++;
      if( isPrime[(i+1)/2] ) sum_2017[i]=sum_2017[i-1]+1;
      else sum_2017[i]=sum_2017[i-1];
    }else{
      sum_2017[i]=sum_2017[i-1];
    }
  }
}

int main(){
  prime_list();
  int start, end;
  int cnt;
  scanf("%d", &cnt);
  int i;
  for(i=0; i<cnt; i++){
    scanf("%d %d", &start, &end);
    printf("%d\n", sum_2017[end]-sum_2017[start-1]);
  }

  return 0;
}


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

typedef long long ll;

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

	int n, m, k;
	cin >> n >> m >> k;
	int a[n],b[m];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < m; i++)
		cin >> b[i];

	ll sum = 0;
	int x = -1;
	int y = -1;
	while (x+1 < n && sum + a[x+1] <= k) {
		x++;
		sum += a[x];
	}
	while (y+1 < m && sum + b[y+1] <= k) {
		y++;
		sum += b[y];
	}

	int maxRead = x + y;
	while (x > -1 && y+1 < m) {
		sum -= a[x];
		x--;
		while (y+1 < m && sum + b[y+1] <= k) {
			y++;
			sum += b[y];
		}
		maxRead = max(maxRead, x + y);
	}

	cout << 2 + maxRead << '\n';
}


Measured memory_bytes: 5212
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    double r; cin >> r;
    cout <<fixed << setprecision(10) <<  r * r * acos(-1) << " " << 2 * r * acos(-1) << endl;
}





Measured memory_bytes: 3168
#include<stdio.h>
int main(){
  int i,j,d[5],t;

  for(i=0;i<5;i++){
    scanf("%d",&d[i]);
  }
  for(i=0;i<5;i++){
    for(j=1;i+j<5;j++){
      if(d[j]>d[j-1]){
	t=d[j];
	d[j]=d[j-1];
	d[j-1]=t;
      }
    }
  }
  printf("%d %d %d %d %d\n",d[0],d[1],d[2],d[3],d[4]);
  return 0;
} 

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

bool ok(ll x) {
    for(ll i = 2; i * i <= x; i++) {
        if(x % i == 0) return false;
    }
    return true;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X;
    cin >> X;
    for(ll i = X; ; i++) {
        if(ok(i)) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int a, b, c; cin >> a >> b >> c;
    if(min(min(a, b), c) == a) cout << a + min(b, c) << endl;
    else if(min(min(a, b), c) == b) cout << b + min(a, c) << endl;
    else cout << c + min(a, b) << endl;    
    return 0;
}

Measured memory_bytes: 3584
#include <cstdio>
#include <map>
using namespace std;
int n, x;
map<int, int> m;
int ans;
int main() {
  scanf("%d", &n);
  while(n--) scanf("%d", &x), ++m[x];
  for(map<int, int>::iterator it = m.begin(); it != m.end(); ++it)
    if(it->first > it->second) ans += it->second;
    else ans += it->second - it->first;
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 4736
#include<stdio.h>
#define N 200000
int bigger(int,int);
int smaller(int,int);

int main(){
  int n,i,j;
  int R[N];
  int maxv,minv;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&R[i]);
  }

  maxv=R[1]-R[0];
  minv=R[0];

  for(j=1;j<n;j++){
      maxv=bigger(maxv,R[j]-minv);
      minv=smaller(minv,R[j]);
  }

  printf("%d\n",maxv);
  return 0;
}

int bigger(int a,int b){
  if(a>b) return a;
  else return b;
}

int smaller(int a,int b){
  if(a<b) return a;
  else return b;
}



Measured memory_bytes: 2512
s = gets.chomp
n = s.length

l_ar = Array.new(n+1, 0)
r_ar = Array.new(n+1, 0)

l_sum = 0
n.times do |i|
  if s[i] == '<'
    l_sum += 1
  else
    l_sum = 0
  end
  l_ar[i+1] = l_sum
end

r_sum = 0
(n-1).downto(0) do |i|
  if s[i] == '>'
    r_sum += 1
  else
    r_sum = 0
  end
  r_ar[i] = r_sum
end

sum = 0
(n+1).times do |i|
  sum += [l_ar[i], r_ar[i]].max
end

puts sum


Measured memory_bytes: 23420
s = gets.chomp
n = s.length 

n.times do |i|
  break if s[i+1].nil?
  if s[i] == s[i+1]
    puts "#{i+1} #{i+2}"
    exit
  elsif s[i+2] && s[i] == s[i+2]
    puts "#{i+1} #{i+3}"
    exit
  end
end

puts "-1 -1"


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

using namespace std;

int n;
int dizi[100005];
int dp[100005][5];
int dpf(int x,int crr){
	// printf("%d\n",crr);
	if(dp[crr][crr-x]!=-1){
		return dp[crr][crr-x];
	}
	if(crr>=n){
		return INT_MAX;
	}
	if(crr==(n-1)){
		return abs(dizi[crr]-dizi[x]);
	}
	else{
		int next;
		next=min(dpf(crr,crr+1),dpf(crr,crr+2));
		dp[crr][crr-x]=next+abs(dizi[crr]-dizi[x]);
		// printf("%d\n",dp[crr][crr-x] );
		return dp[crr][crr-x];
	}
}


int main(){
	// freopen("a.gir","r",stdin);
 //   freopen("a.cik","w",stdout);

	scanf("%d",&n);
	for(int i=0;i<100005;i++){
		for(int j=0;j<4;j++){
			dp[i][j]=-1;
		}
	}
	for(int i=0;i<n;i++){
		scanf("%d",&dizi[i]);
	}
	printf("%d\n",min(dpf(0,1),dpf(0,2)) );
		
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a)  (a).begin(),(a).end()

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

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

vector<pii> MODE(vi &vec){
  vi count(100100,0);//vecに何（v）が何個（count[v]）含まれているかを計数
  for(int v: vec) count[v]++;

  vector<pii> mode;//(度数、値)のpairの配列を用意
  for (int i = 0; i < 100100; i++) mode.push_back(make_pair(count[i],i));

  sort(all(mode),greater<pii>());//度数の高い順に並び変える
  return mode;//(度数、値)のpairを度数の降順に持つ配列を返す
}

int main(){
  int n; cin >> n;
  int m = n/2;
  vi o(m),e(m); //odd even
  rep(i, m) cin >> o[i] >> e[i];
  vector<pii> mode_o,mode_e;
  mode_o = MODE(o); mode_e = MODE(e);
  if (mode_o[0].second != mode_e[0].second) std::cout << n - mode_o[0].first - mode_e[0].first << '\n';
  else{
    int tmp = max(mode_o[1].first + mode_e[0].first, mode_o[0].first + mode_e[1].first);
    std::cout << n - tmp << '\n';
  }
}


Measured memory_bytes: 3308
package main
import (
    "fmt"
)

func main() {
    var h, n int
    fmt.Scan(&h, &n)

    var tempA, sumA int
    for i := 0; i < n; i++ {
        fmt.Scan(&tempA)
        sumA += tempA
    }

    if sumA >= h {
        fmt.Println("Yes")
    } else {
        fmt.Println("No")
    }
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld double
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define setpr(pp) fixed<<setprecision(pp)
#define FOR(I,N) for(I=0;I<N;++I)
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod	%1000000007
#define pi 3.141592653
#define MX 1000000007
ll ftree[200005];

ll query(ll x)
{
	ll ans = 0;
	for(;x>0;x-=(x&-x))
	{
		ans = max(ans,ftree[x]);
	}
	return ans;
}

void update(ll x,ll delta,ll n )
{
	for(;x<=n;x+=(x&-x))
		ftree[x] = max(ftree[x],delta);
}

int main()
{
	IOS;
	ll n,i,x;
	cin>>n;
	ll h[n+1],a[n+1];
	MS0(ftree);
	ll ans=0;
	for(i=1;i<=n;++i)
		cin>>h[i];
	for(i=1;i<=n;++i)
	{
		cin>>a[i];
		ans = max(ans,a[i]);
	}
	for(i=1;i<=n;++i)
	{
		x = query(h[i]-1);
		x += a[i];
		ans = max(ans,x);
		update(h[i],x,n);
	}
	cout<<ans;
}

Measured memory_bytes: 8316
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::vector;

namespace {
void DeriveLucasNumbers(vector<long>* L) {
  L->push_back(2);
  L->push_back(1);
  for (int i = 2; i <= 86; ++i)
    L->push_back((*L)[i - 1] + (*L)[i - 2]);
}
}  // namespace

int main() {
  vector<long> L;
  DeriveLucasNumbers(&L);
  int N;
  cin >> N;
  cout << L[N] << endl;
}


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

int main() {
  int n;
  cin >> n;
  bool flag = false;
  for(int i = 1; i <= 9; i++) {
    for(int j = 1; j <= 9; j++) {
      if(n == i * j) flag = true;
    }
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int A = 0;
  vector<int> v(N);
  for (int i = 0; i < N; i++){
    cin >> v.at(i);
  }
  for (int i = 0; i < N; i++){
    int MAX = 0;
    int M= 0;
    for (int m = 0; m < N; m++){
      if (v.at(m) > MAX){
        MAX = v.at(m);
        i = 1;
      }
    }
    if (i == 1){
      A++;
    for (int m = 0; m < N; m++){
      if (v.at(m) == MAX){
        v.at(m) = -1;
      }
    }
  }
  }
  cout << A << endl;
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>

template<class T>
struct LinearSystemIncidence{
private:
    struct Edge{
        int id, to;
        bool fwd;
        Edge() = default;
        
        Edge(int id_, int to_, bool fwd_)
        : id(id_), to(to_), fwd(fwd_) {}
    };
    using pii = std::pair<int, int>;
    int n, m;   
    bool F2;
    std::vector<T> x;
    std::vector<bool> seen;
    std::vector<std::vector<Edge>> G;

public:
    LinearSystemIncidence() = default;

    LinearSystemIncidence(int n_, std::vector<pii> &E, bool F2_ = false)
    : n(n_), m(E.size()), G(n_), F2(F2_){
        for(int i = 0; i < m; i++){
            G[E[i].first].emplace_back(i, E[i].second, true);
            G[E[i].second].emplace_back(i, E[i].first, false);
        }
    }

    T dfs(std::vector<T> &c, int u){
        seen[u] = true;
        T res = c[u];
        for(Edge e : G[u]){
            if(seen[e.to]) continue;
            T tmp = dfs(c, e.to);
            if(e.fwd) x[e.id] = tmp;
            else x[e.id] = -tmp;
            res += tmp;
            if(F2){
                x[e.id] %= 2;
                if(x[e.id] < 0) x[e.id] += 2;
            }
        }
        if(F2) res %= 2;
        return res;
    }

    std::pair<bool, std::vector<T>> solve(std::vector<T> &c){
        x.assign(m, 0);
        seen.assign(n, false);
        for(int i = 0; i < n; i++){
            if(seen[i]) continue;
            if(dfs(c, i)) return {false, std::vector<T>()};
        }
        return {true, std::move(x)};
    }
};

using pii = std::pair<int,int>;
int main(){
    int n, m;
    std::cin >> n >> m;
    std::vector<pii> E;
    std::vector<int> c(n);
    for(int i = 0; i < m; i++){
        int u, v;
        std::cin >> u >> v;
        u--; v--;
        E.emplace_back(u, v);
        c[u] ^= 1;
    }

    LinearSystemIncidence<int> LSI(n, E, true);
    auto res = LSI.solve(c);

    if(res.first){
        for(int i = 0; i < m; i++){
            if(res.second[i]) std::swap(E[i].first, E[i].second);
            std::cout << E[i].first + 1 << " " << E[i].second + 1 << '\n';
        }
    }
    else std::cout << -1 << '\n';
}

Measured memory_bytes: 18164
#include <bits/stdc++.h>
using namespace std;
bool isincluded (int p){
    if(p%10==3)return true;
    else p/=10;
    if(p==0){return false;}
return isincluded(p);
}
int main() {
int n;
cin >> n;
for(int i=1;i<n+1;i++){
    if(isincluded(i) || i%3==0)cout << " " << i;
}
cout << endl;
}



Measured memory_bytes: 3100
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count=0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            ans = 500*i + 100*j + 50*k
            if(ans==X):
                count += 1

print(count)

#全ての場合について計算したい場合はこのようにfor文を重ねてそれぞれのi,j,kをうまく使用する。


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

long long n;
string s[2];

long long solve();

int main() {
	cin >> n >> s[0] >> s[1];
	cout << solve() << endl;
	return 0;
}

long long solve() {
	long long ans = 3;
	for(long long i = 0; i < n; i++){
		if(i == 0 && s[0][0] != s[1][0]) {
			ans = 6;//横のセットのとき
			++i;
			continue;
		}
		if(i == 0) continue; // 縦のときは3のまま
		if(s[0][i] == s[1][i]){
			if(s[0][i-1] == s[1][i-1]) ans *= 2;
		} else {
			if(s[0][i-1] == s[1][i-1]) ans *= 2;
			else ans *= 3;
			i++;
		}
		ans %= N;
	}
	return ans;
}


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int tc; cin>>tc; while(tc--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    bool x;
    cin>> x;

    cout << !x;
    nl;

    return 0;
}




Measured memory_bytes: 3636
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . ___
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         佛祖保佑       永无BUG
*/
#include<map>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
#include<fstream>
#include<assert.h>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<string.h>
#define mp make_pair
using namespace std;
const int INF=1e9;
inline int pt(int a[],int l,int r){
	int p,i,j;
	p=a[l];
	i=l;
	j=r+1;
	for(;;){
		while(a[++i]<p) if(i>=r) break;
		while(a[--j]>p) if(j<=l) break;
		if(i>=j) break;
		else swap(a[i],a[j]);
	}
	if(j==l) return j;
	swap(a[l],a[j]);
	return j;
}
inline void q_sort(int a[],int l,int r){
	int q;
	if(r>l){
		q=pt(a,l,r);
		q_sort(a,l,q-1);
		q_sort(a,q+1,r);
	}
}
int n,m;
string c[111];
string s[111];
int use[111];
int use2[111];
inline void dfs2(int x,bool md){
	if(x==m){
//		for(int i=0;i<n;i++) cout<<use[i]<<' ';
//		cout<<endl;
//		for(int j=0;j<m;j++) cout<<use2[j]<<' ';
//		cout<<endl;
		cout<<"YES"<<endl;
		exit(0);
	}
	if(use2[x]!=-1){
		dfs2(x+1,md);
		return;
	}
	for(int i=x+1;i<m;i++){
		if(use2[i]!=-1){
			continue;
		}
		int j;
		for(j=0;j<n;j++){
			if(c[j][x]!=c[use[j]][i]) break;
		}
		if(j==n){
			use2[x]=i;
			use2[i]=x;
			dfs2(x+1,md);
			use2[x]=-1;
			use2[i]=-1;
		}
	}
	if(!md){
		int j;
		for(j=0;j<n;j++){
			if(c[j][x]!=c[use[j]][x]) break;
		}
		if(j==n){
			use2[x]=x;
			dfs2(x+1,true);
			use2[x]=-1;
		}
	}
}
inline void dfs(int x,bool md){
	if(x==n){
		dfs2(0,!(m%2));
		return;
	}
	if(use[x]!=-1){
		dfs(x+1,md);
		return;
	}
	for(int i=x+1;i<n;i++){
		if(use[i]!=-1) continue;
		if(s[i]!=s[x]) continue;
		use[i]=x;
		use[x]=i;
		dfs(x+1,md);
		use[x]=-1;
		use[i]=-1;
	}
	if(!md){
		use[x]=x;
		dfs(x+1,1);
		use[x]=-1;
	}
}
int main(){
	cin>>n>>m;
	int i,j;
	for(i=0;i<n;i++){
		cin>>c[i];
		s[i]=c[i];
		sort(s[i].begin(),s[i].end());
	}
//	for(i=0;i<m;i++) cout<<s[i]<<' ';
//	cout<<endl;
	memset(use,-1,sizeof(use));
	memset(use2,-1,sizeof(use2));
	dfs(0,!(n%2));
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
//Solution By SlavicG
#include <bits/stdc++.h>
using namespace std;
 
#define ll                          long long
 
#define forn(i,n)                   for(int i=0;i<n;i++)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
	
#define pb                          push_back
#define sz(a)                       (int)a.size()
#define mp                          make_pair
 
#define   endl                       "\n"
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
int main()
{
	char c;
	cin >> c;
	char x = c  +1;
	cout << x;
}

Measured memory_bytes: 3540
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin >> k;
	cout << a[k-1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int n;
pii a[1000100];
bool cmp(pii x, pii y)
{
    if(x.S>=0 && y.S<0) return 1;
    if(x.S<0 && y.S>=0) return 0;
    if(x.S>=0) return (x.F<y.F);
    if(x.S+x.F > y.S+y.F) return 1;
    if(x.S+x.F < y.S+y.F) return 0;
    return (x.F>y.F);
}

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    cin >> n;
    forn(i, n)
    {
        string s;
        cin >> s;
        int now = 0;
        int nowmin = 0;
        forn(j, s.size())
        {
            if(s[j] == '(') now++;
            else now--;
            nowmin = min(nowmin, now);
            //cout << "now = " << now << ", nowmin = " << nowmin << endl;
        }
        a[i] = mp(max(0, -nowmin), now);
        //cout << a[i].F << " " << a[i].S << endl;
    }
    sort(a, a+n, cmp);
    int now = 0;
    forn(i, n)
    {
        if(now < a[i].F)
        {
            cout << "No" << endl;
            return 0;
        }
        now += a[i].S;
    }
    if(now) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 11396
N=int(input())
W=[]
for _ in range(N):
    W.append(input())
c=1
for i in W:
    d=W.count(i)
    if d>1:
        c=0
        break
for i in range(N-1):
     if W[i][-1]!=W[i+1][0]:
            c=0
            break
if c:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        
        if(S.equals("AAA") || S.equals("BBB")) {
            System.out.println("No");
        } else {
        System.out.println("Yes");
        }
        sc.close();
    }
}


Measured memory_bytes: 35592
import collections
N = int(input())
S = [input() for _ in range(N)]
st = []
strings = dict(collections.Counter(S))
strings_sorted = sorted(strings.items(), key = lambda x:x[1], reverse=True)
max_num = strings_sorted[0][1]
for i in range(len(strings_sorted)):
    if strings_sorted[i][1] == max_num:
        st.append(strings_sorted[i][0])
st.sort()
for item in st:
    print(item)

Measured memory_bytes: 47636
N = int(input())

mod = 10**9+7

if N == 1:
    print(0)
elif N == 2:
    print(2)
else:
    tmp = 2*(pow(10,N,mod)-pow(9,N,mod))-(pow(10,N,mod)-pow(8,N,mod))
    print(tmp%mod)
    

Measured memory_bytes: 61752
Scanf.scanf "%s" (fun a ->
    let n = String.length a in
    let hist = Array.make 26 0 in
    String.iter (fun c ->
        let q = int_of_char c - 97 in
        hist.(q) <- hist.(q) + 1) a;
    let ans = Array.fold_left (fun acc v -> acc - v * (v - 1)) (n * (n - 1)) hist in
    Printf.printf "%d\n" @@ ans / 2 + 1
)

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

//import static java.lang.Math.cos;
//import static java.lang.Math.sin;
//import static java.lang.Math.toRadians;

public class Main {

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

		WalkMan boy = new WalkMan();

		String[] data = br.readLine().split(",");
		int d = Integer.parseInt(data[0]);
		int a = Integer.parseInt(data[1]);
		while (d != 0 || a != 0) {
			boy.move(d);
			boy.turn(a);

			data = br.readLine().split(",");
			d = Integer.parseInt(data[0]);
			a = Integer.parseInt(data[1]);
		}

		boy.printPos();
	}

	// position and direction
	public static class WalkMan {
		private double x; // east and west
		private double y; // north and south
		private int degree = 90; // direction

		public void turn(int a) {
			if (a >= 0) { // turn clockwise
				degree = degree - a;
			} else { // d < 0 turn counterclockwise
				degree = degree - a;
			}
		}

		public void move(int d) {
			x += d * Math.cos( Math.toRadians(degree) );
			y += d * Math.sin( Math.toRadians(degree) );
		}

		public void printPos() {
			System.out.println( (int)x );
			System.out.println( (int)y );
		}
	}
}

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

#define ll long long int
#define All(a) (a).begin(),(a).end()

// Remember v.shrink_to_fit() when erasing
ll cnt=0,M=998244353;
int n;
vector<int> v;
vector<int> diff;


void solve(){
  int k,l,r,t,x,y;
  cin >>n>>k;
  for(int i=0;i<k;i++){
    cin>>l>>r;
    v.push_back(l);
    diff.push_back(r);
  }
  ll dp[n+1]={};
  ll C_sum[n+1]={};
  dp[1]=1;
  C_sum[1]=1;
  
  for(int i=2; i <= n; i++){
    for(int j=0; j <v.size(); j++){
      x=max({0,i-v[j]});
      y=max({0,i-diff[j]-1});
      ll tmp=(C_sum[x]-C_sum[y]);
      while(tmp<0)tmp+=M;
      tmp%=M;
      //cout << tmp<<endl;
      dp[i]+=tmp;
      dp[i]%=M;
    }
    C_sum[i]=(C_sum[i-1]+dp[i])%M;
  }
  printf("%lld\n",dp[n]);
}
int main(){

  solve();

  return 0;
}

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

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

void pre(){

}

void solve(){
    ll n,x,y;
    cin>>n>>x>>y;
    ll dp[n+1][n+1];
    for(ll i=1;i<n+1;i++){
        for(ll j=1;j<n+1;j++){
            dp[i][j] = abs(i-j);
        }
    }

    for(ll i=1;i<n+1;i++){
        for(ll j=1;j<n+1;j++){
            if(dp[i][j] > dp[i][x] + 1 + dp[y][j])
                dp[i][j] = dp[i][x] + 1 + dp[y][j];
            if(dp[i][j] > dp[i][y] + 1 + dp[x][j] )
                dp[i][j] = dp[i][y] + 1 + dp[x][j];
        }
    }

    ll res[n+1];
    memset(res,0,sizeof res);
    for(ll i=1;i<n+1;i++){
        for(ll j=i+1;j<n+1;j++){
            res[dp[i][j]]++;
        }
    }
    for(ll i=1;i<n;i++)
        cout << res[i] << endl;
}

int main(){
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
#define arep(i, x, n) for (long long i = x; i < n; i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9 + 7
// using ll = long long;
typedef long long ll;

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

    int res = 0;
    for (int i = 1; i <= n; i += 2) {
        int cnt = 0;
        for (int j = 1; j <= n; j += 2) {
            if (i % j == 0) {
                cnt++;
            }
        }

        if (cnt == 8) {
            res++;
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 3600
N = int(input())
ans = 100001
for A in range(1, N):
    B = str(N - A)
    A = str(A)
    ttl = sum(list(int(digit) for digit in A))
    ttl += sum(list(int(digit) for digit in B))
    ans = min(ans, ttl)
print(ans)

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

using namespace std;
string s,t;
map<char,char>a;
int main()
{
    int n,m,flag=1;
    cin >> s >> t;
    n=s.size();
    for(char i='a'; i<='z'; i++)
    {
        a[i]=i;
    }
    for(int i=0; i<n; i++)
    {
        if(a[s[i]]!=t[i])
        {
            if(a[s[i]]==s[i])
            {
                a[s[i]]=t[i];
            }
            else
            {
                flag=0;
                break;
            }
        }
    }
    for(char i='a'; i<='z'; i++)
    {
        a[i]=i;
    }
    for(int i=0; i<n; i++)
    {
        if(a[t[i]]!=s[i])
        {
            if(a[t[i]]==t[i])
            {
                a[t[i]]=s[i];
            }
            else
            {
                flag=0;
                break;
            }
        }
    }
    if(flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 776
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String b = sc.next();
        String[] c = b.split("");
        String d = "";
        String e = "";
        if (a != c.length) {
            System.out.println("No");
        } else {
            for (int i = 0; i < a / 2; i++) {
                d += c[i];
            }
            for (int j = a / 2; j <= a - 1; j++) {
                e += c[j];
            }
            if (d.equals(e)) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}



Measured memory_bytes: 21204
a, b = map(int, input().split())
s = input()
flag = 1
try :
    num=int(s[0:a])
except :
    flag = 0
if s[a] != "-" :
    flag = 0
try :
    num = int(s[a+1:])
except :
    flag = 0
if flag == 1 :
    print("Yes")
else :
    print("No")


Measured memory_bytes: 9080
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  int n;
  cin >> n;
  int ans = 10000 - n;
  ans %= 1000;
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  int x=a*e;
  int y=b;
  if(e-c>=0)
    y+=(e-c)*d;
  cout<<min(x,y)<<endl;
  return 0;
}

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

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

    int n;
    cin >> n;
    int d, x;
    cin >> d >> x;
    
    REP(i, n){
        int a;
        cin >> a;
        x += (d + a - 1) / a;
    }
    cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x, y, z;
  cin >> x >> y;
  z =  x * y % 2;
  if (z == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;    
  }

}

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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint fact(int n){
	static vector<mint> memo={1};
	if(memo.size()<=n){
		int k=memo.size();
		memo.resize(n+1);
		for(;k<=n;k++) memo[k]=memo[k-1]*k;
	}
	return memo[n];
}

mint fact_inverse(int n){
	static vector<mint> memo={1};
	if(memo.size()<=n){
		int k=memo.size();
		memo.resize(n+1);
		memo[n]=inverse(fact(n));
		for(int i=n;i>k;i--) memo[i-1]=memo[i]*i;
	}
	return memo[n];
}

mint choose(int n,int k,int type=0){
	if(k<0 || n<k) return 0;
	if(type==0){
		return fact(n)*fact_inverse(k)*fact_inverse(n-k);
	}
	else{
		if(k>n-k) k=n-k;
		mint res=fact_inverse(k);
		rep(i,k) res*=n-i;
		return res;
	}
}

template<class T>
vector<pair<T,int>> run_length_encoding(const vector<T>& a){
	vector<pair<T,int>> res;
	int n=a.size(),pre=0;
	rep(i,n) if(i==n-1 || a[i]!=a[i+1]) res.emplace_back(a[i],i-pre+1), pre=i+1;
	return res;
}

int main(){
	int n,k; scanf("%d%d",&n,&k);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	sort(a.begin(),a.end());

	mint ans=0;
	int small=0;
	for(auto p:run_length_encoding(a)){
		int large=n-p.second-small;
		ans+=(choose(p.second+small,k)-choose(small,k))*p.first;
		ans-=(choose(p.second+large,k)-choose(large,k))*p.first;
		small+=p.second;
	}
	printf("%d\n",ans.to_int());

	return 0;
}


Measured memory_bytes: 2292
#include <iostream>
using namespace std;
typedef long long ll;
int a[100005];
int p[100005];

ll MOD = 1000000007;
ll fr[200005];
ll inv( ll d )
{
  // d^(MOD-1) == 1
  ll m = MOD - 2;
  ll ret = 1;
  while( m > 0 ){
    if( m & 1 ){
      ret = (ret * d) % MOD;
    }
    d = (d * d) % MOD;
    m >>= 1;
  }
  return ret;
}
ll comb( ll a, ll b )
{
  // nCb = (a+b)! / a!b!
  ll ret = fr[a+b];
  ret = (ret * inv(fr[a])) % MOD;
  ret = (ret * inv(fr[b])) % MOD;
  return ret;
}
int main( void )
{
  ios::sync_with_stdio(false);
  int N, d;
  cin >> N;

  fr[0] = 1;
  for( ll i=1; i<=100005; i++ ){
    fr[i] = (fr[i-1] * i) % MOD;
  }

  for( int i=1; i<=N+1; i++ ){
    cin >> a[i];
    if( p[a[i]] == 0 ){
      p[a[i]] = i;
    } else {
      d = i - p[a[i]];
      d = N - d;
    }
  }

  for( int i=1; i<=N+1; i++ ){
    //cout << C[c][i] - D[i-1] << endl;
    if( d-(i-1) >= 0 ){
      cout << ( comb( N+1-i, i ) - comb( d-(i-1), i-1 ) + MOD ) % MOD << endl;
    } else {
      cout << comb( N+1-i, i ) << endl;
    }
  }
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define ai64(v) (v).begin(), (v).end()
#define eb emplace_back

struct mint{
    using i64 = int_fast64_t;
    i64 x;
    const i64 MOD = 1000000007;

    mint(const i64 y = (i64)0) noexcept : x(y) { if(x >= MOD) x %= MOD; }
    mint operator+() const noexcept {return x;}
    mint operator-() const noexcept {return -x;}

    mint operator+(const mint y) const noexcept {return (mint)*this += y; }
    mint operator-(const mint y) const noexcept {return (mint)*this -= y; }
    mint operator*(const mint y) const noexcept {return (mint)*this *= y;}
    mint operator/(const mint y) const noexcept {return (mint)*this /= y;}

    mint& operator+=(const mint y) noexcept {
        x += y.x; 
        if(x >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint y) noexcept {
        x -= y.x;
        if(x < 0) x += MOD;
        return *this;
    }
    mint& operator*=(const mint y) noexcept {
        x *= y.x;
        if(x >= MOD) x %= MOD;
        return *this;
    }
    mint& operator/=(mint y) noexcept {
        i64 exp = MOD - 2;
        while(exp){
            if(exp & 1) *this *= y;
            y *= y;
            exp /= 2;
        }
        return *this;
    }
    friend std::ostream& operator<< (std::ostream& os, const mint& m);
    friend std::istream& operator>> (std::istream& in, mint& m);
};
std::ostream& operator<<(std::ostream& os, const mint& m){
    os << m.x;
    return os;
}
std::istream& operator>> (std::istream& in, mint& m){
    in >> m.x; 
    if(m.x < 0) m.x += 1000000007;
    if(m.x >= 1000000007) m.x %= 1000000007;
    return in; 
}

int main(){
    i64 N, M;
    cin >> N >> M;
    vector<i64> A(N), B(M);
    rep(i, N) cin >> A[i];
    rep(i, M) cin >> B[i];

    sort(A.rbegin(), A.rend());
    sort(B.rbegin(), B.rend()); 
    A.emplace_back(0);
    B.emplace_back(0);

    mint ans = 1;
    i64 largerX_A = 0, largerX_B = 0;
    for(i64 x = N*M; x > 0; x--){
        if(A[largerX_A] == x && B[largerX_B] == x) {
            largerX_A++, largerX_B++;
        } else if(A[largerX_A] == x) {
            ans *= mint(largerX_B);
            largerX_A++;
        } else if(B[largerX_B] == x) {
            ans *= mint(largerX_A);
            largerX_B++;
        } else {
            ans *= mint(max(i64(0), largerX_A*largerX_B - (N*M-x)));
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {
	
	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String line1 = reader.readLine();
		int n = Integer.parseInt(line1);
		Set<String> set = new HashSet<>();
		for(int i = 0; i < n; i++) {
			line1 = reader.readLine();
			set.add(line1);
		}
		System.out.println(set.size());
		
	}

}


Measured memory_bytes: 66244
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    set<int> s;
    int cnt = 0;
    rep(i,n){
        int a;
        cin >> a;
        if(a>=3200){
            cnt++;
        }
        else{
            s.insert(a/400);
        }
    }
    cout << max(1,(int)s.size()) << ' ' << cnt+s.size()<<endl; 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int c[50][50];
bool vis[50][50];
int W,H;
void dfs(int x,int y) {
    vis[y][x]=1;
    for(int dx=-1;dx<=1;dx++) {
        for(int dy=-1;dy<=1;dy++) {
            int nx=x+dx,ny=y+dy;
            if(0>nx||nx>=W||0>ny||ny>=H||c[ny][nx]==0||vis[ny][nx]) continue;
            dfs(nx,ny);
        }
    }
}
int main() {
    while(scanf("%d %d",&W,&H),W) {
        for(int i=0;i<H;i++) {
            for(int j=0;j<W;j++) scanf("%d",&c[i][j]);
        }
        memset(vis,0,sizeof(vis));
        int ans=0;
        for(int i=0;i<H;i++) {
            for(int j=0;j<W;j++) {
                if(c[i][j]==1&&!vis[i][j]) {
                    dfs(j,i);
                    ans++;
                }
            }
        }
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 3228
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();
        int diff = b -a;
        System.out.println(diff*(diff-1)/2 - a);

    }

}


Measured memory_bytes: 21460
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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



int x,y;


void input(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> x >> y;
    
}





void solve(){
    
    int ans = 0;
    if(x==1) ans += 300000;
    if(x==2) ans += 200000;
    if(x==3) ans += 100000;
    
    if(y==1) ans += 300000;
    if(y==2) ans += 200000;
    if(y==3) ans += 100000;
    
    if(x==1 && y==1) ans += 400000;
    
    cout << ans << endl;
    
    
    
}





signed main() {
    
    input();
    solve();
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

double mod_pow(double x, int n){
  double ret = 1;
  while(0 < n){
    if((n % 2) == 0){
      x = (x * x);
      n >>= 1;
    } else {
      ret = (ret * x);
      --n;
    }
  }
  return ret;
}

int main(){
  int N, K;
  cin >> N >> K;
  double ans = 0;
  for(int i = 1; i <= N; i++) {
    int cnt = 0, sum = i;
    while(sum <= K - 1) { sum *= 2; cnt++; };
    ////cerr << "cnt: " << cnt << endl;
    // //cerr << (1 / (double)N) << " " <<  mod_pow(0.5, cnt) << endl;
    ans += (1 / (double)N) * mod_pow(0.5, cnt);
  }
  printf("%.15f\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
int n,sum=0;;
cin>>n;
int arr[n];
for(int i=0;i<n;i++){
    cin>>arr[i];
}
for(int i=0;i<n;i+=2){
    if(arr[i]%2!=0)sum++;
}
cout<<sum;

    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string S,T;
    getline(cin,S);
    getline(cin,T);
    int counter=0;
    for (int i=0;i<S.length();i++)
    {
        if (S[i]!=T[i])
            counter++;
    }
    cout<<counter;
    return 0;
}

Measured memory_bytes: 3896
import bisect
from collections import defaultdict
s = input()
n = len(s)
t = input()
if set(s) & set(t) != set(t):
    print(-1)
else:
    cnt = defaultdict(list)
    for i in range(n):
        cnt[s[i]].append(i+1)
    loop = 0
    prev = 0
    for c in t:
        x = cnt[c]
        idx = bisect.bisect_right(x, prev)
        if idx < len(x):
            prev = x[idx]
        else:
            prev = x[0]
            loop += 1
    print(loop*n+prev)


Measured memory_bytes: 13900