akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

long long gcd(long long x, long long y) {
    if (x < y) { swap(x, y); }

    while (y > 0) {
        long long r = x % y;

        return gcd(y, r);
    }

    return x;
}

long long lcm(long long x, long long y) {
    long long g = gcd(x, y);

    return x / g * y;
}

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

    vector<long long> T;
    T.reserve(N);

    long long data;
    for (int n = 0; n < N; n++) { 
        cin >> data;
        T.push_back(data);
    }

    long long rec = T[0];
    for (int n = 1; n < N; n++) {
        rec = lcm(rec, T[n]);
    }

    cout << rec << endl;

    cin >> N;

    return 0;
}

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


int main()
{
	int a, b, c, x, n;
	n = 0;
	cin >> a >> b >> c >> x;

	for (int i = 0; i <= c; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= a; ++k) {
				if (500 * k + 100 * j + 50 * i == x)
					n += 1;
			}
		}
	}
	cout << n << endl;
}

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

int main()
{
	string S;
	bool a[26];
	string A = "abcdefghijklmnopqrstuvwxyz";

	cin >> S;

	for (int c = 0; c < 26; c++)
		a[c] = false;

	for (int s = 0; S[s] != '\0'; s++)
		for (int c = 0; c < 26; c++)
			if (S[s] == A[c])a[c] = true;

	for (int c = 0; c < 26; c++) {
		if (a[c] == false) {
			cout << A[c] << endl;
			break;
		}
		if (c == 25) cout << "None" << endl;
	}

	return 0;
}

Measured memory_bytes: 512
moves = {"N": (0, 1),
         "S": (0, -1),
         "E": (1, 0),
         "W": ( -1, 0)}

while True:
    n = int(raw_input())

    if n == 0:
        break

    houseki = set()
    pos = (10, 10)

    for i in range(n):
        x, y = map(int, raw_input().split())
        houseki.add((x, y))

    m = int(raw_input())
    for j in range(m):
        d, cnt = raw_input().split()
        move = moves[d]

        for k in range(int(cnt)):
            pos = (pos[0] + move[0], pos[1] + move[1])

            if pos in houseki:
                houseki.remove(pos)

    if len(houseki) == 0:
        print "Yes"
    else:
        print "No"

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

int main(){
  int N;
  cin >> N;
  int A[N];
  int k = 0;
  int l = 0;
  
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  
  while(l == 0){
    for(int i = 0; i < N; i++){
      if(A[i] % 2 == 0){
        A[i] = A[i]/2;
      }
      else{
        l++;
        break;
      }
    }
    k++;
  }
       
  cout << k-1 << endl;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	
	vector<int> aa = a;
	sort (aa.begin(), aa.end());
	int m1 = aa[n-1], m2 = aa[n-2];
	for (int i = 0; i < n; i++) {
		if (a[i] != m1)
			cout << m1 << endl;
		else
			cout << m2 << endl;
	}
}

Measured memory_bytes: 4792
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
const lli M=1e9+7,N=2e5+5;
lli fact[N],dp[N];

lli binpow(lli a,lli b) 
{
    if (b == 0) return 1;
    lli res = binpow(a,b/2);
    res= (res*res)%M;
    
    if(b%2) return (res*a)%M;
    return res;
}
 
lli inv(lli a)
{
    return binpow(a,M-2);
}

lli add(lli a, lli b)
{
	lli res = a + b;
	if(res >= M)
		return res - M;
	return res;
}
 
lli mult(lli a, lli b)
{
	lli  res = a * b;
	if(res >= M)
		return res % M;
	return res;
}
 
lli sub(lli a, lli b)
{
	return (a%M -b%M +M) %M;
}
void pre()
{
    fact[0]=1;
    for(int i=1;i<N;i++) fact[i]=mult(fact[i-1], i);
}
lli C(lli a, lli b)
{
    return mult(fact[a+b] , inv(mult(fact[a], fact[b])));
}
// bool cmp(const pair<lli,lli>& a, const pair<lli,lli>& b)
// {
//     return a.first+a.second<b.first+b.second;
// }

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    pre();
    lli h,w,n;
    cin>>h>>w>>n;
    lli i,j,x,y;
    vector<pair<lli,lli>> v;
    
    for(i=0;i<n;i++)
    {
        cin>>x>>y;
        v.push_back({x,y});
    }
    v.push_back({h,w});
    
    sort(v.begin(), v.end());
    for(i=0;i<=n;i++)
    {
        dp[i]=C(v[i].first-1, v[i].second-1);
        
        for(j=0;j<i;j++)
            if(v[j].first<=v[i].first && v[j].second<=v[i].second)
                dp[i] = sub(dp[i], mult(dp[j], C(v[i].first-v[j].first, v[i].second-v[j].second)));
    }
    
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 1920
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    A = list(map(int, rl().split()))
    
    ans = 0
    for i in range(1, N):
        if A[i] < A[i - 1]:
            ans += A[i - 1] - A[i]
            A[i] = A[i - 1]
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 105008
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();

        int[] A = new int[N];
        for (int i = 0; i < N; ++i) {
            int num = sc.nextInt() - 1;
            A[num]++;
        }
        Arrays.sort(A);
        sc.close();

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

        // 0を除く最小の数字の個数を書き替える
        // 実際の種類cntと目標の種類Kの差の回数
        int ans = 0;
        if (cnt > K) {
            for (int i = (N - cnt); i < (N - cnt) + (cnt - K); ++i) {
                ans += A[i];
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 83192
n = int(input())
Adj = [[-1]*n for _ in range(n)]

for i in range(n):
    ai = int(input())
    for j in range(ai):
        xij,yij = map(int, input().split( ))
        xij -= 1
        Adj[i][xij] = yij###==ってなんぞ
#print(Adj)
ans = 0

bt = 1<<n

for b in range(bt):#全探索
    flag = True
    tmp = 0
    for i in range(n):
        for j in range(n):
            if Adj[i][j]>=0:
                if ((b>>i) &1) and (((Adj[i][j]==0) and ((b>>j) &1)) or ((Adj[i][j]==1) and (not (b>>j) &1))):#正直者の答えが矛盾,醜いがあとでビット演算子確認
                    flag = False
                    break
        if not flag:
            break
    if flag:
        for t in range(n):
            tmp += (b>>t)&1
            #print("test",b,tmp,flag)
    ans = max(tmp, ans)
    #print(b,ans)
print(ans)


Measured memory_bytes: 44656
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B,N,keisan,isum=0,sum=0;

    cin >>N >>A >>B;

    for(int i=0;i<=N;i++){
        keisan=i;
        for(int k=0;k<5;k++){
            isum=isum+keisan%10;
            keisan=keisan/10;
            if(keisan==0)break;
        }
        if(isum>=A&&isum<=B){
            sum=sum+i;
        }
        isum=0;
    }

    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll dp[100009],wt[100009],val[100009];
int main() {
    int n,W;
    cin>>n>>W;
    for(int i=1;i<=n;i++)
        cin>>wt[i]>>val[i];
    // for(int i=1;i<=n;i++)
    //     cout<<wt[i]<<" "<<val[i]<<" ";
    // cout<<endl;
    memset(dp, 0, sizeof(dp));
    for(int i=1;i<=n;i++){
        for(int j=W;j>0;j--){
            // dp[i][j]=dp[i-1][j];
            if(j-wt[i]>=0){
                // cout<<i<<"-"<<j<<"-"<<j-wt[i]<<"-"<<dp[i-1][j-wt[i]]<<"-"<<val[i]<<"-";
                dp[j]=max(dp[j], val[i]+dp[j-wt[i]]);
            }
            // cout<<dp[i][j]<<" ";
        }
        // cout<<endl;
    }
    cout<<dp[W]<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
using namespace std;

int main()
{
  vector<int> c(3);
  for (int i = 0; i < 3; i ++)
    cin >> c.at(i);
  
  sort(c.begin(), c.end(), greater<>{});
  cout << c.at(0) * 10 + c.at(1) + c.at(2) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int k,s;
    scanf("%d%d",&k,&s);

    int count=0;
    int x,y;
    for(x=0;x<=k;x++){
        for(y=0;y<=k;y++){
            if(0<=(s-x-y)&&(s-x-y)<=k){
                count++;
            }
        }
    }
    printf("%d\n",count);
    return 0;
}

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

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

    int n;
    vector<int> v;

    cin >> n;
    for(int i = 3; i <= n; i++){
        int x = i;
        if (x % 3 == 0) v. push_back(x);
        else{
            int y = x;
            while(y){
                if(y % 10 == 3){
                    v.push_back(x);
                    break;
                }
                y /= 10;
            }
        }
    }

    for(int i = 0; i < v.size(); i++){
        cout << " " << v[i] << flush;
    }
    cout << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    int A,B; cin >> A >> B;

    if(A+B >= 10) cout << "error" << endl;
    else cout << A+B << endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    int N;
    cin >> N;

    LL ans = 0;
    for (int i = 1; i <= N; ++i) {
        int A;
        cin >> A;
        if (i % 2 == 1 && A % 2 == 1) ++ans;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define F first
#define S second
#define int long long
#define lint long long
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define SET(x, val) memset(x, val, sizeof(x))
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 2e5 + 5, MOD1 = 1e9 + 7, MOD2 = 998244353;
const lint INF = 1e18;

bool vis[N];
int n, m, ans[N];
vi adj[N];
queue< int > q;
signed main()
{
    cin >> n >> m;
    for(int i = 0; i < m; i++)
    {
        int u, v;
        cin >> u >> v;
        adj[u].pb(v); adj[v].pb(u);
    }
    ans[1]=-1;
    vis[1]=true;
    q.push(1);
    while(q.size())
    {
        int u = q.front();
        q.pop();
        for(auto v: adj[u])
        {
            if(vis[v]) continue;
            ans[v]=u;
            q.push(v);
            vis[v]=true;
        }
    }
    for(int i = 1; i <= n; i++)
    {
        if(ans[i]==0)
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes\n";
    for(int i = 2; i <= n; i++)
    {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 15488
#include<bits/stdc++.h>
#define MOD 1000000007
#define line "\n"
#define loop(i,a,n) for(ll i=a;i<n;i++)
#define ll long long int
#define lb long double
#define ull unsigned long long int
#define pb push_back
#define vi vector < int >
# define vs vector < string >
# define vb vector < bool >
#define vll vector<ll>
# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >
#define vpii vector<pair<int,int>>
#define vpsi vector<pair<string,int>>
#define mii map<int ,int>
#define mis map<int,string>
#define all(v) v.begin(),v.end()


# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
using namespace std;

void solve()
{ 
ll n,x,t;
ll time=0;
cin>>n>>x>>t;
while(n>=0)
{
{
    n-=x;
    time+=t;
    }
if(n<=0)break;

}
cout<<time<<line;
}



int main()
{fast
// #ifndef ONLINE_JUDGE
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
//  #endif
// ll t;
// cin>>t;
// while(t--)
{
solve();
}

}



Measured memory_bytes: 3648
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

ll dp[55][55][2505];

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,a;
    cin>>n>>a;
    V<ll> x(n);
    cinf(n,x);
    dp[0][0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<=n;j++){
            for(int k=0;k<=2500;k++){
                if(k-x[i]>=0&&j>0) dp[i+1][j][k]=dp[i][j-1][k-x[i]]+dp[i][j][k];
                else dp[i+1][j][k]=dp[i][j][k];
            }
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++) ans+=dp[n][i][i*a];
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'\n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え(=でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
*/

Measured memory_bytes: 54528
from collections import defaultdict


n, taks, aoks = map(int, input().split())
taks -= 1
aoks -= 1

edges = defaultdict(list)

for i in range(n-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

aoki_map = [None] * n
taka_map = [None] * n


def dfs(start, edges, path):
    path[start] = 0
    todo = []
    for to in edges[start]:
        todo.append([to, 1])
        path[to] = 1

    while todo:
        node, dist = todo.pop()
        if path[node] < dist:
            continue

        for to in edges[node]:
            if path[to] is None or path[to] > dist+1:
                todo.append([to, dist+1])
                path[to] = dist+1


dfs(aoks, edges, aoki_map)


ans = [-1] * n
ans[taks] = aoki_map[taks]
taka_map[taks] = 0

todo = []
for to in edges[taks]:
    todo.append([to, 1])
    ans[to] = aoki_map[to]
    taka_map[to] = 1


while todo:
    node, dist = todo.pop()
    if taka_map[node] < dist:
        continue

    for to in edges[node]:
        if taka_map[to] is None or taka_map[to] > dist + 1:
            if aoki_map[to] > dist + 1:
                todo.append([to, dist + 1])
                taka_map[to] = dist + 1
                ans[to] = aoki_map[to]
            else:
                ans[to] = aoki_map[to]

res = max(ans)

print(res-1)


Measured memory_bytes: 38552
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<ll,ll> pii;
typedef tuple<ll,ll,ll> t3;

using namespace std;

vector<pii> g[51];

void dfs(int from, int i, vector<bool>& v)
{
    for(auto e: g[from])
    {
        if(e.second == i)
        {
            continue;
        }
        if(v[e.first])
        {
            continue;
        }
        v[e.first] = true;
        dfs(e.first, i, v);
    }
}

int main() {
    int n,m;
    cin>>n>>m;
    for(int i = 0;i < m;i++)
    {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        g[a].emplace_back(b,i);
        g[b].emplace_back(a,i);
    }
    int count = 0;
    for(int i = 0;i < m;i++)
    {
        vector<bool> visits(n, false);
        visits[0] = true;
        dfs(0, i , visits);
        for(auto e: visits)
        {
            if(!e)
            {
                count++;
                break;
            }
        }
    }
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 

using namespace std;

ll n,m;
vector<ll>v[100005];
bool visited[100005];
ll dp[100005];


ll dfs(ll x)
{
    if (dp[x]!=-1)
        return dp[x];
    visited[x]=1;

    for(auto adj : v[x])
    {
        if(!visited[adj])
        {
            dp[x]=max(dp[x],1+dfs(adj));
        }
        else
            dp[x]=max(dp[x],1+dp[adj]);
    }
    if(dp[x]==0)
    dp[x]=1;
    return dp[x];
}

int main()
{
    cin>>n>>m;
    ll x,y,i;
    memset(dp,-1,sizeof(dp));
    for(i=1;i<=m;i++)
    {
        cin>>x>>y;
        v[x].push_back(y);
       // v[y].push_back(x);
    }

    for(i=1;i<=n;i++)
    {
        if(!visited[i])
            dfs(i);
    }
    ll ans=0;
    for(i=1;i<=n;i++)
        ans=max(dp[i],ans);
    cout<<ans;
}

Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+5;
typedef long long ll;

ll gcd(ll a, ll b){
	if(b == 0) return a;
	return gcd(b, a%b);
}

int main(){
	ll a, b; cin >> a >> b;
	if(a < b) swap(a,b);
	ll c = a*b/gcd(a, b);
	cout << c;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int n,y,m,d,i,sum;
  cin >> n;
  for(i=0;i<n;i++){
    sum = 0;
    cin >> y >> m >> d;
    if(y%3==0 || m%2!=0)sum+=20-d;
    else sum+=19-d;
    if(y%3==0)sum+=(10-m)*20;
    else if(m%2==0)sum+=(10-m)/2*39;
    else sum+=19+(10-m-1)/2*39;//ここまでその年
    if(y%3==0)sum+=(1000-y-1)/3*590;
    else if(y%3==1)sum+=395+(1000-y-3)/3*590;
    else sum+=200+(1000-y-2)/3*590;
    cout << sum+1 << endl;
  }
  return 0;
}



Measured memory_bytes: 3036
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <math.h>
#include <string>

using namespace std;
long long int gcd(long long int a, long long int b)
{
	if(a==0)
		return b;
	return gcd(b%a,a);
}
int main()
{
	int t,n,m;
	scanf("%d",&n);
	long long int ar[n];
	for(int i=0;i<n;i++)
		cin>>ar[i];
	long long int ans=ar[0];
	for(int i=1;i<n;i++)
	{
		ans=(ans/gcd(ans,ar[i]))*ar[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  vector<vector<int> > G(n, vector<int>());
  rep(i, m){
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

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

  return 0;
}



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

############################################

# read data for n sequences.
N = int(input())
data = input()

out = 0
r=0;g=0;b=0;
for d in data:
    if d =="R":
        r+=1
    elif d=="B":
        b+=1
    else:
        g+=1
out = r*g*b

if N > 2:
    for ii, i in enumerate(data[:-2]):
        for jj,j in enumerate(data[ii+1:-1]):
            jj = jj+ii+1
            if i!=j:
                sum1 = 0                    
                for d in [d for d in "RGB"]:
                    if i!=d and j!=d:
                        let = d

                if jj+jj-ii<N:
                    if data[jj+jj-ii]==let:                    
                        out-=1
print(out)



Measured memory_bytes: 75428
s = list(input())
t = list(input())
l = list()
wake = len(s)-(len(t)-1)

for i in range(wake):
  l.append(s[i:i+len(t)])
gokei = len(t)
for i in l:
  sco = len(t)
  q = 0
  for j in i:
    if j == t[q]:
      sco -= 1
    q += 1
  if gokei > sco:
    gokei = sco
    
print(gokei)

Measured memory_bytes: 10536
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<58;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Union_Find_Tree{
	public:
	vi Par,Rank;
	Union_Find_Tree(int n){
		Par=Rank=vi(n);
		for(int i=0;i<n;i++) Par[i]=i;
	}
	int Find_Par(int x){
		if(Par[x]==x) return x;
		return Par[x]=Find_Par(Par[x]);
	}
	bool Unite(int x,int y){
		x=Find_Par(x);
		y=Find_Par(y);
		if(x==y) return 0;
		if(Rank[x]<Rank[y]) Par[x]=y;
		else{
			Par[y]=x;
			if(Rank[x]==Rank[y]) Rank[x]++;
		}
		return 1;
	}
	bool Same(int x,int y){
		return Find_Par(x)==Find_Par(y);
	}
};

int n,t,k;
vip a;

int main(){
	int cnt=1;
	while(1){
		cin>>n>>t>>k;
		if(!n) break;
		a=vip(n-1);
		int res=0;
		for(int i=0;i<n-1;i++){
			int u,v,c;
			cin>>u>>v>>c;
			a[i]={c,{u,v}};
		}
		sort(a.rbegin(),a.rend());
		Union_Find_Tree uft(n+1);
		for(int i=0;i<t;i++){
			int v;
			cin>>v;
			uft.Unite(0,v);
		}
		for(int i=0;i<n-1;i++){
			P p=a[i].second;
			int c=a[i].first,u=p.first,v=p.second;
			if(uft.Same(u,v)){
				t--;
				if(t<=k) res+=c;
			}
			else uft.Unite(u,v);
		}
		cout<<"Case "<<cnt<<": "<<res<<endl;
		cnt++;
	}
}

Measured memory_bytes: 3212
import java.io.*;
import java.util.*;

class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Building[] building=new Building[4];
        for(int i=0;i<4;i++){
            building[i]=new Building();
        }
        int n = Integer.parseInt(br.readLine());
        for (int i = 0; i < n; i++) {
            StringTokenizer st = new StringTokenizer(br.readLine());
            int b = Integer.parseInt(st.nextToken());
            int f = Integer.parseInt(st.nextToken());
            int r = Integer.parseInt(st.nextToken());
            int v = Integer.parseInt(st.nextToken());
            building[b-1].floor[f-1].room[r-1]+=v;
        }
        for(int i=0;i<3;i++){
            building[i].show();
            System.out.println("####################");
        }building[3].show();

    }

}

class Building {

    Floor[] floor = new Floor[3];

    Building() {
        for (int i = 0; i < 3; i++) {
            floor[i] = new Floor();
        }
    }
    
    void show(){
        for(int i=0;i<3;i++){
            for(int j=0;j<10;j++){
                System.out.print(" "+this.floor[i].room[j]);
            }System.out.println();
        }
    }
    
}

class Floor {

    int[] room = new int[10];

    Floor() {
        Arrays.fill(room, 0);
    }
}

Measured memory_bytes: 24696
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;

char a[5];


int main()
{
  scanf("%s",a);
  int f=0,t=0,k=0;
  if(a[0]==a[1])
  {
  for(int i=2;i<4;i++)
  {
     if(a[i]==a[0])
     {
      f=1;
      break;
     }

  }
  if(a[2]!=a[3])
  f=1;
  }
  else
  {
  for(int i=2;i<4;i++)
  {
    if(a[i]==a[0])
    t++;
    else if(a[i]==a[1])
    k++;
  }
  if(k!=1||t!=1)
  f=1;

  }
  if(f==1)
  printf("No\n");
  else
  printf("Yes\n");
}


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

int main() {
  long long n,k;
  scanf("%lld %lld", &n, &k);
  long long a[n+1], t[n+1];
  for(int i=1;i<=n;i++){
    scanf("%lld", &a[i]);
    t[i]=0;
  }
  long long next=1;
  long long i=0;
  for(;;){
    if(i==k){
      printf("%lld", next);
      return 0;
    }
    t[next]++;
    //printf("%lld: %lld\n", next, t[next]);
    if(t[next]==3) {
      t[next]--;
      break;
    }
    next = a[next];
    i++;
  }
  int one=0, two=0;
  for(int i=1;i<=n;i++){
    if(t[i]==1) one++;
    if(t[i]==2) two++;
  }
  //printf("one: %d \n two: %d\n", one, two);
  k = (k-one)%two + one;
  //printf("new k = %lld\n", k);
  for(int i=1;i<=n;i++){
    t[i]=0;
  }
  next=1; i=0;
  //printf("2nd\n");
  for(;;){
    if(i==k){
      printf("%lld", next);
      return 0;
    }
    t[next]++;
    //printf("%lld: %lld\n", next, t[next]);
    if(t[next]==3) {
      t[next]--;
      break;
    }
    next = a[next];
    i++;
  }
  return 0;
}

Measured memory_bytes: 5280
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;

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

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main() {
  int n, x;
  cin >> n >> x;
  int sum = 0;
  rep (i, x) {
    int tmp;
    cin >> tmp;
    sum += tmp;
  }
  if (n >= sum) P(n - sum);
  else P(-1);
  return 0;
}

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

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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> data(N);
  rep(i,N)cin >> data[i];

  int cnt = 0;
  rep(i,N){
    if(data[data[i]-1]==i+1)++cnt;
  }

  cout << cnt / 2 << endl;

  return 0;
}


Measured memory_bytes: 768
#ABC127B
S = input()
ab,cd = S[0:2],S[2:4]
if ab == "00" and cd == "00":
    print("NA")
elif int(ab) >= 13 and int(cd) >= 13:
    print("NA")
elif ab == "00" and int(cd) >=13:
    print("NA")
elif int(ab) >=13 and cd =="00":
    print("NA")
elif ab == "00" and int(cd) <= 12:
    print("YYMM")
elif int(ab) <= 12 and cd == "00":
    print("MMYY")
elif int(ab) <= 12 and int(cd) <= 12:
    print("AMBIGUOUS")
elif int(ab) <= 12 and int(cd) >= 13:
    print("MMYY")
elif int(ab) >= 13 and int(cd) <= 12:
    print("YYMM")

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

using namespace std;

inline ll read()
{
    ll ret=0,flag=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')flag=-1;c=getchar();}
    while(c>='0'&&c<='9')ret=ret*10+(c^'0'),c=getchar();
    return flag*ret;
}

struct use
{
    ll x,h;
};

const ll N=2e5+5;
ll n,d,a;
use s[N];
queue<use> q;

bool cmp(const use &a,const use &b)
{
    return a.x<b.x;
}

int main()
{
    n=read(),d=read(),a=read();
    for(ll i=1;i<=n;i++)s[i].x=read(),s[i].h=read();
    sort(s+1,s+n+1,cmp);
    ll ans=0,sum=0;
    for(ll i=1;i<=n;i++)
    {
        while(q.empty()==0&&s[i].x>q.front().x)sum-=q.front().h,q.pop();
        s[i].h-=sum;
        if(s[i].h<=0)continue;
        ll step=s[i].h/a+(s[i].h%a!=0);
        ll attack=step*a;
        sum+=attack;
        ans+=step;
        q.push({s[i].x+(d<<1),attack});
    }
    printf("%lld",ans);
    return 0;
}


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

int main(){
  int i,ans=100000000000,num,fav=753;
  string s;
  cin>>s;
  for(i=0;i<s.length();i++){
    num=stoi(s.substr(i,3));
    if(ans>abs(fav-num))ans=abs(fav-num);
  }
  cout << ans;
}


Measured memory_bytes: 256
h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]

rui = [-1]*(h*w+1)
iti = [[] for _ in range(h*w+1)]

for i in range(h):
    for j in range(w):
        iti[a[i][j]] = (i,j)

for i in range(1,d+1):
    a = 0
    rui[i] = 0
    for j in range(i+d,h*w+1,d):
        a += (abs(iti[j][0] - iti[j-d][0]) + abs(iti[j][1] - iti[j-d][1]))
        rui[j] = a

q = int(input())
for _ in range(q):
    l,r = map(int,input().split())
    print(rui[r]-rui[l])

Measured memory_bytes: 83176
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
using namespace std;

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

	vector<int> vec_a(a);
	for (int i = 0; i < a; i++) cin >> vec_a.at(i);
	vector<int> vec_b(b);
	for (int i = 0; i < b; i++) cin >> vec_b.at(i);

	int ans = vec_a.at(0) + vec_b.at(0);
	for (int i = 0; i < m; i++) {
		int x, y, c;
		cin >> x >> y >> c;
		int pri = vec_a.at(x - 1) + vec_b.at(y - 1) - c;
		if (pri < ans) ans = pri;
	}

	sort(vec_a.begin(), vec_a.end());
	sort(vec_b.begin(), vec_b.end());
	int pri = vec_a.at(0) + vec_b.at(0);
	if (pri < ans) ans = pri;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = [int(input()) for i in range(n)]

ans = 0
i = 1
while i != 2:
  tmp = a[i - 1]
  a[i - 1] = 0
  i = tmp
  if i == 0:
    ans = -1
    break
  ans += 1
print(ans)

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

int64_t i(int64_t n){
  if(n>0) return 1;
  else return 0;
}

int main(){
  int64_t N, K;
  cin >> N >> K;
  if(N>K){
    int64_t k = N/K -1 + i(N%K);
    int64_t a = N - k*K;
    int64_t ans = min(a,K-a);
    cout << ans << endl;
  }
  else{
    cout << min(N,K-N) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#define N 100005
using namespace std;
typedef long long ll;
const ll mod = 1000000007LL;
ll n, m;
ll x;
int main() {
	cin>>x;
	ll l = 0, r = 100000;
	while(l < r) {
		ll mid = (l+r)/2;
		ll y = x;
		ll cur = mid;
		while(y > 0 && cur > 0) {
			if (y >= cur) {
				y -= cur;
			}
			cur--;
		}
		if (y == 0) {
			r = mid;
		} else {
			l = mid+1;
		}
	}
	cout<<r<<endl;
	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

import Data.Map.Strict (Map, (!), fromList, insert, union)
import Data.List (foldl', sortBy, groupBy, minimum)
import Control.Applicative ((<$>))
import Debug.Trace (trace)

type RowCol = (Int, Int)
type Memo   = Map (Int, Int) Int
type IdxRC  = Map Int (Int, Int)

main :: IO ()
main = do
    n  <- readLn :: IO Int
    ms <- map toPair . lines <$> getContents :: IO [RowCol]
    let idxrc'   = fromList idxrc  :: IdxRC
        idxrc    = zip [1..] ms    :: [(Int, RowCol)]
        neighbor = fromList $ zipWith (\(a, (x, y)) (b, (x', y')) -> ((a, b), x * y * y')) idxrc (tail idxrc) :: Memo
        single   = fromList $ zipWith (\(a, (x, y)) (b, (x', y')) -> ((a, b), 0)) idxrc idxrc :: Memo
        memo     = union neighbor single
        rest     = sort' [ (x, y) | x <- [1..(n-2)], y <- [(x+2)..n] ]
    print $ (fst (foldl' solve (memo, idxrc') rest)) ! (1, n)
  where
    toPair = (\[x, y] -> (x, y)) . map read . words
    sort'  = concatMap (sortBy (flip compare)) . groupBy (\(_, a) (_, b) -> a == b) . sortOn
    sortOn = sortBy (\(_, a) (_, b) -> if a >= b then GT else LT)


solve :: (Memo, IdxRC) -> (Int, Int) -> (Memo, IdxRC)
solve (!memo, !idxrc) (!a, !b) = (insert (a, b) value memo, idxrc)
  where
    value = minimum [ ar * bc * snd (idxrc ! (a + (i - 1)))
                    + memo ! (a, a + (i - 1))
                    + memo ! (a + i, b)
                    | i <- [1..(b - a)]
                    ]
      where
        ar    = fst $ idxrc ! a
        bc    = snd $ idxrc ! b



Measured memory_bytes: 5720
S = input()

ans = "Yes"
for i in range(len(S)//2) :
    if S[i] != S[-1-i] :
        ans = "No"

T = S[:len(S)//2]
for i in range(len(T)//2) :
    if T[i] != T[-1-i] :
        ans = "No"

print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

int gcd(int a, int b);

main()
{
    int x, y, z;

    scanf("%d", &x);
    scanf("%d", &y);

    z = gcd(x, y);

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

int gcd(int a, int b)
{
    int c;

    while (b > 0)
    {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}



Measured memory_bytes: 2104
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>

using namespace std;
typedef long long ll;

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

int main() {

    ll N,K;
    cin >> N >> K;
    ll lim = N;
    double out = 0;
    if(N>=K){
        lim = K-1;
        out += (N-K+1)/(double)N;
    }
    ll A[lim];
    rep(i,lim) A[i] = i+1;
    ll cnt = 0;
    while(A[0]<K){
        cnt++;
        rep(i,lim){
            A[i] *= 2;
            if(A[i]>=K){
                out += pow(2,-cnt)/(double)N;
                if(i!=0) A[i] = 0;
            }
        }
    }
    cout << fixed << setprecision(9) << out << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);
typedef long long int ll;
typedef vector<pair<ll,ll> > vpl;
typedef vector<pair<int,int> > vpi;
typedef vector<ll> vec;
typedef map<ll,ll> mp;
ll GCD(ll a,ll b)
{
    if(a == 0)
    {
        return b;
    }
    return GCD(b%a,a);
}
int main()
{
    FastIO;
    int q = 1;
    //cin >> q;
    while(q--)
    {
        string s;
        cin >> s;
        int len = s.length();
        ll res = 0;
        for(int i =0;i<len;i++)
        {
            res+=s[i]-'0';
        }
        if(res%9 == 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}



Measured memory_bytes: 3768
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      ans = 500*i + 100*j + 50*k
      if ans == X:
        count += 1
print(count)
      

Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine().trim();
		String[] arr = line.split(" ");
		int a = Integer.parseInt(arr[0]);
		int b = Integer.parseInt(arr[1]);
		int s = a * b;
		int l = a * 2 + b * 2;
		System.out.println(s + " " + l);
		br.close();
	}
	
}

Measured memory_bytes: 24132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
ll mod = 1000000007;

ll dp[101][4][4][4];

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            for (int k = 0; k < 4; k++) {
                if(i == 0 && j == 1 && k == 2) { continue; }
                if(i == 1 && j == 0 && k == 2) { continue; }
                if(i == 0 && j == 2 && k == 1) { continue; }
                dp[3][i][j][k] = 1;
            }
        }
    }
    int N;
    cin >> N;
    for (int n = 0; n < N; n++){
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                for (int k = 0; k < 4; k++) {
                    for (int l = 0; l < 4; l++) {
                        if (i == 0 && j == 1 && l == 2) continue;
                        if (i == 0 && k == 1 && l == 2) continue;
                        if (j == 0 && k == 1 && l == 2) continue;
                        if (j == 1 && k == 0 && l == 2) continue;
                        if (j == 0 && k == 2 && l == 1) continue;
                        (dp[n+1][j][k][l] += dp[n][i][j][k]) %= mod;
                    }
                }
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < 4; i++)
        for (int j = 0; j < 4; j++)
            for (int k = 0; k < 4; k++)
                 (ans += dp[N][i][j][k]) %= mod;
    cout << ans << endl;
}


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



typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 

//defines
typedef long long ll;
typedef long double ld;

ll n,m,k,a,b,c,t=1;
void solve()
{
    cin>>n;
    map<ll,ll>f;
    for(ll i=1;i<=100;i++)
    {
        for(ll j=1;j<=100;j++)
        {
            for(ll p=1;p<=100;p++)
            {
                m=(i*i)+(j*j)+(p*p)+(i*j)+(j*p)+(p*i);
                if(m<=n)f[m]++;
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        cout<<f[i]<<"\n";
    }
    
 //cout<<"\n";
}

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

 // cin>>t;
    while(t--)
    {
        solve();
    }
  //cout<<sum;
        
    return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	if(n>m)
		for(int i=0;i<n;i++)
			cout<<m;
	else
		for(int i=0;i<m;i++)
			cout<<n; 
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

const long long INF = (long long) 2e18;

int Q;
long long l, r;

long long get(long long at, long long n, bool reverse) {
    if (!reverse) {
        return at < l ? at : (at + 1);
    } else {
        return at < r ? at : (at + 1);
    }
}

long long mul(long long x, long long y) {
    if (x >= INF / y) {
        return INF;
    }
    return x * y;
}

bool check(long long res, long long score) {
    long long low = 1;
    long long high = res;
    while (high - low >= 10) {
        long long rl = low + (high - low) / 3;
        long long rr = high - (high - low) / 3;
        long long x = mul(get(rl, res, false), get(res - rl + 1, res, true));
        long long y = mul(get(rr, res, false), get(res - rr + 1, res, true));
        if (max(x, y) >= score) {
            return false;
        }
        if (x < y) {
            low = rl;
        } else {
            high = rr;
        }
    }
    for (long long now = low; now <= high; now++) {
        long long x = mul(get(now, res, false), get(res - now + 1, res, true));
        if (x >= score) {
            return false;
        }
    }
    return true;
}

int main() {

    scanf("%d", &Q);

    for (int i = 0; i < Q; i++) {
        scanf("%lld %lld", &l, &r);
        long long low = 0;
        long long high = (long long) 1e18;
        while (low <= high) {
            long long mid = (low + high) / 2;
            if (check(mid, l * r)) {
                low = mid + 1;
            } else {
                high = mid - 1;
            }
        }
        printf("%lld\n", high);
    }

    return 0;

}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	int m;
	cin >> m;
	int a = 0;
	int p, x;
	int sum = accumulate(v.begin(), v.end(),0);
	for (int i = 0; i < m; i++) {
		cin >> p >> x;
		cout << sum - v[p - 1] + x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl c(1e5 + 1, 0);
  rep(i, n) {
    ll a;
    cin >> a;
    c[a]++;
  }
  ll ans = 0;
  rep2(i, 1, 1e5) {
    ll now = c[i - 1] + c[i] + c[i + 1];
    ans = max(ans, now);
  }
  cout << ans << endl;
}

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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 x;
  cin >> x;
  int32 g = gcd(360,x);
  ANS(360 / g);
  return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>

#define MAX 1e+7

int main()
{
	int a, b, c;
	int n, min_val;
	int pr_sum, am_sum;

	while ( scanf( "%d", &n ) == 1 ) {
		if ( n == 0 ) { break; }

		// 購入する際のすべての組み合わせを求めて，最安値を求めておく
		min_val = MAX;
		for ( a = 0 ; a < 50 ; a++ ) {
			for ( b = 0 ; b < 50 ; b++ ) {
				for ( c = 0 ; c < 50 ; c++ ) {
					pr_sum =  ( 380 * ( 5 * (a/5) ) ) * 0.80 + 380 * ( a%5 );
					pr_sum += ( 550 * ( 4 * (b/4) ) ) * 0.85 + 550 * ( b%4 );
					pr_sum += ( 850 * ( 3 * (c/3) ) ) * 0.88 + 850 * ( c%3 );

					if ( 200*a+300*b+500*c == n ) {
						if ( min_val > pr_sum ) {
							min_val = pr_sum;
						}				
					}
				}
			}
		}
		printf( "%d\n", min_val );
	}

	return 0;
}



Measured memory_bytes: 2104
_ = input()
N = list(map(int, input().split()))
Tong1 = [0 for i in range(int(1e5 + 7))]
Tong2 = [0 for i in range(int(1e5 + 7))]
for i in range(0, len(N), 2):
    Tong1[N[i]] += 1
for i in range(1, len(N), 2):
    Tong2[N[i]] += 1

Num_pos1 = Tong1.index(max(Tong1))
Num_pos2 = Tong2.index(max(Tong2))
if(Num_pos1 == Num_pos2):
    print(len(N) - max(Tong1) - max(sorted(Tong1, reverse=True)[1], sorted(Tong2, reverse=True)[1]))
else:
    print(len(N) - max(Tong1) - max(Tong2))

Measured memory_bytes: 14404
#include<stdio.h>

int main(){
	int n,tmp,min=1000000,max=-1000000;
	long int sum = 0;
	scanf("%d\n",&n);
	for(int i = 0; i < n; i++){
		scanf("%d ",&tmp);
		sum+=tmp;
		max = max < tmp ? tmp : max;
		min = min > tmp ? tmp : min;
	}
	printf("%d %d %ld\n",min,max,sum);
	return 0;
}



Measured memory_bytes: 2048
n=int(input())
a=[0]+list(map(int,input().split()))

m=0
ans=[]
c=[0]*(n+1)
for i in reversed(range(1,n+1)):
  if a[i]%2!=c[i]%2:
    m+=1
    ans.append(i)
    j=1
    r=set()
    while j*j<=i:
      if i%j==0:
        r.add(j)
        r.add(i//j)
      j+=1
    for j in r:
      c[j]+=1
      c[j]%=2
        
print(m)
print(*sorted(ans))       

Measured memory_bytes: 97744
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys

def main():
    S  = input()
    n  = len(S) - 1
    sum = 0
    for i in range(2 ** n):
        ichi = 0
        for j in range(n): 
            if ((i >> j) & 1):
                sum += int(S[ichi:j+1])
                ichi = j+1
        sum += int(S[ichi:n+1])
    print(sum)



if __name__ == '__main__':
    main()


Measured memory_bytes: 12072
S = input()
hikari = ['maerd','remaerd','esare','resare']

a = True

while a:
    length = len(S)
    go = ''
    roku = ''
    nana = ''

    if length >= 5:
        for i in range(length-1,length-6,-1):
            go += S[i]
    if length >= 6:
        for i in range(length-1,length-7,-1):
            roku += S[i]
    if length >= 7:
        for i in range(length-1,length-8,-1):
            nana += S[i]

    if go in hikari:
        #cut
        S = S[:-5]
        a = True
    elif roku in hikari:
        #cut
        S = S[:-6]
        a = True
    elif nana in hikari:
        #cut
        S = S[:-7]
        a = True
    else:
        a = False

if S != "":
    print('NO')
else:
    print('YES')


Measured memory_bytes: 3188
times = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0}
loss = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0}
times['a'] = int(input())
times['b'] = int(input())
times['c'] = int(input())
times['d'] = int(input())
times['e'] = int(input())

for key, time in times.items():
    a, b = divmod(time, 10)
    if b > 0:
        loss[key] = 10 - b
    else:
        loss[key] = 0

# print(times)
# print(loss)
# print(sorted(loss.items(), key=lambda x: x[1]))

ans = 0
idx = 1
for k, v in sorted(loss.items(), key=lambda x: x[1]):
    ans += times[k]
    if loss[k] > 0 and idx < 5:
        ans += v
    idx += 1
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
int N;
std::vector<int> A, B, C;
int main(){
    std::cin >> N;
    A.resize(N);
    B.resize(N);
    C.resize(N);
    for(int i = 0; i < N; i++) std::cin >> A[i];
    for(int i = 0; i < N; i++) std::cin >> B[i];
    for(int i = 0; i < N; i++) std::cin >> C[i];
    std::sort(A.begin(), A.end());
    std::sort(B.begin(), B.end());
    std::sort(C.begin(), C.end());
    long long ans = 0;
    std::vector<long long> count(N + 1, 0);
    for(int i = 1; i < N + 1; i++){
        count[i] = count[i - 1] +  (C.end() - std::upper_bound(C.begin(), C.end(), B[i - 1]));
    }
    for(int i = 0; i < N; i++){
        int ind = std::upper_bound(B.begin(), B.end(), A[i]) - B.begin();
        ans += count[N] - count[ind];
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 2176
using System;
using System.Collections.Generic;

public class Result{
    private Dictionary<string, int> judgeResult = new Dictionary<string, int>{
        {"AC", 0},
        {"WA", 0},
        {"TLE", 0},
        {"RE", 0}
    };
    
    public Result(){}
    
    public void Add(string s){
        this.judgeResult[s]++;
    }
    
    public string Output(string s){
        return s + " x " + this.judgeResult[s];
    }
}

public class Program{
    public static void Main(){
        var result = new Result();
        int times = int.Parse(Console.ReadLine());
        
        for(int i = 0; i < times; i++){
            string key = Console.ReadLine();
            result.Add(key);
        }
        
        Console.WriteLine(result.Output("AC"));
        Console.WriteLine(result.Output("WA"));
        Console.WriteLine(result.Output("TLE"));
        Console.WriteLine(result.Output("RE"));
    }
}

Measured memory_bytes: 30760
#if 1
#include<iostream>
#include<cstdint>
#include<algorithm>
int32_t N;
int64_t A[100000];
int64_t eiya() {
	std::sort(A, A + N);
	int64_t V = 0;
	for (int i = N - 1; i >= 1; i--)
	{
		if (A[i] == A[i - 1]) {
			if (V != 0) {
				return V*A[i];
			}
			V = A[i];
			--i;
		}
	}
	return 0;
}
int main()
{
	std::cin >> N;
	for (size_t i = 0; i < N; i++)
	{
		std::cin >> A[i];
	}
	std::cout << eiya() << std::endl;
}
#endif

Measured memory_bytes: 1024