akhauriyash/Code-Regression huggingface dataset:
x, y = gets.chomp.split.map(&:to_i).sort

a = x
b = y

least_common_multiple = 0
while true do
  r = b % a
  if r == 0
    least_common_multiple = a
    break
  end
  b = a
  a = r
end

puts x / least_common_multiple * y

Measured memory_bytes: 1788
import java.util.Scanner;

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

    while (in.hasNext()) {
      int N = in.nextInt();

      if (N == 1) {
        System.out.println("Hello World");
      } else if (N == 2) {
        int A = in.nextInt();
        int B = in.nextInt();

        System.out.println(A + B);
      }
    }
  }
}

Measured memory_bytes: 21716
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//#include <ext/pb_ds/detail/standard_policies.hpp>
#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>



#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=a;i<=n;++i)
#define lpd(i,a,n) for(int i=a;i>=n;--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
//#define mod 1000000007
#define eps 1e-8
#define infi 1000000000
#define infll 1000000000000000000ll
#define mod1 100050001
#define mod2 100030001
#define base1 37
#define base2 31


using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;


const int N = 102;


int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    
    if(a+b < c) printf("No\n");
    else printf("Yes\n");
    
    return 0;
}



/*

 5 3
 1 3
 1 5
 3 6
 4 4
 2 6
 1 5 3
 1 5 4
 1 1 1

 */
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
//ios::sync_with_stdio(0);cin.tie(0);

Measured memory_bytes: 256
// Author: wlzhouzhuan
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rint register int
#define rep(i, l, r) for (rint i = l; i <= r; i++)
#define per(i, l, r) for (rint i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

const int N = 100005;
int a[N], b[N], m;
int A, B;

int main() {
  scanf("%d%d%d", &A, &B, &m);
  for (rint i = 1; i <= A; i++) a[i] = read();
  for (rint j = 1; j <= B; j++) b[j] = read();
  int ans = *min_element(a + 1, a + A + 1) + *min_element(b + 1, b + B + 1);
  while (m--) {
    int x = read(), y = read(), z = read();
    ans = min(ans, a[x] + b[y] - z);
  } 
  printf("%d\n", ans);
  return 0;
}

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

typedef long long ll;
ll q, a, b, c, ans;
int main()
{
	cin >> q;
	while (q--) {
		scanf("%lld %lld", &a, &b);
		c = sqrt(a * b);
		ans = c * 2 - 2;
		if (c * (c + 1) < a * b) ans++;
		else if (c * c == a * b && a != c) ans--;
		printf("%lld\n", ans);
	}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>
#include <iomanip>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define double long double
#define int long long
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define inf 10000000000000000 //10^16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
using namespace std;

signed main() {
	int a, b;
	cin >> a >> b;
	cout << max({ a + a - 1,b + b - 1,a + b }) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define mod 998244353
using namespace std;
int n,k;
int c[200005];
int l[15],r[15];
int lowbit(int x){
	return x&-x;
}
void update(int x,int p){
	while (x<=n){
		c[x]=(c[x]+p)%mod;
		if(c[x]<0) c[x]+=mod;
		x+=lowbit(x);
	}
}
ll sum(int x){
	ll ans=0;
	while (x){
		ans=(ans+c[x])%mod;
		if(ans<0) ans+=mod;
		x-=lowbit(x);
	}
	return ans;
}
int main(){
	scanf("%d %d",&n,&k);
	for(int i=1;i<=k;i++)
		scanf("%d %d",&l[i],&r[i]);
	update(1,1);
	update(2,-1);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=k;j++) {
			update(i+l[j], sum(i));
			update(i+r[j]+1,-sum(i));
		}
	}
	printf("%lld",sum(n));
	return 0;
}


Measured memory_bytes: 4524
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int32_t N;
char str[100010];
int32_t countA_bace_[100010];
int32_t countA_to_[100010];
auto countA_bace = countA_bace_+5;
auto countA_to = countA_to_+5;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> str;
	countA_bace[0] = (str[0]=='A'?1:0);
	auto c_iter = countA_bace + 1;
	for (auto iter = str+1; *iter != '\0'; ++iter) {
		*c_iter = c_iter[-1] + (*iter == 'A' ? 1 : 0);
		++c_iter;
	}
	*c_iter = c_iter[-1];
	in >> str;
	countA_to[0] = (str[0] == 'A' ? 1 : 0);
	c_iter = countA_to + 1;
	for (auto iter = str + 1; *iter != '\0'; ++iter) {
		*c_iter = c_iter[-1] + (*iter == 'A' ? 1 : 0);
		++c_iter;
	}
	*c_iter = c_iter[-1];

	int32_t Q;
	in >> Q;
	for (int32_t i = 0; i < Q; ++i)
	{
		int a, b;
		in >> a >> b; --a;
		int32_t bace_a = countA_bace[b-1] - countA_bace[a-1];
		int32_t bace_b = (b-a) - bace_a;
		in >> a >> b; --a;
		int32_t to_a = countA_to[b-1] - countA_to[a-1];
		int32_t to_b = (b - a) - to_a;

		int32_t need_a = to_a - bace_a;
		int32_t need_b = to_b - bace_b;
		need_a %= 3; need_b %= 3;
		need_a += 9; need_b += 9;
		need_a %= 3; need_b %= 3;
		if (need_a == need_b) {
			out << "YES" << endl;
		}
		else {
			out << "NO" << endl;
		}
	}

	return 0;
}
#endif


Measured memory_bytes: 1408
#include  <bits/stdc++.h>
using namespace std;
int main()
{
   int n,m;
   cin>>n>>m;
   int h[n],ma[n];
   for(int i=1;i<=n;i++)
   {
      cin>>h[i];
	  ma[i]=0;
   }
   
   for(int i=0;i<m;i++)
   {
      int a,b;
	  cin>>a>>b; 
	  ma[a]=max(ma[a],h[b]);
	  ma[b]=max(ma[b],h[a]);
   }
   
   int ans=0;
   for(int i=1;i<=n;i++)
   {
      ans += h[i]>ma[i];
   }
   
   cout<<ans<<endl;
}

Measured memory_bytes: 4368
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define Max 100001
#define inf 1000000000000000
using namespace std;
struct title {
    int p,c,score;
}s[11];
int d,g,ans = 1000;
int vis[11];
void dfs(int sum,int k) {
    for(int i = 1;i <= d;i ++) {
        if(vis[i])continue;
        if(g - sum <= s[i].score) {
            int temp;
            if(g - sum < s[i].p * i) {
                temp = g - sum;
                temp = temp / i + (temp % i > 0);
            }
            else temp = s[i].p;
            ans = min(ans,k + temp);
            continue;
        }
        vis[i] = 1;
        dfs(sum + s[i].score,k + s[i].p);
        vis[i] = 0;
    }
}
int main() {
    scanf("%d%d",&d,&g);
    g /= 100;
    for(int i = 1;i <= d;i ++) {
        scanf("%d%d",&s[i].p,&s[i].c);
        s[i].c /= 100;
        s[i].score = s[i].p * i + s[i].c;
    }
    dfs(0,0);
    printf("%d",ans);
}


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

int main() {
  int n;
  std::cin >> n;
  int a[4];
  for (int i = 3; i >= 0; --i) {
    a[i] = n % 10;
    n /= 10;
  }

  for (int j = -1; j <= 1; j += 2)
    for (int k = -1; k <= 1; k += 2)
      for (int l = -1; l <= 1; l += 2) {
        if (7 == (a[0] + a[1] * j + a[2] * k + a[3] * l)) {
          std::cout << a[0]
                    << (j > 0 ? '+' : '-') << a[1]
                    << (k > 0 ? '+' : '-') << a[2]
                    << (l > 0 ? '+' : '-') << a[3]
                    << "=7" << std::endl;
          return 0;
        }
      }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int a[200];
int b[200];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = n - 1; i >= 0; i--) {
		int sum = 0;
		for (int j = 0; j < n; j++) {
			if (!b[j]) {
				sum++;
			}
			if (sum == a[i]) {
				b[j] = a[i];
				goto loop;
			}
		}
		cout << -1 << endl;
		return 0;
	loop:;
	}
	for (int i = 0; i < n; i++) {
		cout << b[i] << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    long long int n,i,j;
    cin>>n;
    long long int a[n][3];
    for(i=0;i<n;i++)
    {
        for(j=0;j<3;j++)
        {
            cin>>a[i][j];
        }
    }
    for(i=1;i<n;i++)
    {
        a[i][0]=max(a[i-1][1],a[i-1][2])+a[i][0];
        a[i][1]=max(a[i-1][2],a[i-1][0])+a[i][1];
        a[i][2]=max(a[i-1][1],a[i-1][0])+a[i][2];
    }
    cout<<max(a[n-1][0],max(a[n-1][1],a[n-1][2]));
    return 0;
}




Measured memory_bytes: 2560
n = int(input())
out=100000
for i in range(1,n):
    a=n-i
    b1=str(a)
    b2=str(i)
    c=list(b1)
    c.extend(b2)
    d=[int(s) for s in c]
    e=sum(d)
    
    if e<out:
        out=e
        
print(out)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

int main() {
    map<string, int> card;
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        card[s]++;
    }
    int m; cin >> m;
    for (int i = 0; i < m; i++) {
        string s; cin >> s;
        card[s]--;
    }

    int ans = 0;
    for (auto p : card) {
        int score = p.second;
        chmax(ans, score);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

using namespace std;



int main(void){

	int n,max=0,num[101]={0};

	while(scanf("%d",&n)!=EOF){
		num[n]++;
		if(num[n]>max) max=num[n];
	}

	for(int i=1;i<=100;i++){
		if(num[i]==max) printf("%d\n",i);
	}
	return 0;
}

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

const int MAXN = 1e5 + 21;

int a[MAXN], b[MAXN];
int n;
long long ans;
pair <int, int> c[MAXN];

int main() {
	ios_base::sync_with_stdio;
	cin.tie();
	cout.tie();
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		c[i].first = a[i] + b[i];
		c[i].second = i;
	}

	sort(c, c + n);

	for (int i = n - 1; i >= 0; i--) {
		if (i % 2 == (n - 1) % 2)
			ans += a[c[i].second];
		else
			ans -= b[c[i].second];
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  int s = 0;
  for(int i = 0;i<3;i++)
  {
      int a;
      cin >> a;
      s += a;
  }
  if(s > 21)cout << "bust\n";
  else cout << "win\n";
  return 0;
}



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

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define PI (acos(-1))
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

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

	ll ans=0;

	ll N=S.size()-1;
	for (int bit = 0; bit < (1<<N); bit++){
		ll t=S[0]-'0';
		rep(i,N){
			ll tt=S[i+1]-'0';
			if (bit & (1<<i)) {///
				ans+=t;
				t=tt;
			} else {
				t=t*10+tt;
			}
		}
		ans+=t;
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main (String args[]) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int P = sc.nextInt();
    String S = sc.next();
    long ans = 0;
    if(P==2||P==5){
      for(int i = N-1; i >= 0; i--){
        if((S.charAt(i)-'0')%P==0){
          ans+=i+1;
        }
      }
    } else {
      int amari[] = new int[P];
      int jouyo = 0;
      int kurai = 1;
      for(int i = N-1; i >= 0; i--){
        jouyo = (jouyo + (S.charAt(i)-'0')*kurai)%P;
        kurai = (kurai*10)%P;
        amari[jouyo]++;
      }
      ans = amari[0];
      for(int i = 0; i < P; i++){
        ans += (long)amari[i]*(amari[i]-1)/2;
      }
    }
    System.out.println(ans);
    return;
  }
}

Measured memory_bytes: 28016
X = int(input())

max_ = 1

for i in range(2,X):
  power=1
  while i**(power+1)<=X:
    power+=1
    
  if power==1:
    break
    
  if i**power>max_:
    #print(i)
    #print(power)
    max_=i**power
    
print(max_)

Measured memory_bytes: 2940
#include<iostream>
#include<cmath>
#include<cstdio>

using namespace std;

int main(){
    double x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    double l=sqrt(((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)));
    printf("%lf\n",l)  ;

    return 0;

}


Measured memory_bytes: 3216
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  int value=0,i;
  string s;
  cin>>s;
  rep(i,0,3)
    if(s.at(i)=='o')value+=100;
  ou(value+700);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int maxN = 2e5+10;
const int mod = 998244353;
int main(){
	ll n,k;
	cin>>n>>k;
	vector<pair<ll,ll>>v(k);
	for(int i=0;i<k;i++){
		cin>>v[i].first>>v[i].second;
	}
	ll dp[maxN]={0};
	ll prefix[maxN]={0};
	//prefix[R]-prefix[L-1] = dp[L]+dp[L+1}+dp[L+2]....dp[L+R];
	//now suppose we have a range form l to r (r>l)
	//we know that for a particular dp[i] all those valid candidates from dp[i-r] to dp[i-l] wiil contribute
	// so therefore for(int k=i-r;k<=i-l;k++) dp[i]=dp[i]+dp[k];
	//that means i need dp[i-r]+dp[i-r+1]-----dp[i-l] = prefix[i-l]-prefix[i-r-1];
	
	dp[1]=1;
	prefix[1]=1;
	for(int i=2;i<=n;i++){
		for(int j=0;j<k;j++){
			int l=v[j].first,r=v[j].second;
			if(i-l<1){
				continue;
			}	
			else if(i-r-1<1){
				dp[i] = (dp[i] + prefix[i-l]-prefix[0])%mod;
			}
			else{
				dp[i] = (mod + dp[i] + prefix[i-l] - prefix[i-r-1])%mod;
			}
		}
		
		prefix[i]=(prefix[i-1]+dp[i])%mod;
	}
	
	cout<<dp[n]%mod<<endl;
}

Measured memory_bytes: 6748
def calc0(N, M):
    cell = [[0 for i in range(M)] for j in range(N)]
    for i in range(M):
        for j in range(N):
            for y in range(-1, 2):
                for x in range(-1, 2):
                    xx = i + x
                    yy = j + y
                    if 0 <= xx < M and 0 <= yy < N:
                        cell[yy][xx] ^= 1
    r = 0
    for i in range(M):
        for j in range(N):
            if cell[j][i]:
                r += 1
    return r
    
def calc(N, M):
    if N == 1 and M == 1:
        return 1
    if N >= 2 and M >= 2:
        return (N - 2) * (M - 2)
    if N == 1:
        return M - 2
    return N - 2

N, M = [int(_) for _ in input().split()]

print(calc(N, M))



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N;
int P[505*505];

int D[505][505];
int did[505][505];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N*N) {
		cin>>P[i];
		P[i]--;
	}
	FOR(y,N) FOR(x,N) {
		did[y][x]=1;
		D[y][x]=min({x+1,y+1,N-y,N-x});
	}
	
	int ret=0;
	FOR(i,N*N) {
		y=P[i]/N;
		x=P[i]%N;
		D[y][x]=101000;
		if(y) D[y][x]=min(D[y][x],D[y-1][x]);
		if(x) D[y][x]=min(D[y][x],D[y][x-1]);
		if(y+1<N) D[y][x]=min(D[y][x],D[y+1][x]);
		if(x+1<N) D[y][x]=min(D[y][x],D[y][x+1]);
		if(x==0 || y==0 || x+1==N || y+1==N) D[y][x]=0;
		ret+=D[y][x];
		did[y][x]=0;
		queue<int> Q;
		if(y) Q.push((y-1)*500+x);
		if(x) Q.push((y-0)*500+x-1);
		if(y+1<N) Q.push((y+1)*500+x);
		if(x+1<N) Q.push((y-0)*500+x+1);
		while(Q.size()) {
			y=Q.front()/500;
			x=Q.front()%500;
			Q.pop();
			
			int mi=1010;
			if(y) mi=min(mi,D[y-1][x]);
			if(x) mi=min(mi,D[y][x-1]);
			if(y+1<N) mi=min(mi,D[y+1][x]);
			if(x+1<N) mi=min(mi,D[y][x+1]);
			if(mi+did[y][x]<D[y][x]) {
				D[y][x]=mi+did[y][x];
				if(y) Q.push((y-1)*500+x);
				if(x) Q.push((y-0)*500+x-1);
				if(y+1<N) Q.push((y+1)*500+x);
				if(x+1<N) Q.push((y-0)*500+x+1);
			}
			
		}
		
	}
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 6580
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";
    readonly string ALFA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    int N;
    void solve()
    {
        N = cin.nextint;
        int K = cin.nextint;
        var A = new int[26];
        for (int i = 0; i < N; i++)
        {
            A[ReadLine()[0] - 'A']++;
        }
        int cnt = 0;
        while (true)
        {
            Array.Sort(A);
            Array.Reverse(A);
            if (A[K - 1] <= 0) break;
            for (int i = 0; i < K; i++)
            {
                A[i]--;
            }
            cnt++;
        }
        WriteLine(cnt);

    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int ans;
int a,b,c,d;
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>a>>b>>c>>d;
	ans=a*c;
	ans=max(ans,a*d);
	ans=max(ans,b*c);
	ans=max(ans,b*d);
	cout<<ans;
	re 0;
}

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

ll x[100000], y[100000], tx[100000], ty[100000], sum1[100001], sum2[100001];
#define dist(x,y)(abs(i-x)+abs(j-y))
int main() {
	ll w, h, n; scanf("%lld%lld%lld", &w, &h, &n);
	rep(i, n) {
		scanf("%lld%lld", &x[i], &y[i]);
		tx[i] = x[i]; ty[i] = y[i];
	}
	sort(x, x + n); sort(y, y + n);
	rep(i, n) {
		sum1[i + 1] = sum1[i] + x[i];
		sum2[i + 1] = sum2[i] + y[i];
	}
	set<ll>ax, ay;
	ll mx = LLONG_MAX, my = LLONG_MAX;
	rep(i, n) {
		ll a = ((x[i] * i - sum1[i]) + (sum1[n] - sum1[i] - x[i] * (n - i))) * 2;
		if (mx > a)mx = a, ax.clear();
		if (mx == a)ax.insert(x[i]);
		a = ((y[i] * i - sum2[i]) + (sum2[n] - sum2[i] - y[i] * (n - i))) * 2;
		if (my > a)my = a, ay.clear();
		if (my == a)ay.insert(y[i]);
	}
	ll ansx, ansy, ans = LLONG_MAX;
	for (ll i : ax)for (ll j : ay)rep(k, n) {
		ll d = mx + my - dist(tx[k], ty[k]);
		if (ans > d) {
			ans = d;
			ansx = i; ansy = j;
		}
	}
	printf("%lld\n%lld %lld\n", ans, ansx, ansy);
}

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

int maxNum(int num,int length){
	int data[10];

	for(int i=0;i<10;i++){
		data[i]=0;
	}

	for(int i=0;i<length;i++){
		data[num%10]++;
		num/=10;
	}

	int ten=1;
	for(int i=1;i<length;i++){
		ten*=10;
	}

	int ans=0;

	for(int j=9;j>=0;j--){
		while(data[j]>0){
			ans += (ten*j);
			data[j]--;
			ten/=10;
		}
	}

	return ans;
}

int minNum(int num,int length){
	int data[10];
	for(int i=0;i<10;i++)data[i]=0;

	int cnt=0;

	while(1){
		data[num%10]++;
		num/=10;	
		if(num==0)break;
	}

	for(int i=1;i<=9;i++){
		cnt+=data[i];
	}
		

	if(cnt>=length)cnt = length;

	int ten=1;
	for(int i=1;i<cnt;i++)ten*=10;

	int ans=0;


	for(int i=1;i<10;i++){
		while(data[i]>0){
			ans += i*ten;
			data[i]--;
			ten/=10;
		}
	}

	return ans;
}

int main(){

	int a,n;
	int data[30];

	while(cin>>a>>n){

		if(a==0 && n==0)break;
		
		for(int i=0;i<30;i++)data[i]=0;
		data[0] = a;

		for(int i=1;i<30;i++){
			data[i] = maxNum(data[i-1],n)-minNum(data[i-1],n);
		//	cout<<"i="<<i<<"max="<<maxNum(data[i-1],n)<<"min="<<minNum(data[i-1],n)<<"ans="<<data[i]<<endl;
		}

		int flag=0;
		for(int i=1;i<30;i++){
			for(int j=0;j<i;j++){
				if(data[i]==data[j]){
					cout<<j<<" "<<data[i]<<" "<<i-j<<endl;
					flag=1;
					break;
				}
			}
			if(flag==1)break;
		}

	}
	return 0;
}

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

int main()
{
    char x[1000+1];
    int len, sum;
    int i;
    while(1) {
        scanf("%s", x);
        if(strcmp(x, "0") == 0) {
            break;
        }
        len = strlen(x);
        sum = 0;
        for(i = 0; i < len; i++) {
            sum += x[i] - '0';
        }
        printf("%d\n", sum);
    }
    return 0;
}


Measured memory_bytes: 2100
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())
if(A<B):
    A=A+V*T
    B=B+W*T
    if (A<B):
        print("NO")
    else:
        print("YES")
else:
    A=A-V*T
    B=B-W*T
    if (A>B):
        print("NO")
    else:
        print("YES")
    
    

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


#define ll long long int
#define ld long double
#define mod 1000000007
#define big 1e18+10
#define small -big
#define pb push_back
#define endl "\n"


template <typename T>

void prarr(T a)
{
     cerr << "[ ";
     
     for(auto i : a){
         cerr << i << " ";
     }
     
     cerr << "]" << endl;
}


#define trace(...) _er(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void _er(const char* name, Arg1&& arg1){
	cerr << "[" << name << " : " << arg1 << "]" << endl;
}

template <typename Arg1, typename... Args>

void _er(const char* names, Arg1&& arg1, Args&&... args){
    
	const char* comma = strchr(names + 1, ',');
	cerr << "[" ; cerr.write(names, comma - names) << " : " << arg1 << "] ";
	_er(comma+2, args...);
}


ll N, K;
ll A[200005];


ll check(ll mid) {
        
        ll c = 0;
        for(ll i = 1; i <= N; i++) {
                
                c += (((A[i] + mid - 1) / mid) - 1);
                
                
        }
        
      
        
        return c;
}
ll bin() {
        
        ll low = 1;
        ll high = A[N];
        ll mid;
        ll ans = A[N];
        
        while(low <= high) {
                
                mid = (low + high) / 2;
                
                if(check(mid) <= K) {
                        
                       
                        
                        ans = mid;
                        high = mid - 1;
                } else {
                        low = mid + 1;
                }
        }
        
        return ans;
}

void solve() {
        
        cin >> N >> K;
        
        for(ll i = 1; i <= N; i++) {
                cin >> A[i];
        }
        
        sort(A + 1, A + 1 + N);
        
        cout << bin() << endl;
}


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

    int t = 1;
    //cin >> t;

    for(int i = 1; i <= t; i++) {  
   
         solve();
    }


    return 0;
        
}


Measured memory_bytes: 5216
/*
author: Apoorv Singh
*/

#include <bits/stdc++.h>
using namespace std;

typedef vector <int> vi;
typedef vector <long long> vl;
typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
#define ll long long
#define pb push_back   
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " " << (x) << endl;
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second

ll modulo = 1e9 + 7;

template <class X>

void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}

ll fpow(ll a, ll n)
{
    ll ans = 1;
    while (n)
    {
        if (n&1)
            ans = (ans * a)%modulo;
        a = (a*a)%modulo;
        n = n >> 1;
    }
    return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    int a[n], b[n], c[n];
    FOR(i,0,n)
    	cin >> a[i] >> b[i] >> c[i];
    ll dp[n][3];
    FOR(i,0,n)
    {
    	FOR(j,0,3)
    		dp[i][j] = 0;
    }
    dp[0][0] = a[0]; dp[0][1] = b[0]; dp[0][2] = c[0];
    FOR(i,1,n)
    {
    	dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
    	dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]);
    	dp[i][2] = c[i] + max(dp[i-1][1], dp[i-1][0]);
    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
    return 0;
}


Measured memory_bytes: 3840
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	for (int i=1; i<=9; i++)
		for (int j=i; j<=9; j++) 
			if (i*j==n) {cout<<"Yes"<<endl; return 0;}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 45

int  main(){

  int i,n,A[N];
  
  scanf("%d",&n);
  A[0]=A[1]=1;

  
  for(i=2;i<=n;i++){
    A[i]=A[i-1]+A[i-2];
  }
    
  printf("%d\n",A[n]);
  
  return 0;
    }



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}

int n,a,b,c;
vector<string> s;
vector<char> ans;

void dfs(int i, int a, int b, int c){
    if(i == n){
        cout << "Yes\n";
        rep(i,n) cout << ans[i] << "\n";
        exit(0);
    }
    if(s[i] == "AB"){
        if(a) ans[i] = 'B', dfs(i+1, a-1, b+1, c);
        if(b) ans[i] = 'A', dfs(i+1, a+1, b-1, c);
    }
    if(s[i] == "BC"){
        if(b) ans[i] = 'C', dfs(i+1, a, b-1, c+1);
        if(c) ans[i] = 'B', dfs(i+1, a, b+1, c-1);
    }
    if(s[i] == "AC"){
        if(a) ans[i] = 'C', dfs(i+1, a-1, b, c+1);
        if(c) ans[i] = 'A', dfs(i+1, a+1, b, c-1);
    }
}

int main(){
    cin >> n >> a >> b >> c;
    s.resize(n);
    ans.resize(n);
    rep(i,n) cin >> s[i];
    dfs(0, a, b, c);
    cout << "No\n";
}

Measured memory_bytes: 15920
lst = [int(input()) for i in range(5)]
ans=0
tmpl=[]
for i in range(5):
    ans+=lst[i]
    if(lst[i]%10!=0):
        ans+=10-lst[i]%10
for i in lst:
    if(i%10==0):
        tmpl+=[10]
    else:
        tmpl+=[i%10]
ans-=10-min(tmpl)
print(ans)    


Measured memory_bytes: 3060
#if 1
  #include <bits/stdc++.h>
#else
  #include "../../../../bits/stdc++.h"
#endif

#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define REP(i,n) FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))

using namespace std;

using pii =  pair<int, int>;
using ll = long long;

#define pb push_back
#define mp make_pair
#define ft first
#define sd second

int N;
ll T[101];


ll gcd_(ll a, ll b) {
  if(a==0 || b==0)return a+b;
  else if(a==b) return a;
  else return gcd_(a%b, b%a);
}

ll lcm_(ll a, ll b) {
  return (a/gcd_(a, b))*b;
}

int main(){
  cin.tie(0);
  
  cin>>N;
  REP(i, N)cin>>T[i];

  ll l=1;

  REP(i, N)l = lcm_(l, T[i]);

  cout<<l<<endl;

  return 0;
}


Measured memory_bytes: 256
s=input()
s=s.replace('BC','D')
s=list(s)
count=0
 
def change():
  global count
  flg=False
  acount=0
  for i in range(len(s)-1):
    if s[i]=='A' and s[i+1]=='D':
      s[i]='D'
      s[i+1]='A'
      count+=1
      flg=True
      count+=acount
    elif s[i]=='A':
      acount+=1
    else:
      acount=0
      
  return flg
      
change()
 
print(count)

Measured memory_bytes: 4840
fun main(args: Array<String>) {
    a58(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a58(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    val numList = args[0].split(" ").map { it.toInt() }
    val diffSet = (1..(numList.size - 1)).map { numList[it] - numList[it - 1] }.toSet()
    println(if (diffSet.size == 1) "YES" else "NO")
}


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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

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

int const MAX = 55;

int n, x, d;
int m[MAX];
vi e[MAX];
ll ds[MAX];
int dq[MAX];

void dfs1(int x, int p = -1) {
	dq[x] = 1;
	ds[x] = m[x];
	for (int y : e[x]) {
		if (y == p) continue;
		dfs1(y, x);
		ds[x] += ds[y];
		dq[x] += dq[y];
	}
}

struct Don {
	ll q, w, c;
	Don () {};
	Don (ll q, ll w, ll c) : q(q), w(w), c(c) {};
	bool operator<(const Don & a) {
		return c * a.w - a.c * w > 0;
	}
};

vector<Don> a, b;

ll const INF = 1e9 + 41;
int const MAXQ = MAX * MAX * MAX;
ll dp[2][MAXQ];

void setval(int id) {
	fi(0, MAXQ - 1) {
		dp[id][i] = INF;
	}
}

ll mult(ll a, ll b) {
	if (a == 0) return 0;
	if (b == 0) return 0;
	if (a > INF || b > INF) return INF;
	return min(INF, a * b);
}

void solve() {
	dfs1(1);
	ll q = x / ds[1];
	a.pb(Don(min(q, 50LL), ds[1], dq[1]));
	if (q > 50) {
		b.pb(Don(q - 50, ds[1], dq[1]));
	}
	fi(2, n) {
		ll q = x / ds[i];
		q = min(q, (ll) d);
		a.pb(Don(min(q, 50LL), ds[i], dq[i]));
		if (q > 50) {
			b.pb(Don(q - 50, ds[i], dq[i]));
		}				
	}
	sort(b.begin(), b.end());

	setval(0);
	setval(1);
	dp[0][0] = 0;
	fi(0, sz(a) - 1) {
		setval(1);
		fj(0, MAXQ - 1) {
			for (ll take = 0; take <= a[i].q; take++) {
				ll c1 = mult(take, a[i].w);
				if (c1 + dp[0][j] >= INF) break;
				assert(j + take * a[i].c < MAXQ);
				dp[1][j + take * a[i].c] = min(dp[1][j + take * a[i].c], dp[0][j] + c1);
			}
		}
		memcpy(dp[0], dp[1], sizeof(dp[0]));	
	}			

	ll ans = 0;
	fi(0, MAXQ - 1) {
		int rem = x - dp[0][i];
		if (rem < 0) continue;
		int cur = i;
		fj(0, sz(b) - 1) {
			ll mini = min(b[j].q, rem / b[j].w);
			cur += mini * b[j].c;
			rem -= b[j].w * mini;
		}
		ans = max(ans, (ll) cur);
	}

	printf("%lld\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	scanf("%d %d %d", &n, &x, &d);
	scanf("%d", &m[1]);
	fi(2, n) {
		int p;
		scanf("%d %d", &m[i], &p);
		e[p].pb(i);
	}  
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

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

int main(){
  string s; cin >> s;
  int s_size = (int)s.size();
  
  bool easy = true;
  for(int i=0; i<s_size; i++){
    int im = i%2;
    if(im==0){
      if(s[i]=='L'){
        easy = false;
        break;
      }
    }else{
      if(s[i]=='R'){
        easy = false;
        break;
      }
    }
  }
  cout << (easy ? "Yes\n" : "No\n");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<61;
const double pi=acos(-1);
const double eps=1e-10;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vi a;

int main(){
	cin>>n;
	n*=2;
	a=vi(n);
	double res=0;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a.rbegin(),a.rend());
	for(int i=0;i<n;i++) res+=a[i]*(1.0-(double)i/(n-1));
	cout<<syosu(11)<<res<<endl;
}

Measured memory_bytes: 1152
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>  // https://boostjp.github.io/tips/math.html
#include <boost/dynamic_bitset.hpp>  // https://boostjp.github.io/tips/dynamic_bitset.html

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

/** 素因数分解
 */
template<typename T>
std::map<T, size_t>
prime_factorize(T n, std::map<T, size_t>& res) {
    for (T p = 2; p * p <= n; ++p) {
        if (n % p != 0) {
            continue;
        }
        size_t num = 0;
        while (n % p == 0) {
            ++num;
            n /= p;
        }
        res[p] += num;
    }
    if (n != 1) {
        res[n] += 1;
    }
    return res;
}


int main()
{
    int64_t N;
    std::cin >> N;

    std::map<int64_t, size_t> f;

    for (int64_t i = 2; i <= N; ++i) {
        prime_factorize(i, f);
    }

    int64_t ans = 1;
    for (auto g: f) {
        if (g.first != 1) {
            ans *= g.second + 1;
            ans %= DIV1097;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin>>a;
    int cnt=0;
    int arr[10]={0};
    for(int i=0;i<a.size();i++){
        if (a[i]=='B'){
            if (cnt!=0){
                cnt-=1;
            }
        }
        else if (a[i]=='0'){
            arr[cnt]=0;
            cnt+=1;
        }
        else if (a[i]=='1'){
            arr[cnt]=1;
            cnt+=1;
        }
    }
    for(int i=0;i<cnt;i++){
        printf("%d", arr[i]);
    }
}

Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        #[allow(unused_mut)]
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashMap;

fn main() {
    input! {
       n: usize,
       s: [String; n],
    }
    let mut counter = HashMap::new();
    for si in s {
        let cnt = counter.entry(si).or_insert(0);
        *cnt += 1;
    }
    let max = counter.iter().map(|(_, v)| v).max().unwrap();
    let mut ans = vec![];
    for (k, v) in counter.iter() {
        if v == max {
            ans.push(k);
        }
    }
    ans.sort();
    for i in ans {
        println!("{}", i);
    }
}


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

int main()
{
	int a, b;

	cin >> a >> b;

	if ((a >= 1) && (a <= 9) && (b >= 1) && (b <= 9)) {
		cout << a * b << endl;
	}
	else {
		cout << -1 << endl;
	}
	

	return 0;
}

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

signed main(){
    int n;cin>>n;
    int ans=0;
    rep(i,n){int a;cin>>a;ans+=a;}
    ans-=(n*(n+1)/2);
    cout<<ans<<endl;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define ll long long
const ll MOD=1e9+7;
using namespace std;

int main(){
  ll N,ans=MOD;
  string S;
  cin>>N>>S;
  vector<ll> W(N,0),E(N,0);
  for(ll i=0;i<N;i++){
    if(S[i]=='W') W[i]++;
    else E[i]++;
  }
  for(ll i=1;i<N;i++){
    E[i]+=E[i-1];
    W[i]+=W[i-1];
  }
  for(ll i=0;i<N;i++){
    ll a=0,b;
    if(i!=0) a=W[i];
    if(i==N-1) b=0;
    else b=E[N-1]-E[i+1];
    ans=min(ans,a+b);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 5380
N = int(input())
A= []
for i in range(N):
    a,b = map(str, input().split())
    k =[a,b]
    A.append(k)



S = []
H = []
C = []
D = []

for i in range(N):
    if A[i][0] == "S":
        S.append(int(A[i][1]))
    elif A[i][0] == "H":
        H.append(int(A[i][1]))
    elif A[i][0] == "C":
        C.append(int(A[i][1]))
    elif A[i][0] == "D":
        D.append(int(A[i][1]))


for i in range(1,14):
    if i not in S:
        print("S",i)
for i in range(1,14):
    if i not in H:
        print("H",i)
for i in range(1,14):
    if i not in C:
        print("C",i)
for i in range(1,14):
    if i not in D:
        print("D",i)



Measured memory_bytes: 5620
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def SS(): return map(str,sys.stdin.readline().rstrip().split())
def II(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

K = I()
s = S()

if len(s) <= K:
  print(s)
else:
  print(s[0:K]+"...")

Measured memory_bytes: 27180