akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
ll f[max_n*2];
ll inv[max_n*2];
ll invn[max_n*2];
ll C(int n,int m)
{
    if(n<m||m<0)return 0;
    return f[n]*inv[n-m]%mod*inv[m]%mod;
}
ll S(int n,int m)
{
    // x_1 + x_2 + ... + x_n = m, x_i >= 0
    if(n==0&&m==0)return 1;
    return C(m+n-1,n-1);
}
ll solve(int n,int s,int m)//xi<m,xi>=0
{
    ll res=S(n,s);
    for(int i=1;i<=n;i++)
    {
        if(i&1)res=Sub(res,Mul(C(n,i),S(n,s-m*i)));
        else res=Add(res,Mul(C(n,i),S(n,s-m*i)));
    }
    return res;
}
void init(int n)
{
    f[0]=1;
    for(int i=1;i<=n;i++)f[i]=f[i-1]*i%mod;
    inv[n]=Pow(f[n]);
    for(int i=n-1;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
    invn[1]=1;
    for(int i=2;i<=n;i++)invn[i]=invn[mod%i]*(mod-mod/i)%mod;
}
ll Lucas(ll n,ll m)
{
    if(n<m||m<0)return 0;
    if(m==0)return 1;
    return C(n%mod,m%mod)*Lucas(n/mod,m/mod)%mod;
}
int n,k,a[max_n];
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)scanf("%d",a+i);
    sort(a+1,a+n+1);
    init(n);
    int ans=0;
    for(int i=k;i<=n;i++){
        ans=Add(ans,Mul(C(i-1,k-1),Add(a[i],mod)));
    }
    for(int i=1;i<=n;i++)ans=Sub(ans,Mul(C(n-i,k-1),Add(a[i],mod)));
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3712
/** author: __nishad__ **/
#include<bits/stdc++.h>
using namespace std;


typedef long long ll ;
typedef vector<ll> vll ;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a,b) for(ll i=(a);i<=(b);i++)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define mp make_pair
#define pi 3.14159265358979323
#define endl "\n"

int main()
{
    IOS;

    int n;

    int a, b, c, x, res=0, limit;
    cin>>a>>b>>c>>x;

    if(c<=0 && x%100!=0)
    {
        res = 0; limit=0;
    }
    else
        limit = x/50;

    loop(i, 0, a){
        loop(j, 0, b){
            loop(k, 0, c){
                if(i*500+j*100+k*50 == x)
                    res++;
            }
        }
    }

    cout<<res;


}






























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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    LL a, b, c;cin >> a >> b >> c;
    if(a%2 == 0 || b%2 == 0 || c%2 == 0){
        cout << 0 << endl;
        return 0;
    }
    cout << min({a*b, b*c, c*a}) << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

def main():
    N = int(input())
    s = [input() for i in range(N)]
    M = int(input())
    t = [input() for i in range(M)]
    max_point = 0

    for a in s:
        add_point = s.count(a)
        sub_point = t.count(a)
        max_point = max(add_point - sub_point,max_point)

    print(max_point)
if __name__=='__main__':
    main()


Measured memory_bytes: 3060
#include<stdio.h>
#include<algorithm>
using namespace std;
const int maxn = 100005;
int n;
int A[3];
int dp[3][maxn] = {0};
int a,b,c;

int main(){
//	freopen("inf.txt","r",stdin);
	scanf("%d\n", &n);
	int t = 1;
	while(n--){
		scanf("%d%d%d", &a, &b, &c);
		dp[0][t] = max(dp[1][t-1]+a, dp[2][t-1]+a);
		dp[1][t] = max(dp[0][t-1]+b, dp[2][t-1]+b);
		dp[2][t] = max(dp[0][t-1]+c, dp[1][t-1]+c);
		t++;
	}
	int ans = max(dp[0][t-1],max(dp[1][t-1],dp[2][t-1]));
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1280
// 問題の URL を書いておく
// https://atcoder.jp/contests/agc023/tasks/agc023_a

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

using ll = int64_t;

int main(int, const char**)
{
    int n;
    cin >> n;
    vector<ll> s(n + 1, 0);
    rep(i, n)
    {
        ll a;
        cin >> a;
        s[i + 1] = s[i] + a;
    }

    sort(s.begin(), s.end());
    ll t = 0;
    ll c = 0;
    ll ans = 0;
    rep(i, n + 1)
    {
        if(s[i] == t)
        {
            c++;
        }
        else
        {
            if(c >= 2)
            {
                ans += (c * (c - 1) / 2);
            }
            c = 1;
            t = s[i];
        }
    }
    if(c >= 2)
    {
        ans += (c * (c - 1) / 2);
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
  int H,W;
  cin>>H>>W;
  map<char,int>mp;
  char temp;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>temp;
      mp[temp]++;
    }
  }
  int N1=0;
  int N2=0;
  int N4=0;
  
  for(auto itr=mp.begin();itr !=mp.end();itr++){
    if(itr->second == 1){
      N1++;
    }
    if(itr->second == 2){
      N2++;
    }
    if(itr->second == 3){
      N2++;
      N1++;
    }
    if(itr->second == 4){
      N4++;
    }
    if((itr->second)>4){
      if((itr->second)%4==0){
        N4+=(itr->second)/4;
      }
      if((itr->second)%4 == 1){
        N4+=(itr->second)/4;
        N1++;
      }
      if((itr->second)%4 == 2){
        N4+=(itr->second)/4;
        N2++;
      }
      if((itr->second)%4 == 3){
        N4+=(itr->second)/4;
        N2++;
        N1++;
      }      
    }
  }
  
  //cout<<N1<<" "<<N2<<" "<<N4<<endl;
  
  if(H%2 == 1){
    if(W%2 == 1){
      if(N1 == 1 && N4>=(H-1)*(W-1)/4){
        cout<<"Yes"<<endl;
        return 0;
      }
      else cout<<"No"<<endl;
      return 0;
    }
    else{
      if(N1 >=1 || N4<W*(H-1)/4){
        cout<<"No"<<endl;
        return 0;
      }
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  if(H%2 == 0){
    if(N1>=1){
      cout<<"No"<<endl;
      return 0;
    }
    if(W%2 == 1){
      if(N2 > H/2){
        cout<<"No"<<endl;
        return 0;
      }
    }
    if(W%2 == 0){
      if(N2 >=1){
        cout<<"No"<<endl;
        return 0;
      }
    }
    cout<<"Yes"<<endl;
    return 0;
  }
  //cout<<"#"<<endl;
  return 0;
}

  

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

int main(){
  ll x,y; cin >>x >>y;
  if(x*y>=0 && x<=y) cout << y-x;
  else if(x*y>0 && x>y) cout << x-y+2;
  else cout << abs(abs(x)-abs(y))+1;
  cout << endl;
  return 0;
}

Measured memory_bytes: 3684
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var B = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        long killed = 0;
        for (int i = N - 1; i >= 0; i--)
        {
            var attack = B[i];
            var first = Math.Min(attack, A[i + 1]);
            attack -= first;
            A[i + 1] -= first;
            killed += first;

            var second = Math.Min(attack, A[i]);
            attack -= second;
            A[i] -= second;
            killed += second;
        }

        Console.WriteLine(killed);
    }
}

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

int main(){
    int N;
    cin >> N;
    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    for (int i=0; i<N; i++){
        string tmp;
        cin >> tmp;
        if (tmp == "AC")
            a += 1;
        else if (tmp == "WA")
            b += 1;
        else if (tmp == "TLE")
            c += 1;
        else if (tmp == "RE")
            d += 1;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
int main(){
  bool flag=false;
  string s;
  cin >> s;
  char ch='C';
  r(i,s.length()){
    if(s.at(i)==ch){
      if(ch=='F')flag=true;
      else if(ch=='C')ch='F';
    }
  }
  if(flag)cout << "Yes"<<endl;
  else cout <<"No"<<endl;
}

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

int main() {
  std::string s;
  std::cin >> s;
  std::set<char> p;
  for (const auto c : s) {
    p.insert(c);
  }

  if (p.size() == 3) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
N,A,B,C,D = map(int,input().split())
S = "0" + input()

if C<D:
    if ("##" in S[A:C+1]) or ("##" in S[B:D+1]):
        print("No")
        exit()
    else:
        print("Yes")
        exit()
else:
    if ("##" in S[A:C+1]) or ("##" in S[B:D+1]):
        print("No")
        exit()
    else:
        if ("..." in S[B-1:D+1+1]):
            print("Yes")
            exit()
        else:
            print("No")
            exit()


Measured memory_bytes: 3636
import java.util.Scanner;


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

		int d,s;

		while (sc.hasNextInt()) {
			s = 0;
			d = sc.nextInt();
			for(int i = 1; i < 600 / d ; i++){
				s += (i * d) * (i * d) * d;
			}
			System.out.println(s);
		}
	}

}

Measured memory_bytes: 12000
/*
 AUTHOR : ANSHU BABU RAJPUT
 
    JAI MAA SARASWATI
    OM NAMAH SHIVAY
    JAI SHRI KRISHNA
    JAI SHRI RAM
    BHARAT MATA KI JAI
 
    #PKMKB	
    #CKMKB
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define int  long long 
#define endl    ("\n")
#define ff       first
#define ss      second
#define pb   push_back
#define pf  push_front
#define ppb   pop_back
#define ppf  pop_front
#define mp   make_pair
#define mod 1000000007
 
#define L(x)    x.length()
#define B(x)     x.begin()
#define E(x)       x.end()
#define F(x)     x.front()
#define SZ(x)     x.size()
#define CLR(x)   x.clear()
 
#define all(x)                      x.begin(),x.end()
#define sortD(x) sort(x.begin(),x.end(),greater<int>)
#define rev(x)             reverse(x.begin(),x.end())
 
#define intV vector<int>
 
#define PI          (3.141592653589)
#define PMAX     priority_queue<int>
#define PMIN             priority_queue<int,vi,greater<int>>
#define setbits(x)                   __builtin_popcountll(x)
#define zrobits(x)                        __builtin_ctzll(x)
 
#define KING(i, n) for (int(i) = 0; (i) < n; (i)++)
#define MAHAKAL(i, n) for (int(i) = n-1; (i) >= 0; (i)--)
 
#define Anshu        int t; cin>>t; while(t--)
#define SITARAM(n,type) type* input=new type[n]
 
mt19937                          rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
void ViLiFY_KiNG()
{
    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);
    freopen("error.txt","w",stderr);
#endif
}
 
int32_t main()
{
    ViLiFY_KiNG();
    int a; cin>>a;
  	string b; cin>>b;
  	int c = 100*(b[0]-'0')+10*(b[2]-'0')+(b[3]-'0');
  	int ans = a*c;
  	ans = ans/100;
  	cout<<ans;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
// #pragma GCC optimize ("Ofast")
// #pragma GCC target ("sse4")
// #pragma GCC optimize ("unroll-loops")
#define ll          long long
#define ld          long double
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
using namespace std;
pii dp[1<<18];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,i,mask;
	cin>>n;
	for(i=0;i<(1<<n);i++)
		cin>>dp[i].F;
	for(i=0;i<n;i++)
		for(mask=0;mask<(1<<n);mask++)
			if(1&(mask>>i)){
				vi v;
				v.pb(dp[mask].F);
				v.pb(dp[mask].S);
				v.pb(dp[mask^(1<<i)].F);
				v.pb(dp[mask^(1<<i)].S);
				sort(all(v));
				dp[mask]={v[3],v[2]};
			}
	for(mask=1,i=0;mask<(1<<n);mask++){
		i=max(i,dp[mask].F+dp[mask].S);
		cout<<i<<endl;
	}
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stdlib.h>
#include <cmath>
#include <math.h>
#include <fstream>
#include <bitset>
#include <time.h>
#include <queue>
#define int long long
using namespace std;
int n, ai;
vector<int> data;
set<int> cant;
vector<vector<int> > go;
int dfs(int vertex){
    set<int> sons;
    for (int i=0; i < go[vertex].size(); i++){
        int to = go[vertex][i];
        int res = dfs(to);
        sons.insert(res);
    }
    int i = 0;
    while (true){
        if (!sons.count(i)) return i;
        i++;
    }
}
pair<int, int> ch(int v){
    set<int> sons;
    for (int i=0; i < go[v].size(); i++){
        int to = go[v][i];
        if (cant.count(to)) continue;
        int vv = dfs(to);
        sons.insert(vv);
    }
    pair<int, int> p;
    bool pf = false;
    int i = 0;
    while (true){
        if (sons.count(i)) {i ++; continue;}
        if (!pf){
            pf = true;
            p.first = i;
            i++;
        }
        else{
            p.second = i;
            return p;
        }
    }
}
int32_t main(){
    cin >> n;
    for (int i=0; i < n; i++){
        vector<int> help;
        go.push_back(help);
    }
    for (int i=0; i < n; i++){
        cin >> ai;
        data.push_back(ai-1);
        go[ai-1].push_back(i);
    }
    set<int> ms;
    vector<int> c;
    vector<int> cycl;
    int now = 0;
    while (true){
        if (!ms.count(now)){
            ms.insert(now);
            c.push_back(now);
            now = data[now];
        }
        else{
            bool hc = false;
            for (int i=0;i<c.size(); i++){
                if (!hc){
                    if (c[i] != now) continue;
                    else{
                        hc = true;
                        cycl.push_back(c[i]);
                    }
                }
                else cycl.push_back(c[i]);
            }
            break;
        }
    }
    for (int i=0; i < cycl.size(); i++){
        cant.insert(cycl[i]);
    }
    set<int> firsts;
    for (int i=0; i < cycl.size(); i++){
        pair<int, int> p = ch(cycl[i]);
        firsts.insert(p.first);
    }
    if (firsts.size() >= 2 || cycl.size() % 2 == 0){
        cout << "POSSIBLE" << endl;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 31212
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

int popCount(ll n){
    n = (n & 0x5555555555555555) + (n >>  1 & 0x5555555555555555);
    n = (n & 0x3333333333333333) + (n >>  2 & 0x3333333333333333);
    n = (n & 0x0f0f0f0f0f0f0f0f) + (n >>  4 & 0x0f0f0f0f0f0f0f0f);
    n = (n & 0x00ff00ff00ff00ff) + (n >>  8 & 0x00ff00ff00ff00ff);
    n = (n & 0x0000ffff0000ffff) + (n >> 16 & 0x0000ffff0000ffff);
    n = (n & 0x00000000ffffffff) + (n >> 32 & 0x00000000ffffffff);
    return n;
}

int main(){
    int P, N;
    while(std::cin >> N >> P, P || N){
        ll isEmpty = 0;
        int stones[50], pos = 0;
        std::fill(stones, stones+50, 0);

        while(!(popCount(isEmpty) == N - 1 && P == 0)){
            if(P > 0){
                P -= 1;
                stones[pos] += 1;
                isEmpty &= ~(1LL << pos);
            }else{
                P += stones[pos];
                stones[pos] = 0;
                isEmpty |= 1LL << pos;
            }
            pos = (pos + 1) % N;
        }
        // REP(i, N){
        //     printf("%d ", stones[i]);
        // }
        // puts("");

        REP(i, N){
            if(isEmpty >> i & 1){continue;}
            printf("%d\n", i);
            break;
        }
    }
}

Measured memory_bytes: 1144
import math

n = int(input())
cnt = 0
for i in range(n):
    num = int(input())
    flag = 1
    if num == 2:
        flag = 1
    elif num % 2 == 0 or num < 2:
        flag = 0
    else:
        for j in range(3, int(math.sqrt(num))+1, 2):
            if num % j == 0:
                flag = 0
                break
    if flag:
        cnt+=1
print(cnt)


Measured memory_bytes: 5668
N = int(input())
c = list(input())


# 赤の個数を数える
R = c.count('R')

# 白の個数を数える
W = c.count('W')

# 左から赤をすべて並べ、白はすべて右側に寄せることを考える
# 赤と白の石の間に仕切りを作ると仕切りの位置は左からR番目の石の右側にある
# つまり仕切りより左にある白い石の数だけ操作をすればよい

ans = 0
for i in range(R):
  if c[i] == 'W':
    ans += 1

print(ans)







Measured memory_bytes: 10748
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

#define DEBUG(x) cerr << #x << " = " << x << endl

const int INF = (int)1e9;

struct Edge {
  int from, to, cost, hour, rail;
  Edge(int from_, int to_, int cost_, int hour_, int rail_) :
    from(from_), to(to_), cost(cost_), hour(hour_), rail(rail_) { }
};

int main() {
  while(true) {
    int N, M, H, K; cin >> N >> M >> H >> K;
    if(N == 0 && M == 0 && H == 0 && K == 0) break;
    vector<Edge> G;
    for(int i = 0; i < M; ++i) {
      int a, b, c, h, r; cin >> a >> b >> c >> h >> r;
      --a, --b, --r;
      G.emplace_back(a, b, c, h, r);
      G.emplace_back(b, a, c, h, r);
    }
    int S, T, P; cin >> S >> T >> P;
    --S, --T;
    int passport[1 << 8];
    for(int i = 0; i < (1 << 8); ++i) passport[i] = INF;
    passport[0] = 0;
    for(int i = 0; i < P; ++i) {
      int l, d; cin >> l >> d;
      int B = 0;
      for(int j = 0; j < l; ++j) {
        int k; cin >> k;
        --k;
        B |= (1 << k);
      }
      passport[B] = d;
    }
    while(true) {
      bool update = false;
      for(int i = 0; i < (1 << K); ++i) {
        for(int j = i + 1; j < (1 << K); ++j) {
          int B = i | j;
          if(passport[B] > passport[i] + passport[j]) {
            update = true;
            passport[B] = passport[i] + passport[j];
          }
        }
      }
      if(!update) break;
    }
    int ans = INF;
    for(int B = 0; B < (1 << K); ++B) {
      vector<Edge> G2 = G;
      for(int i = 0; i < (int)G2.size(); ++i) {
        if((B >> G2[i].rail) & 1) G2[i].cost = 0;
      }
      int d[N][H+1];
      for(int i = 0; i < N; ++i)
        for(int j = 0; j < H + 1; ++j)
          d[i][j] = INF;
      for(int j = 0; j < H + 1; ++j) {
        d[T][j] = 0;
      }
      while(true) {
        bool update = false;
        for(int i = 0; i < (int)G2.size(); ++i) {
          for(int h = 0; h + G2[i].hour <= H; ++h) {
            if(d[G2[i].to][h + G2[i].hour] > d[G2[i].from][h] + G2[i].cost) {
              d[G2[i].to][h + G2[i].hour] = d[G2[i].from][h] + G2[i].cost;
              update = true;
            }
          }
        }
        if(!update) break;
      }
      for(int j = 0; j < H + 1; ++j) {
        ans = min(ans, passport[B] + d[S][j]);
      }
    }
    if(ans == INF) {
      cout << -1 << endl;
    }
    else {
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 1248
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int P = stdIn.nextInt();
		int Q = stdIn.nextInt();
		int R = stdIn.nextInt();
		
		if(P <= Q) {
			if(R <= Q) {
				System.out.println(P+R);
			}
			else {
				System.out.println(P+Q);
			}
			
		}
		else {
			if(R <= P) {
				System.out.println(R+Q);
			}
			else {
				System.out.println(P+Q);
			}
		}

	}

}

Measured memory_bytes: 23252
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int X, A, B; cin >> X >> A >> B;
    cout << (X-A)%B << endl;
    
    return 0;
}

Measured memory_bytes: 256
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left #bisect_left(list, value)
#from fractions import gcd
enu = enumerate

sys.setrecursionlimit(10**7)
a, b, c = map(int, input().split())

val = (c-a-b)**2 - 4*a*b

if val>0 and c-a-b>0:
    print('Yes')
else:
    print('No')




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

int main() {
  int N; cin >> N;
  vector<int> cards(N);
  for(int i=0;i<N;i++){
    cin >> cards.at(i);
  }
  sort(cards.begin(), cards.end());
  reverse(cards.begin(), cards.end());
  
  int a=0, b=0;
  for(int i=0;i<N;i++){
    if(i%2==0)
      a+=cards.at(i);
    else
      b+=cards.at(i);
  }
  cout << a-b << endl;
}


Measured memory_bytes: 256
from collections import deque, defaultdict

N, Q = map(int, input().split())
edge = defaultdict(list)
for i in range(N-1):
    a, b = map(int, input().split())
    edge[a].append(b)
    edge[b].append(a)

query = [0] * (N+1)
for i in range(Q):
    p, x = map(int, input().split())
    query[p] += x

q = deque()
q.appendleft((1, 1, query[1]))
ans = [0] * (N+1)

while q:
    now, prev, weight = q.pop()
    ans[now] += weight
    for e in edge[now]:
        if e == prev:
            continue
        q.appendleft((e, now, weight+query[e]))

print(*ans[1:])
        


Measured memory_bytes: 131928
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
#include <map>
#include <cstring>
#include <cassert>
 
using namespace std;

int main(){

    long long n,m;
    cin>>n>>m;

    if(n>=2 && m>=2){
        cout<<(n-2)*(m-2)<<endl;
    }else if(n==1 && m==1){
        cout<<1<<endl;
    }else if(n==1){
        cout<<m-2<<endl;
    }else{
        cout<<n-2<<endl;
    }

}


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

#define lld long long
#define pi pair<int, int>
#define pl pair<lld, lld>
#define mem0(x) memset(x, 0, sizeof(x))
#define fillnum(x, n) fill(begin(x), end(x), n)
#define asort(x) sort(x.begin(), x.end())
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>())

int main() {
    lld A, B, N;
    cin >> A >> B >> N;
    lld maxv = -1;
    lld nowx = max(0LL, N - 10 * B);
    while(true) {
        if(nowx > N) {
            cout << maxv << endl;
            exit(0);
        }
        lld left = (A * nowx / B);
        lld right = A * (nowx / B);
        // cout << left << " " << right << endl;
        maxv = max(maxv, left - right);
        nowx = min(((left + 1) * B / A) + 1, (right + 1) * B);
        // cout << ((left + 1) * B / A) + 1 << " " << (right + 1) * B << endl;
        // cout << nowx << endl;
    }
}

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

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

a_str = ''
b_str = ''
for i in range(a):
    b_str = b_str + str(b)

for i in range(b):
    a_str = a_str + str(a)

if a_str > b_str:
    print(b_str)
else:
    print(a_str)


Measured memory_bytes: 2940
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

K = int(input())
aa = reversed(inpl())

MIN = MAX = 2
for a in aa:
    if MIN%a == 0 or MAX//a - MIN//a > 0:
        MIN = ((MIN-1)//a+1) *a
        MAX = MAX//a*a+a-1
    else:
        print(-1)
        sys.exit()

print(MIN,MAX)


Measured memory_bytes: 15600
#include <iostream>
using namespace std;
int main()
{
    long a , b , c = 0, d = 0, e = 0;
    cin >> a >> b;
    int x [a];
    for (int i = 0; i < a; i++)
	{
        cin >> x[i];
    }
    c = a + (b - 3);
    d = b - 1;
    e = c / d;
    cout << e;
    return 0;
} 

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

char s[123] ;

int main()
{
    int a , b , c , d ;
    while(~scanf("%d %d %d %d",&a,&b,&c,&d)){
        printf("%d\n",std::min(b,d) - std::max(a,c) > 0 ? std::min(b,d) - std::max(a,c) : 0) ;
    }
    return 0 ;
}


Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n; readV(n);
  long[] a; readA(n, a);

  a.sort!"a>b";
  auto ans = 0L;

  while (a[$-1] < n) {
    if (a[0] < n) {
      writeln(ans);
      return;
    }
    a[] += 1;
    a[0] -= n+1;
    ++ans;
    a.sort!"a>b";
  }

  foreach (i; 1..n) {
    auto c = (a[0]-a[i])/(n+1);
    ans += c*i;
    a[0..i][] -= c*(n-i+1);
    a[i..$][] += c*i;
  }

  auto d = max(0, a[0]-n*2);
  ans += d*n;
  a[] -= d;

  while (a[0] >= n) {
    a[] += 1;
    a[0] -= n+1;
    ++ans;
    a.sort!"a>b";
  }

  writeln(ans);
}


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

using namespace std;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

int main (){
   int n,k;
   int a[220000]= {};
   int d[220000];
   cin >> n >> k;
   cinf(n,d);
   REP(i,n){
       a[d[i]]++;
   }

    sort(a,a+n, greater<int>());
    
    int total = 0;
    REP(i,k){
        total += a[i];
    }

    cout << n - total << endl;





    return 0;
}

//できず
//方針等みて再回答
//種類ナンバー配列を作ること

Measured memory_bytes: 1920
#include<stdio.h>

int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int i;
    int j=0;
    for(i=a;i<=b;i++)
    {
        if(c%i==0) j++;
    }
    printf("%d\n",j);
    return 0;
}



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

using namespace std;
typedef long long ll;

ll N, X, L, D = 0, counter = 1;

int main() {
	cin >> N >> X;
	for (int i = 1; i <= N; i++) {
		cin >> L;
		D += L;
		if (D <= X)counter++;
	}
	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int x = stdIn.nextInt();
    int a = 0, b, p, i, t;
		for(b = 1;b <= x;b++) {
			t = b;
			for(p = 2;p <= x;p++) {
				t *= b;
				if(t <=x && a < t) a = t;
			}
		}
		if(x == 1) a = 1;
		System.out.print(a);
	}
}


Measured memory_bytes: 23764
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int ANS = 0;
	int N ;//
	int ASUM=0 ;//
  	int B[101];//各桁の数を格納
 
	//Nをスキャン
	scanf("%d", &N);
	//N個の数字をスキャン 0からN-1まで
 	for (int i = 0; i < N-1; i++) { 
		scanf("%d", &B[i]);
	}
   	for (int i = 0; i < N-2; i++) { 
		if(B[i]>=B[i+1]){
          ASUM=ASUM+B[i+1];
        }
      else{
        ASUM=ASUM+B[i];
      }
	}
  ASUM=ASUM+B[0]+B[N-2];
  
 
	ANS = ASUM;
 
	printf("%d", ANS);
 
	return 0;
}

Measured memory_bytes: 128
h,w=map(int,input().split())
a=[input() for _ in range(h)]
res=[]
for i in range(h):
    if "#" not in a[i]:
      res.append(i)

resh=[]
h=len(a)
for i in range(w):
    for j in range(len(a)):
      if a[j][i]=="#":
        break
    else:
      resh.append(i)
for i in range(h):
  for j in range(w):
    if i not in res and j not in resh:
      print(a[i][j],end="")
  if i not in res:
    print("")

Measured memory_bytes: 4468
#include<stdio.h>
int main(){
    char A , B ;

    scanf("%s%s",&A,&B);
    if(A == 'H' && B == 'H'){
        printf("H");
    }else if(A == 'H' && B == 'D'){
        printf("D");
    }else if(A =='D' && B == 'H'){
        printf("D");
    }else{
        printf("H");
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main (){
    map<ll,ll>mp;
    int t;cin>>t;
    ll tmp=0,ans=0;
    while(t--){
        ll n;cin>>n;
        tmp+=n;
        if(tmp==0) ans+=(mp[0]++)+1;
        else ans+=mp[tmp]++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 12800
N, X = map(int, input().split())
L_lst = list(map(int, input().split()))

sum_ = 0

ans = 0

for i in range(N):
    sum_ += L_lst[i]
    if sum_ > X:
        ans = i + 1
        break
if ans == 0:
    ans = N + 1

print(ans)

Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1e9 + 7;
void solve(){
    ll n, s;
    cin >> n >> s;
    ll ans = 0;
    unordered_map<ll, vi> a;
    vector<pair<ll, ll>> sz;
    for (ll i = 0; i < n; ++i) {
        ll w, v;
        cin >> w >> v;
        a[w].pb(v);
    }
    for (auto& p : a) {
        sort(rall(p.se));
        sz.pb({p.fi, p.se.size()});
    }
    ll sum0 = 0;
    for (ll i = 0; i <= sz[0].se; ++i) {

        if (i != 0) sum0 += a[sz[0].fi][i - 1];
        ll sum = i * sz[0].fi;

        if (sz.size() > 1) {
            ll sum1 = 0;

            for (ll j = 0; j <= sz[1].se; ++j) {
                if (j != 0) sum1 += a[sz[1].fi][j - 1];

                if (sz.size() > 2) {
                    ll sum2 = 0;

                    for (ll k = 0; k <= sz[2].se; ++k) {
                        if (k != 0) sum2 += a[sz[2].fi][k - 1];

                        if (sz.size() > 3) {
                            ll sum3 = 0;
                            for (ll l = 0; l <= sz[3].se; ++l) {
                                if (l != 0) sum3 += a[sz[3].fi][l - 1];
                                if (sum + j * sz[1].fi + k * sz[2].fi + l * sz[3].fi <= s) {
                                    ans = max(ans, sum1 + sum2 + sum3 + sum0); 
                                }
                            }
                        }

                        if (sum + j * sz[1].fi + k * sz[2].fi <= s) {
                            ans = max(ans, sum1 + sum2 + sum0); 
                        }
                    }
                }

                if (sum + j * sz[1].fi <= s) {
                    ans = max(ans, sum0 + sum1);
                }
            }
        }
        if (sum <= s) ans = max(ans, sum0);
    }
    cout << ans;
}
int main(){
    speed;
    ll t = 1;
    //cin >> t;
    for (ll i = 1; i <= t; ++i) {
        solve();
    }
}

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

using namespace std;

int main(){
	long long a,b;
	char op;
	
	while(1){
		cin>>a>>op>>b;
		if(op=='?') break;
		if(op=='-') cout<<a-b<<endl;
			else if(op=='+') cout<<a+b<<endl;
				else if(op=='*') cout<<a*b<<endl;
					else if(op=='/') cout<<a/b<<endl;
	}
}


Measured memory_bytes: 3040
#include <iostream>
using namespace std;
int main(void){

    int a,b,c;
    cin >> a >> b >> c;
    int score = 0;
    for(int day = 1; ; day++){
        score += a;
        if(day % 7 == 0){
            score += b;
        }
        if(score >= c){
            cout << (day) << endl;
            break;
        }
    }
}


Measured memory_bytes: 3084
use strict;
use warnings;

my (@tmp, @arr, @ans);
while(<>){
	chomp;
	next if($. == 1);
	unless(/^\.+$/){
		@tmp = split(//, $_);
		for (my $i = 0; $i < length($_); $i++){
			$arr[$i] .= $tmp[$i];
		}
	}
}

@arr = grep {!/^\.+$/} @arr;

for (my $i = 0; $i <= $#arr; $i++){
	@tmp = split(//, $arr[$i]);
	for (my $n = 0; $n <= $#tmp; $n++){
		$ans[$n] .= $tmp[$n];
	}
}

printf join("\n", @ans);


Measured memory_bytes: 768
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		Console.WriteLine(0);
		string z=Console.ReadLine();
		int lb=0,ub=n,mid=0;
		while(ub-lb>1){
			mid=(ub+lb)/2;
			Console.WriteLine(mid);
			string q=Console.ReadLine();
			if(q=="Vacant"){break;}
			else if(((lb+mid)%2==0&&q!=z)||((lb+mid)%2==1&&q==z)){ub=mid;}
			else{
				lb=mid;
				z=q;
			}
		}
	}
}

Measured memory_bytes: 13512
n,k=map(int,input().split())
h=list(map(int,input().split()))
min_cost=[0]*n
min_cost[0]=0
min_cost[1]=abs(h[1]-h[0])
for i in range(2,n):
    s=[]
    for j in range(1,k+1):
        if i-j<0:
            continue
        s.append(min_cost[i-j]+abs(h[i]-h[i-j]))
    min_cost[i]=min(s)
print(min_cost[-1])

Measured memory_bytes: 52448
#include <algorithm>
#include <iterator>
#include <iostream>
#include <sstream>
#include <bitset>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <time.h>
#include <limits>
#include <math.h>
#include <climits>
#include <numeric>
#include <utility>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <functional>
#include<unordered_map>

using namespace std;
const double pi=acos(-1.0);
//memset ( a , 0 , n * sizeof(ll) ) ;

#define 	boost  		ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define 	endl 		'\n'
#define 	sl(n) 		scanf("%lld",&n)
#define		mp 			make_pair
#define 	pb 			push_back
#define 	ppb 		pop_back
#define 	fi 			first
#define 	se 			second
#define 	ll 			long long
#define 	ull 		unsigned long long
#define 	pii 		pair<int, int>
#define 	f(i,a,b) 	for(ll i = (ll)(a); i < (ll)(b); i++)
#define 	rf(i,a,b) 	for(ll i = (ll)(a); i > (ll)(b); i--)
#define 	ms(a,b) 	memset((a),(b),sizeof(a))
#define 	max(a,b) 	((a>b)?(a):(b))
#define 	min(a,b) 	((a<b)?(a):(b))
#define 	vec(g1) 	int temp;cin>>temp;g1,push_back(temp);
#define 	abs(x) 		((x<0)?(-(x)):(x))
#define 	MAX 		1000005
#define 	inf 		LLONG_MAX
#define 	MIN 		INT_MIN

//typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

int mod = 1e9 + 7 ;
ll gcd(ll a , ll b){return b==0?a:gcd(b,a%b);}
ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
// ll fac[200005];
// ll inverse(ll n){return powmod(n, mod-2);}
// ll nCr(ll n, ll r){return (fac[n] * inverse(fac[r]) % mod * inverse(fac[n-r]) % mod) % mod;}

/**.................................................................................................................................*/
int main(){
	boost;
	int n,w;
	cin>>n>>w;
	pair<int,ll> a[n];
	f(i,1,n+1){
	    cin>>a[i].fi>>a[i].se;
	}
	sort(a,a+n);
	ll dp[n+1][w+1];
	ms(dp,0);
	f(i,0,w+1){ dp[0][i]=0;}
	f(i,0,n+1)dp[i][0]=0;
	
	for(int i=1;i<=n;i++){ 
		for(int j=1;j<=w;j++){
			if(j>=a[i].fi){
				dp[i][j]=max(dp[i-1][j-a[i].fi]+a[i].se,dp[i-1][j]);
			}
			else{ dp[i][j]=dp[i-1][j];}
		}
	}

         cout<<dp[n][w]<<endl;



 	return 0;
}


Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long q,h,s,d,n;
	cin >> q >> h >> s >> d >> n;
	cout << (n/2)*min(q * 8,min(h * 4, min(s * 2,d))) + ((n%2) * min(q * 4,min(h * 2,s))) << endl;
    return 0;
}  


Measured memory_bytes: 256
def main():
    A, B = map(int, input().split())

    A = 14 if A == 1 else A
    B = 14 if B == 1 else B

    if A > B:
        print("Alice")
    elif A < B:
        print("Bob")
    else:
        print("Draw")

if __name__ == '__main__':
    main()


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

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	while (a + 1 < b) {
		a++;
		b--;
	}
	if (a + 1 == b)cout << "Borys" << endl;
	else cout << "Alice" << endl;
}

Measured memory_bytes: 256
use proconio::*;
use std::collections::BinaryHeap;

fn main() {
    input! {
        d: usize,
        c: [i64; 26],
        s: [[i64; 26]; d],
    };

    let mut score = 0;
    let mut lasts = [-1; 26];
    let mut t = vec![26; d];
    let depth = 5;
    for i in 0..d {
        let mut max_score = -10000000;
        for j in 0..26 {
            let tmp = search(i, j, &c, &s, &mut lasts, depth, d, 0);
            if tmp > max_score {
                max_score = tmp;
                t[i] = j;
            }
        }
        score += max_score;
        lasts[t[i]] = i as i64;
    }

    for &a in &t {
        println!("{}", a + 1);
    }
}

fn calc_score(i: usize, j: usize, c: &Vec<i64>, s: &Vec<Vec<i64>>, lasts: &mut [i64; 26]) -> i64 {
    let mut res = s[i][j];
    let tmp = lasts[j];
    lasts[j] = i as i64;

    for j in 0..26 {
        let i = i as i64;
        let last = lasts[j];
        res -= c[j] * (i - last);
    }

    lasts[j] = tmp;
    res
}

fn search(
    i: usize,
    t: usize,
    c: &Vec<i64>,
    s: &Vec<Vec<i64>>,
    lasts: &mut [i64; 26],
    depth: usize,
    d: usize,
    cscore: i64,
) -> i64 {
    if depth == 0 || i == d - 1 {
        return calc_score(i, t, &c, &s, lasts) + cscore;
    }

    let mut max_score = -1000000;
    let tmp_last = lasts[t];
    lasts[t] = i as i64;
    let tmp_score = calc_score(i, t, &c, &s, lasts);
    let mut cands = BinaryHeap::new();
    for j in 0..26 {
        let tmp_score = calc_score(i + 1, j, &c, &s, lasts);
        cands.push((tmp_score, j));
    }
    for &(_, j) in cands.iter().take(3) {
        let tmp = search(i + 1, j, &c, &s, lasts, depth - 1, d, cscore + tmp_score);

        if tmp > max_score {
            max_score = tmp;
        }
    }

    lasts[t] = tmp_last;
    max_score + cscore
}


Measured memory_bytes: 2308
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define endl '\n'
#define inf 9223372036854775807
#define maxn 3000001
#define mod (ll)(1e9+7)
#define int ll
 
using namespace std;
 
void io(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

int n,ar[2005];
string S,T;

void __solve(){
		cin>>S>>T;
		int n=S.size();
		int m=T.size();
		int ans=m;
		for(int i=0;i<n-m+1;i++){
			int cur=0;
			for(int j=i;j<i+m;j++){
				// cout<<S[j]<<" "<<T[j-i]<<endl;
				if(S[j]!=T[j-i]){
					cur++;
				}
			}
			ans=min(ans,cur);
			// cout<<ans<<endl;
		}
		cout<<ans<<endl;
		
}


int32_t main(){
io();
IOS;    
			int t=1;
			// cin>>t;
			while(t--){
				__solve();
			}
		
		



        

        


        
    
        
        
                


 
        
 
 
 
        
 
 
 
 
        
        
 
        
        
 
    
    
    
    
 
 
       
 
 
 
 
      
   
 
 
 
 
}

Measured memory_bytes: 3640
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ll,ll>
#define K 3000
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;
ll n,m,s;
ll c[110] , d[110] , dp[70][K+8];
struct datas
{
	ll node;
	ll cost;
	ll tim;
};

vector<datas> v[100];
void djiktra()
{
	priority_queue<pair<ll,pii>,vector<pair<ll,pii>>,greater<pair<ll,pii>>> pq;
	pq.push({0,{s,1}});
	dp[1][s] = 0;
	while(!pq.empty())
	{
		pair<ll,pii> st = pq.top();
		ll pcity = st.se.se;
		ll kane = st.se.fi;
		ll ti = st.fi;
		pq.pop();
		if(dp[pcity][kane] < ti) continue;
		for(auto u: v[pcity])
		{
			if(kane >= u.cost and dp[u.node][kane - u.cost] > ti + u.tim)
			{
				dp[u.node][kane - u.cost] = ti + u.tim;
				pq.push({ti+u.tim,{kane-u.cost,u.node}});
			}
		}
		if(kane + c[pcity] < K and dp[pcity][kane+c[pcity]] > ti + d[pcity])
		{
			dp[pcity][kane+c[pcity]] = ti + d[pcity];
			pq.push({ti + d[pcity] , {kane+c[pcity] , pcity}});
		}
	}
}
signed main()
{
    fast;
   
    ll i,j;
    cin>>n>>m>>s;
    s = min(s,K-1LL);
    for(i=0;i<m;i++)
    {
    	ll x,y,a,b;
    	cin>>x>>y>>a>>b;
    	v[x].pb({y,a,b});
    	v[y].pb({x,a,b});
    }
    for(i=1;i<=n;i++)
    {
    	cin>>c[i]>>d[i];
    	for(j=0;j<K;j++) dp[i][j] = 1e18;
    }
    djiktra();
    for(i=2;i<=n;i++)
    {
    	cout<<*min_element(dp[i] , dp[i]+K)<<"\n";
    }

}

Measured memory_bytes: 7580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
struct UnionFind {

	vector<long long> data;

	UnionFind(long long size): data(size, -1) {}
	
	void unite(long long x, long long y){
		x = root(x);
		y = root(y);
		if( x != y ){
			if( data[y] < data[x] ) swap(x, y);
			data[x] += data[y];
			data[y] = x;
		}
	}

	bool same(long long x, long long y){
		return root(x) == root(y);
	}

	long long root(long long x){
		return (data[x] < 0) ? x : data[x] = root(data[x]);
	}

	long long size(long long x){
		return -data[ root(x) ];
	}
};

int main(){
    ll n,m; cin>>n>>m;
    vector<ll> p(n), x(m), y(m);
    UnionFind tree(n+1);
    rep(i,n) cin>>p[i];
    rep(i,m){
        cin>>x[i]>>y[i];
        tree.unite(x[i], y[i]);
    }
    ll res=0;
    for(ll i=1; i<=n; i++){
        if(i==p[i-1] || tree.same(i, p[i-1])) res++;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

  public static void main(String[] args) throws Exception {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int t = sc.nextInt();
    int prev = sc.nextInt();
    long sum = 0;
    for (int i = 1; i < n; i++) {
      int next = sc.nextInt();
      int diff = next - prev;
      if (t < diff) {
        sum += t;
      } else {
        sum += diff;
      }
      prev = next;
    }
    sum += t;
    System.out.println(sum);
  }
}


Measured memory_bytes: 63224
#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>;

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

bool palin(string s) {
    int n = s.size();
    for (int i=0; i<n; ++i) {
        if (s[i] != s[n-i-1]) return false;
    }
    return true;
}

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

    int n = s.size();
    string a = s.substr(0,(n-1)/2);
    string b = s.substr((n+3)/2-1);

    if (palin(s) && palin(a) && palin(b)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
/*
* @Author: Kabid
* @Date:   2020-04-26 18:01:07
* @Last Modified by:   Kabid
* @Last Modified time: 2020-04-26 19:16:00
*/
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<set>
#define ll long long
#define  in(x) scanf("%d",&x);
#define out(x) printf("%d",x);
#define  ins(x)  scanf("%s",x);
#define outs(x) printf("%s",x);
#define lin puts("");
#define _ putchar(' ');
using namespace std;

int t;       //test cases
int i = 1, j;	 //iterators
int n, k, p; //variables
int w;
int a, b, c, d;
string s;
set<string>st;
int main() {
	cin>>n;
	for (i = 0; i < n; i++) {
		cin>>s;
		st.insert(s);
	}
	cout<<st.size();
	return 0;
}


Measured memory_bytes: 19120
#include <iostream>                                                                           
using namespace std;                                                                          
int main(){                                                                                   
  int s;                                                                                      
  cin >> s;                                                                                   
  cout << (s/3600) << ":" << (s%3600)/60 << ":" << (s%60) << endl;                            
} 


Measured memory_bytes: 3092
#include <bits/stdc++.h>
 
using namespace std;
 
int N;
long long ans, x;
 
long long gcd(long long a, long long b)
{
    if (a == 0) return b;
    return gcd(b%a, a);
}
 
long long lcm(long long a, long long b)
{
    long long x = gcd(a, b);
    a /= x;
    return a*b;
}
 
int main()
{
    cin >> N >> ans;
    for (int i=1; i < N; i++)
    {
         cin >> x;
         ans = lcm(ans, x);
    }
    cout << ans;
}

Measured memory_bytes: 256