akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

int main()
{
    char s[101];
    long sl;
    int i, j = 0;
    char A[10] = "No";
    scanf("%s", s);
    sl = strlen(s);
    
    for (i = 0; i < sl; i++)
    { for (j = 0; j < (sl - i); j++)
    {if (s[i]== 'C' && s[i+j] == 'F')
	   {A[0] = 'Y';
           A[1] = 'e';
           A[2] = 's';
           A[3] = '\0';
           break;}}}

    printf("%s\n", A);
    return 0;
}





Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

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;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int x,y; cin >> x >> y;
    bool f=false;
    if(x==2){
        if(y==2) f=true;
    }else if(x==4 || x==6 || x==9 || x==11){
        if(y==4 || y==6 || y==9 || y==11) f=true;
    }else{
        if(y==1 || y==3 || y==5 || y==7 || y==8 || y==10 || y==12) f=true;
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3612
import math

INF = 1000000007

D, G = map(int, input().split())

p = []
c = []

for i in range(D):
    pi, ci = map(int, input().split())
    p.append(pi)
    c.append(ci)


def main():
    ans = INF

    # 2 ** D - 1 まで
    for b in range(2 ** D):
        num = 0
        pnt = 0

        # コンプリートしない MAX
        x = None

        # 得点が高い方から
        for i in range(D - 1, -1, -1):
            # i 番目 の フラグ が 立っている
            if b >> i & 1:
                num += p[i]
                # コンプリートする
                pnt += c[i] + 100 * (i + 1) * p[i]

            elif x is None:
                x = i

        # コンプリート オール
        # または 既に 目標の 総合スコア に到達
        if x is None or G <= pnt:
            ans = min(ans, num)

        # コンプリートしない
        elif math.ceil((G - pnt) / (100 * (x + 1))) < p[x]:
            ans = min(ans, num + math.ceil((G - pnt) / (100 * (x + 1))))

    print(ans)
    return


main()


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

#define ff first
#define ss second
#define maxn 2000006
#define pb push_back
#define ll long long
#define lll __int128
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<=n;i++)

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

using namespace std;

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

	ll n; cin >> n;

	ll a[n + 1], b[n + 1], c[n];

	f(i, 1, n) cin >> a[i];
	f(i, 1, n) cin >> b[i];
	f(i, 1, n - 1) cin >> c[i];
	ll ans = 0;
	f(i, 1, n) {
		ans += b[a[i]];
		// cout<<b[a[i]]<<" ";
		if (i != 1) {
			if (a[i - 1] + 1 == a[i]) ans += c[a[i - 1]];
		}
		// cout<<endl;
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9) {
		    System.out.println("hon");
		} else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) {
		    System.out.println("pon");
		} else {
		    System.out.println("bon");
		}
		
    }
}

Measured memory_bytes: 35752
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
 
int main(){
  int N,K;
  cin>>N>>K;
  VI X(N);
  rep(i,N) cin>>X[i];
  int ans=1001001001;
  rep(i,N-K+1){
    int tmp=X[K-1+i]-X[i]+min(abs(X[K-1+i]),abs(X[i]));
    ans=min(ans,tmp);
  }
  cout<<ans<<endl;
}

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

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define INF 1000000000
#define PI 3.14159265358979323846

#define _CRT_SECURE_NO_WARNINGS

using namespace std;

// N, E, S, W
const int dx[4] = { -1, 0,  1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<LL> vll;
//==============================================

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

	int n; cin >> n;
	vi dp{1, 1};

	REP3(i, 2, n) {
		dp.push_back(dp[i - 1] + dp[i - 2]);
	}

	cout << dp[n] << "\n";
	return 0;
}

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

int main() {
  int n; cin >> n;
  vector<string> s(n);
  map<char,int> m;
  rep(i,n) cin >> s[i];
  rep(i,n) {
    if (i==0) {
      rep(j,s[i].size()) {
        m[s[i][j]]++;
      }
    } else {
      map<char,int> ms;
      rep(j,s[i].size()) {
        ms[s[i][j]]++;
      }
      for (auto a: m) {
        char k = a.first;
        int v = a.second;
        if (ms.count(k)) {
          if (ms[k] < v) m[k] = ms[k];
        } else m.erase(k);
      }
    }
  }
  for (auto a: m) {
    char k = a.first;
    int v = a.second;
    rep(i,v) cout << k;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3588
fn main(){
    let s :char = input().pop().unwrap();
    if "3".contains(s) {
        println!("bon");
    }else if "0168".contains(s) {
        println!("pon");
    }else{
        println!("hon");
    }
}

fn input() -> String{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_end().to_string()
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<typename T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<typename T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T> bool Min(T a, T b) { return a > b ? b : a; }
template<typename T> bool Max(T a, T b) { return a < b ? b : a; }

const int INF = 1e9+5;


template<typename T> void de(T a){ 
#ifdef LOCAL_DEFINE
	cout<<a<<endl;
#endif
}

int main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    	cout.precision(10);
    	cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif
        
	string a,b;
	cin>>a>>b;

	int n = a.size(),m = b.size();
	vector<vector<pair<int,pair<int,int>>>> dp(n+1,vector<pair<int,pair<int,int>>>(m+1,mp(-INF,mp(0,0))));

	dp[0][0]={0,{0,0}};

	forn(i,n){
	 	forn(j,m){
	 		  if(a[i]==b[j]){
	 		  	dp[i+1][j+1]=mp(dp[i][j].fi+1,mp(i,j));
	 		  }	
	 		   	//dp[i][j] =  Max(dp[i-1][j],dp[i][j-1]); the second will store the last equated char 
	 		   	uax(dp[i][j+1],mp(dp[i][j].fi,mp(i,j))); // this will store the last position
	 		   	uax(dp[i+1][j],mp(dp[i][j].fi,mp(i,j)));
	 		 
	 	}
	}

	// dp[i][j] = max common part till a[i] and b[j], last common part is i,j

	//searching for max 
	pair<int,pair<int,int>>ans = {0,{0,0}};
	forn(i,n+1){
		  forn(j,m+1){
		 	uax(ans,mp(dp[i][j].fi,mp(i,j)));
		 	de(dp[i][j].fi);
          	}
	}

	string s="";

	while(!(ans.se.fi==0||ans.se.se==0)){
		int i = ans.se.fi;
		int j = ans.se.se;
		pii previous = dp[i][j].se;
		// we will only add if we traveled diagonally
		if(previous==mp(i-1,j-1)){
			assert(a[i-1]==b[j-1]);
			s+=a[i-1];
		}
		de(s);
		ans.se =previous;
	}
	reverse(all(s));
	cout<<s<<endl;
               
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif

	return 0;
}	



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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string S, T;
    ll A, B;
    string U;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    if(U == S) A--;
    else B--;
    cout << A << ' ' << B << endl;
    return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;
class Main{
    public static void main(String[] args){
	int x,y;
	Scanner scanner = new Scanner(System.in);
	x = scanner.nextInt();
	y = scanner.nextInt();
	System.out.println(calc_gcd(x,y));
    }
    public static int calc_gcd(int x,int y){
        
	if(x < y){
	    int tmp = x;
	    x = y;
	    y = tmp;
	}
	if(x % y == 0) return y;
	return calc_gcd(y,x%y);
    }
}




Measured memory_bytes: 26120
//#define local
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
#ifdef local
#include "library/debug.cpp"
#else
#define debug(...)
#endif
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;
const ll mod = 1e9+7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x; cin >> x;
    rep(i,200){
        rep(j,200){
            if(i*i*i*i*i - j*j*j*j*j == x){
            cout << i <<' '<< j << endl;
            return 0;
            }
            else if(i*i*i*i*i + j*j*j*j*j == x){
            cout << i <<' '<< j*(-1) << endl;
            return 0;
            }
        }
    }
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ll  long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pb push_back
#define Max(x,y,z) max(x,max(y,z))
#define f first
#define s second
#define lbd lower_bound
#define sz(x)       (ll)x.size()
#define pi 3.1415926536
#define mod 1000000007
using namespace std;
void solve()
{   ll n,m,k,y,x,res=0,l,cnt0=0,z,sum1=0,cnt1=0,h,res1,cnt=0;
    cin>>n>>m;
    res=(n*3)+m;
    cout<<(res/2);

}
int main()
{   speed_up
    ll t;
   //cin>>t;
    t=1;
    while(t--)
        solve();
}


Measured memory_bytes: 256
#   1???????????? W ??¨?????? T ,T ??????????????? W ?????°???????????????????????°??????
import sys
#   ??????W?????????
w = input()
#   ??????T?????????
t = []
#   ??????T?????????
while 1:
    temp = input()
    if temp == "END_OF_TEXT":
        break
    t += temp.strip(".")
    t += " "
#   ??????????????????
t = "".join(t).split()
#   print(t)
#   ??????T???????????¨????????????W????????????????????????
count = 0
for i in range(len(t)):
    if t[i].lower() == w:
        count += 1
print(count)

Measured memory_bytes: 7432
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int A,B,K;
	scanf("%d%d%d",&A,&B,&K);
	for(int i=A;i<=min(A+K-1,B);i++)
		printf("%d\n",i);
	for(int i=max(A+K,B-K+1);i<=B;i++)
		printf("%d\n",i);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    set<ll> st;
    map<ll, ll> mp;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        mp[a[i]]++;
        st.emplace(a[i]);
    }
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    int m = a.size();
    vector<ll> c(m);
    for (int i = 0; i < m; i++) {
        c[i] = mp[a[i]];
    }
    vector<vector<int>> g(m);
    for (int i = 0; i < m; i++) {
        for (ll x = 2; x < 2e9; x <<= 1) {
            int j = lower_bound(a.begin(), a.end(), x - a[i]) - a.begin();
            if (j < i && a[i] + a[j] == x) {
                g[i].emplace_back(j);
                g[j].emplace_back(i);
            }
        }
    }
    debug(a);
    debug(c);
    debug(g);
    ll ans = 0;
    vector<bool> was(m);
    function<void(int)> dfs = [&](int v) {
        ll t = 0;
        for (int to : g[v]) {
            if (was[to]) {
                continue;
            }
            was[to] = true;
            dfs(to);
            t += c[to];
        }
        if (t >= c[v]) {
            ans += c[v];
            c[v] = 0;
        } else {
            ans += t;
            c[v] -= t;
        }
    };
    for (int i = 0; i < m; i++) {
        if (!was[i] && __builtin_popcount(a[i]) == 1) {
            was[i] = true;
            dfs(i);
            ans += c[i] / 2;
        }
    }
    for (int i = 0; i < m; i++) {
        if (!was[i]) {
            was[i] = true;
            dfs(i);
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 35200
N = int(input())
A = list(map(int, input().split()))
A = [A[i - 1] - i for i in range(1, N + 1)]
A.sort()
if N % 2 == 1:
    b = A[(N - 1) // 2]
else:
    b = round((A[N // 2] + A[N // 2 - 1])) // 2
print(sum([abs(A[i] - b)for i in range(N)]))


Measured memory_bytes: 26180
//I_love_math_problems
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
uli abso(uli x){ return x<0?-x:x; }
int main(){
   uli a,b;
   cin>>a>>b;
   if(a<=0 && 0<=b){
      puts("Zero");
      return 0;
   }
   if(a>0){
      puts("Positive");
   }
   else{//a<0
      int sgn=(abso(a-b)+1)%2;
      if(sgn==0)puts("Positive");
      else puts("Negative");
   }
   return 0;
}


Measured memory_bytes: 256
input_list = input().split(' ')

for i, n in enumerate(input_list):
    input_list[i] = int(n)

W = input_list[0]
H = input_list[1]
x = input_list[2]
y = input_list[3]
r = input_list[4]

if (x - r) >= 0 and (x + r) <= W and (y - r) >= 0 and (y + r) <= H:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 5596
#include <bits/stdc++.h>
// #include "/usr/local/include/cxx_pretty_print/cxx_pretty_print.hpp"

using namespace std;
/* type aliases */
using i32 = int32_t; using ui32 = uint32_t; using i64 = int64_t; using ui64 = uint64_t; using i128 = __int128;
using f32 = float;   using f64  = double;   using f80 = long double;
using PII = pair<i32, i32>; using PLL = pair<i64, i64>; using PFF = pair<f32, f32>; using PDD = pair<f64, f64>;
using VB  = vector<bool>;   using VS  = vector<string>;
using VI  = vector<i32>;    using VL  = vector<i64>;    using VF  = vector<f32>;    using VD  = vector<f64>;
using VVI = vector<VI>;     using VVL = vector<VL>;     using VVF = vector<VF>;     using VVD = vector<VD>;
using VPI = vector<PII>;    using VPL = vector<PLL>;    using VPF = vector<PFF>;    using VPD = vector<PDD>;
/* constants */
constexpr i64 mod = 1000000007;                                // 10^9+7
constexpr i64 inf = 9000000000000000000;                       // 9*10^18
/* macros */
#define MAX(c)        *max_element(ALL(c))
#define MIN(c)        *min_element(ALL(c))
#define SIZE(c)       (i64)((c).size())                        // unsined int (size_t) -> int64_t
#define ALL(c)        (c).begin(), (c).end()
#define RALL(c)       (c).rbegin(), (c).rend()
#define REP(i, n)     for (i64 i=0; i<(i64)(n); ++i)           // 0 to n-1
#define REPD(i, n)    for (i64 i=(i64)(n)-1; i>=0; --i)        // n-1 to 0
/* debug */
#define debug(x)      cerr << #x << ": " << (x) << '\n'
#define debugvec(v)   for (size_t _ = 0; _ < (v).size(); ++_) {cerr << #v << '[' << _ << "]: " << (v)[_] << '\n';}
/* useful output */
auto print = [](auto x) {cout << (x) << '\n';};
template <class T> void printvec(T v, string sep=" ", string end="\n") {REP(i, SIZE(v)-1) cout << v[i] << sep; cout << v[SIZE(v)-1] << end;}
/* useful input */
VS splitstr(string s, char delim=' ') {VS v; string buf; stringstream ss{s}; while (getline(ss, buf, delim)) v.push_back(buf); return v;}




void Main() {
    string s;
    cin >> s;
    print(8 - count(s.begin(), s.end(), 'o') <= 15 - SIZE(s) ? "YES" : "NO");

}


signed main() {
    cin.tie(nullptr);                                         // cin と cout の tie を切り高速化
    cout << fixed << setprecision(15);                        // 浮動小数点数が 1e-006 のように表示されることを防ぐ
    Main();
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define digit(a) to_string(a).size()
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;
int main(void)

{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = (int)INF;
    rep(i, 0, s.length() - 2) ans = min(ans, abs(753 - stoi(s.substr(i, 3))));
    cout << ans << endl;
}


Measured memory_bytes: 3652
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<string>
#include<set>
#include<vector>
#include<bitset>
#include<map>
#define N 200005
#define ll long long
#define oo 100000000
#define For(i,x,y) for(int i=x;i<=y;i++)
#define Rep(i,x,y) for(int i=x;i>=y;i--)
#define Forn(i,x,y) for(int i=x;i<y;i++)
using namespace std;
inline int read(){int x=0,f=0;char ch=getchar();for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=1;for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-48;return f?-x:x;}
inline void write(ll x){if(x<10) putchar(x+48);else write(x/10),putchar(x%10+48);}
inline void writeln(ll x){if(x<0) putchar('-'),x=-x;write(x);putchar('\n');}
int n,m,st[N],ed[N];
int main(){
	n=read();m=read();
	For(i,1,m){
		int x=read(),y=read();
		if(x>y) swap(x,y);
		if(x==1) st[y]=1;
		if(y==n) ed[x]=1;
	}
	For(i,1,n) if(st[i]&&ed[i]){puts("POSSIBLE");return 0;}
	puts("IMPOSSIBLE");
	return 0;
}

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

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

using ll = int64_t;

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char x;cin >> x;
    if(isupper(x))cout << "A" << '\n';
    else cout << "a" << '\n';
}



Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()

int main(void){
  int n ; 
  while(cin >> n){
    int cnt = 0;
    rep(i,10)
      rep(j,10)
      rep(k,10)
      rep(l,10)
      if(i+j+k+l==n){
	cnt++;
	//	cout<< i << " " << j << " " << k << " " << l << endl;
	//	cout<< cnt << endl;
      }
    cout<< cnt << endl;
  }
}

Measured memory_bytes: 1160
import java.util.*;

class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		int cas=0;
		while (true) {
			cas++;
			int n = sc.nextInt();
			if(n==0)break;
			ArrayList<P> plist = new ArrayList<P>();
			for (int i =0;i<n;i++) {
				plist.add(new P(sc.nextDouble(),sc.nextDouble()));
			}
			ln(String.format("%d %.1f",cas,-P.getS(plist)));
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
	public static void pr(Object o) {
		System.out.print(o);
	}
	public static void ln(Object o) {
		System.out.println(o);
	}
	public static void ln() {
		System.out.println();
	}
}


class P {
	double x, y;
	public static final double EPS = 1e-10;

	P(double _x, double _y) {
		x = _x;
		y = _y;
	}

	public static final P Xunit = new P(1, 0);
	public static final P Yunit = new P(0, 1);
	public static final P O = new P(0, 0);
	public static double cross(P a, P b) {
		return a.x * b.y - a.y * b.x;
	}
	public P s(P a) {
		return new P(x - a.x, y - a.y);
	}
	public static double getS(List<P> plist) {
		P o1 = plist.get(0);
		P prev = plist.get(1);
		double S = 0;
		for (P p : plist.subList(2, plist.size())) {
			S += getS(o1, prev, p);
			prev = p;
		}
		return S;
	}
	// 負値がかえることもあるので注意。
	public static double getS(P o, P a, P b) {
		return cross(a.s(o), b.s(o)) / 2;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof P) {
			P p = (P) obj;
			return x == p.x && y == p.y;
		}
		return false;
	}
	public String toString() {
		return "(" + x + "," + y + ")";
	}
}

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

const int M = 1e5+10;
int a[M];

int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	int cnt=0;
	a[n] = a[0]-1;
	for(int i=0;i<n;i++)
		if(a[i] != a[i+1])
			cnt++;
		else
			i++;
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 640
#ABC125D-FlippingSigns.py

from sys import stdin

input = stdin.readline

N = int(input())
sign = 0
A = list(map(int, input().split()))
for i in range(N):
    if A[i] < 0:
        A[i] = A[i] * (-1)
        sign += 1
result = 0

if sign % 2 == 0:
    result = sum(A)
else:
    result = sum(A) - min(A) * 2

print(result)


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

#define pb  push_back
#define mp  make_pair
#define ll  long long
#define itr iterator

typedef pair<ll,ll> pii;

const ll MAX=2e5+9;
const ll INF=1e12;

set<ll> st;

map<ll,ll> maps;

ll N,res,now,arr[MAX];

signed main()
{
	ios_base::sync_with_stdio(false);

	cin>>N;
	for(int A=1;A<=N;A++)
	{
		cin>>arr[A];
		maps[arr[A]]++;
	}
	for(int A=0;A<32;A++)
		st.insert(1<<A);
	sort(arr+1,arr+N+1);
	for(int A=N;A>=1;A--)
	{
		if(!maps[arr[A]])
			continue;
		maps[arr[A]]--;
		now=*st.upper_bound(arr[A]);
		if(maps[now-arr[A]])
		{
			maps[now-arr[A]]--;
			res++;
		}
	}	 
	cout<<res;
	return 0;
}

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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define inf 100000000000010
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool isprime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

struct CustomCompare
{
    bool operator()(const int& lhs, const int& rhs)
    {
        return lhs < rhs;
    }
};

bool comp(pair<ll, ll>a,pair<ll,ll>b)
{
    return a.fi>=b.fi;
}

ll builtin_popcount(ll x)
{
    ll cnt = 0;
    for(ll i=60;i>=0;i--)
    {
        if((1LL<<i)&x)cnt++;
    }
    return cnt;
}

ll addmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a+b)%mod;
}
ll mulmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
/*
const int mxn = 5*(1e6) +10;
vi spf(mxn);
void sieve()
{
    for(ll i =0;i<mxn;i++)spf[i]  = i;
    for(ll i=2;i<mxn;i+=2)spf[i] = 2;
    for(ll i = 3;i*i<mxn;i++)
    {
        if(spf[i]==i)
        {
            for(ll j = i*i;j<mxn;j+=i)
            {
                if(spf[j]==j)spf[j] = i;
            }
        }
    }
}
*/




int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
string s; cin>>s;
ll sum = 0;
for(auto x:s)sum+=(x-'0');
if(sum%9==0)cout<<"Yes\n";
else cout<<"No\n";
return 0;

}
/*
1
4
1 2
2 3
3 4
2
2 2
*/


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

using namespace std;

int main () {
    int h = 0, w = 0;
    cin >> h >> w;
    vector<int> bfbf(w), start(w);
    int bf = 0;
    char input = 0;
    int start_w = 0;
    vector<vector<int>> count(h, vector<int>(w));
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            cin >> input;
            if (input == '#') {
                for (int k=start.at(j); k<i; k++) {
                    count.at(k).at(j) += bfbf.at(j) - 1;
                }
                for (int k=start_w; k<j; k++) {
                    count.at(i).at(k) += bf;
                }
                bf = 0;
                bfbf.at(j) = 0;
                start.at(j) = i+1;
                start_w = j+1;
            }
            else {
                bf++;
                bfbf.at(j)++;
            }
        }
        if (bf != 0) {
            for (int k=start_w; k<w; k++) {
                count.at(i).at(k) += bf;
            }
        }
        start_w = 0;
        bf = 0;
    }
    for (int i=0; i<w; i++) {
        if (bfbf.at(i) != 0) {
            for (int j=start.at(i); j<h; j++) {
                count.at(j).at(i) += bfbf.at(i) - 1;
            }
        }
    }
    int maximum = 0;
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            if (count.at(i).at(j) > maximum) maximum = count.at(i).at(j);
        }
    }
    cout << maximum << endl;
    return 0;
}


Measured memory_bytes: 16000
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int memo[101][10001];

int v[101],w[101];

int dp(int i,int j){
    if(i == 0) return 0;

    if(memo[i][j] >= 0) return memo[i][j];

    if(j - w[i - 1] < 0) return dp(i - 1,j);

    return memo[i][j] = max(dp(i - 1,j),dp(i - 1,j - w[i - 1]) + v[i - 1]);
}

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

    for(int i = 0;i < N;i++){
        scanf("%d%d",&v[i],&w[i]);
    }
    for(int i = 0;i <= N;i++){
        for(int j = 0;j <= W;j++){
            memo[i][j] = -1;
        }
    }

    printf("%d\n",dp(N,W));

}




Measured memory_bytes: 7148
#include <algorithm>
#include <iostream>
using namespace std;
using ll = long long;

int main() {
    ll edge[3];
    bool even = false;
    for (int i = 0; i < 3; ++i) {
        cin >> edge[i];
        if (edge[i] % 2 == 0) even = true;
    }
    sort(edge, edge + 3);
    cout << (even ? 0 : edge[0] * edge[1]) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    
    int a, b;
 
    cin >> a >> b;
  
    if(a>=6 && a<=12){
        cout << b/2 << endl;
    }else if(a<=5){
        cout << 0 << endl;
    }else{
        cout << b << endl;
    }
 
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define isin(i,a,b) ((a) <= (i) && (i) < (b))
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll  = long long;
using unit= unsigned;
using ull = unsigned long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vvi = vector<vi>;
using vp  = vector<P>;
void _main(); int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << 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; }
template<class T>T gcd(T a, T b){ if (b==0){ return a; }else{ return gcd(b, a%b); }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
constexpr double eps = 1e-10;
constexpr int inf = INT_MAX / 2;
constexpr ll infl = 1LL << 60;

void _main() {
  map<char, int> m;
  rep(i, 0, 4) {
    char c;
    cin >> c;
    ++m[c];
  }
  bool f = sz(m) == 2;
  fore(x, m) {
    f = f && x.second == 2;
  }
  Yes(f);
}

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

int main(){
    int a, b;
    while (cin >> a >> b){
        //一正一负必有零；
        if (a <= 0 && b >= 0) cout << "Zero" << endl;
        //判断二者为负的情况；
        else if (a < 0){
            if ((b - a + 1) % 2 == 0) cout << "Positive" << endl;
            else cout << "Negative" << endl;
        }
        else cout << "Positive" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int tmp;
    if(a > b){
        tmp = a;
        a = b;
        b = tmp;
    }
    if(a > c){
        tmp = a;
        a = c;
        c = tmp;
    }
    if(b > c){
        tmp = b;
        b = c;
        c = tmp;
    }
    cout << a << " " << b << " " << c << endl;
    return 0;
}


Measured memory_bytes: 3096
n = int(input())
a = list(map(int, input().split()))

inf = 10**18
ans = 1

sorted(a, reverse=True)
if 0 in a:
    print(0)
    exit()
else:
    for i in a:
        ans *= i
        if ans > inf:
            print(-1)
            exit()

print(ans)


Measured memory_bytes: 21560
#![allow(unused)]

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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 ) * } } ; }
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 , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
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 ) * } } ; }
//入力マクロここまで

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;

fn main() {
    input! {
        a: usize,
        b: usize,
    }

    let mut ans = 0;

    for i in 1..b - a  {
        ans += i;
    }

    ans -= a;

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<map>
#include<queue>
#include<vector>
#define ll long long
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static int buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
ll S;
int main()
{
	S=read();
	ll n=(ll)ceil(sqrt(S));
	printf("%lld %lld %lld %lld %lld %lld\n",0ll,0ll,1ll,n,n,n*n-S);
	return 0;
}

Measured memory_bytes: 128
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::Read;
use std::io::{stdout, BufWriter, Write};
 
fn main() {
    let mut buf = String::new();
    
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
 
    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();
 
    // 読み込んだStringを空白で分解する
    let mut iter = buf.split_whitespace();
 
    
    let r: i64 = iter.next().unwrap().parse().unwrap();
    
    println!("{}", 3 * r * r);
    
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
    public static long[] AtsusaDP = new long[51];

    static {
        AtsusaDP[0] = 1L;
        for (int i = 0; i < 50; i++) {
            AtsusaDP[i + 1] = 3L + 2 * AtsusaDP[i];
        }
    }

    public static long[] P_CountDP = new long[51];

    static {
        P_CountDP[0] = 1;
        for (int i = 0; i < 50; i++) {
            P_CountDP[i + 1] = 1L + 2 * P_CountDP[i];
        }
    }


    public static long ans = 0L;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long x = sc.nextLong();

        eatBG(n, x);
        System.out.println(ans);
    }

    /**
     * @param level ハンバーガーのレベル
     * @param rest  残りの食べるべき数
     * @return 新しい残りの食べるべき数
     */
    private static long eatBG(int level, long rest) {
        if (level == 0) {
            if (rest > 0) {//P part
                ans++;
                return rest-1;
            } else {
                return rest;
            }
        }

        if (rest >= AtsusaDP[level]) {
            rest -= AtsusaDP[level];
            ans += P_CountDP[level];
            return rest;
        } else {
            rest--;//B part
            if (rest > 0) rest = eatBG(level - 1, rest);// n-1 BG part
            if (rest > 0) {//P part
                rest--;
                ans++;
            }
            if (rest > 0) {//n-1 part
                rest = eatBG(level - 1, rest);
            }
            rest--;//B part
            return rest;
        }
    }
}


Measured memory_bytes: 25044
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;


int main()
{
	vector<int> a;
	int n;

	scanf("%d", &n);
	a.resize(n);
	for(int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
		a[i] -= 1;
	}

	int ans = 0;

	for(int i = 0; i < n; ++i) {
		int x = i;
		int y = a[x];
		int z = a[y];
		if(x == z)
			ans += 1;
	}
	ans = ans / 2;

	printf("%d\n", ans);
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
	
	public static void main (String[]args) {
		Scanner sc = new Scanner(System.in);
		
		int N =  sc.nextInt();
		List<Integer> inputList = new ArrayList<Integer>();
		List<Integer> aliceList = new ArrayList<Integer>();
		List<Integer> bobList = new ArrayList<Integer>();
				
		for (int i = 0; i < N;i++) {
		
			int num = sc.nextInt();
		
			inputList.add(num);
		}
		
		Collections.sort(inputList,Collections.reverseOrder());
		boolean aliceFlg = true;
		
		for (int j = 0 ; j < inputList.size(); j++) {
			
			if (aliceFlg) {
				
				aliceList.add(inputList.get(j));
				aliceFlg = false;
			} else {
				
				bobList.add(inputList.get(j));
				aliceFlg = true;
			}
			
			
		}
		
		int aliceSum = 0;
		
		for (int aliceNum:aliceList) {
			aliceSum += aliceNum;
		}
		
		int bobSum = 0;
		
		for (int bobNum:bobList) {
			bobSum += bobNum;
		}
		
		System.out.println(aliceSum-bobSum);
			
	}	
}

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

int main(){
    unsigned long N, K;
    cin >> N >> K;
    vector<unsigned long> A(N), f;
    copy_n(istream_iterator<unsigned long>(cin), N, A.begin());
    {
        unsigned long S{accumulate(A.cbegin(), A.cend(), 0UL)}, i{1};
        for(; i * i < S; ++i)if(!(S % i))f.push_back(S / i);
        for(; i > 0; --i)if(!(S % i))f.push_back(i);
    }
    cout << [&]{for(const auto& i : f){
        vector<unsigned long> r(N);
        transform(A.cbegin(), A.cend(), r.begin(), [&i](auto a){return a % i;});
        sort(r.rbegin(), r.rend());
        unsigned long Q{accumulate(r.cbegin(), r.cend(), 0UL) / i}, k{0};
        for(unsigned long j = 0; j < N; ++j)k += j < Q ? i - r[j] : r[j];
        if(k <= 2 * K)return i;
    }}() << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long int ll;
static const int MAX_LEN = 501;
static const int MAX_M = 500;

string A, B;
int M;
int memo[MAX_LEN][10][MAX_M][3][2];

int solve(string S){
	if(S == "0") return 0;
	int sum[MAX_LEN];
	fill(sum, sum + S.length(), 0);
	for(int i = 0; i < S.length(); i++){
		if(i == 0){
			sum[i] = S[i] - '0';
		}else{
			sum[i] = (sum[i - 1] * 10 + (S[i] - '0'));
		}
		sum[i] %= M;
	}
	for(int i = 0; i < S.length(); i++){
		for(int j = 0; j < 10; j++){
			for(int k = 0; k < M; k++){
				for(int l = 0; l < 3; l++){
					for(int m = 0; m < 2; m++){
						memo[i][j][k][l][m] = 0;
					}
				}
			}
		}
	}
	for(int i = 1; i <= S[0] - '0'; i++){
		if(i == S[0] - '0'){
			memo[0][i][i % M][2][1]++;
		}else{
			memo[0][i][i % M][2][0]++;
		}
	}
	for(int i = 1; i < S.length(); i++){
		for(int j = 1; j < 10; j++){
			memo[i][j][j % M][2][0]++;
		}
		for(int j = 0; j < M; j++){
			for(int k = 0; k < 10; k++){
				for(int l = 0; l < 10; l++){
					if(l > k){
						memo[i][l][(j * 10 + l) % M][1][0] += memo[i - 1][k][j][0][0];
						memo[i][l][(j * 10 + l) % M][1][0] += memo[i - 1][k][j][2][0];
						memo[i][l][(j * 10 + l) % M][1][0] %= 10000;
					}else if(l < k){
						memo[i][l][(j * 10 + l) % M][0][0] += memo[i - 1][k][j][1][0];
						memo[i][l][(j * 10 + l) % M][0][0] += memo[i - 1][k][j][2][0];
						memo[i][l][(j * 10 + l) % M][0][0] %= 10000;
					}
				}
			}
		}
		for(int j = 0; j < S[i] - '0'; j++){
			if(j > (S[i - 1] - '0')){
				memo[i][j][(sum[i - 1] * 10 + j) % M][1][0] += (memo[i - 1][S[i - 1] - '0'][sum[i - 1]][0][1] + memo[i - 1][S[i - 1] - '0'][sum[i - 1]][2][1]);
			}else if(j < (S[i - 1] - '0')){
				memo[i][j][(sum[i - 1] * 10 + j) % M][0][0] += (memo[i - 1][S[i - 1] - '0'][sum[i - 1]][1][1] + memo[i - 1][S[i - 1] - '0'][sum[i - 1]][2][1]);
			}
		}
		if(S[i] > S[i - 1]){
			memo[i][S[i] - '0'][sum[i]][1][1] = (memo[i - 1][S[i - 1] - '0'][sum[i - 1]][0][1] + memo[i - 1][S[i - 1] - '0'][sum[i - 1]][2][1]);
		}else if(S[i] < S[i - 1]){
			memo[i][S[i] - '0'][sum[i]][0][1] = (memo[i - 1][S[i - 1] - '0'][sum[i - 1]][1][1] + memo[i - 1][S[i - 1] - '0'][sum[i - 1]][2][1]);
		}
	}
	int res = 0;
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 10; j++){
			res += memo[S.length() - 1][j][0][i][0];
		}
		res += memo[S.length() - 1][S[S.length() - 1] - '0'][0][i][1];
	}
	return res % 10000;
	
}
int main(){
	cin >> A >> B >> M;
	reverse(A.begin(), A.end());
	for(int i = 0; i < A.length(); i++){
		if(A[i] != '0'){
			A[i]--;
			break;
		}else A[i] = '9';
	}
	if(A[A.length() - 1] == '0' && A != "0") A.erase(A.begin() + A.length() - 1);
	reverse(A.begin(), A.end());
	cout << (solve(B) - solve(A) + 10000) % 10000 << endl;
	return 0;
}


Measured memory_bytes: 61776
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int k, s, ans = 0;
  scanf("%d%d", &k, &s);
  for(int i = 0; i <= min(k, s); i++)
  {
      for(int j = 0; j <= min(k, s); j++)if(s-i-j <= k && s-i-j >= 0)ans++;
  }
  printf("%d", ans);
  return 0;
}


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

int f(int n){
  if (n%2 == 0) return n/2;
  else return 3*n+1;
}

int main(){
  int s;
  cin >> s;
  int count = 0;
  int i = 0;
  if (s <= 2) i = 4;
  else {
    while (count != 2){
      i += 1;
      if (s == 4) count += 1;
      s = f(s);
    }

  }
  
  cout << i << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


aI, aO, aT, aJ, aL, aS, aZ = li()

if aI>0 and aJ>0 and aL>0:
    ans1 = 3 + ((aI-1)//2)*2 + ((aJ-1)//2)*2 + ((aL-1)//2)*2 + aO
    ans2 = (aI//2)*2 + (aJ//2)*2 + (aL//2)*2 + aO
    ans = max(ans1,ans2)

else:
    ans = (aI//2)*2 + (aJ//2)*2 + (aL//2)*2 + aO

print(ans)

Measured memory_bytes: 3064
N = int(input())
h = list(map(int, input().split()))
h.append(0)# 配列外参照を防ぐため.
ans = 0

while(True):
  if max(h) == 0: break
  i = 0

  while(i < N):
    if h[i] == 0:
      i += 1
      continue
    else:
      ans += 1
      while((h[i] != 0) & (i < N)):
        h[i] -= 1
        i += 1


print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr first
#define sc second
#define ll  long long
#define mp make_pair
#define mod 1000000007

using namespace std;

ll x[100100];

int main()  {
    ll mn,mx;
    int n;
    cin>>n;
    for(int i=0 ;i <n ;i ++){
        scanf("%I64d",&x[i]);
    }
    mn =2,mx =2;
    reverse(x,x+n);
    for(int i=0 ;i <n ;i ++){

        ll st = mn/x[i];
        st *= x[i];
        if(st < mn)
            st += x[i];
        if(st > mx){
            cout<<-1<<endl;
            return 0;
        }
        ll en = mx/x[i];
        en*=x[i];
        en += x[i]-1;
        mn = st,mx = en;
    }
    cout<<mn<<" " <<mx<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep( i, n ) for( int ( i ) = 0; ( i ) < ( n ); ( i )++ )
#define repr( i, n ) for( int ( i ) = ( n ); ( i ) >= 0; ( i )-- )
#define FOR( i, m, n ) for( int ( i ) = ( m ); ( i ) < ( n ); ( i )++ )
#define all( x ) ( x ).begin(), ( x ).end()
typedef long long lint;
using namespace std;
 
int main( void ){
	
	int n;
	cin >> n;
	int v = 2;
	if( n > 999999998 ){
		v = 999999998;
	}
	
	
	while( 1 ){
		if( !( v % n ) ){
			break;
		}
		v += 2;
	}
	
	cout << v << endl;
	
	return 0;
}


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

int main()
{
	int64_t d, g;
	cin >> d >> g;
	vector<int64_t> ps(d), cs(d);
	for (int i = 0; i < d; i++)
	{
		cin >> ps[i] >> cs[i];
	}
	int64_t ans = (1ll << 60);
	for (int i = 0; i < (1 << d); i++)
	{
		int64_t sum = 0, num = 0;
		for (int j = 0; j < d; j++)
		{
			if ((i >> j) & 1)
			{
				sum += 100 * (j + 1) * ps[j] + cs[j];
				num += ps[j];
			}
		}
		for (int j = d - 1; 0 <= j; j--)
		{
			if (!((i >> j) & 1))
			{
				int64_t puni = max(int64_t(0), min(ps[j], (g - sum + 100 * (j + 1) - 1) / (100 * (j + 1))));
				sum += 100 * (j + 1) * puni;
				num += puni;
				break;
			}
		}
		if (g <= sum)
		{
			ans = min(ans, num);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
R, G, B, N = [int(n) for n in input().split()]

count = 0
for r in range(N//R + 1):
    for g in range((N-r*R)//G + 1):
        b_ = N - (R * r + G * g) 
        if b_ % B == 0:
                count += 1

print(count)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

int main()
{
	boost;
	int n, i;
	cin >> n;
	ll arr[n];
	fo(i, 0, n)
	cin >> arr[i];
	
	ll curr = 1000;
	for(int i = 0, j = 0; i < n; i = j) {
		while(j + 1 < n && arr[j] < arr[j + 1])
			++j;

		ll stocks = curr / arr[i];
		ll rem = curr % arr[i];
		curr = stocks * arr[j] + rem;
		++j;
	}
	cout << curr;
}


Measured memory_bytes: 3440