akhauriyash/Code-Regression huggingface dataset:
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

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

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

const mod = 1000000007

func mpow(a, b int) int {
	if b == 0 {
		return 1
	} else if b%2 == 0 {
		tmp := mpow(a, b/2)
		return tmp * tmp % mod
	}
	return mpow(a, b-1) * a % mod
}

var fracMemo = []int{1, 1}

func mfrac(n int) int {
	if len(fracMemo) > n {
		return fracMemo[n]
	}
	if len(fracMemo) == 0 {
		fracMemo = append(fracMemo, 1)
	}
	for len(fracMemo) <= n {
		size := len(fracMemo)
		fracMemo = append(fracMemo, fracMemo[size-1]*size%mod)
	}
	return fracMemo[n]
}

var ifracMemo = []int{1, 1}

func mifrac(n int) int {
	if len(ifracMemo) > n {
		return ifracMemo[n]
	}
	if len(ifracMemo) == 0 {
		fracMemo = append(ifracMemo, 1)
	}
	for len(ifracMemo) <= n {
		size := len(ifracMemo)
		ifracMemo = append(ifracMemo, ifracMemo[size-1]*mpow(size, mod-2)%mod)
	}
	return ifracMemo[n]
}

func nCr(n, r int) int {
	if n == r {
		return 1
	}
	if n < r || r < 0 {
		return 0
	}
	ret := 1
	ret *= mfrac(n)
	ret %= mod
	ret *= mifrac(r)
	ret %= mod
	ret *= mifrac(n - r)
	ret %= mod
	return (ret)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	n := getInt()
	p := make([][]int, n)
	d := 0
	for i := 0; i <= n; i++ {
		a := getInt() - 1
		p[a] = append(p[a], i)
		if len(p[a]) == 2 {
			d = a
		}
	}

	l := p[d][0]
	r := n - p[d][1]
	// out(d, p[d])
	// out(l, r)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	fmt.Fprintln(w, n)
	for i := 2; i <= n+1; i++ {
		ans := nCr(n+1, i)
		ans -= nCr(l+r, i-1)
		if ans < 0 {
			ans += mod
		}
		fmt.Fprintln(w, ans)
	}

}


Measured memory_bytes: 9856
#include <bits/stdc++.h>
#define ll long long

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

	string s;
	cin>>s;
	ll cnt=0;
	ll sol=0;
	char tek,pret;
	for(int i=0;i<s.size();i++)
    {
        tek=s[i];
        if(tek=='A') cnt++;
        if(tek=='A' && pret=='B') cnt=1;
        if(tek=='B' && pret=='B') cnt=0;
        if(tek=='C' && pret=='B') sol+=cnt;
        if(tek=='C' && pret!='B') cnt=0;
        pret=tek;
    }
    cout<<sol;

	return 0;
}


Measured memory_bytes: 764
#[allow(dead_code)]
fn read_line(n: usize) -> String {
    let mut ss = String::new();
    for _i in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        ss.push_str(&s);
    }
    ss
}

macro_rules! parse {
    ($s:expr => $($r:tt)*) => {
        let s = $s;
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        parse!{s => $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main()
{
    parse!{
        n: usize,
        a_s: [i32; n],
    }
    let mut ans = 0;
    let mut i = 1i32;
    for a in a_s {
        if a == i {
            i += 1;
        }
        else {
            ans += 1;
        }
    }

    if n == ans {
        println!("-1");
        return;
    }

    println!("{}", ans);
}

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

int dp[2010][2010][2]={0};
bool S[2010],T[2010];
int main(){
	int M,N,ma,cnt;
	char ch;
	cin>>M>>N;
	for(int i=0;i<M;i++){
		cin>>ch;
		if(ch=='I')S[i]=true;
		else S[i]=false;
	}
	for(int i=0;i<N;i++){
		cin>>ch;
		if(ch=='I')T[i]=true;
		else T[i]=false;
	}
	
	for(int i=M;i>=0;i--){
		for(int j=N;j>=0;j--){
			//O
			ma=0;
			if(i<M&&S[M-i-1]==true){
				ma=max(ma,dp[i+1][j][1]+1);
			}
			if(j<N&&T[N-j-1]==true){
				ma=max(ma,dp[i][j+1][1]+1);
			}
			dp[i][j][0]=ma;
			//I
			ma=0;
			if(i<M&&S[M-i-1]==false&&dp[i+1][j][0]>0){
				ma=max(ma,dp[i+1][j][0]+1);
			}
			if(j<N&&T[N-j-1]==false&&dp[i][j+1][0]>0){
				ma=max(ma,dp[i][j+1][0]+1);
			}
			dp[i][j][1]=ma;
		}
	}
	cnt=0;
	for(int i=0;i<=M;i++){
		for(int j=0;j<=N;j++){
			//cout<<dp[i][j][0]<<" ";
			cnt=max(cnt,dp[i][j][0]);
		}
		//cout<<endl;
	}
	//cout<<endl;
	/*
	for(int i=0;i<=M;i++){
		for(int j=0;j<=N;j++){
			cout<<dp[i][j][1]<<" ";
		}
		cout<<endl;
	}
	*/
	cout<<cnt<<endl;
	return 0;
}

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

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

  ll N;
  cin >> N;
  vector<pair<ll,ll>> A(N);
  rep(i, N) {
    cin >> A[i].first;
    A[i].second = i;
  }
  sort(all(A));
  reverse(all(A));
  
  vector<vector<ll>> dp(N+1, vector<ll>(N+1));
  
  rep(i, N) rep(j, i+1) {
    
    if (j==0) {
      dp[i+1][j] = dp[i][j] + A[i].first * abs(A[i].second - (N-1-(i-j)));
    }else {
      dp[i+1][j] = max(dp[i][j-1] + A[i].first * (A[i].second - (j-1)),
                       dp[i][j] + A[i].first * (N-1-i+j - A[i].second)
                      );
    }
    
    if (j==i) {
      dp[i+1][j+1] = dp[i][j] + A[i].first * abs(A[i].second - j);
    }else {
      dp[i+1][j+1] = max(dp[i][j] + A[i].first * (A[i].second - j),
                         dp[i][j+1] + A[i].first * (N-1-i+j+1 - A[i].second)
                         );
    }
  }
  
  ll ans = dp[N][0];
  rep2(i, N) ans = max(ans, dp[N][i]);
  
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 34624
#include <iostream>
#include <functional>
#include <string>
using namespace std;


void MyFunc(int a, int b)
{
  string A, B;
  for (int i = 0; i < b; i++)
    A += to_string(a);
  for (int i = 0; i < a; i++)
    B += to_string(b);

  if (A >= B)
    cout << B << endl;
  else
    cout << A << endl;
}


int main(void)
{
  int a, b;
  cin >> a >> b;

  function<void(int, int)> func = MyFunc;
  func(a, b);

  return 0;
}



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

int main()
{
  string s, t;
  cin >> s >> t;
  i64 ans = 0;
  for (i64 i = 0; i < s.size(); i++)
    if (s[i] == t[i])
      ans++;
  cout << ans << endl;
  return 0;
}


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

int main(void){
    int A,B,max;
    cin>>A>>B;
    int add=A+B;
    int sub=A-B;
    int mul=A*B;

    if(add>=sub)
        max=add;
    else
        max=sub;

    if(max<mul)
        max=mul;

    cout<<max<<endl;
    return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int64 k;
    cin >> k;
    int32 n = 50;
    cout << n << "\n";
    vector<int64> a(n,(k/n)+n-1);
    REP(i,k%n){
        sort(ALL(a));
        a[0] += n;
        FOR(i,1,n){
            a[i]--;
        }
    }
    REP(i,n){
        cout << a[i] << " ";
    }
    cout << "\n";
    // int64 cnt = 0;
    // while(true){
    //     bool flg = true;
    //     REP(i,n){
    //         if(a[i] >= n){
    //             flg = false;
    //             break;
    //         }
    //     }
    //     if(flg)break;
    //     cnt++;
    //     sort(ALL(a));
    //     REP(i,n-1)a[i]++;
    //     a[n-1] -= n;
    // }
    // ANS(cnt);
    return 0;
}

Measured memory_bytes: 384
n,k=map(int,input().split())
A=list(map(int,input().split()))
from collections import Counter
C=Counter(A)
ans=0
l=len(C)
ans=0
if l<=k:
    print(ans)
else:
    B=[]
    for i in C.keys():
        B.append([i,C[i]])
    B=sorted(B,key=lambda x:x[1])
    for i in range(l-k):
        ans+=B[i][1]
    print(ans)

Measured memory_bytes: 47284
#include<cstdio>
#include<cstring>
#include<map>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
map<ll,ll> ma;
ll a[50]={1,2,4,5,8,10,13,14,18,21,26,28,33,36,40,41,46,50,57,60,68};
ll solve(ll xx){
    if(xx<=20) return a[xx];
    if(ma[xx]) return ma[xx];
    if(xx%2) return ma[xx]=(2*solve(xx/2)%mod+solve(xx/2-1)%mod)%mod;
    else return ma[xx]=(2*solve(xx/2-1)%mod+solve(xx/2)%mod)%mod;
}
int main(){
    ll n;
    scanf("%lld",&n);
    ll ans=solve(n);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int n;
	scanf("%d",&n);
	int i = 1;
	int sum = 0;
	while (i <= n)
	{
		if ((i>0 && i < 10)||(i>99 && i < 1000)||(i>9999 && i < 100000))
			sum++;
		i++;
	}
	printf("%d\n",sum);
	return(0);
}


Measured memory_bytes: 128
// ------------------------------------
// Date:2018/ 2/12
// Problem:0003 : IsItRightTriangle 3.cpp
//
// ------------------------------------

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <random>

using namespace std;

#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define REP(i,n) FOR(i,0,n)

int main()
{
  int N;
  vector<int> d(3,0);
  cin >> N;
  while(N--) {
    scanf("%d %d %d",&d[0], &d[1], &d[2]); 
    sort(d.begin(),d.end(), std::greater<int>());
    if (d.at(0)*d.at(0)==d.at(1)*d.at(1)+d.at(2)*d.at(2)) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;

int power(int x,int n,int mod){
    //(x^n)%mod
    int result=1;
    while(n){
        if(n%2)
            result=(result*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return result;
}



int32_t main() {

    fast
    int x;
    cin >> x;

    if(x <= 599) {
        cout << 8 << endl;
    } else if(x <= 799) {
        cout << 7 << endl;
    }    else if(x <= 999) {
        cout << 6 << endl;
    } else if(x <= 1199) {
        cout << 5 << endl;
    } else if(x <= 1399) {
        cout << 4 << endl;
    }    else if(x <= 1599) {
        cout << 3 << endl;
    } else if(x <= 1799) {
        cout << 2 << endl;
    } else {
        cout << 1 << endl;
    }




    return 0;
}



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

// 'r'  " 
int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  vector<ll> x(n);
  for(auto &&y:x)cin>>y;
  ll ans = 0;
  
  for(int i=1;i<n;i++){
    ans += min(a*(x[i]-x[i-1]),b);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
import math

n,d = map(int,input().split())
x = []
for i in range(n):
    x.append(list(map(int,input().split())))

count = 0
for i in range(n):
    for j in range(i+1,n):
        sum = 0
        for k in range(d):
            sum += (x[i][k]-x[j][k])**2
        if math.sqrt(sum).is_integer():
            count += 1
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
#define inf 1000000007

int main(void){
    int n, k;
    cin >> n >> k;
    int d[k];
    int a, b, c, e, x;
    int count;
    for(int i = 0; i < k; i++)
        cin >> d[i];
    for(int i = n; i < 100000; i++){
        count=0;
        x=i/10000; a=i/1000-x*10; b=i/100-x*100-a*10; c=i/10-x*1000-a*100-b*10; e=i%10;
        if(i<10000) x = 9999;
        if(i<1000) a = 999;
        if(i<100)  b = 999;
        if(i<10)   c = 999;
        //cout << x << a << b << c << e << endl;  
        for(int j = 0; j < k; j++){
            if(x==d[j]||a==d[j]||b==d[j]||c==d[j]||e==d[j])
                count++;
        }
        if(count==0){
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

long long  factorial(long long n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}

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

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}

//int ()



int main()
{
  int  a ,b, c, d, e, X, Y ,r;
//  long long  a, b, c, d, e, X, Y;
  //  double  c;
//  int  A[200003]={};
  int  A[100003]={};
  int  B[100003]={};
  int  C[100003][11]={};

  int  flg=0;

//  long long  a, b, c, d, X, Y;
  char s[101][101]={};
  char t[101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p,q;
//  int flag=0;
//  int tmp=0;
//  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  int len=0;
  int l=0;
//  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  int ans=0;
  int max=0;
  int sum=0;
  int addr=0;
  int ptn=0;
  long long  tmp=0;
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
  scanf("%d", &a);
//  scanf("%d%d", &a, &b);
  for(i=0;i<a;i++){
    scanf("%d", &A[i]);
  }
  
  for(i=0;i<a;i++){
    for(j=i+1;j<a;j++){
      sum=sum+A[i]*A[j];
    }
  }
  printf("%d\n", sum);
  
return 0;
}


Measured memory_bytes: 512
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>

using namespace std;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main(){
    int h,w,D;
    cin >> h >> w >> D;
    int a;
    ll d[h*w+1];
    vector<pii> pxy(h*w+1);
    vector<ll> ans;

    REP(i,h){
        REP(j,w){
            cin>>a;
            pxy[a] = pii(i,j);
        }
    }

    REP(i,D){
        d[i]=0;
    }
    FOR(i,D+1,h*w+1){
        d[i]= d[i-D] + abs(pxy[i].first-pxy[i-D].first) + abs(pxy[i].second-pxy[i-D].second);
    }

    int q;
    cin >> q;

    REP(i,q){
        int l,r;
        cin >> l >> r;
        ans.push_back(d[r]-d[l]);
    }

    REP(i,q)cout << ans[i] << endl;
    return 0;

}

Measured memory_bytes: 3444
from heapq import heappush, heappop
n=int(input())
a=list(map(int, input().split()))
q1=[]
q2=[]
s1=[]
s2=[]
for i in range(n):
    heappush(q1, a[i])
s1.append(sum(a[0:n]))
for ai in a[n:2*n]:
    heappush(q1, ai)
    m=heappop(q1)
    s1.append(s1[-1]+ai-m)
a=a[::-1]
for i in range(n):
    heappush(q2, -a[i])
s2.append(-sum(a[0:n]))
for ai in [-i for i in a[n:2*n]]:
    heappush(q2, ai)
    m=heappop(q2)
    s2.append(s2[-1]+ai-m)
ans=s1[0]+s2[-1]
for i in range(n+1):
    ans=max(s1[i]+s2[-i-1], ans)
print(ans)    

Measured memory_bytes: 37212
#include <bits/stdc++.h>
using namespace std;
int n;
string str;
int ind;
int dig(int lead){
	if(str[ind]<'0'||'9'<str[ind]) return lead;
	int tmp=str[ind]-'0';
	++ind;
	return dig(lead*10+tmp);
}
int solve(){
	vector<int> step;
	for(;;){
		if(ind>=str.size()){
			sort(step.begin(),step.end());
			int tmpans=0;	
			for(int i=0;i<step.size()/2+1;++i)
				tmpans+=step[i];
			return tmpans;
		}else if(str[ind]=='['){
			++ind;
			step.push_back(solve());
		}else if(str[ind]==']'){
			++ind;
			sort(step.begin(),step.end());
			int tmpans=0;	
			for(int i=0;i<step.size()/2+1;++i)
				tmpans+=step[i];
			return tmpans;
		}else{
			step.push_back(dig(0)/2+1);
		}
	}
}
int main(){
    cin >> n;
    for(int i=0;i<n;++i){
    	cin >> str;
    	ind=0;
    	cout << solve() << endl;
    }
    return 0;
}

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

const int N = 2e5 + 10;

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

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d%d", &a[i], &b[i]);
	}
	bool flg = 1;
	for (int i = 1; i <= n; ++i)
		flg &= a[i] == b[i];
	if (flg) {
		puts("0");
		return 0;
	}
	ll mn = 1e18, sum = 0;
	for (int i = 1; i <= n; ++i) {
		sum += a[i];
		if (a[i] > b[i]) mn = min(mn, (ll) b[i]);
	}
	if (mn == 1e18) {
		puts("0");
		return 0;
	}
	printf("%lld\n", sum - mn);
	return 0;
}


Measured memory_bytes: 3976
def palindrome?(num)
  digits = num.to_s
  digits.length.times do |i|
    if digits[i] != digits[-(i + 1)]
      return false
    end
  end

  true
end

a, b = gets.split.map(&:to_i)

puts a.upto(b).count { |n| palindrome?(n) }


Measured memory_bytes: 1788
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int a, b, c, d; cin >> a >> b >> c >> d;

    int ans = 0;
    if (c < a) {
        if (d < b) ans = d - a;
        else ans = b - a;
    } else {
        if (d < b) ans = d - c;
        else ans = b - c;
    }
    cout << (ans > 0 ? ans : 0) << endl;
}


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

int main() {
  int n, m = 0;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  rep(i, n-1){
    if(v[i] == v[i+1]){
      ++m;
      v[i+1] = 0;
    }
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	int x,y,sx,sy,cost;
};
int f[10001]={};

int main() {

	int n;
	cin>>n;
	for(int i=1; i<101; i++){
		for(int j=1; j<101; j++){
			for(int k=1; k<101; k++){
				ll t=i*i+j*j+k*k+i*j+j*k+k*i;
				if(t>n)break;
				f[t]++;
			}
		}
	}
	rep(i,n)cout<<f[i+1]<<endl;

	return 0;
}


Measured memory_bytes: 3564
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#include <stdbool.h>

typedef double db;
typedef int in;
typedef long int li;
typedef long long int lli;
typedef long ld;
typedef long lld;

#define pi M_PI
#define in scanf
#define out printf
#define inf INT_MAX
#define rep(i,n) for(int i=0;i<n;++i)
#define debugd(d) printf("%d\n",d)
#define debugs(s) printf("%s\n",s)
#define debugc(c) printf("%c\n",c)
#define debugf(f) printf("%f\n",f)


int main (void)
{
  int n;
  in("%d",&n);
  if(n/100==n%10) puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;

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

    long long n, k;
    cin >> n >> k;

    long long ans = 0;
    for(long long i = k; i <= n + 1; i++){
        long long a = i * (i - 1) / 2;
        long long b = i * (2 * n - i + 1) / 2;
        long long add = b - a + 1;
        ans = (ans + add) % MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <string>
#include <sstream>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

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

    string S, T;
    cin >> S >> T;

    if (S.length() != T.length()) {
        cout << "No" << endl;
        return 0;
    }

    int len = S.length();

    for (int i = 0; i < len + 1; ++i) {
        if (S == T) {
            cout << "Yes" << endl;
            return 0;
        }
        string tmp = S.substr(0, len - 1);
        S = S.substr(len - 1, 1) + tmp;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
ll n,a,b;
int main(){
	scanf("%lld%lld%lld",&n,&a,&b);
	if((a^b)&1^1)return printf("%lld\n",(b-a)>>1),0;
	R ll res=1e18;
	cmin(res,b-1),cmin(res,a+((b-a-1)>>1));
	swap(a,b),a=n-a+1,b=n-b+1;
	cmin(res,b-1),cmin(res,a+((b-a-1)>>1));
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	long a;
	long b;
	
	scanf("%ld",&a);
	scanf("%ld",&b);

	if ((a + b) % 2 == 0){
		printf("%ld",(a + b) / 2);
	}
	
	else {
		printf("IMPOSSIBLE");
	}
	return (0);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;    
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
#define PI 3.1415926535897932384626433832795
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define trav(x,v) for (auto &x : v)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define pv(v) trav(x, v) cout << x << " "; cout << endl; // print vector/array
#define pvv(vv) trav(xx, vv){pv(xx);} // print 2-d vector/2-d array
#define pm(m) trav(x, m) cout << x.F << ":" << x.S << " "; cout << endl; //print map/lookup table

const int MOD = 1000000007;
vector<int> v[100005];
bool visi[100005];
int dp[100005];
int dfs(int s){
    if(visi[s])
        return dp[s];
    visi[s] = 1;
    int ini = 0;
    for(auto x : v[s]){
        ini = max(ini, dfs(x) + 1);
    }
    dp[s] = ini;
    return ini;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin >> n >> m;
    int x,y;
    F0R(i,m){
        cin >> x >> y;
        v[x].pb(y);
    }
    memset(visi, 0, sizeof(visi));
    memset(dp, 0, sizeof(dp)); 
    FOR(i, 1, n+1){
        if(!visi[i])
            int dump = dfs(i);
    }
    int ans = 0;
    FOR(i, 1, n+1){
        ans = max(ans, dp[i]);
    }
    cout << ans;
    return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = LLONG_MAX/2;//1LL << 55;
const int mod = 1e9 + 7;

struct BIT {
  vector<int> data;
  BIT(int n):data(n+1, 0){}
  int sum(int k) {
    int ret = 0;
    while(k > 0) {
      ret += data[k];
      ret %= mod;
      k -= k & -k;
    }
    return ret;
  }
  int sum(int l, int r) {
    return (sum(r)-sum(l-1)+mod*10)%mod;
  }
  void add(int k, int x) {
    while(k < (int)data.size()) {
      data[k] += x;
      data[k] %= mod;
      k += k & -k;
    }
  }
};

int dp[100010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, A, B;
  cin >> N >> A >> B;
  if(A > B) swap(A, B);
  vint S(N+1);
  S[0] = -inf;
  reps(i, 1, N+1) cin >> S[i];

  rep(i, N-1) {
    if(S[i+2]-S[i] < A) {
      cout << 0 << endl;
      return 0;
    }
  }

  BIT bit(N+1);
  int l = 0, r = 0;
  dp[0] = 1;
  bit.add(1, 1);
  reps(i, 1, N+1) {
    while(S[i]-S[r] >= B) ++r;
    //assert(l < r);
    if(l < r) dp[i] = bit.sum(l+1, r);
    bit.add(i+1, dp[i]);
    if(S[i]-S[i-1] < A) l = i-1;
  }
  if(l < N) dp[N] += bit.sum(l+1, N); // X
  dp[N] %= mod;
  cout << dp[N] << endl;

  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n";
using namespace std;
typedef long long int ll;
 
bool possible(int mid,vector<int>a,int k)
{
    for(auto i:a)
    {
        k-=(i-1)/mid;
    }
    if(k>=0)return true;
    return false;
}
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int mn =0,mx=1000000001;
    while(mn<mx-1)
    {
        int mid = (mn)+(mx-mn)/2;
        if(possible(mid,a,k))
            mx = mid;
        else
            mn = mid;
    }
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,k;cin>>n>>m>>k;
    vector<ll> A(n), B(m);
    rep(i, n) cin>>A[i];
    rep(i, m) cin>>B[i];
    vector<ll> sa(n+1, 0), sb(m+1, 0);
    for(int i=0; i<n; i++){
        sa[i+1] = sa[i] + A[i];
    }
    for(int i=0; i<m; i++){
        sb[i+1] = sb[i] + B[i];
    }
    ll ans = 0;
    for(ll i=0; i<=n; i++){
        if(k-sa[i] < 0){
            break;
        }
        ll t = k-sa[i];
        int size =  upper_bound(all(sb), t) - sb.begin() -1;
        ans = max(i+size, ans);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 9440
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    string str;
    cin >> str;
    int N = str.size();

    vector<vector<int>> dp(N + 1, vector<int>(2, 0));
    dp[0][0] = 1;

    for (int i = 0; i < N; i++) {
        if (str[i] == '0') {
            dp[i+1][0] = dp[i][0];
            dp[i+1][1] = (3 * dp[i][1]) % MOD;
        } else {
            dp[i+1][0] = (2 * dp[i][0]) % MOD;
            dp[i+1][1] = (dp[i][0] + (dp[i][1] * 3) % MOD) % MOD;
        }
    }

    cout << (dp[N][0] + dp[N][1]) % MOD << endl;
    return 0;
}

Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
  int n,m;
  cin>>n>>m;
  vp out(n);
  rep(i,n)out[i]={i,i};
  vp in(m);
  rep(i,m)cin>>in[i].first>>in[i].second;
  sort(all(in));
  rep(i,m){
    int t=in[i].second;
    out[t].first=min(out[t].first,out[t-1].first);
    out[t].second=max(out[t].second,out[t-1].second);

    out[t-1]=out[t];
  }
  rep(i,n)cout<<out[i].second-out[i].first+1<<(i==n-1?'\n':' ');
}

Measured memory_bytes: 5224
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
*/

ll h,w,dp[2010][2010][4],ans=0;
string s[2010];

void init(){
	cin>>h>>w;
	rep(i,h)cin>>s[i];
	rep(i,h+2)rep(j,w+2)rep(k,4)dp[i][j][k]=0;
	reg(i,1,h)reg(j,1,w){
		if(s[i-1][j-1]=='.'){
			dp[i][j][0]=dp[i][j-1][0]+1;
		}else{
			dp[i][j][0]=0;
		}
	}
	reg(i,1,h)ireg(j,1,w){
		if(s[i-1][j-1]=='.'){
			dp[i][j][1]=dp[i][j+1][1]+1;
		}else{
			dp[i][j][1]=0;
		}
	}
	reg(i,1,h)reg(j,1,w){
		if(s[i-1][j-1]=='.'){
			dp[i][j][2]=dp[i-1][j][2]+1;
		}else{
			dp[i][j][2]=0;
		}
	}
	ireg(i,1,h)reg(j,1,w){
		if(s[i-1][j-1]=='.'){
			dp[i][j][3]=dp[i+1][j][3]+1;
		}else{
			dp[i][j][3]=0;
		}
	}
}

int main(void){
	init();
	reg(i,1,h)reg(j,1,w){
		if(s[i-1][j-1]=='.')ans=max(ans,dp[i][j][0]+dp[i][j][1]+dp[i][j][2]+dp[i][j][3]-3);
	}
	// reg(i,1,h){
	// 	reg(j,1,w)cerr<<dp[i][j][3]<<" ";
	// 	cerr<<endl;
	// }
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 130048
#include<bits/stdc++.h>
using namespace std; 
#define mod 1000000007
#define N 100005
#define ll long long
#define ull unsigned long long
#define loop1(i, j, k, step) for (int i=j; i<k; i+=step)
#define loop(i, j, k) for (int i=j; i<k; i++) 
#define rloop1(i, j, k, step) for (int i=j; i>=k; i-=step)
#define rloop(i, j, k) for(int i=j; i>=k; i--)
#define rep(i, k) for(int i = (0); i < (k); i++ )
#define rrep(i, k) for(int i = k-1; i >= 0; i-- )

#define forall(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define pop pop_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define endl "\n"
#define Max (int)INT_MAX
#define Min (int)INT_MIN
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;


void solve()
{
	int n,i,j,k,l;
	cin>>n;
	int visit[n+1]={0};
	rep(i,n-1){
		cin>>k;
		visit[k]++;
	}
	loop(i,1,n+1)
	{
		cout<<visit[i]<<endl;
	}
}
int  main() 
{
	fast_io;
    int t=1;
    //cin>>t;
    while(t--)
    	solve();
	return 0; 
}

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

int gcd(int a, int b){
	if(a<b){
		swap(a,b);
	}
	int r = a%b;
	while(r!=0){
		a = b;
		b = r;
		r = a %b;
	}
	return b;
}
int main(){
	int k;
	cin >> k;
	long long sum = 0;
	for(int i=1;i<=k;i++){
		for(int j=1; j <= k; j++){
			for(int l=1; l <= k; l++){
				sum += gcd(gcd(i,j),l);
			}
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3624
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var x = cin.nextInt();
            var y = cin.nextInt();
            var z = cin.nextInt();

            Console.WriteLine((x-z)/(y+z));
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public string[] ArrayString(int N)
        {
            string[] Array = new string[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = next();
            }
            return Array;
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(b-a==c-b)puts("YES");
  else puts("NO");
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        int N = scanner.nextInt();
        int A = scanner.nextInt();
        int B = scanner.nextInt();

        int sum = 0;

        for(int i=1; i<=N; i++){
            int tmp = i;
            int acc = 0;
            while(tmp != 0){
                acc += tmp % 10;
                tmp /= 10;
            }

            if(A<= acc && acc <= B){
                sum += i;
            }
        }

        System.out.println(sum);

    }

    static List<Integer> primeList(int n) {
        List<Integer> list = new ArrayList<>();
        boolean[] prime = new boolean[n + 1];
        Arrays.fill(prime, true);
        prime[0] = false;
        prime[1] = false;
        for (int i = 2; i < Math.sqrt(n); i++) {
            if (!prime[i]) continue;
            for (int j = 2; i * j <= n; j++) {
                prime[i * j] = false;
            }
        }
        for (int i = 0; i < prime.length; i++) {
            if (prime[i]) list.add(i);
        }

        return list;
    }
}

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

using namespace std;

#define MOD 1000000007LL
#define N 10000000
#define ll long long

int n, m;
ll fac[N+5], fac_inv[N+5];

template <typename T>
void upd(T &x, T y) {
	x = x*y%MOD;
}

ll fpow(ll x, ll p) {
	ll base = x, ret = 1;
	while(p) {
		if(p&1) upd(ret, base);
		upd(base, base);
		p >>= 1;
	}
	return ret;
}

void init() {
	fac[0] = 1;
	for(int i = 1; i <= N; ++i) fac[i] = fac[i-1]*i%MOD;
	fac_inv[N] = fpow(fac[N], MOD-2);
	for(int i = N; i >= 1; --i) fac_inv[i-1] = fac_inv[i]*i%MOD;
}

template <typename T>
ll F(T x, T y) {
	return fac[x+y-1]*fac_inv[x-1]%MOD*fac_inv[y]%MOD;
}

signed main() {
	cin >> n >> m;
	init();
	ll ans = 1;
	for(int i = 2; i*i <= m; ++i) {
		if(m%i == 0) {
			int cnt = 0;
			while(m%i == 0) cnt++, m /= i;
			upd(ans, F(n, cnt));
		}
	}
	if(m > 1) upd(ans, (ll)n);
	cout << ans;
	return 0;
}

Measured memory_bytes: 156544
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 92233720ll;
int k,n;
string s;
const int nax = 2000001;
int p25[nax],fac[nax];
void fill(){
  p25[0] = 1;
  fac[0] = 1;
  loop(i,1,nax){
   fac[i] = (fac[i-1] * i)%mod;
   p25[i] = (p25[i-1] * 25)%mod;
  }
}
int power(int base,int n,int m = mod)
 {
  if(n == 0)
     return 1;
  if(n&1)
     {
      int y = power(base,n-1,m);
      return (y*base)%m;
     }
  else
     {
      int y = power(base,n/2,m);
      return (y*y)%m;
     }
 }
int nCr(int n,int r){
  int num = fac[n];
  int denom = (fac[r] * fac[n-r])%mod;
  int denominv = power(denom,mod-2);
  int ans = (num * denominv)%mod;
  return ans;
}

void solve()
 {
  fill();
  cin>>k>>s;
  n = s.size();
  int tot = power(26,n+k);
  int reductions = 0;
  loop(i,0,n){
    int now = (nCr(n+k,i) * p25[n+k-i])%mod;
    reductions = (reductions + now)%mod;
  }
  int ans = (tot - reductions + mod)%mod;
  cout<<ans;
 }
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 35476
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie acos(-1)
#define loop(i,a,n) for(int i=a;i<n;i++)
#define trav(a,x) for(auto &a:x)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define endl "\n"
#define debug(x)  cout<<#x<<" " <<x<<endl;
#define dbg(x,y)  cout<<#x<<" " <<x<<" "<<#y<<" "<<y<<endl;
#define all(v) v.begin(),v.end()
#define si(x) x.size()

const int e = 100005;
const ll INF = 1e18+5;
int n,a;
vi x(55);
ll dp[55][55][55*55];
ll ans(int i , int j , int k)// i is index  j is no. k is sum
{
    if(i==n+1)
    return 0;
    if(j==0 && k==0)
    return 1;
    ll &memo = dp[i][j][k];
    if(memo!=-1)
    return memo;
    memo=ans(i+1,j-1,k-x[i])+ans(i+1,j,k);
    return memo;
}
void solve()
{
    memset(dp,-1,sizeof(dp));
    cin>>n>>a;
    loop(i,0,n)
    cin>>x[i];
    ll val=0;
    for(int i = 1 ; i <= n ; i++ )
    {
        ll sum = a*i;
        val+=ans(0,i,sum);
    }
    cout<<val;
}
int main() {
	// your code goes here
	io;
	//int t ;
	
    solve();
	return 0;
}


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

using namespace std;

int W, a, b;
int ab[2];

int main(void)
{
  // input
  cin >> W >> ab[0] >> ab[1];
  sort(ab, ab+2);
  if(ab[1] - W > 0){
    printf("%d\n",ab[1]-ab[0]-W);
  }
  else{
    printf("0\n");
  }


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define simplify ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;

const int N=2e5+5;
int arr[N];
int mp[10000005];

int32_t main()
{
    simplify

    int n;
    cin>>n;
    
    for(int i=0;i<n;i++){
        cin>>arr[i];
        mp[arr[i]]++;
        //s.insert(arr[i]);
    }
    int ans=n;
    
    int curr,cnt;
    for(int i=0;i<n;i++){
        curr=arr[i];
        cnt=0;
        for(int j=1;j*j<=curr;j++){
            if(curr%j==0){
                cnt+=mp[j];
                if(j!=curr/j)
                    cnt+=mp[curr/j];
            }
        }
        if(cnt>1)ans--;
    }
    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 13020
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const inputs = input.trim().split('\n');
const adj = inputs.map((s) => s.split(' ').map(Number));

class Edge {
  constructor(dest, weight = 1) {
    this.dest = dest;
    this.weight = weight;
  }
}

class Node {
  constructor() {
    this.list = [];
  }
  addEdge(edge) {
    this.list.push(edge);
  }
  isOdd() {
    return !!(this.list.length % 2);
  }
}

class Graph {
  constructor() {
    this.init();
  }
  init() {
    this.map = new Map();
  }
  getNode(source, edge) {
    if (!this.map.has(source)) {
      this.map.set(source, new Node());
    }
    return this.map.get(source);
  }
  addEdge(source, edge) {
    const node = this.getNode(source);
    node.addEdge(edge);
  }
  countOdd() {
    return Array.from(this.map.values()).map(node => node.isOdd() ? 1 : 0).reduce((a, b) => a + b);
  }
  canPatrol() {
    if (graph.countOdd() !== 2) {
      return false;
    }
    return graph.getNode(1).isOdd() && graph.getNode(2).isOdd();
  }
}

const graph = new Graph();
adj.forEach(([source, dest]) => {
  if (source === 0 && dest === 0) {
    console.log(graph.canPatrol() ? 'OK' : 'NG');
    graph.init();
    return;
  }
  graph.addEdge(source, new Edge(dest));
  graph.addEdge(dest, new Edge(source));
});



Measured memory_bytes: 18616
#include <bits/stdc++.h>
using namespace std;
#define PI acos(-1)
typedef long long ll;
#define X first
#define Y second
typedef pair<int, int> pii;
#define INF 0x3f3f3f3f

int main()
{
    //freopen("in.txt", "r", stdin);
    int n, k;
    ll ans = 0;
    while (~scanf("%d%d", &n, &k))
    {
        if (k == 0)
        {
            printf("%lld\n", (ll)n*n);
            continue;
        }
        for (int i = k + 1; i <= n; i++)
        {
            ans += (i - k) * (n/i);
            // printf("b:%d count:%d k:%d\n", i, (i-k)*(n/i), k);
            int t = max(0, n%i - k + 1);
            ans += t;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = 1000000007;
		long ans = 1;
		for(int i=1; i<n+1; i++){
			ans = (ans*i)%m;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22228
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
const ll INF = 1LL << 60;
#define MOD 1000000007
#define MAX_V 100010
#define MAX_N 100010

bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}

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

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    if(c>a){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}






Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int main(){
	int n,d;
	cin>>n>>d;
	vi dp(1100,-inf);
	dp[0]=0;
	rep(i,n){
		int a,b;
		cin>>a>>b;
		for(int j=1099;j>=0;j--)if(dp[j]!=-inf)rep(k,a+1)if(j+k<1100){
			cmax(dp[j+k],dp[j]+(i+1)*100*k+(k==a?b:0));
		}
	}
	rep(i,1100)if(dp[i]>=d){
		cout<<i<<endl;
		return 0;
	}
}







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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,m; cin>>n>>m;
    vector<ll> a(n),b(n),c(m),d(m);
    rep(i,n) cin>>a[i]>>b[i];
    rep(i,m) cin>>c[i]>>d[i];

    rep(i,n){
        ll mdist=abs(a[i]-c[0])+abs(b[i]-d[0]),cp=1;
        for(int j=1;j<m;j++){
            ll nowdist=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(mdist>nowdist){
                mdist=nowdist;
                cp=j+1;
            }
        }
        cout<<cp<<endl;
    }
    return 0;
}

Measured memory_bytes: 3588