akhauriyash/Code-Regression huggingface dataset:
from collections import Counter
from copy import deepcopy

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N = int(input())
prime = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
dp = [[0] * 26 for _ in range(N)]
if N == 1:
    print(0)
else:
    for i in range(1,N):
        dp[i] = deepcopy(dp[i-1])
        temp = Counter(prime_factorize(i+1))
        for x in temp.items():
            if len(prime_factorize(x[0])) == 1:
                dp[i][prime.index(x[0])] += x[1]
        four = 0
        two = 0
        fourteen = 0
        twenty_four = 0
        seventy_four = 0
        for j in range(25):
            if dp[i][j] >= 74:
                seventy_four += 1
                twenty_four += 1
                fourteen += 1
                four += 1
                two += 1
            elif dp[i][j] >= 24:
                twenty_four += 1
                fourteen += 1
                four += 1
                two += 1
            elif dp[i][j] >= 14:
                fourteen += 1
                four += 1
                two += 1
            elif dp[i][j] >= 4:
                four += 1
                two += 1
            elif dp[i][j] >= 2:
                two += 1
        dp[i][25] = ((four*(four-1))//2) * (two-2) + twenty_four * (two-1) + fourteen * (four-1) + seventy_four
    print(dp[N-1][25])

Measured memory_bytes: 9572
#include<iostream>
using namespace std;
const int nmax = 8;
bool graph[nmax][nmax];
int dfs(int v, int N, bool visited[nmax]) {
	bool all_visited = true;
	for (int i = 0; i < N; ++i) {
		if (visited[i] == false)
			all_visited = false;
	}
	if (all_visited) {
		return 1;
	}
	int ret = 0;
	for (int i = 0; i < N; ++i) {
		if (graph[v][i] == false)continue;
		if (visited[i])continue;
		visited[i] = true;
		ret += dfs(i, N, visited);
		visited[i] = false;
	}
	return ret;
}
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		int A, B;
		cin >> A >> B;
		graph[A - 1][B - 1] = graph[B - 1][A - 1] = true;
	}
	bool visited[nmax];
	for (int i = 0; i < N; ++i) {
		visited[i] = false;
	}
	visited[0] = true;
	cout << dfs(0, N, visited) << endl;
	return 0;
}

Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

N,M = m()

po = [l() for i in range(10)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            po[i][j] = min(po[i][j],po[i][k] + po[k][j])


num = [0 for i in range(10)]

co = 0

for i in range(N):
    aaa = l()
    for j in aaa:
        if j != -1:
            num[j] += 1

for i in range(10):
    if i != 1:
        co += po[i][1] * num[i]
print(co)



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

int main() {
    int X; cin >> X;
    for(int i = 0; i <= X / 100 + 1; i++) {
        if (X - i * 100 < 0) {
            cout << 0 << endl;
            break;
        } else if (X - i * 100 <= i * 5) {
            cout << 1 << endl;
            break;
        }
    }   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int i,r=0,b=0;
  string s;
  cin >> s;
  for (i=0;i<s.size();i++){
    if (s.at(i)=='0') r++;
    else b++;
  }
  cout << min(r,b)*2 << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll N, X, D;
	cin >> N >> X >> D;
	if (N == 1) {
		if (X == 0)cout << 1 << "\n";
		else cout << 2 << "\n";
		return 0;
	}
	if (D == 0) {
		if (X == 0)cout << 1 << "\n";
		else cout << N + 1 << "\n";
		return 0;
	}
	if (D == 1) {
		vector<pll> V(N + 1);
		V[0] = pll(0, 0);
		ll bottom = 0;
		ll top = 0;
		for (ll n = 1; n <= N; n++) {
			bottom += X + (n - 1);
			top += X + (N - n);
			V[n] = pll(bottom, top);
		}
		sort(V.begin(), V.end(), [](pll a, pll b) {
			if (a.first == b.first)return a.second < b.second;
			return a.first < b.first;
		});
		ll ans = 0;
		pll cur = V[0];
		for (ll n = 1; n <= N; n++) {
			if (V[n].first > cur.second) {
				ans += cur.second - cur.first + 1;
				cur = V[n];
			}
			else {
				cur.second = max(cur.second,V[n].second);
			}
		}
		ans += (cur.second - cur.first + 1);
		cout << ans << "\n";
		return 0;
	}
	if (D < 0) {
		D *= -1;
		X *= -1;
	}
	vector<pll> V(N+1);
	V[0] = pll(0, 0);
	for (ll n = 1; n <= N; n++) {
		ll bottom = n * (n - 1) / 2 *D+ n * X;
		ll top = (n * N - n * (n + 1) / 2) * D + n * X;
		V[n] = pll(bottom, top);
	}
	sort(V.begin(), V.end(), [=](pll a, pll b) {
		ll ma = a.first % D;
		ma = (ma + D) % D;
		ll mb = b.first % D;
		mb = (mb + D) % D;
		if (ma != mb)return ma < mb;
		if (a.first == b.first)return a.second < b.second;
		else return a.first < b.first;
	});
	pll cur = V[0];
	ll ans = 0;
	for (ll n = 1; n <= N; n++) {
		ll ma = cur.first % D;
		ma = (ma + D) % D;
		ll mb = V[n].first % D;
		mb = (mb + D) % D;
		if (ma != mb) {
			ans += (cur.second - cur.first) / D + 1;
			cur = V[n];
		}
		else if (cur.second < V[n].first) {
			ans += (cur.second - cur.first) / D + 1;
			cur = V[n];
		}
		else {
			cur.second = max(cur.second,V[n].second);
		}
	}
	ans += (cur.second - cur.first) / D + 1;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3328
/*
    ~A_Pessimist~:)
*/

#include<bits/stdc++.h>
#define ll long long int
using namespace std;

void solve()
{
    int i,j,mx=0,cnt=0;
    string s;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
        if(s[i]=='R')
        {
            cnt=0;
            j=i;
            while(j<s.size() && s[j]=='R') cnt++,j++;
            i=j-1;
            mx=max(mx,  cnt);
        }
    }
    cout<<mx<<endl;
}

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

    int t=1;
    //cin>>t;

    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3640
#include<stdio.h>

int main(void)
{
	int ne[6];
	int ans[2];
	int i;
	
	for(i=0;i<5;i++){
		scanf("%d",&ne[i]);
	}
	if(ne[0]<ne[1] && ne[0]<ne[2])
	ans[0]=ne[0];
	
	else if(ne[1]<ne[0] && ne[1]<ne[2])
	ans[0]=ne[1];
	
	else
	ans[0]=ne[2];
	
	if(ne[3]<ne[4])
	ans[1]=ne[3];
	
	else
	ans[1]=ne[4];
	
	printf("%d\n",ans[0]+ans[1]-50);
	
	return 0;
}


Measured memory_bytes: 2124
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/


template<typename T>
struct SqrtDecomposition {
private:
	const int sqrtN = 1024;
	T N, K;
	vector<T> data;
	vector<T> bucketAdd;
public:
	SqrtDecomposition(T n) : N(n) {
		K = (N + sqrtN - 1) / sqrtN;
		data.assign(K * sqrtN, 0);
		bucketAdd.assign(K, 0);
	}
	void add(T s, T t, T x) {
		for (T k = 0; k < K; ++k) {
			T l = k * sqrtN, r = (k + 1) * sqrtN;
			if (r <= s || t <= l)
				continue;
			if (s <= l && r <= t) {
				bucketAdd[k] += x;
			}
			else {
				for (T i = max(s, l); i < min(t, r); ++i) {
					data[i] += x;
				}
			}
		}
	}
	// [x, y)
	T get(T s) {
		int k = s / sqrtN;
		return data[s] + bucketAdd[k];
	}
};


int main() {

	ll n, q;
	cin >> n >> q;
	
	SqrtDecomposition<ll> decomp(n);

	while (q--) {
		ll c;
		cin >> c;
		if (c == 0) {
			ll s, t, x;
			cin >> s >> t >> x;
			decomp.add(s, t + 1, x);
		}
		else {
			ll i;
			cin >> i;
			cout << decomp.get(i) << endl;
		}
	}
	

	return 0;
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi p(n), q(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];
    vi a(n);
    rep(i, n) a[i] = i+1;
    map<vi, int> mp;
    do {
        mp[a] = mp.size();
    } while (next_permutation(all(a)));
    cout << abs(mp[p]-mp[q]) << endl;
    return 0;
}


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

typedef long long ll;


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

    int N, M;

    cin >> N >> M;

    vector<ll> A(N);

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

    sort(A.begin(), A.end());

    vector<pair<ll, ll> >C(M);

    for(int i = 0; i < M; i++) {
        int b, c;
        cin >> b >> c;
        C[i] = make_pair(c, b);
    }

    sort(C.begin(), C.end(), greater<pair<ll, ll> >());

    int pos = 0;

    for(int i = 0; i < N; i++) {
        if(C[pos].first <= A[i]) {
            break;
        }
        A[i] = C[pos].first;
        C[pos].second--;
        if(!C[pos].second) {
            pos++;
        }
    }

    ll count = 0;

    for(int i = 0; i < N; i++) {
        count += A[i];
    }

    cout << count << endl;
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int mat[4][4] = {0};

int check(int i, int j);

int main(void){
    int p, n;

    for( int i = 0; i < 3; i++){
        cin >> p >> n;
        mat[p - 1][n - 1] = 1;
        mat[n - 1][p - 1] = 1;
    }
    /*
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 4; j++){
            cout << mat[i][j];
        }
        cout << endl;
    }
    */

    if(check(0,0) == 3){
        cout << "YES" << endl;
    }else {
        cout << "NO" << endl;
    }

    return 0;
}

int check(int i, int j){
    if(mat[i][j] == 0){
        //printf("check(%d,%d) %d  ==> check(%d,%d)\n",i,j,mat[i][j],i,j+1);
        if(j + 1 < 4){
            return check(i, j + 1);
        }
        /*
        else if(i + 1 < 4){
            return check(i + 1, 0);
        }
        */
        else{
            return 0;
        }
    }
    else if(mat[i][j] == 1) {
        mat[j][i] = 0;
        //printf("check(%d,%d) %d ==> check(%d,%d)\n",i,j + 1,mat[i][j],j,0);
        return check(j,0) + 1;
    }
}

Measured memory_bytes: 256
l,r = map(int,input().split())
la=l%2019
ra=r%2019
sa=l%673
if la==0:
    print(0)
elif sa+(r-l)>=673:
    print(0)
else:
    ans=2019
    for i in range(la,ra):
        for j in range(1,ra-i+1):
            if ans>(i*(i+j))%2019:
                ans=(i*(i+j))%2019
    print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
    int n, i, m, count, count2=1;
    scanf("%d", &n);
    int h[n];

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

    for(i=1; i<n; i++)
    {
        count=0;
        for(m=0; m<i; m++)
        {
            if(h[i]>=h[m])
            {
                count++;
            }
            else
            {
                break;
            }
        }
        if(count==i)
        {
            count2++;
        }
    }

    printf("%d\n", count2);

    return 0;

}

Measured memory_bytes: 128
#include<stdio.h>

struct queues {
	char name[11];
	int time;
	int next;
};

int main( void ) 
{
	struct queues ps[100001];
	int i;
	int n,q;
	int cnt,cur,pre;
	int time,res;
	int head;
	
	scanf( "%d%d", &n, &q );
	head=0;
	for( i=0; i<n; i++ ) {
		scanf( "%s%d", ps[i].name, &ps[i].time );
		ps[i].next=i+1;
	}
	
	res=time=cnt=0;
	pre=cur=head;
	while( cnt<n ) {
		if( ps[cur].time <= q ) {
			time+=ps[cur].time;
			printf( "%s %d\n", ps[cur].name, time );
			
			if( head == cur ) {
				head=ps[cur].next;
			} else {
				ps[ pre ].next=ps[cur].next;
			}
			cnt++;
		} else {
			time+=q;
			ps[cur].time-=q;
			pre=cur;
		}
		cur=ps[cur].next;
		
		if( n<=cur ) { 
			cur=head;
		}	
	}
	
	return 0;
}

Measured memory_bytes: 1580
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

a = l()

po = [a[i] for i in range(n)]

for i in range(1,n):
    po[i] += po[i-1]

co = 0

ans = 0

for i in range(n):
    po[i] += co
    if i % 2 == 0:
        if po[i] > 0:
            continue
        else:
            co += abs(po[i]) + 1
            ans += abs(po[i]) + 1

    else:
        if po[i] < 0:
            continue
        else:
            co -= abs(po[i]) + 1
            ans += abs(po[i]) + 1
anss = 0
co = 0
po = [a[i] for i in range(n)]

for i in range(1,n):
    po[i] += po[i-1]

for i in range(n):
    po[i] += co
    if i % 2 != 0:
        if po[i] > 0:
            continue
        else:
            co += abs(po[i]) + 1
            anss += abs(po[i]) + 1

    else:
        if po[i] < 0:
            continue
        else:
            co -= abs(po[i]) + 1
            anss += abs(po[i]) + 1
print(min(ans,anss))


Measured memory_bytes: 62036
// A - Five Antennas
#include <bits/stdc++.h>
using namespace std;

int main(){
	int a,b,c,d,e,K; cin>>a>>b>>c>>d>>e>>K;
	int mini = min({a,b,c,d,e});
	int maxi = max({a,b,c,d,e});
	cout<< (maxi-mini>K?":(":"Yay!") <<endl;
}

Measured memory_bytes: 256
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import comb

# 再帰がやばいとき
# import sys
# sys.setrecursionlimit(10**9)

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e50)
MOD = int(1e9)+7 # 10^9 + 7

# field[H][W]
def create_grid(H, W, value = 0):
    return [[ value for _ in range(W)] for _ in range(H)]

########

def main():
    N, C = l_inpl()
    D = [ l_inpl() for _ in range(C) ]
    c = []
    for _ in range(N):
        ci = l_inpl()
        ci = [ i-1 for i in ci ] 
        c.append(ci)

    # t[i][j]: i={0, 1, 2}, jは色
    t = create_grid(3, C)
    for ci in range(C):
        for i in range(N):
            for j in range(N):
                t[(i+j)%3][ci] += D[c[i][j]][ci]

    ans = INF
    for i in range(C):
        for j in range(C):
            for k in range(C):
                if i == j or j == k or k == i:
                    continue
                tmp = 0
                tmp += t[0][i]
                tmp += t[1][j]
                tmp += t[2][k]
                ans = min(ans, tmp)
    
    print(ans)
if __name__ == "__main__":
    main()


Measured memory_bytes: 44252
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int> >
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type* arr = new type[n];
#define forn(i, n) for (int i = 1; i <= n; i++)
#define me0(x) memset(x, 0, sizeof(x))
#define me1(x) memset(x, -1, sizeof(x))
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)
// mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
const int N = 2e6 + 2;
void run() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int a,b,n;
int solve() {
	cin>>a>>b>>n;
  	int ans = min(n,b-1);
  	ans = (a*ans)/b;
  	return ans;
}
int32_t main() {
    run();
   	cout<<solve();
    return 0;
}

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

int main(){
  string S;
  cin >> S;
  if(S[0] == S[1] and S[2] == S[3] and S[1] != S[2]
    or S[0] == S[2] and S[1] == S[3] and S[2] != S[1]
     or S[0] == S[3] and S[1] == S[2] and S[3] != S[1]){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

a = I()

print(a+a**2+a**3)

Measured memory_bytes: 61752
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll mod = 1000000007;

/*
00 01 02 ... 0w-1 1w-1 1w-2 ...

h=3 w=4
00 01 02 03 13 12 11 10 20 21 22 23 
iからの写像は
i/wが奇数の時  i/w (w-1)-i%w
i/wが偶数の時  i/w i%w
*/


void solve(){
    int h,w;
    cin >> h >> w;
    int a[h+2][w+2];
    rep(i,h){
        rep(j,w){
            cin >> a[i][j];
        }
    }
    vector<pair<int,int>> v;
    rep(i,h*w){
        if((i/w%2)==1) v.emplace_back(make_pair(i/w, (w-1)-i%w));
        else v.emplace_back(make_pair(i/w, i%w));
    }

    vector<string> ans;

    rep(i,h*w-1){
        int x,y;
        x = v[i].first;
        y = v[i].second;
        if(a[x][y]%2 == 1){
            a[v[i+1].first][v[i+1].second]++;
            ans.emplace_back(to_string(x+1) + " " + to_string(y+1) + " " + to_string(v[i+1].first+1) + " " + to_string(v[i+1].second+1) );
        }
    }

    cout << ans.size() << endl;
    rep(i,ans.size()){
        cout << ans[i] << endl;
    }



}

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

Measured memory_bytes: 13808
//ΔAGC022B
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 2500;
int main()
{
	int n,i;
	cin>>n;
	if(n==3){
		cout<<2<<' '<<5<<' '<<63<<' ';
		return 0;
	}
	n-=4;
	cout<<2<<' '<<4<<' '<<3<<' '<<9<<' ';
	for(i=1;n>1&&i<N;i=i+1,n-=2)
		cout<<i*12+2<<' '<<i*12+4<<' ';
	for(i=1;n>1&&i<N;i=i+1,n-=2)
		cout<<i*12+3<<' '<<i*12+9<<' ';
	for(i=0;n>1&&i<N;i=i+1,n-=2)
		cout<<i*12+8<<' '<<i*12+10<<' ';
	for(i=1;i<=n;i=i+1)
		cout<<i*6<<' ';
	return 0;
}

Measured memory_bytes: 384
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

k,n = map(int,readline().split())
lst1 = list(map(int,readline().split()))

dist = 0

for i in range(n-1):
    dist = max(dist,abs(lst1[i]-lst1[i+1]))

dist = max(dist,k-lst1[-1]+lst1[0])

print(k-dist)

Measured memory_bytes: 71060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Go_ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int> >,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const ll  MAX=1e18+500;
const int sz=110;


int main()
{
    Go_
    int a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;

    cin>>n;
    string pip="ACL";

    string ans="";
    for(i=1;i<=n;i++) ans+=pip;

    cout<<ans<<'\n';
    
    
}

Measured memory_bytes: 3640
#include<stdio.h>
int main(){
	int n,x,a,i;
	while(scanf("%d",&n)!=EOF){
		if(n==0)break;a=0;
		for(i=0;i<n/4;i++){
			scanf("%d",&x);
			a+=x;
		}
		printf("%d\n",a);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 998244353;
int N;
int a[305],S;
int dp[305][90005],f[90005];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void update(int &x,int y) {
    x = inc(x,y);
}
int fpow(int x,int c) {
    int res = 1,t = x;
    while(c) {
	if(c & 1) res = mul(res,t);
	t = mul(t,t);
	c >>= 1;
    }
    return res;
}
void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) {
	read(a[i]);
	S += a[i];
    }
    dp[0][0] = 1;
    f[0] = 1;
    for(int i = 1 ; i <= N ; ++i) {
	for(int j = S ; j >= 0 ; --j) {
	    update(dp[i][j],mul(2,dp[i - 1][j]));
	    if(j >= a[i]) {
		update(dp[i][j],dp[i - 1][j - a[i]]);
		update(f[j],f[j - a[i]]);
	    }
	}
    }
    int ans = fpow(3,N);
    for(int j = 0 ; j <= S ; ++j) {
	if(j * 2 >= S) {
	    update(ans,MOD - mul(3,dp[N][j]));
	}
    }
    if(S % 2 == 0) {
	update(ans,mul(f[S / 2],3));
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 106368
//#include <stdio.h>
#include <bits/stdc++.h>
#include <climits>
using namespace std;
int main()
{   
    int x;
    cin >> x;
    int ans=0;
 
    int value=x/100;
    int up=105*value;
    int down=100*value;
    //cout <<up <<down;
    if(down <=x and x <=up){
        ans=1;
    }
    cout <<ans<<endl;
    
    return 0;

}


Measured memory_bytes: 256
N = int(input())
a = [int(i) for i in input().split()]
list = {}
list[8] = 0

for i in a:
    if 1 <= i <= 399:
        list[0] = 1
    elif 400 <= i <= 799:
        list[1] = 1
    elif 800 <= i <= 1199:
        list[2] = 1
    elif 1200 <= i <= 1599:
        list[3] = 1
    elif 1600 <= i <= 1999:
        list[4] = 1
    elif 2000 <= i <= 2399:
        list[5] = 1
    elif 2400 <= i <= 2799:
        list[6] = 1
    elif 2800 <= i <= 3199:
        list[7] = 1
    else:
        list[8] += 1

if len(list) == 1:
    min = 1
else:
    min = len(list) - 1

if list[8] > 0:
    max = len(list) + list[8] - 1
else:
    max = len(list) - 1

print(min,max)


Measured memory_bytes: 9132
#include <iostream>

using namespace std;

int bsort(int a[],int n){
    int sw=0;
    bool flag=1;
    while(flag){
            flag=0;
        for(int i=n-1;i>0;i--){
            if(a[i]<a[i-1]){
                swap(a[i],a[i-1]);
                flag=1;
                sw++;
            }
        }
    }
    return sw;
}

int main()
{
   int n;
   cin >>n;
   int a[n];
   for(int i=0;i<n;i++){
       cin >> a[i];
   }
   int co;
   co=bsort(a,n);
   for(int i=0;i<n;i++){
        if(i)cout << " ";
        cout << a[i];
   }
   cout << endl;
   cout << co<< endl;
    return 0;
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

#define inCI(v, l, r) ((l) <  (v) && (v) <= (r))
#define inCD(v, l, r) ((l) <  (v) && (v) <  (r))

LL n, m, dp[301][301][301], MOD = 1e9 + 7;

int main() {
	cin >> n >> m;
	vector<vector<int>> ma(n + 1, vector<int>(4, -1));
	vector<vector<int>> mi(n + 1, vector<int>(4, n + 1));
	inc(i, m) {
		int l, r, x;
		cin >> l >> r >> x;
		l--;
		setmax(ma[r][x], l);
		setmin(mi[r][x], l);
	}
	
	dp[0][0][0] = 1;
	inc(i, n) {
	incII(j, 0, i) {
	incII(k, 0, j) {
		int c = ma[i + 1][3];
		int d = mi[i + 1][2];
		int a = ma[i + 1][2];
		int b = mi[i + 1][1];
		if(inCI(j, a, b) && inCI(k, c, d)) { (dp[i + 1][j][k] += dp[i][j][k]) %= MOD; }
		if(inCI(i, a, b) && inCI(k, c, d)) { (dp[i + 1][i][k] += dp[i][j][k]) %= MOD; }
		if(inCI(i, a, b) && inCI(j, c, d)) { (dp[i + 1][i][j] += dp[i][j][k]) %= MOD; }
	}
	}
	}
	
	LL ans = 0;
	incII(j, 0, n) {
	incII(k, 0, j) {
		(ans += dp[n][j][k]) %= MOD;
	}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 211328
#include <stdio.h>

int main(int argc, char const *argv[]) {
  char s[100000];
  int cnt_0 = 0, cnt_1 = 0;
  int ans;

  scanf("%s", s);

  // 0101...
  for (int i = 0; s[i] != '\0'; ++i) {
    if (i % 2 == 0) {
      if ('0' != s[i]) cnt_0++;
    } else {
      if ('1' != s[i]) cnt_0++;
    }
  }

  // 1010...
  for (int j = 0; s[j] != '\0'; ++j) {
    if (j % 2 == 0) {
      if ('1' != s[j]) cnt_1++;
    } else {
      if ('0' != s[j]) cnt_1++;
    }
  }

  if (cnt_0 < cnt_1)
    ans = cnt_0;
  else
    ans = cnt_1;
  printf("%d\n", ans);
  return 0;
  return 0;
}

Measured memory_bytes: 256
import sys

def main():
    k = int(input().replace('\n','').split()[1])
    tmp = list(map(int,input().replace('\n','').split()))
    tmp.sort(reverse=True)
    n=0
    for i in tmp[k:]:
        n+=int(i)
    print(n)
if __name__ == '__main__':
    input = sys.stdin.readline
    main()


Measured memory_bytes: 20048
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

ll comb(ll x,ll y){
  if(y == 1)return x;
  ll ans = 1;
  rep(i,y)ans *= x-i;
  for(int i = 1;i <= y;i++) ans /= i;
  return ans;
}

int main(){
  string N;
  cin >> N;
  ll K;
  cin >> K;
  ll ans = 0;
  ll keta = N.size();

  for(int i = 1;i < keta;i++){
    if(K == 1){
      ans += 9;
    }else if(K == 2){
      if(i >= 3){
        ans += 81*comb(i-1,1);
      }else if(i == 2){
        ans += 81;
      }else{
        continue;
      }
    }else{
      if(i == 3){
        ans += 729;
      }else if(i > 3){
        ans += 729*comb(i-1,2);
      }else{
        continue;
      }
    }
/*
    if(i >= K){
      if(i == K){
        ll add = 1;
        rep(j,K)add *= 9;
        ans += add;
      }else if(i == K+1){
        ll add = 1;
        rep(j,K)add *= 9;
        ans += add*(i-1);
      }else{
        ll add = 1;
        rep(j,K)add *= 9;
        ans += add*comb(i-1,K-1);
        //ans += add;
      }
    }else{
      continue;
    }
    */
  }
//return 0;
  vector<int> num(keta+1,0);
  for(int i = 1;i <= keta;i++)num[i] = (int)(N.at(i-1)-'0');

  //cout << ans << endl;

  if(K == 1)ans += num[1];

  if(K == 2){
    ans += (num[1]-1)*(keta-1)*9;
    /*
    for(int a = 2;a <= keta;a++){
      ans += num[a];
    }
    */
    //cout << ans << endl;
    for(int f = 2;f <= keta;f++){
      if(num[f] == 0)continue;
      else if(f == keta && num[f] > 0)ans += num[keta];
      else{
        if(num[f] > 0){
          ans += 9*comb(keta-f,1);
          ans += num[f];
          break;
        }
      }
    }
  }

  if(K == 3){
    ans += (num[1]-1)*comb(keta-1,2)*81;
    ll s = 0;
    for(int f = 2;f <= keta;f++)if(num[f] > 0){
      s = f;
      break;
    }
    if(s == 0){
      cout << ans << endl;
      return 0;
    }
    if(s == keta)ans += 0;
    else if(keta-1 == s){
      ans += (num[s]-1)*9;
      ans += num[keta];
      cout << ans << endl;
      return 0;
    }else{
      ans += 81*comb(keta-s,2);
      ans += (num[s]-1)*(keta-s)*9;
      for(int ss = s+1;ss <= keta;ss++){
        if(num[ss] == 0)continue;
        else if(ss == keta && num[ss] > 0)ans += num[keta];
        else{
          if(num[ss] > 0){
            ans += 9*comb(keta-ss,1);
            ans += num[ss];
            break;
          }
        }
      }
    }


  }

  cout << ans << endl;



return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
template <typename T>
T gcd(T m, T n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main(){
  lll H;
  cin>>H;
  lll ans=0;
  lll numm=1;
  while(true){
    ans+=numm;
    if(H==1)break;
    H=(H)/2;
    numm*=2;
  }
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String start;
        int numShuffle;
        int numTake;
        int i;
        while (true) {
            start = sc.next();
            if (start.equals("-")) break;
            numShuffle = sc.nextInt();
            for (i = 0; i < numShuffle; i++) {
                numTake= sc.nextInt();
                start = start.substring(numTake).concat(start.substring(0, numTake));
            }
            System.out.println(start);
        }
    }
}


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

void solve(long long L)
{
    printf("%12f", (double)L * L * L / 27);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long L;
    scanf("%lld", &L);
    solve(L);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

int main() {
  ll N;
  cin >> N;
  ll K;
  cin >> K;
  ll C;
  cin >> C;
  string S;
  cin >> S;

  vi l(N + 1), r(N + 1);
  for (ll i = 0; i < N; i++) {
    l[i + 1] = l[i];
    if (S[i] == 'o') {
      if (i > C)
        l[i + 1] = max(l[i + 1], l[i - C] + 1);
      else
        l[i + 1] = 1;
    }
  }
  for (ll i = N - 1; i >= 0; i--) {
    r[i] = r[i + 1];
    if (S[i] == 'o') {
      if (i < N - C)
        r[i] = max(r[i], r[i + C + 1] + 1);
      else
        r[i] = 1;
    }
  }

  for (ll i = 0; i < N; i++) {
    if (l[i] + r[i + 1] < K) {
      cout << i + 1 << endl;
    }
  }
}


Measured memory_bytes: 6832
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    n = ni()
    s = 'UDLR'
    g = [list() for _ in range(4)]
    for _ in range(n):
        x, y, u = input().split()
        g[s.index(u)].append((int(x), int(y)))


    def calc(a, b):
        a.sort()
        b.sort()
        idx = 0
        m = len(b)
        res = 10 ** 9
        for x, y in a:
            while idx < m and (b[idx][0] < x or b[idx][0] == x and b[idx][1] < y):
                idx += 1
            if idx >= m:
                break
            if b[idx][0] == x and b[idx][1] >= y:
                res = min(res, b[idx][1] - y)
        return res * 5

    res1 = calc(g[0], g[1])
    res2 = calc([(y, x) for x, y in g[3]], [(y, x) for x, y in g[2]])
    res3 = calc([(x+y, x-y) for x, y in g[3]], [(x+y, x-y) for x, y in g[0]])
    res4 = calc([(x+y, x-y) for x, y in g[1]], [(x+y, x-y) for x, y in g[2]])
    res5 = calc([(x-y, x+y) for x, y in g[0]], [(x-y, x+y) for x, y in g[2]])
    res6 = calc([(x-y, x+y) for x, y in g[3]], [(x-y, x+y) for x, y in g[1]])
    ans = min(res1, res2, res3, res4, res5, res6)
    if ans > 10**9:
        print('SAFE')
    else:
        print(ans)
    return

solve()

Measured memory_bytes: 62308
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int to_int(char ch) {
    return (int)(ch - '0');
}

int main() {
    fastIO;

    string s;
    cin >> s;

    int min_diff = 999;
    for (size_t i = 0; i < s.size() - 2; i++) {
        int subsum = to_int(s.at(i)) * 100 + to_int(s.at(i + 1)) * 10 +
                     to_int(s.at(i + 2));
        min_diff = min(min_diff, abs(753 - subsum));
    }
    cout << min_diff << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 1LL << 60;
int main() {
    int N;
    cin >> N;
    vector<int>A(N+1);
    vector<int>B(N+1);
    vector<int>C(N+1);
    A[0]=0;
    B[0]=0;
    C[0]=0;
    for(int i=1;i<=N;i++){
        cin >> A[i] >> B[i] >> C[i] ;
    }
    vector<vector<int>> dp(N+1, vector<int>(3));
    for(int i=0;i<=N;i++){
        for(int j=0;j<3;j++){
            dp[i][j] = 0;
        }
    }
    dp[1][0] = A[1];
    dp[1][1] = B[1];
    dp[1][2] = C[1];
    for(int i=2;i<=N;i++){
        for(int j=0;j<3;j++){
            dp[i][0] = max(dp[i-1][1], dp[i-1][2] ) + A[i];
            dp[i][1] = max(dp[i-1][0], dp[i-1][2] ) + B[i];
            dp[i][2] = max(dp[i-1][0], dp[i-1][1] ) + C[i];
        }
    }
    int ans = max( dp[N][0],max( dp[N][1], dp[N][2]));
    cout << ans << endl;
}

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

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

  //vector <vector <int> > A;
  vector <int> a(10020);
  vector <int> d(101);
  int sum=0;

  for(int i=0; i<K; i++){
    cin >> d.at(i);

    //vector <int> a(d.at(i));
    for(int j=sum; j<sum+d.at(i);j++){
      cin >> a.at(j);
    }
    sum += d.at(i);
  }

  sort(a.begin(),a.end());

  int result =1;
  for(int i=0; i<a.size()-1; i++){
    if(a.at(i)!=0&&a.at(i)!=a.at(i+1)){
      result++;
    }
  }


  cout << N-result << endl;

}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T = double>
using point = complex<T>; // 2D point only

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

template <typename T = int>
using ii = pair<T,T>;
template <typename T = int>
using iii = pair<T,ii<T>>;
template <typename T = int>
using ii_i = pair<ii<T>,T>;
template <typename T = int>
using vi = vector<T>;
template <typename T = int>
using vvi = vector<vi<T>>;
template <typename T = int>
using vii = vector<ii<T>>;
template <typename T = int>
using viii = vector<iii<T>>;
template <typename T = int>
using lim = numeric_limits<T>;

#ifdef _DEBUG
#define debug_text(...) printf(__VA_ARGS__)
#else
#define debug_text(...) /* --- NOTHING --- */
#endif

#define re real()
#define im imag()
#define fi first
#define se second
#define sz(v) (v).size()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

// OST
template <typename T>
using ordered_set = __gnu_pbds::tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// from: https://codeforces.com/blog/entry/62393
// struct custom_hash {
// 	static uint64_t splitmix64(uint64_t x) {
// 		// http://xorshift.di.unimi.it/splitmix64.c
// 		x += 0x9e3779b97f4a7c15;
// 		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
// 		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
// 		return x ^ (x >> 31);
// 	}

// 	size_t operator()(uint64_t x) const {
// 		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
// 		return splitmix64(x + FIXED_RANDOM);
// 	}
// };

const int INF = ~(1<<31);
const ll LINF = (1LL << 60);
const long double EPS = 1e-9;
const long double PI = acos(-1);

const int N = 1005;
const int M = 1 << 19;
const int MOD = 1e9+7; // 998244353;
const int MOD2 = 1e9+9;
const int IMAX = 1e9+7;
const ll LMOD = 1LL << 59;
const ll LMAX = 1e16+7;
const ll P = 131;
const ll P2 = 151;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};
const int dx8[8] = {-1,-1,-1,0,0,1,1,1};
const int dy8[8] = {-1,0,1,-1,1,-1,0,1};

void solution() {
	ll x; cin >> x;
	ll l = 0, r = 1e9+1;
	for (int i = 0; i < 100; ++i) {
		ll mid = l + (r - l) / 2;
		if (mid*(mid+1)/2 >= x) {
			r = mid;
		} else {
			l = mid;
		}
	}
	cout << l+1 << endl;
}

void pregen() {
	
}

void prepare() {
	
}

int main () {
	ios_base::sync_with_stdio(false); cin.tie(0); // cout.tie(0);
	// cout.precision(2); cout << fixed;

	int T = 1;
	// cin >> T;
	pregen();
	for (int i = 1; i <= T; ++i) {
		prepare();
		solution();
	}

	return 0;
}

Measured memory_bytes: 3692
# -*- coding: utf-8 -*-
import sys
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()


c=0
def main():
    N=int(input())
    edge=[[] for _ in range(N)]
    for i in range(N):
        l=list(map(lambda x:int(x)-1,input().split()))
        for x in l[2:]:
            edge[i].append(x)
    d=[-1]*N
    f=[-1]*N
    used=[False]*N
    def dfs(v):
        global c
        used[v]=True
        d[v]=c
        for nv in edge[v]:
            if not used[nv]:
                c+=1
                dfs(nv)
        c+=1
        f[v]=c
    global c
    while not all(used):
        for i in range(N):
            if not used[i]:
                c+=1
                dfs(i)

    for i in range(N):
        print(i+1,d[i],f[i])
    
                

if __name__ == '__main__':
    main()



Measured memory_bytes: 5664
import sys
input = sys.stdin.readline

s = input().rstrip()     # rstrip() がないとダメ
if len(s) % 2 == 1: s = s[:-1]
else: s = s[:-2]

for _ in range(len(s) // 2):
    if s.count(s[:len(s) // 2]) == 2: print(len(s));  exit()
    else: s = s[:-2]
print(0)

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

struct Benri {
    Benri() {
        std::cin.tie(0); ios::sync_with_stdio(false);
        cout << fixed << setprecision(12);
    }
} benri;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007
#define MOD2 998244353




int main() {
    int N; cin >> N;
    vi p(N);
    rep(i,N) cin >> p[i];
    int s = accumulate(all(p),0);
    int t = (*max_element(all(p))) / 2;
    cout << s - t << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#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,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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 main(){
    int n; cin >> n;
    string s = to_string(n);
    rep(i,3){
        if(s[i] - '0' == 7) {
            cout <<"Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3688
unittest
{
	assert( [ "abcdefgh", "3" ].parse.expand.solve == "adg" );
	assert( [ "lllll", "1" ].parse.expand.solve == "lllll" );
	assert( [ "souuundhound", "2" ].parse.expand.solve == "suudon" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	input.popFront;
	auto w = input.front.to!( long );
	return tuple( s, w );
}

auto solve( dchar[] s, long w )
{
	dchar[] ans;
	for( auto i = 0L; i < s.length; i += w )
	{
		ans ~= s[ i ];
	}
	return ans;
}


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

int main()
{
    string s;
    cin >> s;
    string ans = "";
    for (char c : s)
    {
        if (c == 'B')
        {
            ans = ans.substr(0, ans.size() - 1);
        }
        else
        {
            ans += c;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256