akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long;

int main()
{
    int n, out = 0;
    cin >> n;
    vector<int> l(n);
    rep(i, n) {
        cin >> l[i];
    }

    sort(l.begin(), l.end(), greater<int>());

    if (n < 3) {
        cout << 0 << endl;
        return 0;
    }
    for (int i = 0; i <= n - 3; ++i) {
        for (int j = i + 1; j <= n - 2; ++j) {
            for (int k = j + 1; k <= n - 1; ++k) {
                if (l[i] < l[j] + l[k]) {
                    if (l[i] != l[j] && l[j] != l[k] && l[k] != l[i]) {
                        ++out;
                    }
                }
            }
        }
    }

    cout << out << endl;
    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
const ll MOD = 1e9+7;
const int MAX = 1001001;
ll 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;
    }
}
ll 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;
}

ll calc(int n,int r){
    if(r>n||r-1<0) return 0;
    return (fac[n]*finv[n-r])%MOD;
}

signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    COMinit();
    int N,K;
    cin >> N >> K;
    vector<int> G[N];
    vector<int> deg(N);
    vector<ll> ans(N);
    rep(i,N-1){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].pb(b); G[b].pb(a);
    }
    deg[0]=(int)G[0].size();
    for(int i=1;i<N;i++) deg[i]=(int)G[i].size()-1;
    for(int i=0;i<N;i++){
        if(deg[i]==0) ans[i]=1;
        else if(i==0){
            ans[i]=calc(K-1,deg[0]);
        }else{
            ans[i]=calc(K-2,deg[i]);
        }
    }
    ll res=K;
    rep(i,N) res=(res*ans[i])%MOD;
    cout << res << endl;
}


Measured memory_bytes: 33636
a,b,n=map(int,input().split())
import math
ans=0
d=min(n,b)
e=b-1
if b>d:
    print(math.floor(a*d/b)-a*math.floor(d/b))
else:
    print(math.floor(a*e/b)-a*math.floor(e/b))

Measured memory_bytes: 9180
from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 1000010
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=-1
def sieve():
    for i in range(2,MAXN,2):
        spf[i] = 2
    for i in range(3,int(MAXN**0.5)+1):
        if spf[i]==i:
            for j in range(i,MAXN,i):
                if spf[j]==j:
                    spf[j]=i
def fib(n,m):
    if n == 0:
        return [0, 1]
    else:
        a, b = fib(n // 2)
        c = ((a%m) * ((b%m) * 2 - (a%m)))%m
        d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m
        if n % 2 == 0:
            return [c, d]
        else:
            return [d, c + d]
 
def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))
 
def arrIN(x = ' '):
    return list(map(int,sys.stdin.readline().strip().split(x)))
 
def ncr(n,r):
    num=den=1
    for i in range(r):
        num = (num*(n-i))%MOD
        den = (den*(i+1))%MOD
 
    return (num*(pow(den,MOD-2,MOD)))%MOD
 
def flush():
    return sys.stdout.flush()




'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''

def bfs(v):
    q = [v]
    vis[v] = 1
    l = 0
    while q:
        x = q.pop(0)
        l+=1
        for i in d[x]:
            if not vis[i]:
                vis[i] = 1
                q.append(i)
    return l


n,m = arrIN()
d = defaultdict(set)

for _ in range(m):
    a,b = arrIN()
    d[a].add(b)
    d[b].add(a)

vis = defaultdict(int)
cc = []
for i in range(1,n+1):
    if not vis[i]:
        cc.append(bfs(i))

cc.sort()
ans = cc[0]
cl = cc[0]
t = cl
for i in cc[1:]:
    if i==cl:
        continue
    cl = i-t
    t+=cl
    ans+=cl
print(ans)



Measured memory_bytes: 141044
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
//Loopで使う文字列の長さは固定！
//intで大丈夫？オーバーフローしない？
//Loop回数は本当に10⁹以内になってる？Loopは回る？？
public class Main {
    public static void main(String[]$){
        Scanner sc = new Scanner(in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        int d=sc.nextInt();
        out.println(min(a,b)+min(d,c));
    }
}

Measured memory_bytes: 23764
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  int N,max,t=0;
  cin>>N;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin>>p.at(i);
    t+=p.at(i);
  }
  max=*max_element(p.begin(),p.end());
  cout<<t-max+max/2<<endl;
  return 0;
}


Measured memory_bytes: 256
// Disjoint Set: Union Find Tree

#include <iostream>

using namespace std;

const int mxn = 10000;
const int mxm = 100000;

int n, q, fa[mxn];

int find(int u) {
	if (fa[u] == u)
		return u;
	else
		return fa[u] = find(fa[u]);
}

void merge(int a, int b) {
	a = find(a);
	b = find(b);
	if (a != b)
		fa[a] = b;
}

bool check(int a, int b) {
	a = find(a);
	b = find(b);
	return a == b;
}

int main() {
	cin >> n >> q;
	for (int i = 0; i < n; ++i)
		fa[i] = i;
	for (int i = 0; i < q; ++i) {
		int k, u, v;
		cin >> k >> u >> v;
		if (k == 0)
			merge(u, v);
		else
			cout << check(u, v) << endl;
	}
	return 0;
}


Measured memory_bytes: 3244
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(auto x:v) cout<<" "<<x; cout<<endl;

int main(){ 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	int n;
	cin>>n;
	string s;
	cin>>s;
	int red=0,wh=0;
	for(auto c:s){
		if(c=='R')
			red++;
		else
			wh++;
	}
	int ans=0;
	for(int i=0;i<red;i++){
		if(s[i]=='W')
			ans++;
	}
	ans=min(red,ans);
	ans=min(ans,wh);
	cout<<ans<<endl;
}


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

results = {
  'AC': 0,
  'WA': 0,
  'TLE': 0,
  'RE': 0
}

for i in range(N):
  res = input()
  results[res] += 1

print('{} x {}'.format('AC', results['AC']))
print('{} x {}'.format('WA', results['WA']))
print('{} x {}'.format('TLE', results['TLE']))
print('{} x {}'.format('RE', results['RE']))

Measured memory_bytes: 9232
N= int(input())
g =[]
h=0
for i in range(N):
    a = int(input())
    g.append(a)
g.sort()

S=sum(g)
if S%10!=0:
    print(S)
if S%10==0:
    for k in range(len(g)):
        if g[k]%10!=0:
            S-=g[k]
            print(S)
            break
    else:
        print("0")
                

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
import java.math.*;

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

	void run() {
		Scanner sc = new Scanner();
		int n = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		int ans = 0;
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				if (i + h <= n && j + w <= n)
					++ans;
			}
		}
		System.out.println(ans);
	}

	void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

}

class Scanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}
}


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

struct Card{char suit, value;};

void bubble(struct Card A[], int N){
	for(int i=0; i<N; i++){
		for(int j=N-1; j>=i+1; j--){
			if(A[j].value < A[j-1].value){
				Card t = A[j];
				A[j] = A[j-1];
				A[j-1] = t;
			}
		}
	}
}

void selection(struct Card A[], int N){
	for(int i=0; i<N; i++){
		int minj = i;
		for(int j=i; j<N; j++){
			if(A[j].value < A[minj].value) minj = j;
		}
		Card t = A[i]; A[i] = A[minj]; A[minj] = t;
	}
}

void print(struct Card A[], int N){
	for(int i=0; i<N; i++){
		if(i>0) cout << " ";
		cout << A[i].suit << A[i].value;
	}
	cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N){
	for(int i=0; i<N; i++){
		if(C1[i].suit != C2[i].suit) return false;
	}
	return true;
}

int main() {
	Card C1[100], C2[100];
	int N;
	char ch;
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> C1[i].suit >> C1[i].value;
	}
	for(int i=0; i<N; i++) C2[i] = C1[i];
	bubble(C1, N);
	selection(C2, N);
	
	print(C1, N);
	cout << "Stable" << endl;
	print(C2, N);
	if(isStable(C1, C2, N)){
		cout << "Stable" << endl;
	}else{
		cout << "Not stable" << endl;
	}
	return 0;
}


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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long[] aa = sc.LongArray();

        Dictionary<long, long> dic = new Dictionary<long, long>();

        long sum = 0;

        long answer = 0;
        for (int i = 0; i < n; i++)
        {
            sum += aa[i];

            if (sum == 0)
            {
                answer++;
            }

            if (dic.ContainsKey(sum))
            {
                answer += dic[sum];
            }

            if (dic.ContainsKey(sum))
            {
                dic[sum]++;
            }
            else
            {
                dic.Add(sum, 1);
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 60884
from collections import defaultdict, Counter, namedtuple, deque

NN = 202020
MOD = 10**9+7
INF = float("inf")

n, u, v = map(int, input().split())
Edge = [list(map(int, input().split())) for _ in range(n-1)]
u -= 1
v -= 1
graph = [[] for _ in range(n)]
for a, b in Edge:
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)


def bfs(start, player):
    que = deque([(start, -1, 0)])
    while que:
        node, par, dst = que.popleft()
        # print(node, par, dst)
        if len(graph[node]) == 1:
            # print(player, node)
            dst_dict[player][node] = dst

        for nxt in graph[node]:
            if nxt == par:
                continue
            que.append((nxt, node, dst+1))


dst_dict = [{}, {}]
bfs(u, 0)
bfs(v, 1)
# print(dst_dict[0], dst_dict[1])

max_time = 0
for k in dst_dict[0]:
    if dst_dict[0][k] < dst_dict[1][k]:
        max_time = max(max_time, dst_dict[1][k]-1)

print(max_time)



Measured memory_bytes: 91608
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
const int mod = 1e9 + 7;

ll N;

P f(ll x) {
    string target = to_string(x);
    // cout << target << endl;
    string a1 { target[0] };
    string a2 { target[target.size() - 1] };

    return P(stol(a1), stol(a2));
}

int main() {
    cin >> N;

    map<P, ll> mp;
    for (ll i = 1; i <= N; i++) {
        P p = f(i);
        mp[p]++;
    }

    ll ans = 0;
    for (ll i = 1; i <= N; i++) {
        P p = f(i);

        ans += mp[P(p.second, p.first)];
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

int a[15][15];
signed main(void)
{
  while(true) {
  int n;
  cin >> n;
  if(!n) break;
  REP(i, n) REP(j, n) cin >> a[i][j];

  REP(i, n) {
    int sum = 0;
    REP(j, n) {
      sum += a[i][j];
      printf("%5d", a[i][j]);
    }
    printf("%5d\n", sum);
  }
  int ret = 0;
  REP(i, n) {
    int sum = 0;
    REP(j, n) {
      sum += a[j][i];
    }
    ret += sum;
    printf("%5d", sum);
  }
  printf("%5d\n", ret);
}

  return 0;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define SYOU(x) setprecision(x)
#define abs(x,y) (max(x,y)-min(x,y))
#define mp make_pair
#define fi first
#define se second
using namespace std;
int i[111100];
vector<pair<int ,int> > ii;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=1,e=1,f=0,g=1,h=1,j;
  cin >>a>>b;
  d=b*1900;
  d+=100*(a-b);
  for(int n=1;n<=b;n++){
    d*=2;
  }
  cout <<d<<'\n';
  return (0);
}


Measured memory_bytes: 256
//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>
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;

int main() {
  int A,B;
  cin >> A >> B;
  if(A == 1 && B == 2){
    cout << 3 <<endl;
  }
  else if(A == 2 && B == 1){
    cout << 3 <<endl;
  }
  else if(A == 1 && B == 3){
    cout << 2 <<endl;
  }
  else if(A == 3 && B == 1){
    cout << 2 <<endl;
  }
  else if(A == 2 && B == 3){
    cout << 1 <<endl;
  }
  else{
    cout << 1 <<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int MAXN = 3e5 + 5;
using namespace std;
char tmp[MAXN];
int sum[MAXN];

int main()
{
    scanf("%s", tmp);
    int n = strlen(tmp);
    int lo = 0, hi = n;
    while (lo <= hi)
    {
        int mid = (lo + hi) >> 1;
        int cur = 0, flag = 1;
        memset(sum, 0, sizeof sum);
        for (int i = 0; i < n; i++)
        {
            cur += sum[i];
            if (tmp[i] == '1' && cur % 2 == 0)
            {
                if (i + mid > n && i < mid )
                {
                    flag = 0;
                    hi = mid - 1;
                    break;
                }
                sum[i]++, cur++;
                sum[i + mid]--;
            }
            else if (tmp[i] == '1' && cur % 2 == 1) {}
            else if (tmp[i] == '0' && cur % 2 == 0) {}
            else if (tmp[i] == '0' && cur % 2 == 1)
            {
                if (i + mid > n && i < mid)
                {
                    flag = 0;
                    hi = mid - 1;
                    break;
                }
                sum[i]++, cur++;
                sum[i + mid]--;
            }
        }
        if (flag) lo = mid + 1;
    }
    printf("%d\n", lo - 1);
    return 0;
}


Measured memory_bytes: 1536
n = int(input())
s_list = []
for _ in range(n):
    s_list.append(input())
m = int(input())
t_list = []
for _ in range(m):
    t_list.append(input())
    
# print(s_list)
# print(t_list)

st_set = set(s_list + t_list)
# print(st_set)

ans = 0
for st in st_set:
    # print(s_list.count(st))
    # print(t_list.count(st))
    # print(f"{s_list.count(st)} {t_list.count(st)}")
    ans = max(ans, s_list.count(st) - t_list.count(st))

print(ans)

Measured memory_bytes: 9136
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

ll cou[222222];

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

	ll n;cin >> n;
	vector<ll> v(n);
	REP(i, n)cin >> v[i];
	REP(i, n)cou[v[i]]++;

	ll ans = 0;
	REP(i, 222222)ans += cou[i] * (cou[i] - 1) / 2;

	REP(i, n){
		ll now = ans - cou[v[i]] * (cou[v[i]] - 1) / 2;
		now += max(0LL, (cou[v[i]] - 2) * (cou[v[i]] - 1) / 2);
		cout << now << "\n";
	}



	return 0;
}


Measured memory_bytes: 4736
A=int(raw_input())
B=int(raw_input())
C=int(raw_input())
X=int(raw_input())

goukei=0
for a in xrange(A+1):
	tempA = a*500
	for b in xrange(B+1):
		tempB = b*100
		for c in xrange(C+1):
			if (tempA+tempB+50*c) == X:
				goukei=goukei+1
print(goukei)

Measured memory_bytes: 2568
#include <cstdio>
#include <cstdint>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <set>
#include <map>
#include <numeric>

int main() {
  size_t n;
  scanf("%zu", &n);

  std::vector<size_t> a(n);
  std::iota(a.begin(), a.end(), 0);

  std::vector<size_t> p(n), q(n);
  for (auto& pi: p) scanf("%zu", &pi), --pi;
  for (auto& qi: q) scanf("%zu", &qi), --qi;

  int pn, qn;
  int m = 0;
  do {
    if (a == p) pn = m;
    if (a == q) qn = m;
    ++m;
  } while (std::next_permutation(a.begin(), a.end()));

  printf("%d\n", std::abs(pn-qn));
}


Measured memory_bytes: 256
import sys,math
#sys.setrecursionlimit(100000000)
input = sys.stdin.readline
 
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input()))
def inara():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
################################################################
############ ---- THE ACTUAL CODE STARTS BELOW ---- ############

a,b,n=invr()
ans=-1

hi=n
lo=0

while hi>=lo:
	mid=(hi+lo)//2
	temp=(a*mid)//b-a*(mid//b)
	if temp>=ans:
		lo=mid+1
		ans=temp
	else:
		hi=mid-1
print(ans)


Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin >> N;
    map<int,int> m;
    int A[N];
    rep(i,N){
        cin >> A[i];
        m[A[i]]++;
    }
    int a,b;
    int ans=0;
    for(auto p:m){
        a=p.first;
        b=p.second;
        if(a<b){
            ans+=(b-a);
        } else if(a>b){
            ans+=b;
        }
    }
    cout << ans << endl;


}


Measured memory_bytes: 5120
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        if (N % 2 == 1)
        {
            WriteLine("No");
            return;
        }
        var S = ReadLine();
        var b = true;
        for (int i = 0; i < N / 2; i++)
        {
            if (S[i] != S[i + N / 2]) b = false;
        }
        WriteLine(b ? "Yes" : "No");

    }
}

public class NextPermutation
{
    int[] perm;
    public int Length => perm.Length;

    public NextPermutation(int N)
    {
        perm = new int[N];
        for (int i = 0; i < perm.Length; i++)
        {
            perm[i] = i;
        }
    }

    public NextPermutation(int[] init)
    {
        perm = init;
    }

    public int this[int i]
    {
        get
        {
            return perm[i];
        }
    }

    public bool Next()
    {
        var l = 0;
        for (int i = perm.Length - 2; i >= 0; i--)
        {
            if (perm[i] < perm[i + 1])
            {
                l = i;
                break;
            }
        }

        var v = perm[l];
        var r = 0;
        for (int i = perm.Length - 1; i >= 0; i--)
        {
            if (perm[i] > v)
            {
                r = i;
                break;
            }
        }

        if (l == 0 && r == 0) return false;
        Swap(ref perm[l++], ref perm[r]);
        Array.Reverse(perm, l, perm.Length - l);
        return true;
    }

    static void Swap<T>(ref T l, ref T r)
    {
        var t = l;
        l = r;
        r = t;
    }
}

Measured memory_bytes: 13140
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        n: usize,
        lit_by: [usize1; n], 
    }
    let mut seen = vec![-1; n];
    let mut now_on = 0usize;
    for i in 0.. {
        let dist = seen.get_mut(now_on).unwrap();
        if *dist != -1 { break; }
        *dist = i;

        now_on = *lit_by.get(now_on).unwrap();
    }
    println!("{}", seen[1]);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define resz resize
 
#define sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define F0R(i, a) for (ll i = 0; i < (a); i++)
#define FORR(i, a, b) for (ll i = a; i >= (b); i--)
#define F0RR(i, a) for (ll i = a; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
 
using pii = pair<ll, ll>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using vpdd = vector<pdd>;
using vvpdd = vector<vpdd>;
 
ll gcd(ll a,ll b)
{
    if(b==0)return a;
    else return gcd(b,a%b);
}
ll po(ll a,ll b)
{
    ll ans = 1;
    while(b--)
        ans*=a;
    return ans;
}
ll pom(ll a,ll b,ll mod)
{
    if(b==0)return 1;
    ll k = pom(a,b/2,mod);
    if(b%2==0)return (k*k)%mod;
    else return ((k*k)*mod*a)%mod;
}
 
ll sqdist(ll a,ll b,ll c,ll d)
{
    return (a-c)*(a-c)+(b-d)*(b-d);
}
ll fact(ll n)
{
    if(n==0)return 1;
    ll ans = 1;
    FOR(i,1,n+1)ans*=i;
    return ans;
}

ll arr[100005];
int a[100];
int b[100];



void solve()
{
int n;
cin>>n;
FOR(i,1,n+1)arr[i]=1;
FOR(i,0,n)cin>>a[i];
FOR(i,0,n)cin>>b[i];
int p=0;ll c = 0;
FOR(i,0,n)
{
    ll curr = a[i];
    //p+=(s.find(a[i])-s.begin())*(s.size()-1);
    c=0;
    FOR(i,0,curr)
        c+=arr[i];
    //cout<<curr<<' '<<c<<' '<<n-i-1<<' '<<fact(n-i-1)<<endl;
    arr[curr]=0;
    p+=c*(fact(n-i-1));
}
//cout<<p<<endl;
FOR(i,1,n+1)arr[i]=1;
int q=0;c = 0;
FOR(i,0,n)
{
    ll curr = b[i];
    //p+=(s.find(a[i])-s.begin())*(s.size()-1);
    c=0;
    FOR(i,0,curr)
        c+=arr[i];
    //cout<<curr<<' '<<c<<' '<<n-i-1<<' '<<fact(n-i-1)<<endl;
    arr[curr]=0;
    q+=c*(fact(n-i-1));
    //cout<<q<<endl;
}
//cout<<q<<endl;
cout<<abs(p-q);
}

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

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    // ll t;
    //cout<<"Y"<<endl;
    //cin>>t;
    //while(t--)
        solve();
}

Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
tmp = float('inf')
ans = 0
for i in range(n):
    if tmp > abs(a - (t-h[i]*0.006)):
        tmp = abs(a- (t-h[i]*0.006))
        ans = i

print(ans+1)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
int main(){
  int N,M;cin>>N>>M;
  vector<int> a(N),b(M);
  for(auto& x:a)cin>>x;
  for(auto& x:b)cin>>x;
  auto v=atcoder::convolution(a,b);
  for(auto& x:v)cout<<x<<" ";
}

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

int main() {
	int m,h;string s,a;
	while(cin>>s&&s!="-")
	{
		cin>>m;
		for(int i=0;i<m;i++)
		{
			cin>>h;
			a=s.substr(h);
			s.erase(h);
			s=a+s;
		}
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 3184
#include <stdio.h>

int main(void)
{
	char roma[101];
	int ara[101];
	int i = 0;
	int sum = 0;
	
	
	while (scanf("%s", roma) != EOF){
		while (roma[i] != '\0'){
			
			switch (roma[i]){
				case 'I':
				ara[i] = 1;
				break;
				
				case 'V':
				ara[i] = 5;
				break;
				
				case 'X':
				ara[i] = 10;
				break;
				
				case 'L':
				ara[i] = 50;
				break;
				
				case 'C':
				ara[i] = 100;
				break;
				
				case 'D':
				ara[i] = 500;
				break;
				
				case 'M':
				ara[i] = 1000;
				break;
				}
			if (ara[i - 1] < ara[i]){
				sum -= ara[i - 1];
				sum -= ara[i - 1];
			}
			sum += ara[i];
			i++;
		}
		printf("%d\n", sum);
		sum = 0;
		i = 0;
	}
	
	return (0);
}

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



int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    string ans;
    for (int i = 0; i < ty - sy; i++) {
        ans += 'U';
    }
    for (int i = 0; i < tx - sx; i++) {
        ans += 'R';
    }
    for (int i = 0; i < ty - sy; i++) {
        ans += 'D';
    }
    for (int i = 0; i < tx - sx; i++) {
        ans += 'L';
    }
    ans += 'L';
    for (int i = 0; i < ty - sy + 1; i++) {
        ans += 'U';
    }
    for (int i = 0; i < tx - sx + 1; i++) {
        ans += 'R';
    }
    ans += 'D';
    ans += 'R';
    for (int i = 0; i < ty - sy + 1; i++) {
        ans += 'D';
    }
    for (int i = 0; i < tx - sx + 1; i++) {
        ans += 'L';
    }
    ans += 'U';

    cout << ans << '\n';


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  long int x;
  cin >> n >> x;
  vector<long int> ame(n);
  for(int i = 0;i < n;i++) cin >> ame.at(i);
  sort(ame.begin(), ame.end());
  long int sum = 0;
  int answer;
  for(int i = 0;i < n;i++){
    sum += ame.at(i);
    if(sum == x){
      answer = i+1;
      break;
    }else if(sum > x){
      answer = i;
      break;
    }else if(x > sum){
      answer = i;
    }
  }
  cout << answer << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	int n;
	int[] a;
	long cnt1;
	long cnt2;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
		sc.close();
	}

	Main(Scanner sc) {
		n = sc.nextInt();
		a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = sc.nextInt();
		}
	}

	void solve() {
		Thread t1 = new Thread(()->{calc_run1((a[0]>0)?0:(Math.abs(a[0])+1),1,(a[0]>0)?a[0]:1);});
		t1.start();
		Thread t2 = new Thread(()->{calc_run2((a[0]<0)?0:(Math.abs(a[0])+1),-1,(a[0]<0)?a[0]:-1);});
		t2.start();
		try {
			t1.join();
			t2.join();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println(Math.min(cnt1, cnt2));
	}
	
	void calc_run1(long cnt,int sign,long sum){
		for(int i=1;i<n;i++){
			sum += a[i];
			if(sum*sign>=0){
				cnt += Math.abs(sum) + 1;
				sum = -sign;
			}
			sign *= -1;
		}
		cnt1 = cnt;
	}
	
	void calc_run2(long cnt,int sign,long sum){
		for(int i=1;i<n;i++){
			sum += a[i];
			if(sum*sign>=0){
				cnt += Math.abs(sum) + 1;
				sum = -sign;
			}
			sign *= -1;
		}
		cnt2 = cnt;
	}
}


Measured memory_bytes: 55724
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;	cin >> n;
  map<string,int>	s;
  for(int i=0;i<n;i++){
    string str;	cin >> str;
    if(s.count(str))	s[str]+=1;
    else	s[str]=1;
  }
  
  int m=0;
  for(auto x:s){
    m=max(m,x.second);
  }
  
  for(auto x:s){
    if(x.second==m)	cout << x.first << endl;
  }
  
}

Measured memory_bytes: 19228
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;

	char buf[L], *S , *T, c;

	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}

	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}

	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	char B[45], *outs=B+40, *outr=B+40;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;

		if(!a)*--outs = '0';
		else
			while(a)
				*--outs = (a % 10) + 48, a /= 10;

		if(x)
			*--outs = x;

		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
using i128 = i64;
using u128 = u64;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}

template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

const int MOD = 1000000007;
const int INF = 1000000000;
const int MAXN = 1<<21;

int main()
{
	
	map<char, int> F;
	string s;
	cin >> s;
	for (auto c : s)
		F[c] ++;
	vector<pair<char, int> > v;
	for (auto p : F)
		v.push_back(p);
	puts(v.size() == 2 && v[0].Y == v[1].Y ? "Yes" : "No");
	
	return 0;
}


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

int main() {
    double D, E;
    while(cin >> D >> E, D) {
        double ret = 1e12;
        for(int x=0; x<=D; ++x) {
            for(int y=0; y<=D; ++y) {
                if(x + y == D) {
                    ret = min(ret, abs(sqrt(x*x + y*y) - E));
                }
            }
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for(int i=m; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <typename T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0; }
template <typename T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1;} return 0; }


int main() {
  ll X;
  cin>>X;
  ll ans=0;
  ll res=100;
  while(res<X){
      res+=res/100;
      ans++;
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int N,M,C,sum,cnt=0;
  cin>>N>>M>>C;
  int B[M],A[N][M];
  for(int i=0;i<M;i++) cin>>B[i];
  for(int i=0;i<N;i++){
  	for(int j=0;j<M;j++){
    	cin>>A[i][j];
    }
  }
  
  for(int i=0;i<N;i++){
    sum=0;
  	for(int j=0;j<M;j++){
      sum+=A[i][j]*B[j];
    }
    if(sum+C>0) cnt++;
  }
  cout<<cnt<<endl;
}	


Measured memory_bytes: 256
#include<cstdio>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

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

int main(){
	int n,m; scanf("%d%d",&n,&m);
	rep(i,m){
		int l; scanf("%d",&l);
		n=gcd(n,l);
	}
	puts(n==1?"Yes":"No");

	return 0;
}

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

int main()
{
	int n;
	scanf("%d", &n);
	int mx = -1, mn = 1001;
	for (int i = 0; i < n; i++)
	{
		int a;
		scanf("%d", &a);
		mx = max(mx, a);
		mn = min(mn, a);
	}
	printf("%d\n", mx - mn);

	return 0;
}

Measured memory_bytes: 128
#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 ll long long
#define INF 999999999
using namespace std;
int main() {
  int n,m,x;
  int mi = INF;
  cin>> n >> m >> x;

  std::vector<int> c(n);
  vector< vector<int> > v (n, vector<int>(m) );
  for (int i = 0; i < n; i++) {
    cin>> c[i];
    for (int j = 0; j < m; j++) {
      cin>>v[i][j];
    }
  }
  // {0, 1, ..., n-1} の部分集合の全探索
  for (int bit = 0; bit < (1<<n); ++bit) {
      std::vector<int> us(m);
      int cost = 0;
      vector<int> S;
      for (int i = 0; i < n; ++i) {
          if (bit & (1<<i)) { // 列挙に i が含まれるか
              S.push_back(i);
          }
      }
      for (int i = 0; i < (int)S.size(); ++i) {
                  cost+= c[S[i]];
        for (int j = 0; j < m; j++) {
          us[j]  += v[S[i]][j];
        }
      }
      bool ans = true;
      for (int i = 0; i < m; i++) {
        if (us[i] < x) {
          ans = false;
        }
      }
      if (ans) {
        mi = min(cost,mi);
      }
  }
  if (mi == INF) {
    cout<< -1 <<endl;
  }
  else{
    cout<< mi <<endl;
  }
}


Measured memory_bytes: 3636
N,K = map(int, input().split())
P=input().split()
P = [int(p) for p in P]
maxv=0
expv=0

for i in range(K):
    expv+=P[i]

maxv=expv

for i in range(N-K):
    expv=expv-P[i]+P[i+K]
    maxv=max(maxv,expv)
    
        
print("{:.20f}".format((maxv+K)/2))


Measured memory_bytes: 24516
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
using namespace std;

int main() {

	int N;
	cin >> N;
	int t[100001];
	for (size_t i = 0; i < 100001; i++)
	{
		t[i] = 100001;
	}
	t[0] = 0;
	for (int i = 1; i <= N; i++)
	{
		t[i] = min(t[i - 1] + 1, t[i]);
		int sn = 6;
		while (i - sn >= 0)
		{
			t[i] = min(t[i - sn] + 1, t[i]);
			sn = sn * 6;
		}
		sn = 9;
		while (i - sn >= 0)
		{
			t[i] = min(t[i - sn] + 1, t[i]);
			sn = sn * 9;
		}
	}
	cout << t[N];
	return 0;
}

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

int main() {
  int a,b,c,x,y,ans=0;
  cin >> a >> b >> c >> x >> y;
  
  a=min(a,2*c);
  b=min(b,2*c);
  
  int k=min(x,y);
  ans+=k*min(a+b,2*c);
  x-=k;
  y-=k;
  ans+=x*a+y*b;
  
  cout << ans;
  
  
}

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

int main(){
  string s;
  cin>>s;
  int m,ans,x,y,count=10000;
  for(int i=0;i<s.size()-2;i++){
    x=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
    y=abs(753-x);
    if(y<count){
      ans=y;
      count=y;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[0]==5&&a[1]==5&&a[2]==7){
		cout<<"YES\n";
	}
	else{
		cout<<"NO\n";
	}
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n,m;
    int A[101][101],b[101],c[101];
    scanf("%d %d",&n,&m);
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            scanf("%d",&A[i][j]);
        }
    }
    for(int j=0; j<m; j++){
        scanf("%d",&b[j]);
    }
    
    for(int i=0; i<n; i++){
        c[i] = 0;
        for(int j=0; j<m; j++){
            c[i] += A[i][j] * b[j];
        }
    }
    
    for (int i = 0; i < n; i++) {
        printf("%d\n", c[i]);
    }
    return 0;
}


Measured memory_bytes: 2104
import heapq

def main():
    n, m = map(int, input().split())
    data = {}
    priorityQ = []
    for _ in range(n):
        a, b = map(int, input().split())
        if m + 1 - a >= 0:
            if m+1-a in data:
                data[m+1-a].append(b)
            else:
                data[m+1-a] = [b]
    ans = 0
    for i in range(m, 0, -1):
        if i in data.keys():
            for k in data[i]:
                heapq.heappush(priorityQ, -k)
        if priorityQ:
            ans -= heapq.heappop(priorityQ)
    print(ans)
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 28936
# -*- coding: utf-8 -*-

a,b=map(int,input().split())

def isPalindrome(s):
    if s[0]==s[4] and s[1]==s[3]:
        return True
    return False

ans=0
for i in range(a,b+1):
    if isPalindrome(str(i)):
        ans+=1
print(ans)


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

int main() {
  
  int N;
  cin >> N;
  int P = 0;
  
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    P += r - l + 1;
  }
  cout << P << endl;
}


Measured memory_bytes: 384
n,t = gets.chomp.split(' ').map(&:to_i)
min_c = 1001
n.times do
  path =  gets.chomp.split(' ').map(&:to_i)
  if path[1] <= t
    if path[0] < min_c
      min_c = path[0]
    end
  end
end
if min_c < 1001
  puts min_c
else
  puts "TLE"
end

Measured memory_bytes: 14388
import io.StdIn.readLine

object Main extends App {
  val List(a, b) = readLine.split(" ").map(_.toInt).toList
  val result: String = a match {
    case a if a < b  => "a < b"
    case a if a > b  => "a > b"
    case a if a == b => "a == b"
  }

  println(result)
}



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

using namespace std;

int main(){
    int n;
    string s;
    int res = 0;
    int max = 0;
    cin >> n >> s;
    for(int i =0; i< s.length();i++){
        if(s[i]=='I'){
            res+=1;
        }
        else{
            res-=1;
        }
        if(res > max){
            max = res;
        }
    }
    cout << max;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


def solve():
    N = Scanner.int()
    A = Scanner.map_int()
    ans = 0
    for i in range(N):
        if (i + 1) % 2 == 1 and A[i] % 2 == 1:
            ans += 1

    print(ans)


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


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

struct Card{
	int no;
	char name;
};

bool compare_as_ints(Card i,Card j)
{
	return (i.no<j.no);
}

int Partition(Card A[],int p,int r)
{
	Card x=A[r];
	int i=p-1;

	for(int j=p; j<=r-1; j++)
	{
		if(A[j].no<=x.no)
		{
			i++;
			swap(A[i],A[j]);
		}
	}
	swap(A[i+1],A[r]);
	return i+1;
}

void quickSort(Card A[], int p, int r)
{
	if(p<r){
		int q=Partition(A,p,r);
		quickSort(A,p,q-1);
		quickSort(A,q+1,r);
	}
}

int main()
{	
	int n;
	cin>>n;
	
	Card A[100000],B[100000];
	for(int i=0; i<n; i++){
		cin>>A[i].name>>A[i].no;
		B[i]=A[i];
	}

	quickSort(A,0,n-1);
	stable_sort(B,B+n,compare_as_ints);

	bool stable=true;
	for(int i=0; i<n; i++){
		if(A[i].no==B[i].no && A[i].name==B[i].name);
		else
			stable=false;
	}
	if(stable)
		cout<<"Stable"<<endl;
	else
		cout<<"Not stable"<<endl;

	for(int i=0; i<n; i++)
		cout<<A[i].name<<' '<<A[i].no<<endl;

	return 0;
}

Measured memory_bytes: 4724
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;
 
template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)
 
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;
  

int main() {
    string a, b;
    cin >> a >> b;

    int num = stoi(a + b);
    string res = "No";
    rep(i,1000) {
        if (i*i == num) res = "Yes";
    }
    
    cout << res << endl;
    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();
    int X = sc.nextInt();
    int m[] = new int[N];
    int answer =0;
    for(int i=0;i<N;i++){
      m[i]=sc.nextInt();
      X=X-m[i];
      answer++;
    }
    Arrays.sort(m);
    answer = answer + X/m[0];
    System.out.println(answer);
    
  }
  

  
}

Measured memory_bytes: 21844