akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int a[10001],n,m,ans=0;
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=n;i>=n-m+1;i--)ans+=a[i];
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,m,x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  REP(i,n){
    cin >> c[i];
    REP(j,m) cin >> a[i][j];
  }
  int ans = 1e9;
  REP(bit, (1<<n)){
    vector<int> sc(m, 0), vc;
    REP(d,n){
      if(bit & (1<<d)) vc.push_back(d);
    }

    int tmp = 0;
    for(auto b: vc){
      tmp += c[b];
      REP(i,m) sc[i] += a[b][i];
    }

    bool flag = true;
    REP(i,m) if(sc[i]<x) flag = false;
    if(flag) ans = min(ans, tmp);

  }
  cout << (ans<1e9 ? ans : -1) << '\n';
  return 0;
}


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (300006)
ll mod=1e9+7;
int main(){
	FAST
	ll n,k;
	bool allneg=1;
	cin>>n>>k;
	ll A[n];
	FOR(i,0,n-1)cin>>A[i];
	FOR(i,0,n-1)allneg&=A[i]<0;
	sort(A,A+n,[](ll x,ll y){return llabs(x) > llabs(y); });
	ll neg = 0, dc = 0;
	FOR(i,0,k-1){
		neg += A[i] < 0;
		if(A[i]==0) dc=1;
	}
	if(!dc && (neg & 1) && !allneg && n != k){
		ll lpos=-1,lneg=-1,fpos=-1,fneg=-1;
		FOR(i,0,k-1){
			if(A[i]<0) lneg=i;
			if(A[i]>0) lpos=i;
		}
		DEC(i,n-1,k){
			if(A[i]<0)fneg=i;
			if(A[i]>0)fpos=i;
		}
		if((lpos!=-1&&fneg!=-1) || (lneg!=-1&&fpos!=-1)){
			ll opt = 0;
			if(lpos == -1 || fneg == -1) opt = 2;
			else if(lneg == -1 || fpos == -1) opt=1;
			else {
				ld sum1 = 0, sum2 = 0;
				FOR(i,0,k-1){
					if(i^lpos) sum1 += log2l(llabs(A[i]));
					if(i^lneg) sum2 += log2l(llabs(A[i]));
				}
				sum1 += log2l(llabs(A[fneg]));
				sum2 += log2l(llabs(A[fpos]));
				if(sum1 > sum2) opt=1;
				else opt=2;
			}
			ll ans=1;
			if(opt==1){
				FOR(i,0,k-1)if(i^lpos)ans*=A[i],ans%=mod,ans+=mod,ans%=mod;
				ans*=A[fneg],ans%=mod,ans+=mod,ans%=mod;
			}else{
				FOR(i,0,k-1)if(i^lneg)ans*=A[i],ans%=mod,ans+=mod,ans%=mod;
				ans*=A[fpos],ans%=mod,ans+=mod,ans%=mod;
			}
			cout<<ans<<'\n';
			return 0;
		}
	}
	
		if(neg & 1){
			sort(A,A+n,[](ll x,ll y){return llabs(x) < llabs(y); });
		}
		ll ans = 1;
		FOR(i,0,k-1){
			ans *= A[i], ans %= mod, ans += mod, ans %= mod;
		}
		cout<<ans<<'\n';
}


Measured memory_bytes: 5216
#include <stdio.h>

int main(void)
{
	int coin[] = {500, 100, 50, 10, 5, 1};
	int n, i, num;
	
	while (scanf("%d", &n), n != 0){
		num = 0;
		n = 1000 - n;
		
		i = 0;
		while (i < 6){
			if (n >= coin[i]){
				n -= coin[i];
				num++;
				continue;
			}
			i++;
		}
	
		printf("%d\n", num);
	}
	
	return (0);
}

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

int main() {
    int n;
    cin >> n;
    int m = 1e9, ans = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (m >= a) ans++;
        m = min(m, a);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
void print(vector<int> now) {
    for (int x : now) cout << x << " ";
    cout << endl;
}
int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];

    int ans = INF;
    rep(bit, (1 << n)) {
        if (__builtin_popcount(bit) != n / 2) continue;
        vector<pair<int, int>> odd, even;
        rep(i, n) {
            if (bit & (1 << i)) {
                odd.emplace_back((i % 2 == 1 ? a[i] : b[i]), i);
            } else {
                even.emplace_back((i % 2 == 0 ? a[i] : b[i]), i);
            }
        }
        sort(all(odd));
        sort(all(even));

        int pos1 = 0, pos2 = 0;
        vector<pair<int, int>> now(n);
        rep(i, n) {
            if (i % 2 == 0) {
                now[i] = even[pos1];
                // cout << even[pos1].first << " " << even[pos1].second << endl;
                pos1++;
            } else {
                now[i] = odd[pos2];
                // cout << odd[pos2].first << " " << odd[pos2].second << endl;
                pos2++;
            }
        }
        bool ok = true;
        rep(i, n - 1) {
            ok &= (now[i + 1].first >= now[i].first);
        }
        if (!ok) {
            continue;
        }
        int cnt = 0;
        rep(i, n) rep(j, i) {
            cnt += now[j].second > now[i].second;
        }
        chmin(ans, cnt);
    }
    cout << (ans == INF ? -1 : ans) << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(0, i, N)
    {
        int a;
        cin >> a;
        A.at(i) = a - i + 1;
    }
    sort(all(A));
    ll ans = 0;
    ll ans1 = 0, ans2 = 0;
    if (N % 2 == 0 || N == 1)
    {
        rep(0, i, N)
        {
            ans += abs(A.at(i) - A.at(N / 2));
        }
    }
    else
    {
        rep(0, i, N)
        {
            ans1 += abs(A.at(i) - A.at(N / 2));
            ans2 += abs(A.at(i) - A.at(N / 2 + 1));
        }
        ans = min(ans1, ans2);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
n = int(input())

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

sum = 0
for i in a:
  sum += b[i-1]
  if i > 0 and i < n and (a[i]-1 == a[i-1]):
    sum += c[a[i-1]-1]
  
print(sum)
  
         

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)


void aryan_p() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	return;
}


int32_t main() {


	int n ;
	cin >> n ;
	map<int, int> m ;
	int sum = 0;
	for (int i = 0 ; i < n ; i++) {
		int a ;
		cin >> a;
		m[a]++;
		sum += a;
	}

	w(q) {
		int b, c;
		cin >> b >> c;

		int x = m[b];
		sum -= (b * m[b]);
		m[c] += x ;
		sum += (c * x);
		m[b] = 0 ;
		cout << sum << "\n";
	}

	return 0;
}

Measured memory_bytes: 9440
#include <cstdio>
#include <iostream>

using namespace std;

struct Dice{
	int q1,q2,q3,q4,q5,q6;
};

int main(){
	Dice d;
	char od;
	
	scanf("%d %d %d %d %d %d", &d.q1, &d.q2, &d.q3, &d.q4, &d.q5, &d.q6);
	
	while( scanf("%c", &od) != EOF ){
		if(od=='N'){
			int tmp=d.q1;
			d.q1=d.q2;
			d.q2=d.q6;
			d.q6=d.q5;
			d.q5=tmp;
		}
		else if(od=='E'){
			int tmp=d.q1;
			d.q1=d.q4;
			d.q4=d.q6;
			d.q6=d.q3;
			d.q3=tmp;
		}
		else if(od=='W'){
			int tmp=d.q1;
			d.q1=d.q3;
			d.q3=d.q6;
			d.q6=d.q4;
			d.q4=tmp;
		}
		else if(od=='S'){
			int tmp=d.q1;
			d.q1=d.q5;
			d.q5=d.q6;
			d.q6=d.q2;
			d.q2=tmp;
		}
	}
	
	printf("%d\n", d.q1);
	
	return 0;
}



Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
template <class T1, class T2> void vadd(vector<T1> &v, T2 x);

#define int long long int

void solve(std::vector<long long> x) {
  rep(i, 5) {
    if (!x[i])
      cout << i + 1 << endl;
  }
}

signed main() {
  std::vector<long long> x(5);
  for (int i = 0; i < 5; i++) {
    scanf("%lld", &x[i]);
  }
  solve(std::move(x));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 3680
using System;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Array.Sort(a);
        Console.WriteLine(a[n-1]-a[0]);
    }
}

Measured memory_bytes: 13396
#include<stdio.h>

int main(){
int a,b,c,n,i,j,ans=0;
scanf("%d%d%d%d",&a,&b,&c,&n);
for(i=0;i<=a;i++){
for(j=0;j<=b;j++){
if((n-i*500-j*100)<0)break;
int l;
for(l=0;l<=c;l++){
if(n==i*500+j*100+50*l)ans++;
}
}
}
printf("%d\n",ans);
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
using namespace std;
#define N 1000000

int main()
{
    int n, a[N];
    long long int ans = 0;
    scanf( "%d", &n );

    for( int i = 1; i <= n; i ++ )
        scanf( "%d", &a[i] );

    if( a[1] != 0 ) {
        printf( "-1\n" ); return 0;
    }

    for( int i = 2; i <= n; i ++ )
    {
        if( a[i] - a[i-1] >= 2 ) {
            printf( "-1\n" ); return 0;
        }

        if( a[i] - a[i-1] == 1 ) 
            ans ++;
        else ans += a[i];
    }

    printf( "%lld\n", ans );

    return 0;
}

Measured memory_bytes: 2944
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n; ll W;
	cin>>n>>W;
	int v[100]; ll w[100];
	for(int i=0; i<n; i++){
		cin>>w[i]>>v[i];
	}
	ll dp[100001];
	fill(dp, dp+100001, 1e9+7);
	dp[0]=0;
	for(int i=0; i<n; i++){
		for(int j=100000; j>=v[i]; j--){
			dp[j]=min(dp[j-v[i]]+w[i], dp[j]);
		}
	}
	ll ans=0;
	for(int i=100000; i>=0; i--){
		if(dp[i]<=W){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

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

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  int N;
  string S;
  cin >> N;
  cin >> S;
  int count = 0;
  for(int i=0;i<N;i++)
  {
    if(S[i]=='A')
    {
      if(S[i+1]=='B')
      {
        if(S[i+2]=='C')
        {
          count++;
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <limits>
#include <set>
#include <map>
 
int main()
{
    int n{}, k{};
    std::cin >> n >> k;
    std::vector<int> nums(n + 1);
    int64_t total{};
    for (int64_t i = k; i <= n + 1; i++) {
        const auto min = i * (i - 1) / 2;
        const auto max = min + (n - i + 1) * i;
        total = (total + max - min + 1) % 1000000007LL; 
    }
    std::cout << total << std::endl;
    return 0;
}

Measured memory_bytes: 3952
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007


int main(){
    string S; cin >> S;
    int N = S.size();
    
    for(int i=0; i<N; i++){
        for(int j=0; j<N-i+1; j++){
            string r = S;
            r.erase(j, i);
            if(r=="keyence"){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007

int main(){
    string s;
    int w;
    cin>>s>>w;
    string ans;
    int i=0;
    while(i<s.size()){
        ans+=s[i];
        i+=w;
    }
    cout<<ans<<endl;
}

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#ifdef LOCAL
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl
#else
#define dmp(x) void(0)
#endif

template <class t, class u>
void chmax(t &a, u b)
{
    if (a < b)
        a = b;
}
template <class t, class u>
void chmin(t &a, u b)
{
    if (b < a)
        a = b;
}

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vc<vc<t>>;

using vi = vc<int>;

int fact(int n)
{
    if (n == 0)
        return 1;
    return fact(n - 1);
}
int main()
{
    int a, b;
    cin >> a >> b;
    if (a >= 9 || b >= 9)
    {
        cout << ":(" << endl;
    }
    else
    {
        cout << "Yay!" << endl;
    }
}

Measured memory_bytes: 256
n,m = list(map(int, input().split()))
mod = 10**9+7

def factorial(n):
    val = 1
    for i in range(2, n + 1):
        val *= i
        val %= mod
    return val

if abs(n-m)>1:
    print(0)
elif abs(n-m)==1:
    num = factorial(min(m,n))
    print(num**2*max(m,n)%mod)
else:
    num = factorial(m)
    print(num**2*2%mod)


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W; cin >> H >> W;
    vector<string> S(H);
    for (int i=0;i<H;++i) cin >> S[i];
    vector<int> cnt(26,0);
    for (int i=0;i<H;++i)
        for (int j=0;j<W;++j)
            ++cnt[S[i][j]-'a'];
    int odd0=((H&1)&&(W&1)),odd1=((H&1?W/2:0)+(W&1?H/2:0));
    for (int i=0;i<26;++i){
        if (cnt[i]&1) --odd0;
        if (cnt[i]%4==2) --odd1;
    }
    cout << (odd0==0&&0<=odd1?"Yes":"No") << '\n';
}

Measured memory_bytes: 256
let n, a, b = Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c
let rec f n = if n = 0 then 0 else n mod 10 + f (n / 10)
let ans = ref 0
let _ =
  for i = 1 to n do let s = f i in if a <= s && s <= b then ans := !ans + i done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 384
#include <stdio.h>

int main()
{
        int n;
        int a,b;
        int a_sum,b_sum;
        while(scanf("%d",&n),n){
                a_sum=b_sum=0;
                for(;n--;){
                        scanf("%d%d",&a,&b);
                        if(a>b)a_sum+=a+b;
                        if(a==b){a_sum+=a;b_sum+=b;}
                        if(a<b)b_sum+=a+b;
                }
        printf("%d %d\n",a_sum,b_sum);
        }
        return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

int main(){
  int n,r[200000],max,i,j,min;

  scanf("%d",&n);
  while(n<2||n>200000)  scanf("%d",&n);

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

  max=r[1]-r[0];
  min=r[0];
  for(j=1;j<n;j++){
      if((r[j]-min)>max) max=r[j]-min;
      if(min>r[j])min=r[j];
  }
  printf("%d\n",max);

  return 0;
}




Measured memory_bytes: 2576
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/arc085_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N, M;
  cin >> N >> M;

  ll ans = (100 * (N - M) + 1900 * M) * pow(2, M);

  cout << ans << endl;
}

Measured memory_bytes: 4000
#include<bits/stdc++.h>
using namespace std;
int S[3],ord[3],res;
char s[3][4010];
bool mat[3][3][4010];
int main(){
	memset(mat,true,sizeof(mat));
	for(int i=0;i<3;i++)scanf("%s",s[i]),S[i]=strlen(s[i]),res+=S[i];
	for(int i=0;i<3;i++)for(int j=0;j<3;j++){
		if(i==j)continue;
		for(int k=0;k<S[i];k++){
			for(int l=0;l<S[j]&&k+l<S[i];l++)if(s[i][k+l]!='?'&&s[j][l]!='?'&&s[i][k+l]!=s[j][l]){mat[i][j][k]=false;break;}
			if(mat[i][j][k])res=min(res,(S[0]+S[1]+S[2])-min(S[j],S[i]-k));
//			printf("%d ",mat[i][j][k]);
		}
//		puts("");
	}
	for(int i=0;i<3;i++)ord[i]=i;
	do{
		for(int j=0;j<S[ord[0]];j++)for(int k=j;k<max(S[ord[0]],j+S[ord[1]]);k++){
			if(!mat[ord[0]][ord[1]][j])continue;
			if(!mat[ord[0]][ord[2]][k])continue;
			if(!mat[ord[1]][ord[2]][k-j])continue;
			res=min(res,max(S[ord[0]],max(j+S[ord[1]],k+S[ord[2]])));
		}
	}while(next_permutation(ord,ord+3));
	printf("%d\n",res);
	return 0;
}


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

using namespace std;


int main(){
    int N,x;
    cin >> N;
    int cost = 0;
    int dp[N];
    vector<int> h;
    for(int i=0; i<N; ++i){
        cin >> x;
        h.push_back(x);
        dp[i] = INT_MAX;
    }
    dp[N-1] = 0;
    for(int i= N-2; i>=0; --i){
        if(i+1 < N){
            dp[i] = min(dp[i], abs(h[i]-h[i+1])+dp[i+1]);
        }
        if(i+2 < N){
            dp[i] = min(dp[i], abs(h[i]-h[i+2])+dp[i+2]);
        }
    }
    cout << dp[0];
    return 0;
}


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

int main() {
    double l;
    cin >> l;
    
    cout << fixed << setprecision(10);

    cout << (l * 3000 / 3) * (l  * 3000 / 3) * (l * 3000/ 3) / 27000000000;

}


Measured memory_bytes: 256
function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input);
	input = input.trim().split("").map((a)=>Number(a));
	//input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  var output = 0;
  if(input.length == 1){
     myout(input[0]);
    return;
  }
  var flag = true;
  
  for(var i = 0; i < input.length - 1; i++){
    var mae = input[i];
    var ato = input[i+1];
    if(!flag){
       output += 9;
       continue;
    }
    if(ato != 9){
       output += mae - 1;
       output += 9;
       flag = false;//以降、全て+9
    }else{
      output += mae;
    }
  }
  if(flag){
     output += 9//全部9だったら最後の分だけ追加
     }
  myout(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int inf=1e9;
int main(void)
{
    int N,prev;
    int A[25],B[25],C[25];
    cin >> N;
    int ans=0;
    for(int i=1;i<=N;i++)
    {
        cin >> A[i];
    }
    for(int i=1;i<=N;i++)
    {
        cin >> B[i];
    }
    for(int i=1;i<=N-1;i++)
    {
        cin >> C[i];
    }
    for(int i=1;i<=N;i++)
    {
        if(i==1) 
        {
            ans+=B[A[i]];
            prev=A[i];
        }
        else
        {
            ans+=B[A[i]];
            if(A[i]==prev+1)
            {
                ans+=C[prev];
            }
            prev=A[i];
        }
        
    }
    cout << ans << endl;
    return 0;
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    a,b=MI()
    if a==1:
        a+=13
    if b==1:
        b+=13
        
    if a>b:
        print("Alice")
    elif b>a:
        print("Bob")
    else:
        print("Draw")

main()


Measured memory_bytes: 38256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int N; cin >> N;
    vector<int> a(N);
    vector<int> ideal(N);
    rep(i,N){
        cin >> a[i];
        ideal[i] = a[i];
    }
    sort(all(ideal));
    bool ans = false;
    bool tmp = true;
    rep(i,N)if(ideal[i] != a[i])tmp = false;
    ans = tmp;
    for(int i = 0; i < N; ++i){
        for(int j = i + 1; j < N; ++j){
            swap(a[i], a[j]);
            tmp = true;
            rep(i,N)if(a[i] != ideal[i])tmp = false;
            swap(a[i], a[j]);
            if(tmp)ans = true;
        }
    }
    cout << (ans ? "YES" : "NO" )  << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, M;
    cin >> N >> M;
    map<ll, vector<ll>> counter;
    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        counter[a].push_back(b);
    }
    ll ans = 0;
    priority_queue<ll> queue;

    rep2(i, 1, M + 1) {
        if (counter.find(i) != counter.end()) {
            auto tmp = counter[i];
            for (auto t: tmp) {
                queue.push(t);
            }
        }
        if (!queue.empty()) {
            ll q = queue.top();
            queue.pop();
            ans += q;
        }
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

const int N = 1e5 + 5;

int n, m;
int uf[N];
int d[N], D[N];
vector<int> G[N];

int find(int x) {
	return uf[x] == x ? x : (uf[x] = find(uf[x]));
}

void dfs(int p, int fa, boolean out) {
	for (auto e : G[p]) {
		if (e ^ fa) {
			dfs(e, p, out);
		}
	}
	if (!fa)
		return;
	if (D[p]) {
		D[p] ^= 1;
		if (out) {
			printf("%d %d\n", p, fa);
		}
	} else {
		D[fa] ^= 1;
		if (out) {
			printf("%d %d\n", fa, p);
		}
	}
}

int main() {
	scanf("%d%d", &n, &m);
	if (m & 1) {
		puts("-1");
		return 0;
	}
	for (int i = 1; i <= n; i++)
		uf[i] = i;
	int cx = -1, cy = -1;
	for (int i = 1, u, v; i <= m; i++) {
		scanf("%d%d", &u, &v);
		if (find(u) ^ find(v)) {
			uf[find(u)] = find(v);
			G[u].push_back(v);
			G[v].push_back(u);
		} else {
			if (cx == -1) {
				cx = u;
				cy = v;
			} else {
				printf("%d %d\n", u, v);
				d[u] ^= 1;
			}
		}
	}
	if (cx != -1) {
		for (int i = 1; i <= n; i++)
			D[i] = d[i];
		D[cx] ^= 1;
	}
	dfs(1, 0, false);
	for (int i = 1; i <= n; i++)
		D[i] = d[i];
	if (D[1]) {
		D[cy] ^= 1;
		printf("%d %d\n", cy, cx);
	} else {
		D[cx] ^= 1;
		if (cx != -1) {
			printf("%d %d\n", cx, cy);
		}
	}
	dfs(1, 0, true);
	return 0;
}


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

#define MOD 1000000007LL

int a[100010] = {0}, b1[100010] = {0}, b2[100010] = {0}, c[100010] = {0}, d[100010] = {0}, e[100010] = {0};

int main(void) {
	int h, i, j, k, l, M, N, Q;
	scanf("%d%d%d", &N, &M, &Q);
	for (i=0;i<Q;i++) scanf("%d", &a[i]);

	j = 0;
	for (i=Q-1;i>=0;i--) {
		if (!c[a[i]]) {
			c[a[i]] = 1;
			b1[j++] = a[i];
		}
	}
	for (i=1;i<=M;i++) {
		if (!c[i]) b1[j++] = i;
	}
	for (i=1;i<=M;i++) {
		d[b1[i]] = i;
	}

	e[0] = N;
	for (i=Q-1;i>=0;i--) {
		h = d[a[i]];
		if (e[h]>0) {
			e[h]--;
			e[h+1]++;
		}
	}

	for (l=0;!e[l];l++);
	memset(c, 0, sizeof(int)*100010);
	k = 0;
	for (i=0;i<l;i++) {
		b2[k++] = b1[i];
		c[b1[i]] = 1;
	}
	for (i=1;i<=M;i++) {
		if (!c[i]) b2[k++] = i;
	}
	if (!memcmp(b1, b2, sizeof(int)*M)) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

int n;
double arr[51];
int main() {
    IOS
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }

    sort(arr, arr+n);
    for (int i = 1; i < n; ++i) {
        arr[i] = (arr[i]+arr[i-1])/2;
    }
    cout.precision(5);
    cout << fixed << arr[n-1] << endl;

    return 0;


}


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

bool FIND(string S, string T){
	if(S.find(T) == string::npos){
		return false;
	} else {
		return true;
	}
}

int main(){
    int Pay, N;
    cin >> Pay >> N;
    vector<string> D(N);
    for(int i = 0; i < N; i++)cin >> D[i];
    while(true){
        bool jdg = true;
        for(int i = 0; i < N; i++){
            if(FIND(to_string(Pay), D[i])){
                jdg = false;
                break;
            }
        }
        if(jdg)break;
        else Pay++;
    }
    cout << Pay << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
using namespace std;

int n;
int k;

typedef pair<int,int> P;

vector<P> edges[100001];

int l[100001];
int r[100001];

queue<int> que;

int INF = 1e9;


bool solve()
{
	while(!que.empty())
	{
		int v = que.front();
		que.pop();

		int nl = l[v] - 1;
		int nr = r[v] + 1;

		for(P& p : edges[v])
		{
			if(l[p.first] !=INF && abs(nl - l[p.first]) % 2 == 1)
			{
				return false;
			}
			if(l[p.first] == INF || l[p.first] < nl || nr < r[p.first])
			{
				//update
				if(l[p.first] == INF)
				{
					l[p.first] = nl;
					r[p.first] = nr;
				}
				l[p.first] = max(l[p.first] , nl);
				r[p.first] = min(r[p.first] , nr);

				if(!(l[p.first] <= r[p.first]))
					return false;

				que.push(p.first);
			}
		}
	}	
	return true;

}
int main()
{
	fill(l,l + 100001,INF);
	fill(r,r + 100001,INF);
	cin >> n;

	for(int i = 0;i < n - 1;i++)
	{
		int a,b;
		cin >> a >> b;

		edges[a].push_back(P{b,0});
		edges[b].push_back(P{a,0});
	}

	cin >> k;


	for(int i = 0;i < k;i++)
	{
		int v,p;
		cin >> v >> p;
		que.push(v);
		l[v] = p;
		r[v] = p;
	}
	
	if(!solve())
	{
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;

	for(int i = 1;i <= n;i++)
	{
		//cerr << i << "-" << l[i] << ":" << r[i] << endl;
		cout << l[i] << endl;
	}

	return 0;
}



Measured memory_bytes: 8192
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    s=input()
    t=input()
    if s==t[:-1]:
        print("Yes")
    else:
        print("No")

main()


Measured memory_bytes: 61948
a,b,c = map(int,input().split())
d1 = abs(a-b)
d2 = abs(b-c)
d3 = abs(c-a)
if a%2 == 1 or b%2 == 1 or c%2 ==1:
    print(0)
elif d1 == d2 == 0:
    print(-1)
else:
    cnt1 = 0
    cnt2 = 0
    cnt3 = 0
    while d1 % 2 == 0:
        d1 //= 2
        cnt1 +=1 
    while d2 % 2 == 0:
        d2 //= 2
        cnt2 +=1
    while d3 % 2 == 0:
        d3 //= 2
        cnt3 +=1
    print(min(cnt1,cnt2)) 

Measured memory_bytes: 3064
import itertools

h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]

ans = 0
for hh in itertools.product("01", repeat = h):
    h_lst = []
    for i, s in enumerate(hh):
        if s == "1":
            h_lst.append(i)
    for ww in itertools.product("01", repeat = w):
        w_lst = []
        for i, s in enumerate(ww):
            if s == "1":
                w_lst.append(i)
        tmp = 0            
        for i in h_lst:
            for j in w_lst:
                if c[i][j] == "#":
                    tmp += 1
        if tmp == k:
            ans += 1
print(ans)

        

Measured memory_bytes: 9208
//
// Created by syu on 18/05/12.
//
#include <iostream>
using namespace std;

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if((abs(b-a)<=d&&abs(c-b)<=d)||abs(c-a)<=d){
        cout << "Yes" <<endl;
    } else{
        cout << "No" <<endl;
    }
    return 0;
}

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

long long n, m;
bool visit[50];
vector<vector<long long> > G(50);

void visit_init(){
    for(long long i = 0; i < 50; i++){
        visit[i] = false;
    }
}

bool visit_true(){
    bool flag = true;
    for(long long i = 0; i < n; i++){
        if(visit[i] == false){
            flag = false;
            break;
        }
    }
    if(flag == true){
        return true;
    }
    else{
        return false;
    }
}


void dfs(long long x, long long break_a, long long break_b){
    if(visit[x] == true){
        return;
    }

    visit[x] = true;

    for(long long v = 0; v < G[x].size(); v++){
        if((x == break_a and G[x][v] == break_b) || (x == break_b and G[x][v] == break_a)){
            continue;
        }
        dfs(G[x][v], break_a, break_b);
    }
}

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

    vector<pair<long long, long long> >v;

    for(long long i = 0; i < m; i++){
        long long a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
        v.push_back(make_pair(a, b));
    }

    long long count = 0;
    for(long long i = 0; i < v.size(); i++){
        visit_init();
        dfs(0, v[i].first, v[i].second);
        if(visit_true() == false){
            count++;
        }
    }

    cout << count << endl;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

int cnt_div2(int a) {
  int cnt = 0;
  while (a%2 == 0) {
    a /= 2;
    cnt++;
  }
  return cnt;
}

int main () {
  int N; cin >> N;
  vi a(N); REP(i,N) scanf("%d",&a[i]);

  int cnt_1 = 0;
  int cnt_2 = 0;
  int cnt_4 = 0;
  REP(i,N) {
    if (cnt_div2(a[i]) == 0) {
      cnt_1++;
    }
    else if (cnt_div2(a[i]) == 1) {
      cnt_2++;
    }
    else if (cnt_div2(a[i]) >= 2) {
      cnt_4++;
    }
  }

  if (cnt_2 == 0) {
    cout << (cnt_1 <= cnt_4+1 ? "Yes" : "No") << endl;
  }
  else {
    cout << (cnt_1 <= cnt_4 ? "Yes" : "No") << endl;
  }
}

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

int w, h;
int map[52][52];

int check(int i, int j)
{
	if (map[i][j] == 0)return 0;
	else
	{
		map[i][j] = 0;
		check(i-1, j - 1);
		check(i-1, j);
		check(i-1, j + 1);
		check(i, j - 1);
		check(i, j + 1);
		check(i + 1, j - 1);
		check(i + 1, j);
		check(i + 1, j + 1);
		return 0;
	}
}

int main()
{
	while (true)
	{
		map[52][52] = { 0 };
		int count = 0;
		cin >> w >> h;
		if (w == 0)return 0;

		for (int i = 1; i < h+1; i++)
		{
			for (int j = 1; j < w+1; j++)
			{
				cin >> map[i][j];
			}
		}
		for (int i = 1; i < h+1; i++)
		{
			for (int j = 1; j < w+1; j++)
			{
				if (map[i][j] == 1)
				{
					check(i, j);
					count++;
				}
			}
		}
		cout << count << endl;
	}
}

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

using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    s += '0';
    int n = s.size();
    vector<array<int, 2>> dp(n+1);
    dp[0][0] = 0, dp[0][1] = 1e9;
    for (int i = 0; i < n; ++i) {
        int u = s[i]-'0';
        dp[i+1][0] = min(dp[i][0]+u, dp[i][1]+u+1);
        dp[i+1][1] = min(dp[i][0]+10-u, dp[i][1]+9-u);
    }
    cout << dp[n][0] << '\n';
    return 0;
}


Measured memory_bytes: 12136
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        while (true) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
            ArrayList<ArrayList<Integer>> graph = new ArrayList<>();
            for (int i = 0; i <= n; i++) {
                graph.add(new ArrayList<>());
            }
            int m = sc.nextInt();
            for (int i = 0; i < m; i++) {
                int a = sc.nextInt();
                int b = sc.nextInt();
                graph.get(a).add(b);
                graph.get(b).add(a);
            }
            HashSet<Integer> all = new HashSet<>();
            all.addAll(graph.get(1));
            for (int x : graph.get(1)) {
                all.addAll(graph.get(x));
            }
            if (all.size() == 0) {
                sb.append(0).append("\n");
            } else {
                sb.append(all.size() - 1).append("\n");
            }
        }
        System.out.print(sb);
    }
}



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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator+(long long x,const mint& m){ return mint(x)+m; }
mint operator-(long long x,const mint& m){ return mint(x)-m; }
mint operator*(long long x,const mint& m){ return mint(x)*m; }
mint operator/(long long x,const mint& m){ return mint(x)/m; }

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n),b(n);
	rep(i,n) scanf("%d",&a[i]);
	rep(i,n) scanf("%d",&b[i]);

	vector<bool> fix_a(n),fix_b(n);
	rep(i,n) if(i==0 || a[i-1]<a[i]) fix_a[i]=true;
	for(int i=n-1;i>=0;i--) if(i==n-1 || b[i]>b[i+1]) fix_b[i]=true;

	mint ans=1;
	rep(i,n){
		if(fix_a[i] && fix_b[i]){
			if(a[i]!=b[i]) ans=0;
		}
		else if(fix_a[i]){
			if(a[i]>b[i]) ans=0;
		}
		else if(fix_b[i]){
			if(b[i]>a[i]) ans=0;
		}
		else{
			ans*=min(a[i],b[i]);
		}
	}
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 1024
s = input()
t = input()
sl = len(s)
st = len(t)
ans = st
for i in range(0, sl-st+1):
    cnt = 0
    for j in range(st):
        if s[i+j] != t[j]:
            cnt += 1
    #print(i, cnt)
    ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 67628
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int n, ans;
char c[364][364];
signed main() {
	cin >> n;
	rep(i, n)rep(j, n)cin >> c[i][j];
	rep(i, n) {
		char d[364][364];
		rep(j, n)rep(k, n)d[j][k] = c[(j - i + n) % n][k];
		rep(j, n)rep(k, n)if (d[j][k] != d[k][j])goto ng;
		ans += n - i;
	ng:;
		if (!i)continue;
		rep(j, n)rep(k, n)d[j][k] = c[j][(k - i + n) % n];
		rep(j, n)rep(k, n)if (d[j][k] != d[k][j])goto ng2;
		ans += n - i;
	ng2:;
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner a = new Scanner(System.in);
		int b = a.nextInt();
		int c = a.nextInt();
		int d = a.nextInt();
		int count = 0;
		for(int i = b;i <= c;i++){
			if((d % i) == 0){
				count++;
			}
		}
		System.out.println(count);
	}
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()


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

    int ma = (N-1)*(N-2)/2;
    if(ma<K){
        cout << -1 << endl;
        return 0;
    } //制約条件からこれはすでに満たされているからほんと入らない

    int cnt = ma-K; //何個のノードの最小距離を変更しなければいけないのか

    cout << (N-1)+cnt << endl; //star + 新しく設置する辺　辺を一つ設置すると1個のノードの最小距離がへる
    for(int i=2;i<=N;i++){
        cout << 1 << " " << i << endl;
    }
    //starを構築

    for(int i=2;i<=N;i++){
        for(int j=i+1;j<=N;j++){
            if(cnt==0)return 0;
            cout << i << " " << j << endl;
            cnt--;
        }
    }


    return 0;

}



Measured memory_bytes: 256
#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 FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
typedef pair<int, int> P;
// 二つのunion-find
int par[200005][2];
int rnk[200005][2];
// n要素で初期化
void Init(int n){
  //par.resize(n);rnk.resize(n);
  FOR(i,0,n) FOR(j,0,2){par[i][j]=i;rnk[i][j]=0;}
}
//木の根を求める
int Find(int i, int x){
  if(par[x][i] == x) return x;
  else return par[x][i] = Find(i, par[x][i]);
}
//xとyの属する集合を併合
void Merge(int i, int x, int y){
  x = Find(i,x);y = Find(i,y);
  if(x == y) return;
  if(rnk[x][i] < rnk[y][i]) par[x][i] = y;
  else{par[y][i] = x;if(rnk[x][i] == rnk[y][i]) rnk[x][i]++;}
  return;
}

int main()
{
  int N, K, L;
  cin >> N >> K >> L;
  Init(N+1);
  // 道路のグループ
  FOR(i,0,K) {
    int a, b;
    cin >> a >> b;
    Merge(0, a, b);
  }
  // 鉄道のグループ
  FOR(i,0,L) {
    int a, b;
    cin >> a >> b;
    Merge(1, a, b);
  }
  // 属するグループの親のpairが同じなら両方繋がっている
  map<P, int> MAP;
  FOR(i,1,N+1) MAP[P(Find(0,i),Find(1,i))]++;
  FOR(i,1,N+1) {
    printf("%d%c", MAP[P(Find(0,i),Find(1,i))], i == N ? '\n' : ' ');
  }
  return 0;
}

Measured memory_bytes: 15104
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	public static void main(String[] args) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			String str = reader.readLine();
			double S = Double.parseDouble(str);
			int h = (int)Math.floor(S / 3600);
			int m = (int)Math.floor((S % 3600) / 60);
			int s = (int)Math.floor((S % 3600) % 60);
			System.out.println(h + ":" + m + ":" + s);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}

Measured memory_bytes: 24524
#include<stdio.h>
int main(void)
    {
    int N,K,X,Y;
    scanf("%d%d",&N,&K);
    X=1;
    for(int i=0;i<N-1;i++)
    {
    X=X*(K-1);
    }
    Y=K*X;
    printf("%d\n",Y);
    return 0;
    }  

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

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

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<Edge>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}



bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int dfs(int x,int y,int H,int W,vector<vector<char>> &masu){
  if(masu[x][y] == '#'){

  }
}
bool palin(string S){
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}
int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N){
    cin >> A[i];
  }
  map<ll,ll> ma;//ma[a]はAの中のaの個数
  rep(i,N){
    ma[A[i]]++;
  }
 /* for(auto p :ma){
    auto k = p.first;
    auto v = p.second;
    cout << k << " " << v << endl;
  }*/
  ll ans = 0;
  for(auto p :ma){
    auto k = p.first;
    auto v = p.second;
    if(v >= 2) ans += v*(v-1)/2;
  }
  ll cop = ans;
  rep(i,N){
    ll c = ma[A[i]];
    if(c >= 2){
      ans -= c*(c-1)/2;
      c--;
      ans += c*(c-1)/2;
    }
    cout << ans << endl;
    ans = cop;
  }
}

Measured memory_bytes: 11008
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ll long long
#define MOD 1000000007
#define MAX 100010
#define aout(a) REP(i,sizeof(a)) cout << a[i] << " "; cout << endl;
#define vout(v) REP(i,v,size()) cout << v[i] << " "; cout << endl;
using namespace std;
using Graph = vector<vector<int>>;
#define PI 3.1415926535897932384
int N;
ll ans = 0;
bool flag = false;

int main(){
  cin >> N;
  int MA = 1000001;
  int A[201010];
  int cnt[1010101];
  bool ok[1010101];
  FOR(i, 0, N) cin >> A[i];

  FOR(i, 0, N) cnt[A[i]]++;
  FOR(x, 1, MA) ok[x] = true;
  FOR(x, 1, MA) if(0 < cnt[x]) {
    if (1 < cnt[x]) ok[x] = false;
    for (int x2 = x * 2; x2 < MA; x2 += x) ok[x2] = false;
  }

  int ans = 0;
  FOR(i, 0, N) if (ok[A[i]]) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 9244
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int,n);
	double ans = 0.0;
	REP(i,n) {
		VAR(double, x);VAR(string, u);
		if(u=="BTC") x *= 380000.0;
		ans += x;
	}
	FOUT(6,ans)BR;
  
  return 0;
}


Measured memory_bytes: 892