akhauriyash/Code-Regression huggingface dataset:
module ABC129

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_B

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_B

    ! variables for this <subroutine>
    integer(INT32) :: num_weights
    integer(INT32) :: sum_fore, sum_rear
    integer(INT32) :: difference_min

    ! support variables for this <subroutine>
    integer(INT32) :: itr

    ! arrays for this <subroutine>
    integer(INT32), allocatable :: val_weight(:)

    ! STEP.01
    ! read out the number of weights
    read(unit=INPUT_UNIT, fmt=*) num_weights

    ! STEP.02
    ! allocate the array to store the values of weight
    allocate( val_weight(1:num_weights) )

    ! STEP.03
    ! read out the values of weight
    read(unit=INPUT_UNIT, fmt=*) val_weight(1:num_weights)

    ! STEP.04
    ! search the minimum value of difference of summation of weights that can be realized in given weights
    sum_fore       = val_weight(1)
    sum_rear       = sum( val_weight(2:num_weights), dim=1 )
    difference_min = abs( sum_fore - sum_rear )

    do itr = 2_INT32, num_weights - 1_INT32, 1_INT32
      sum_fore       = sum_fore + val_weight(itr)
      sum_rear       = sum_rear - val_weight(itr)
      difference_min = min( difference_min, abs( sum_fore - sum_rear ) )
    end do

    ! STEP.05
    ! output the minimum value of difference of summation of weights that can be realized in given weights
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') difference_min

    ! STEP.05
    ! deallocate the array to store the values of weight
    deallocate( val_weight )

    ! STEP.END
    return

  end subroutine task_B

end module ABC129


program main

  ! <module>s to import
  use, non_intrinsic :: ABC129

  ! require all variables to be explicitly declared
  implicit none

  call task_B

end program main

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
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;
}

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N;
    cin >> N;
    map<string, int> m;

    REP(i, N)
    {
        string ts;
        cin >> ts;
        if (m.find(ts) == m.end())
        {
            m[ts] = 1;
        }
    }
    cout << distance(m.begin(), m.end()) << endl;
    return 0;
}

Measured memory_bytes: 19204
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Max = 1e5 + 5;
int lst[Max], ls[Max];

int main()
{
	int n;
	cin >> n;
	string str;
	cin >> str;
	int ma = 0;
	int x = 0;
	for (int i = 0; i < str.size(); i++)
	{
		if (str[i] == 'D')x--;
		else x++;
		ma = max(ma, x);
	}
	cout << ma;
}

Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;

// http://www.prefield.com/algorithm/misc/dice.html
enum FACE { TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT };
class dice {
public:
	dice(int top,int front,int right,int left,int back,int bottom) {
		id[TOP] = top; id[FRONT] = front; id[RIGHT] = right;
		id[LEFT] = left; id[BACK] = back; id[BOTTOM] = bottom;
	}
	void roll_north() { roll(TOP, FRONT, BOTTOM, BACK); }
	void roll_south() { roll(TOP, BACK, BOTTOM, FRONT); }
	void roll_east() { roll(TOP, LEFT, BOTTOM, RIGHT); }
	void roll_west() { roll(TOP, RIGHT, BOTTOM, LEFT); }
	void roll_right() { roll(FRONT, LEFT, BACK, RIGHT); }
	void roll_left() { roll(FRONT, RIGHT, BACK, LEFT); }
	void all_rolls(set<long long> &s){
		for (int k = 0; k < 6; (k&1?roll_east():roll_north()),++k)
			for (int i = 0; i < 4; roll_right(), ++i)
				s.insert(((long long)id[TOP]<<40) | ((long long)id[FRONT]<<32) | (id[RIGHT]<<24) | (id[LEFT]<<16) | (id[BACK]<<8) | (id[BOTTOM]<<0));
	}
private:
	void roll(FACE a, FACE b, FACE c, FACE d){
		int tmp = id[a];
		id[a] = id[b]; id[b] = id[c];
		id[c] = id[d]; id[d] = tmp;
	}
	int id[6];
};

int main(){
	string str;
	int d[6];
	int n,i,j,r;
	for(;cin>>n,n;){
		set<long long>s;
		for(r=i=0;i<n;i++){
			for(j=0;j<6;j++)cin>>str,d[j]=str[0];
			long long x=((long long)d[0]<<40) | ((long long)d[1]<<32) | (d[2]<<24) | (d[3]<<16) | (d[4]<<8) | (d[5]<<0);
			if(s.find(x)!=s.end())r++;
			else{
				dice di(d[0],d[1],d[2],d[3],d[4],d[5]);
				di.all_rolls(s);
			}
		}
		cout<<r<<endl;
	}
}

Measured memory_bytes: 1228
from itertools import combinations_with_replacement
N, M, Q = map(int, input().split())
a = list()
b = list()
c = list()
d = list()

for _ in range(Q):
    _a, _b, _c, _d = map(int, input().split())
    a.append(_a-1)
    b.append(_b-1)
    c.append(_c)
    d.append(_d)
ans = 0

for A in combinations_with_replacement(range(1, M+1), r=N):
    dmax = 0
    for q in range(Q):
        if A[b[q]] - A[a[q]] == c[q]:
            dmax += d[q]
    ans = max(ans, dmax)
print(ans)

Measured memory_bytes: 9228
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    Yes((A < C && C < B) || (A > C && C > B));
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int tmp;
  int count[5];
  for(int i = 0;i < 5;i++) count[i]= 0;
  for(int i= 0;i < 6;i++){
    cin >> tmp;
    count[tmp]++;
    if(count[tmp] > 2){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 256
# coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)
#from heapq import heappop, heappush
#from collections import OrderedDict, defaultdict
import math
#from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque
#import numba

def run():
    dict = 'abcdefghijklmnopqrstuvwxyz'
    dict2 = 'zabcdefghijklmnopqrstuvwxy'
    ret = ''
    N = int(input())
    done = False
    while N:
        tmp = N % 26
        N = N // 26
        if tmp == 0:
            N -= 1
        ret = dict2[tmp] + ret
    print(ret)
if __name__ == "__main__":
    run()

Measured memory_bytes: 9136
#include <iostream>
#include <vector>

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

#define long long ll

int main(){
    string s;
    cin >> s;
    int n = s.size();
    vector<string> s_out;
    rep(i,n){
        if(s[i] == '0'){
            s_out.push_back("0");
        }else if(s[i] == '1'){
            s_out.push_back("1");
        }else if(s_out.size() > 0){
            s_out.pop_back();
        }
    }
    rep(i,s_out.size()){
        cout << s_out[i];
    }
    cout <<  endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		new Main().solver();
	}

	double EPS = 1e-8;

	void solver() {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] table = new char[h][w];
		for (int i = h - 1; i >= 0; i--) {
			table[i] = sc.next().toCharArray();
		}
		ArrayList<Pair> vd = new ArrayList<>();
		for (int i = 0; i <= h; i++) {
			for (int j = 0; j <= w; j++) {
				int cnt = 0;
				for (int k = 0; k < 4; k++) {
					int ni = i - (k & 1);
					int nj = j - (k >> 1);
					if (0 <= ni && ni < h && 0 <= nj && nj < w && table[ni][nj] == '#')
						cnt++;
				}
				if (cnt % 2 == 1) {
					if (0 <= i - 1 && i - 1 < h && 0 <= j && j < w && table[i - 1][j] == (cnt == 1 ? '#' : '.')) {
						// |# .|. #|
						// |# #|. .|
						// System.out.println(j + " " + i);
						if (j != 0) {
							vd.add(new Pair(((double) i) / ((double) j), 1, j, i));
						} else {
							vd.add(new Pair(1e9, 1, j, i));
						}
					}
					if (0 <= i && i < h && 0 <= j - 1 && j - 1 < w && table[i][j - 1] == (cnt == 1 ? '#' : '.')) {
						// |# #|. .|
						// |. #|# .|
						vd.add(new Pair(((double) i) / ((double) j), -1, j, i));
					}
				}
			}
		}
		vd.sort(new Comparator<Pair>() {
			@Override
			public int compare(Pair o1, Pair o2) {
				return -Double.compare(o1.a, o2.a);
			}
		});
		int res = 1, cur = 1;
		for (int i = 0; i < vd.size();) {
			int idx = i;
			while (idx < vd.size() && Math.abs(vd.get(i).a - vd.get(idx).a) < EPS) {
//				System.out.println("diff" + vd.get(idx).b + " tan" + vd.get(idx).a + " cur" + cur + " x" + vd.get(idx).x
//						+ " y" + vd.get(idx).y);
				cur += vd.get(idx).b;
				idx++;
			}
			i = idx;
			res = Math.max(cur, res);
		}
		System.out.println(res);
	}

	class Pair {
		double a;
		int b;
		int x, y;

		Pair(double a, int b, int x, int y) {
			this.a = a;
			this.b = b;
			this.x = x;
			this.y = y;
		}
	}
}

Measured memory_bytes: 42500
n = int(input())
xyh = [[int(i) for i in input().split()] for j in range(n)]
xyh.sort(key=lambda x: x[2], reverse=True)

for i in range(101):
    for j in range(101):
        h = xyh[0][2] + abs(xyh[0][0] - i) + abs(xyh[0][1] - j)
        for k in xyh:
            if k[2] == max(h - abs(k[0] - i) - abs(k[1] - j), 0):
                continue
            else:
                break
        else:
            print(i, j, h)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <tuple>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)

int main()
{

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

  int x[M];
  int diffList[M - 1];

  rep(i, M)
  {
    cin >> x[i];
  }

  sort(x + 0, x + M);

  rep(i, M)
  {
    if (i == 0)
      continue;

    int diff = abs(x[i] - x[i - 1]);
    diffList[i - 1] = diff;
  };

  int ans = 0;
  sort(diffList + 0, diffList + (M - 1));
  rep(i, M - 1 - (N - 1))
  {
    // cout << diffList[i] << endl;
    ans += diffList[i];
  };

  cout << ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define pb push_back
#define ms(a, x) memset(a, x, sizeof(a))
#define forn(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i) 
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int mod = 1e9;
const int N = 1e5+10;
/*=======================================================================*/

int dp[3050][3050];
char s[N];
char t[N];
int main()
{
    scanf("%s",s);
    scanf("%s",t);
    int n=strlen(s);
    int m=strlen(t);
    for(int i=n-1;i>=0;i--)
    {
        for(int j=m-1;j>=0;j--)
        {
            if(s[i]==t[j])
            {
                dp[i][j]=dp[i+1][j+1]+1;
            }else
            {
                dp[i][j]=max(dp[i+1][j],dp[i][j+1]);
            }
        }
    }
//    cout<<dp[n-1][m-1]<<endl;
    int i=0;
    int j=0;
    while(i<n&&j<m)
    {
        if(s[i]==t[j])
        {
            putchar(s[i]);
            i++;
            j++;
        }else if(dp[i][j]==dp[i+1][j])
        {
            i++;
        }else
        {
            j++;
        }
    }

    return 0;
}

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

using namespace std;

class cake{
public:
    long long kireisa,oishisa,ninkido;
};

long long search_max(int w1,int w2,int w3,int N,int M,vector<cake> c){
    vector<long long> score(N);
    
    for(int i=0;i<N;i++){
        score[i]= c[i].kireisa*w1+c[i].oishisa*w2+c[i].ninkido*w3;
    }
    sort(score.begin(),score.end(),greater<long long>());
    long long sum=0;
    for(int i=0;i<M;i++) sum+=score[i];
    return sum;
}

int main(){
    int N,M;   
    cin>>N>>M;
    vector<cake> c(N);
    for(int i=0;i<N;i++) cin>>c[i].kireisa>>c[i].oishisa>>c[i].ninkido;
    long long max_score=0;
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                max_score=max(max_score,search_max((i?1:-1),(j?1:-1),(k?1:-1),N,M,c));
            }
        }
    }
    
    cout<<max_score<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int i = 0; i < n; i++ ){ cout << x[i] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second
     
using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ ll x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

int n;
ll a[100010];
ll ans;

int main(){

  n = in();
  REP( i , n ){
    a[i] = in();
  }

  REP( i , n ){
    ans += a[i] / 2;
    if( a[i] % 2 == 1 and a[i+1] > 0 ){
      ans++;
      a[i+1]--;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

	static int N, A, B, C;
	static int[] ls;
	static int INF = (int) 10e8;

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

		N = in.nextInt();
		A = in.nextInt();
		B = in.nextInt();
		C = in.nextInt();
		ls = new int[N];
		for (int i = 0; i < N; i++) {
			ls[i] = in.nextInt();
		}

		int mp = dfs(0, 0, 0, 0);
		System.out.println(mp);
	}

	private static int dfs(int cur, int a, int b, int c) {
		if (cur == N) {
			if (a == 0 || b == 0 || c == 0) {
				return INF;
			}
			return Math.abs(a - A) + Math.abs(b - B) + Math.abs(c - C) - 30;
		}
		int ret0 = dfs(cur + 1, a, b, c);
		int ret1 = dfs(cur + 1, a + ls[cur], b, c) + 10;
		int ret2 = dfs(cur + 1, a, b + ls[cur], c) + 10;
		int ret3 = dfs(cur + 1, a, b, c + ls[cur]) + 10;
		return Math.min(Math.min(ret0, ret1), Math.min(ret2, ret3));
	}

}


Measured memory_bytes: 24332
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
#define ll long long
using namespace std;

ll ans;
int n,tmp;
int mp[210000];

int main()
{
	memset(mp,-1,sizeof(mp));
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&tmp);
		if(i-tmp<=0)
		{
			printf("-1\n");
			return 0;
		}
		mp[i-tmp]=tmp;
	}
	for(int i=1,last=0;i<=n;i++)
	{
		//printf("%d ",mp[i]);
		if(mp[i]==-1)continue;
		if(i+mp[i]<last+mp[last])
		{
			printf("-1\n");
			return 0;
		}
		last=i;
		ans+=mp[i];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

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

        Scanner scn = new Scanner(System.in);

        while(true){
            int count = scn.nextInt();

            if(count == 0) break;

            int[] array;
            array = new int[count];

            int max = 0;
            int min = 1000;

            int mx_i = 0;
            int mn_i = 0;
            int sum = 0;
            int ave = 0;

            for (int i = 0; i < count; i++){
                array[i] = scn.nextInt();
                if(array[i] >= max) {
                    max = array[i];
                    mx_i = i;
                }
                if(array[i] <= min) {
                    min = array[i];
                    mn_i = i;
                }
                sum += array[i];
            }

            sum = sum - array[mx_i] - array[mn_i];

            ave = sum / (count - 2);

            System.out.println(ave);
        }
    }
}


Measured memory_bytes: 29128
#include <cstdio>
#include <cstring>


int maxHeapify(int *a, int i, int h){
    int l = i*2;
    int r = i*2+1;

    int largest, tmp;
    if(l<=h and a[l]>a[i])largest = l;
    else largest = i;
    if(r<=h and a[r]>a[largest])largest = r;

    if(largest != i){
        tmp = a[i];
        a[i] = a[largest];
        a[largest] = tmp;
        return largest;
    }else return 0;
}

void heapUp(int *a, int h){
    int tmp = h;
    int hoge = 1;
    while(tmp>1 and hoge>0){
        tmp = tmp/2;
        hoge = maxHeapify(a,tmp,h);
    }
}

void heapDown(int *a, int h){
    int tmp=1;
    while(tmp>0){
        tmp = maxHeapify(a,tmp,h);
    }
}

int main(){
    int x;
    char cmd[8];
    int array[2000001];
    int tail=1;
    while(true){
        scanf("%s",cmd);
        if(strcmp(cmd,"insert")==0){
            scanf("%d",&x);
            array[tail]=x;
            tail++;
            heapUp(array, tail-1);
        }else if(strcmp(cmd,"extract")==0){
            printf("%d\n",array[1]);
            array[1] = -1;
            heapDown(array,tail-1);
        }else if(strcmp(cmd,"end")==0){
            break;
        }else return -1;
    }
    return 0;
}



Measured memory_bytes: 8556
#include <bits/stdc++.h>
using namespace std;
int arr[100100];
int barr[100100];
int j=0;
long long getmax1(int n)	{
	int retv=-1;
	for(int i=0;i<n-1;i++)	{
		if(arr[i]==arr[i+1])	{
			retv=arr[i];
			break;
		}
	}
	int cnt=0;
	for(int	i=0;i<n;i++)	{
		if(arr[i]==retv && cnt<2)	{
			cnt++;
			continue;
		}
		barr[j]=arr[i];
		j++;
	}
	return retv;
}
long long getmax2(int n)	{
	int retv=-1;
	for(int i=0;i<n-1;i++)	{
		if(barr[i]==barr[i+1])	{
			retv=barr[i];
			break;
		}
	}
	return retv;
}
int main()	{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)	{
		cin>>arr[i];
	}
	sort(arr,arr+n);
	reverse(arr,arr+n);
	long long v1=getmax1(n);
	long long v2=getmax2(j);
	if(v1==-1 || v2==-1)	{
		cout<<"0\n";
	}
	else	{
		v1=v1*v2;
		cout<<v1<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iomanip>
#include <limits>
#include <thread>
#include <utility>
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <numeric>
#include <cassert>
#include <random>
#include <chrono>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <list>
#include <functional>
#include <bitset>
#include <complex>
#include <tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double D;
typedef complex<D> P;
const ll E = 1e18 + 7;
const ll MOD = 1000000007;
#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define fill(x, y) memset(x, y, sizeof(x))
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
template <class... A>
void prints() { cout << endl; }
template <class... A>
void prints_rest() { cout << endl; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

template <class T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

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

    int N, D;
    cin >> N >> D;

    vector<vector<int>> arr;
    int in;
    rep(i, N) {
        vector<int> vec;
        rep(j, D) {
            cin >> in;
            vec.push_back(in);
        }
        arr.push_back(vec);
    }

    int ans = 0;

    rep(i, N-1) {
        REP(j, i+1, N) {
            vector<int> a,b;
            a = arr[i];
            b = arr[j];

            int sum = 0;
            rep(k, D)
                sum += pow(a[k] - b[k], 2);

            if (sum == pow(int(sqrt(sum)), 2) )
                ans++;
        }
    }

    prints(ans);

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>
#include <sstream> // std::stringstream
#include <bitset>  // std::bitset<N>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
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;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/

const ll MOD=1000000007;

ll min(ll a, ll b){
	if(a>=b){
		return b;
	}
	else{
		return a;
	}
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve()
{
	string s, t;
	cin >> s >> t;
	ll min = t.size();
	for (ll i = 0; i <= s.size() - t.size(); i++)
	{
		ll count=0;
		for (ll j = 0; j < t.size();j++)
		{
			if(s[i+j]!=t[j]){
				count++;
			}
		}
		if (count < min)
		{
			min = count;
		}
	}

	cout << min << endl;
}

int main(){
	
	solve();
	
    return 0;
}



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

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;



signed main() {
	ll a, b;
	while (cin >> a >> b) {
		ll k = a + b;
		ll ans = 0;
		while (k > 0) {
			ans++;
			k /= 10;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3048
N, M = map(int, input().split())

value_nums = [] # 価格、買える本数の順番
for _ in range(N):
  v,n = map(int, input().split())
  value_nums.append([v,n])
  
  
vn_sorted = sorted(value_nums, key = lambda x: x[0])
#print(vn_sorted)

ans = 0
for value, num in vn_sorted:
  if M >= num:
    ans += value * num
    M -= num
  elif 0 <= M < num:
    ans += value * M
    M = 0
    break
  
print(ans)

Measured memory_bytes: 21988
MOD = 2019  # これなにげに3の倍数だからいつも見たいなMODの演算が通用しない笑
L, R = list(map(int, input().split()))

# このコーナーケースに注意
if (R - L) >= MOD:
    print(0)
    exit()

# Lをなるべく0に近づける
L %= MOD
# RをなるべくLに近づけてみる
R %= MOD
if R <= L:
    R += MOD

# print(L, R)
ans = 114514
for i in range(L, R):  # i<jが成り立つ範囲に注意
    for j in range(i + 1, R + 1):
        ans = min(ans, (i * j) % MOD)
print(ans)

Measured memory_bytes: 3060
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int Q = scan.nextInt();
		int a, b, p, x;

		HashMap<Integer, ArrayList> map = new HashMap<>();
		for (int i = 0; i < N - 1; i++) {
			a = scan.nextInt();
			b = scan.nextInt();
			if (!map.containsKey(a)) {
				ArrayList<Integer> list = new ArrayList<>();
				map.put(a, list);
			}
			map.get(a).add(b);

			if (!map.containsKey(b)) {
				ArrayList<Integer> list = new ArrayList<>();
				map.put(b, list);
			}
			map.get(b).add(a);
		}

		int[] score = new int[N];
		for (int i = 0; i < Q; i++) {
			p = scan.nextInt();
			x = scan.nextInt();
			score[p - 1] += x;
		}

		ArrayDeque<Integer> que = new ArrayDeque();
		que.offer(1);
		boolean[] visited = new boolean[N];

		while (!que.isEmpty()) {
			int tgt = que.poll();
			ArrayList<Integer> list = map.get(tgt);
			visited[tgt - 1] = true;
			for (int i = 0; i < list.size(); i++) {
				int next = list.get(i);
				if (!visited[next - 1]) {
					score[next - 1] += score[tgt - 1];
					que.offer(next);
				}
			}
		}

		// 結果の出力
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < N; i++) {
			sb.append(score[i]).append(" ");
		}
		System.out.println(sb);
	}
}

Measured memory_bytes: 221608
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace debug
{
    class main
    {
        static void Main(string[] args)
        {
            //問題クラスを展開
            ProgramB a = new ProgramB();
            a.main();//実行する

        }

    }

    //ABC096
    class ProgramA
    {
        public void main()
        {
            //入力
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);


            if (a<= b)
                Console.WriteLine(a);
            else
                Console.WriteLine(a-1);

        }
    }

    class ProgramB
    {
        public void main()
        {
            //入力
            string[] s = Console.ReadLine().Split(' ');

            int[] num = new int[3];

            for (int i = 0; i < 3; i++)
                num[i] = int.Parse(s[i]);

            Array.Sort(num);

            int k = int.Parse(Console.ReadLine());

            Console.WriteLine(num[0]+num[1]+num[2] * Math.Pow(2,k));
        }

        
    }

    class ProgramC
    {
        public void main()
        {

            //入力
            string s = Console.ReadLine();
            int k = int.Parse(Console.ReadLine());

            List<string> ans = new List<string>();

            //kが5文字以下が答えの候補なので入れて考えてみる
            for(int j = 1; j <= 5;j++)
                for (int i = 0;i < s.Length + 1 - j;i++)
                {
                    if(!ans.Contains(s.Substring(i, j)))
                        ans.Add(s.Substring(i, j));
                }
            
            //ソートする
            ans.Sort();

            //答え出力
            Console.WriteLine(ans[k -1]);

        }

        
    }



    class ProgramD
    {
        public void main()
        {

            //入力
            int n = int.Parse(Console.ReadLine());

            List<int> a = new List<int>(10000);

            for (int i = 0; i < 10000; i++)
                a.Add(i + 2);

            //10000までの素数を出す
            for(int i = 2;i <= Math.Sqrt(10000);i++)
            {
                List<int> t = new List<int>(10000);
                foreach (var s in a)
                {
                    if (s % i == 0 && s / i != 1)
                        t.Add(s);
                }

                foreach (var s in t)
                {
                    a.Remove(s);
                }


            }

            //5で割ったあまりが1だけのものを出す
            int count = 0;
            foreach (var s in a)
            {
                if (s % 5 == 1)
                {
                    Console.Write(s + " ");
                    count++;
                }

                if (count == n)
                    break;
            }
            
        }
    }

    


}






Measured memory_bytes: 27888
import sys
input = sys.stdin.buffer.readline

N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)][::-1]

A, B, C = sorted([A, B, C])

answer = 10 ** 15
for i in range(4 ** N):
  x =[0] * 3
  tmp = 0
  for j in range(N):
    index = (i // (4 ** j)) % 4
    if index != 3:
      if x[index]:
        tmp += 10
      x[index] += L[j]
  x.sort()
  if x[0] != 0:
    tmp += abs(x[0] - A) + abs(x[1] - B) + abs(x[2] - C)
    answer = min(answer, tmp)

print(answer)

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

vector<long long> bucket(200005,0);

int main(){
    int n;
    cin>>n;
    bucket.resize(n);
    vector<long long> a(n);
    for(int i=0;i<n;++i){
        int temp; cin>>temp;
        --temp;
        a[i]=temp;
        ++bucket[temp];
    }

    long long sum=0;
    for(int i=0;i<n;++i) sum+=bucket[i]*(bucket[i]-1)/2;
    for(int i=0;i<n;++i){
        long long temp=bucket[a[i]];
        long long before=temp*(temp-1)/2;
        long long after=(temp-1)*(temp-2)/2;
        //cout<<"i: "<<i<<" bucket: "<<bucket[t]<<" before: "<<comb[t]<<" after: "<<(bucket[t]-2)*(bucket[t]-1)/2<<endl;
        long long ans=sum-before+after;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 6404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define mp make_pair
const int maxn = 4e2+5;
const int MOD = 1e9+7;
#define mod(x) x % MOD
#define INF 1ll << 60

ll a[maxn];
ll dp1[maxn][maxn];
ll dp2[maxn][maxn];

int main(){
    int n = 0;
    while(~scanf("%d", &n)){
        for(int i = 1;i <= n;i++){
            for(int j = 1;j <= n;j++){
                dp1[i][j] = INF;
                dp2[i][j] = INF;
            }
        }
        for(int i = 1;i <= n;i++){
            scanf("%lld", a + i);
            dp1[i][i] = a[i];
            dp2[i][i] = 0;
        }
        for(int len = 1;len < n;len++){
            for(int i = 1;i + len <= n;i++){
                int j = i + len;
                for(int k = i;k <= j;k++){
                    //cout<<"ha"<<endl;
                    dp1[i][j] = min(dp1[i][j], dp1[i][k] + dp1[k+1][j]);
                    dp2[i][j] = min(dp2[i][j], dp2[i][k] + dp2[k + 1][j] + dp1[i][j]);
                }    
            }
        } 
        
        // for(int i = 1;i <= n;i++){
        //     for(int j = 1;j <= n;j++){
        //         printf("%lld%c", dp2[i][j], j == n ? '\n' : ' ');
        //     }
        // }
        printf("%lld\n",dp2[1][n]);
    }    
    return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int N, K;
    cin >> N >> K;
    vector<int> okasi(N);
    REP(i, K) {
        int d;
        cin >> d;
        REP(j, d) {
            int A;
            cin >> A;
            okasi[A-1]++;
        }
    }
    int ans = 0;
    REP(i, N) {
        if(okasi[i] == 0) ans++;
    }
    cout << ans << endl;
}

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

const int max_v = 1e5;
ll num[max_v + 1];

int main() {
  int n;
  cin >> n;
  fill(num, num+max_v+1, 0LL);
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    num[a]++;
    ans += a;
  }

  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    ll b, c;
    cin >> b >> c;
    ans += (c - b) * num[b];
    num[c] += num[b];
    num[b] = 0LL;
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 4356
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K,X,Y;
  cin>>N>>K>>X>>Y;
  if(N>K){ 
  cout<<K*X+(N-K)*Y<<endl;
  }
  else{
    cout<<N*X<<endl;
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(void){
    string n;

    cin >> n;

    if(n[0]=='1')n[0]='9';
    else if(n[0]=='9')n[0]='1';

    if(n[1]=='1')n[1]='9';
    else if(n[1]=='9')n[1]='1';

    if(n[2]=='1')n[2]='9';
    else if(n[2]=='9')n[2]='1';

    cout << n << endl;

    return 0;
}

Measured memory_bytes: 256
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
template<typename X,typename M>
  struct segtree{
    using FX=function<X(X,X)>;
    using FA=function<X(X,M)>;
    using FM=function<M(M,M)>;
    int n;
    FX fx;
    FA fa;
    FM fm;
    const X ex;
    const M em;
    vector<X> dat;
    vector<M> lazy;
    segtree(int n_,FX fx_,FA fa_,FM fm_,X ex_,M em_)
      :n(),fx(fx_),fa(fa_),fm(fm_),ex(ex_),em(em_),dat(n_*4,ex),lazy(n_*4,em){
        int x=1;
        while(n_>x){
          x*=2;
        }
        n=x;
      }
    void set(int i,X x){
      dat[i+n-1]=x;
    }
    void build(){
      for(int k=n-2;k>=0;k--){
        dat[k]=fx(dat[2*k+1],dat[2*k+2]);
      }
    }
    void eval(int k){
      if(lazy[k]==em){
        return;
      }
      if(k<n-1){
        lazy[k*2+1]=fm(lazy[k*2+1],lazy[k]);
        lazy[k*2+2]=fm(lazy[k*2+2],lazy[k]);
      }
      dat[k]=fa(dat[k],lazy[k]);
      lazy[k]=em;
    }
    void update(int a,int b,M x,int k,int l,int r){
      eval(k);
      if(a<=l && r<=b){
        lazy[k]=fm(lazy[k],x);
        eval(k);
      }
      else if(a<r && l<b){
        update(a,b,x,k*2+1,l,(l+r)/2);
        update(a,b,x,k*2+2,(l+r)/2,r);
        dat[k]=fx(dat[k*2+1],dat[k*2+2]);
      }
    }
    void update(int a,int b,M x){
      update(a,b,x,0,0,n);
    }
    X query_sub(int a,int b,int k,int l,int r){
      eval(k);
      if(r<=a  || b<=l){
        return ex;
      }
      else if(a<=l && r<=b){
        return dat[k];
      }
      else{
        X vl=query_sub(a,b,k*2+1,l,(l+r)/2);
        X vr=query_sub(a,b,k*2+2,(l+r)/2,r);
        return fx(vl,vr);
      }
    }
    X query(int a,int b){
      return query_sub(a,b,0,0,n);
    }
  };
int main(){
  using X=long long;
  using M=long long;
  auto fx=[](X x1,X x2) -> X{return min(x1,x2);};
  auto fa=[](X x,M m) -> X{return m;};
  auto fm=[](M m1,M m2) -> M{return m2;};
  long long ex=2147483647;
  long long em=2147483647;
  segtree<X,M> seg(100010,fx,fa,fm,ex,em);
  int n,q;
  cin >> n >> q;
  int a,b,c,i;
  ll d;
  for(i=0;i<q;i++){
    cin >> a;
    if(a==0){
      cin >> b >> c >> d;
      seg.update(b,c+1,d);
    }
    else{
      cin >> b >> c;
      cout << seg.query(b,c+1) << endl;
    }
  }
  return 0;
}


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

int main() {
	int x, y;
	cin >> x >> y;
	x--, y--;

	int group[12] = {1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
	if (group[x] == group[y])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
using namespace std;

#define __int64 long long
#define long __int64
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vec = 4;
const int Vecy[Vec] = {0,-1,0,1};
const int Vecx[Vec] = {1,0,-1,0};
const int Modd = 1000000007;

vector<vector<int>> datas;
bitset<10> bs;
vector<int> teacher;

bool isOk(){
    for(int i=0; i<datas.size(); i++){
        int count = 0;
        for(int j=0; j<datas[i].size(); j++){
            count += bs[datas[i][j] - 1];
        }

        if(count % 2 != teacher[i]) return false;
    }

    return true;
}

int main(){
    int n,m;
    int ans = 0;
    cin >> n >> m;

    rep(i,m){
        int k;
        cin >> k;
        vector<int> sub;
        rep(j, k){
            int s;
            cin >> s;
            sub.push_back(s);
        }
        datas.push_back(sub);
    }

    rep(i, m){
        int t;
        cin >> t;
        teacher.push_back(t);
    }

    ans = 0;
    for(int i=0; i<pow(2, n); i++){
        bs = i;
        if(isOk()) ans ++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

template<typename T> bool chmin(T& a, const T& b) {
    if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
    if (a < b) return a = b, true; else return false;
}

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    int h, a;
    cin >> h >> a;
    print(int(ceil(double(h) / a)));

    return 0;
}



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

int main() {

	//S > T
	string S;
	string T;

	do {

		cin >> S;
		cin >> T;


	} while (S.length() - T.length() < 0 && S.length() >=1000 && T.length() >= 1000);

	int min_num = 10001;
	for (int i = 0; i < S.length() - T.length()+1; i++) {


		int count_num = 0;

		for (int j = 0; j < T.length(); j++) {
			

			if (S[i + j] != T[j]) {
				count_num++;
			}

		}

		if (count_num < min_num) {
			min_num = count_num;
		}


	}

	cout << min_num;


	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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

    if (s[0] != 'A')
    {
        printf("WA");
        return 0;
    }

    int count = 0;
    int index = -1;
    for (int i = 2; i < s.size()-1; i++)
    {
       if (s[i] == 'C')
       {
           count++;
           index = i;
       }
    }
    
    if (count != 1)
    {
        printf("WA");
        return 0;
    }

    for (int i = 0; i < s.size(); i++)
    {
        if (i == 0 || i == index)
        {
            continue;
        }
        
        if (isupper(s[i]))
        {
            printf("WA");
            return 0;
        }  
    }
    
    printf("AC");
    return 0;
}

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

int main() {
	int a,b,c,k; scanf("%d%d%d%d",&a,&b,&c,&k);
	int ans = min(a,k) - (a+b<k) * min(k-a-b,c);
	printf("%d",ans);
}

Measured memory_bytes: 3808
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

const int INF = 1e6;

using namespace std;

int n,a,b,c;
int l[10];

int solve (int at, int bt, int ct, int cur)
{
    if (cur==n)
    {
        if (min({at,bt,ct})>0)
            return abs(a-at)+abs(b-bt)+abs(c-ct)-30;
        else
            return INF;
    }
    int r1=solve(at,bt,ct,cur+1);
    int r2=solve(at+l[cur],bt,ct,cur+1)+10;
    int r3=solve(at,bt+l[cur],ct,cur+1)+10;
    int r4=solve(at,bt,ct+l[cur],cur+1)+10;
    return min({r1,r2,r3,r4});
}

main()
{
    fast;
    int i;
    cin>>n>>a>>b>>c;
    for (i=0;i<n;i++)
        cin>>l[i];
    int ans=solve(0,0,0,0);
    cout<<ans<<endl;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector< vector<int> > A(H, vector<int>(W));
  for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> A[i][j];

  int ans = 1000000000;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int cost = 0;
      for (int m = 0; m < H; m++)
        for (int n = 0; n < W; n++) cost += A[m][n] * min(abs(i - m), abs(j - n));
      ans = min(cost, ans);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3156
#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,Y;
  cin >> N >> Y;
  ll a=10000,b=5000,c=1000;
  for(ll x=Y/a;x>=0;x--) {
    ll money=Y,num;
    money = Y-x*a;
    for(ll y=money/b;y>=0;y--) {
      money = Y-x*a-y*b;
      ll z=money/c;
      num=x+y+z;
      if(num==N) {
        cout << x << " " << y << " " << z << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

vector<vector<vector<pair<int, int> > > > graph(2, vector<vector<pair<int, int> > >(100001));

vector<long long int> dijkstra(int s, int index)
{
	vector<long long int> result(100001, -1);
	priority_queue<pair<long long int, int> > qu;
	qu.push(make_pair(0, s));
	while(!qu.empty()){
		long long int nowc = -(qu.top()).first;
		int nowt = (qu.top()).second;
		qu.pop();
		if(result[nowt] >= 0) continue;
		result[nowt] = nowc;
		for(int i = 0; i < graph[index][nowt].size(); i++){
			int nextt = graph[index][nowt][i].first;
			long long int nextc = graph[index][nowt][i].second;
			if(result[nextt] >= 0) continue;
			qu.push(make_pair(-(nowc + nextc), nextt));
		}
	}
	return result;
}


int main()
{
	int n, m, s, t;
	cin >> n >> m >> s >> t;
	s--;
	t--;
	for(int i = 0; i < m; i++){
		int u, v;
		int a[2];
		cin >> u >> v >> a[0] >> a[1];
		u--;
		v--;
		for(int j = 0; j < 2; j++){
			graph[j][u].push_back(make_pair(v, a[j]));
			graph[j][v].push_back(make_pair(u, a[j]));
		}
	}
	vector<long long int> needyen_from_s = dijkstra(s, 0);
	vector<long long int> needsnuuk_to_t = dijkstra(t, 1);
	long long int init = (long long int)pow(10, 15);
	vector<long long int> ans(100001);
	ans[n - 1] = init - needyen_from_s[n - 1] - needsnuuk_to_t[n - 1];
	for(int i = n - 2; i >= 0; i--){
		// cout << needyen_from_s[i] << " " << needsnuuk_to_t[i] << endl;
		ans[i] = max(ans[i + 1], init - needyen_from_s[i] - needsnuuk_to_t[i]);
	}
	for(int i = 0; i < n; i++){
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 16984