akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define f(i,x,n) for(ll i=x;i<n;i++)
#define fl(i,x,n) for(ll i=n;i>=x;i--)
#define mod (ll)1e9+7
#define print(x) cout<<x<<endl
#define vec vector<ll>
#define pai pair<ll, ll>
#define itr(it) :: iterator it
#define MAX (ll)1e16
#define MIN (ll)-1e16
#define X first
#define Y second
#define up upper_bound
#define lo lower_bound
using namespace std;
       ///////////   ///     ///   ///      ///   ////////////  ///      ///
       ///           ///     ///   ///      ///   ///      ///  ///      ///
       ///           ///     ///   ///      ///   ///      ///  ///      ///
       ///////////   ///////////   ///      ///   ////////////  ////////////
               ///   ///     ///   ///      ///   ///      ///  ///      ///
               ///   ///     ///   ///      ///   ///      ///  ///      ///
       ///////////   ///     ///   ////////////   ////////////  ///      ///
ll minn( ll a , ll b) 
{
    if(a>b)
        return b;
    return a;
}
ll maxx2( ll a , ll b)
{
    if(a>b)
        return a;
    return b;
}
ll maxx(ll a,ll b,ll c)
{
  return maxx2(a,maxx2(b,c));
}
ll gcdd(ll a, ll b)
{
    if(b==0)
        return a;
    else
        return gcdd(b,a%b);
}
ll dsum(ll n)
{
    ll sum=0;
    while(n>0)
    {
        sum+=n%10;
        n/=10;
    }
    return sum;
}
ll poww(ll a,ll b)
{
    if(b<=0)
        return 1;
    if(b==1)
        return a;
    else
        return poww(a,b/2)*poww(a,b/2)*poww(a,b%2);
}
ll sumsq(ll x,ll y,ll z)
{
    return (x-y)*(x-y)+(y-z)*(y-z)+(z-x)*(z-x);
}
ll n,w,a[101],c[101],dp[101][100001]={0};
signed main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    IOS;
    cin>>n>>w;
    f(i,1,n+1)
    {
        cin>>a[i]>>c[i];
    }
    f(i,0,101)
    {
        f(j,0,100001)
        {
            dp[i][j]=10000000000;
        }
    }
    dp[0][0]=0;
    f(i,1,n+1)
    {
        f(j,0,100001)
        {
        	//cout<<i<<" "<<j<<endl;
            if((j-c[i])>=0)
            {
                dp[i][j]=minn(dp[i-1][j-c[i]]+a[i],dp[i][j]);
            }
            dp[i][j]=minn(dp[i][j],dp[i-1][j]);
        }
    }
    //cout<<dp[2][30]<<endl;
    fl(i,0,100000)
    {
        if(dp[n][i]<=w)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int CountOfExam = 0;
	cin >> CountOfExam;
    int AC = 0;
  	int WA = 0;
  	int TLE = 0;
  	int RE = 0;
	for(int i = 1; i <= CountOfExam; i++)
    {
      string currentString;
      cin >> currentString;
      if(currentString == "AC") AC++;
      if(currentString == "WA") WA++;
      if(currentString == "TLE") TLE++;
      if(currentString == "RE") RE++;
    }
  
	std::cout << "AC x " << std::to_string(AC) << "\n";
	std::cout << "WA x " << std::to_string(WA) << "\n";
	std::cout << "TLE x " << std::to_string(TLE) << "\n";
	std::cout << "RE x " << std::to_string(RE) << "\n";
  
  return 0;
}

Measured memory_bytes: 3700
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>

#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n;
    scanf("%d", &n);

    printf("%d\n", 1 - n);


    return;
}

int main()
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for (t = 0; t < T; t++) {
        //printf("Case #%d: ", t + 1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 1712
#include<iostream>
#include<cstdio>
using namespace std;
const int oo=1000000007;
struct edg{int nxt,y,v;}e[410000];  int lk[110000],ltp=0;
void ist(int x,int y,int z){
	e[++ltp]=(edg){lk[x],y,z};  lk[x]=ltp;
	e[++ltp]=(edg){lk[y],x,z};  lk[y]=ltp;
}
struct nds{
	int x,y;
	bool operator<(nds z){  return x<z.x;}
}hp[410000];  int sz=0;
void psh(nds z){
	hp[++sz]=z;
	for(int i=sz;i!=1 && hp[i]<hp[i>>1];i>>=1)  swap(hp[i],hp[i>>1]);
}
void pp(){
	hp[1]=hp[sz--];
	int x=1,mn=1;
	for(;;){
		mn=x;
		if((x<<1)<=sz && hp[x<<1]<hp[mn])  mn=(x<<1);
		if((x<<1|1)<=sz && hp[x<<1|1]<hp[mn])  mn=(x<<1|1);
		if(mn==x)  break;
		swap(hp[mn],hp[x]);
		x=mn;
	}
}
int n,m;
int dstc[110000],lst[110000];
void dij(int x){
	sz=0;
	for(int i=1;i<=n;++i)  dstc[i]=oo;
	dstc[x]=0;
	psh((nds){x,0});
	while(sz){
		while(sz && hp[1].y>dstc[hp[1].x])  pp();
		//最大队列长度为边数，因为每个边至多松弛一次
		//每松弛一次加一个点入队
		if(!sz)  break;
		x=hp[1].x;  dstc[x]=hp[1].y;  //x复用警告
		pp();
		for(int i=lk[x];i;i=e[i].nxt)if(dstc[x]+e[i].v<dstc[e[i].y]){
			dstc[e[i].y]=dstc[x]+e[i].v;
			psh((nds){e[i].y,dstc[e[i].y]});
			lst[e[i].y]=x;
		}
	}
}
int main(){
	cin>>n>>m;
	int l,r;
	while(m --> 0){
		scanf("%d%d",&l,&r);
		ist(l,r,1);
	}
	dij(1);
	printf("Yes\n");
	for(int i=2;i<=n;++i)  printf("%d\n",lst[i]);
	return 0;
}




Measured memory_bytes: 11712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int main(){
	char c;
	cin>>c;
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
		cout<<"vowel";
	}
	else cout<<"consonant";
	return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)
/*
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
*/

// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    UnionFind u(N);
    rep(i,0,M) {
        int A, B;
        cin >> A >> B;
        u.merge(A-1,B-1);
    }
    int ans = 1;
    rep(i,0,N) {
        ans = max((ll)ans, u.size(i));
    }
    cout << ans << endl;
}

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

int main() {
	string s;
	cin >> s;
	if (s[0] == s[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(ll i=start;i<end;i++)
#define N 100001
#define all(v) v.begin(),v.end()
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ov(a) for(ll i=0;i<a.size();i++)cout<<a[i]<<" ";nl
int main() 
{
    fastio();


    map<vector<ll>,ll>mp;
    ll n;
    cin>>n;
    while(n--)
    {
    	string s;
    	cin>>s;
    	vector<ll>temp(26,0);
    	for(auto i:s)temp[i-'a'] ++;
    	mp[temp]++;
    }
    ll ans = 0;
    for(auto i:mp)
    	ans+=i.second*(i.second-1)/2;
    cout<<ans;

	return 0;
}

Measured memory_bytes: 29952
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, k, a, b, dec = 1;
	cin >> n >> k;
	
	for(int i = 0; i < n; i++){
		a = dec * 2;
		b = dec + k;
		dec = min(a, b);
	}
	
	cout << dec;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, s, e) for(int i=s; i>=e; i--)
#define reps(i, s, e) for(int i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
#define enl << endl
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*(b/gcd(a, b)); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    ll n;
    cin >> n;

    ll num = 1;
    reps(i, 1, sqrt(n)){
        if(n%i == 0){
            num = i;
        }
    }

    ll res = max(keta(num), keta(n/num));

    //cout << num sp n/num << endl;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
// AOJ 2135 Reverse a Road
// 2018.2.26 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define QMAX 15000
typedef struct { short t, s, r; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && (que[l].t < que[i].t ||
		que[l].t == que[i].t && que[l].r < que[i].r)) min = l; else min = i;
	if (r < qsize && (que[r].t < que[min].t ||
		que[r].t == que[min].t && que[r].r < que[min].r)) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, int t, int r)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t, que[i].r = r;
	while (i > 0 && (que[min = PARENT(i)].t > que[i].t ||
		   que[min].t == que[i].t && que[min].r > que[i].r)) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

short hi[1002], *to[1002], *no[1002];
char mk[1002][1002][2];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int dijkstra(int *rno, int start, int goal)
{
	int i, s, t, r, e, k;

	memset(mk, 0, sizeof(mk));
	qsize = 0;
	enq(start, 0, 0);
	while (qsize) {
		s = que[0].s, t = que[0].t, r = que[0].r, deq();
		if (s == goal) { *rno = r; return t; }

		if (r == 0) {
			for (i = 0; i < hi[s]; i++) {
				e = to[s][i], k = no[s][i];
				if (k > 0) {
					if (!mk[e][k][0]) mk[e][k][0] = 1, enq(e, t+1, 0);
				} else {
					if (!mk[s][-k][1]) mk[s][-k][1] = 1, enq(e, t+1, -k);
				}
			}
		} else {
			for (i = 0; i < hi[s]; i++) {
				e = to[s][i], k = no[s][i];
				if (k > 0 && !mk[e][k][1]) mk[e][k][1] = 1, enq(e, t+1, r);
			}
		}
	}
	return -1;
}

int main()
{
	int N, S, T, M, a, b, i, j, k, ans;
	short *memo;

	while (N = in()) {
		N++, S = in(), T = in();
		M = in();

		memo = malloc(M << 2);
		memset(hi, 0, N << 1);
		j = 0, i = M; while (i--) {
			memo[j++] = a = in(), memo[j++] = b = in();
			hi[a]++, hi[b]++;
		}

		for (a = 0; a < N; a++) if (hi[a]) {
			to[a] = malloc(hi[a] << 1);
			no[a] = malloc(hi[a] << 1);
		}
		memset(hi, 0, N << 1);
		j = 0; for (i = 1; i <= M; i++) {
			a = memo[j++], b = memo[j++];
			k = hi[a]++, to[a][k] = b, no[a][k] =  i;
			k = hi[b]++, to[b][k] = a, no[b][k] = -i;
		}
		free(memo);

		ans = dijkstra(&k, S, T);
		printf("%d %d\n", ans, k);
	}
	return 0;
}


Measured memory_bytes: 4756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define enum(i,x,y) for(register int i=(x);i<=(y);++i)
#define try(i,x,y) for(register int i=(x);i>=(y);--i)
template <typename TYPE> inline void chkmax(TYPE &x,TYPE y){x<y?x=y:0;}
template <typename TYPE> inline void chkmin(TYPE &x,TYPE y){y<x?x=y:0;}
template <typename TYPE> void readint(TYPE &x)
{
    x=0;int f=1;char c;
    for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=x*10+c-'0';
    x*=f;
}
const int MAXN=3005;
const double pi=acos(-1);

int n,L;
long double a[MAXN];

int main()
{
	#ifndef ONLINE_JUDGE
    //freopen("code.in","r",stdin);
    //freopen("code.out","w",stdout);
	#endif
	readint(n);readint(L);
	enum(i,1,n)
	{
		scanf("%Lf",&a[i]);
		a[i]=2*pi*a[i]/L;
	}
	sort(a+1,a+n+1);
	long double x=0,y=0;
	enum(i,1,n)
		enum(j,i+1,n)
		{
			double b=(a[i]+a[j])/2;
			x+=((n-j+i-1)-(j-i-1))*cos(b)/n;y+=((n-j+i-1)-(j-i-1))*sin(b)/n;
		}
	printf("%.15Lf %.15Lf\n",x*6/((n-1)*(n-2)),y*6/((n-1)*(n-2)));
    return 0;
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  int n; cin>>n;
  ll x=2; ll y=1;
  n--;
  while(n--) {
    ll z = x+y;
    x=y;
    y=z;
  }
  out(y);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>

using namespace std;
#define LL long long
#define LLBIG 1999999999999999999
#define INTBIG 100000000
#define VI vector<int>
#define VVI vector<vector<int>>

int main() {
	while (true) {
		int n; cin >> n;
		if (!n)break;
		int cost[10][10];
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				cost[i][j] = INTBIG;
				if (i == j) cost[i][j] = 0;
			}
		}
		for (int i = 0; i < n; i++) {
			int a, b, c;
			cin >> a >> b >> c;
			cost[a][b] = cost[b][a] = c;
		}
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				for (int k = 0; k < 10; k++) 
					cost[i][j] = cost[j][i] = min(cost[i][j], cost[i][k] + cost[k][j]);
			}
		}
		int id = 0, sum = INTBIG;
		for (int i = 0; i < 10; i++) {
			int tmp = 0; bool flg = false;
			for (int j = 0; j < 10; j++) {
				if (i != j && cost[i][j] != INTBIG) {
					flg = true;
					tmp += cost[i][j];
				}
			}
			if (sum > tmp && flg) {
				sum = tmp; id = i;
			}
		}
		cout << id << " " << sum << endl;
	}

	return 0;
}


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

int isPrime(int n) {
	int cnt = 0;
	for(int k= n+1;k<=2*n;k++){
		for (int i = 2; i*i <= k; i++) {
			if (k%i == 0) {
				cnt++;
				break;
			}
		}
	}

	cout << (2*n)-(n)-cnt << endl;
	return cnt;
}

int main() {
	
	while (1) {
		int n;

		cin >> n;

		if (n == 0)
			break;

		isPrime(n);

	}
	return 0;
}

Measured memory_bytes: 3064
# coding: utf-8

A = int(input()) #500円玉の枚数
B = int(input()) #100円玉の枚数
C = int(input()) #50円玉の枚数
X = int(input()) #50の倍数

X = X / 50

num = 0 #条件を満たす通り数

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if X == i * 10 + j * 2 + k:
                num += 1

print(num)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int res = 1;
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 1; i < n; i++) {
        if (s[i] != s[i - 1]) {
            res++;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 512
n,x= list(map(int,input().split(" ")))
As = [1]
Ps = [1]
for i in range(n):
    As.append(As[i] * 2 + 3)
    Ps.append(Ps[i] * 2 + 1)

def rec(N,X):


    if X == 0:
        return 0
    if N == 0:
        return 1
    if X == 1:
        return 0
    if 1 < X <=As[N-1] + 1:
        return rec(N-1,X-1)

    if X == As[N-1] + 2:
        return Ps[N-1] + 1

    if As[N-1] + 2 < X < 2 * As[N-1] + 3:
        return Ps[N-1] + 1 + rec(N-1,X -As[N-1] -2)

    if X == 2*As[N-1] + 3:
        return 2 * Ps[N-1] + 1


ans = rec(n,x)
print(ans)

Measured memory_bytes: 38384
import sys

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


N = int(sys.stdin.readline().strip())

decomposed = factorization(N)
# print(decomposed)

if decomposed == [[1, 1]]:
	print(0)
	sys.exit()

ans = 0
for factor, count in decomposed:
	for i in range(10000):
		if count < i*(i+1) // 2:
			ans += i-1
			break

print(ans)

Measured memory_bytes: 63376
#include<iostream>
#include<cstring>
#include<cstdio>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int main()
{
    int n,L;
    while(cin >> n>> L)
    {
        string s[110];
        int a[110];
        for(int i= 0;i < n;i ++)
        {
            cin >> s[i];
            a[i] = (int)s[i][0];
        }
        sort(s,s+n);
        for(int i= 0;i < n;i++)
        {
            cout << s[i];
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N;
    while(cin>>N){
        if(!N)break;
        int cou[10]={0};
        for(int i=0;i<N;i++){
            int a;
            cin>>a;
            cou[a]++;
        }
        for(int i=0;i<10;i++){
            if(cou[i]==0)cout<<"-"<<endl;
            else{
                for(int j=0;j<cou[i];j++)cout<<"*";
                puts("");
            }
        }
    }
}

Measured memory_bytes: 1120
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    vector<ll> a(M,0);
    vector<ll> b(M,0);
    vector<ll> c(M,0);
    for(ll i=0;i<M;++i){cin>>a[i]>>b[i]>>c[i];a[i]--;b[i]--;}
    vector<vector<ll>> d(N, vector<ll>(N, INF));
    for(ll i=0;i<N;++i)d[i][i]=0;
    for(ll i=0;i<M;++i){
        d[a[i]][b[i]]=c[i];
        d[b[i]][a[i]]=c[i];
    }

    //ワーシャルフロイド法
    for(ll i=0;i<N;++i)
            for(ll j=0;j<N;++j)
                for(ll k=0;k<N;++k)chmin(d[j][k],d[j][i]+d[i][k]);
    
    ll ans=0;
    for(ll i=0;i<M;++i)if(d[a[i]][b[i]]<c[i])ans++;
    prt(ans)

    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner

fun main(args: Array<String>){
    val sc = Scanner(System.`in`)
    val A = sc.nextInt()
    val B = sc.nextInt()
    if((A + B) % 2 == 0){
        println((A+B)/2)
    }else{
        println("IMPOSSIBLE")
    }
}

Measured memory_bytes: 31404
def solve(n, As):
    odd = As[1::2]
    even = As[::2]
    if n % 2 == 0:
        return " ".join(map(str, odd[::-1] + even))
    else:
        return " ".join(map(str, even[::-1] + odd))

if __name__ == "__main__":
    n = int(input())
    As = list(map(int, input().split(" ")))
    print(solve(n, As))


Measured memory_bytes: 31300
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<int, int>;

int n;
string s;
int cnt, cst;
const ll mod = 1000000007;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll ans = 1;
    cin >> n >> s;
    for(char ch : s)
    {
        if((cnt % 2 == 0) == (ch == 'B'))
        {
            cnt++;
        }
        else
        {
            ans = ans * cnt % mod;
            cnt--;
            if(cnt < 0) break;
        }
    }
    if(cnt){
        cout << 0;
    }
    else
    {
        for(int i=1;i<=s.length()/2;i++)
        {
            ans = i * ans % mod;
        }
        cout << ans;
    }
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define pii pair <int,int>
#define vpii vector< pair<int,int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	int n, i;
	string s, t, ans;
	cin >> n;
	cin >> s >> t;
	fo(i, 0, n){
		ans.pb(s[i]);
		ans.pb(t[i]);
	}
	cout << ans;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = 10**6#float('inf')
#mod = 10 ** 9 + 7 
mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

#階乗#
lim = 50
fact = [1] * (lim+1)
for n in range(1, lim+1):
	fact[n] = n * fact[n-1]

def C(n, r):
	return fact[n]//fact[n-r]//fact[r]


N, A, B = MAP()
v = sorted(LIST(), reverse=True)

V_cnt = Counter(v)
V_max = Counter(v[:A])
key = v[A-1]
print(sum(v[:A])/A)

v = v[::-1]

idx_1 = bisect_left(v, key)
idx_2 = bisect(v, key)
n = idx_2 - idx_1
k = bisect(v, key)
m = N - k


if m == 0:
	ans = 0
	for i in range(A, min(B-m, n)+1):
		ans += C(n, i)
	print(ans)
else:
	print(C(n, A-m))

Measured memory_bytes: 10088
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
	string a,b;
    cin >> a >> b;
    reverse(b.begin(),b.end());
    cout << ((a == b) ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <deque>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <climits>

using namespace std;

int main(){
    int n;
    long long a, b;
    cin >> n >> a >> b;
    vector<int> xs(n);
    for(int i=0; i<n; ++i){
        cin >> xs[i];
    }
    long long ans=0;
    for(int i=0; i<n-1; ++i){
        ans+=min((xs[i+1]-xs[i])*a, b);
    }
    cout << ans << endl;
    return 0;
}


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

#define MAX_N 100000
#define MAX_M 100000
typedef long long int ll;

std::vector< std::pair<ll, std::pair<int, int>> > data;
std::vector<int> counts(MAX_N + 1, 1);
ll ids[MAX_N];

void printID(ll id) {
  ll tmp = id;
  int digit = 0;
  while(tmp > 0) {
    tmp /= 10;
    ++digit;
  }

  for(int i = 0; i < 12 - digit; ++i) {
    std::cout << 0;
  }
  std::cout << id << std::endl;
}

int main() {
  int n, m;

  std::cin >> n >> m;
  for(int i = 0; i < m; ++i) {
    int p;
    ll y;
    std::cin >> p >> y;

    data.push_back(std::make_pair(y, std::make_pair(p, i)));
  }
  std::sort(data.begin(), data.begin() + m);

  for(int i = 0; i < m; ++i) {
    auto d = data[i];
    ids[(d.second).second] = 1000000LL * (d.second).first + counts[(d.second).first];
    ++counts[(d.second).first];
  }

  for(int i = 0; i < m; ++i) {
    printID(ids[i]);
  }
}

Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n;
    string s;
    cin >> n >> s;
    int a = 0, b = 0;
    rep(i,n) if(s[i] == 'R') a++;
    int ans = a;
    rep(i,n){
        if(s[i] == 'R') a--;
        else b++;
        ans = min(ans, max(a, b));
    }
    cout << ans << endl;
}

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

using Graph = vector<vector<int>>;
int N, Q;
Graph G;

void dfs(int v, int p, vector<long long> &res) {
  if (p != -1) res[v] += res[p];
  for (auto e : G[v]) {
    if (e == p) continue;
    dfs(e, v, res);
  }
}

int main() {
  cin >> N >> Q;
  G.assign(N, vector<int>());
  for (int i = 0; i < N-1; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<long long> val(N, 0);
  for (int i = 0; i < Q; ++i) {
    int p, x;
    cin >> p >> x;
    --p;
    val[p] += x;
  }
  dfs(0, -1, val);
  for (auto v : val) cout << v << " ";
  cout << endl;
}

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

typedef long long ll;

ll N, M;

ll lcm(ll number1, ll number2){
	return number1 * number2 / std::__gcd(number1, number2);	
}

int f(int x) {
    int ans = 0;
    while (x % 2 == 0 && x > 0) {
        x /= 2;
        ans++;
    }

    return ans;
}

int main() {
    // cout << (14 >> 2) << endl;
    // return 0;
    // int d = f(0);
    // int d2 = f(12);
    // cout << d << endl;
    // cout << d2 << endl;
    // return 0;

    cin >> N >> M;
    vector<ll> a(N);

    rep(i, N) {
        cin >> a[i];
    }

    rep(i, N) {
        a[i] /= 2;
    }

    // 奇数で計算できるようにするため 2で何回割れるか数える    
    int t = f(a[0]);
    for (int i = 0; i < a.size(); i++) {
        int tmp = f(a[i]);    
        if (t != tmp) {
            cout << 0 << endl;
            return 0;
        }

        a[i] >>= t;
    }
    M >>= t;

    int num = a[0];
    for (int i = 1; i <= a.size() - 1; i++) {
        if (num > M) {
            cout << 0 << endl;
            return 0;
        }
        num = lcm(num, a[i]);    
    }

    int x = M / num;
    cout << (x + 1) / 2 << endl;
}

Measured memory_bytes: 1024
s = gets.chomp
l = s.size
s_arr = s.split('')

n_1_arr = s_arr[0...(l-1)/2]
n_3_arr = s_arr[(l+3)/2-1..l]

if s_arr == s_arr.reverse && n_1_arr == n_1_arr.reverse && n_3_arr == n_3_arr.reverse
  print('Yes')
else
  print('No')
end

Measured memory_bytes: 1788
X,Y,Z,K = gets.chomp.split(" ").map(&:to_i)
A = gets.chomp.split(" ").map(&:to_i).sort!
B = gets.chomp.split(" ").map(&:to_i).sort!
C = gets.chomp.split(" ").map(&:to_i).sort!

i = 0
d = []
A.each do |ax|
  B.each do |by|
    d[i] = ax + by
    i += 1
  end
end

d.sort!.reverse!
d.slice!(K, d.length) if d.length >=  K

j = 0
sum = []
d.each do |e|
  C.each do |cz|
    sum[j] = e + cz
    j += 1
  end
end

sum.sort!.reverse!

(0..K-1).each do |i|
  puts sum[i]
end

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

int main(void)
{
    int n, m, i, j, k, a; cin >> n >> m;
    int ans = 0;
    vector<int> food(m + 1);
    for (i = 0; i < m; i++) food.at(i) = 0;

    for (i = 0; i < n; i++) {
        cin >> k;
        for (j = 0; j < k; j++) {
            cin >> a;
            food.at(a - 1) += 1;
        }
    }

    for (i = 0; i < m; i++) {
        if (food.at(i) == n) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        FastReader scan = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        Task solver = new Task();
        int t = 1;
        while (t --> 0) solver.solve(1, scan, out);
        out.close();
    }
 
    static class Task {
 
        public void solve(int testNumber, FastReader scan, PrintWriter out) {
            long a = scan.nextLong(), s = 0;
            int b = scan.nextInt();
            while(b --> 0) s += scan.nextLong();
            out.println(s >= a ? "Yes" : "No");
        }
    }
 
    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }
 
    static void shuffle(long[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            long temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }
 
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        public FastReader(String s) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(new File(s)));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
 
}

Measured memory_bytes: 33560
#include<iostream>
using namespace std;
 
int main()
{
	// input
	int n;
	cin >> n;
	int A[n] = { };
	int outp[n] = { };
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}

	//processing
	for (int x = 1; x <= n; x++) {
		outp[(A[x - 1] - 1)] = x;
	}

	//output
	if (n > 0) {
		cout << outp[0];
	}
	if (n > 1) {
		for (int i = 1; i < n; i++) {
			cout << " " << outp[i];
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1536
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		ArrayList<Integer> num = new ArrayList<Integer>();
		Scanner scan = new Scanner(System.in);
		int kazu = 0 ;

		while(scan.hasNext()){
			kazu = scan.nextInt();
			if(kazu != 0){
			num.add(kazu);
			}else{
				System.out.println(num.get(num.size() - 1));
				num.remove(num.size() - 1);

			}
		}

	}

}

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

int main(){
  int k,n;
  cin >> n >> k;
  vector<int> p(n);
  for(int i = 0; i < n; i++) cin >> p[i];
  sort(p.begin(),p.end());
  long long ans = 0;
  for(int i = 0; i < k; i++) ans+=p[i];
  cout << ans << endl;
  return 0;
}

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

void call(int n){
	int count=1,x;
	while(1){
		x=count;
		if(x%3==0){
			printf(" %d",count);
		}else if(x%10==3){
			printf(" %d",count);
		}else{
			while(1){
				x/=10;
				if(x){
					if(x%10==3){
						printf(" %d",count);
						break;
					}
				}else{
					break;
				}
			}
		}

		if(++count > n){
			break;
		}
		
	}
	printf("\n");
}

int main(){
	int n;

	scanf("%d",&n);

	call(n);
	
	return 0;
}


Measured memory_bytes: 2112
#include <cstdio>
#include <algorithm>
using namespace std;
struct map {int n, s; };
bool comp(const map& a, const map& b) {
    return a.s>b.s;
}
map x[5];
int main() {
    int s1, s2;
    while (scanf("%d%d",&s1,&s2)) {
        if (!s1&&!s2) break;
        x[0]=(map){0,s1+s2};
        for (int i=1; i<5; i++) {
            scanf("%d%d",&s1,&s2);
            x[i]=(map){i,s1+s2};
        }
        sort(x,x+5,comp);
        printf("%c %d\n",x[0].n+'A',x[0].s);
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i,N) repf(i,0,N)
#define reps(i,N) repfs(i,1,N)
#define repf(i,a,b) for(int i=a;i<b;i++)
#define repfs(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,N) for(int i=N-1;i>=0;i--)
#define reprs(i,N) for(int i=N;i>0;i--)
#define pb push_back
#define pob pop_back

template<typename T> 
void chmax(T &a,T b){ a = max(a, b);};
template<typename T> 
void chmin(T &a,T b){ a = min(a, b);};

typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int n;

void solve(){
	int ans=0;
	int m=-1;
	rep(i,n){
		int a;
		cin>>a;
		ans+=a;
		chmax(m,a);
	}
	ans-=m/2;
	cout<<ans<<endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>n;
		solve();
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int main()
{
  int a, b, c, X, Y;
  char s[101]={};
  char s_temp[101]={};
  char t[101]={};
  int len=0;
  int N, M;
  int A[20000]={};
  int B[20000]={};
  int C[20000]={};
  int i,j,k;
  int flag=0;
  int tmp=0;
  int min=101;
  int cnt=0;
  int max=0;
  int ans=0;

//  long cnt =0;
  long long A_temp;
//    int k=0;

  scanf("%d", &a);
// printf("%d\n", a);

  if(1200>a)   printf("ABC\n");  
  else if(2800>a)   printf("ARC\n");  
  else printf("AGC\n");  
  
return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

struct bubble {
	int y;
	int x;
	int way;
};

void move(vector<vector<int>>&field, vector<bubble>&bs) {
	vector<bubble>nbs;
	for (auto b : bs) {
		b.y += dy[b.way];
		b.x += dx[b.way];
		if (b.x >= 0 && b.x <= 3 && b.y >= 0 && b.y <= 3)nbs.push_back(b);
	}
	bs = nbs;
}

void update(vector<vector<int>>&field, vector<bubble>&bs) {
	vector<bubble>nbs;
	for (auto b : bs) {
		const int x = b.x;
		const int y = b.y;
		if (field[y][x]) {
			field[y][x]++;
		}
		else {
			nbs.push_back(b);
		}
	}
	bs = nbs;
}

void bomb(vector<vector<int>>&field, vector<bubble>&bs) {
	for (int y = 0; y < 4; ++y) {
		for (int x = 0; x < 4; ++x) {
			if (field[y][x]>4) {
				field[y][x] = 0;
				for (int i = 0; i < 4; ++i) {
					bs.push_back(bubble{ y,x,i });
				}
			}
		}
	}
}

void put(vector<vector<int>>&field, const int x, const int y) {
	vector<bubble>bs;
	bs.push_back(bubble{ x,y,0 });
	while (1) {
		assert(bs.size() < 70);
		update(field, bs);
		assert(bs.size() < 70);
		bomb(field, bs);
		assert(bs.size() < 70);
		move(field, bs);
		assert(bs.size() < 70);
		if (bs.empty())break;
	}
}


int main() {
	vector<vector<int>>field(4, vector<int>(4));
	for (size_t i = 0; i < 4; i++)
	{
		for (size_t j = 0; j < 4; j++)
		{
			cin >> field[i][j];
		}
	} 
	{
		bool ok = true;
		for (int i = 0; i < 4; ++i) {
			for (int j = 0; j < 4; ++j) {
				if (field[i][j])ok = false;
			}
		}
		if (ok) {
			cout << 0<< endl;
			return 0;
		}
	}
	
	//map < vector<pair<int,int>>, vector<vector<int>>>mp;
	//mp[vector<pair<int,int>>(0)] = field;
	for (int atime = 1; atime <= 5; ++atime) {
		for (int n = 0; n < 1 << (atime * 4); ++n){
			int num = n;
			vector<pair<int, int>>ps(atime);
			for (int i = 0; i < atime; ++i) {
				ps[i].second = num % 4;
				num /= 4;
				ps[i].first = num % 4;
				num /= 4;
			}
			//auto nfield(mp[{ps.begin(), ps.end()-1}]);
			auto nfield(field);
			for (int i = 0; i < atime; ++i) {
				put(nfield, ps[i].second, ps[i].first);
			}
			//put(nfield, ps[i].second, ps[i].first);
			bool ok = true;
			for (int i = 0; i < 4; ++i) {
				for (int j = 0; j < 4; ++j) {
					if (nfield[i][j])ok = false;
				}
			}
			if (ok) {
				cout << atime << endl;
				return 0;
			}
			//mp[ps] = nfield;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 3124
<?PHP
$first_line = fgets(STDIN);
$second_line = fgets(STDIN);
$first_line_array = explode(" ", $first_line);
$steps_amount=$first_line_array[0];
//ジャンプで飛べる足場の数
$skip_power=$first_line_array[1];
$steps_heights = explode(" ", $second_line);

//足場ごとにたどり着くまでのコストの総和の最小値を入れていく配列
$dps=[];

foreach (range(0, $steps_amount-1) as $index) {

    // とりあえず無限で初期化して、数を比較して最小値を入れていく
//    $dps[$index] = INF;
    
    // 最初にいた足場に辿り着くまでのコストは０
    if($index===0){
        $dps[0]=0;
        continue;
    }
    
    $dps[$index]=$dps[$index-1]+abs($steps_heights[$index]-$steps_heights[$index-1]);

    foreach (range(1, $skip_power) as $i) {
        if($index>=$i){
            if ($dps[$index]> abs($dps[$index - $i] + abs($steps_heights[$index] - $steps_heights[$index - $i]))){$dps[$index]=abs($dps[$index - $i] + abs($steps_heights[$index] - $steps_heights[$index - $i]));}
        }

    }
}

echo end($dps);

Measured memory_bytes: 23028
//InTheNameOfGod
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(i,j,k) for(int i=j;i<k;++i)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define lb(i) i&(-i);
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn =3e5+5;
const ll md = 998244353;
ll sum(ll a,ll b)
{
    return (a+b)%md;
}
ll mn(ll a,ll b)
{
    return (a-b+md)%md;
}
ll mul(ll a,ll b)
{
    return (a*b)%md;
}
ll pw(ll a,ll b)
{
    ll o=1;
    rep(i,0,30)
    {
        if(b&(1LL<<i))
        {
            o=mul(o,a);
        }
        a=mul(a,a);
    }
    return o;
}
ll n,f[maxn],rf[maxn],re,a,b,k;
ll cnt(ll a,ll b)
{
    if(a>b)return 0;
    return mul(f[b],mul(rf[a],rf[b-a]));
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n>>a>>b>>k;
    f[0]=1;
    rep(i,1,n+1)
    {
        f[i]=mul(i,f[i-1]);
    }
    rf[n]=pw(f[n],md-2);
    rrep(i,n-1,0)
    {
        rf[i]=mul(rf[i+1],i+1);
    }
    if((a+b)*n<k)
    {
        cout<<0;
        return 0;
    }
    if(a<b)
    {
        swap(a,b);
    }
    rep(i,0,maxn)
    {
        ll x=i,y;
        if(x*a<=k&&(k-x*a)%b==0)
        {
            y=(k-x*a)/b;
            re=sum(re,mul(cnt(x,n),cnt(y,n)));
        }
    }
    cout<<re;
    return 0;
}


Measured memory_bytes: 4992
program who_says_a_pun
  implicit none
  integer :: n, i, j, ans = 0, z(5000) = 0
  character(5000) :: s
  read(*,*) n
  read(*,*) s
  do i = 1, n
    z(1:n-i+1) = z_algorithm(s(i:n))
    do j = 2, n-i+1
      ans = max(ans,min(j-1,z(j)))
    end do
  end do
  write(*,'(i0)') ans
contains
  function z_algorithm(s) result(z)
    character(*) :: s
    integer :: z(len_trim(s)), n, i, j, k
    z = 0
    n = len_trim(s)
    z(1) = n
    i = 1
    j = 0
    do while (i < n)
      do while (i+j < n .and. s(j+1:j+1) == s(i+j+1:i+j+1))
        j = j+1
      end do
      z(i+1) = j
      if (j == 0) then
        i = i+1
        cycle
      end if
      k = 1
      do while (i+k < n .and. k+z(k+1) < j)
        z(i+k+1) = z(k+1)
        k = k+1
      end do
      i = i+k
      j = j-k
    end do
  end
end program who_says_a_pun

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
#define SEG_LEN (1 << 18)
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  ll n,k;
  cin >> n >> k;
  map<ll,ll>cnt;
  ll ans = 0;
  REP(i,1,n + 1)cnt[i % k]++;
  ans += cnt[0] * cnt[0] * cnt[0];
  for(auto i : cnt){
    if(i.first == 0)continue;
    int a = i.first,b = k - a,c = k - b;
    if(a + c == k)ans += cnt[a] * cnt[b] * cnt[c];
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    ll n;
    cin>>n;
    vector<ll> a,b,c;
    ll tmp;
    rep(i,n){
        cin>>tmp;
        a.push_back(tmp);
    }
    rep(i,n){
        cin>>tmp;
        b.push_back(tmp);
    }
    rep(i,n-1){
        cin>>tmp;
        c.push_back(tmp);        
    }
    ll sum=0;
    ll old_soeji=a[0];
    ll soeji;
    rep(i,n){
        soeji = a[i];
        sum+=b[soeji-1];
        if(soeji-old_soeji==1){
            sum+=c[old_soeji-1];
        }
        old_soeji = soeji;
    }
    cout<<sum<<endl;

}


Measured memory_bytes: 3608
N,W=map(int,input().split())

def solve_knapsack(capacity):
    # basic checks
 
    
    # populate the capacity = 0 columns, with '0' capacity we have '0' profit
    dp = [0]*(W + 1)
    

    for i in range(0, N):
        weights,profits = map(int,input().split())
        for c in range(capacity, weights-1, -1):
            tmp = profits + dp[c - weights]
            if tmp > dp[c]: dp[c] = tmp
 
    # maximum profit will be at the bottom-right corner.
    return dp[capacity]
  
def main():
    
 
    res = solve_knapsack(W)
 
    print(res)
if __name__ == "__main__":
	main()

Measured memory_bytes: 9716
from collections import deque


def main():

    N = int(input())
    g = {}
    for i in range(N):
        g[i] = set()

    for i in range(N - 1):
        a, b = map(int, input().split())
        g[a - 1].add(b - 1)
        g[b - 1].add(a - 1)

    # BFS
    dist = [-1] * N     # [-1:initial, 0:even, 1:odd]
    dist[0] = 0
    n_even = 0
    que = deque([0])
    while len(que):
        v = que[0]
        if dist[v] % 2 == 0:
            n_even += 1
        que.popleft()
        for n in g[v]:
            if dist[n] == -1:
                dist[n] = (dist[v] + 1) % 2
                que.append(n)

    ans = [-1] * N
    if n_even <= int(N / 3):
        n3, n3q, n3r = 1, 0, 1
        for i in range(N):
            if dist[i] == 0:
                ans[i] = n3 * 3
                n3 += 1
            else:
                if n3q * 3 + n3r <= N:
                    ans[i] = n3q * 3 + n3r
                    if n3r == 1:
                        n3r = 2
                    else:
                        n3q += 1
                        n3r = 1
                else:
                    ans[i] = n3 * 3
                    n3 += 1
    elif n_even > int(N * 2 / 3):
        n3, n3q, n3r = 1, 0, 1
        for i in range(N):
            if dist[i] == 1:
                ans[i] = n3 * 3
                n3 += 1
            else:
                if n3q * 3 + n3r <= N:
                    ans[i] = n3q * 3 + n3r
                    if n3r == 1:
                        n3r = 2
                    else:
                        n3q += 1
                        n3r = 1
                else:
                    ans[i] = n3 * 3
                    n3 += 1
    else:
        n3, n31, n32 = 1, 0, 0
        for i in range(N):
            if dist[i] == 0:
                if n31 * 3 + 1 <= N:
                    ans[i] = n31 * 3 + 1
                    n31 += 1
                else:
                    ans[i] = n3 * 3
                    n3 += 1
            else:
                if n32 * 3 + 2 <= N:
                    ans[i] = n32 * 3 + 2
                    n32 += 1
                else:
                    ans[i] = n3 * 3
                    n3 += 1

    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 138636
using System;

public class hello
{
    public static void Main()
    {
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            string[] s   = line.Trim().Split(' ');
            var a = int.Parse(s[0]);
            var b= int.Parse(s[1]);
            Console.WriteLine(Gcd(a, b));
        }
    }
    public static int Gcd(int a, int b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var t = a % b;
            a = b;
            b = t;
        }
        return a;
    }
}

Measured memory_bytes: 9160