akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
 
#define pb push_back
#define nl puts ("")
#define sp printf ( " " )
#define phl printf ( "hello\n" )
#define ff first
#define ss second
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define MP make_pair
#define FOR(i,x,y) for(vlong i = (x) ; i <= (y) ; ++i)
#define ROF(i,x,y) for(vlong i = (y) ; i >= (x) ; --i)
#define CLR(x,y) memset(x,y,sizeof(x))
#define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end())
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define SQ(x) ((x)*(x))
#define ABS(x) ((x)<0?-(x):(x))
#define FABS(x) ((x)+eps<0?-(x):(x))
#define ALL(x) (x).begin(),(x).end()
#define LCM(x,y) (((x)/gcd((x),(y)))*(y))
#define SZ(x) ((vlong)(x).size())
#define NORM(x) if(x>=mod) x-=mod;if(x<0) x+=mod;
#define MOD(x,y) (((x)*(y))%mod)
#define ODD(x) (((x)&1)==0?(0):(1))
#define Set(N,cur) N=(N|(1LL<<cur))
#define Reset(N,cur) N=(N&(~(1LL<<cur)))
#define Check(N,cur) (!((N&(1LL<<cur))==0))
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define dump(x) cerr<<"~ "<<#x<<" = "<<x<<endl
//Imran addition
#define rep(i,n) for(int i = 1; i <= n; i++)
#define mem CLR
#define pf printf
#define sc scanf
#define endl "\n"
#define gi(k) scanf("%d",&k)
#define gl(k) scanf("%lld",&k)
#define NMAX 2147483647
#define LMAX 9223372036854775807LL
 
using namespace std;
 
 
#define LL long long
#define LLU long long unsigned int
typedef long long vlong;
typedef unsigned long long uvlong;
typedef pair < int, int > pii;
typedef pair < vlong, vlong > pll;
typedef vector<int> vi;
typedef vector<vlong> vl;
typedef vector<pll> vll;
 
inline vlong gcd ( vlong a, vlong b ) {
    a = ABS ( a ); b = ABS ( b );
    while ( b ) { a = a % b; swap ( a, b ); } return a;
}
 
 
const vlong inf = 2147383647;
const vlong mod = 1000000007;
const double pi = 2 * acos ( 0.0 );
const double eps = 1e-9;
 
int n,k,ar[10003],ans; 
 
int main () {
 
 	#ifdef forthright48
    freopen ( "00_input.txt", "r", stdin ); //freopen ( "00_output.txt", "w", stdout );
 	#endif
 
	int n,k;

    cin >> n >> k;

    rep(i,n) {
        gi(ar[i]);
    }

    sort(ar+1, ar+n+1);

    rep(i,n-1) {
        if(ar[i] <= k) {
            k -= ar[i]; ans++;
        }
    }

    if(k == ar[n]) ans++;


    cout << ans << endl;
	
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include "string.h"

using namespace std;

int main(void){

    int N, M, *a, *b, A, B, count;

    cin >> N >> M;
    a = new int[N + 1];
    b = new int[N + 1];
    for (size_t i = 0; i < N; i++) {
        cin >> a[i + 1];
        b[i + 1] = a[i + 1];
    }

    for (size_t i = 0; i < M; i++) {
        cin >> A >> B;
        if (a[A] < a[B]) {
            b[A] = 0;
        }else if (a[A] > a[B]) {
            b[B] = 0;
        }else{
            b[A] = 0;
            b[B] = 0;
        }
    }

    count = 0;
    for (size_t i = 0; i < N; i++) {
        if (b[i + 1] != 0) {
            count ++;
        }
    }
    cout << count << endl;

    delete a, b;

    return 0;
}


Measured memory_bytes: 4016
import Control.Monad
import Data.List
main=do
    n<-readLn::IO Int
    print $ luca n
luca 0 = 2
luca 1 = 1
luca n = luca' 2 1 (n-2)
luca' a b n
    | n==0 = a+b
    | True = luca' b (a+b) (n-1)

Measured memory_bytes: 508
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower

using namespace std;

int main()
{
    //system("chcp 65001");

    int N;
    cin >> N;
    int i;
    float ans = 0;
    for(i =1;i <= N;i++)
    {
        if(i%2 == 1)
        {
            ans += 1.0;
        }
    }

    cout << ans/float(N);
    

    return 0;
}

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

int main(){
    int X;
    scanf("%d",&X);

    for(int i = 0;i <= 7;i++){
        if(400 + i*200 <= X && X <= 599 + i*200){
            printf("%d",8-i);
            return 0;
        }
    }
    
}

Measured memory_bytes: 1656
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 1e18;
const ll fact_table = 800008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
// priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
// #define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
 
ll mod = 998244353;
//ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,a,b,c,d,e,h,r,l,q;
ll k;
ll x[500005], y[500005], z[500005];
// char s[500005];
string s, t, u;

int main(){
    cin >> n;
    for(ll i=0;i<n;i++){
        cin >> x[i];
    }
    sort(x, x + n);
    bool dame = false;
    for(ll i=0;i<n-1;i++){
        if(x[i] == x[i+1])dame = true;
    }
    YES(!dame);
    return 0;
}


















Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std; using ll = long long;
using ull = unsigned long long; using P = pair<int, int>;
const int INF = 1e9; const int MOD = 1000000007;
const int dx[] = {-1,0,1,0}; const int dy[] = {0,-1,0,1};
//const int dx[] = {-1,-1,-1, 0, 0, 1, 1, 1}; const int dy[] = {-1, 0, 1,-1, 1,-1, 0, 1};
#define PI 3.14159265358979323846264338327950L //setprecision(15)
#define MAX 1000000
int minf[MAX + 1];
// エラトステネスの篩
void sieve() {
	memset(minf, -1, sizeof(minf));
	for (int i = 2; i <= MAX; i++) {
		if (minf[i] != -1) continue;
		minf[i] = i;
		for (int j = i * 2; j <= MAX; j += i) {
			minf[j] = i;
		}
	}
}
// 高速素因数分解
map<ll, ll> div(ll n) {
	map<ll, ll> res;
	while (n != 1) {
		++res[minf[n]];
		n = n / minf[n];
	}
	return res;
}

// 素因数分解O(√n)
map<ll, ll> prime_factor2(ll n) {
	map<ll, ll> res;
	for (ll i = 2; i*i <= n; i++) {
		while (n % i == 0) {
			++res[i];
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

int main() {
	sieve();
	int N; cin >> N;
	int t = 0;
	ll ans = 0;
	while (1) {
		t++;
		if (t == N) break;
		map<ll, ll> ma = div(t);
		ll tmp = 1;
		for (auto it = ma.begin(); it != ma.end(); it++) {
			tmp *= it->second + 1;
		}
		ans += tmp;
	}
	cout << ans << endl;
}

Measured memory_bytes: 7536
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <iomanip>
#include <iostream>
#include <map>

using namespace std;

const int CMax = 100005;

int main()
{
    int n;
    long long h, num, sum = 0;
    scanf("%lld %d", &h, &n);
    for (int i = 0; i < n; i++) {
        scanf("%lld", &num);
        sum += num;
    }
    if (sum >= h) printf("Yes\n");
    else printf("No\n");
}


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

int main(){
  int N,K,total;
  cin >> N >> K;
  total=0;
  for(int i=0;i<N;i++){
    int B,x;
    cin >> x;
    if(x-K<=0){
      if(-2*(x-K)>=x*2)total+=x*2;
      else total+=-2*(x-K);
    }
    else{ if(2*(x-K)>=x*2)total+=x*2;
          else total+=2*(x-K);
        }
  }
  cout << total << endl;
}


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

int N;
int A[210];

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

    int counter = 0;

    while (true) {
        bool flag_odd = false;

        for (int i = 0; i < N; ++i){
            if (A[i] % 2 != 0) flag_odd = true;
            if (flag_odd) break;
        
            A[i] /= 2;
        }

        if (flag_odd) break;

        ++counter;
    }

    cout << counter << endl;

    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include<stdio.h>
using namespace std;

int main()
{
	int n, x,count=0; 
	while (cin >> n >> x) {
		count = 0;
		if (n == 0 && x == 0) { break; }
		for (int a = 1; a <= n; a++)
		{
			for (int b = 1; b <= n; b++)
			{
				for (int c = 1; c <= n; c++)
				{
					if (a != b&&a != c&&b != c) {
						if (a + b + c == x) {
							count++;
						}
					}
				}
			}
		}
		cout << count / 6 << endl;
	}
	return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <cmath>
#define MOD 1000000007
using namespace std;
int H, W, K, meta[8] = {1,1,2,3,5,8,13,21};
long meta2[9][2], cache[9][101] = {0};

long Map(int X, int Y) {
	if (Y == H) {
		long ans = 0;
		if (X == K+1) {
			return meta2[X-1][1];
		} else if (X == K) {
			return meta2[X][0];
		} else if ( X == K-1 ) {
			return meta2[X][1];
		} else
			return 0;
	}

	if (abs(X-K) > abs(H-Y+1)) return 0;

	if (!cache[X][Y]) {
		long result = Map(X, Y+1) * meta2[X][0];
		if (X > 1) {
			result += Map(X-1, Y+1) * meta2[X-1][1];
		}
		if (X < W) {
			result += Map(X+1, Y+1) * meta2[X][1];
		}

		cache[X][Y] = result % MOD;
	}
	return cache[X][Y];
}

int main(void) {
	cin >> H >> W >> K;
	for(int i=1; i<=W; i++)
		for(int j=0; j<2; j++)
			meta2[i][j] = meta[i - 1] * meta[W - i - j];
	cout << Map(1, 1) % MOD;

}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<String> list = new ArrayList<String>();
		for(int i = 0; i < n; i++) {
			String r = sc.next();
			list.add(r);
		}
		sc.close();
		if(list.contains("Y")) {
			System.out.println("Four");
		}else {
			System.out.println("Three");
		}
	}

}

Measured memory_bytes: 21844
# coding: utf-8

A, B, C, X, Y = map(int, input().split())

# ABピザはAとBの平均より安いか
mean_AB = (A + B) / 2

if mean_AB > C:
    if X <= Y:
        price = C * X * 2 + B * (Y-X)
        # ABピザがかなり安く、余りが出ても多めに買ってもよい場合か
        price_AB = C * Y * 2
        if price_AB < price:
            price = price_AB
    else:
        price = C * Y * 2 + A * (X-Y)
        # ABピザがかなり安く、余りが出ても多めに買ってもよい場合か
        price_AB = C * X * 2
        if price_AB < price:
            price = price_AB

else:
    price = A * X + B * Y

print(price)

Measured memory_bytes: 3064
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  int n,h;cin>>n>>h;
  int a = 0;
  for(int i = 0; n > i; i++){
    int t;cin>>t;
    if(h<=t)a++;
  }
  cout << a << endl;
  
}


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

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

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
const int mod = 1000000007;

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

    vector<ll> l(n);
    for(ll i = 0; i < n; i++) {
        cin >> l[i];
    }
    asort(l);

    ll cnt = 0;
    for(ll i = 0; i < n; i++) {
        for(ll j = i + 1; j < n; j++) {
            ll k = lower_bound(l.begin(), l.end(), l[i] + l[j]) - l.begin();
            cnt += k - (j + 1);
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main()
{string S;
 cin >> S;
 
 int n = S.size();
 int mymin = 10000;
 rep(i,n-2){
  
   
   int u = (S[i] - '0') * 100 + (S[i+1] - '0') * 10 + S[i+2] - '0';
   
   mymin = min ( mymin , abs(753 - u));  
 }
 
 cout << mymin << endl;
 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N,A;cin>>N>>A;
    ll ans=N;
    for(ll i=1;i<=60;i++){
        ll sum=0;
        sum+=A*(i-1);
        double x=pow(N,1.0/double(i));
        if(x<2.0) continue;
        
        ll y=floor(x);
        
        for(int j=0;j<=i;j++){
            ll now=1;
            for(int k=0;k<j;k++) now*=(y+1);
            for(int k=j;k<i;k++) now*=y;
            
            if(now>=N){
                sum+=(y+1)*j+y*(i-j);
                chmin(ans,sum);
                break;
            }
        }
    }
    
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a , b;
  cin >> a >> b;

  if(a%2 == 0 || b%2 == 0){
    cout << "Even" << endl;
  }

  else if(a%2 == 1 && b%2 ==0){
    cout << "Even" << endl;
  }

  else if(a%2 == 0 && b%2 ==1){
    cout << "Even" << endl;
  }

  else{
    cout << "Odd" << endl;
  }
}

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

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

    vector<int> p(n); // n人の正解数を加算していく
    for (int i = 0; i < n; ++i) {
        p.at(i) = 0;
    }

    int a;
    for (int i = 0; i < q; ++i) {
        cin >>a;
        ++p.at(a-1);
    }

    for (int i = 0; i < n; ++i) {
        cout << ((k - q + p.at(i) > 0) ? "Yes" : "No") << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,k,p[5050],c[5050];
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>p[i];
	} 
	for(int i=1;i<=n;i++)
	{
		cin>>c[i];
	}
	int ans=-1e18;
	vector<int> v;
	for(int i=1;i<=n;i++)
	{
		v.clear();
		int now=i;
		while(1)
		{
			v.push_back(c[now]);
			now=p[now];
			if(now==i)
			{
				break;
			}
		}
		int sum=0;
		for(int j=0;j<v.size();j++)
		{
			sum+=v[j];
		}
		int pres=0;
		for(int j=1;j<=min(k,(int)v.size());j++)
		{
			pres+=v[j-1];
			int tmp=pres+(k-j)/v.size()*max(sum,0ll);
			ans=max(ans,tmp);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3844
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9 + 7;
const int maxn = 300005;
#define endl '\n'
#define ld long double
#define int ll
#define all(x) (x).begin(),(x).end()

int32_t main()
{ 
  IOS

  int n;
  cin >> n;
  vector<int> x(n), y(n);
  int ans = -1e18;
  vector<int> dp(4,-1e18);
  for(int i = 0;i<n;i++){
    cin >> x[i] >> y[i];
      for(int j = 0;j<=3;j++){
        ans = max(ans, dp[3^j] + ((j/2)?1:-1)*x[i] + ((j%2)?1:-1)*y[i]);
      }
      for(int j = 0;j<=3;j++){
        dp[j] = max(dp[j],((j/2)?1:-1)*x[i] + ((j%2)?1:-1)*y[i]);
      }
  }  
  cout << ans  << endl;
    
    
} 



Measured memory_bytes: 6364
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		for(int i=1 ; i<= n ; i++) {
			if(String.valueOf(i).length() % 2 == 1) {
				count++;
			}
		}

		System.out.println(count);

		sc.close();

	}

}


Measured memory_bytes: 41392
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

vector<P> p_fac(ll n){ //素因数分解
	vector<P> res;
	for(ll a=2;a*a<=n;a++){
		if(n%a!=0) continue;
		ll ex=0;//指数
		while(n%a==0){
			ex++; n/=a;
		}
		res.eb(make_pair(a,ex));
	}
	if(n!=1) res.eb(make_pair(n,1));
	return res;
}

void solve(){
  ll n; cin>>n;
  vector<P> v=p_fac(n);
  vi a={0};
  REP(i,1,100){
    a.eb(a[i-1]+i);
  }
  ll ans=0;
  for(P p:v){
    ans+=ub(a,p.se)-1;
  }
  out(ans);
}

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


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

typedef long long int ll;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int main(){
  ll N,X;
  cin >> N >> X;
  vector<ll> A(N);
  for(int i = 0;i < N;i++){
    cin >> A[i];
  }
  ll ans = 0;
  for(int i = 0;i < N-1;i++){
    if(A[i]+A[i+1] > X){
      if(A[i] <= X){
        ans += A[i]+A[i+1]-X;
        A[i+1] = X - A[i];
      }else{
        ans += A[i]+A[i+1]-X;
        A[i+1] = 0;
        A[i] = X;
      }
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
		
	string S;
	cin>>S;
	
	int ans=S.size();
	int s=0;
	fx(S.size()){
		if(S.at(x)=='S'){
			while(x<S.size()&&S.at(x)=='S'){
				s++;
				x++;
			}
			while(x<S.size()&&s>0&&S.at(x)=='T'){
				s--;
				x++;
				ans-=2;
			}
			x--;
		}
	}
	ce(ans)
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int a[100010];
struct node
{
	int num,d;
}b[100010];
bool cmp(node a,node b){return a.d>b.d;}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read(),m=read();long long sum=0;
    for(int i=1;i<=n;i++)a[i]=read(),sum+=a[i];sort(a+1,a+n+1);
    for(int i=1;i<=m;i++)b[i].num=read(),b[i].d=read();
    sort(b+1,b+m+1,cmp);
    int p=1;bool bk=true;
    for(int i=1;i<=m;i++)
    {
    	while(p<=n && b[i].num)
    	{
    		if(a[p]<b[i].d){sum+=b[i].d-a[p];p++,b[i].num--;}
    		else {bk=false;break;}
    	}if(bk==false)break;
    }printf("%lld\n",sum);
   	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
using namespace std;
int n,m;

bool check(int x){
	int c=0;
	while(x){
		c++;
		x/=10;
	}
	return c%2;
}

int main(){
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++) ans+=check(i);
	cout<<ans;
} 

Measured memory_bytes: 256
#include<iostream>
#include<stack>
using namespace std;
string s;int sum=0;
stack <int> sta;
int main()
{
	cin >> s;
	sta.push(s[0]) ;
	for(int i=1;i<s.length();i++) {
		if(!sta.empty()&&sta.top()!=s[i] )  {
			sta.pop(); sum+=2; 
		}
		else sta.push(s[i]) ;
	}
	cout <<sum;
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main() {
    ll N, Y;
    cin >> N >> Y;


    for(int i=0; i<=N; i++) {
        for(int j=0; j<=N-i; j++) {
            int k = N - i - j;
            if(i * 1000 + j * 5000 + k * 10000 == Y) {
                cout << k << " " << j << " " << i << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll l,r,d,x=0;
    string s;
    cin>>l>>r>>d;
    for(ll i=l;i<=r;i++) {
        if(i%d==0)
        x++;
    }
  //  cin>>  ;
    cout<< x ;
}

Measured memory_bytes: 3644
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]


jud = [True]*n

for i in ab:
    if h[i[0] - 1] >= h[i[1] - 1]:
        jud[i[1] - 1] = False
    if h[i[0] - 1] <= h[i[1] - 1]:
        jud[i[0] - 1] = False

print(jud.count(True))

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


int main()
{
	int n;
	cin >> n;
	vector<int> a(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> a.at(i);
	}

	vector<int> ans(n + 1, 0);
	for (int i = n; i >= 1; i--) {
		int balls = 0;
		for (int j = i; j <= n; j += i) {
			if (ans.at(j) == 1) {
				balls++;
			}
		}
		if (a.at(i) != (balls % 2)) {
			ans.at(i) = 1;
		}
	}

	int m = 0;
	string ans_str = "";
	for (int i = 1; i <= n; i++) {
		if (ans.at(i) == 1) {
			m++;
			ans_str += to_string(i);
		}
		if (i != n) {
			ans_str += " ";
		}
	}

	cout << m << endl;
	cout << ans_str << endl;
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> a(N), b(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if(N % 2 == 0){
        cout << b[N/ 2 -1] - a[N/2 -1] + b[N/2] - a[N/2] + 1 << endl;
    }
    else {
        cout << b[N/2] - a[N/2] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 4780
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ff first 
#define ss second
#define mod 1000000007
#define lim 100005
#define nfs_mw ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

vector<int> gr[lim];
queue<int> nodes;
bool vis[lim] = {};
int dp[lim] = {};

void dfs(int u){
	vis[u] = 1;
	for(int v:gr[u]) if(!vis[v]) dfs(v);
	nodes.push(u);
}

int main()
{
	int i,j,n,m,u,v,ans = 0;
	cin>>n>>m;
	
	while(m--){
		cin>>u>>v;
		gr[u].pb(v);
	}
	
	for(i=1; i<=n; i++) if(!vis[i]) dfs(i);

	for(i=1; i<=n; i++){
		u = nodes.front();
		nodes.pop();
		for(int v:gr[u]) dp[u] = max(dp[u], dp[v] + 1);
		ans = max(dp[u], ans);
	}
	cout<<ans;
}

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

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		Arrays.setAll(A, i -> sc.nextInt());
		Map<Integer, Integer> m = new HashMap<>();
		for(int i = 0; i < N; i++) {
			for(int j = 2; j <= Math.sqrt(A[i]); j++)
				if(A[i] % j == 0) {
					while(A[i] % j == 0)
						A[i] /= j;
					m.put(j, m.getOrDefault(j, 0)+1);
				}
			if(A[i] > 1)
				m.put(A[i], m.getOrDefault(A[i], 0)+1);
			if(System.currentTimeMillis() - start > 1600) {
				System.out.println("setwise coprime");
				return;
			}
		}
		int ans = 0;
		for(int k : m.values()) {
			if(k > 1)
				ans = 1;
			if (k == N) {
				ans = 2;
				break;
			}
		}
		if (ans == 0)
			System.out.println("pairwise coprime");
		else if (ans == 1)
			System.out.println("setwise coprime");
		else
			System.out.println("not coprime");
	}

}

Measured memory_bytes: 65856
#include<bits/stdc++.h>
#define MAX 100007
using namespace std;

int dp[MAX],visit[MAX];
vector<int>adj[MAX];

void dfs(int s)
{
    if(visit[s])
        return;
    visit[s]=1;
    dp[s]=1;
    for(int i=0; i<adj[s].size(); i++)
    {
        int s1=adj[s][i];
        dfs(s1);
        dp[s]=max(dp[s],1+dp[s1]);
    }
}

int main()
{

    int n,m,i,a,b,res=0;
    cin >> n >> m;
    for(i=0; i<m; i++)
    {
        cin >> a >> b;
        adj[a].push_back(b);
    }

    for(i=1; i<=n; i++)
    {
        if(visit[i])
            continue;
        dfs(i);
        res=max(res,dp[i]);
    }

    res--;

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main()
{
  string s ;
  cin >> s;
  if((s[2]==s[3])&&(s[4]==s[5])) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
K, N = map(int,input().split())

A = list(map(int, input().split()))

distance = list()
for i in range(N-1):
    tmp = A[i+1] - A[i]
    distance.append(tmp)
distance.append(A[0] + K - A[-1])

print(sum(distance) - max(distance))

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

int main(){
  int N;
  string S;
  int pos=0, max=0;
  cin >> N >> S;
  for(int i=0; i<N; i++){
    if(S[i]=='I'){
      pos++;
    }
    if(S[i]=='D'){
      pos--;
    }
    if(pos>max) max=pos;
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        class Solver
        {
            public readonly int N;
            private bool[][] links;
            public Solver(int N, int[][] paths)
            {
                this.N = N;
                links = new bool[N][];
                for (int i = 0; i < N; ++i) { links[i] = new bool[N]; }
                foreach (int[] path in paths)
                {
                    int a = path[0] - 1;
                    int b = path[1] - 1;
                    links[a][b] = true;
                    links[b][a] = true;
                }
            }
            public int Solve(Stack<int> stack)
            {
                if (stack.Count == N) { return 1; }
                int i = stack.First();
                int sum = 0;
                for (int j = 1; j < N; ++j)
                {
                    if (!stack.Contains(j) && links[i][j])
                    {
                        stack.Push(j);
                        sum += Solve(stack);
                        stack.Pop();
                    }
                }
                return sum;
            }
        }
        static void Main(string[] args)
        {
            int[] V = ReadInts();
            int N = V[0];
            int M = V[1];
            int[][] paths = new int[M][];
            for (int i = 0; i < M; ++i) { paths[i] = ReadInts(); }
            var stack = new Stack<int>();
            stack.Push(0);
            Console.WriteLine(new Solver(N, paths).Solve(stack));
        }
    }
}


Measured memory_bytes: 13524
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    long long n; cin>>n;
    long long sum=0;
    for(long long i=1;i*i<=n;i++){
        if(n%i==0){
            if(i>1) if(n/i==n/(i-1)) sum+=i-1;
            if((n/i-1)>0) if(i==n/(n/i-1)) sum+=(n/i)-1;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [0] * N
B = [0] * N
Sum = [[0] * 2 for i in range(N)]

for i in range(N):
    A[i], B[i] = map(int, input().split())
    Sum[i][0] = i
    Sum[i][1] = A[i] + B[i]
    
a = 0
b = 0
turn = 0

Sum.sort(key=lambda x:x[1], reverse=True)
    
for i in range(N):
    if turn == 0:
        a += A[Sum[i][0]]
        turn = 1
    else:
        b += B[Sum[i][0]]
        turn = 0

print(a - b)

Measured memory_bytes: 60576
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;

ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



/* TEMPLATE ENDS HERE */

#define MAXN (1 << 20)

mod a[MAXN];
mod s[MAXN];

int main() {
	cout << fixed << setprecision(12);	
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		a[i] = t;
	}
	for (int i = n - 1; i >= 0; i--) {
		s[i] = s[i + 1] + a[i];
	}
	mod ret = 0;
	for (int i = 0; i < n - 1; i++) {
		ret += a[i] * s[i + 1];
	}
	cout << ret << endl;
	return 0;
}




Measured memory_bytes: 20008
#include<iostream>
    using namespace std;
    int main(){
        int N, count=0;
        int A[200];
        cin >> N;
        for(int i=0;i<N;i++) cin >> A[i];
        bool exist_odd = false;
        while (true){
            for(int i=0;i<N;i++){
                if(A[i]%2 != 0) exist_odd = true;
            }
            if(exist_odd) break;
            for(int i = 0;i<N;i++){
                A[i] /= 2;
            }

            ++count;
        }
        cout << count <<endl;
        
    }


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

using namespace std;

int main () {

	int N;
	cin >> N;

	vector<int> a(N);
	vector<int> b(N);
	vector<int> c(N);

	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}

	for (int i = 1; i < N; i++) {

		a[i] += max(b[i - 1], c[i - 1]);
		b[i] += max(c[i - 1], a[i - 1]);
		c[i] += max(a[i - 1], b[i - 1]);

	}

	cout << max(a[N - 1], max(b[N - 1], c[N - 1])) << endl;

}


Measured memory_bytes: 1408
package main

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

var sc *bufio.Scanner
var out *bufio.Writer

func main() {
	sc = bufio.NewScanner(os.Stdin)
	//bytes, _ := ioutil.ReadFile("./stdin.txt")
	//sc = bufio.NewScanner(strings.NewReader(string(bytes)))
	out = bufio.NewWriter(os.Stdout)
	buf := make([]byte, 1<<20)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	n, m := nextInt(), nextInt()
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
	}
	for i := 0; i < m; i++ {
		a, b := nextInt(), nextInt()
		g[a-1][b-1] = 1
		g[b-1][a-1] = 1
	}

	fmt.Fprintln(out, f(g, n, 0, 1))
}

func f(g [][]int, n, a, d int) int {
	if d == (1<<n)-1 {
		return 1
	}
	ret := 0
	for i := 0; i < n; i++ {
		if d&(1<<i) == 0 && g[a][i] == 1 {
			ret += f(g, n, i, d|1<<i)
		}
	}
	return ret
}

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func intMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}
func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}


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

#define fastIO ios_base::sync_with_stdio(false)
#define forI0N(i, a, b) for(int i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main() {
    fastIO;
    int N, K;
    cin >> N >> K;

    vector<int> h(N);
    forI0N(i, 0, N) cin >> h[i];

    vector<ull> jump(N, ULLONG_MAX);
    jump[0] = 0;
    forI0N(i, 1, N) {
        forI0N(j, 1, min(i, K) + 1) {
            jump[i] = min(jump[i], jump[i - j] + abs(h[i] - h[i - j]));
        }
    }

    cout << jump[N - 1];
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x,m=0;
	while(1){
		cin >> n >> x;
		m=0;
		if(n==0 && x==0) break;
		for(int i=1;i<=n-2;i++){
			for(int j=i+1;j<=n-1;j++){
				for(int k=j+1;k<=n;k++){
					if(i+j+k==x){
						m++;
					}
				}
			}
		}
		cout << m << endl;
	}
}


Measured memory_bytes: 3028
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000000000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

struct edge{ll to, cost;}; //edgeパラメータ
typedef pair<ll,ll> P;
struct graph{
  ll N; //ノードの個数
  vector<vector<edge> > G; //G[辺の元]((.to辺の先,.costコスト),...)
  vector<ll> d; // dist[n] = ノードnまでのの重み長さ
  ll repeat; // 何回更新したか

  graph(ll n){ //グラフ生成時
    N = n;
    G.resize(N); //Edge情報
    d.resize(N); //Node情報,ans
    rep(i,N){d[i] = INF;}
  }

  void add_edge(ll s, ll t, ll cost){
    G[s].emplace_back((edge){t, cost});
  }

  bool bellman_ford(ll s){
    d[s] = 0;
    repeat=0;

    while(true) {
      bool update = false;
      ++repeat;
      rep(v, N) {
        if(d[v] == INF) continue;
        //rep(i, G[v].size()){
          //edge& E = G[v][i];
        for(auto& E: G[v]){
          if( d[E.to] > d[v] + E.cost) {
            d[E.to] = d[v] + E.cost;
            //cout<< i<< E.to<<E.cost<<d[i]<<"\n";
            if(E.to==N-1) update = true;
          }
        }
      }
      if(repeat>=N and update) return false;
      if(repeat>2*N) return true;
    }
  }
};


void Main(){

  ll n,M;

  cin>>n>>M;

  graph g(n);

  rep(i,M){
    ll a,b,c;
    cin>>a>>b>>c;
    g.add_edge(a-1,b-1,-c);
  }

  if(g.bellman_ford(0)){
    cout<< -g.d[n-1]<<"\n";
  }
  else{
    cout<< "inf"<<"\n";
  }



}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
	int N;
	cin >> N;
    ll ans = 1;
    rep(i, N) ans = ans*(i+1)%MOD;

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
function lcm(a,b) {
  var g = (n, m) => m ? g(m, n % m) : n
  return a * b / g(a, b)
}

function main(input) {
  var nums = input.split(" ").map(Number)
  console.log(lcm(nums[0], nums[1]))
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7372
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<tuple<int, int, int>> vti;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, i;
    string s;
    cin >> n >> s;
    
    int cnt = 1;
    char prev_c = s[0];
    for (i=1;i<n;i++){
        if (prev_c != s[i]) cnt++;
        prev_c = s[i];
    }
    cout << cnt << endl;
 }


Measured memory_bytes: 512
program agc002b
  implicit none
  integer :: n, m, i
  integer,allocatable :: box(:), x(:), y(:), xy(:,:)
  logical,allocatable :: f(:)

  read *, n, m
  allocate(box(n),f(n),xy(2,m))
  box = 1
  f = .false.
  f(1) = .true.
  read *, xy
  x = xy(1,:)
  y = xy(2,:)

  do i = 1,m
     box(x(i)) = box(x(i)) - 1
     box(y(i)) = box(y(i)) + 1
     f(y(i)) = f(y(i)).or.f(x(i))
     if (box(x(i)) == 0) f(x(i)) = .false.
  end do

  print *, count(f)
end program agc002b


Measured memory_bytes: 3200
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 105, K = 1e5 + 5, MOD = 1e9 + 7;
int n, p, dp[N][K], prefix[N][K], a[N];
 
inline int add(int a, int b){
	a += b;
	if(a >= MOD)a -= MOD;
	return a;
}
 
inline int sub(int a, int b){
	a -= b;
	if(a < 0)a += MOD;
	return a;
}
 
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
 
	cin>>n>>p;
	for(int i=1;i<=n;++i)
		cin>>a[i];
 
	for(int i=0;i<=n;++i)
		dp[i][0] = prefix[i][0] = 1;
	for(int j=0;j<=p;++j)
		prefix[0][j] = 1;
 
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=p;++j)
		{
			// coefficient of x^j is prefix[i - 1][j - a[i] : j];
 
			int first = (j - a[i] - 1 >= 0)? prefix[i - 1][j - a[i] - 1] : 0;
			int last = prefix[i - 1][j];
			
			dp[i][j] = add(dp[i][j], sub(last, first));
			prefix[i][j] = add(prefix[i][j - 1], dp[i][j]);
		}
	}
		
 
	cout<<dp[n][p]<<"\n";
	return 0;
}

Measured memory_bytes: 82176
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int> >
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int> >
#define VPII vector<pair<int,int> >

#define INT ll

using namespace std;
/*........................................Define functions.........................................*/


/*....................................Define global variables .....................................*/



/*.........................................kemkemG0................................................*/
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);


	int N,D;
	cin>>N>>D;
	double w=2*D+1;

	int ans=ceil(N/w);
	cout<<ans<<endl;
	









		

		return 0;
}




Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
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; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x, q = 0,r = 0;
	cin >> x;
	r = x % 100;
	q = (x - (x % 100))/100;
	for (ll a = 0; a <= q; a++) {
		for (ll b = 0; b <= q - a; b++) {
			for (ll c = 0; c <= q - a - b; c++) {
				for (ll d = 0; d <= q - a - b - c; d++) {
					for (ll e = 0; e <= q - a - b - c - d; e++) {
						for (ll f = 0; f <= q - a - b - c - d - e; f++) {
							if (100 * a + 101 * b + 102 * c + 103 * d + 104 * e + 105 * f == x) {
								return cout << 1 << endl,0;
							}
						}
					}
				}
			}
		}
	}
	cout << 0 << endl;
}




Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,j,tmp,n;
  scanf("%d",&n);
  int mochi[n];
  for(i=0;i<n;i++){
    scanf("%d",&mochi[i]);
  }

  for (i=0; i<n; ++i) {
    for (j=i+1; j<n; ++j) {
      if (mochi[i] > mochi[j]) {
        tmp =  mochi[i];
        mochi[i] = mochi[j];
        mochi[j] = tmp;
      }
    }
  }

  int cnt,tmp2;
  cnt=1;
  tmp2=mochi[n-1];
  for(i=n-1;i>-1;i--){
    if(mochi[i]<tmp2){
      cnt++;
      tmp2=mochi[i];
    }
  }

  printf("%d\n",cnt);
  return 0;
}


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

int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}

int main() {
    int N, K; cin >> N >> K;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    int ma = *max_element(a.begin(), a.end());
    int g = a[0];
    for (int i = 1; i < N; i++) {
        g = gcd(g, a[i]);
    }
    if (K % g || K > ma) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << "POSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 640