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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;
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; }

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

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

// 繰り返し二乗法
ll power(ll a, ll b){
    if(a==1)return a;
    // if(a==0)re
    ll res=1;
    while(b>0){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}

const int MAX=2100000;

ll fact[MAX], fact_inv[MAX];

void init_fact(ll n){
    fact[0]=1;
    // 階乗の計算
    for(ll i=0; i<n; i++) fact[i+1]=fact[i]*(i+1)%MOD;
    fact_inv[n]=power(fact[n], MOD-2);
    // 逆元の計算
    for(ll i=n-1;i>=0;i--) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
}

ll comb(ll n, ll r){
    return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}

ll perm(ll n, ll r){
    return (fact[n]*fact_inv[n-r])%MOD;
}

int main() {
    cout<<fixed<<setprecision(10);

    string s,t; cin>>s>>t;
    vint rui_s(s.size()+1, 0);
    vint rui_t(t.size()+1, 0);
    rep(i,s.size()){
        rui_s[i+1] = rui_s[i] + (ll)(s[i] == 'A');
    }
    rep(i,t.size()){
        rui_t[i+1] = rui_t[i] + (ll)(t[i] == 'A');
    }

    auto f = [](ll x, ll y){return (x+2*y)%3;};

    ll q; cin>>q;
    while(q>0){
        ll a,b,c,d; cin>>a>>b>>c>>d;
        a--; b--; c--; d--;

        ll sval, tval;
        sval = f(rui_s[b+1] - rui_s[a], b - a + 1 - (rui_s[b+1] - rui_s[a]));
        tval = f(rui_t[d+1] - rui_t[c], d - c + 1 - (rui_t[d+1] - rui_t[c]));

        if(sval == tval) puts("YES");
        else puts("NO");
        q--;
    }

    return 0;

}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p  = pair<int,int>;
const ll INF = (ll)1e9+7;

const int MAX = (int)1e6;
const int MOD = (int)1e9+7;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
	ll x,y;
	cin >> x >> y;
  	COMinit();
  	for(ll i=1;i<=(ll)1e6;i++){
    	ll two_x = 2*i;
      	if(two_x-y>=0&&x-i>=0&&two_x-y==x-i){
          	cout << COM(i,x-i);
        	return 0;
        }
    }
  	cout << 0;
  	return 0;
}

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

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

   if(M==2){
      int ans1=0,ans2=0;
      for(int i=0;i<N;i++){
         if(i%2==0 and a[i]==2 or i%2==1 and a[i]==1) ans1++;
         if(i%2==0 and a[i]==1 or i%2==1 and a[i]==2) ans2++;
      }
      cout<<min(ans1,ans2)<<endl;
   }else{
      int ans=0;
      for(int i=0;i<N;){
         int i0=i++;
         while(i<N and a[i]==a[i0]) i++;
         ans+=(i-i0)/2;
      }
      cout<<ans<<endl;
   }
   return 0;
}



Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i=0; i< n; i++)
using namespace std;
typedef long long ll;


int main() {
	ll a, b, k,z;
	cin >> a >> b >> k;
	
	if (k - a > 0) {
		if (b - (k - a) < 0) {
			z = 0;
		}
		else z = b - (k - a);
		cout << 0 << " " << z << endl;
	}
	else {
		cout << a-k << " " << b << endl;
	}
	return 0;
}


Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#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)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 210;
int link[N] , vis[N] , n;
vi g[N];
int dfs(int c) {
    for(auto t : g[c]) if(!vis[t]) {
        vis[t] = true;
        if(link[t]==-1||dfs(link[t]))
            return link[t]=c,1;
    }
    return 0;
}
int bipart(int n,int m){
    fill_n(link,m,-1);
    int res=0;
    rep(i,0,n){
        memset(vis,0,m*sizeof(int));
        res += dfs(i);
    }
    return res;
}
bool isoddprim(int x){
    if(x <= 2) return false;
    for(int i=2;i*i<=x;++i) if(x%i==0)
        return false;
    return true;
}

int main(){
    cin >> n;
    map<int,int> vis;
    rep(i,0,n){
        int x;
        cin>>x;
        vis[x]^=1;
        vis[x+1]^=1;
    }
    vi odd , even;
    for(auto e : vis) if(e.se == 1) {
        (e.fi & 1 ? odd : even).pb(e.fi);
    }
    int n = sz(odd) , m = sz(even);
    rep(i,0,n) rep(j,0,m) if(isoddprim(abs(odd[i] - even[j])))
        g[i].pb(j);
    int maxmatch = bipart(n , m);
    cout << maxmatch + ((n - maxmatch) / 2 + (m - maxmatch) / 2) * 2 + ((n - maxmatch) & 1) * 3 << endl;;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9+7;
const int MAX = 5100000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
#define INT_MAX 1e9+7
vector<ll> fac(MAX), finv(MAX), inv(MAX);

void comInit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(ll i=2; i<MAX; i++){
        fac[i] = fac[i-1]*i % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
}


ll com(ll n, ll k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main(){
    ll x,y; cin >> x >> y;
    if((2*y-x)%3!=0 && (2*x-y)%3!=0) puts("0");
    else{
        comInit();
        ll a = (2*y-x)/3;
        ll b = (2*x-y)/3;
        cout << com(a+b,a) << endl;
    }
}

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

using namespace std;

int n, k, arr[100000], memo[100000];

int solve(int i) {
    if (i >= n)
        return 2e9;

    if (i == n - 1)
        return 0;

    int r = 2e9;
    if (memo[i] != -1)
        r = memo[i];
    else
        for (int j = i + 1; j <= i + k; j++)
            r = min(r, abs(arr[i] - arr[j]) + solve(j));
    memo[i] = r;
    return r;
}

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

    memset(memo, -1, sizeof memo);
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    cout << solve(0) << "\n";
}

Measured memory_bytes: 5760
#include <iostream>
using namespace std;
int main(void){
    
    long long int N,M,a = 1,b = 1,c = 1,i;
    cin >> N >> M;
    
    for(i = 0; i < 9; i++){
        a *= 10;
    }
    
    a += 7;
    
    for(i = 1; i <= N; i ++){
            b *= i;
            if( b >= a){
                b %= a;
            }
        }
        for(i = 1; i <= M; i++){
            c *= i;
            if( c >= a){
                c %= a;
            }
        }
    
    if(N == M){
         
         cout << (b * c * 2) % a << endl;
         
    }else if(N - M == 1 || M - N == 1 ){
        
        cout << (b * c) % a << endl;
        
    }else{
        
        cout << 0 << endl;
        
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

string s;
int a;
vector<int> vi1, vi2;
vector<P> v;

int changei(string s){
	int res;
	stringstream ss;
	ss << s;
	ss >> res;
	return res;
}

int main(){
	while (getline(cin, s)){
		if (s == "")break;
		string t = s.substr(0, s.find(","));
		a = changei(t);
		vi1.push_back(a);
	}
	while (getline(cin, s)){
		string t = s.substr(0, s.find(","));
		a = changei(t);
		vi2.push_back(a);
	}
	REP(i, vi1.size()){
		bool f = 0;
		int co = 0;
		REP(j, vi1.size()){
			if (vi1[i] == vi1[j])co++;
		}
		REP(j, vi2.size()){
			if (vi1[i] == vi2[j]){
				co++;
				f = 1;
			}
		}
		if (f){
			if (find(ALL(v), P(vi1[i], co)) == v.end()){
				v.push_back(P(vi1[i], co));
			}
		}
	}
	sort(ALL(v));
	REP(i, v.size()){
		cout << v[i].first << " " << v[i].second << endl;
	}
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
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 int INF=1e18;
const int MOD=1e9+7;

signed main(){
    cout<<50<<endl;
    int K;cin>>K;
    vector<int>A(50,49+K/50);
    int d=K%50;
    REP(i,50){
        if(i<d)A[i]+=51-d;
        else A[i]-=d;
    }
    REP(i,50)cout<<A[i]<<" ";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    ld a, b, h, m;
    cin >> a >> b >> h >> m;
    ld ra = h * (2 * M_PIl) / 12 + m * 2 * M_PIl / 12 / 60;
    ld rb = m * 2 * M_PIl / 60;

    ld xa = a * cosl(ra);
    ld ya = a * sinl(ra);
    ld xb = b * cosl(rb);
    ld yb = b * sinl(rb);

    ld ans = (xb - xa) * (xb - xa) + (yb - ya) * (yb - ya);
    ans = sqrtl(ans);
    printf("%.20Lf\n", ans);

    return 0;
}

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


int main() 
{
    string S;
    cin>>S;
    for (int i = 1; i < 5; i++)
    {
        auto s= S[i-1];
        if(s==S[i])
        {
            cout<<"Bad"<<endl;
            return 0;
        }        
    }
    
    cout<<"Good"<<endl;
    return 0;   
}

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

d = dict()
pre = input()
d[pre] = 1
for _ in range(N - 1):
    w = input()
    if w in d or pre[len(pre) - 1] != w[0]:
        print("No")
        exit()
    d[w] = 1
    pre = w

print("Yes")


Measured memory_bytes: 2940
import numpy as np

def yakusu(n):
    a = []
    for i in range(1, int(n*0.5)+1):
        if n % i == 0:
            a.append(i)
    a.append(n)
    return a

A, B, K = map(int, input().split())
a = yakusu(A)
b = yakusu(B)
ab = []
for i in a:
    if i in b:
        ab.append(i)
print(ab[-1*K])

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

using namespace std;

#define ll long long

int bin_pow(int a, int pow) {
    if (pow == 0) return 1;
    if (pow == 1) return a;
    if (pow % 2 == 0) {
        int tmp = bin_pow(a, pow / 2);
        return tmp * tmp;
    }
    return a * bin_pow(a, pow - 1);
}

int fact(int x) {
    int ans = 1;

    for (int i = 1; i <= x; i++) ans *= i;
    return ans;
}

int count(vector<int> a) {
    int ans = 0;
    unordered_set<int> was;
    for (int i = 0; i < a.size(); i++) {
        int count = a[i] - 1;
        for (int j = 1; j < a[i]; j++) {
            count -= was.count(j);
        }
        ans += count * fact(a.size() - i - 1);
        was.insert(a[i]);
    }

    return ans;
}

ll m = 1000000007;

bool isPrime(int x) {
    for (int i = 2; i * i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}

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

    ll n;
    cin >> n;

    if (n % 2 == 1) {
        cout << 0;
        return 0;
    }

    ll ans = 0;

    for (ll i = 5; i <= n; i *= 5) {
        ans += n / i / 2;
    }

    cout << ans;
    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N[4]; rep(i,4) cin >> N[i];
  sort(N,N+4);
  string result = (N[0]==1&&N[1]==4&&N[2]==7&&N[3]==9) ? "YES" : "NO";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
def digitSum(num):
    s = str(num)
    res = 0
    for c in s:
        res += int(c)
    return res

n = int(input())
r = float('inf')
for i in range(1,n):
    j = n - i
    r = min(r,digitSum(i)+digitSum(j))
print(r)


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

int main(){
    std::string s, t;
    std::cin >> s >> t;

    int n = s.size(), i = 0;
    std::vector<int> sList(26, -1), tList(26, -1);
    bool sFlg = true, tFlg = true; 
    while(sFlg && tFlg && i < n){
        int sElem = s.at(i) - 97;
        if(sList.at(sElem) < 0){
            sList.at(sElem) = t.at(i) - 97;
        }else{
            sFlg = sList.at(sElem) == t.at(i) - 97;
        }

        int tElem = t.at(i) - 97;
        if(tList.at(tElem) < 0){
            tList.at(tElem) = s.at(i) - 97;
        }else{
            tFlg = tList.at(tElem) == s.at(i) - 97;
        }

        ++i;
    }

    std::string ans = "No";
    if(sFlg && tFlg){
        ans = "Yes";
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 1020
#include<stdio.h>

int main(void){
   int a,b,c,k;
   int sum=0;
   scanf("%d %d %d %d",&a,&b,&c,&k);
   for(int i=0;i<a;i++){
      if(k<=0){
         break;
      }
      sum +=1;
      k -=1;
   }
   for(int i=0;i<b;i++){
      if(k<=0){
         break;
      }
      sum +=0;
      k -=1;
   }
   for(int i=0;i<c;i++){
      if(k<=0){
         break;
      }
      sum -=1;
      k -=1;
   }
   printf("%d",sum);
   return 0;
}
         


Measured memory_bytes: 1704
using System;
using System.Linq;
using System.Collections.Generic;

public class Program{
  public static void Main(){
    var n = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
    long a = n[0]%n[2]==0?n[0]/n[2]-1:n[0]/n[2];
    long b = n[1]/n[2];
    Console.WriteLine((b-a).ToString());
  }
}


Measured memory_bytes: 13140
const Main = input => {
  const sp = input.split('\n');
  const K = Number(sp[0]);
  const AB = sp[1].split(' ').map(e => Number(e));

  const A_ex = Math.floor(AB[0] / K);
  const A_mod = AB[0] % K;
  const B_ex = Math.floor(AB[1] / K);
  const B_mod = AB[1] % K;

  console.log((A_mod===0 || B_mod===0 || A_ex < B_ex) ? 'OK' : 'NG');
};

Main(require('fs').readFileSync('/dev/stdin', 'utf8').trim());
/*Main(`7
500 600`);
Main(`4
5 7`)
Main(`1
11 11`)*/


Measured memory_bytes: 29624
a=int(input())
#print(a)
b,c=map(int,input().split())
d=[int(i) for i in input().split()]
#print(d)
e={}
for i in range(a):
	e.update({abs(b-d[i]*0.006-c):i+1})
#print(e)
e=sorted(e.items())
#print(e)
print(e[0][1])


Measured memory_bytes: 3572
#include<iostream>
using namespace std;
int main(){
	int cut=0;
	int a;
	int b;
	while(1){
	cin>>a;
		cut=0;
		if(a==0){
			break;
		}
	b=1000-a;
	cut+=b/500;
	b=b%500;
	cut+=b/100;
	b=b%100;
	cut+=b/50;
	b=b%50;
	cut+=b/10;
	b=b%10;
	cut+=b/5;
	b=b%5;
	cut+=b;
	cout<<cut<<endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include <iostream>

using namespace std;

void dfs(int n, int x, char s[], char nxt) {
    if (x == n) {
        cout << s << endl;
        return;
    }

    for (char i = 'a'; i < nxt; i++) {
        s[x] = i;
        dfs(n, x + 1, s, nxt);
    }

    s[x] = nxt++;
    dfs(n, x + 1, s, nxt);
}

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

    char s[n+1];
    s[n] = 0;
    dfs(n, 0, s, 'a');

    return 0;
}


Measured memory_bytes: 1536
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i64,
        p: i64,
    }
    let num_a = 3 * a + p;
    let pie: i64 = num_a / 2;
    println!("{}", pie);
}

Measured memory_bytes: 4352
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
 
#define int long long
#define read(a) int a; cin >> a;
#define readarr(a, n) int a[(n) + 1] = {}; fori(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori(i, 1, n) {fori(j, 1, m) cin >> a[i][j];}
#define pb push_back
#define fi first
#define se second
#define rz resize
#define sz(s) (int)(s.size())
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define sort1(v) sort(v.begin(), v.end()) 
#define endl '\n'
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 
     
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    //start from here

    int h, w;
    cin >> h >> w;

    char a[h+1][w+1]; int dp[h+1][w+1] = {};
    fori(i, 1, h)
    {
    	fori(j, 1, w) cin >> a[i][j];
    }

    if(a[1][1] == '#') dp[1][1] = 1;

    fori(i, 1, h)
    {
    	fori(j, 1, w)
    	{
    		if(i == 1 && j == 1) continue;

    		else if(i == 1)
    		{
    			dp[i][j] = dp[i][j-1];
    			if(a[i][j-1] == '.' && a[i][j] == '#') dp[i][j]++;
    		}

    		else if(j == 1)
    		{
    			dp[i][j] = dp[i-1][j];
    			if(a[i-1][j] == '.' && a[i][j] == '#') dp[i][j]++;
    		}

    		else
    		{
    			int c1 = dp[i-1][j];
    			int c2 = dp[i][j-1];
    			if(a[i-1][j] == '.' && a[i][j] == '#') c1++;
				if(a[i][j-1] == '.' && a[i][j] == '#') c2++;
				dp[i][j] = min(c1, c2);
    		}
    	}
    }

    cout << dp[h][w];

    return 0;
}


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

int main() {
	int n,q;cin>>n>>q;
	list<int> li[1010];
	
	while(q--){
		int query;cin>>query;
		if(query==0){
			int t,x;cin>>t>>x;
			li[t].push_back(x);
		}else if(query==1){
			int t;cin>>t;
			bool isFirst = true;
			for(auto &&lj: li[t]){
				if(!isFirst) cout << " ";
				cout<<lj;
				isFirst &= false;
			}
			cout<<endl;
		}else{
			int s,t;cin>>s>>t;
			li[t].splice(li[t].end(), move(li[s]));
			li[s].clear();
		}
	}
  return 0;
}




Measured memory_bytes: 18620
main(n,s,i,f,x){unsigned int u;for(scanf("%d",&n);n--;){
	scanf("%x",&u);
	i=(u&0x7fffff80)>>7;
	f=(u&0x7f)*78125;
	for(x=7;x>1&&!(f%10);f/=10)x--;
	printf("%s%d.%0*d\n",u&(1<<31)?"-":"",i,x,f);
}exit(0);}

Measured memory_bytes: 616
# coding: utf-8
n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

count = 0
for i in reversed(range(n)):
    if a_list[i+1] >= b_list[i]:
       count += b_list[i]
       #print(count)
    elif a_list[i+1] < b_list[i]:
        count += a_list[i+1]
        count += min(a_list[i], b_list[i]-a_list[i+1])
        a_list[i] = max(0,a_list[i] - (b_list[i] - a_list[i+1]))
        #print(count)
    
print(count)


Measured memory_bytes: 18624
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,t,a,x,ans=1;
    double temp,mn=(ll)(1e15);
    cin>>n>>t>>a;
    for(ll i=1;i<=n;i++){
        cin>>x;
        temp=abs(t-x*0.006-a);
        if(temp<mn)mn=temp,ans=i;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
A,B=map(int,input().split())
P=list(map(int,input().split()))

C=[0]*3
for p in P:
  if p<=A:
    C[0]+=1
  elif A+1<=p<=B:
    C[1]+=1
  else:
    C[2]+=1
    
print(min(C))

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define INF 1000000001
#define MOD 1000000007

using namespace std;



int main() {
	int n,cnt=0;
	cin >> n;
	vector<int> v;
	REP(i, n) {
		int a;
		cin >> a;
		v.pb(a);
	}
	REP(i, n) {
		RFOR(j,n,i+1){
			if (v[j] < v[j - 1]) {
				swap(v[j], v[j - 1]);
				cnt++;
			}
		}
	}
	REP(i, n) {
		cout << v[i] ;
		if (i != n - 1) cout << " ";
	}
	cout << endl;
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3144
n=int(input())
count=0
for i in range(n):
    yakusu=0
    if((i+1)%2==0):
        continue
    for j in range(i+1):
        if((i+1)%(j+1)==0):
            yakusu+=1
    if(yakusu==8):
        count+=1

print(count)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        double R = scan.nextDouble();
        System.out.printf("%.6f\n", 2 * Math.PI * R);
    }
}


Measured memory_bytes: 28980
x, n = map(int, input().split())
p = list(map(int, input().split()))

ans = 10 ** 9
num = 10 ** 9
a = [0] * 200
for i in range(len(p)):
    a[p[i]] = 1

for i in range(110):
    if a[i] == 1:
        continue

    if ans > abs(i - x):
        num = i
        ans = abs(i - x)

# print(num)
if abs(x - (-1)) <= abs(num-x):
    num = -1
print(num)


Measured memory_bytes: 9196
import java.text.DecimalFormat;
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main {
	
	void run() {
		Scanner sc = new Scanner(System.in);
		
		for(;;) {
			int v = sc.nextInt();
			int l = sc.nextInt();
			if((v|l) == 0) break;
			String fmt = "";
			for(int i=0;i<l;i++) fmt += "0";
			DecimalFormat dc = new DecimalFormat(fmt);
			
			HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
			map.put(v, 0);
			
			int s=0, ans = -1, c=1;
			for(;;c++) {
				String val = dc.format(v);
				int[] ar = new int[l];
				for(int i=0;i<l;i++) ar[i] = val.charAt(i)-'0';
				sort(ar);
				String max = "";
				String min = "";
				for(int i=0;i<l;i++) {
					min += "" + ar[i];
					max += "" + ar[l-i-1];
				}
				int maxI = Integer.valueOf(max), minI = Integer.parseInt(min);
//				debug(maxI, minI);
				v = maxI - minI;
				
				if(map.containsKey(v)) {
					s = map.get(v);
					ans = v;
					break;
				}
				else {
					map.put(v, c);
				}
//				debug(v, c);
			}
			System.out.println(s + " " + ans + " " + (c-s));
		}
	}
	
	void debug(Object... os  ) {
		System.err.println(deepToString(os));
	}
	
	public static void main(String[] args ) {
		new Main().run();
	}
}

Measured memory_bytes: 21752
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
ll gcd(ll a,ll b){
    if(a==0)
        return b;
    else
        return gcd(b%a,a);
}
ll findGCD(vector<ll> arr,ll n) 
{ 
    ll result = arr[0]; 
    for (ll i = 1; i < n; i++) 
        result = gcd(arr[i], result);
    return result; 
}

int main() {
    SPEED;
    cout.precision(8);
    cout << fixed;
    ll m,n;
    cin>>m>>n;
    if(m<=n){
        for(ll i=0;i<n;i++) cout<<m;
    }
    else{
        for(ll i=0;i<m;i++) cout<<n;
    }
    return 0;
}

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

using namespace std;



int main (){
    string s;
    cin >> s;
    int n = s.size();
    long long ans = 0;

    for(int i = 0; i < 1 << (n - 1); i++){
        long long num = 0;
    
        for(int j = 0; j < n; j++){
    
            num = num * 10 + (s[j] - '0');
    
            if(i & (1 << j)){
    	      ans += num;
    	      num = 0;
    	    }
        }
        ans += num;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys

input=sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()


def II(): return int(input())


def MI(): return map(int,input().split())


def MF(): return map(float,input().split())


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


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))


# rstrip().decode('utf-8')

def main():
	n,m,k=MI()
	mod=998244353
	
	f=[1]
	for i in range(1,2*10**5+100):
		f.append((f[-1]*i)%mod)
	finv=[]
	for i in f:
		finv.append(pow(i,mod-2,mod))
	
	mp=[1]
	for i in range(1,2*10**5+100):
		mp.append((mp[-1]*(m-1))%mod)
		
	
	ans=0
	for kk in range(k+1):
		cnt=f[n-1]*finv[kk]*finv[n-1-kk]*m*mp[n-kk-1]
		ans+=cnt
		ans%mod
	print(ans%mod)













if __name__=="__main__":
	main()


Measured memory_bytes: 32860
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
using namespace std;

int main()
{
    long long n;
    cin >> n;
    
    if (n == 2)
    {
        cout << 1 << endl;
        return 0;
    }
    long long res = 0;
    // num of div of n-1
    for (long long i = 2; i <= sqrt(n-1); i++)
    {
        if (i*i == n-1)
        {
            res++;
        }
        else if ((n-1) % i == 0)
        {
            res += 2;
        }
    }
    res++;
    
    for (long long i = 2; i <= sqrt(n); i++)
    {
        if (n % i != 0)
        {
            continue;
        }
        long long m = n;
        while (m % i == 0)
        {
            m /= i;
        }
        if (m % i == 1)
        {
            res++;
        }
        if (i * i == n)
        {
           continue;
        }

        m = n;
        while (m % (n/i) == 0)
        {
            m /= (n/i);
        }
        if (m % (n/i) == 1)
        {
            res++;
        }
    }
    res++;

    cout << res << endl;
}

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



int main(){
    int n;
    while(cin>>n,n){
        vector<LL> a(n);
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        int m;cin >> m;
        vector<LL> mpa,da,mpb,db;
        for (int i = 0; i < m; i++) {
            int x,y;
            string s;cin >> s >> x >> s >> y;
            if(s=="Single") mpa.pb(x),da.pb(y);
            else mpb.pb(x),db.pb(y);
        }
        vector<LL> dpa(1<<17,INF),dpb(1<<17,INF);
        dpa[0] = 0,dpb[0] = 0;
        for (int i = 0; i < mpa.size(); i++) {
            for (int j = 0; j <= 100000; j++) {
                if(dpa[j] == INF) continue;
                int nx = j + da[i];
                if(nx >= 100000) nx = 100000;
                dpa[nx] = min(dpa[nx], dpa[j] + mpa[i]);
            }
        }
        for (int i = 0; i < mpb.size(); i++) {
            for (int j = 0; j <= 100000; j++) {
                if(dpb[j] == INF) continue;
                int nx = j + db[i];
                if(nx >= 100000) nx = 100000;
                dpb[nx] = min(dpb[nx], dpb[j] + mpb[i]);
            }
        }
        LL ma=INF,mb=INF;
        for (int i = 100000; i > 0; i--) {
            ma = min(ma,dpa[i]);
            dpa[i] = ma;
            if(dpb[i]!=INF){
                mb = min(mb,dpb[i]);
                dpb[i] = mb;
            }
        }
        LL ans = INF;
        for (int i = 0; i <= 100000; i++) {
            if(dpb[i]==INF) continue;
            LL tmp = dpb[i];
            for (int j = 0; j < n; j++) {
                if(a[j] - i <= 0) continue;
                tmp += dpa[a[j] - i];
            }
            ans = min(ans, tmp);
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 4984
#include <bits/stdc++.h>
using namespace std;
bool checkString(string str) {
	int len = str.length();
	if (len == 3) {
		return str[0] == str[2];
	}
	int sub = (str.length() - 1)/2;
	for (int i=0; i<=(len-3)/2; i++) {
		if ((str[i] != str[len-1-i]) or (i<=sub/2 - 1 and str[i] != str[sub-i-1])) {
			return false;
		}
	}
    return true;
}
int main(int argc, char **argv) {
	string word;
	cin >> word;
	if (checkString(word)) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	return 0;
}



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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, l, r, s;

int main() {
	cin >> n;
	rep(i,n) {
		cin >> l >> r;
		s += r-l+1;
	}
	cout << s << ln;
}

Measured memory_bytes: 256
using System;

namespace ABC054_A_One_Card_Poker
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(' ');
			int a = int.Parse(input[0]);
			int b = int.Parse(input[1]);

			if (a == 1)
			{
				if(b == 1) Console.WriteLine("Draw");
				else Console.WriteLine("Alice");
			}else if (b == 1)
			{
				if(a == 1) Console.WriteLine("Draw");
				else Console.WriteLine("Bob");
			}
			else
			{
				if(a == b) Console.WriteLine("Draw");
				else if(a > b) Console.WriteLine("Alice");
				else Console.WriteLine("Bob");
			}

		}
	}
}

Measured memory_bytes: 11092
import sys
from collections import Counter


def main():
    input = sys.stdin.buffer.readline
    _ = input()
    a_list = list(map(int, input().split()))
    res_set = set(a_list)
    # キーに要素、値に出現回数を持つカウンタ
    a_counter = Counter(a_list)
    for e in a_counter.items():  # e:(整数，出現回数)
        if e[1] == 1:
            for i in range(e[0] * 2, 10**6 + 1, e[0]):  # その整数を含まない倍数
                res_set.discard(i)
        else:
            for i in range(e[0], 2 * 10**6 + 1, e[0]):  # その整数を含む倍数
                res_set.discard(i)
    print(len(res_set))


if __name__ == '__main__':
    main()


Measured memory_bytes: 47960
#include <iostream>
using namespace std;
int main() {

	int X, score = 0;
	cin >> X;
	while (X >= 500) {
		score += 1000;
		X -= 500;
	}
	while (X >= 5) {
		score += 5;
		X -= 5;
	}
	cout << score;
	return 0;
}

Measured memory_bytes: 256
x = input()

for i in range(1 << 3):
    start = ["+", "+", "+"]
    for j in range(3):
        if (i >> j) & 1:
            start[j] = "-"
    #print(start, i)
    ans = int(x[0])
    for k in range(3):
        if start[k] == "+":
            ans += int(x[k + 1])
        else:
            ans -= int(x[k + 1])
    #print(ans)
    if ans == 7:
        print(x[0] + str(start[0]) + x[1] + str(start[1]) + x[2] + str(start[2]) + x[3] + "=7")
        break


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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for (int &x : a)
    cin >> x;
  sort(a.begin(),a.end());
  cout << a.at(N-1)-a.at(0) << endl;
  return 0;
}

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

int main(){
    int N,D,num;
    cin>>N>>D;
    num=2*D+1;
    if(N%num==0){
        cout<<N/num<<endl;
    }
    else{
        cout<<(N/num)+1<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <utility>
#include <numeric>
#include <iomanip>

using namespace std;

int main() {
    int n; cin >> n;
    vector<string> vec(n);
    for (int i = 0; i < n; i++)
    {
        cin >> vec[i];
        sort(vec[i].begin(), vec[i].end());
    }
    sort(vec.begin(), vec.end());

    long long int ans = 0;
    int i = 0;
    int j = 0;

    while (j < n)
    {
        while (j < n && vec[i] == vec[j])
        {
            j++;
        }
        //cout << i << " " << j << endl;
        ans += (long long)(j - i) * (j - i - 1) / 2;
        i = j;
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 7296
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,c,a,b,ans=1000000000000;
ll l[10];
void solve(ll i,ll sa,ll sb,ll sc,ll fc){
  if(i==n){
    if(sa==0||sb==0||sc==0) return;
    ll tmp = abs(sa-a)+abs(sb-b)+abs(sc-c)+(fc-3)*10;
    ans = min(tmp,ans);
    return;
  }
  solve(i+1,sa+l[i],sb,sc,fc+1);
  solve(i+1,sa,sb+l[i],sc,fc+1);
  solve(i+1,sa,sb,sc+l[i],fc+1);
  solve(i+1,sa,sb,sc,fc);
}
signed main(){
  cin >> n >> a >> b >> c;
  for(int i=0;i<n;i++){
    cin >> l[i];
  }
  solve(0,0,0,0,0);
  cout << ans << endl;
}


Measured memory_bytes: 256
n,p=map(int,input().split())
ps=[]
for i in range(n):
	ps.append(input().split())
	ps[i][1]=int(ps[i][1])
t=0
while len(ps)>0:
	if ps[0][1]>p:
		ps.append([ps[0][0],ps[0][1]-p])
		t+=p
		ps.pop(0)
	else:
		t+=ps[0][1]
		print("{0} {1}" .format(ps[0][0],t))
		ps.pop(0)




Measured memory_bytes: 16852
// finish date: 2018/01/10
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

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

bool isExist(char c, string str) {
    rep(i, str.length()) {
        if (c == str[i]) return true;
    }
    return false;
}

int fact(int n) {
    int ans = 1;
    FOR(i, 1, n + 1) {
        ans *= i;
    }
    return ans;
}

int main() {
    ll a, b, x;
    cin >> a >> b >> x;
    if (a == 0) {
        if (b == 0) cout << 1 << endl;
        else cout << b / x + 1 << endl;
    } else cout << b / x - ((a - 1 > 0) ? a - 1 : 0) / x;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

ll f(ll x, vector<ll>& a, int k) {
  rep(i,k) {
    x=x-x%a[i];
  }
  return x;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int k;
  cin>>k;
  vector<ll> a(k);
  ll mx=0;
  rep(i,k)cin>>a[i];
  rep(i,k)mx=max(mx,a[i]);
  ll lb;
  // calc lb
  {
    ll ok=mx*k+2;
    ll ng=1;
    while(ok-ng>1) {
      ll m=(ok+ng)/2;
      if(f(m,a,k)>=2) {
        ok=m;
      } else {
        ng=m;
      }
    }
    lb=ok;
  }
  ll ub;
  // calc ub
  {
    ll ok=1;
    ll ng=mx*k+2;
    while(ng-ok>1) {
      ll m=(ok+ng)/2;
      if(f(m,a,k)<=2) {
        ok=m;
      } else {
        ng=m;
      }
    }
    ub=ok;
  }
  if(lb<=ub) {
    cout << lb << " " << ub << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
// 161-C Replacing Integer

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>

// qsortで用いる比較用関数．*a<*bならaが先になる．
int compare(const void* a, const void* b) {
    return *(char*)a - *(char*)b;
}

void kojun(char* word) {
    char min_alphabet[2],tmp[2];
    int i, min_i,j;

    for (j = strlen(word) - 1; j > 0; j--) {
        min_i = 0;
        min_alphabet[0] = word[min_i];
        for (i = 1; i < j+1; i++) {
            if (word[i] < min_alphabet[0]) {
                //printf("word[i]:%c min_alphabet:%c ", word[i], min_alphabet[0]);
                min_alphabet[0] = word[i];
                min_i = i;
            }
        }
        tmp[0] = word[j];
        word[j] = word[min_i];
        word[min_i] = tmp[0];
        
        //printf("j:%d min_alphabet:%c\n", j, min_alphabet[0]);
    }
    return;
}

void syojun (char* word) {
    char max_alphabet[2], tmp[2];
    int i, max_i, j;

    for (j = strlen(word) - 1; j > 0; j--) {
        max_i = 0;
        max_alphabet[0] = word[max_i];
        for (i = 1; i < j + 1; i++) {
            if (word[i] > max_alphabet[0]) {
                //printf("word[i]:%c max_alphabet:%c ", word[i], max_alphabet[0]);
                max_alphabet[0] = word[i];
                max_i = i;
            }
        }
        tmp[0] = word[j];
        word[j] = word[max_i];
        word[max_i] = tmp[0];

        //printf("j:%d max_alphabet:%c\n", j, max_alphabet[0]);
    }
    return;
}


int main() {

    int n,i,min= 1000000000,max=1;
    int a;

    scanf("%d", &n);
    
    
    for (i = 0; i < n; i++) {
        scanf("%d", &a);
        if (a < min)min = a;
        if (a > max)max = a;
    }
    printf("%d", max - min);

    return 0;
}

Measured memory_bytes: 128
def main():
    N = int(input())
    h = list(map(int, input().split()))
    dp = [0 for _ in range(N)]
    dp[1] = abs(h[0] - h[1])
    for i in range(2, N):
        h1 = dp[i - 1] + abs(h[i] - h[i - 1])
        h2 = dp[i - 2] + abs(h[i] - h[i - 2])
        dp[i] = min(h1, h2)

    print(dp[-1])


main()


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

#define rep(i,n) for( (i)=0;(i)<(n);++(i) )
#define debg(a) cout<<(a)<<endl;
#define int long long 
#define str string
#define elif else if

int i,j,k;
int dx,dy;
int a,b,c,x,y,n,m,cnt=0,ans=0;
str s,t;

signed main(){
  cin>>a>>b>>c;
  if(b>=c){cout<<b+c<<endl;return 0;}
  elif(a+b>=c){cout<<b+c<<endl;return 0;}
  else{
    ans+=b*2;
    c-=b;
    if(a>=c){cout<<ans+c+1<<endl;return 0;}
    else {
      cout<<ans+a+1<<endl;
    }
  }
  return 0;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = Console.ReadLine().ToCharArray();
            int[] S = new int[A.Count()];

            for(int i = 0; i < A.Count(); i++)
            {
                S[i] = int.Parse(A[i].ToString());
            }


            int count = 0;

            if (S[0] == 0)
            {

                for (int i = 1; i < S.Count(); i++)
                {
                    if (i % 2 == 0 && S[i]==1)
                    {
                        count++;
                    }
                    if(i%2 ==1 && S[i] == 0)
                    {
                        count++;
                    }
                }
            }
            else
            {
                for (int i = 1; i < S.Count(); i++)
                {
                    if (i % 2 == 0 && S[i] == 0)
                    {
                        count++;
                    }
                    if (i % 2 == 1 && S[i] == 1)
                    {
                        count++;
                    }
                }
            }

            Console.WriteLine(count);

        }
    }
}


Measured memory_bytes: 14048
import Foundation

extension String {
    @inlinable
    func wordsMap<T>(_ f: (Substring) -> T?) -> [T] {
        return self.split(separator: " ").compactMap(f)
    }
}

@inlinable
func readWords<T>(_ f: (Substring) -> T?) -> [T] {
    return readLine()!.wordsMap(f)
}

func main() {
    let nh = readLine()!.wordsMap { Int($0) }
    let n = nh[0]
    let h = nh[1]

    var maxA = 0
    let weapons = (1...n).map { _ -> Int in
        let ab = readWords { Int($0) }
        let a = ab[0]
        let b = ab[1]
        maxA = max(a, maxA)
        return b
    }

    let niceB = weapons.filter { $0 > maxA }.sorted(by: >)

    var total = 0
    var ans = 0
    for b in niceB {
        total += b
        ans += 1
        if total >= h {
            print(ans)
            return
        }
    }

    let rest = h - total

    print((rest % maxA == 0 ? 0 : 1) + rest / maxA + ans)
}

main()

Measured memory_bytes: 15660
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod=1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int res=0;
    string chaine;
    for(int i=1;i<=n;i++){
        chaine=to_string(i);
        if(chaine.length()%2==1){res++;}
    }
    cout<<res<<endl;
    return 0;
    }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = long long;
const ll INF = 1000000000000;

int main()
{
    int n;
    long double ans = 0;
    std::cin >> n;
    for(int i = 0; i < n; i++){
        long double x;
        std::string u;
        std::cin >> x >> u;
        if(u == "JPY"){
            ans += x;
        }else{
            ans += (x * 380000);
        }
    }
    std::cout << std::fixed << std::setprecision(18) << ans << std::endl;
}

Measured memory_bytes: 256