akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    int a;
    private void solve() {
        a = nextInt();

        out.println(a + a * a + a * a * a);
    }

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

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

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

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

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

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

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

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

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

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

    public int[] nextIntArray(int n) {
        int[] x = new int[n];
        for(int i = 0;i < n;i++) {
            x[i] = nextInt();
        }
        return x;
    }

    public long[] nextLongArray(int n) {
        long[] x = new long[n];
        for(int i = 0;i < n;i++) {
            x[i] = nextLong();
        }
        return x;
    }

    public double[] nextDoubleArray(int n) {
        double[] x = new double[n];
        for(int i = 0;i < n;i++) {
            x[i] = nextDouble();
        }
        return x;
    }
}

Measured memory_bytes: 32492
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct modint{
    ll a;
    const ll MOD=1e9+7;
    modint(ll a_=0){
        a=a_%MOD;
        if(a<0) a+=MOD;
    }
    modint inv()const{
        ll n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y(n);
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    bool operator!=(const modint& x){
        return a!=x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y(a+x.a);
        return y;
    }
    modint operator-(const modint& x){
        modint y(a-x.a);
        return y;
    }
    modint operator*(const modint& x){
        modint y(a*x.a);
        return y;
    }
    modint operator/(const modint& x){
        return *this * x.inv();
    }
    modint& operator+=(const modint& x){
        *this=*this+x;
        return *this;
    }
    modint& operator-=(const modint& x){
        *this=*this-x;
        return *this;
    }
    modint& operator*=(const modint& x){
        *this=*this*x;
        return *this;
    }
    modint& operator/=(const modint& x){
        *this=*this/x;
        return *this;
    }
};
istream& operator>>(istream &in,modint& x){
    ll a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}
modint pwr(ll a,ll b){
    modint n(1),A(a);
    while(b){
        if(b&1) n*=A;
        A*=A;
        b>>=1;
    }
    return n;
}

class FSmallProducts {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n,k,m;
        in>>n>>k;
        m=(int)sqrt(n);
        vector<modint> c(2*m),s(2*m+1),ns(2*m+1);
        fr(i,m) c[i]=1,c[i+m]=n/(m-i)-n/(m-i+1);
        if(n/m==m) c[m]-=1;
        s[0]=1;
        fr(_,k){
            ifr(i,2*m) ns[i]=ns[i+1]+(s[0]-s[2*m-i])*c[i];
            s.swap(ns);
        }
        out<<s[0]<<endl;
    }
};

int main() {
    FSmallProducts solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3200
# include<iostream>
# define N 100000

int S[N];
int T[N];
int n,q;

int binary(int num){
    int right=n, left=0;
    while(left < right){
        int mid = (left + right) / 2;
        if(S[mid] == num) return 1;
        else if(S[mid] < num) left = mid+1;
        else right = mid;
    }
    return 0;
}
int main(){
    scanf("%d",&n);
    for(int i=0; i<n; i++) scanf("%d",&S[i]);

    scanf("%d",&q);
    for(int i=0; i<q; i++) scanf("%d",&T[i]);

    int cnt = 0;
    for(int i=0; i<q; i++) cnt += binary(T[i]);
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 3716
(let ((a (read)) (b (read)) (k (read)))
  (if (< a k)
	(progn
	  (princ 0)
	  (princ #\space)
	  (princ (max 0 (- b (- k a)))))
	(progn
	  (princ (- a k))
	  (princ #\space)
	  (princ b))))


Measured memory_bytes: 11236
#define DINGER_GISBAR
#include <bits/stdc++.h>
using namespace std;
const long long MOD = static_cast<int>(1e9) + 7;
//{{{TEMPLATE_BEGIN
#include <unistd.h>
using namespace std::rel_ops;
#ifdef ZEROKUGI
#include <dumper.hpp>
#define dump(x) dumper::dumper(cerr, __LINE__, (#x), (x), 50, 1, 1)
#define tick(...) dumper::tick(__VA_ARGS__)
#pragma message "Compiling " __FILE__
#else
#define dump(x)
#define tick(...)
#endif
typedef long long lint;
typedef unsigned long long ulint;
typedef long double ldouble;
typedef vector<int> vint;
#define rep(i, n) \
    for (int i = 0, i##_len = static_cast<int>(n); i < i##_len; i++)
#define all(c) begin(c), end(c)
#define perm(c)   \
    sort(all(c)); \
    for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))
#define uniquenize(v) (v).erase(unique(all(v)), end(v))
#define cauto const auto &
#define memset(x, y) memset(x, y, sizeof(x))
#define popcount __builtin_popcount
#define gcd __gcd
inline lint bit(int x) { return 1LL << x; }
template <class T>
inline int size(const T& a) {
    return (int)a.size();
}
template <class T>
inline bool chmin(T& a, const T& b) {
    return a > b ? a = b, 1 : 0;
}
template <class T>
inline int clamp(T v, T lo, T hi) {
    return (v > hi) - (v < lo);
}
template <class T>
inline bool chmax(T& a, const T& b) {
    return a < b ? a = b, 1 : 0;
}
template <class T>
inline pair<vector<T>, char> operator*(const vector<T>& v, const char& c) {
    return make_pair(v, c);
}
template <class T>
inline istream& operator>>(istream& is, vector<T>& v) {
#ifdef ZEROKUGI
    if (v.empty()) {
        cerr << "Error L" << __LINE__ << ": vector size is zero." << endl;
        exit(EXIT_FAILURE);
    }
#endif
    for (auto& x : v) is >> x;
    return is;
}
template <class T>
inline ostream& operator<<(ostream& os, const pair<vector<T>, char>& v) {
    bool t = 0;
    for (const T& x : v.first) {
        if (t) os << v.second;
        os << x;
        t = 1;
    }
    return os;
}
template <class T>
inline ostream& operator<<(ostream& os, vector<T>& v) {
    return os << v * ' ';
}
struct before_main {
    before_main() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
        tick(0, 0);
    };
} __before_main;
//}}}TEMPLATE_END

int main() {
    string s;
    cin >> s;
    int k;
    cin >> k;
    int n = s.size();

    for (int i = 0; i < n; i++) {
        if(s[i] == 'a') continue;
        int d = min('z' - s[i] + 1, k);

        if (d == 'z' - s[i] + 1) {
            k -= d;
            s[i] = 'a';
        }
    }

    s[n-1] -= 'a';
    s[n-1] += (k%26);
    s[n-1] %= 26;
    s[n-1] += 'a';
    cout << s << endl;
}


Measured memory_bytes: 592
#include <iostream>

using namespace std;

int exp_2(int x)
{
    int rez = 0;
    if (x % 2 == 0)
    {
        while (x % 2 == 0) x /= 2, rez++;
    }
    return rez;
}

int main()
{
    int n, s = 0, x;
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> x;
        s += exp_2(x);
    }
    cout << s;
    return 0;
}


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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
typedef long long ll;

int N;
ll X;
ll mn [2000];

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N >> X;
	vector<ll> A(N);
	FOR(i,0,N){
		cin >> A [i];
	}
	fill(mn,mn + N,LLONG_MAX);

	ll ans = LLONG_MAX;
	FOR(magic,0,N){
		ll sum = magic * X;
		FOR(i,0,N){
			mn [i] = min(mn [i],A [(i - magic + N) % N]);
			sum += mn [i];
		}
		ans = min(sum,ans);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <complex>
#include <cmath>
using namespace std;
typedef complex<int> P;

const double PI = acos(-1);


void rotate(vector<P> &p){
	for(int i = 0 ; i < p.size() ; i++){
		p[i] = P(-p[i].imag(),p[i].real());
	}
}

int chk(vector<P> a,vector<P> b){
	if( a == b ) return true;
	reverse(b.begin(),b.end());
	if( a == b ) return true;
	return false;
}

int issame(vector<P> a,vector<P> b){
	for(int i = 0 ; i < 4 ; i++){
		if( chk(a,b) ) return true;
		rotate(b);
	}
	
	for(int i = 0 ; i < b.size() ; i++){
		b[i] -= b.back();
	}
	
	for(int i = 0 ; i < 4 ; i++){
		if( chk(a,b) ) return true;
		rotate(b);
	}
	return false;
}

int main(){
	int n;
	while(cin >> n && n){
		vector< vector<P> > l(n+1);
		for(int i = 0 ; i <= n ; i++){
			int m;
			cin >> m;
			for(int j = 0 ; j < m ; j++){
				int x,y;
				cin >> x >> y;
				l[i].push_back(P(x,y));
			}
			for(int j = m-1 ; j >= 0 ; j--){
				l[i][j] -= l[i][0];
			}
		}
		for(int i = 1 ; i <= n ; i++){
			if( issame(l[0],l[i]) ) cout << i << endl;
		}
		
		
		cout << "+++++" << endl;
	}
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int i,j,k;
	int w,h,n;
	int x[100] = {0}, y[100] = {0}, a[100] = {0};
	int s,sd,hs,hl,ws,wl;

	scanf("%d %d %d", &w, &h, &n);

	hs = 0;
	hl = h;
	ws = 0;
	wl = w;

	s = w * h;

	for(i = 0; i < n; i++)
	{
		scanf("%d %d %d", &x[i], &y[i], &a[i]);
	}

	for(i = 0; i < n; i++)
	{
		sd = 0;

		if (a[i] == 1 && x[i] >= ws)
		{
			sd = (hl - hs) * (x[i] - ws);
			ws = x[i];

		}else if (a[i] == 2 && x[i] <= wl)
		{
			sd = (hl - hs) * (wl - x[i]);
			wl = x[i];

		}else if (a[i] == 3 && y[i] >= hs)
		{
			sd = (wl - ws) * (y[i] - hs);
			hs = y[i];

		}else if (a[i] == 4 && y[i] <= hl)
		{
			sd = (wl - ws) * (hl - y[i]);
			hl = y[i];
		}

		s -= sd;

		if (s <= 0)
		{
			printf("0\n");
			return 0;
		}
	}

	printf("%d\n", s);



	return 0;
}

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

#define check cout<<"-------"<<endl
#define debug(x) cout<<x<<endl

#define N 101
#define MAX 2001

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a[N][N];
    int list[MAX];
    
    int n;
    cin>>n;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            cin>>a[i][j];
        }
    }
    
    int sum = 0, min, mini, i, j;
    int lp = n-1;
    list[0] = 1;
    for(i = 1; i <= n; i++) a[i][1] = -1;
    while(lp--) {
        min = 2001;
        for(i = 0; list[i] !=0; i++) {
            for(j = 1; j <= n; j++) {
                if(min > a[ list[i] ][j] && a[ list[i] ][j] != -1) {
                    min = a[ list[i] ][j];
                    mini = j;
                }
            }
        }
        sum += min;
        list[i] = mini;
        for(int j = 1; j <= n; j++) a[j][mini] = -1;
    }
    
    cout<<sum<<endl;
    
    return 0;
}



Measured memory_bytes: 3224
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
 
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	pii maxv = make_pair(1,0);
	reps(i,n){
		int x = __builtin_ctz(i);
		if(maxv.second < x){
			maxv.second = x;
			maxv.first = i;
		}
	}
	cout << maxv.first << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6;
const ll LINF = 1e18;
using namespace std;

#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (int i = (a); i < (b); i++)
#define rrrep(i, a, b) for (int i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl

ll n, cnt, ans, a[ohara], b, c, d, tmp, tmpp, m, h, w, x, y, sum, pos, k;
ld doua;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
bool fl;
struct edge
{
    int to, cost;
};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin >> n;
    rep(i, n) cin >> a[i];
    while (1)
    {
        ll ma = 0, flags;
        rep(j, n)
        {
            if (ma <= a[j])
            {
                ma = a[j];
                flags = j;
            }
        }
        if (ma <= n - 1)
        {
            break;
        }
        ll herkai;
        tmp = (ma - (n - 1)) / n;
        if ((ma - (n - 1)) % n != 0)
            tmp++;
        herkai = tmp;
        ans += herkai;
        ma -= herkai * n;
        a[flags] = ma;
        rep(j, n)
        {
            if (j == flags)
                continue;
            a[j] += herkai;
        }
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input_int_tuple() -> (i32, i32) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<i32> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn input_i32_vec() -> Vec<i32> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let (n, x) = input_int_tuple();
    let l_vec = input_i32_vec();
    let mut d = 0;
    let mut count = 1;
    for l in l_vec {
        d += l;
        if d <= x {
            count += 1;
        } else {
            break;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

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

    if(b % a == 0) { return a; }

    if(a > b) { return GCD(a % b, b); }

    if(a < b) { return GCD(a, b % a); }
}

int main()
{
    int a, b;

    cin >> a >> b;

    cout << GCD(a, b) << endl;

    return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
         Scanner in = new Scanner(System.in);
         String S = in.next();
         String T = in.next();
         if(Math.abs(S.length() - T.length()) != 1) {
             System.out.println("No");
             return;
         }
         int length = Math.min(S.length(), T.length());
         for(int i = 0; i < length; i++) {
             if(S.charAt(i) != T.charAt(i)) {
                 System.out.println("No");
                 return;
             }
         }
         System.out.println("Yes");
    }
}


Measured memory_bytes: 35672
// Example program
#include <iostream>
#include <string>
using namespace std;
int main()
{

    string a,b,c;cin>>a>>b>>c;
    if(a[a.size()-1]==b[0] and b[b.size()-1]==c[0])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define INF 10000000000000000LL
#define ll  long long 
const int inf =INT_MAX;
const int MAX=3e5+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=1e6+9;
const int MAX_A=71;
const int LN=20;
using namespace std;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    if(s[0] != 'A'){
        cout << "WA" << "\n";
        return 0;
    }
    
    int seenC = 0;
    for(int i = 2; i < n-1; i++)
        if(s.at(i) == 'C')
            seenC++;
    
    if(seenC != 1){
        cout << "WA" << "\n";
        return 0;
    }

    int c = 0;
    for(int i = 0; i < n; i++){
        if(s[i] != 'A' && s[i] != 'C' && !islower(s[i])){
            cout << "WA" << "\n";
            return 0;
        }
    }

    cout << "AC" << "\n";
    return 0;
}

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

using namespace std;

const int INF = 1e9;
int V, E;
int n;
int e[20];
int d[20][20];
int memo[(1 << 15) + 10];
vector<int> v;

int rec(int S) {
  if (memo[S]) return memo[S];
  if (!S) return 0;
  int res = INF;
  for (int i = 0; i < n - 1; i++) {
    if (!(S >> i & 1)) continue;
    for (int j = i + 1; j < n; j++) {
      if (!(S >> j & 1)) continue;
      int S2 = S & ~(1 << i);
      S2 = S2 & ~(1 << j);
      res = min(res, rec(S2) + d[v[i]][v[j]]);
    }
  }
  return memo[S] = res;
}

int main(void) {
  cin >> V >> E;

  int sum = 0;
  fill(d[0], d[20], INF);
  for (int i = 0; i < V; i++) {
    d[i][i] = 0;
  }
  for (int i = 0; i < E; i++) {
    int s, t, c;
    cin >> s >> t >> c;
    d[s][t] = d[t][s] = min(d[s][t], c);
    e[s]++, e[t]++;
    sum += c;
  }

  for (int k = 0; k < V; k++) {
    for (int i = 0; i < V; i++) {
      for (int j = 0; j < V; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  for (int i = 0; i < V; i++) {
    if (!(e[i] & 1)) continue;
    v.push_back(i);
    n++;
  }
  cout << sum + rec((1 << n) - 1) << endl;

  return 0;
}


Measured memory_bytes: 3176
#include <iostream>
using namespace std;
int main(){
    double x1, y1, x2, y2, x3, y3, xp, yp;
    while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp){

        /*double max_x = x1;
        if(x2 > max_x) max_x = x2;
        if(x3 > max_x) max_x = x3;

        double max_y = y1;
        if(y2 > max_y) max_y = y2;
        if(y3 > max_y) max_y = y3;

        double min_x = x1;
        if(x2 < min_x) min_x = x2;
        if(x3 < min_x) min_x = x3;

        double min_y = y1;
        if(y2 < min_y) min_y = y2;
        if(y3 < min_y) min_y = y3;

        if(xp >= min_x && xp <= max_x && yp >= min_y && yp <= max_y)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;*/
        double a1, b1, a2, b2, A, B;
        a1 = x2 - x1;
        a2 = y2 - y1;
        b1 = x3 - x1;
        b2 = y3 - y1;
        xp = xp - x1;
        yp = yp - y1;
        A = (b1 * yp - b2 * xp) / (a2 * b1 - a1 * b2);
        B = (a2 * xp - a1 * yp) / (a2 * b1 - a1 * b2);
        if(A + B < 1 && A > 0 && B > 0) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}



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

int main()
{
	long long K; cin >> K;

	long long x = K / 50;
	long long y = K % 50;

	long long first = x;

	vector<long long>a;
	if (x != 0) {
		a.resize(50);
		for (int i = 0; i < 50; i++) {
			a[i] = first + i + (i > 50 - y - 1);
		}
	}
	else {
		if (y >= 2) {
			a.resize(y);
			for (int i = 0; i < y; i++) {
				a[i] = first + i + 1;
			}
		}
		else if (y ==1) {
			a.push_back(0);
			a.push_back(2);
		}
		else if (y == 0) {
			a.push_back(0);
			a.push_back(0);
		}
	}

	int size = a.size();
	cout << size << endl;
	for (int i = 0; i < size; i++) {
		if (i)cout << " ";
		cout << a[i];
	}
	cout << endl;

    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
//const long long MOD = 1000000007LL;
const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
	return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
	return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
	return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
	return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
	a += rhs.a;
	if (a >= Modulus) {
	  a -= Modulus;
	}
	return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
	if (a < rhs.a) {
	  a += Modulus;
	}
	a -= rhs.a;
	return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
	a = a * rhs.a % Modulus;
	return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
	u64 exp = Modulus - 2;
	while (exp) {
	  if (exp % 2) {
		*this *= rhs;
	  }
	  rhs *= rhs;
	  exp /= 2;
	}
	return *this;
  }
};

using mint = modint<MOD>;


int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	int N; cin >> N;
	vector<int> A(N);
	rep(i,N) cin >> A[i];

	const int MAX = 1000000;
	vector<mint> dp(1010101);
	vector<vector<int>> table(1010101);
	for (int i = 1; i <= MAX; ++i) {
		for (int j = 1; j*i <= MAX; ++j) {
			table[j*i].emplace_back(i);
		}
	}
	
	rep(i,N) {
		for (auto j : table[A[i]]) {
			dp[j] += A[i];
		}
	}
	for (int i = MAX; i >= 1; i--) dp[i] *= dp[i];
	mint ans = 0;
	for (int i = MAX; i >= 1; i--) {
		//if (dp[i].a != 0) cout << dp[i].a << " " << <<ln;
		ans += (dp[i]/i);
		for (auto j : table[i]) {
			dp[j] -= dp[i];
		}
	}
	rep(i,N) ans -= A[i];

	cout << (ans/2).a << ln;
}


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

int main(){
    string s, t;
    cin >> s >> t;
    int n = s.size();

    vector<int> S(n,-1);
    int a = 0;
    rep(i,n){
        if(S[i] != -1) continue;
        S[i] = a;
        char si = s[i];
        for(int j = i+1; j < n; j++){
            if(s[j] == si) S[j] = a;
        }
        a++;
    }
    vector<int> T(n,-1);
    int b = 0;
    rep(i,n){
        if(T[i] != -1) continue;
        T[i] = b;
        char ti = t[i];
        for(int j = i+1; j < n; j++){
            if(t[j] == ti) T[j] = b;
        }
        b++;
    }
    if(S != T) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 2312
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    for( int i=0; i<n; i++){
        cin >> p[i];
    }
    for( int i=0; i<n; i++){
        cin >> q[i];
    }

    if( p > q ) swap(p,q);
    int ans=0;
    while(p<q){
        next_permutation(p.begin(),p.end());
        ans++;
    }
    cout << ans << endl;
}




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


vector<int> sieve_of_eratosthenes(int n) {
  vector<int> primes(n);
  for (int i = 2; i < n; ++i)
    primes[i] = i;
  for (int i = 2; i*i < n; ++i)
    if (primes[i])
      for (int j = i*i; j < n; j+=i)
        primes[j] = 0;
  return primes;
}

		int dp[15][200][1121];

int main()
{
	vector<int> a=sieve_of_eratosthenes(1121);
	vector<int> prime;
	for(int i=0;i<a.size();i++)
		if(a[i]!=0) prime.push_back(a[i]);

	int n,k;
	while(cin>>n>>k && n!=0){
		memset(dp,0,sizeof(dp));

		dp[0][0][0]=1;

		for(int i=0;i<k;i++){
			for(int j=0;j<prime.size();j++){
				for(int num=0;num<=n;num++){
					if(dp[i][j][num]==0) continue;
					for(int next=j;next<prime.size();next++){
						if(num+prime[next]>n) break;
						dp[i+1][next+1][num+prime[next]]+=dp[i][j][num];
					}
				}
			}

		}
		int ans=0;
		for(int i=0;i<=prime.size();i++){
			ans+=dp[k][i][n];
		}
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 13000
/*
h s, d't skp th si tll i's sved
 * ABC141 E
*/
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
ll n;
cin>>n;
ll ans=n-1;
for(ll i=2;i<=sqrt(n);i++)
{
if(n%i==0)
{
ans=min(ans,i-1+n/i-1);
}
}
cout<<ans;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
   int n, m, a, b;
   cin >> n >> m;
   
   vector<int> x(n, 0);
   
   for(int i = 0; i < m*2; ++i){
       cin >> a;
       ++x.at(a-1);
   }
   
   for(int i = 0; i < n; ++i){
       cout << x.at(i) << endl;
   }
}


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

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

int main() {
    int T;
    scanf("%d", &T);
    if(T>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3692
#include <iostream>

using namespace std;

int main(void){
    int A;
    int Five = 0, Seven = 0;
    for(int i = 0; i < 3; i++){
        cin >> A;
        if(A == 5) Five++;
        if(A == 7) Seven++;
    }
    if(Five == 2 && Seven == 1){
        cout << "YES";
    }else{
        cout << "NO";
    }
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


int main() {
    int A, B;
    cin >> A >> B;

    int ans = 0;
    int sum = 1;
    while(B > sum){
        sum -= 1;
        sum += A;
        ans++;
    }    

    cout << ans <<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int sum1=0,ans=0;
		
		for(int i=1; i<=n; i++) {
		
				sum1=i/10000+(i%10000)/1000+(i%1000)/100+(i%100)/10+i%10;
			
			if(sum1>=a && sum1<=b) {
				ans=ans+i;
			}
		}
		System.out.println(ans);

	}

}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const int mx = 710000;


ll gcd(ll x, ll y){
	if(x%y == 0)return y;
	else return gcd(y, x%y);
}

ll a,b;
int main(){
	cin >> a >> b;
	ll g = gcd(a,b);
	// ll ans = 1;
	set<ll> ans = {1};
	for(int i = 2; i <= sqrt(g) + 1; i++){
		if(g%i == 0)ans.insert(i);
		// if(g%i == 0)ans++;
		while(g%i == 0){
			g /= i;
		}
	}
	if(g > 1)ans.insert(g);
	// cout << g << endl;
	// set<ll> ans = {1};
	// for(int i = 2; i< max_divisor + 1; i++){
	// 	while(max_divisor % i == 0){
	// 		ans.insert(i);
	// 		cout << i << endl;
	// 		max_divisor /= i;
	// 	}
	// 	cout <<  max_divisor << endl;
	// }
	cout << ans.size() << endl;
}

Measured memory_bytes: 256
def main():
    H, W = map(int, input().split())
    M = []
    for _ in range(H):
        M.append(input())
    ans = [[''] * W for _ in range(H)]
    for i in range(H):
        for j in range(W):
            if M[i][j] == '#':
                ans[i][j] = '#'
                continue
            c = 0
            for ii, jj in [
                (i + 1, j), (i, j + 1), (i - 1, j), (i, j - 1),
                (i + 1, j - 1), (i - 1, j + 1), (i - 1, j - 1), (i + 1, j + 1)
            ]:
                if 0 <= ii < H and 0 <= jj < W:
                    if M[ii][jj] == '#':
                        c += 1
            ans[i][j] = str(c)
    for a in ans:
        print(''.join(a))


main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int N = S.size();
  int a, z;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'A') {
      a = i;
      break;
    }
  }
  for (int j = 0; j < N; j++) {
    if (S.at(j) == 'Z') {
      z = j;
    }
  }
  cout << z - a + 1 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
typedef long long ll;
using namespace std;
const ll MOD = (ll)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long

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

	string s;
	cin >> s;

	cout << s[0] << (int)s.size() - 2 << s[(int)s.size() - 1] << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long i64;
const int P=1e9+7,N=3007;
char s0[N];
int n,m,rs[N],p=0,f[N],ans=1;
inline int fix(int x){return x-=P,x+(x>>31&P);}
int main(){
	scanf("%d%d%s",&n,&m,s0+1);
	for(int i=1;i<=n;++i)rs[i]=i;
	for(int i=1,x,y;i<=m;++i){
		scanf("%d%d",&x,&y);
		if(y>rs[x])rs[x]=y;
	}
	f[0]=1;
	for(int i=1,mr=0;i<=n;++i){
		if(rs[i]>mr){
			int c1=0;
			for(int j=mr+1;j<=rs[i];++j)c1+=s0[j]-'0';
			if(c1)for(int j=mr-i+1;j>=0;--j)f[j+c1]=f[j],f[j]=0;
			mr=rs[i];
		}
		for(int j=0;j<=mr-i;++j)f[j]=fix(f[j]+f[j+1]);
		f[mr-i+1]=0;
	}
	printf("%d\n",f[0]);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n,v;
  cin>>n>>v;
  vector<Int> a(n),b(n),c(n),d(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  for(Int i=0;i<n;i++) cin>>b[i];
  for(Int i=0;i<n;i++) cin>>c[i];
  for(Int i=0;i<n;i++) cin>>d[i];
  map<Int, Int> m;
  for(Int i=0;i<n;i++)
    for(Int j=0;j<n;j++)
      m[a[i]+b[j]]++;
  Int ans=0;
  for(Int i=0;i<n;i++)
    for(Int j=0;j<n;j++)
      ans+=m[v-(c[i]+d[j])];
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 128088
#include<iostream>
using namespace std;
typedef long long ll;

const int MAX_N = 2 * 1e3 + 2;
const int MAX_M = 2 * 1e3 + 2;
const ll MOD = 1e9 + 7;

int S[MAX_N], T[MAX_M];
ll dp[MAX_N][MAX_M];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    for (int i = 1; i <= N; i++) cin >> S[i];
    for (int i = 1; i <= M; i++) cin >> T[i];
    dp[0][0] = 1;
    for (int i = 1; i <= N; i++) dp[i][0] = 1;
    for (int i = 1; i <= M; i++) dp[0][i] = 1;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= M; j++) {
            dp[i][j] = (dp[i][j] + (dp[i - 1][j] + dp[i][j - 1]) % MOD) % MOD;
            if (S[i] != T[j]) {
                dp[i][j] = (dp[i][j] - dp[i - 1][j - 1] + MOD) % MOD;
            }
        }
    }
    cout << dp[N][M] << endl;
    return 0;
}

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

int main(){
	int ans[3] = {1,0,0},p,q;
	char tmp[3];
	while(cin>>tmp[0]>>tmp[1]>>tmp[2]){
		p = (int)tmp[0] - 'A';
		q = (int)tmp[2] - 'A';
		swap(ans[p],ans[q]);
	}
	if(ans[0] == 1)
		cout<<'A'<<endl;
	else if(ans[1] == 1)
		cout<<'B'<<endl;
	else
		cout<<'C'<<endl;

	return 0;
}

Measured memory_bytes: 1132
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,sum,j;
  sum=0;
  j=0;
  cin >> n;
  vector<int> Ls(n);
  for (int i=0 ; i< n ;i++){
    cin >> Ls.at(i);
  }
  for (int i =0 ; i < n; i++){
    sum+=Ls.at(i);
  }
  for (int i=0; i <n ; i++){
    if(sum-Ls.at(i) <= Ls.at(i)){
      j++;
    }
  }
  if (j==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" <<endl;
  }
}


Measured memory_bytes: 3636
//ABC 073 A
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iomanip>
using namespace std;

int main() {
	string num;
	cin >> num;
	if (num[0] != '9' && num[1] != '9') {
		cout << "No";
	}
	else {
		cout << "Yes";
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string S;
	cin >> S;
	LL W;
	cin >> W;
	for (LL n = 0; n < S.size(); n += W) {
		cout << S.substr(n, 1);
	}
	cout << "\n";
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int N;
      string S;
      cin >> N;
      for (int i = 0; i < N; i++) {
        cin >> S;
        if (S == "Y"){
          cout << "Four" << endl;
          break;
        }
        if (i == N-1){
          cout << "Three" << endl;
        }
      }
      
    
    }

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define A first
#define B second
#define MOD 1000000007

typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;

int mulmd(ll a, ll b){
    ll ret = (a * b) % MOD;
    return (int)ret;
}

inline int power(ll x, ll y, int p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = mulmd(res, x);
        y = y >> 1;
        x = mulmd(x, x);
    }
    return (int)res;
}

int submd(ll a, ll b){
    ll ret = a - b;
    if(ret < 0){
        ret += MOD;
    }
    return (int)ret;
}

int addmd(ll a, ll b){
    ll ret = (a + b) % MOD;
    return (int)ret;
}

int invPow(ll a){
    return power(a, MOD - 2, MOD);
}

const int N = 1e5 + 5;

int arr[N];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    int cnt = 0;
    int n = s.size();
    for(int i = 0; i < n/2; i++){
        if(s[i] != s[n - i - 1]) cnt++;
    }
    cout << cnt;

}

/**
    Check out for boundary cases, (n = 1 or n = 0)
    check for integer overflow

**/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	cout<<a[n-1]-a[0]<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	a, b, c, d := sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()

	fmt.Fprintln(wtr, max(a*b, c*d))
	wtr.Flush()
}


Measured memory_bytes: 640
import sys
#from collections import defaultdict, deque, Counter
#from bisect import bisect_left
#import heapq
import math
#from itertools import groupby as gb
#from itertools import permutations as perm
#from itertools import combinations as comb
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
n,m = map(int, stdin.readline().rstrip().split())
#AB = [list(map(int, stdin.readline().rstrip().split())) for _ in range(n)]

dp = [0 for _ in range(n+1)]
dp[0] = 1

broke = [0 for _ in range(n+1)]
for i in range(m):
    broke[int(stdin.readline().rstrip())] = 1

for i in range(n):
    if broke[i+1] == 1:
        dp[i+1] = 0
    elif i == 0:
        dp[i+1] = dp[i]
    else:
        dp[i+1] = dp[i] + dp[i-1]

print(dp[n]%MOD)


Measured memory_bytes: 460824
package main
 
import (
	"fmt"
)
 
var N int64
var ANS int64
func main() {
	fmt.Scan(&N)
	for i := int64(1); i <= N; i++ {
		for j := int64(1); j <= N; j++ {
			g1 := gcd(i, j)
			for k := int64(1); k <= N; k++ {
				g2 := gcd(k, g1)
				ANS += g2
			}
		}
	}
	fmt.Println(ANS)
}

func gcd(a, b int64) int64 {
	if b > a {
		a, b = b, a
	}
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}


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

int main() {
  int x, y;
  bool ans = false;
  cin >> x >> y;

  for (int crane = 0; crane <= x; crane++) {
    int turtle = x - crane;
    int sum = crane * 2 + turtle * 4;
    if (sum == y) ans = true;
  }
  if (ans) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }  
}

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

int main()
{
	int n1,n2,n3,n4;
	
	int ara[11]={0};
	
	cin>>n1>>n2>>n3>>n4;
	ara[n1]++;
	ara[n2]++;
	ara[n3]++;
	ara[n4]++;
	
	if(ara[1] && ara[9] && ara[7] && ara[4])
	cout<<"YES\n";
	else
	cout<<"NO\n";
	
	return 0;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

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

int main() {
  int n, a, b;
  string s;
  cin >> n >> a >> b;
  cin >> s;
  int aa = 0;
  int bb = 0;
  rep(i, n) {
    bool ok = false;
    char c = s.at(i);
    if (c == 'a') {
      if (aa + bb < a + b) {
        ok = true;
        aa++;
      }
    } else if (c == 'b') {
      if (aa + bb < a + b && bb < b) {
        ok = true;
        bb++;
      }
    } else {
      // false のまま
    }
    cout << (ok ? "Yes" : "No") << endl;
  }
  return 0;
}


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

using namespace std;

int main(){
	int N, M;
	int Ltmp, Rtmp;
	int Lmax, Rmin;
	cin >> N >> M;
	
	Lmax = 1;
	Rmin = N;

	for (int i = 0; i < M; i++) {
		cin >> Ltmp >> Rtmp;
		if (Lmax < Ltmp) {
			Lmax = Ltmp;
		}
		if (Rmin > Rtmp) {
			Rmin = Rtmp;
		}
	}
	
	if (Lmax > Rmin) {
		cout << 0 << endl;
	}else{
		cout << Rmin - Lmax + 1 << endl;
	}
	
}



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

using namespace std;

int main(void)
{
	int N;
	cin >> N;
	int h[N];
	for (int i = 0; i < N; i++) {
		cin >> h[i];
	}
	int d[N];
	d[0] = 0;
	for (int i = 1; i < N; i++) {
		int cost1 = INT_MAX, cost2 = INT_MAX;
		if (i >= 2) {
			cost2 = d[i-2] + abs(h[i]-h[i-2]);
		}
		if (i >= 1) {
			cost1 = d[i-1] + abs(h[i]-h[i-1]);
		}
		d[i] = min(cost1, cost2);
	}
	cout << d[N-1] << endl;
	return 0;
}


Measured memory_bytes: 1024
n, t = [int(x) for x in input().split(' ')]
time = [int(x) for x in input().split(' ')]
diff = [time[j+1]-time[j] for j in range(n-1) if time[j+1] - time[j] > t]
dec = sum(diff) - len(diff) * t
print(time.pop() + t - dec)


Measured memory_bytes: 25200
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

template<int MOD> struct modint {
    long long val;
    constexpr modint(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr modint operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr modint operator + (const modint& r) const noexcept { return modint(*this) += r; }
    constexpr modint operator - (const modint& r) const noexcept { return modint(*this) -= r; }
    constexpr modint operator * (const modint& r) const noexcept { return modint(*this) *= r; }
    constexpr modint operator / (const modint& r) const noexcept { return modint(*this) /= r; }
    constexpr modint& operator += (const modint& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr modint& operator -= (const modint& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr modint& operator *= (const modint& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr modint& operator /= (const modint& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const modint& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const modint& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const modint<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr modint<MOD> modpow(const modint<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = modint<MOD>;

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

    mint mn = n;
    mint mk = k;

    mint ans = 0;
    for (int i = k; i <= n + 1; i++) {
        mint mi = i;
        ans += mn * (mn + 1) / 2 - (mn - mi) * (mn - mi + 1) / 2;
        ans -= mi * (mi - 1) / 2;
        ans += 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624