akhauriyash/Code-Regression huggingface dataset:
ans=[11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381, 1451]
n=int(input())
print(*ans[:n], sep=' ')

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
const int N=55,mod=1000000007;
char s1[N],s2[N];long long f[N];
void work()
{
	int l,n=0;
	scanf("%d",&l);
	scanf("%s",s1+1);
	scanf("%s",s2+1);
	for(int i=1;i<=l;i++){
		if(s1[i]!=s1[i+1]){
			s1[++n]=s1[i];
			s2[n]=s2[i];
		}
	}
	if(s1[1]==s2[1])f[1]=3;
	else f[1]=6;
	for(int i=2;i<=n;i++){
		if(s1[i]==s2[i]){
			if(s1[i-1]!=s2[i-1])f[i]+=f[i-1];
			else f[i]+=(f[i-1]+f[i-1])%mod;
		}
		else{
			if(s1[i-1]==s2[i-1])f[i]+=(f[i-1]+f[i-1])%mod;
			else f[i]+=(f[i-1]*3)%mod;
		}
		f[i]%=mod;
	}
	printf("%lld\n",f[n]);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string.h>
#include<queue>
#include<utility>
#include<algorithm>
#include<math.h>
using namespace std;
int a[100011]={0},b[100011]={0};
int main(){
	int n;
	cin>>n;
	for(int i=0;i<=n;i++){
		 scanf("%d",&a[i+1]);
	}
	for(int i=1;i<=n;i++){
		 scanf("%d",&b[i]);
	}
	long long ans=0;
	for(int i=1;i<=n;i++){
		if(a[i]>=b[i]) ans+=b[i];
		else {
			ans+=b[i];
			a[i+1]-=b[i]-a[i];
			if(a[i+1]<0) {
				ans+=a[i+1];
				a[i+1]=0;
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<sstream>
#include<queue>
#include<set>
#include<map>
#include<stack>
#define i64 long long
#define vi32 vector<int>
#define vi64 vector<long long>
#define  ii pair<i64,i64>
const long long mod = 1000000007LL, inf = 1e9, linf = 1e18;
using namespace std;
#define pb push_back
#define mp make_pair
#define N 1000005	
using namespace std;


int main()
{
	i64 x, r, d;
	cin >> r >> d >> x;
	for (int i = 1; i <= 10; i++)
	{
		cout << r * x - d << endl;
		x = r * x - d;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int in(int b,vector<int>& v){
  auto itr=lower_bound(v.begin(),v.end(),b);
  if(itr==v.end())return 0;
  return (*itr)==b;
}

int main(){
  int n;cin >>n;
  vector<int> a(n); rep(i,n) cin >>a[i];
  sort(a.begin(),a.end());
  vector<int> ans;
  map<int,int> mp;
  rep(i,n) mp[a[i]]++;
  int cnt=0;
  rep(i,n){
    int flag=1;
    int b=1;
    while(b*b<=a[i]){
      if(a[i]%b!=0){
        b++; continue;
      }
      if(in(b,ans) or in(a[i]/b,ans)){
        flag=0; break;
      }
      b++;
    }
    if(flag){
      ans.push_back(a[i]);
      cnt++;
    }
  }
  rep(i,ans.size()){
    if(mp[ans[i]]>1) cnt--;
  }
  print(cnt);
}


Measured memory_bytes: 14284
/*---------------------------*\
____________Mari000____________         
________Mostafa  Shehab________    
\*---------------------------*/
 
#include <bits/stdc++.h>
using namespace std;
 
#define PI  3.14159265  // PI = acos(-1)
#define EPS (1e-10)
#define endl "\n"
typedef long long ll;
typedef long double ld;
//template <class Type>
 
ll power(ll x,ll y,ll p);
int Bit(ll x);
 
void Fast(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}
 
inline int D(){
	int t;
	scanf("%d",&t);
	return t;
}
inline ll llD(){
	ll t;
	scanf("%lld",&t);
	return t;
}
 
const int N=1e6 + 5;
int arr[N];
bool visit[N];
 
ll n,m,k,a,b,c,cnt,sz,len;
ll l,r,mid;
ll MN,MX,SU;
 
 
ll GCD(ll a,ll b){
	return b ? GCD(b,a%b) : a;
}
 
vector<int> vec;
void seive(){
	visit[1]=true;
	for(int i=2;i<N;++i){
		if(visit[i])
			continue;
		for(ll j=1ll*i*i;j<N;j+=i)
			visit[j]=true;
	}
}

unordered_map<string,int> mp;
string s;
int main(){
	Fast();
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>s;
		mp[s]++;
	}
	cin>>m;
	for(int i=0;i<m;++i){
		cin>>s;
		--mp[s];
	}
	for(auto i:mp)
		cnt=max(cnt,(ll)i.second);

	printf("%lld\n",cnt);
		
}
 
 
 
 
 
 
 
 
 
ll power(ll x,ll y,ll p){ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
    while (y > 0){ 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;
    }
    return res; 
}
 
 
int Bit(ll x){
	if(!x)
		return 0;
	return 1+Bit(x>>1);
}
 
// 408

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(X) (X).begin(),(X).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    ll x, a, b;
    cin >> x;
    bool ok = false;
    if(x>=500){
         a = x/500;
        x %= 500;
        ok = true;
    }
    if(x>=5){
         b = x/5;
         ok = true;
    }
    if(!ok) {
        cout << 0 << endl;
        return 0;
    }
    cout << a*1000 + b * 5 << endl;
    return 0;
}

Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''
    N , M = [int(item) for item in input().split()]
    LRs = [[int(item) for item in input().split()] for _ in range(M)]

    L_max = 0
    R_min = N

    for L, R in LRs:
        L_max = max(L_max, L)
        R_min = min(R_min, R)

    delta = R_min - L_max
    if delta >= 0:
        print(delta + 1)
    else:
        print(0)



if __name__ == "__main__":
    resolve()


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int N = 10;

int n, m, k;

int a[N][N], b[N][N];

void init() {
	for (int i = 0; i < N; i ++) {
		for (int j = 0; j < N; j ++) {
			b[i][j] = a[i][j];
		}
	}
}

int main() {
	
	FAST;
	
	cin >> n >> m >> k;
	for (int i = 0; i < n; i ++) {
		for (int j = 0; j < m; j ++) {
			char x;
			cin >> x;
			a[i][j] = (x == '.' ? 0 : 1);
		}
	}
	int ans = 0;
	for (int mask = 0; mask < (1 << (n + m)); mask ++) {
		init();
		for (int x = 0; x < (n + m); x ++) {
			if (mask & (1 << x)) {
				if (x < n) {
					for (int j = 0; j < m; j ++) {
						b[x][j] = 0;
					}
				}
				else {
					for (int i = 0; i < n; i ++) {
						b[i][x - n] = 0;
					}
				}
			}
		}
		int cnt = 0;
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				cnt += b[i][j];
			}
		}
		if (cnt == k) ans ++;
	}
	cout << ans << '\n';
	return 0;
}

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}


vector<ll> about(vector<ll> numbers, ll n, ll first_count) {
    rep(i, n) numbers[i] += first_count;
    ll n1 = n + 1;
    sort(numbers.begin(), numbers.end());
    rep(i, n) {
        ll a = numbers.front();
        ll b = numbers[i];
        ll diff = b - a;
        ll c = diff / n1;
        ll k = c * n1;
        numbers[i] -= k;
        first_count -= c;
    }
    sort(numbers.begin(), numbers.end());
    ll f = first_count / n;

    rep(i, n) {
        numbers[i] -= (n1 * f);
    }

    ll g = f * n;
    first_count -= g;

    reverse(numbers.begin(), numbers.end());

    rep(i, first_count) {
        numbers[i] -= n1;
    }

    return numbers;
}

ll simulate(vector<ll> numbers, ll n) {
    int count = 0;
    while ((*max_element(numbers.begin(), numbers.end())) >= n) {
        count++;
        rep(i, n) numbers[i]++;
        *max_element(numbers.begin(), numbers.end()) -= (n + 1);
    }
    return count;
}

int main() {
    ll n;
    cin >> n;
    vector<ll> numbers(n);
    rep(i, n) cin >> numbers[i];

    ll ini_target = n * (n - 1);
    ll ini_max = accumulate(numbers.begin(), numbers.end(), 0ll);
    ll first_count = ini_max - ini_target;
    if (first_count <= 0) {
        ll ans = simulate(numbers, n);
        cout << ans << endl;
        ret();

    }
    vector<ll> numbers2 = about(numbers, n, first_count);
    ll si = simulate(numbers2, n);
    ll ans = si + first_count;
    cout << ans << endl;

}


Measured memory_bytes: 256
<?php

main();

function main() {
	while ($input = trim(fgets(STDIN))) {
		list($a, $b, $n) = explode(' ', $input);
		$array = decimalPlaces($a, $b, $n);
		echo array_sum($array) . "\n";
	}
}

function decimalPlaces($a, $b, $n) {
	$i = 0;
	$result = array();
	$a = $a % $b;
	while ($i < $n) {
		$a *= 10;
		$result[] = (int) ($a / $b);
		$a %= $b;
		$i++;
	}
	return $result;
}

Measured memory_bytes: 6660
package main

import (
	"fmt"
	"os"
)

func main() {
	var n int
	_, err := fmt.Fscanf(os.Stdin, "%d", &n)
	if err != nil {
		panic(err)
	}

	min, max := 1001, -1
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Fscanf(os.Stdin, "%d", &tmp)
		if min > tmp {
			min = tmp
		}
		if max < tmp {
			max = tmp
		}
	}

	fmt.Println(max - min)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,M;
    cin>>N>>M;
    string A[N],B[M];
    rep(i,N) cin>>A[i];
    rep(i,M) cin>>B[i];
    
    for(int i=0;i<N-M+1;i++){
        for(int k=0;k<N-M+1;k++){
            bool z=true;
            for(int j=0;j<M;j++){
                if(B[j]!=A[j+k].substr(i,M))  {
                    z=false;
                    break;
                }
            }
            if(z){
                cout << "Yes" << endl;
                return 0;
            }
        }

    }
    cout << "No" << endl;



}


Measured memory_bytes: 256
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define mod 1000000007
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes printf("Yes\n")
#define no printf("No\n")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using ull=unsigned long long;
using vi=vector<int>;
using pint=pair<int,int>;

const int INF=1LL<<55;
int n;

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

    cin>>n;
    vi vec(n);
    vi sorted(n);
    rep(i,n){
        cin>>vec[i];
        sorted[i]=vec[i];
    }
    sort(rall(sorted));
    int vl,vr;
    vr=sorted[n/2];
    vl=sorted[n/2 - 1];
    //cout<<vr<<" " <<vl<<endl;
    if(vr==vl){
        rep(i,n) cout<<vr<<endl;
    }else{
        double d=((double)vl+(double)vr)/2;
        show(d);
        rep(i,n){
            if(vec[i] < d){
                cout<<vl<<endl;
            }else{
                cout<<vr<<endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 5504
/* ex7_1
   key_tree */

#include<stdio.h>

typedef struct point{
    int x_elem;
    int y_elem;
}point;

// ある頂点について移動させた頂点を返す関数
point shift_point(point coodinate, int dif_x, int dif_y){
    point new_coordinate;
    new_coordinate.x_elem = coodinate.x_elem + dif_y;
    new_coordinate.y_elem = coodinate.y_elem - dif_x;
    return new_coordinate;
}


int main(void){
    // 入力
    int dif_x, dif_y;
    point coordinate1, coordinate2, coordinate3, coordinate4;
    scanf("%d %d %d %d", &coordinate1.x_elem, &coordinate1.y_elem, &coordinate2.x_elem, &coordinate2.y_elem);
    
    dif_x = coordinate1.x_elem - coordinate2.x_elem;
    dif_y = coordinate1.y_elem - coordinate2.y_elem;
    // 複素回転で座標を求めると、(x3,y3),(x4,y4)は以下の式で求められる
    coordinate3 = shift_point(coordinate2, dif_x, dif_y);
    coordinate4 = shift_point(coordinate1, dif_x, dif_y);
    // 出力
    printf("%d %d %d %d", coordinate3.x_elem, coordinate3.y_elem, coordinate4.x_elem, coordinate4.y_elem);
    printf("\n");
    
    return 0;

}



Measured memory_bytes: 1728
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M;
    cin >> N >> M;
    if(N == M){
        print("Yes");
    }else{
        print("No");
    }
    

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int> ;
using vl = vector<ll>;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    int r_cnt = 0;
    rep(i,s.length()){
        if(s[i] == 'R')r_cnt++;
    }

    int ans = 0;
    rep(i,r_cnt){
        if(s[i] == 'W') ans++;
    }
    if(r_cnt == 0){
        cout << 0 << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}

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

typedef long long int ll;
ll dp[100005];
ll h[100005];

int n;

ll f(int i)
{	
	ll& x = dp[i];
	
  if(x != -1) return x;

  if(i <= 0) return 0;

  if(i-2 < 0) return x = f(i-1)+abs(h[i]-h[i-1]);
  
  return x = min(f(i-2)+abs(h[i]-h[i-2]), f(i-1)+abs(h[i]-h[i-1]));


}

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

	cout << f(n-1) << endl;
}


Measured memory_bytes: 4992
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    bool ok = false;
    REP(i, 0, 26) {
        char c = 'a' + i;
        if (S + c == T) {
            ok = true;
        }
    }
    yesno(ok);
}


Measured memory_bytes: 3652
#include <iostream>
#include <map>
using ll = long long;
using namespace std;

int n;
map<int, int> m;

int main()
{
	cin >> n;

	ll ans = 0;
	for (int i = 1; i <= n; ++i) {
		int tmp = i;
		int right = tmp % 10;
		while (tmp >= 10) tmp /= 10;
		int left = tmp;
		++m[left * 10 + right];
	}

	for (int i = 1; i <= 9; ++i)
		for (int j = 1; j <= 9; ++j)
			ans += m[i * 10 + j] * m[i + j * 10];
	cout << ans;
	return 0;
}

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

namespace ConsoleApplication2
{
    class Program
    { 
        static void Main(string[] args)
        {
            string[] s =Console.ReadLine().Split(' ');

            int w = int.Parse(s[0]);
            int h = int.Parse(s[1]);
            int x = int.Parse(s[2]);
            int y = int.Parse(s[3]);
            int r = int.Parse(s[4]);


                //if((w < (x+r)) || (0 > (x-r)))
                //{
                //    Console.WriteLine("No");                
                //}

            if (((w >= (x + r)) && (0 <= (x - r))) && ((h >= (y + r)) && (0 <= (y - r))))
                {
                    Console.WriteLine("Yes");
                }
            else
            {
                Console.WriteLine("No");
            }
                //if ((h > (y - r)) && (0 < (y + r)))
                //{
                //    Console.WriteLine("Yes");
                //}

            //Console.WriteLine("No"); //??\???????????¶????????????????????£?????¨???

            //int n =int.Parse(s);
        }
    }
}

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


int main() {
    string n;
    cin>>n;
    rep(i,3){
        if(n.at(i)=='7'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;

int main(void){
    int K;
    string S;
    cin >> K;
    cin >> S;
    if(S.size() <= K){
        cout << S << endl;
    }else{
        cout << S.substr(0,K) + "..."<< endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
    x=0;char c=getchar();bool f=0;
    while(!isdigit(c)) f|=c=='-',c=getchar();
    while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f) x=-x;return  x;
}
template<class t> inline void write(t x){
    if(x<0){putchar('-'),write(-x);}
    else{if(x>9)write(x/10);putchar('0'+x%10);}
}

#define int long long
#define pii pair<int,int>
#define x first
#define y second

const int mod=1e9+7,N=1e4+5;
int n,ans,cnt,id[1000005];
vector<pii> ma,p[N];

int fpow(int x,int y){
	int res=1;
	for(;y;y>>=1,x=x*x%mod) if(y&1) res=res*x%mod;
	return res;
}

signed main(){
	read(n);
	for(int i=1,x;i<=n;i++){
		int xx=read(x);
		for(int j=2;j*j<=x;j++){
			int cnt=0;
			while(x%j==0) x/=j,cnt++;
			if(cnt)	p[i].push_back(pii(j,cnt));
		}
		if(x^1) if(xx/x%x) p[i].push_back(pii(x,1)); else p[i][p[i].size()-1].y++;
		for(int j=0;j<p[i].size();j++){
			if(!id[p[i][j].x]) id[p[i][j].x]=++cnt,ma.push_back(pii(p[i][j].x,0));
			ma[id[p[i][j].x]-1].y=max(ma[id[p[i][j].x]-1].y,p[i][j].y);
		}
//		for(int j=0;j<p[i].size();j++) printf("#%lld:: %lld %lld\n",i,p[i][j].x,p[i][j].y);
	}
//	for(int i=0;i<cnt;i++) printf("#%lld %lld\n",ma[i].x,ma[i].y);
	for(int i=1;i<=n;i++){
		vector<pii> now=ma;
		int cur=1;
		for(int j=0;j<p[i].size();j++) now[id[p[i][j].x]-1].y-=p[i][j].y;
		for(int j=0;j<cnt;j++) cur=cur*fpow(now[j].x,now[j].y)%mod;
		ans=(ans+cur)%mod;
//		printf("@%lld %lld\n",i,cur);
	}
	write(ans);
}

Measured memory_bytes: 7424
readline = open(0).readline
ans = []
while 1:
    m, f, r = map(int, readline().split())
    if m == f == r == -1:
        break
    v = m+f
    if m == -1 or f == -1 or v < 30:
        ans.append("F\n")
    elif v >= 80:
        ans.append("A\n")
    elif v >= 65:
        ans.append("B\n")
    elif v >= 50 or (v >= 30 and r >= 50):
        ans.append("C\n")
    else:
        ans.append("D\n")
open(1, 'w').writelines(ans)


Measured memory_bytes: 5608
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
 
static const double EPS = 1e-8;

class Input{
public:
  string axis;
  int a,b;
  Input(string _ax,int _a,int _b)
    : axis(_ax), a(_a), b(_b) {}
};

int main(){
  int n,total_queries;
  while(~scanf("%d %d",&n,&total_queries)){
    if(n == 0 && total_queries == 0) break;

    int res = n * n * n;

    vector<int> points[256];
    vector<Input> inputs;
    for(int i=0; i < total_queries; i++){
      string axis;
      int a,b;
      cin >> axis >> a >> b;
      points[axis[0]].push_back(a);
      points[axis[1]].push_back(b);
      inputs.push_back(Input(axis,a,b));
    }
    sort(points['x'].begin(),points['x'].end());
    points['x'].erase(unique(points['x'].begin(),points['x'].end()),points['x'].end());

    sort(points['y'].begin(),points['y'].end());
    points['y'].erase(unique(points['y'].begin(),points['y'].end()),points['y'].end());

    sort(points['z'].begin(),points['z'].end());
    points['z'].erase(unique(points['z'].begin(),points['z'].end()),points['z'].end());

    bool dp[points['x'].size()][points['y'].size()][points['z'].size()];
    for(int x = 0; x < points['x'].size(); x++){
      for(int y = 0; y < points['y'].size(); y++){
        for(int z = 0; z < points['z'].size(); z++){
          dp[x][y][z] = false;
        }
      }
    }

    for(int i=0; i < inputs.size(); i++){
      string axis = inputs[i].axis;
      
      char other = (axis[0] != 'x' && axis[1] != 'x') ? 'x'
        : (axis[0] != 'y' && axis[1] != 'y') ? 'y' : 'z';

      int proj_a = lower_bound(points[axis[0]].begin(),points[axis[0]].end(),inputs[i].a) - points[axis[0]].begin();
      int proj_b = lower_bound(points[axis[1]].begin(),points[axis[1]].end(),inputs[i].b) - points[axis[1]].begin();

      for(int i=0;i<points[other].size();i++){
        if(other == 'x'){
          if(!dp[i][proj_a][proj_b]) res--;
          dp[i][proj_a][proj_b] = true;
        }
        else if(other == 'y'){
          if(!dp[proj_a][i][proj_b]) res--;
          dp[proj_a][i][proj_b] = true;
        }
        else if(other == 'z'){
          if(!dp[proj_a][proj_b][i]) res--;
          dp[proj_a][proj_b][i] = true;
        }
      }
      res -= (n - points[other].size());
    }
    
    printf("%d\n",res);
  }
}

Measured memory_bytes: 1548
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  int A[3][3];
  rep(i,3)rep(j,3)cin >> A[i][j];
  int N;
  cin >> N;
  vector<int> B(N);
  rep(i,N)cin >> B[i];
  rep(i,N){
    rep(j,3)rep(k,3){
      if(A[j][k]==B[i])A[j][k]=0;
    }
  }
  bool flag = false;
  if(A[0][0]==A[1][1] && A[1][1]==A[2][2])flag=true;
  if(A[0][2]==A[1][1] && A[1][1]==A[2][0])flag=true;
  rep(i,3){
    if(A[i][0]==A[i][1] && A[i][1]==A[i][2])flag=true;
  }
  rep(i,3){
    if(A[0][i]==A[1][i] && A[1][i]==A[2][i])flag=true;
  }

  if(flag)cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

using namespace std;

int main(){
    
    int n, m, x;
    int cnt1 = 0, cnt2 = 0;
    vector<int> a;

    cin >> n >> m >> x;

    for(int i = 0; i < m; i++){
        int tmp;
        cin >> tmp;
        a.emplace_back(tmp);
    }

    for(int i = 0; i < m; i++){
        if(a[i] < x) cnt1++;
        if(a[i] > x) cnt2++; 
    }

    cout << min(cnt1, cnt2) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>

using namespace std;

const double PI = acos(-1.0);

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

	for (int i = 1; i <= n; i++) {
		int x = i;
		if (x % 3 == 0) {
			cout << " " << i;
			continue;
		}
		while (x > 0) {
			if (x % 10 == 3) {
				cout << " " << i;
				break;
			}
			x /= 10;
		}
	}
	cout << endl;

	return 0;
}



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

int n, a[3];
string s[100000];

int next(int n) { return (n + 1) % 3; }
int prev(int n) { return (n - 1 + 3) % 3; }

signed main() {
	int i, j;
	
	cin >> n >> a[0] >> a[1] >> a[2];
	rep(i, n) {
		cin >> s[i];
		if (s[i] == "AC") { s[i] = "CA"; }
	}
	
	stack<int> stk[6];	//"AB", "BC", "CA" | "BA", "CB", "AC"
	rep(i, n) {
		a[s[i][0] - 'A']++;
		a[s[i][1] - 'A']--;
		stk[s[i][0] - 'A'].push(i);
		
		int t = s[i][0] - 'A';
		rep(j, 3) {
			while (!stk[t].empty() && a[next(t)] < 0) {
				int id = stk[t].top(); stk[t].pop();
				a[t] -= 2;
				a[next(t)] += 2;
				stk[t + 3].push(id);
			}
			t = prev(t);
		}
		if (a[0] < 0 || a[1] < 0 || a[2] < 0) { cout << "No" << endl; return 0; }
	}
	
	string coms[6] = {"AB", "BC", "CA", "BA", "CB", "AC"};
	static string ans[100000];
	
	rep(i, 6) {
		while (!stk[i].empty()) {
			int id = stk[i].top();
			stk[i].pop();
			ans[id] = coms[i];
		}
	}
	
	cout << "Yes" << endl;
	rep(i, n) cout << ans[i][0] << endl;
	return 0;
}

Measured memory_bytes: 10264
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 1000005 ;
using namespace std ;
 
int n, h[26], f[N][26], r[N] ;
char s[N], t[N] ;
struct poi {
    int x, y ;
} a[N] ;
 
int main() {
    scanf("%d", &n) ;
    scanf("%s%s", s + 1, t + 1) ;
    bool flg = true ;
    rep(i, 1, n) if (s[i] != t[i]) 
        flg = false ;
    if (flg) {
        printf("0\n") ;
        return 0 ;
    }
    rep(i, 0, 25) h[i] = 0 ;
    rep(i, 1, n) {
        h[s[i] - 'a'] = i ;
        rep(j, 0, 25) f[i][j] = h[j] ;
    }
    int las = n ;
    for (int i = n ; i; -- i) {
        las = min(las, i) ;
        int x = f[las][t[i] - 'a'] ;
        if (!x) {
            printf("-1\n") ;
            return 0 ; 
        }
        r[x] = max(r[x], i) ;
        las = x ;
    }
    int tot = 0, ans = 0 ;
    rep(i, 1, n) if (r[i]) {
        ++ tot ;
        a[tot].x = i, a[tot].y = r[i] ;
    }
    a[tot + 1].x = n + 1 ;
    rep(i, 1, n) {
        int l = i, r = tot + 1, goal = a[i].y - i, ret = r ;
        for ( ; l <= r ; ) {
            int mid = (l + r) / 2 ;
            if (a[mid].x - mid >= goal) ret = mid, r = mid - 1 ;
                else l = mid + 1 ;
        }
        ans = max(ans, ret - i) ;
    }
    printf("%d\n", ans) ;
    return 0 ;
}

Measured memory_bytes: 115456
from functools import reduce

def cin():  return list(map(int,input().split()))
N, M, K = cin()
MOD = 998244353

fac = [1] * (N + 1)
inv = [1] * (N + 1)

for j in range(1, N + 1):  fac[j] = fac[j - 1] * j % MOD

inv[N] = pow(fac[N], MOD - 2, MOD)
for j in range(N - 1, -1, -1):  inv[j] = inv[j + 1] * (j + 1) % MOD
    
def cmb(n, r):
    if r > n or n < 0 or r < 0:  return 0
    return fac[n] * inv[n - r] * inv[r] % MOD

ans = 0
for i in range(K + 1):
    ans += M * cmb(N - 1, i) * pow(M - 1, N - 1 - i, MOD)
    ans %= MOD
print(ans)

Measured memory_bytes: 80076
import Enum

defmodule Main do
  def battle(a, _b, c, _d) when a <= 0 or c <= 0 do
    if c > 0 do
      "No"
    else
      "Yes"
    end
  end

  def battle(a, b, c, d) do
    battle(a - d, b, c - b, d)
  end

  def main do
    [a, b, c, d] =
      IO.read(:line)
      |> String.trim
      |> String.split(" ")
      |> map(&String.to_integer(&1))

    IO.puts(battle(a, b, c, d))
  end
end


Measured memory_bytes: 30736
//When I wrote this only God and I knew what it is
//Now, only The_Blitz knows...
#pragma GCC optimize ("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define sz(x) int(x.size())
#define pb push_back
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ff first
#define ss second
typedef long long ll;
typedef pair<int, int> ii;

int main(){
	fastio;
	ll n, k; cin >> n >> k;
	int ans = 0;
	while(n -- ){
		ll x; cin >> x;
		if(x >= k) ans ++;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
using namespace std;

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

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

  int sx,sy;
  vector<vector<char> > map(h+2, vector<char>(w+2, '#'));
  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
      cin >> map[i][j];
      if(map[i][j]=='%'){
        sy=i;
        sx=j;
      }
    }
  }

  queue<pair<int,pair<int,int> > > q;
  q.push(make_pair(0, make_pair(sy,sx)));
  map[sy][sx]='#';
  int princess=1e9;
  int soldier=1e9;
  while(!q.empty()){
    int step=q.front().first;
    int y=q.front().second.first;
    int x=q.front().second.second;
    q.pop();
    for(int i=0; i<4; i++){
      int nx=x+dx[i];
      int ny=y+dy[i];
      if(map[ny][nx]!='#'){
        if(map[ny][nx]=='@') princess = step;
        if(map[ny][nx]=='$') soldier = min(step, soldier);
        map[ny][nx] = '#';
        q.push(make_pair(step+1, make_pair(ny,nx)));
      }
    }
  }

  if(princess<soldier){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3168
/* 
 * Author: pawanmsr
 */

/*
 * Run in Mac using the following command:
 * g++ -std=c++14 <cpp_filename>
 * A binary will be generated. Then run:
 * ./a.out
 */

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <fstream>
#include <cstring>
#include <unordered_map>

// #include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

// Macro //
#define X first
#define Y second
#define pii pair<int,int>
#define pll pair<ll,ll>

// Global //
int n, t[50];
string x, s[50];

// Functions //


// Main //
int main(int argc, char const *argv[])
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // // freopen("output.txt", "w", stdout);
    // #else
    // // online submission
    // #endif
    
    /* code */
    cin >> n;
    for (int i=0; i<n; i++)
        cin >> s[i] >> t[i];
    cin >> x;

    int ans = 0;
    bool found = false;
    for (int i=0; i<n; i++) {
        if (found) ans += t[i];
        if (s[i] == x) found = true;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
  bool isPrime[1000001];
  int num, prime[1000001];
  for(int i = 0; i <= 1000000; i++) isPrime[i] = true;
  isPrime[0] = isPrime[1] = false;
  num = 0;
  for(int i = 2; i <= 1000000; i++){
    if(isPrime[i]){
      prime[num++] = i;
      for(int j = i+i; j <= 1000000; j += i) isPrime[j] = false;
    }
  }
  int a, d, n;
  while(cin >> a >> d >> n, a || d || n){
    int cnt = 0;
    int  A = a;
    while(cnt < n){
      if(isPrime[A]) cnt++;
      A += d;
    }
    cout << A - d << endl;
  }
  return 0;
}

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

int main(){
    int x,n;
    cin>>x>>n;
    if(n==0){cout<<x;return 0;}
    unordered_set<int> s;
    int temp;
    for(int i=0;i<n;++i){cin>>temp;s.insert(temp);}
    if(s.find(x)==s.end())cout<<x;
    else {
        int i=1;
        while(i>=1){
            if(s.find(x-i)==s.end()){cout<<x-i;break;}
            if(s.find(x+i)==s.end()){cout<<x+i;break;}
            i++;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3636
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n: usize = read();
    let a: Vec<i64> = read_vec();
    let mut dp = vec![Vec::new(); 1 << n];

    for j in 0..1 << n {
        dp[j].push(a[j]);
    }
    for i in 0..n {
        for j in (0..1 << n).rev() {
            if (1 << i) & j != 0 {
                let mut dum = dp[j - (1 << i)].clone();
                dp[j].append(&mut dum);
                dp[j].sort();
                dp[j] = vec![dp[j][dp[j].len() - 2], dp[j][dp[j].len() - 1]];
            }
        }
    }
    let mut current_max = 0;
    for j in 1..1 << n {
        current_max = std::cmp::max(current_max, dp[j][dp[j].len() - 1] + dp[j][dp[j].len() - 2]);
        println!("{}", current_max);
    }
}


Measured memory_bytes: 24820
memo = {}
def f(m,k):
    if k>m:
        return 0
    if m==1:
        return 1
    if k==0:
        return 1
    if k==1:
        return m
    if (m,k) in memo:
        return memo[(m,k)]
    memo[(m,k)]=f(m-1,k-1)+f(m-1,k)
    return memo[(m,k)]

N,A,B = map(int,input().split())
V = sorted(list(map(int,input().split())),reverse=True)
amin = 10**15+10
for i in range(A):
    amin = min(amin,V[i])
av = sum(V[:A])/A
cnt = 0
for i in range(N):
    if V[i]==amin:
        cnt += 1
cntB = 0
for i in range(B):
    if V[i]==amin:
        cntB += 1
cntA = 0
for i in range(A):
    if V[i]==amin:
        cntA += 1
print(av)
if V[0]>amin:
    print(f(cnt,cntA))
else:
    tot = 0
    for i in range(cntA,cntB+1):
        tot += f(cnt,i)
    print(tot)

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
	int n,x;
	cin >> n >> x;
	int m[n];
	int sum = 0;
	for(int i=0;i<n;i++){
		cin >> m[i];
		sum += m[i];
	}
	sort(m,m+n);
	int ans = 0,i = 0;
	x -= sum;
	while(x>=0){
		ans++;
		x -= m[0];
	}
	cout << ans + n - 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    N*=2
    size = -1
    group_num = -1
    for i in range(2,N+2):
        if i*(i-1)==N:
            group_num = i
            size = i-1
            break
    if size == -1:
        print("No")
        return 
    
    ans = [[-1]*size for _ in range(group_num)]

    now = 0
    for i in range(group_num):
        for j in range(size):
            if j<i:
                ans[i][j] = ans[j][i-1]
            else:
                now += 1
                ans[i][j] = now

        
    print("Yes")
    print(group_num)
    for a in ans:
        print(size,*a)

if __name__ == '__main__':
    main()

Measured memory_bytes: 46940
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    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 {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    friend std::istream &operator>>(std::istream &in, mint &o) {
        ll a;
        in >> a;
        o = a;
        return in;
    }

    friend std::ostream &operator<<(std::ostream &out, const mint &o) {
        out << o.x;
        return out;
    }

};

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> s(n), t(m);
    for (int &i : s) cin >> i;
    for (int &i : t) cin >> i;
    vector<vector<mint>> dp(n, vector<mint>(m));

    auto get = [&](int i, int j) -> mint {
        if (i < 0) return 0;
        if (j < 0) return 0;
        return dp[i][j];
    };

    rep(i, n) {
        rep(j, m) {
            int a = s[i];
            int b = t[j];
            if (a != b) continue;
            dp[i][j] = get(i - 1, j - 1) + 1;
        }

        rep(j, m) dp[i][j] += get(i, j - 1);
        rep(j, m) dp[i][j] += get(i - 1, j);
    }

    cout << dp.back().back() + 1 << endl;

}


Measured memory_bytes: 34564
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws Exception
	{
		int k=nextInt();
		int x=nextInt();
		if(k*500>=x)
			out.println("Yes");
		else
			out.println("No");
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws Exception
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws Exception{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws Exception{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws Exception{
		return br.readLine();
	}
	int nextInt()throws Exception{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws Exception{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws Exception{
		return Double.parseDouble(nextToken());
	}
}

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

int main(){
    int n,K,R,S,P;
    string t;
    cin>>n>>K>>R>>S>>P>>t;

    ll ans=0;
    rep(k,K){
        bool last=false;
        for(int i=k;i<n;i+=K){
            if(i>=K && t[i-K]==t[i] && last) last=false;
            else{
                last=true;
                if(t[i]=='r') ans+=P;
                else if(t[i]=='s') ans+=R;
                else ans+=S;
            }
        }
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 3760
package main

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

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

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

func atoi(s string) int {
	i, e := strconv.Atoi(s)
	if e != nil {
		panic(e)
	}
	return i
}

func readStringArray() []string {
	return strings.Split(strings.TrimSpace(readLine()), " ")
}

func readInt() int {
	return atoi(readLine())
}

func readIntArray() []int {
	var a []int
	sa := readStringArray()
	for _, s := range sa {
		a = append(a, atoi(s))
	}
	return a
}

func main() {
	a1 := readIntArray()
	a2 := readIntArray()
	H := a1[0]
	W := a1[1]
	h := a2[0]
	w := a2[1]

	var ans int
	ans = (H - h) * (W - w)
	fmt.Println(ans)
}


Measured memory_bytes: 640
import java.util.*


fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    var N: Long
    N = sc.nextLong()
    val H = Array((N).toInt()){0L}
    for (i in 0 until N) {
        H[(i).toInt()] = sc.nextLong()
    }
    solve(N, H)
}

fun solve(N: Long, H: Array<Long>) {
    var res = 0
    var t = 0

    for (i in 0 until H.size - 1) {
        if (H[i] >= H[i + 1]) {
            t++
        } else {
            t = 0
        }
        res = Math.max(res, t)
    }

    println(res)
}



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

int main()
{
    int n, t, dig = 0, cnt = 0;
    cin >> n;
    t = n;
    while (t != 0)
    {
        t /= 10;
        dig++;
    }
    for (int i = 1; i < dig; i += 2)
        cnt += pow(10, i) - pow(10, i - 1);
    if (dig % 2)
        cnt += n - pow(10, dig - 1) + 1;
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {

	int x=0,y,a,b,c;
	
	cin >> a >> b >> c;
	for (int i = a; i <= b; i++) {
		if (c%i == 0) {
			x++;
		}
	}
	cout << x << endl;
	return 0;
}


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

namespace AOJ.ITP
{
    public class FindingMissingCards
    {
        public static void Main()
        {
            // トランプ存在チェック用配列を用意
            string[] card = new string[52];
            for (int i = 1; i <= 13; i++)
            {
                card[i - 1] = "S " + i;
                card[i + 12] = "H " + i;
                card[i + 25] = "C " + i;
                card[i + 38] = "D " + i;
            }

            // 手持ちのトランプを消していく
            int cnt = int.Parse(Console.ReadLine());
            for (int i = 0; i < cnt; i++)
            {
                var input = Console.ReadLine().Split(' ');
                int num = int.Parse(input[1]);
                switch (input[0])
                {
                    case "S":
                        num -= 1;
                        break;
                    case "H":
                        num += 12;
                        break;
                    case "C":
                        num += 25;
                        break;
                    case "D":
                        num += 38;
                        break;
                }
                card[num] = string.Empty;
            }

            // 結果を出力
            foreach (var s in card.Where(x => !string.IsNullOrEmpty(x))) { Console.WriteLine(s); }
        }
    }
}

Measured memory_bytes: 20288
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
  string a;
  cin >> a;
  int count = 700;
  if (a[0] == 'o') count += 100;
  if (a[1] == 'o') count += 100;
  if (a[2] == 'o') count += 100;
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        mut n: usize,
        m: usize,
        h: [usize; n],
    }
    let mut g = vec![true; n];
    for _ in 0..m {
        input! {
            a: Usize1,
            b: Usize1,
        }
        if h[a] <= h[b] {
            g[a] = false;
        }
        if h[a] >= h[b] {
            g[b] = false;
        }
    }

    println!("{}", g.into_iter().filter(|&gi| gi).count());
}


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

template <typename T> struct BinaryIndexedTree {
  BinaryIndexedTree(size_t n) : n(n + 1), v(n + 2) {}

  size_t n;
  vector<T> v;

  T sum(int k) {
    T ret = 0;
    for (++k; k; k -= k & -k) ret += v[k];
    return ret;
  }

  void add(int k, T x) {
    for (++k; k <= n; k += k & -k) v[k] += x;
  }
};

template <typename T> struct Compresser {
  Compresser(vector<T> &v) : formatted(v.size(), -1), zip(v) {
    sort(zip.begin(), zip.end());
    zip.erase(unique(zip.begin(), zip.end()), zip.end());
    for (int i = 0; i < formatted.size(); ++i) {
      formatted[i] = lower_bound(zip.begin(), zip.end(), v[i]) - zip.begin();
    }
  }

  vector<T> zip;
  vector<int> formatted;

  size_t size() {
    return formatted.size();
  }

  inline int operator[](size_t idx) {
    return formatted[idx];
  }

  T unzip(size_t idx) {
    return zip[formatted[idx]];
  }
};

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

  vector<int64_t> a(n + 1);
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    a[i] += a[i - 1] - k;
  }

  int64_t ans = 0;
  Compresser<int64_t> cmp(a);
  BinaryIndexedTree<int64_t> bit(n);
  for (int i = 0; i <= n; ++i) {
    ans += bit.sum(cmp[i]);
    bit.add(cmp[i], 1);
  }

  cout << ans << endl;
}


Measured memory_bytes: 5760