akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
    #include <algorithm>
    #include <cstdlib>
    #include <cstdio>
    #include <numeric>
    #include <utility>
    #include <cmath>
    #include <vector>
    #include <queue>
    #include <string>
    #include <map>
    #define MAX_U   10
    #define MIN_U   0
    #define rep(i,n) for(int i=0;i<n;i++)
    #define sz(x) ((int)(x).size())
    using namespace std;
    typedef long long ll;
    typedef vector<int> vi;
    typedef vector<char> vc;
    typedef vector<string> vs;
    typedef queue<int> qi;
    const int INF=numeric_limits<int>::infinity();
    void printa(){cout<<"\n";}
    template<class T, class... A>void printa(const T&first,const A&... rest){cout<<first;printa(rest...);}
    template<class... A>void printa(const A&... rest){printa(rest...);}
    void prints(){cout<<" ";}
    template<class T, class... A>void prints(const T&first,const A&... rest){cout<<first;prints(rest...);}
    template<class... A>void prints(const A&... rest){prints(rest...);}
    int factorial(int x){int f=1;for(int i=1;i<x+1;i++)f=f*i;return f;}
    int sigma(int x){int s;for(int i=1;i<x+1;i++)s=s+i;return s;}
    int middle(int x){if(x%2==0)return x/2;else return x/2+1;}
    double heron(int a,int b,int c){double s;s=(a+b+c)/2;return sqrt(s*(s-a)*(s-b)*(s-c));}
    double trapezium(int a,int b,int h){return (a+b)*h/2;}
    double triangle(int a,int h){return a*h/2;}
    void sorm(vector<int> vec){sort(vec.begin(),vec.end());}
    void sorg(vector<int> vec){sort(vec.begin(),vec.end(),greater<int>());}
    int cmp( const void *p, const void *q ) {
    if( *(double*)p > *(double*)q ) return 1;
    if( *(double*)p < *(double*)q ) return -1;
    return 0;
    }
    int main(void){
        cin.tie(0);
        ios::sync_with_stdio(false); 
        int x,b=2,b2,b3;
        cin>>x;
        if(x==1){
            printa(1);
            exit(0);
        }
        double st[x];
        for(int f=0;f<x;f++){
            for(int i=3;i<x+2;i++){
                if(pow(b,i)>x){st[f]=pow(b,i-1);b++;b2=i;break;}
            }
            //printa(b-1,",",b2-1,",",pow(b-1,b2-1),",",f);
        }
        b3=sizeof(st)/sizeof(double);
        qsort(st,b3,sizeof(double),cmp);
        for(int ef=0;ef<x;ef++){
            if(st[ef]>x){printa(st[ef-1]);break;}
        }
        return 0;
    }

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        int AminusB = A - B;

        int ans = C <= AminusB ? 0 : C - AminusB;
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<string.h>
#include<stdio.h>
#include<queue>

using namespace std;


int main()
{
    string str;
    int n;
    cin>>str>>n;
    long long sum=0,ans=0,flag=0;
    if(str.size()==1)
    {
        cout<<n/2;
        return 0;
    }
    if(str.size()==2)
    {
        if(str[0]==str[1])
            cout<<n;
        else cout<<"0";
        return 0;
    }
    for(int i=1; i<str.size(); i++)
    {
        if(str[i]==str[i-1]&&!flag)
        {
            flag=1;
            sum++;
            continue;
        }
        flag=0;
    }
    if(str[0]!=str[str.size()-1]||flag==1)
        cout<<sum*n;
    else
    {
        if(str[0]!=str[1])
            cout<<(sum+1)*n-1;
        else
        {
            if(str[1]!=str[2])
                cout<<sum*n;
            else
            {
                long long  ans=1;
                flag=1;
                for(int i=1; i<str.size(); i++)
                {
                    if(str[i]==str[i-1]&&!flag)
                    {
                        flag=1;
                        ans++;
                        continue;
                    }
                    flag=0;
                }
                //cout<<"ans="<<ans<<" "<<"sum="<<sum<<"flag="<<flag<<n%2;
                if(flag==1)
                  cout<<(sum+ans)*(n/2)+(n%2)*sum;
                else cout<<sum+(n-1)*ans;
            }
        }
    }
    return 0;
}



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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int numero;
    cin >> numero;
    numero = numero % 10;
    if (numero == 0 || numero == 1 || numero == 6 || numero == 8) {
        cout << "pon\n";
    } else if (numero == 3) {
        cout << "bon\n";
    } else {
        cout << "hon\n";
    }
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
typedef long double ld;
using ll=long long;
using namespace std;
const auto mod=1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int a; cin >> a ;
  string s; cin >> s;
  
  if(a>=3200) cout << s << endl;
  else cout << "red" << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int const MAXN=220000;
int N;
pair<int,int> a[MAXN];

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

	cin>>N;
	rep(i,0,N) cin>>a[i].second>>a[i].first;
	
	sort(a,a+N);
	
	ll t=0;
	rep(i,0,N) {
		t+=a[i].second;
		if (t>a[i].first) {
			cout<<"No\n";
			return 0;
		}
	}
	
	cout<<"Yes\n";
}


Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>

using namespace std;

#define ll long long
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 100000;
int v[5 + nmax];
int pref[5 + nmax], suff[5 + nmax];

int main()
{
  int n;
  cin >> n;
  for(int i = 1;i <= n;i++)
    cin >> v[i];
  for(int i = 1;i <= n;i++)
    pref[i] = __gcd(pref[i - 1], v[i]);
  for(int i = n;1 <= i; i--)
    suff[i] = __gcd(suff[i + 1], v[i]);
  int result = 0;
  for(int i = 1;i <= n;i++) {
    result = MAX(result, __gcd(pref[i - 1], suff[i + 1]));
  }
  cout << result;

  return 0;
}


Measured memory_bytes: 1408
q,h,s,d=map(int,input().split())
n=int(input())
if n%2==0:
    print(min(q*8,h*4,s*2,d)*(n//2))
else:
    print(min(q*8,h*4,s*2,d)*(n//2)+min(q*4,h*2,s))
    


Measured memory_bytes: 2940
// Created by arjun_singh12 (Arjun Singh) on [21-04-2020 03:12:19]
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define M 1000000007
#define INF LLONG_MAX
#define vll vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>>
#define pb push_back
#define pll pair<ll,ll>
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define repr(i,n,a) for(ll i=n;i>=a;i--)
#define endl "\n"
#define db(x); cout<<"Debug: "<<#x<<" = "<<x<<endl;
#define dbv(v); cout<<"Debug: Vector "<<#v<<" = "; for(ll i=0;i<sz(v);i++) cout<<v[i]<<" "; cout<<endl;
using namespace std;
int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	ll test=1;
	// cin>>test;
	while(test--)
	{
	    ll n,k; cin>>n>>k;
	    vll v(n);
	    rep(i,0,n)
	    {
	    	cin>>v[i];
	    }
	    vll dp(n,INT_MAX);
	    dp[0]=0;
	    rep(i,1,n)
	    {
	    	rep(j,1,k+1)
	    	{
	    		if(i-j<0) break;
	    		dp[i]=min(dp[i-j]+abs(v[i]-v[i-j]),dp[i]);
	    	}
	    }
	    // dbv(dp);
	    cout<<dp[n-1]<<endl;
	}
}


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

using namespace std;

typedef long long llong;

const llong MOD = 1E9 + 7;

llong n, k, ans = 0;
vector<llong> fact, inv_fact;

llong c(llong N, llong K)
{
    llong res = fact[N];
    res = (res * inv_fact[K]) % MOD;
    res = (res * inv_fact[N - K]) % MOD;

    return res;
}

llong binary_pow(llong a, llong p)
{
    llong cur = a;
    llong res = 1;

    while (p > 0)
    {
        if (p & 1)
            res = (res * cur) % MOD;

        cur = (cur * cur) % MOD;
        p /= 2;
    }

    return res;
}

llong inv(llong x)
{
    return binary_pow(x, MOD - 2);
}

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

    cin >> n >> k;

    fact.resize(n + 1);
    inv_fact.resize(n + 1);

    fact[0] = inv_fact[0] = 1;
    for (llong i = 1; i <= n; i++)
    {
        fact[i] = (fact[i - 1] * i) % MOD;
        inv_fact[i] = inv(fact[i]);
    }

    for (llong zeros = 0; zeros < n; zeros++)
    {
        if (zeros > k)
            break;

        llong first = c(n, zeros);
        llong second = c(n - 1, n - zeros - 1);

        ans = (ans + (first * second) % MOD) % MOD;
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n, m; cin >> n >> m;
    vvi a(n, vi(m));
    rep(i, n){
        ll k; cin >> k;
        rep(j, k){
            ll in; cin >> in; in--;
            a[i][in] = 1;
        }
    }
    ll cnt = 0;
    rep(i, m){
        ll count = 0;
        rep(j, n) if(a[j][i] == 1) count++;
        if(count == n) cnt++;
    }
    cout << cnt << endl;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;

typedef long long LL;
typedef long double ldouble;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    string s;
    cin >> s;
    bool f = true;
    for(int i = s.size() - 1; i >= 0; --i) {
        if(i >= 4) {
            if(i >= 5 && s[i - 5] == 'e' && s[i - 4] == 'r' && s[i - 3] == 'a' && s[i - 2] == 's' && s[i - 1] == 'e' && s[i] == 'r') {
                i -= 5;

            } else if(s[i - 4] == 'e' && s[i - 3] == 'r' && s[i - 2] == 'a' && s[i - 1] == 's' && s[i] == 'e') {
                i -= 4;

            } else if(i >= 6 && s[i - 6] == 'd' && s[i - 5] == 'r' && s[i - 4] == 'e' && s[i - 3] == 'a' && s[i - 2] == 'm' && s[i - 1] == 'e' && s[i] == 'r') {
                i -= 6;

            } else if(s[i - 4] == 'd' && s[i - 3] == 'r' && s[i - 2] == 'e' && s[i - 1] == 'a' && s[i] == 'm') {
                i -= 4;

            } else {
                f = false;

            }
        }
    }
    if(f) cout << "YES";
    else cout << "NO";
    cout << endl;
    return 0;
}



Measured memory_bytes: 512
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
long int n;
long int a[100005][3];
long int dp[102][100005];
long int Func(int i,int wt_left){
    if(i>=n)    return 0;
    if(dp[i][wt_left]!=-1) return dp[i][wt_left];
    if(wt_left==0) return 0;
    dp[i][wt_left] = Func(i+1,wt_left);
    if(-a[i][0]+wt_left>=0){
        dp[i][wt_left] = max(dp[i][wt_left],a[i][1]+Func(i+1,wt_left-a[i][0]));
    }
    return dp[i][wt_left];
}
int main(){
    
	cin>>n;
	long int sum_left;
	cin>>sum_left;
	for(int i =0;i<n;i++){
	    cin>>a[i][0]>>a[i][1];
	}
	memset(dp,-1,sizeof(dp));
	

	cout<<Func(0,sum_left)<<endl;
// 	for(int i=0;i<n;i++){
// 	    for(int j=0;j<sum_left;j++){
// 	        cout<<dp[i][j]<<" ";
// 	    }
// 	    cout<<endl;
// 	}
}

Measured memory_bytes: 83344
import math
N,M=[int(i) for i in input().split()]
mod=10**9+7
#a=[int(input()) for i in range(N)]

if abs(N-M)>=2:
  print(0)
elif abs(N-M)>=1:
  print(((math.factorial(M))*math.factorial(N))%mod)
else:
  print((2*(math.factorial(M))*math.factorial(N))%mod)

Measured memory_bytes: 5184
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;

#define FOR(x) for(int i = 0; i < x; i++)

stack<short> x, y;
short a[10], n, j, i;

bool solve(short c, bool judge){
	if(c == 10) return true;
	if(x.top() < a[c]){
		x.push(a[c]);
		if(solve(c + 1, true)) return true;
	}
	if(y.top() < a[c]){
		y.push(a[c]);
		if(solve(c + 1, false)) return true;
	}
	if(judge) x.pop();
	else y.pop();
	return false;
}

int main(){
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		x.push(0);
		y.push(0);
		for(j = 0; j < 10; j++)
			scanf("%d", &a[j]);
		if(solve(0, true)) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 1016
#include "bits/stdc++.h"
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long int
#define tc int t; cin>>t; while(t--)
#define fora(i,n) for(int i=0;i<n;i++)
#define forb(i,a,n) for(int i=a;i<n;i++)
#define dbg(x)    { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y)  { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define mod 1000000007
using pii= pair<int,int>;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
template<class T> T power(T N,T P){ return (P==0)?  1: N*power(N,P-1);}
void solve() {
    int n; cin>>n;
    int arr[n];
    fora(i,n) cin>>arr[i];
    int dp[n+1]={0};
    dp[0]=0;
    for(int i=1;i<=n;i++) {
        if(i==1) {
            dp[i]=abs(arr[0]-arr[1]);
        }
        else dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);
    }
    // for(auto it:dp) cout<<it<<" ";
        // cout<<"\n";
    cout<<dp[n-1];
}


int32_t main()
{
    fastio
    solve();  
    

    return 0;


}

Measured memory_bytes: 4364
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long[] map = new long[100002];
        int n = sc.nextInt();
        long k = sc.nextLong();
        for(int i = 0; i < n; i++){
            map[sc.nextInt()] += sc.nextLong();
        }
        for(int i = 1; i <= 100000; i++){
            k -= map[i];
            if(k <= 0){
                System.out.println(i);
                return;
            }
        }
    }
}


Measured memory_bytes: 80800
#include<bits/stdc++.h>
using namespace std;
int cnt[100005];
int main(){
  int n, x;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x; cnt[x]++;
  }
  int res = 0, say = 0;
  for (int i = 1; i <= 100000; i++) {
    if (cnt[i] == 0) continue;
    res += cnt[i] - 1;
    say++;
  }
  cout << (res % 2 == 0 ? say : say - 1) << endl;
  return 0;
}

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

int main() {
	ll n;
	cin >> n;
	map<string, ll>ss;
	for (int i = 0; i < n; i++) {
		string a;
		cin >> a;
		sort(a.begin(), a.end());
		if (ss.count(a))ss.at(a)++;
		else ss[a] = 1;
	}
	ll ans = 0;
	for (auto a : ss) {
		ll x = a.second;
		ans += x * (x - 1) / 2;
	}
	cout << ans << endl;

	

}

Measured memory_bytes: 11136
#include "iostream"
using namespace std;

int main(int argc, char const *argv[])
{
	int n,m=0;
	cin >> n >> m;

	int A[n][m];
	int b[m];
	int ans[n];
	int i,j=0;

	for (i=0;i<n;++i)
	{
		ans[i]=0;
	}

	for(i=0;i<n;i++)
	{
		for (j=0;j<m;++j)
		{
			cin >> A[i][j];
		}
	}

	// for(i=0;i<n;i++)
	// {
	// 	for (j=0;j<m;++j)
	// 	{
	// 		cout << A[i][j];
	// 	}
	// 	cout << endl;
	// }

	for (i=0;i<m;++i)
	{
		cin >> b[i];
	}

	// for (i=0;i<m;++i)
	// {
	// 	cout << b[i] << endl;
	// }

	for (i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			ans[i] += A[i][j] * b[j];
			// cout << "ans[" << i <<"]=" << ans[i] << endl;
		}
	}

	for(i=0;i<n;i++)
	{
		cout << ans[i]<< endl;
	}
	return 0;
}


Measured memory_bytes: 3108
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

# N, M, X = list(map(int, sys.stdin.readline().split()))
# A = np.array(list(map(int, sys.stdin.readline().split())))
#
# print(min(len(A[A > X]), len(A[A<X])))

A, B, K = list(map(int, sys.stdin.readline().split()))

a = list(range(A, min(B, A + K)))
b = list(range(max(A, B - K + 1), B + 1))



print('\n'.join(map(str, list(sorted(set(a + b))))))


Measured memory_bytes: 13816
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vil vector<pil>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e6 + 5;
const double eps = 1e-9;
ll pw[22], d, ans = 0;

void dfs(ll cur, int dep, int mx, ll cnt, int fl, ll& nx) {
	if (d == cur && dep > mx/2) {
		nx += cnt;
		return;
	}
	if (dep > mx/2) return;
	ll val = pw[dep] - pw[mx+1-dep];
	for (ll i = -9; i <= 9; i++) {
		if (pw[mx+1-dep] <= llabs(cur + val * i - d)) continue;
		dfs(cur + val * i, dep + 1, mx, cnt * (10 - fl - llabs(i)), 0, nx);
	}
}

int main() {
	pw[1] = 1;
	for (int i = 2; i <= 19; i++)
		pw[i] = pw[i-1] * 10ll;
	nl(d);
	for (int i = 1; i <= 19; i++) {
		ll cur = 0;
		dfs(0, 1, i, 1, 1, cur);
		ans += cur + 9 * (i&1) * cur;
	}
	prl(ans);
	return 0;
}


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

//return vector include prome number under N
vector<long long> prime_list(long long N){
    vector<long long> prime_list(N+1);
    for(long long i=0; i<N+1; i++){
        prime_list[i]=0;
    }

    prime_list[0]=1;
    prime_list[1]=1;

    for(long long i=2; i<=sqrt(N); i++){
        for(long long j=i*2; j<=N; j+=i){
            prime_list[j]=1;
        }
    }

    vector<long long> list;
    for(long long i=0; i<N+1; i++){
        if(prime_list[i]==0) list.push_back(i);
    }

    return list;
}

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

    if(n==1){
        cout<<"0"<<endl;
        return 0;
    }

    int flag=0;
    for(ll i=2; i<=sqrt(n); i++){
        if(n%i==0){
            flag=1;
            break;
        }
    }
    if(flag==0){
        cout<<"1"<<endl;
        return 0;
    }

    vector<ll> prime=prime_list(sqrt(n));
    vector<ll> v;

    ll num=n;
    rep(i, prime.size()){
        if(num%prime[i]==0){
            ll prime_num=0;
            while(num%prime[i]==0){
                prime_num++;
                num=num/prime[i];
                if(num==0) break;
            }
            v.push_back(prime_num);
        }
    }
    if(num>1) v.push_back(1);

    ll ans=0;
    rep(i, v.size()){
        ll num=v[i];
        ll number=1;
        ll a=2;
        while(num>=number){
            ans++;
            number+=a;
            a++;
        }
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 12064
while True:
    num,sums = map(int, input().split())
    if num == 0 and sums == 0:
        break
    count = 0
    for x in range(1, num + 1):
        for y in range(x + 1, num + 1):
            for z in range(y + 1, num + 1):
                if x + y + z == sums:
                    count += 1
    print(count)


Measured memory_bytes: 5596
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
using namespace std;

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	cout << a[0] << b[1] << c[2] << endl;
}

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

int N, L[10];

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

	int m = L[0];
	int m_i = 0;
	for (int i = 1; i < N; ++i)
	{
		if (L[i] > m)
		{
			m = L[i];
			m_i = i;
		}
	}

	int sum = 0;

	for (int i = 0; i < N; ++i)
	{
		if (m_i != i)
		{
			sum += L[i];
		}
	}

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

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

int main(){
    int a ,b;
    cin >> a >> b;
    if ( a < b ) {
    cout <<"a < b"<< endl;
    }  if ( a > b ) { 
    cout <<"a > b"<< endl;
    }  if ( a == b ) {
    cout <<"a == b"  << endl;
    }
}

 



Measured memory_bytes: 3080
x,n=map(int,input().split())
if n!=0:
    ls=list(map(int,input().split()))

if n==0:
    print(x)
else:
    if x in ls:
        ls.sort()
        x_idx = ls.index(x)
        pos_search = x + 1
        ans_1 = ls[-1]+1
        ans_2 = ls[0]-1
        for i in ls[x_idx+1:]:
            if i == pos_search:
                pass
            else:
                ans_1 = pos_search
                break
            pos_search+=1
        nega_ls = ls[:x_idx]
        nega_ls.reverse()
        nega_search = x - 1
        for i in nega_ls:
            if i == nega_search:
                pass
            else:
                ans_2 = nega_search
                break
            nega_search-=1
        if abs(ans_2-x) <= abs(ans_1-x):
            print(ans_2)
        else:
            print(ans_1)
    else:
        print(x)

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

using namespace std;

long long dp[5001], dp1[25000001];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    // knApsAck
    // weight is Ga, value is Gb

    int n, ga, sa, ba, gb, sb, bb;
    cin >> n >> ga >> sa >> ba >> gb >> sb >> bb;

    long long out = n, best = n;

    for(int i = 0; i <= n; ++i){
        dp[i] = i;
        if(i >= ga)
            dp[i] = max(dp[i], dp[i - ga] + gb);
        if(i >= sa)
            dp[i] = max(dp[i], dp[i - sa] + sb);
        if(i >= ba)
            dp[i] = max(dp[i], dp[i - ba] + bb);
        best = max(best, dp[i]);
    }

    for(int i = 0; i <= best; ++i){
        dp1[i] = i;
        if(i >= gb)
            dp1[i] = max(dp1[i], dp1[i - gb] + ga);
        if(i >= sb)
            dp1[i] = max(dp1[i], dp1[i - sb] + sa);
        if(i >= bb)
            dp1[i] = max(dp1[i], dp1[i - bb] + ba);
        out = max(out, dp1[i]);
    }

    cout << out << "\n";

    return 0;

}


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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl

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

    // input
    ll N, Q;
    cin >> N >> Q;

    stack<ll> sta[N];

    FOR(q, 0, Q){
        ll a;
        cin >> a;

        // push
        if(a==0){
            ll t, x;
            cin >> t >> x;
            sta[t].push(x);
        }
        // top
        else if(a==1){
            ll t;
            cin >> t;
            if(sta[t].size()>0){
                p(sta[t].top());
            }
        }
        // pop
        else{
            ll t;
            cin >> t;
            if(sta[t].size()>0){
                sta[t].pop();
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 5228
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int, int>pii;
typedef pair<int, pii>pi3;
ll mod = 1000000007;
int m[100][100];
bool flag[100][100];
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
int main()
{
	int n, a;
	cin >> n >> a;
	printf((n % 500 <= a) ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
constexpr ll INF = 1e15;

pair<ll, vecint> solve(const vecll& a, int orig) {
  int n = a.size();
  ll sum = 0;
  vecint ans;
  bool found = false;
  ll mx = -INF;
  ll mxi = -1;
  int oldorig = orig;
  REP(i,n) {
    if (a[i] > mx) {
      mx = a[i];
      mxi = i;
    }
    if (a[i] >= 0) {
      sum += a[i];
      if (found) {
        ans.push_back(2);
        orig -= 2;
      } else {
        found = true;
      }
    } else {
      if (found) {
        ans.push_back(3);
        if (orig == 3) {
          ans.push_back(2);
        }
        orig -= 2;
      } else {
        ans.push_back(1);
        ans.push_back(1);
        orig -= 2;
      }
    }
  }
  if (mx < 0) {
    ans.clear();
    sum = mx;
    orig = oldorig;
    REP(i,2*mxi) {
      ans.push_back(1);
      --orig;
    }
  }
  while (orig > 1) {
    ans.push_back(orig);
    --orig;
  }
  return make_pair(sum, ans);
}

int main()
{
  int n;
  cin>>n;
  vecll a(n);
  REP(i,n) cin>>a[i];
  vecll even;
  vecll odd;
  REP(i,n) {
    if (i%2 == 0) even.push_back(a[i]);
    else odd.push_back(a[i]);
  }
  auto ans_ev = solve(even, n);
  auto ans_od = solve(odd, n-1);
  if (ans_ev.first >= ans_od.first) {
    cout<<ans_ev.first<<"\n";
    cout<<ans_ev.second.size()<<"\n";
    for(auto&&e:ans_ev.second) {
      cout<<e<<"\n";
    }
  } else {
    cout<<ans_od.first<<"\n";
    cout<<ans_od.second.size()+1<<"\n";
    cout<<"1\n";
    for(auto&&e:ans_od.second) {
      cout<<e<<"\n";
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream> 
                    
int main() {        
    int h, w = 0;   
                    
    while(std::cin >> h >> w, h || w) {
        for(int i = h ; i; i--) {
            for(int j = w; j; j--) {
                if(i == h || i == 1 || j == w || j == 1) {
                    std::cout << "#";
                }else {
                    std::cout << ".";
                }   
            }       
            std::cout << std::endl;
        }           
        std::cout << std::endl;
    }               
                    
    return 0;       
}

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

constexpr int INF = 1e9;

void print(const vector<int> & vs){
    cout << vs[0];
    for (int i = 1; i < vs.size(); ++i) cout << ' ' << vs[i];
    cout << endl;
}

class RMQ{
private:
    int n;
    vector<vector<int>> data; // doubling_range_min  data[k][p] : min(src[p:p+2^k])  including p and not including p+2^k
public:
    RMQ(const vector<int> &src): n(src.size()){
        data.emplace_back(src);
        for (int k = 0, r = 1; r < n; ++k, r <<= 1 ){
            data.emplace_back(data[k]);
            for (int p = 0; p + r < n; ++p) data[k + 1][p] = min(data[k][p], data[k][p + r]);
        }
    }
    int query(int L, int R){ // min(data[0][L..R] including both ends. [L, R]
        if (L == R) return data[0][L];
        int k = 31 - __builtin_clz(R - L);
        return min(data[k][L], data[k][R + 1 - (1<<k)]);
    }
};

int get_smallest(int s, int t, RMQ & rmq0, RMQ & rmq1){
//    assert(s <= t - 1);
    if (s & 1){
        return rmq1.query(s, t - 1);
    }else{
        return rmq0.query(s, t - 1);
    }
}

void process(int s, int t, priority_queue<int> & pq, vector<tuple<int, int, int>> & data, RMQ & rmq0, RMQ & rmq1, const vector<int> & idx){
    if (s + 1 >= t) return;
    int x = get_smallest(s, t - 1, rmq0, rmq1);
    int y = get_smallest(idx[x] + 1, t, rmq0, rmq1);
    data[x] = make_tuple(y, s, t);
    pq.push(-x);
}

vector<int> solve(int N, const vector<int> & ps){
    // 分割統治する。
    // pq に、(x, y, s, t) を入れる。 (x, y) 区間 ps[s:t - 1) のうち、sから数えて偶数位置にある最小の x、xの位置から数えて奇数位置にある最小y
    // pq から、x最小のものを取り出し、処理する。
    //   qs の末尾に、x, y を追加する。
    //   ps[s:t) を、x, y の位置で分割する。
    //      idx[x] = i, idx[y] = j とすると、[s:i), [i + 1:j), [j + 1:t) に分割する。
    //      区間の幅がゼロのときは、処理をスキップする。
    //   分割した区間のそれぞれについて、区間内の最小のx, y を求め、pq に追加する。
    // 上記の操作のため、以下の前処理をしておく。
    // idx[v] = i : ps[i] = v の逆引き
    // rmq0, rmq1 : psの区間のうち、偶数位置、奇数位置での最小値を返す range minimum query。
    //              rmq0 であれば、奇数位置をINFとして長さNの rmq を用意すればよい。
    vector<int> qs = {};
    priority_queue<int> pq;
    vector<tuple<int, int, int>> data(N + 1);  // data[x] = (y, s, t)
    vector<int> idx(N + 1);
    for (int i = 0; i < N; ++i) idx[ps[i]] = i;
    vector<int> ps0 = ps;
    vector<int> ps1 = ps;
    for (int i = 1; i < N; i += 2) ps0[i] = INF;
    for (int i = 0; i < N; i += 2) ps1[i] = INF;
    RMQ rmq0(ps0);
    RMQ rmq1(ps1);
    process(0, N, pq, data, rmq0, rmq1, idx);
    while (not pq.empty()){
        int x, y, s, t;
        x = -pq.top();
        pq.pop();
        tie(y, s, t) = data[x];
        qs.push_back(x);
        qs.push_back(y);
        process(s,          idx[x], pq, data, rmq0, rmq1, idx);
        process(idx[x] + 1, idx[y], pq, data, rmq0, rmq1, idx);
        process(idx[y] + 1, t,      pq, data, rmq0, rmq1, idx);
    }
    return qs;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> ps(N);
    for (auto & p : ps) cin >> p;
    print(solve(N, ps));
    return 0;
}


Measured memory_bytes: 36984
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int power(int x, unsigned int y, unsigned int m)
{
    if (y == 0)
        return 1;
    int p = power(x, y/2, m) % m;
    p = (p * p) % m;
    return (y%2 == 0)? p : (x * p) % m;
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int n,m;
		cin >> n >> m;
		if(n==m){
			rep(i,0,m) cout<<m;
		}
		else{
			rep(i,0,max(n,m)) cout<<min(n,m);
		}
	}
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll S, W; cin >> S >> W;
  if (W >= S) {
    cout << "unsafe\n";
  }else {
    cout << "safe\n";
  }

  return 0;
}



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

int main() {
    int k, a, b; cin >> k >> a >> b;
    for(int i=a; i<=b; ++i) {
        if(i%k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3588
N = int(input())

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

def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
        
a = A[0]
for i in range(N):
    a = gcd(a,A[i])

print(a)
    

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

ll mod = 1e9+7;
ll fact[123456];

void pre(){
    fact[0] = 1;
     for(int i = 1; i < 123456; i++){
        fact[i] = (1LL*fact[i-1]*i)%mod;
     }

}



int main() {
	int n, m;
	cin >> n >> m;
	pre();
	if(abs(n-m) > 1){
        cout << 0;
	}
	else{
       ll ans;
       if(n == m){
           ans = (2*fact[n]*fact[m])%mod;
       }
       else{
         ans = (fact[n]*fact[m])%mod;
       }
       cout << ans;
	}
	return 0;
}


Measured memory_bytes: 1152
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")
 
 
def main():
    A, B = input(), input()
    print("YES" if A == B[::-1] else "NO")
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)



int main(){
	int n;
	int p[20];
	cin >> n;
	REP(i,n) cin >> p[i];
	
	int ans=0;
	for(int i=1; i<n-1; i++){
		if(p[i-1]<p[i] && p[i]<p[i+1]) ans++;
		if(p[i-1]>p[i] && p[i]>p[i+1]) ans++;
	}
	
	cout << ans << endl;
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
macro_rules! scan {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              scan!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              scan!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty;;$n:expr) => {
          (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
      };
}

fn main() {
    let (n, c) = scan!(usize, usize);

    let mut chans = Vec::new();
    for _ in 0..c {
        chans.push([0; 2 * 100001])
    }
    for _ in 0..n {
        let (s, t, c) = scan!(usize, usize, usize);
        chans[c - 1][2 * s - 1] += 1;
        chans[c - 1][2 * t] -= 1
    }

    let mut tvs = [0; 2 * 100001];
    for i in 0..chans.len() {
        for j in 1..chans[i].len() {
            chans[i][j] += chans[i][j - 1];
            // if chans[i][j] > 1 {
            //     chans[i][j] = 1
            // }
        }

        for (j, tv) in tvs.iter_mut().enumerate() {
            if chans[i][j] > 0 {
                *tv += 1
            }
            //*tv += chans[i][j]
        }
    }

    println!("{}", tvs.iter().max().unwrap())
}


Measured memory_bytes: 33788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    ll ans = 0;
    for(ll a = 1 ; a <= 1000000 ; a++){
        for(ll b = 1 ; b <= 1000000 ; b++){
            if(a * b < n)
                ++ans;
            else
                break;
        }
    }
    //cout<<1005*1005<<" ";
    cout<<ans;
}


Measured memory_bytes: 3648
N,A,B,C,D=map(int,input().split())
ans=False

for i in range(N):
  if i*C - (N-i-1)*D <= abs(B-A) <= i*D - (N-i-1)*C:
    ans=True
    break
if ans:
  print("YES")
else:
  print("NO")

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

bool isKaibun(string s, int a, int b){
    bool res = true;
    for(int i = 0; i <= (b-a)/2; i++) res &= (s[a+i] == s[b-i]);
    return res;
}

int main(){
    string s; cin >> s;
    int n = s.size();
    bool res = true;
    res &= isKaibun(s, 0, n-1);
    res &= isKaibun(s, 0, (n-1)/2-1);
    res &= isKaibun(s, (n+3)/2-1, n-1);
    if(res) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
a=[]
for i in range(h):
    a1=list(input())
    if a1!=['.']*w:
        a.append(a1)
    else:
        h-=1
i=0
while i < w:
    if [a[j][i]=='.' for j in range(h)]==[True]*h:
        w-=1
        a=[a[j][:i]+a[j][i+1:] for j in range(h)]
        #print(a)
    else:
        i+=1
for i in range(h):
    print(''.join(a[i]))

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

set<ll> primeFactorization( ll n ){
  set<ll> a = {1};
  while( n != 1 ){
    ll root = (ll)sqrt(n);
    for(ll i=2;i<=n;++i){
	  if( i > root ){
        a.insert(n);
        n /= n;
        break;
      }
      if( n%i == 0 ){
        a.insert(i);
        n /= i;
        break;
      }
    }
  }
  return a;
}


int main() {
  ll a,b;cin >> a >> b;
  ll num = __gcd(a,b);
  set<ll> array = primeFactorization(num);

  //for( auto p : array ) cout << p << endl;
  cout << array.size() << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main()
{
     int n, num, dig, rev = 0;
     cin >> num;
     n = num;
     do
     {
         dig = num % 10;
         rev = (rev * 10) + dig;
         num = num / 10;
     } while (num != 0);

     if (n == rev)
         cout << "Yes";
     else
         cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

int main(){
    ll n,a,b;cin>>n>>a>>b;
    if(a == 0 && b == 0)cout<<0<<endl;
    else cout<<a*(n/(a+b))+min(n%(a+b),a)<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a);i<=(b);i++)
#define ROF(i,a,b) for(int i = (a);i>=(b);i--)
#define MST(a,x) memset(a,x,sizeof(a))
#define ll long long
#define PB push_back
#define PH push
#define MP make_pair
#define FT first
#define SD second
#define N 100005
#define M 21
#define INF 1000000000000007
#define MOD 1000000007
#define MOD2 1000000009
#define eps 1e-14
using namespace std;
vector<pair<int,ll> >e[2*N+5];
int vis[2*N+5];
ll val[2*N+5];
ll up,down;
bool dfs(int u)
{
    int f = 1;
    if(u<=N)up = min(up,val[u]);
    else down = min(down,val[u]);
    vis[u] = 1;
    for(auto v:e[u])
    {
        int to = v.FT;
        ll w = v.SD;
        if(vis[to])
        {
            if(val[to]!=w-val[u])return 0;
            continue;
        }
        val[to] = w-val[u];
        f = f&dfs(to);
    }
    return f;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r,c,n;
    while(cin>>r>>c)
    {
        cin>>n;
        MST(vis,0);
        FOR(i,1,2*N-1)e[i].clear();
        FOR(i,1,n)
        {
            int x,y,z;
            cin>>x>>y>>z;
            e[x].PB(MP(N+y,z));
            e[N+y].PB(MP(x,z));
        }
        int f = 1;
        FOR(i,1,2*N)
        {
            if(!vis[i])
            {
                up = down = INF;
                val[i] = 0;
                f = f&dfs(i);
                if(up+down<0)f = 0;
                if(!f)break;
            }
        }
        if(f)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


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

template<class T> inline bool chmin(T& a, T b){
    if(a > b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;
long long dp[100010];
long long h[100010];

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; ++i) cin >> h[i];
    for(int i = 0; i < 100010; ++i) dp[i] = INF;
    dp[0] = 0;
    for(int i = 1; i < N; ++i){
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if(i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[N-1] << endl;

    return 0;
}

Measured memory_bytes: 1792
n=int(input())
n_ls=list(str(n))
n_top,n_bottom=int(n_ls[0]),int(n_ls[-1])
if n<100:
    n_middle=0
else:
    n_middle=int("".join(n_ls[1:-1]))
len_n=len(n_ls)
count=0
for i in range(1,n+1):
    stred_ls=list(str(i))
    top,bottom=int(stred_ls[0]),int(stred_ls[-1])
    if bottom==0:
        continue
    # 頭とケツが一緒の時は, 1桁の数も候補になる
    if top==bottom:
        count+=1
    #print("1:",count)
    if len_n<=2:
        if int(str(bottom)+str(top))<=n:
            count+=1
        #print("2:",count)
    else:
        for x in range(len_n-2):
            count+=10**x
        #print("2:",count)
        judged_x=x+1
        #print('比較', str(bottom)+("X"*judged_x)+str(top), n)
        if n_top>bottom:
            count+=10**judged_x
        elif n_top==bottom:
            if n_bottom>=top:
                count+=n_middle+1
            else:
                count+=n_middle
        #print("3:",count)
print(count)
    

Measured memory_bytes: 43372
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>

template<typename T> bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}

template<typename T> bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N,M;
    cin>>N>>M;
    
    if(N==1){
        cout<<M<<endl;
        return 0;
    }
    
    for(ll i=1;i<=sqrt(M);i++){
        if(M%i==0 && i>=N){
            cout<<M/i<<endl;
            return 0;
        }
    }
    for(ll i=sqrt(M);i>=1;i--){
        if(M%i==0 && M/i>=N){
            cout<<i<<endl;
            return 0;
        }
    }
    
    return 0;
}


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

int main(){
  int n;
  cin>>n;
  string s=to_string(n);
  int a=0;
  for(int i=0;i<s.size();++i)a+=s[i]-'0';
  cout << (n%a?"No":"Yes") << endl;
  return 0;
}

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

typedef struct{
  char c;
  int n;
}Card;

int main(){
  int n,num,i,j,min;
  Card a[110],b[110],v;
  int flag;
  char c;

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

  flag = 1;
  while(flag){
    flag =0;
    for(j = n - 1; j > 0; j--){
      if(a[j].n < a[j-1].n){
        v = a[j];
        a[j] = a[j-1];
        a[j-1] = v;
        flag = 1;
      }
    }
  }
  for(j = 0; j < n; j++){
    if(j)printf(" ");
      printf("%c%d",a[j].c,a[j].n);
  }
  printf("\n");
  printf("Stable\n");



  for(i = 0; i < n-1; i++){
    min =i;
    for(j = i; j < n; j++){
      if(b[j].n < b[min].n) min = j;
    }
    v = b[i];
    b[i] = b[min];
    b[min] = v;
  }
  for(j = 0; j < n; j++){
    if(j)printf(" ");
      printf("%c%d",b[j].c,b[j].n);
  }
  printf("\n");

  for(i=0;i<n;i++){
    if(a[i].c!=b[i].c){
      printf("Not stable\n");
      break;
    }
  }
  if(i == n) printf("Stable\n");
  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
using graph = vector<vector<int>>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c;
    cin >> a >> b >> c;
    if(a <= b * c){
        cout << "Yes" <<"\n";
    }else{
        cout << "No" <<"\n";
    }
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL W,H,x,y;
int main()
{
    scanf("%lld%lld%lld%lld",&W,&H,&x,&y);
    double t=(double)W*H/2;
    int flag=0;
    if(x*2==W&&y*2==H)
        flag=1;
    printf("%.6f %lld\n",t,flag);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
    int n;
    cin>>n;
    int a[n];
   // int sum=0;
    for(auto &x:a)
    cin>>x;
    sort(a,a+n);
    int sum=a[n-1];
    int k=n-2;
    for(int i=n-3;i>=0;i-=2)
    {
        if(!i)
        sum+=a[k];
        else
        sum+=2*a[k];
        k--;
    }
    cout<<sum;
}

Measured memory_bytes: 5184