akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1e17;
#define int long long
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int x; cin >> x;
	int now = 0;
	for (int i = 1; i <= MOD; i++) {
		now += i;
		if (now >= x) {
			cout << i << endl; return 0;
		}
	}
	return 0;
}


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

typedef long long ll;
const ll maxn = 1000000 + 15;
ll vis[maxn];

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

void sieve(ll n) {
	ll m = (ll)sqrt(n + 0.5) + 10;
	memset(vis, 0, sizeof(vis));
	for(ll i = 2; i <= m; i++) if (!vis[i]) for(ll j = i * i; j <= m; j+=i) vis[j] = 1;
}

int main() {
	ll a, b, gcdab;
	cin >> a >> b;
	gcdab = gcd(a, b);
	sieve(gcdab);
	ll sum = 1, d = (ll)sqrt(gcdab + 0.5) ;
	for(ll i = 2; i <= d; i++) {
		if (!vis[i] && gcdab % i == 0) {
			sum++;
			while(gcdab % i == 0) gcdab /= i;
		}
	}
	if (gcdab != 1) sum++;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 8064
def int_raw():
    return int(raw_input())

def ss_raw():
    return raw_input().split()

def ints_raw():
    return map(int, ss_raw())

INF = 1 << 29

a,b,c =ints_raw()
def ans():
    if a==b and b==c:
        return "Yes"
    else:
        return "No"


print ans()


Measured memory_bytes: 2568
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let c1 = read::<String>().chars().collect::<Vec<_>>();
    let c2 = read::<String>().chars().collect::<Vec<_>>();

    for i in 0..3 {
        if c1[i] != c2[2 - i] {
            println!("NO");
            return;
        }
    }
    println!("YES");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

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

  int32_t A, B, M;
  cin >> A >> B >> M;
  vector<int32_t> refs(A);
  int32_t min_r = INT_MAX;
  for (auto& ref : refs) {
    cin >> ref;
    min_r = min(ref, min_r);
  }
  
  vector<int32_t> mics(B);
  int32_t min_m = INT_MAX;
  for (auto& mic : mics) {
    cin >> mic;
    min_m = min(mic, min_m);
  }

  int32_t res = min_r + min_m;

  for (int i = 0; i < M; i++) {
    int32_t x, y, c;
    cin >> x >> y >> c;
    int32_t val = refs[x-1] + mics[y-1] - c;
    res = min(res, val);
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 1024
N = int(input())
cnt=[0,0,0,0]
for _ in range(N):
    S=input()
    if S=="AC":
      cnt[0]+=1
    elif S=="WA":
      cnt[1]+=1
    elif S=="TLE":
      cnt[2]+=1
    else:
      cnt[3]+=1

msg="AC x " + str(cnt[0]) + "\n"
msg+="WA x " + str(cnt[1]) + "\n"
msg+="TLE x " + str(cnt[2]) + "\n"
msg+="RE x " + str(cnt[3])

print(msg)


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

int main() {
  int T; scanf("%d", &T);
  while(T--) {
    int N, K; scanf("%d%d", &N, &K);
    vector<int> X(N), dist(N-1);
    for(int i=0; i<N; i++) {
      scanf("%d", &X[i]);
    }

    int sum = X[N-1] - X[0];
    for(int i=1; i<N; i++) {
      dist[i-1] = X[i] - X[i-1];
    }
    sort(dist.rbegin(), dist.rend());

    // fprintf(stderr, "sum = %d\n", sum);
    for(int i=0; i<min(K-1,N-1); i++) {
      // fprintf(stderr, "substitute: %d\n", dist[i]);
      sum -= dist[i];
    }
    printf("%d\n", sum);
  }
  return 0;
}



Measured memory_bytes: 3196
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

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

void Main() {
  char c;
  cin >> c;
  printf("%c\n", c + 1);
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int a, b;
    cin >> a >> b;
    int d = b - a;
    int t = 0;
    for (int i = 1; i < d; i++) {
        t += i;
    }

    cout << t - a << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int T = sc.nextInt();
        int r = 0;
        for(int t=A; t<=T; t+=A) {
            r+=B;
        }
        System.out.println(r);
   }
}

Measured memory_bytes: 21844
N=gets.to_i
as=gets.split.map(&:to_i)
ans=0
61.times do |i|
    i=1<<i
    cnt=0
    as.each do |e|
        cnt+=1 if (e & i)!=0
    end
    ans+=i*(cnt)*(N-cnt)
    ans%=1000000007
end
puts ans

Measured memory_bytes: 34820
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
const int N = 1005;

int a[N], b[N], c[N], dist[101][101];
int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
	
	int n,m;
	cin >> n >> m;

	rep(i,m) {
		cin >> a[i] >> b[i] >> c[i];
		a[i]--;
		b[i]--;
	}

	rep(i,n) {
		rep(j,n) {
			if(i == j)
				dist[i][j] = 0;
			else
				dist[i][j] = inf;
		}
	}

	rep(i,m) {
		dist[a[i]][b[i]] = c[i];
		dist[b[i]][a[i]] = c[i];
	}

	rep(k,n) {
		rep(i,n) {
			rep(j,n) {
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}

	int ans = 0;
	rep(i,m) {
		if(dist[a[i]][b[i]] != c[i])
			ans++;
		// db(dist[a[i]][b[i]]);
	}
	cout << ans << '\n';
}

Measured memory_bytes: 384
N = int(input())
P = [int(x) for x in input().split(' ')]

cnt = 0
for i in range(N-2):
  if P[i] < P[i+1] and P[i+1] < P[i+2]:
    cnt += 1
  elif P[i] > P[i+1] and P[i+1] > P[i+2]:
    cnt += 1
    
  #print(P[i:i+3])
  
print(cnt)

Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	index := -1
	for i := range s {
		if len(s[i:]) >= len(t) {
			flag := true
			for j := 0; j < len(t); j++ {
				if s[i:][j] != t[j] && s[i:][j] != '?' {
					flag = false
					break
				}
			}
			if flag == true {
				index = i
			}
		}
	}
	if index == -1 {
		fmt.Println("UNRESTORABLE")
		return
	}

	ans := ""
	for i := 0; i < len(s); i++ {
		switch {
		case i == index:
			ans += t
			i += len(t) - 1
		case s[i] == '?':
			ans += "a"
		default:
			ans += string(s[i])
		}
	}

	fmt.Println(ans)
}


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

using namespace std;
using ll=long long ;

void solve() {
    int n; cin >> n;
    vector<int> a(n+1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int k = max_element(a.begin()+1, a.end()) - a.begin();
    ll res;
    int l,r;
    if (a[k] <= 0) res=a[k],l=k,r=k;
    else {
        ll s1 = 0;
        int l1 = 0, r1 = 0;
        for (int i = 1; i <= n; i+=2) {
            if (!l1 && a[i] > 0) l1 = i;
            if (a[i] > 0) r1 = i;
            if (a[i] > 0) s1 += a[i];
        }
        ll s2 = 0;
        int l2 = 0, r2 = 0;
        for (int i = 2; i <= n; i+=2) {
            if (!l2 && a[i] > 0) l2 = i;
            if (a[i] > 0) r2 = i;
            if (a[i] > 0) s2 += a[i];
        }
        if (s1 > s2) res=s1, l=l1, r=r1;
        else res=s2, l=l2, r=r2; 
    }
    cout << res << "\n";
    vector<int> pos;
    for (int i = n; i > r; i--) {
        pos.emplace_back(i);
    }
    while (l != r) {
        if (a[r-2] > 0) {
            pos.emplace_back(r-1);
        } else {
            pos.emplace_back(r-2);
        }
        r = r-2;
    }
    for (int i = 1; i < l; i++) {
        pos.emplace_back(1);
    }
    cout << pos.size() << "\n";
    for (auto& x: pos) {
        cout << x << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    int X[N];
    int ans = 0;
    rep(i, N){
        cin >> X[i];
        if(X[i] < K-X[i]) ans += 2*X[i];
        else ans += 2*(K-X[i]);
    }
    cout << ans;
    cout << endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>

using namespace std;
long long cur[200100];
long long sum[200100];
const int mod = 1e9+7;
int main()
{
    long long ans = 0;
    int n;
    scanf("%d",&n);
    sum[0] = 0;
    for(int i = 1;i <= n;i++) {
        scanf("%lld",&cur[i]);
        sum[i] = cur[i] + sum[i-1];
    }
    for(int i = 1;i <= n;i++) {
        ans += ((sum[n]-sum[i])%mod)*cur[i];
        ans %= mod;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 6916
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b,c;
    char d,e;
  	string s;
  	cin>>a;
  if(a%2==0)
 cout<<a<<endl;
 else
   cout<<a*2<<endl;
  /* 
 if(a>=1200&&a<2800)
    cout<<"ARC"<<endl;
 else if(a>=2800)
   cout<<"AGC"<<endl;
 else
   cout<<"ABC"<<endl;
  else if(a==23)
    cout<<"Christmas Eve Eve"<<endl;
  else
    cout<<"Christmas Eve Eve Eve"<<endl;
  */
 return 0;
}

Measured memory_bytes: 256
N, M = list(map(int, input().split()))
P, CP = [], []

for i in range(N):
    P.append(list(map(int, input().split())))
for i in range(M):
    CP.append(list(map(int, input().split())))

for i in range(N):
    a, b = P[i][0], P[i][1]
    now = 10**10
    for j in reversed(range(M)):
        c, d = CP[j][0], CP[j][1]
        distance = abs(a-c)+abs(b-d)
        if distance <= now:
            result = j+1
            now = distance
    print(result)

Measured memory_bytes: 9200
#include<iostream>
#include<algorithm> // sort,reverse,min,lower_bound
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  string str; cin >>str;
  reverse(str.begin(),str.end());
  int n=str.size();
  li head=0,tail=0;
  rep(i,n){
    int a=str.at(i)-'0';
    li thead= min(head+a,tail+a+1);
    li ttail= min(head+10-a, tail+10-a-(i!=0));
    head=thead,tail=ttail;
    if(df)printf("%d/%d ",head,tail);
  }
  printf("%ld",min(head,tail+1));
}

/// confirm df==0 ///


Measured memory_bytes: 1412
#include<bits/stdc++.h>
using namespace std;
constexpr int maxn = 200000;
constexpr int maxm = 2000;
constexpr int mod = 1000000007;
void add(int& x, int y){
    x += y;
    if(x >= mod) x -= mod;
}
int A[maxn], B[maxn];
int DP[maxm * 2 + 1][maxm * 2 + 1];
int C[maxm * 2 + 1][maxm * 2 + 1];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int N;
    cin >> N;
    for(int i = 0; i < N; i += 1){
        cin >> A[i] >> B[i];
        DP[maxm - A[i]][maxm - B[i]] += 1;
    }
    C[0][0] = 1;
    int ans = 0;
    for(int i = 0; i <= 2 * maxm; i += 1)
        for(int j = 0; j <= 2 * maxm; j += 1){
            if(i) add(DP[i][j], DP[i - 1][j]);
            if(j) add(DP[i][j], DP[i][j - 1]);
            if(i) add(C[i][j], C[i - 1][j]);
            if(j) add(C[i][j], C[i][j - 1]);
        }
    for(int i = 0; i < N; i += 1){
        add(ans, DP[maxm + A[i]][maxm + B[i]]);
        add(ans, mod - C[A[i] * 2][B[i] * 2]);
    }
    cout << (ans & 1 ? (ans + mod) / 2 : ans / 2);
    return 0; 
}

Measured memory_bytes: 126848
import java.util.Scanner;
import static java.util.Arrays.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int[] list = new int[5];
		for(int i = 0; i < 5; i++) list[i] = in.nextInt();
		sort(list);
		String s = "";
		StringBuilder buf = new StringBuilder();
		for(int i = list.length-1; i >= 0 ; i--) {
			buf.append(s);
			buf.append(list[i]);
			s = " ";
		}
		System.out.println(buf.toString());
	}
}

Measured memory_bytes: 12000
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;

#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

typedef long long ll;

int H, W;
bool visited[111][111];
vector<string> vs;

int dfs(int y, int x, char c){
    int ret = 0;
    if(y < 0 || y >= H || x < 0 || x >= W) return ret;
    if(visited[y][x]) return ret;
    if(c!=vs[y][x]) return ret;
    char now = vs[y][x];
    ret++;
    visited[y][x] = true;
    ret += dfs(y+1, x, now);
    ret += dfs(y-1, x, now);
    ret += dfs(y, x+1, now);
    ret += dfs(y, x-1, now);
    return ret;
}

int main(){
    while(1){
        cin >> H >> W;
        if(H==0&&W==0) break;
        vs.resize(H);
        FOR(i,0,H)FOR(j,0,W)visited[i][j] = false;
        FOR(y,0,H){
            string s;
            cin >> s;
            vs[y] = s;
        }
        int ans = 0;
        FOR(y,0,H){
            FOR(x,0,W){
                if(dfs(y,x,vs[y][x])) ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3924
N = int(input())
K = int(input())
x = [(int(xi), i + 1) for i, xi in enumerate(input().split())]
A = [(0, i) for i in range(1, N+1)]
B = [(K, i) for i in range(1, N+1)]
print(sum([2*min(abs(x[i][0]-A[i][0]), abs(x[i][0]-B[i][0])) for i in range(N)]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<double,double> P;
const ll INF = 1e16;
const int MOD = 1000000007;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 



///////////////////////___modpow___////////////////////

////////////////////////////////////////////////////////////////////


signed main(){
  string s;int q;cin>>s>>q;string t;
  bool m = true;
  rep(i,q){
    int x;cin>>x;
    if(x == 1){
      m = !m;continue;
    }
    int f;char c;cin>>f>>c;
    if((f == 1 && m) || (f == 2 && !m)){
      t += c;
    }else{
      s += c;
    }
  }
  if(m){
    reverse(t.begin(), t.end());

    cout << t << s << endl;
  }
  else{
    reverse(s.begin(), s.end());
    cout << s << t << endl;
  }
}




Measured memory_bytes: 960
<?php

$inputs = [];

for ($i = 0; $i < 5; $i++) {
    fscanf(STDIN, "%d", $inputs[$i]);
}

$sum = 0;
$diffs = [];
foreach ($inputs as $item) {
    $upten = (int)ceil($item / 10) * 10;
    $diff = $upten - $item;
    if ($diff > 0) {
        $diffs[] = $diff;
    }
    $sum += $upten;
}

if (count($diffs) > 0) {
    $sum -= max($diffs);
}

echo $sum;

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

const int N = 16;
const int inf = 1e9;

int n, m;
int e[N][1 << N];
int c[N][N];
int dp[N][1 << N];

void minimize(int &x, int y) { x = (x > y) ? y : x; }

void prep() {
	for (int mask = 0; mask < (1 << n); ++mask) {
		for (int i = 0; i < n; ++i) if (!(mask >> i & 1)) {
			for (int j = 0; j < n; ++j) if (mask >> j & 1) e[i][mask] += c[i][j];
		}
	}
}

void brute(int pos, int cmask, int cost, int &u, int &mask) { 
// dp[u][mask] is the current state
// cmask is the next mask
	if (pos == n) {
		minimize(dp[u][cmask], dp[u][mask] + cost);
		return;
	}
	
	if (mask >> pos & 1) {
		return brute(pos + 1, cmask | (1 << pos), cost, u, mask);
	}

	brute(pos + 1, cmask, cost, u, mask);
	brute(pos + 1, cmask | (1 << pos), cost + e[pos][mask ^ (1 << u)], u, mask);
}

int main() {
	scanf("%d %d", &n, &m);
	while(m--) {
		int u, v, w; scanf("%d %d %d", &u, &v, &w);
		--u; --v;
		c[u][v] = c[v][u] = w;
	}

	prep();

	for (int mask = 0; mask < (1 << n); ++mask) {
		for (int i = 0; i < n; ++i) dp[i][mask] = inf;
	}

	dp[0][1] = 0;

	for (int mask = 0; mask < (1 << n); ++mask) {
		for (int u = 0; u < n; ++u) if (dp[u][mask] != inf) {
			
			for (int v = 0; v < n; ++v) if (!(mask >> v & 1)) {
				if (c[u][v] == 0) continue;
				minimize(dp[v][mask ^ (1 << v)], dp[u][mask] + e[v][mask ^ (1 << u)]);
			}

			brute(0, 0, 0, u, mask);
		}
	}

	printf("%d\n", dp[n - 1][(1 << n) - 1]);
}

Measured memory_bytes: 7424
// 行列計算　掛け算

#include <stdio.h>
#define N 101

int main(void){
  int n, m, l;
  int i, j, k;
  int a[N][N], b[N][N];
  long long c[N][N] = {0};

  scanf("%d %d %d", &n, &m, &l);

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

  for(i=0; i<m; i++){
    for(j=0; j<l; j++){
      scanf("%d", &b[i][j]);
    }
  }

  for(i=0; i<n; i++){
    for(j=0; j<l; j++){
      for(k=0; k<m; k++){
        c[i][j] += a[i][k] * b[k][j];
      }
    }
  }

  for(i=0; i<n; i++){
    printf("%lld", c[i][0]);
    for(j=1; j<l; j++){
      printf(" %lld", c[i][j]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2064
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int overnum = 0;
	int n,l;
	int a[100000];
	cin >> n >> l;
	for(int i = 0;i < n;i++) cin >> a[i];
	for(int i = 0;i < n - 1;i++) if(a[i] + a[i + 1] >= l) overnum++;
	if(overnum == 0){
		cout << "Impossible" << endl;
		return 0;
	}
	cout << "Possible" << endl;
	for(int i = 1;i < n;i++){
		if(a[i - 1] + a[i] < l) cout << i << endl;
		else if(overnum > 1){
			cout << i << endl;
			overnum--;
		}else break;
	}
	for(int i = n - 1;i >= 1;i--){
		if(a[i - 1] + a[i] < l) cout << i << endl;
		else {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include <cstdio>

int main(){
	int Num=0;
	long int Time=0;
	long int Res=0;
	long int Before=0;
	scanf(" %d %ld",&Num,&Time);
	for(int i=0;i<Num;i++){
		long int Input=0;
		scanf(" %ld",&Input);
		if(i==0){
			Before=Input;
			continue;
		}
		long int Sub=Input-Before;
		if(Sub<Time){
			Res+=Sub;
		}else{
			Res+=Time;
		}
		Before=Input;
	}
	Res+=Time;
	printf("%d\n",Res);
	return 0;
}

Measured memory_bytes: 128
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, a, b) = (v[0], v[1], v[2]);

    let mut ans = 0;
    for i in 1..n + 1 {
        let mut digit_sum = 0;
        {
            let mut i = i;
            while i != 0 {
                digit_sum += i % 10;
                i /= 10;
            }
        }
        if digit_sum >= a && digit_sum <= b {
            ans += i;
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
N,K=map(int,input().split())
A=list(map(int,input().split()))

num=[-1]*N
rep=[]

now=0
for i in range(N):
    if i==K:
        print(now+1)
        exit()
    aft=A[now]-1
    rep.append(now)
    if num[now]==-1:
        num[now]=i
    else:
        break
    now=aft

end=i
start=num[aft]
loop=end-start+1
print(rep[start+(K-start)%loop]+1)

Measured memory_bytes: 32380
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(void){
    int n;
    ll ans = 0,tmp,ans2 = 0;
    cin >> n;
    vector<int> a(n),b(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
        b[i] = (a[i] - (i+1));
    }
    sort(b.begin(),b.end());
    if(n % 2 == 1){
        tmp = b[n/2];
        for(int i = 0;i < n;i++)ans += abs(b[i]-tmp);
        cout << ans << endl;
    }else{
        tmp = b[n/2];
        for(int i = 0;i < n;i++)ans += abs(b[i]-tmp);
        tmp = b[n/2-1];
        for(int i = 0;i < n;i++)ans2 += abs(b[i]-tmp);
        ans = min(ans,ans2);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
N,Y = list(map(int, input().split()))
total = 0
find = False
for x in range(N+1) :
    a = 10000 * x
    for y in range(N + 1 - x) :
        b = 5000 * y
        z = N - x - y
        c = 1000 * z
        total = a + b + c
        if total == Y :
            print(x, y, z)
            find = True
            break
    if find :
        break
if not find :
    print(-1,-1,-1)

Measured memory_bytes: 3064
#include <iostream>
#include <set>
#define int long long
using namespace std;
set<int>s;
int a[234567], n, m, p;
signed main() {
	cin >> n; for (int i = 0; i < n; i++)cin >> a[i];
	cin >> m; for (int i = 0; i < m; i++) { cin >> p; s.insert(p); }
	for (int i = 0; i < n; i++)if (s.count(a[i]) == 0)cout << a[i] << endl;
}


Measured memory_bytes: 14032
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;

int main()
{
	ll n; cin >> n;
	vector<ll>a(n);
	vector<ll>rui(n);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
		if (i)rui[i] = rui[i - 1] + a[i];
		else rui[i] = a[i];
	}
	vector<ll>tmp = rui;

	ll pm;
	ll b;
	if (rui[0] == 0) {
		rui = tmp;
		pm = 1;
		b = 1;
		ll cnt1 = 1;
		for (ll i = 1; i < n; i++) {
			if (rui[i] + b > 0 && rui[i - 1] + b > 0) {
				cnt1 += rui[i] + b + 1;
				b -= rui[i] + b + 1;
				pm = -1;
			}
			else if (rui[i] + b < 0 && rui[i - 1] + b < 0) {
				cnt1 -= rui[i] + b - 1;
				b -= rui[i] + b - 1;
				pm = 1;
			}
			else if (rui[i] + b == 0) {
				if (pm == 1) {
					b--;
					cnt1++;
					pm = -1;
				}
				else if (pm == -1) {
					b++;
					cnt1++;
					pm = 1;
				}
			}
			else if (rui[i] + b > 0)pm = 1;
			else if (rui[i] + b < 0)pm = -1;
		}

		rui = tmp;
		pm = -1;
		b = -1;
		ll cnt2 = 1;
		for (ll i = 1; i < n; i++) {
			if (rui[i] + b > 0 && rui[i - 1] + b > 0) {
				cnt2 += rui[i] + b + 1;
				b -= rui[i] + b + 1;
				pm = -1;
			}
			else if (rui[i] + b < 0 && rui[i - 1] + b < 0) {
				cnt2 -= rui[i] + b - 1;
				b -= rui[i] + b - 1;
				pm = 1;
			}
			else if (rui[i] + b == 0) {
				if (pm == 1) {
					b--;
					cnt2++;
					pm = -1;
				}
				else if (pm == -1) {
					b++;
					cnt2++;
					pm = 1;
				}
			}
			else if (rui[i] + b > 0)pm = 1;
			else if (rui[i] + b < 0)pm = -1;
		}
		cout << min(cnt1, cnt2) << endl;
	}
	else {
		rui = tmp;
		if (rui[0] > 0)pm = 1;
		else pm = -1;
		b = 0;
		ll cnt1 = 0;
		for (ll i = 1; i < n; i++) {
			if (rui[i] + b > 0 && rui[i - 1] + b > 0) {
				cnt1 += rui[i] + b + 1;
				b -= rui[i] + b + 1;
				pm = -1;
			}
			else if (rui[i] + b < 0 && rui[i - 1] + b < 0) {
				cnt1 -= rui[i] + b - 1;
				b -= rui[i] + b - 1;
				pm = 1;
			}
			else if (rui[i] + b == 0) {
				if (pm == 1) {
					b--;
					cnt1++;
					pm = -1;
				}
				else if (pm == -1) {
					b++;
					cnt1++;
					pm = 1;
				}
			}
			else if (rui[i] + b > 0)pm = 1;
			else if (rui[i] + b < 0)pm = -1;
		}

		ll cnt2;
		rui = tmp;
		if (rui[0] > 0) {
			b = -rui[0] - 1;
			pm = -1;
			cnt2 = rui[0] + 1;
		}
		else {
			b = -rui[0] + 1;
			pm = -1;
			cnt2 = -rui[0] + 1;
		}
		for (ll i = 1; i < n; i++) {
			if (rui[i] + b > 0 && rui[i - 1] + b > 0) {
				cnt2 += rui[i] + b + 1;
				b -= rui[i] + b + 1;
				pm = -1;
			}
			else if (rui[i] + b < 0 && rui[i - 1] + b < 0) {
				cnt2 -= rui[i] + b - 1;
				b -= rui[i] + b - 1;
				pm = 1;
			}
			else if (rui[i] + b == 0) {
				if (pm == 1) {
					b--;
					cnt2++;
					pm = -1;
				}
				else if (pm == -1) {
					b++;
					cnt2++;
					pm = 1;
				}
			}
			else if (rui[i] + b > 0)pm = 1;
			else if (rui[i] + b < 0)pm = -1;
		}
		cout << min(cnt1, cnt2) << endl;
	}

	return 0;
}



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

#define ll long long 

int main() {
    ios::sync_with_stdio(0); 

    int a, b; 
    cin >> a >> b; 

    for (int i = 0; i < max(a, b); i++) 
        cout << min(a, b); 

    cout << "\n"; 

    return 0; 
}



Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<vector>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<deque>
#include<ctype.h>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<algorithm>
#define INF 0x3f3f3f3f
#define gcd(a,b) __gcd(a,b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define FAST_IO ios::sync_with_stdio(false)
const double PI = acos(-1.0);
const double eps = 1e-6;
const int MAX=1e5+10;
const int mod=1e9+7;
typedef long long ll;
using namespace std;

inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll qpow(ll a,ll b){ll r=1,t=a; while(b){if(b&1)r=(r*t)%mod;b>>=1;t=(t*t)%mod;}return r;}
inline ll inv1(ll b){return qpow(b,mod-2);}
inline ll exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return a;}ll r=exgcd(b,a%b,y,x);y-=(a/b)*x;return r;}
inline ll read(){ll x=0,f=1;char c=getchar();for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;for(;isdigit(c);c=getchar()) x=x*10+c-'0';return x*f;}
ll sum=0,n,a[MAX],x;
ll b[MAX];
int main()
{
    ll i,j;
    scanf("%lld",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        sum=sum+a[i];
    }

    if(sum%(n*(n+1)/2))
    {
        printf("NO\n");
        return 0;
    }
    x=sum/(n*(n+1)/2);

    b[1]=a[1]-a[n]-x;
    for(i=2;i<=n;i++)
        b[i]=a[i]-a[i-1]-x;
    for(i=1;i<=n;i++)
    {
        if(b[i]-x>0 || (-b[i])%n>0)
        {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    ll left = 0, right = 0;
    rep(i, N) {
        cin >> vec[i];
        right += vec[i];
    }
    ll mini = 1e18;
    rep(i, N) {
        mini = min(mini, abs(left - right));
        left += vec[i];
        right -= vec[i];
    }
    cout << mini << endl;
    return 0;
}

Measured memory_bytes: 3988
using System;
using System.Collections.Generic;
class Program
    {
    	static void Main(string[] args)
    	{
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            //int[] pos = new int[3 * n];
            int r = 0, g = 0, rg = 0 ;
            long ans = 1;
            long mod = 998244353;
            for (int i=2; i<=n; i++) 
            {
                ans *= i;
                ans %= mod;
            }

            for (int i=0; i < 3 * n; i++)
            {
                if (s[i] == 'R')
                {
                    if (r < 0)
                    {
                        if (r >= g) ans *= -r;
                        else ans *= (Math.Min(0, g) - r);
                        r++;
                    }
                    else if (g > 0)
                    {
                        ans *= g;
                        g--;
                        rg++;
                    }
                    else r++;
                }
                else if (s[i] == 'G')
                {
                    if (g < 0)
                    {
                        if (g >= r) ans *= -g;
                        else ans *= (Math.Min(0, r) - g);
                        g++;
                    }
                    else if (r > 0)
                    {
                        ans *= r;
                        r--;
                        rg++;
                    }
                    else g++;
                }
                else if (s[i] == 'B')
                {
                    if (rg > 0)
                    {
                        ans *= rg;
                        rg--;
                    }
                    else if (r <= 0 && g <= 0)
                    {
                        r--;
                        g--;
                    }
                    else
                    {
                        ans *= Math.Max(r, g);
                        r--;
                        g--;
                    }
                }
                ans %= mod;
                


            }
            Console.WriteLine(ans);
            
            
        }
    }
    //mcs Main.cs
    //mono Main.exe

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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    int n,a;
    cin >> n >> a;
    if((n%500) > a){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
#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 _GLIBCXX_DEBUG
int main()
{
    int n,m;
    cin>>n>>m;
    vin a(n);
    rep(i,n)cin>>a[i];
    int sum=0;
    rep(i,n)sum+=a[i];
    int b=0;
    rep(i,n){
        if(a[i]>=(double)sum/(4*m))b++;
    }
    if(b>=m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
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;
}

#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef pair<int, int> pii;

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


    const long long INF = 1LL << 60;
    long long dp[100010];
    REP(i,100010) dp[i] = INF;
    dp[0] = 0;

    int N, K;
    cin >> N >> K;

    vi h(N);
    REP(i,N) cin >> h[i];

    REP(i,N){
        for (int k=0; i-k>=0 and k<K; ++k){
            chmin(dp[i+1],dp[i-k]+abs(h[i+1]-h[i-k]));
        }
    }


    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1408
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		if(n==1 && m==0){
			System.out.println(0);
			return;
		}
		StringBuilder ans=new StringBuilder();
		int[] s=new int[n];
		Arrays.fill(s,-1);
		for(int i=0; i<m; i++){
			int tmps=sc.nextInt()-1;
			int tmpc=sc.nextInt();
			if(n!=1 && tmps==0 && tmpc==0){
				System.out.println(-1);
				return;
			}
			if(s[tmps]!=-1 && s[tmps]!=tmpc){
				System.out.println(-1);
				return;
			}
			s[tmps]=tmpc;
		}
		for(int i=0; i<n; i++){
			if(s[i]!=-1){
				ans.append(s[i]);
			}else{
				if(i==0){
					ans.append("1");
				}else{
					ans.append("0");
				}
			}
		}
		System.out.println(ans);
	}
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int n, x; cin >> n >> x;
  vector<int> vs(n);
  rep(i, n) {
    cin >> vs[i];
  }
  if (n == 1) {
    cout << abs(vs[0] - x) << "\n";
    return 0;
  }
  sort(vs.begin(), vs.end());
  int base = __gcd(abs(vs[0] - x), abs(vs[1] - x));
  rep(i, n) {
    base = __gcd(base, abs(vs[i] - x));
  }
  cout << base << "\n";
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>

using namespace std;

int main()
{
	string s;
	cin >> s;
	
	if(s == "ABC") cout << "ARC" << endl;
	if(s == "ARC") cout << "ABC"  << endl;
 

	return 0;

}

Measured memory_bytes: 3596
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Sagor
 */

#include <fstream>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define gap                        ' '
#define EPS                        1e-9
#define P_INF                      2e9+17
#define N_INF                     -2e9-17
#define MOD                        1000000007
#define PI                         2*acos(0.0)
#define All(x)                     x.begin(),x.end()
#define Mem(Name, type)            memset(Name, type, sizeof(Name))

template<typename T>
T GCD(T a, T b) { return a ? GCD(b % a, a) : b; }

template<typename T>
T LCM(T a, T b) { return (a * b) / GCD(a, b); }

template<typename T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) {
    for (auto ob : v) os << ob << " ";
    return os;
}

template<typename T, typename S>
std::ostream &operator<<(std::ostream &os, const std::map<T, S> &v) {
    for (auto ob : v) os << ob.first << " : " << ob.second << std::endl;
    return os;
}

using ld = double;
using ll = long long int;
using ul = unsigned long long int;
using namespace std;

class BSubstring {
public:
    void solve(std::istream &in, std::ostream &out) {
        string s, t;
        in >> s >> t;
        int ans = 2000;
        for (int i = 0; i < (int) s.size(); ++i) {
            int p = 0, cnt = 0;
            bool chk = false;
            for (int j = 0; j < (int) t.size(); ++j) {
                if (i + (int) t.size() > (int) s.size()) {
                    chk = true;
                    break;
                }
                if (s[i + p] != t[j]) cnt++;
                p++;
            }
            if (!chk)
                ans = min(ans, cnt);
        }
        out << ans << endl;
    }
};


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    BSubstring solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3664
n=gets.to_i
group=[]
if n.odd?
  group << [n]
  n-=1
end

(n/2).times{|i|
  group << [i+1,n-i]
}

ans=[]
group.combination(2){|g1,g2|
  g1.each{|v1|
    g2.each{|v2|
      ans << [v1,v2]
    }
  }
}

puts ans.size
ans.each{|pair|
  puts pair*" "
}


Measured memory_bytes: 2300
N, M = map(int, input().split())
A = []
K = []
for i in range(N):
    AK = list(map(int, input().split()))
    K.append(AK[0])
    A.append(AK[1:])

ma = K.index(max(K))

kinds = 0
for j in range(K[ma]):
    f = 0
    for i in range(N):
        if A[ma][j] in A[i]:
            f += 1
    if f == N:
        kinds += 1
print(kinds)



Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <regex>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define forin(i, a) for(auto i: (a))
#define p(...) printf(__VA_ARGS__); cout << endl;
#define in(...) __VA_ARGS__; input__(__VA_ARGS__);
#define input(...) in(__VA_ARGS__)
#define out(...) output__(__VA_ARGS__);
#define output(...) out(__VA_ARGS__)
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](auto const &a, auto const &b){ return c ;}
#define key(t, x, compare) [](const t &a, const t &b){ return a x compare b x ;}
#define unless(a) if(!(a))

using namespace std;

using pii = pair<int, int>;

template <class... T>
void input__(T &...a) {
  for(auto v: {&a...}) {
    cin >> *v;
  }
}

void output__(){
  cout << endl;
}

template <class Head, class... T>
void output__(Head const &v, T const &...a) {
  if(sizeof...(a) == 0) {
    cout << v;
  } else {
    cout << v << " ";
  }
  output__(a...);
}

bool all_ok(int a1, int a2, int a3, int b1, int b2, int b3, int c[3][3]) {
  int a[3] = {a1, a2, a3};
  int b[3] = {b1, b2, b3};

  rep(i, 3) rep(j, 3) {
    if(c[i][j] != a[i] + b[j]) {
      return false;
    }
  }
  return true;
}

int main(){
  int c[3][3];
  rep(i, 3) rep(j, 3) {
    cin >> c[i][j];
  }

  FOR(a1, -200, 201) {
    int b1 = c[0][0] - a1;
    FOR(a2, -200, 201) {
      int b2 = c[0][1] - a1;
      FOR(a3, -200, 201) {
        int b3 = c[0][2] - a1;

        if(all_ok(a1, a2, a3, b1, b2, b3, c)) {
          out("Yes");
          exit(0);
        }
      }
    }
  }
  out("No");
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

const int MAXN = 400;
const ll INF = 1e15;
ll psum[MAXN + 5];
ll dp[MAXN + 5][MAXN + 5]; // len, start

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

  int n;
  cin >> n;
  vi a(n);
  trav(i, a) cin >> i;
  psum[0] = a[0];
  rep(i, 1, n)
    psum[i] = psum[i - 1] + a[i];
  auto sum = [&](int i, int j){return i ? (psum[j] - psum[i - 1]) : psum[j];};

  rep(len, 0, n + 1) rep(i, 0, n)
    dp[len][i] = INF;
  rep(i, 0, n) {
    dp[1][i] = 0;
    if (i + 1 < n)
      dp[2][i] = a[i] + a[i + 1];
  }
  rep(len, 3, n + 1) {
    rep(i, 0, n - len + 1) {
      int j = i + len - 1;
      rep(step, 1, len) {
	int k = i + step;
	assert(k + (len - step) - 1 == j);
	auto possible = dp[step][i] + dp[len - step][k] + sum(i, k - 1) + sum(k, j);
	dp[len][i] = min(dp[len][i], possible);
      }
    }
  }
  cout << dp[n][0] << '\n';
}


Measured memory_bytes: 1536
n,x,y = map(int, input().split())

dis = [0]*n

for i in range(1,n+1):
    for j in range(i+1, n+1):
        kyori = min(j-i, abs(x - i) + 1 + abs(y - j))
        dis[kyori] += 1

for k in range(1, n):
    print(dis[k])


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<int> ans(n);
  for (int i = 0; i < n - 1; i++) {
    int a;
    cin >> a;
    ans[a - 1]++;
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

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

using namespace std;
int ans = 1000;
bool dfs(int L0, int R0, int L1, int R1) {
	if (L1 >= 5 and R1 >= 5) { 
		return true;
	}

	if (R0 <= 4 and L1 <= 4 and !dfs(R0+L1,R1,L0,R0))return true;	
	if (R0 <= 4 and R1 <= 4 and !dfs(L1,R0+R1,L0,R0))return true;	
	if (L0 <= 4 and L1 <= 4 and !dfs(L0+L1,R1,L0,R0))return true;	
	if (L0 <= 4 and R1 <= 4 and !dfs(L1,R1+L0,L0,R0))return true;	
	else return false;
}


int main() {
	int L0,R0; cin >> L0 >> R0;
	int L1,R1; cin >> L1 >> R1;
	bool ans;
	ans = dfs(L0,R0,L1,R1);
	if (ans) {
		cout << "ISONO" << endl;	
	}else{
		cout << "NAKAJIMA" << endl;	
	}
	return 0;
}



Measured memory_bytes: 3104
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)

    if op=="?":
         break
    if op=="+":
        print(a+b)
    if op=="-":
        print(a-b)
    if op=="*":
        print(a*b)
    if op=="/":
        print(a//b)


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

    int max_price = 0;
    int max_index;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] > max_price) {
            max_price = a[i];
            max_index = i;
        };
    }

    int sum = 0;
    for (int i = 0; i < n; i++) {
        if (i == max_index) sum += a[i] / 2;
        else sum += a[i];
    }

    cout << sum << endl;

    return 0;
}

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

int main(){
    string deck;
    int h, m;

    //loop(while cin deck = "-")
    while(cin >> deck){
        if(deck == "-"){break;}
        cin >> m;
        for(int i = 0; i < m; i++){
            cin >> h;
            string temp;
//            cout << deck << endl;
            for(int j = 0; j < h; j++){temp[j] = deck[j];}
            for(int j = 0; j < deck.length() - h; j++){deck[j] = deck[h + j];}
//            cout << deck << endl;
            for(int j = 0; j < h; j++){deck[deck.length() - h + j] = temp[j];}
//            cout << "deck.length():" << deck.length() << endl;
//            cout << deck << endl;
        }        
        cout << deck << endl;
    }
    return 0;
}




Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
int main(){
  //エラトステネスの篩
  int MAX=110000;
  vector<int> is_prime(MAX,1);
  is_prime[0]=0,is_prime[1]=0;
  for(int i=2;i<MAX;i++){
    if(!is_prime[i])continue;
    for(int j=i*2;j<MAX;j+=i)is_prime[j]=0;
  }

  vector<int>a(MAX,0);
  for(int i=0;i<MAX;i++){
    if(i%2==0)continue;
    if(is_prime[i]&&is_prime[(i+1)/2])a[i]=1;
  }
  //累積和
  vector<int>s(MAX+1,0);
  for(int i=0;i<MAX;i++)s[i+1]=s[i]+a[i];

  //クエリ
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int l,r;
    cin>>l>>r;
    r++;
    cout<<s[r]-s[l]<<endl;
  }
}

Measured memory_bytes: 4376