akhauriyash/Code-Regression huggingface dataset:
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;
vector<int> a;
int dp[440][440];

int rec(int l, int r) {
    if(dp[l][r] != INF) return dp[l][r];
    if(l >= r) {
        return dp[l][r] = 0;
    }
    if(r == l + 1) {
        return dp[l][r] = 0;
    }
    int res = 0, tmp = INF;
    for(int i = l + 1; i < r; ++i) {
        chmin(tmp, rec(l, i) + rec(i, r));
        res += a[i];
    }
    return dp[l][r] = res + a[l] + tmp;
}

void solve() {
	cin >> n;
    a.resize(n);
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, 440) {
        rep(j, 440) {
            dp[i][j] = INF;
        }
    }
    cout << rec(0, n) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 1792
/*  Success may not come to me immediately,
 *  but it will come definitely....
 */
#include <bits/stdc++.h>
//=====================================================================
using namespace std;
//=====================================================================
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//=====================================================================
#define li      int64_t
#define ld      double_t
#define ulli    uint64_t
//=====================================================================
#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define repi(i,v)   for(i=v.begin();i!=v.end();i++)
#define repir(i,v)  for(i=v.rbegin();i!=v.rend();i++)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))
#define nl          cout<<'\n'
//=====================================================================
typedef vector<li>       vli;
typedef vector<string>   vstr;
typedef pair<li,li>      pli;
typedef pair<li,pli >    ppli;
typedef pair<li,ppli >   pppli;
typedef vector<pli >     vpl;
typedef vector<ppli >    vppli;
typedef vector<pppli >   vpppli;
//=====================================================================
#define pb  push_back
#define pob pop_back
#define pf  push_front
#define pof pop_front
#define all(v)  v.begin(),v.end()
#define itr iterator
#define rtr reverse_iterator
#define sz  size()
#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define mp  make_pair
#define F   first
#define S   second
//=====================================================================
#define mod (li)(1e9+7)
#define inf (li)(1e18)
#define MX1 (li)(1e5+5)
#define MX2 (li)(1e6+5)
#define pi  acos(-1)
//=====================================================================
li power(li a,li b){li ans=1;while(b){if(b&1){ans=(ans*a)%mod;}
a=(a*a)%mod;b>>=1;}return ans;}
//=====================================================================
li mmi(li n){return power(n,mod-2);}
//=====================================================================
li two(li n){return (1LL<<n);}
//=====================================================================
void onbit(li &n,li x){n|=two(x);}
//=====================================================================
void offbit(li &n,li x){n&=~two(x);}
//=====================================================================
li cntbit(li n){li res=0;while(n and ++res)n-=n&-n;return res;}
//=====================================================================
li dx[]={-1,0,1,0},dy[]={0,-1,0,1};
//=====================================================================
/*------------------------MAIN CODE BEGINS NOW!------------------------*/

void solve(){
  string s;cin>>s;
  li i,flag=1;
  rep(i,0,s.length()){
    if(i==4 and flag){
      cout<<" ";
      i--;
      flag=0;
    }else cout<<s[i];
  }
  nl;
}

int main(){
  opt
  li t=1;
  //cin>>t;
  while(t--){
    solve();
  }
  return 0;
}

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

using namespace std;

#define EPS (1e-7)

double conv(double dosu) {
  return dosu*M_PI/180.0;
}

int main() {
  int M;
  
  while(cin >> M && M) {
    double sum = 0.0;
    double S = 0.0;
    for(int i=0; i<M-1; i++) {
      double arg; cin >> arg;
      S += sin(conv(arg));
      sum += arg;
    }
    S += sin(conv(360-sum));
    
    int N; cin >> N;
    sum = 0;
    double T = 0.0;
    for(int i=0; i<N-1; i++) {
      double arg; cin >> arg;
      T += sin(conv(arg));
      sum += arg;
    }
    T += sin(conv(360-sum));
    
    if(fabs(S-T) < EPS) cout << 0 << endl;
    else if(S > T) cout << 1 << endl;
    else if(S < T) cout << 2 << endl;
  }
  
  return 0;
}

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

int main()
{
    string s;
    cin >> s ;

    string set[5]={"a","i","u","e","o"};

    for(int i = 0 ; i < 5 ; i++ ){
        string t  = set[i];
        if(s==t) {
            cout << "vowel" << endl;
            return 0;
        }
    }
    cout << "consonant" << endl;
}

Measured memory_bytes: 256
#縦がx，横がy

from collections import deque

H, W = map(int, input().split())
S = []
maxlen = 0

for _ in range(H):
    S.append(input())

#i,jはスタートする場所，x,yはi,jスタートで現在どこにいるか．
#i2,j2は四近傍，new_x,new_yは次に移動する場所
for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            queue = deque([[i,j]])
            distance = [[-1]*W for _ in range(H)]
            distance[i][j] = 0
            mazemax = 0
            #print()
            while len(queue): #queueが無くなるまで
                #print(*distance,sep="\n",end="\n")
                x, y = queue.popleft()
                for i2, j2 in ([1, 0], [-1, 0], [0, 1], [0, -1]): #四方向を見る
                    new_x, new_y = x+i2, y+j2
                    if new_x < 0 or new_x >= H or new_y < 0 or new_y >= W: #範囲外を飛ばす
                        continue
                    elif S[new_x][new_y] == "." and distance[new_x][new_y] == -1:
                        distance[new_x][new_y] = max(distance[new_x][new_y], distance[x][y] + 1)
                        mazemax = max(mazemax, distance[new_x][new_y])
                        queue.append([new_x, new_y])
                if len(queue) == 0:
                    maxlen = max(maxlen,mazemax)

print(maxlen)

"""
5 5
...#.
.#.#.
...#.
#.##.
#....
"""

Measured memory_bytes: 3316
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for x in range(m)]
city = [0 for x in range(n)]
for a, b in ab:
    city[a - 1] += 1
    city[b - 1] += 1

for c in city:
    print(c)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define     ll      long long int
#define     yes         cout<<"YES"<<endl
#define     no      cout<<"NO"<<endl
int main()
{
    ll a,b,c,k,sum=0;
    cin>>a>>b>>c>>k;
    if(a>=k) cout<<k<<endl;
    else{
        int mn=min(a,k);
       sum+=mn;
        k-=mn;
        if(b>=k) cout<<sum<<endl;
        else{
            int mn2=min(b,k);
            k-=mn2;
            if(c>=k) cout<<sum+((-1)*k);
            else{
                int mn3=min(c,k);
                cout<<sum+((-1)*mn3)<<endl;
            }
        }

    }
    return 0;
}


Measured memory_bytes: 3608
import math
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])
m = int(arr_data[0][1])

arr_chk = []
for j in range(1 + n, 1 + n + m):
    
    arr_temp = []
    arr_temp.append(int(arr_data[j][0]))
    arr_temp.append(int(arr_data[j][1]))
    arr_chk.append(arr_temp)
    
#学生数ループ処理    
for i in range(1, 1 + n):
    
    x1 = int(arr_data[i][0])
    y1 = int(arr_data[i][1])
    
    l = abs(x1-arr_chk[0][0]) + abs(y1-arr_chk[0][1])
    
    seq=0
    
    #チェックポイント数分ループ
    for j in range(1,len(arr_chk)):
     
        ltemp = abs(x1-arr_chk[j][0]) + abs(y1-arr_chk[j][1])
        
        if l>ltemp:
            
            seq=j
            l=ltemp
            
    print(seq+1)
    
    

Measured memory_bytes: 3064
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
N,M = map(int,input().split())
fac = [1, 1]
inv = [0, 1]
finv = [1, 1]
MOD = 10**9+7
for i in range(2, M+2):
    fac.append(fac[-1] * i % MOD)
    inv.append(MOD - inv[MOD%i] * (MOD//i) % MOD)
    finv.append(finv[-1] * inv[-1] % MOD) 
def comb_mod(n, r, m):  #nCr mod m
    if (n<0 or r<0 or n<r): return 0
    r = min(r, n-r)
    return fac[n] * finv[n-r] * finv[r] % m

def chofuku(n,r): # nHr mod MOD の計算
    return comb_mod(n+r-1,r)
 
def nPr(n,r,m): #nPr mod MOD の計算
    return fac[n]*finv[n-r]%m
ans = 0
for i in range(1,N+1):
    if i % 2 == 1:
        flag = 1
    else:
        flag = -1
    s = flag*comb_mod(N,i,MOD)*nPr(M-i,N-i,MOD)
    ans += s
    if ans > MOD:
        ans %= MOD
ans1 = 1
for i in range(N):
    ans1 *= (M-i)
    ans1 %= MOD
ans2 = (ans1*ans1)%MOD
ans3 = (ans*nPr(M,N,MOD)) %MOD
print((ans2-ans3)%MOD)


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

const int mod=998244353;

int main(){
  int n, k;
  cin >> n >> k;
  vector<pair<int, int>>lr(k);
  for(int i=0; i<k; i++){
    cin >> lr[i].first >> lr[i].second;
  }
  vector<int>dp(2*n+10, 0), dpdiff(2*n+10, 0);
  dp[0]=1;
  dpdiff[1]=mod-1;
  for(int i=0; i<n; i++){
    //cerr << dp[i] << ' ' << dpdiff[i+1] << endl;
    for(int j=0; j<k; j++){
      dpdiff[i+lr[j].first] += dp[i];
      dpdiff[i+lr[j].first] %= mod;
      dpdiff[i+lr[j].second+1] += mod-dp[i];
      dpdiff[i+lr[j].second+1] %= mod;
    }
    dp[i+1] = (dp[i]+dpdiff[i+1])%mod;
  }
  /*for(int i=0; i<2*n; i++)cerr << dp[i] << ' ';
  cerr << endl;
  for(int i=0; i<2*n; i++)cerr << dpdiff[i] << ' ';*/
  cout << dp[n-1];
  return 0;
}
  

Measured memory_bytes: 5960
#include <iostream>

using namespace std;

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

	int **a = new int*[n];
	for (int i = 0; i < n; i++)
	{
		a[i] = new int[m];

		for (int j = 0; j < m; j++)
		{
			cin >> a[i][j];
		}
	}

	int *b = new int[m];
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}

	for (int i = 0; i < n; i++)
	{
		int sum = 0;
		for (int j = 0; j < m; j++)
		{
			sum += a[i][j] * b[j];
		}
		cout << sum << endl;
	}
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
typedef unsigned long long ull;
typedef long long ll;
#define __TRUE "Yes"
#define __FALSE "No"
#define cout(x) cout << (x) << endl
#define MAX 100001
using namespace std;

int main() {
  ll N,x;
  cin >> N >> x;
  vector<ll> a(N);
  for(ll i=0;i<N;i++) {
    cin >> a[i];
  }
  ll ans=0;
  if(a[0]>x) {
    ans += (a[0]-x);
    a[0]=x;
  }
  for(ll i=1;i<N;i++) {
    if( (a[i-1]+a[i])>x ) {
      ans += (a[i]+a[i-1]-x);
      a[i]=x-a[i-1];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
a = 3.times.map{gets.chomp.split.map(&:to_i)}

n = gets.chomp.to_i

# 横

ans = 'No'
n.times do
  b = gets.to_i
  3.times do |i|
    3.times do |j|
      a[i][j] = '○' if a[i][j] == b
      if a[i].count('○') > 2
        ans = 'Yes'
      end
    end
  end
end

# 縦3つ
3.times do |i|
  if a[0][i] == '○' && a[1][i] == '○' && a[2][i] == '○'
    ans = 'Yes'
  end
end

# 斜め(左上から右下)
if a[0][0] == '○' && a[1][1] == '○' && a[2][2] == '○'
  ans = 'Yes'
end


# 斜め版(右上から左下)
if a[0][2] == '○' && a[1][1] == '○' && a[2][0] == '○'
  ans = 'Yes'
end

puts ans

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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int cnt[26];

int main() {
  int n;
  string s;
  cin >> n >> s;

  for (int i = 0; i < s.size(); i++) {
    cnt[s[i]-'a']++;
  }

  ll ans = 1;
  for (int i = 0; i < 26; i++) {
    ans *= cnt[i] + 1;
    ans %= MOD;
  }

  cout << ans - 1 << endl;
  return 0;
}


Measured memory_bytes: 512
// JavaProgram.cpp
// Author : Priydarshi Singh (@dryairship)
// One cat just leads to another. One bug leads to two others.

#include <bits/stdc++.h>
using namespace std;

// I like my types defined.
typedef long long           ll;
typedef pair<int, int>      pii;
typedef pair<ll, ll>        pll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef vector<pii>         vii;
typedef vector<pll>         vll;
typedef set<int>            si;
typedef map<string, int>    msi;
typedef map<int, int>       mii;

// Traditional science is all about finding "hashtag define"s.
#define fr(i, n)            for(int i=0; i<(n); ++i)
#define frC(i, n, c)        for(int i=0; (i<(n)) && (c); ++i)
#define frA(i, a, n)        for(int i=a; i<=(n); ++i)
#define frD(i, a, n)        for(int i=a; i>=(n); --i)
#define fill(a)             memset(a, 0, sizeof(a))
#define fill1(a)            memset(a, -1, sizeof(a))
#define revsort(a, b)       sort(a, b, greater<int>())
#define ff                  first
#define ss                  second
#define pb                  push_back 
#define dout                if(DEBUGGING) cout
#define dbg                 if(DEBUGGING) 
#define endl                "\n"

// When you realize MOD > INF...
int DEBUGGING    =          0;
const int INF    =          1000000000;
const int MOD    =          1000000007;
const ll LINF    =          1e18;
const double PI  =          3.1415926535897932;
const double EPS =          1e-7;

// I'D SPAM. Hehe.
ll gcdEx                    (ll a, ll b, ll *x, ll *y){if(!a){*x=0;*y=1;return b;} 
ll x1,y1,gcd=gcdEx          (b%a,a,&x1,&y1); *x=y1-(b/a)*x1;*y=x1; return gcd;}
ll modI(ll b, ll m)         {ll x,y;gcdEx(b,m,&x,&y);return (x%m+m)%m;}
ll modD(ll a, ll b)         {return (modI(b,MOD)*(a%MOD))%MOD;}
ll modS(ll a, ll b)         {return ((a%MOD)-(b%MOD)+MOD)%MOD;}
ll modP(ll x, ll y)         {ll r=1; x%=MOD; while(y>0){if(y&1){r=(r*x)%MOD;} y=y>>1; x=(x*x)%MOD;} return r;}
ll modA(ll a, ll b)         {return ((a%MOD)+(b%MOD))%MOD;}
ll modM(ll a, ll b)         {return ((a%MOD)*(b%MOD))%MOD;}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

vi adj[100005];
int vis[100005];

void solve(int TEST_CASE){
    int n,m,a,b;
    cin >> n >> m;
    fr(i,m){
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    fill(vis);
    queue<int> q;
    q.push(1);
    int t;
    while(!q.empty()){
        t = q.front();
        q.pop();
        fr(i,adj[t].size()){
            if(!vis[adj[t][i]]){
                vis[adj[t][i]]=t;
                q.push(adj[t][i]);
            }
        }
    }
    int f=0;
    frA(i,2,n){
        if(!vis[i]){
            cout << "No";
            return;
        }
    }
    cout << "Yes" << endl;
    frA(i,2,n){
        cout << vis[i] << endl;
    }
}

int main(int argc, char* argv[]){
    if(argc==2 && argv[1][1]=='v') DEBUGGING = 1;
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin.exceptions(cin.failbit);
    int nTestCases=1;
    //cin >> nTestCases;
    frA(i,1,nTestCases) solve(i);
    return 0;
}

Measured memory_bytes: 10584
#include <stdio.h>

int 
main(){
	
	int N,i;
	scanf("%d",&N);
	int p[50];
	int cnt=0;
	for(i=0;i<N;i++){
		scanf("%d",&p[i]);
		if(i+1 != p[i])cnt++;
	}
	if(cnt<=2){
		printf("YES\n");
	}
	else printf("NO\n");
	

 return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i = a;i < n;i++)
#define INF 1e9
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
	string s;
	cin >> s;
	
	ll cnt = 0,wcnt = 0;
	rep(i,0,s.size()){
		if(s[i] == 'W'){
			cnt += abs(wcnt - i);
			wcnt++;
		}
	}
	
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    char b;
    cin >> b;
    if(b=='A')cout << 'T' << endl;
    if(b=='C') cout << 'G' << endl;
    if(b=='G')cout << 'C' << endl;
    if(b=='T')cout << 'A' << endl;
}

Measured memory_bytes: 256
import sys

S = (input())

l = len(S)//2
if len(S)==2:
    if S[0]==S[1]:
        print(len(S))
        sys.exit()
for i in range(l):
    S = S[0:len(S)-2]
    a = S[0:len(S)//2]
    b = S[len(S)//2:]

    if a==b:
        print(len(S))
        sys.exit()


Measured memory_bytes: 3060
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int R, C, K;
  cin >> R >> C >> K;
  auto f = vect(R, vect(C, 0ll));
  for (int i = 0; i < K; i++) {
    int r, c;
    ll v;
    cin >> r >> c >> v;
    r--;
    c--;
    f[r][c] = v;
  }
  auto dp = vect(R + 1, vect(C + 1, vect(4, -LLINF)));
  dp[0][0][0] = 0ll;
  ll ans = 0ll;
  for (int i = 0; i < R; i++) {
    for (int j = 0; j < C; j++) {
      for (int k = 0; k < 4; k++) {
        if (i + 1 < R) {
          if (k < 3) chmax(dp[i + 1][j][0], dp[i][j][k] + f[i][j]);
          chmax(dp[i + 1][j][0], dp[i][j][k]);
        }
        if (j + 1 < C) {
          if (k < 3) chmax(dp[i][j + 1][k + 1], dp[i][j][k] + f[i][j]);
          chmax(dp[i][j + 1][k], dp[i][j][k]);
        }
      }
    }
  }
  for (int k = 0; k < 4; k++) {
    chmax(ans, dp[R - 1][C - 1][k]);
    if (k < 3) chmax(ans, dp[R - 1][C - 1][k] + f[R - 1][C - 1]);
  }
  cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


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

using namespace std;

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define double long double
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define deb(x) cout << x << endl
#define done(x) {cout << x << endl;return;}
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;


const int N = 2e5+5;

void solve() {

  int n;
  cin>>n;
  string res;
  while(n){
   n--;
   res+=(char)('a'+n%26);
   n/=26;
  }
  reverse(all(res));
  cout<<res;
}


signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(15);
    int t = 1;
   //cin >> t;

    while (t--)
        solve();
#ifdef aa
    cout << endl << endl << endl << endl << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}







int powm(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = (res*a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}

int divide(int a, int b) {
    return (a % mod) * powm(b, mod - 2) % mod;
}

int norm(int a) {
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return a;
}


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


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

const int N = 510;
const ll inf = 1e18;
int n;
ll a[N] , mem[N][N];

ll yes(int i , int j){
	return a[j] - a[i-1];
}

ll dp(int l , int r){
	if(l == r) return 0;
	ll &ret = mem[l][r];
	if( ret != -1) return ret;
	ret = inf;
	for(int i=l ; i<r ; i++)
		ret = min(ret , dp(l , i) + yes(l , i) + dp(i+1 , r) + yes(i+1 , r));
	return ret;
}

int main(){
	memset(mem , -1 , sizeof mem);
	scanf("%d" , &n );
	for(int i=1 ; i<=n ; i++) {
		scanf("%lld" , a+i);
		a[i] += a[i-1];
	}
	printf("%lld" , dp(1 , n));
}


Measured memory_bytes: 2304
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();

		Map<Integer, Integer> map = new HashMap<>();

		for (int i = 0; i < n; i++) {

			int in = sc.nextInt();
			map.put(in, map.getOrDefault(in, 0) + 1);

		}

		int size = map.keySet().size();

		int remKeyNum = size - k;

		LinkedList<Integer> values = new LinkedList<>(map.values());

		Collections.sort(values);

		int ans = 0;

		for (int i = 0; i < remKeyNum; i++) {
			ans += values.poll();
		}

		if (size >= k) {
			System.out.println(ans);
		} else {
			System.out.println(0);
		}

		sc.close();

	}
}

Measured memory_bytes: 99932
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
  int h1,m1,h2,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int a = h2*60+m2-h1*60-m1-k;
  cout << a << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int n, k;
    string s;
    int cnt = 1;

    cin >> n >> k >> s;

    for (int i = 0; i < s.size()-1; i++) {
        if (s[i] != s[i+1]) {
            cnt++;
        }
    }

    while (k && cnt > 1) {
        if (cnt >= 3) {
            cnt -= 2;
            k--;
        }
        else {
            cnt--;
            k--;
        }
    }

    cout << n - cnt << endl;
}



Measured memory_bytes: 512
"""
強連結成分分解
"""

import sys

sys.setrecursionlimit(1000000)

def dfs(v, visited, edges, order):
  visited[v] = True
  for to in edges[v]:
    if not visited[to]:
      dfs(to, visited, edges, order)
  order.append(v)

def search_strongly_connection(v, visited, reverse_edges, parent):
  visited[v] = True
  for to in reverse_edges[v]:
    if not visited[to]:
      parent[to] = v
      search_strongly_connection(to, visited, reverse_edges, parent)

def find(parent, x):
  if parent[x] == x:
    return x
  tmp = find(parent, parent[x])
  parent[x] = tmp
  return tmp

v_num , e_num = map(int, input().split())
edges = [[] for _ in range(v_num)]
reverse_edges = [[] for _ in range(v_num)]
for _ in range(e_num):
  s, t = map(int, input().split())
  edges[s].append(t)
  reverse_edges[t].append(s)


order = []
visited = [False] * v_num
for v in range(v_num):
  if not visited[v]:
    dfs(v, visited, edges, order)
order.reverse()


visited = [False] * v_num
parent = [i for i in range(v_num)]
for v in order:
  if not visited[v]:
    search_strongly_connection(v, visited, reverse_edges, parent)

q_num = int(input())
for _ in range(q_num):
  u, v = map(int, input().split())
  if find(parent, u) == find(parent, v):
    print(1)
  else:
    print(0)


Measured memory_bytes: 19148
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 998244353, N = 1e6+10, in = (1+P)/2;

int n,a[N],f[N],vis[N],p[N],cnt,mu[N];
void init() {
	f[1] = mu[1] = 1;
    for (int i=2; i<N; ++i) {
        if (!vis[i]) p[++cnt]=i,f[i]=1-i,mu[i]=-1;
        for (int j=1,t; j<=cnt&&i*p[j]<N; ++j) {
            vis[t=i*p[j]] = 1;
            if (i%p[j]==0) {f[t]=f[i],mu[t]=0;break;}
			f[t]=f[i]*f[p[j]];
			mu[t]=-mu[i];
        }
    }
}

int main() {
	init();
	scanf("%d",&n);
	int ans = 0;
	REP(i,1,n) {
		int t;
		scanf("%d",&t);
		ans = (ans-t)%P;
		++a[t];
	}
	REP(i,1,N-1) {
		int t = 0;
		for (int j=i,d=1; j<N; ++d,j+=i) t = (t+(ll)d*a[j])%P;
		if (!t) continue;
		ans = (ans+(ll)i*f[i]%P*t%P*t)%P;
	}
	ans = (ll)ans*in%P;
	if (ans<0) ans+=P;
	printf("%d\n",ans);
}








Measured memory_bytes: 19840
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    vector<pair<ll,int>> v[11];

    v[1].push_back(MP(0ll, 0));

    for(int i=1;i<=9;++i)
    {
        for(pair<ll, int> tmp: v[i])
        {
            int last_digit = tmp.first % 10;
            int max_digit = tmp.second;
            for(int j=0;j<=max_digit+1;++j)
            {
                v[i+1].push_back(MP(tmp.first * 10 + j, j == max_digit + 1 ? max_digit + 1 : max_digit));
            }
        }
    }
    int n;
    cin >> n;

    for(pair<ll, int> tmp: v[n])
    {
        ll x = tmp.first;
        char c[n+1] = {};
        for(int i=0;i<n;++i)
        {
            c[i] = x % 10 +'a';
            x /= 10;
        }
        string s(c);
        reverse(s.begin(), s.end());
        cout << s << endl;
    }
}

Measured memory_bytes: 4208
#include <cstdio>
#include <cstring>
int g[101][101];

int main()
{
  memset(g, 0, sizeof(g));
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
  {
    int u, adj_num;
    scanf("%d%d", &u, &adj_num);
    while (adj_num--)
    {
      int v;
      scanf("%d", &v);
      g[u - 1][v - 1] = 1;
    }
  }
  for (int i = 0; i < n; i++)
  {
    printf("%d", g[i][0]);
    for (int j = 1; j < n; j++)
    {
      printf(" %d", g[i][j]);
    }
    printf("\n");
  }
}



Measured memory_bytes: 2796
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n;cin >> n;
    vector<int> a(n+1);
    vector<int> b(n);
    rep(i,n+1) cin >> a[i];
    rep(i,n) cin >> b[i];
    ll ans =0;
    rep(i,n){
        if (a[i] >= b[i]) ans += b[i];
        else {
            b[i] -= a[i];
            ans += a[i];
            if ( a[i+1] >= b[i]){
                a[i+1] -= b[i];
                ans += b[i];
            }
            else {
                ans += a[i+1];
                a[i+1] = 0;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll = long long;
using vll = vector<long long>;
using vvll = vector<vll>;
const double EPS = 1e-9;
const long long MOD=1e9+7;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define SZ(x) ((int)(x).size())
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
  ll n,m; cin>>n>>m;
  dsu g(n);

  rep(i,m){
    ll a,b; cin>>a>>b;
    a--; b--;
    g.merge(a,b);
    
  }
  ll cnt = g.groups().size()-1;
  cout<<cnt<<endl;
}

Measured memory_bytes: 8872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 
const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;
// get<K>(tuple型の変数)


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

    int n; cin >> n;
    vector<int> a(n);

    for(int i=0; i<n; ++i) cin >> a[i];
    int ans = 0;
    int l=0, r=0;
    
    for(l=0; l<n; ++l){
        chmax(r, l);
        while(r+1<n && a[r] >= a[r+1]) ++r;
        chmax(ans, r-l);
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 640
import java.util.*

fun main(args:Array<String>):Unit {
    while (true) {
        val (n, m) = readLine()!!.trim().split(' ').map(String::toInt)
        if (n == 0) return
        val scores = Array(n) {
            val (code, prize) = readLine()!!.trim().split(' ')
            Prize(code, prize.toInt())
        }
        val loto = Array(m){readLine()!!.trim()}
        println(scores.flatMap{score -> loto.map{score.prize(it)}}.sum())
    }
}
class Prize(private val mCode:String, private val mPrize:Int){
    fun prize(number:String):Int {
        return if (mCode.zip(number).filterNot{(a, _) -> a == '*' }.all{(a, b) -> a == b}) mPrize else 0
    }
}


Measured memory_bytes: 102064
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long InF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑


int main() {
	int a, b;
	string h;
	cin >> a >> b >> h;
	h[b - 1] += 32;
	cout << h << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;

int main(void) {
  int a, b, c;
  cin >> a >> b >> c;
  if( a <= c && c <= b ) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int h,w,d,q,x,y,m;
    cin>>h>>w>>d;
    int a,c[h*w],b[h*w];
    memset(b,0,sizeof(b));
    vector<pair<int,int> > v(h*w);
    vector<int> ans;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a;
            v[a-1]=make_pair(i,j);
        }
    }
    bool maki=true;
    for(int i=0;maki;i++){
        for(int j=0;j<d;j++){
            m=i*d+j;
            if(m+d>=h*w){maki=false;break;}
            c[m]=abs(v[m+d].first-v[m].first)+abs(v[m+d].second-v[m].second);
        }
    }
    for(int i=0;i<h*w-d;i++){
        b[i+d]+=b[i]+c[i];
    }
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>x>>y;
        x--;y--;
        ans.pb(b[y]-b[x]);
    }
    for(int i=0;i<q;i++){
        cout << ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

#define mem(dp,a)       memset(dp,a,sizeof dp)
#define ninja           ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb(x)           push_back(x)
#define all(c)          c.begin(), c.end()
#define int             long long
#define ff              first
#define ss              second
#define nl              '\n'


int32_t main()
{
	ninja
	int n,k; cin>>n>>k;
	map<int, int> mp;
	int p=k;
	int x;
	while(p--){
		cin>>x;
		int c;
		while(x--){
			cin>>c;
		mp[c]++;}
	}
	int res=0;
	for(int i=1;i<=n;i++){
		if(mp.find(i)==mp.end()){
			res++;
		}
	}
	cout<<res;
}



Measured memory_bytes: 3656
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.cpp
 * Author: baisganon
 *
 * Created on 2017/06/04, 20:10
 */

#include<iostream>
using namespace std;

int LinearSearch(int x,int s[],int n){
	s[n] = x;
	for(int i=0;;i++){
		if(s[i]==x){
			if(i<n){
				return i;
			}else{
				return -1;
			}
		}
	}
}

int main(){
	int data1;
	cin >> data1;
	int* list1 = new int[data1+1];
	for(int i=0;i<data1;i++){
		cin >> list1[i];
	}

	int data2;
	cin >> data2;
	int* list2 = new int[data2];
	for(int i=0;i<data2;i++){
		cin >> list2[i];
	}

	int count=0;
	for(int i=0;i<data2;i++){
		if(LinearSearch(list2[i],list1,data1)!=-1)
			count++;
	}
	
	cout << count << endl;
	delete[] list1,list2;
	return 0; 
}

Measured memory_bytes: 3096
A,B,C,D = map(int, input().split())

def gcd(a, b):
  while b:
    a, b = b, a % b
  return a

# 範囲内の最も小さい数値
def cnt(inp):
  min_ = inp * (int((A-1) // inp) + 1)
  max_ = inp * (int((B) // inp))
  num = (max_ - min_) // inp + 1
#  return([min_,max_,int(num)])
  return(int(num))

Ccnt = cnt(C)
Dcnt = cnt(D)
lcm = C*D // gcd(C,D)
CDcnt = cnt(lcm)

# print(Ccnt, Dcnt, CDcnt,(B+1-A)-Ccnt[2]-Dcnt[2]+CDcnt[2])
print((B+1-A)-Ccnt-Dcnt+CDcnt)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define mod 1000000007
#define pll pair<long long,long long>
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
//find_by_order() ->  iterator to the k-th largest element (counting from zero)
//order_of_key() ->    the number  items in a set that are strictly smaller than our item aka index in set
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t;
    cin>>s>>t;
    int n=s.size(),m=t.size();
    int z=INT_MAX;
    for(int i=0;i<=n-m;i++){
        int k=0,x=0;
        for(int j=i;j<i+m;j++){
           if((t[k]-'a')!=(s[j]-'a'))x++;
           k++;
        }
        z=min(z,x); 
    }
    cout<<z;
    return 0;
}

Measured memory_bytes: 3580
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    static int nAsInt;
    static int count;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        String N = in.next();
        nAsInt = Integer.valueOf(N);
        for (int i = 3; i < N.length() + 1; i++) {
            dfs(i, 0, 0);
        }
        System.out.println(count);
    }

    private static void dfs(int depth, int currentDepth, int value) {
        if (depth == currentDepth) {
            if (value <= nAsInt && String.valueOf(value).contains("3")
                    && String.valueOf(value).contains("5")
                    && String.valueOf(value).contains("7"))
            {
                count++;
            }
            return;
        }
        int nextValue = value + (int)Math.pow(10, currentDepth) * 7;
        dfs(depth, currentDepth + 1, nextValue);

        nextValue = value + (int)Math.pow(10, currentDepth) * 5;
        dfs(depth, currentDepth + 1, nextValue);

        nextValue = value + (int)Math.pow(10, currentDepth) * 3;
        dfs(depth, currentDepth + 1, nextValue);

    }

}


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

int main(void){
  int a[3],i,j,buff,count;
  char str[100],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  a[0]=atoi(p);
  p=strtok(NULL," \n");
  a[1]=atoi(p);
  p=strtok(NULL," \n");
  a[2]=atoi(p);
  
  for(i=0;i<2;i++){
   for(j=2;j>i;j--){
    if(a[j-1]<a[j]){
     buff=a[j-1],a[j-1]=a[j],a[j]=buff; 
    }
   }
  }
  
  if((a[1]-a[2])%2==1){
    count=0;
    a[0]++,a[1]++;
    count++;
   for(i=0;a[2]<a[1];i++){
    a[2]+=2;
    count++;
   }
   for(i=0;a[1]<a[0];i++){
    a[2]++,a[1]++;
    count++;
   }
    printf("%d\n",count);
    return 0;
  }
  
  if((a[1]-a[2])%2==0){
    count=0;
   for(i=0;a[2]<a[1];i++){
    a[2]+=2;
    count++;
   }
   for(i=0;a[1]<a[0];i++){
    a[2]++,a[1]++;
    count++;
   }
    printf("%d\n",count);
    return 0;
  }
  
 return 0; 
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

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

	REP(i, 1000)
	{
		int n = i*(i + 1) / 2;
		if (n > N)break;
		if (n < N)continue;
		cout << "Yes" << endl;
		cout << i + 1 << endl;

		//! 未だ使用していない数
		int x = 1;
		vector< vector<int> >v;
		REP(j, i + 1)
		{
			vector<int> p;
			REP(k, j)
			{
				p.push_back(v[k][j - 1]);
			}
			//! i個に足りない分補充
			REP(k, i - j)
			{
				p.push_back(x++);
			}

			//! 構成した部分集合を出力
			cout << i;
			REP(k, i)
			{
				cout << " " << p[k];
			}
			cout << endl;
			v.push_back(p);
		}
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int N, M; cin >> N >> M;
	string S; cin >> S;
	string T; cin >> T;

	int g = __gcd(N, M);
	int n = N / g;
	int m = M / g;
	rep (k, g){
		int a = k * n;
		int b = k * m;
		if (S[a] == T[b]){
			continue;
		}else{
			cout << -1 << endl;
			return 0;
		} // end if
	} // end rep

	cout << (ll) n * m * g << endl;

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include <array>
#include <vector>
#include <algorithm>
#include "math.h"
using namespace std;

int main() {
  int N, X;
  vector<int> m;
  cin >> N >> X;
  for (int i=0; i<N; i++) {
    int mm;
    cin >> mm;
    m.push_back(mm);
    X -= mm;
  }
  int cnt = N;
  int min_price = *std::min_element(m.begin(), m.end());
  cnt = cnt + X / min_price;
  std::cout << cnt;
  return 0;
}

Measured memory_bytes: 384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define SUM(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class DWalkAndTeleport {
public:
  static void solve(istream &cin, ostream &cout) {
    int N, A, B;
    cin >> N >> A >> B;
    int ans = 0;
    vector<int> X(N);
    rep(i, N) cin >> X[i];
    rep(i, N - 1) {
      ans += min(A * (X[i + 1] - X[i]), B);
    }
    cout << ans << endl;
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  DWalkAndTeleport solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3984
#include <stdio.h>

using namespace std;

int main() {
  int N,X=800,Y=15,BACK,B,A,TOTAL;

scanf("%d",&N);

B=N*X;
A=N/15;
BACK=200*A;
TOTAL=B-BACK;
printf("%d\n",TOTAL);



  return 0;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int t,a,b,c;
inline int read(){
	int ret=0,pos=1;char c=getchar();
	while(!isdigit(c) && c!='-' ) c=getchar();
	if(c=='-')	pos=-1,c=getchar();
	while(isdigit(c))ret=(ret<<3)+(ret<<1)+(c&15),c=getchar();
	return pos*ret;
}
signed main(){
	a=read(),b=read(),c=read();t=a;
	a-=b;b-=c;c-=t;
	if(a!=0 && b!=0 && c!=0)	puts("No");
	else
		if(a==0 && b==0 && c==0) puts("No");
		else puts("Yes");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct sp {
	int t;
	string s;
}name[1000000];
bool cmp(struct sp a,struct sp b)
{
	if(a.t!=b.t)
	return a.t>b.t;
	else
	return a.s<b.s;
}
int main()
{
	int t=0,n,i;
	string fp;
	cin>>n;
	map<string,int> mp;
	
	for(i=0;i<n;i++)
	{
		cin>>fp;
		if(mp.find(fp)==mp.end())
		{
			mp[fp]=t;
			name[t].s=fp;
			name[t].t=1;
			t++;
		}
		else
		{
			name[mp[fp]].t++;
		}
	}
	sort(name,name+t,cmp);
	int maxl=name[0].t;
	i=0;
	while(name[i].t==maxl)
	{
		cout<<name[i].s<<"\n";
		i++;
	}
	
}

Measured memory_bytes: 40832