akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

int main() {
    lli n,a,b;
    cin3(n,a,b);
    lli x[n];
    ncin1(n,x);

    lli i = 0;
    lli cur = x[0];
    lli ans = 0;
    REP(i,1,n) {
        //cout2(i, min((x[i]-cur)*a, b));
        ans += min((x[i]-cur)*a, b);
        cur = x[i];
    }
    cout << ans << endl;
}


//6
//1,6,7,9,21
//oxxxxooxoxxxxxxxxxxxo


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N=25,mo=1e9+7;
struct Matrix{
	int a[N][N],n;
	Matrix operator * (const Matrix &b)const{
		Matrix c;c.n=n;
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++){
				c.a[i][j]=0;
				for(int k=0;k<n;k++)(c.a[i][j]+=1ll*a[i][k]*b.a[k][j]%mo)%=mo;
			}
		return c;
	}
}a;
Matrix qpow(Matrix a,int b){
	Matrix ans;ans.n=a.n;
	for(int i=0;i<a.n;i++){
		for(int j=0;j<a.n;j++)ans.a[i][j]=0;
		ans.a[i][i]=1;
	}
	while(b){
		if(b&1)ans=ans*a;
		a=a*a,b>>=1;
	}
	return ans;
}
int main(){
	a.n=21;
	for(int i=0;i<5;i++)a.a[i<<1][i<<1|1]=a.a[i<<1|1][i<<1]=a.a[(i+1)<<1][i<<1]=1;
	for(int i=10;i<=20;i++)a.a[i+1][i]=a.a[i][i]=1;
	int t,n;scanf("%d",&t);
	while(t--){
		scanf("%d",&n);
		printf("%d\n",qpow(a,n+10).a[20][0]);
	}
	return 0;
}

Measured memory_bytes: 3808
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <vector>

using namespace std;
typedef long long LL;
typedef pair<int,int> mp;
#define pb push_back
const int maxn = 305;
const int mod = 1e9+7;

int dp[maxn][maxn][maxn],n,m,ans;
vector<mp> lim[maxn];
int main()
{
	#ifdef Amberframe
		freopen("arc074e.in","r",stdin);
		freopen("arc074e.out","w",stdout);
	#endif
	scanf("%d %d",&n,&m);dp[0][0][0]=1;
	for (int l,r,x,i=1;i<=m;i++)
		scanf("%d %d %d",&l,&r,&x),lim[r].pb(mp(l,x));
	for (int i=0;i<=n;i++)
	for (int j=0;j<=n;j++)
	for (int k=0;k<=n;k++)
	if (int w=dp[i][j][k]) {
		int t=max(max(i,j),k);bool tag=true;
		for (unsigned l=0;l<lim[t].size();l++)
		{
			int u=lim[t][l].first,s=lim[t][l].second;
			tag&=((i>=u)+(j>=u)+(k>=u))==s;
		}
		if (!tag) continue;
		if (t==n) (ans+=w)%=mod;
		(dp[t+1][j][k]+=w)%=mod;
		(dp[i][t+1][k]+=w)%=mod;
		(dp[i][j][t+1]+=w)%=mod;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 110848
import java.util.Scanner;

public class Main {
	static long mod = 1000000007;

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			long sum = 0;
			long tmpsum = 0;
			for (int i = 0; i < n; i++) {
				long tmp = sc.nextLong();
				long add = (tmp * tmpsum) % mod;
				sum = (sum + add) % mod;
				tmpsum = (tmpsum + tmp) % mod;
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 59776
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
int main(void){
    int n;
    std::cin >> n;
    std::vector<int> d(n);
    rep(i, n){
        std::cin >> d.at(i);
    }
    int k = 0;
    //文字kは総和
    rep(i, n - 1){
        rep(j, n - i - 1){
            k = k + (d.at(i) * d.at(i + j + 1)) ;
        }
    }
    std::cout << k << std::endl;
}


Measured memory_bytes: 256
h, w = gets.chomp.split.map(&:to_i)
s = []
for i in 0...h
    s.push(gets.chomp.split(//))
end
for i in 0...h
    for j in 0...w
        if s[i][j] == '#'
            for k in -1..1
                for l in -1..1
                    if  i + k < 0 or i + k >= h or j + l < 0 or j + l >= w
                        next
                    end
                    if s[i+k][j+l] == '.'
                        s[i+k][j+l] = 1
                    elsif s[i+k][j+l] == '#'
                        next
                    else
                        s[i+k][j+l] += 1
                    end
                end
            end
        end
    end
end
for i in 0...h
    for j in 0...w
        if s[i][j] == '.'
            s[i][j] = 0
        end
    end
end
for i in 0...h
    print(s[i].join())
    puts
end

Measured memory_bytes: 2172
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

Int Ceil(Int a, Int b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return Floor(a, b) + 1;
    }
}

vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

Int digits(Int n) {
    return (Int)to_string(n).size();
}

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

    Int n, k;
    cin >> n >> k;
    vector<pair<Int, Int>> ab(n);
    for (Int i = 0; i < n; i++) {
        cin >> ab[i].first >> ab[i].second;
    }

    sort(ab.begin(), ab.end());
    Int ans = 0, cnt = 0;
    for (auto [a, b] : ab) {
        cnt += b;
        if (k <= cnt) {
            ans = a;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> x(N), y(N);
  REP(i, N)
  cin >> x[i] >> y[i];
  vector<int> vx(N), vy(N);
  REP(i, N)
  {
    vx[i] = x[i];
    vy[i] = y[i];
  }
  sort(ALL(vx));
  sort(ALL(vy));
  ll ans = 9223372036854775807;
  for (int i = 0; i < N - 1; i++)
  {
    for (int j = i + 1; j < N; j++)
    {
      for (int k = 0; k < N - 1; k++)
      {
        for (int l = k + 1; l < N; l++)
        {
          int lx = vx[i], rx = vx[j];
          int ly = vy[k], ry = vy[l];
          int count = 0;
          REP(m, N)
          {
            if (lx <= x[m] && x[m] <= rx && ly <= y[m] && y[m] <= ry)
              count++;
          }
          if (K <= count)
            ans = min(ans, (ll)(rx - lx) * (ry - ly));
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N = gets.to_i
G = (1..N).map{ Array.new(N, 0) } #??£??????????????????

N.times{
	u,k,*v = gets.split(' ').map(&:to_i) # u,k ?????°??????????????????, v ?????????
	v.each {|vi| # v ??????????´? vi ????????????
		# (u-1) ??¨ (vi-1) ???????????????
		G[u-1][vi-1] = 1
	}
}

def dfs(src)
	D[src] = $time # ?¨??????????????¨????
	$time += 1
	(0..N-1).each {|dst|
		if G[src][dst]==1 && !D[dst] then # src ?????? dst ????§????????????§???dst ???????¨?????????£??????
			dfs(dst)
		end
	}
	F[src] = $time # ?¨????????????????????¨????
	$time += 1
	# ??¢??°??????????????§???????????? (?????¢??°)
end



D = Array.new(N) # D[i] ??????????????? nil
F = Array.new(N)
$time = 1

(0..N-1).each {|id| # ???????????\???????????????
	if ! D[id] then # D[id] ???????¨?????????£??????
		dfs(id) # dfs ????§???????
	end
}
# ??????
(0..N-1).each {|id|
	puts "#{id+1} #{D[id]} #{F[id]}"
}

Measured memory_bytes: 8896
#include<bits/stdc++.h>
using namespace std;
int a[100010];
int res[100010];
int cnt[100010];
int solve(int n){
	for(int i=1;i<=n;i++){
		cin>>a[i];
		res[i]=__gcd(res[i-1],a[i]);
	}
	for(int i=n;i>0;i--){
		cnt[i]=__gcd(cnt[i+1],a[i]);
	}
	int ans=1;
	for(int i=1;i<=n;i++){
		ans=max(ans,__gcd(res[i-1],cnt[i+1]));
	}
	return ans;
}
int main(){
	int n;
	cin>>n;
	cout<<solve(n)<<endl;
	return 0;
}

Measured memory_bytes: 1408
from collections import deque

s = deque(input())
q = int(input())
rev = 0 # revが0のとき先頭、1のとき後尾

for _ in range(q):
    t = input().split()

    if len(t) == 1:
        rev ^= 1
    else:
        if rev == 1:
            if t[1] == '1':
                s.append(t[2])
            else:
                s.appendleft(t[2])
        else:
            if t[1] == '1':
                s.appendleft(t[2])
            else:
                s.append(t[2])

if rev == 1:
    s.reverse()

print(''.join(s))


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A.at(i);
  }
  vector<double> A2(N);
  for (int i = 0; i < N; ++i) {
    A2.at(i) = 1.0 / A.at(i);
  }
  double sum = accumulate(A2.begin(), A2.end(), 0.0);
  double ans = 1.0 / sum;
  cout << fixed << setprecision(12) << ans << endl;
}


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

int main() {

int a, b;
int mean_i;
double mean_d;

cin >> a >> b;
mean_i = (a+b)/2;
mean_d = (a+b)/2.0;

if (mean_d - mean_i >= 0.5) mean_i= mean_i+1;
cout << mean_i << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
int x,y,z;
cin >> x >> y >> z;
int d = (x*100)+(y*10)+(z*1);
if(d%4==0){
    cout << "YES" << endl;
}else{
    cout << "NO" << endl;
}
return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  bool ok = false;
  for (int i = 1; i <= 9; ++i) {
    for (int j = 1; j <= 9; ++j) {
      if (i * j == N) ok = true;
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i=0; i<N; i++) cin >> A[i];

	vector<int> count(N+1);
	for(int i=0; i<N; i++) count[A[i]]++;
	vector<int> b;
	for(int i=0; i<N+1; i++) if(count[i]>0) b.push_back(count[i]);
	sort(b.begin(), b.end());

	vector<ll> xs;
	int k = 0;
	ll sum = 0;
	int c = 0;
	for(ll x=0; x<=N; x++){
		while(b[k]==x){
			k++;
			c++;
			sum += x;
		}
		xs.push_back(sum + (b.size()-c) * x);
		debug(x, c, sum, (ll)(sum+(b.size()-c)*x));
	}

	for(int i=1; i<=N; i++){
		int lb=0, ub=N+1;
		while(ub-lb>1){
			ll x = (ub+lb)/2;
			if(i*x<=xs[x]){
				lb = x;
			} else {
				ub = x;
			}
		}
		cout << lb << endl;
	}

	return 0;
}


Measured memory_bytes: 9712
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if(a>b){
        swap(a,b);
    }
    if(b>c){
        swap(b,c);
    }
    if(a>b){
        swap(a,b);
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
}


Measured memory_bytes: 3060
s = input()

c = 0
while True:
    l = len(s)-c
    key = list(s[:c+1])
    for i in range(1,l):
        new_key = []
        for k in key:
            if k in s[i:i+c+1]:
                new_key.append(k)
        key = new_key
        if key == []:
            break
    if key != []:
        break
    c += 1
print(c)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
int main() {
int N, M; cin >> N >> M;
  vector<pair<ll, ll>> a(N);
  rep(i, N) {
    cin >> a[i].first >> a[i].second;
  }
  sort(a.begin(), a.end());

  ll ans=0;
  rep(i, N) {
    if(a[i].second<M) {ans+=a[i].first*a[i].second; M = M-a[i].second;}
    else if(M==0) {cout << ans << endl;break;}
    else {ans +=a[i].first*M; cout << ans << endl;break;}
  }
 
  }


Measured memory_bytes: 1792
# include <bits/stdc++.h>
    #pragma GCC optimize("Ofast")

    # define pb push_back
    # define fr first
    # define sc second
    # define mk make_pair

    using namespace std;

    const long long linf = 1e18 + 7;
    const int inf = 1e9 + 7;
    const int N = 1e6 + 5;

    typedef long long ll;

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

    int main(){
          cin >> n;

          for(int i = 1; i <= n; i ++){
                cin >> a[i];
                if(a[i] % 4 == 0)
                      b ++;
                else if(a[i] % 2 == 0)
                      c ++;
          }

          n -= 2 * b + 1;

          if((c / 2 * 2) >= n || n < 1)
                puts("Yes");
          else
                puts("No");
    }


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#define N 305
using namespace std;

typedef long long ll;
ll n, c, a[N][N];
bool v[N][N];
int main()
{
	ll i, j, k;
	cin >> n;
	for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) scanf("%lld", &a[i][j]);
	for (k = 1; k <= n; k++) {
		for (i = 1; i <= n; i++) {
			for (j = 1; j <= n; j++) {
				if (i == k || j == k) continue;
				if (a[i][j] > a[i][k] + a[k][j]) {puts("-1"); return 0;}
				if (a[i][j] == a[i][k] + a[k][j]) v[i][j] = 1;
			}
		}
	}
//	for (i = 1; i <= n; i++, puts("")) for (j = 1; j <= n; j++) printf("%d ", v[i][j]);
	for (i = 1; i <= n; i++) for (j = i + 1; j <= n; j++) c += (!v[i][j]) * a[i][j];
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 1024
#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>
#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 mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int a;
	cin>>a;
	ll out=2;
	rep(i,a)out=out*2+2;
	cout<<out<<endl;
}








Measured memory_bytes: 256
a,b,c=map(int,input().split())
ans=0
average=int((a+b+c)/3)
while True:
    if a%2==1 or b%2==1 or c%2==1:
        print(ans)
        exit()
    else:
        tb=int(b/2)
        tc=int(c/2)
        ta=int(a/2)
        a=tb+tc
        b=ta+tc
        c=ta+tb

        ans+=1
    if a==average and b==average and c==average:
        print(-1)
        exit()


Measured memory_bytes: 8988
#include "bits/stdc++.h"
using namespace std;
int main(){
    string o,e;
    cin >> o >> e;
    int n,m,i;
    n = o.size();
    m = e.size();
    for(i=0;i<m;i++)cout << o.at(i) << e.at(i);
    if(n-m) cout << o.at(n-1);
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
// Libraries
fun string(): String = readLine()!!
fun int(): Int = readLine()!!.toInt()
fun long(): Long = readLine()!!.toLong()
fun stringList(): List<String> = readLine()!!.split(" ")
fun intList(): List<Int> = readLine()!!.split(" ").map(String::toInt)
fun longList(): List<Long> = readLine()!!.split(" ").map(String::toLong)

// 最大公約数(ユーグリットの互除法)
tailrec fun gcd(a: Int, b: Int): Int = when {
    a < b -> gcd(b, a)
    b == 0 -> a
    else -> gcd(b, a % b)
}

fun main(args: Array<String>) {
    val s = string().toCharArray()

    if(s[0] == s[1] && s[1] == s[2]) {
        println("No")
    }else{
        println("Yes")
    }
}

Measured memory_bytes: 33528
#include "bits/stdc++.h"
using namespace std;

constexpr long long MOD = 998244353;
vector<long long> F, RF, R;

long long Comb(long long A, long long B) {
	return (F[A] * ((RF[A - B] * RF[B]) % MOD)) % MOD;
}

long long Calc(long long A, long long B) {
	if (B == 0) return 1;
	if (B % 2 == 0) {
		long long C = Calc(A, B / 2);
		return (C * C) % MOD;
	}
	return (A * Calc(A, B - 1)) % MOD;
}

int main() {
	long long N, NG = 0;
	cin >> N;
	F.resize(N + 1), RF.resize(N + 1), R.resize(N + 1);
	F[0] = F[1] = RF[0] = RF[1] = R[0] = R[1] = 1;
	for (int i = 2; i <= N; i++) {
		F[i] = (F[i - 1] * i) % MOD;
		R[i] = MOD - (R[MOD % i] * (MOD / i)) % MOD;
		RF[i] = (RF[i - 1] * R[i]) % MOD;
	}
	long long NOW = 1;
	for (int X = N; X > N / 2; X--) {
		long long COUNT = Comb(N, X);
		COUNT *= NOW;
		COUNT %= MOD;
		NG = (NG + COUNT) % MOD;
		NOW = (NOW * 2) % MOD;
	}
	cout << (Calc(3, N) - NG * 2 + MOD * 2) % MOD << endl;
}


Measured memory_bytes: 234624
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def same(x, y):
    return find(x) == find(y)

def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if par[x] > par[y]:
        x, y = y, x
    par[x] += par[y]
    par[y] = x


N, M = map(int, input().split())
par = [-1 for i in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    unite(a - 1, b - 1)

cnt = -1
num = {0}

for i in par:
  if i <= -1:
    cnt += 1

print(cnt)

Measured memory_bytes: 10904
let () =
  let m = 1000000 in
  let a = Array.make m false in a.(0) <- true;
  let dp = Array.make m 0 in
  let rec aux i j =
    if i*j < m then (a.(i*j) <- true; aux i (j + 1))
  and make i =
    if i < m then begin
      if not a.(i) then aux i 2;
      dp.(i) <- dp.(i - 1) + (if a.(i) then 0 else 1);
      make (i + 1)
    end
  in
  make 2;
  let rec doit () =
    Printf.printf "%d\n" dp.(read_int ());
    doit ()
  in
  try doit() with _ -> ()

Measured memory_bytes: 18264
def main():
  n = int(input())
  A = [int(x) for x in input().split()]
  
  a_dict = {}

  for i in range(n):
    a_dict[i+1] = 0

  for a in A:
      a_dict[a] = a_dict[a] + 1

  for i in range(n):
    print(a_dict[i+1])
  
if __name__ == "__main__":
    main()
    pass

Measured memory_bytes: 38844
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

map<int,int> res;
void prime_factor(int n){
	for(int i = 2; i * i  <= n; i++) {
		while(n % i == 0){
			res[i]++;
			n /= i;
		}
	}
	if (n != 1){
		res[n]++;
	}
}

int main(){
	int n;cin>>n;
	for(int i = n; i >= 1; i--) {
		prime_factor(i);
	}
	int f74 = 0,f24 = 0,f14 = 0,f4 = 0,f2 = 0;
	for(auto ite = res.begin();ite != res.end();ite++){
		// cout << (*ite).sc << endl;
		if((*ite).sc >= 74){
			f74 ++;
			f24 ++;
			f14 ++;
			f4 ++;
			f2 ++;
		}
		else if ((*ite).sc >= 24){
			f24 ++;
			f14++;
			f4 ++;
			f2 ++;
		}
		else if ((*ite).sc >= 14){
			f14 ++;
			f4 ++;
			f2 ++;
		}
		else if ((*ite).sc >= 4){
			f4 ++;
			f2 ++;
		}
		else if ((*ite).sc >= 2){
			f2++;
		}
	}
	// cout << f74 << endl;
	// cout << f24 << endl;
	// cout << f14 << endl;
	// cout << f4 << endl;
	// cout << f2 << endl;
	int ans = 0;
	ans += f74;
	ans += (f24 * (f2 - 1));
	ans += (f14 * (f4 - 1));
	ans += (f4 * (f4 - 1) * (f2 - 2))/2;

	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main(){
  int n;
  vector<int> wi;
  cin >> n;
  for(int i=0; i<n; i++){
    int temp;
    cin >> temp;
    wi.push_back(temp);
  }

  // sort(wi.begin(), wi.end() );
  vector<int> cumulativeSum;
  cumulativeSum.push_back(0);
  for(int i=0; i<n; i++){
    int temp = cumulativeSum.at(i) + wi.at(i);
    cumulativeSum.push_back( temp );
  }

  int min = 999999999;
  for(int t=0; t<n; t++){
    int s1 = cumulativeSum[t];
    int s2 = cumulativeSum[n] - cumulativeSum[t];
    if(min > abs(s2 - s1) ) min = abs(s2 - s1);
  }

  cout << min << endl;
  return 0;
}


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

int main(void)
{
  int a;
  cin >> a;
  vector<int> data(a);
  for(int i = 0; i < a; i++)
  {
    cin >> data[i];
  }
  int res = 0;
  int cnt = 0;
  for(int i = 0; i < a - 1; i++)
  {
    if(data[i] >= data[i+1])
    {
      cnt++;
    }else{
      cnt = 0;
    }
    res = max(res, cnt);
  }
 
  cout << res << endl;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, 0, n)cin >> a[i];
	sort(all(a));
	int m = a[n - 1];
	a.pop_back();
	printf("%d ", m);
	auto it = lower_bound(all(a), m / 2);
	if (it == a.end()) {
		printf("%d\n", *--it);
	}
	else if (it == a.begin()) {
		printf("%d\n", *--it);
	}
	else {
		int x = *it, y = *(it - 1);
		printf("%d\n", m / 2 - y < x - m / 2 ? y : x);
	}
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n;
  cin >> n;
  int a[n][n - 1];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n - 1; j++){
      cin >> a[i][j];
    }
  }

  vector< queue< int > > b(n);
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n - 1; j++){
      b[i].push(a[i][j]);
    }
  }

  bool ok = true;
  int i = 0, count = 0;
  set< int > d;
  for(int i = 0; i < n; i++) d.insert(i);
  while(count < n * (n - 1) / 2){
    bool found = false;
    set< int > c;
    int j = 0;
    for(int j: d){
      if(c.find(j) != c.end() || b[j].empty()){
        ++j;
        continue;
      }
      int k = b[j].front() - 1;
      if(c.find(k) != c.end() || b[k].empty()){
        ++j;
        continue;
      }
      if(b[k].front() == j + 1){
        b[j].pop();
        b[k].pop();
        found = true;
        c.insert(j);
        c.insert(k);
        ++count;
      }
      j++;
    }
    d = c;
    if(!found){
      ok = false;
      break;
    }
    ++i;
  }

  if(ok) cout << i << endl;
  else cout << -1 << endl;


  return 0;
}


Measured memory_bytes: 8320
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();
            var ans = "Yes";


            for (var i = 0; i<s.Length; i++)
            {
                if(s[i] !=t[i])
                {
                    ans = "No";
                }
            }

            Console.WriteLine(ans);
        }



        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public List<int> ParseIntList(string[] x)
        {
            var convertedList = new List<int>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(int.Parse(x[i]));
            }

            return convertedList;
        }


        public List<double> ParseDoubleList(string[] x)
        {
            var convertedList = new List<double>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(double.Parse(x[i]));
            }

            return convertedList;
        }

        public List<long> ParseLongList(string[] x)
        {
            var convertedList = new List<long>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(long.Parse(x[i]));
            }

            return convertedList;
        }

        public int CountContainWords(string source, string word)
        {
            var count = 0;
            var loopCount = source.Length - (word.Length - 1);
            for (var i = 0; i < loopCount; i++)
            {
                if (source.Substring(i, word.Length) == word)
                {
                    count++;
                }
            }
            return count;
        }
    }
}

Measured memory_bytes: 17324
#include <stdio.h>
int main(void)
{
	int H, W;
	int h, w;
	
	scanf("%d %d",&H ,&W);
	do{
		for(h=1; h<=H; h++){
			for(w=1; w<=W; w++)
				printf("#");
			printf("\n");
		}
		printf("\n");
		scanf("%d %d",&H ,&W);
			
	}while(H!=0 && W!=0);
	return 0;
}

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

int main() {
  int N,M;
  cin>>N>>M;
  vector<int> count(100);
  
  for(int i=0;i<N;i++){
  	count.at(i+1)=0;
  }
  
  for(int i=0;i<M;i++){
  	int a,b;
    cin>>a>>b;
    count.at(a)++;
    count.at(b)++;
  }
  
  for(int i=0;i<N;i++){
  	cout<<count.at(i+1)<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
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;
}
const long long INF = 1LL << 60;
long long dp[100100][3];
int main(void){
	
    int N;cin>>N;
	for(int i=0;i<100100;i++){
    	for(int j=0;j<3;j++){
          dp[i][j]=0;
        }
    }
	long long h[N+100][3]={0};
    for(int i=0;i<N;i++){
    	for(int j=0;j<3;j++){
        	cin>>h[i][j];
        }
	}
    dp[0][0]=h[0][0];
	dp[0][1]=h[0][1];
	dp[0][2]=h[0][2];

    for(int i=1;i<N;i++){
      	for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
        		if(j==k)continue;
                chmax(dp[i][j],dp[i-1][k]+h[i][j]);
                
            }
        }
    }
    long long output;output=0;
    for(int i=0;i<3;i++){
    	chmax(output,dp[N-1][i]);
    }
                  
    cout<<output<<endl;
    return 0;
}


Measured memory_bytes: 4992
// "include" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>
// }}}

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 pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long 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 h,w,n;
	cin >> h >> w >> n;
	vector<int> a(n+1);
	vector<vector<int> > mas(h+1,vector<int>(w+1));
	reps(i,n){
		cin >> a[i];
	}
	int now = 1;
	reps(i,h){
		if(i % 2 == 0){
			for(int j = 1;j <= w;++j){
				mas[i][j] = now;
				a[now]--;
				if(a[now] == 0) ++now;
			}
		}
		else{
			for(int j = w;j >= 1;--j){
				mas[i][j] = now;
				a[now]--;
				if(a[now] == 0) ++now;
			}
		}
	}
	reps(i,h){
		reps(j,w){
			cout << ((j == 1) ? "" : " ") << mas[i][j];
		}
		cout<< '\n';
	}
	return 0;	
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define M 1000000007
#define pie 3.141592653589793238
using namespace std;


signed main(){  
    string s; cin >> s;
    if(s[0] == s[1] && s[1] ==  s[2] && s[1] == 'R'){
        cout << 3;
    }   
    else if((s[0] == s[1] || s[2] == s[1]) && s[1] == 'R' ){
        cout << 2;
    }
    else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R'){
        cout << 1;
    }
    else
        cout << 0;
    return 0;
}

Measured memory_bytes: 3624
A,B,C,D=map(int,input().split())
num = 0
while(A>=0 and C>=0):
    if A<= 100 and 0 <= B<= 100 and C<= 100 and 0 <= D<= 100:
        if num %2 == 0:
            C = C- B
            if C<=0:
                print("Yes")
                break
            num += 1
        elif num %2 !=0:
            A = A - D
            if A<=0:
                print("No")
                break
            num += 1
    else:
        break


Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9 + 7, A = 2e3 + 2;

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    while(n)
        n /= k, cnt++;
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX_STRING 100

	char sInput[MAX_STRING+1]="";
	int anX[200000];
	int anY[200000];
	int compar(const int *val1, const int *val2);

int main() {
//	char* psInput;

	int i=0;
	int j=0;
	int nMin=0;
	int nMax=0;
	int nNow=0;
	int nCount=0;
	int nNumber=0;
	int nMiddleIndex=0;
	int nTempMiddle=0;
	int nFirstMiddle=0;
	int nSecondMiddle=0;

	// read line 1
    scanf("%d", &nNumber);
	// read line 2
	for(i=0; i<nNumber; i++) {
        scanf("%d", &anX[i]);
		anY[i]=anX[i];
	}
	// sort
    qsort(anY, nNumber, sizeof(int),
        (int (*)(const void *, const void *))compar
    );
	nMiddleIndex=(nNumber/2)-1;
	nFirstMiddle=anY[nMiddleIndex];
	nSecondMiddle=anY[nMiddleIndex+1];

	if (nNumber==2){
		printf("%d\n%d\n",anX[1],anX[0]);
	} else {
		for (i=0; i<nNumber; i++){
			if(anX[i]<nFirstMiddle){
				printf("%d\n",nFirstMiddle);
			} else {
				printf("%d\n",nSecondMiddle);
			}
		}
	}

    return 0;
}
int compar(const int *val1, const int *val2) {
    if ( *val1 > *val2 ) {
        return -1;
    } else if ( *val1 == * val2 ) {
        return 0;
    } else {
        return 1;
    }
}

Measured memory_bytes: 3692
import java.util.Arrays;
import java.util.Scanner;

class Main {

    public static int getMinCost(int[] height, int k, int[] memo) {
        return getMinCostHelper(0, height,k, memo);
    }

    private static int getMinCostHelper(int i, int[] height, int k, int[] memo) {
        if(i == height.length - 1) {
            return 0;
        }

        if(memo[i] != -1) {
            return memo[i];
        }

        int costIncurred = Integer.MAX_VALUE;
        for(int index = i + 1; index <= i + k; index++) {
            if(index < height.length) {
                costIncurred = Math.min(costIncurred, Math.abs(height[index]-height[i]) + getMinCostHelper(index, height, k, memo));
            }
        }
        return memo[i] = costIncurred;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int numberOfStones = scanner.nextInt();
        int[] height = new int[numberOfStones];
        int k = scanner.nextInt();
        int[] memo = new int[numberOfStones];
        Arrays.fill(memo, -1);
        for(int i=0; i<numberOfStones; i++)
            height[i] = scanner.nextInt();
        System.out.println(getMinCost(height, k, memo));
    }

}


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

using namespace std;

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

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	ll x, k, d;
	cin >> x >> k >> d;
	ll move = (abs(x) + d - 1) / d;
	if (k >= move) {
	  ll p = abs(abs(x) - d * move);
	  ll q = abs(abs(x) - d * (move - 1));
	  cout << (k % 2 == move % 2 ? p : q) << endl;
	} else {
	  cout << abs(abs(x) - k * d) << endl;
	}
	
    
    return 0;
}



Measured memory_bytes: 3648
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n = int(input())
a = readints()
# print(a)
x = [0]*(10**5+10)
# print(x)
for i in range(n):
    x[a[i]-1] += 1
    x[a[i]] += 1
    x[a[i]+1] += 1
max_x = max(x)
print(max_x)


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

using namespace std;

int main() {
    const int num_of_towers = 999;
    vector<int> towers(num_of_towers);
    towers[0] = 1;
    for (int i = 1; i < num_of_towers; ++i)
        towers[i] = towers[i - 1] + (i + 1);

    int a, b;
    cin >> a >> b;

    int diff = b - a;
    int real_height = towers[diff - 1];
    cout << real_height - b << '\n';
}


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

int main(void){

    char s[10];
    int flg=0;
    int flg_c=0;

    scanf("%10s",s);

    int i,j;
    int length;

    i=0;
    length=strlen(s);

    //printf("length=%d\n",length);

    if(s[0]=='A'){
      for(i=2;i<=(length-2);i++){
        if(s[i]=='C'){
          flg++;
        }
      }
    //printf("flg==%d\n",flg);
    if(flg==1){
      for(j=0;j<length;j++){
       if(s[j]>=97&&s[j]<=122){
          flg_c++;
        }
      }
      //printf("flg_c==%d\n",flg_c);
      if(flg_c==(length-2)){
        printf("AC");
      }else{
        printf("WA");
      }
    }else{
      printf("WA");
    }
 }else{
  printf("WA");
  }

 return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

ll MOD = 1e9+7;

int main()
{
    ll N,M;
    cin >> N >> M;
    if(abs(N-M) > 1){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1LL;
    for(int i=1; i<=N; i++){
        ans *= i;
        ans %= MOD;
    }
    if(N == M){
        ans *= ans;
        ans %= MOD;
        ans *= 2;
        ans %= MOD;
    }else{
        ll cnt = 1LL;
        for(int i=1; i<=M; i++){
            cnt *= i;
            cnt %= MOD;
        }
        ans *= cnt;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
        using namespace std;
        long long n,ans,pref[4001][3],vals[4001];
        string s;
         
        int main(){
            cin >> n >> s;
            for(int i = 0 ; i < n ; i += 1){
                if(s[i] == 'R'){
                    vals[i] = 0;
                }else if(s[i] == 'G'){
                    vals[i] = 1;
                }else{
                    vals[i] = 2;
                }
            }
            for(int i = n-1 ; i >= 0 ; i -= 1){
                for(int j = 0 ; j < 3 ; j += 1){
                    pref[i][j] = pref[i+1][j];
                }
                pref[i][vals[i]] += 1;
            }
            for(int i = 0 ; i+1 < n ; i += 1){
                for(int j = i+1 ; j < n ; j += 1){
                    if(vals[j] == vals[i]){
                        continue;
                    }
                    ans += pref[j][3-vals[i]-vals[j]];
                    if(2*j-i < n && vals[2*j-i] == 3-vals[i]-vals[j]){
                        ans -= 1;
                    }
                }
            }
            cout << ans << endl;
        }

Measured memory_bytes: 3756
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int partition(vector< pair<int,char> >& A, int p, int r) {
	int x = A[r].first;
	int ind = p-1;
	for (int i = p; i < r; ++i) {
		if (A[i].first <= x) {
			++ind;
			swap(A[i].first,A[ind].first);
			swap(A[i].second,A[ind].second);
		}
	}
	swap(A[r].first,A[ind+1].first);
	swap(A[r].second,A[ind+1].second);
	return (ind+1);
}

void quick_sort(vector< pair<int,char> >& A, int p, int r) {
	if (p < r) {
		int q = partition(A,p,r);
		quick_sort(A,p,q-1);
		quick_sort(A,q+1,r);
	}
	return;
}

int main(void) {
	int n;
	cin >> n;
	map<int,string> ms;
	vector< pair<int,char> > A(n);
	for (int i = 0; i < n; ++i) {
		cin >> A[i].second;
		cin >> A[i].first;
		ms[A[i].first] += A[i].second;
	}
	quick_sort(A,0,n-1);

	map<int,int> mi;
	bool stable = true;
	for (int i = 0; stable && i < n; ++i) {
		if (ms[A[i].first][mi[A[i].first]] != A[i].second) {
			stable = false;
		}
		else {
			++mi[A[i].first];
		}
	}
	if (stable) {
		cout << "Stable" << endl;
	}
	else {
		cout << "Not stable" << endl;
	}
	for (int i = 0; i < n; ++i) {
		cout << A[i].second << " ";
		cout << A[i].first << endl;
	}

	return 0;
}



Measured memory_bytes: 6316
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

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

    bitset<20000> B;
    rep(i,N) {
        for (int j = A[i]-M; j < A[i]+M; ++j) {
            B[j] = 1;
        }
    }
    int ans = 0;
    rep(i,T) {
        if (!B[i]) ans++;
    }
    cout << ans << ln;
}



Measured memory_bytes: 3216
#include <stdio.h>
 
int main(void)
{
 
   int a, b, c;
   
   scanf("%d %d %d", &a, &b, &c);
 
 
   if( a < b ){
      if( b < c ){
         printf("Yes");
      }else{
         printf("No");
      }
   }else{
      printf("No");
   }
 
   printf("\n");
 
   return 0;
}
 

Measured memory_bytes: 584
import sys
import numpy as np

def power_table(MOD, w, size):
    w_table = [0] * size
    w_table[0] = 1
    for i in range(1, size):
        w_table[i] = w_table[i - 1] * w % MOD
    return w_table

def numpy_ntt(MOD, w_table, data, scale=None):
    size = data.size
    step = 1
    while step < size:
        batch_size = size // (step * 2)
        data = data.reshape(step * 2, -1)
        odd = data[0::2]
        even = data[1::2]
        w1 = w_table[0:size // 2:batch_size]
        w2 = w_table[size // 2:size:batch_size]
        sub1 = (odd + even * w1) % MOD
        sub2 = (odd + even * w2) % MOD
        data = np.concatenate((sub1, sub2))
        step *= 2
    if scale is not None:
        data = data * scale % MOD
    return data.flatten()

def read_data():
    int_gen = (int(s) for s in sys.stdin.read().split())

    n = next(int_gen)

    graph = [[] for _ in range(n)]
    for a, b in zip(int_gen, int_gen):
        a -= 1
        b -= 1
        graph[a].append(b)
        graph[b].append(a)

    size_table = [1] * n

    ret = 0
    stack = [None, 0, 0]

    while True:
        node = stack[-1]
        index = stack[-2]
        size_table[node] += ret
        if index < len(graph[node]):
            dtr = graph[node][index]
            stack[-2] += 1
            if dtr != stack[-3]:
                stack.extend((0, dtr))
            ret = 0
        else:
            del stack[-2:]
            if len(stack) <= 1: break
            ret = size_table[node]

    g = [0] * n
    for s in size_table:
        if s != n:
            g[s - 1] += 1
            g[n - s - 1] += 1
    return (n, g)


def solve():
    MOD = 924844033

    def pow_mod(a, n):
        ret = 1
        while n != 0:
            if n % 2 == 1: ret = ret * a % MOD
            a = a * a % MOD
            n //= 2
        return ret

    n, answer = read_data()

    fac = [0] * (n + 1)
    fac[0] = 1
    for i in range(1, n + 1):
        fac[i] = fac[i - 1] * i % MOD

    ifac = [0] * (n + 1)
    ifac[n] = pow_mod(fac[n], MOD - 2)
    for i in range(n, 0, -1):
        ifac[i - 1] = ifac[i] * i % MOD

    def comb(x, y):
        return fac[x] * ifac[y] % MOD * ifac[x - y] % MOD

    for i in range(n):
        answer[i] = answer[i] * fac[i + 1] % MOD
    answer.reverse()

    ntt_size = 1
    while ntt_size <= n * 2: ntt_size *= 2

    w_table = power_table(MOD, pow_mod(5, MOD // ntt_size), ntt_size)

    np_w_table = np.array(w_table).reshape(-1, 1)
    ifac_ntt = numpy_ntt(MOD, np_w_table, np.array(ifac[:n] + [0] * (ntt_size - n)))
    answer_ntt = numpy_ntt(MOD, np_w_table, np.array(answer + [0] * (ntt_size - n)))

    answer_ntt = answer_ntt * ifac_ntt % MOD

    for i in range(1, ntt_size // 2):
        w_table[i], w_table[ntt_size - i] = w_table[ntt_size - i], w_table[i]
    answer = numpy_ntt(MOD, np.array(w_table).reshape(-1, 1), answer_ntt, pow_mod(ntt_size, MOD - 2)).tolist()

    for i in range(1, n + 1):
        a = n * comb(n, i)
        b = answer[n - i] * ifac[i]
        print((a - b) % MOD)

solve()


Measured memory_bytes: 109528
import java.util.*;
public class Main{
   public static void main(String[] args) {
     Scanner sc = new Scanner(System.in);
     int   n = sc.nextInt();
     int m = sc.nextInt();
     for(int i=0;i<m;i++){
       n-=sc.nextInt();
     }
     if(n>=0){
      System.out.println(n) ;
    } else{
      System.out.println(-1);
    }
   }
}


Measured memory_bytes: 46248
n=int(input())
s=[]
while n!=0:
    x=n%26
    if x!=0:
        s.append(chr(96+x))
        n=n//26
    if x==0:
        s.append(chr(122))
        n=(n-1)//26
        
    
m=len(s)
ans=s[m-1]
if m==1:
    print(ans)
    exit()

for i in range(m-1):
    ans+=s[m-2-i]
print(ans)

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];

    bool ans = a[0] == a[1] && a[1] == a[2];

    cout << (ans? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
    	Scanner sc= new Scanner(System.in);
    int n=sc.nextInt(),m=sc.nextInt();
    int a[][]=new int[n][m];
    int b[]=new int[m];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++)a[i][j]=sc.nextInt();
    }
    for(int i=0;i<m;i++){
    	b[i]=sc.nextInt();
    }
    for(int i=0;i<n;i++){
    	int out=0;
    	for(int j=0;j<m;j++){
    		out+=a[i][j]*b[j];
    	}
    	System.out.println(out);
    }
    }
}

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int N;
    cin >>N;

    vector<int> A(N+1),B(N+1,0),C(N+1,0);
    repd(i,1,N+1) cin >> A[i];
    for(int t=N;t>0;t--){
        C[t]=A[t]^B[t];
        if(C[t] && t!= 1){
            for (int i = 1; i * i <= t; i++) {
                if (t % i) continue;
                B[i]^=1;
              //  cout <<" " <<i<< "-"<<t<<endl;
                if (i!=1&&i * i != t){
                    B[t/i]^=1;

                //cout <<" " <<t/i<< "-"<<t<<endl;
                }
            }
        }
    }
  //  dbg_v1(k,B);
    queue<int> x;
    repd(i,1,N+1){
      if(C[i]) x.push(i);
    }
    cout<<x.size()<<endl;
    while(!x.empty()){
        cout<<x.front()<<endl;
        x.pop();
    }

    return (0);
}

Measured memory_bytes: 3712