akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

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

  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }

  vector<int> dp(N, 0);
  for (int i = 1; i < N; i++) {
    int minn = 1000000000;
    for (int j = 1; j <= K; j++) {
      if (i - j < 0)
        break;
      minn = min(minn, dp[i - j] + abs(H[i] - H[i - j]));
    }
    dp[i] = minn;
  }
  cout << dp[N - 1] << endl;

  return 0;
}


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

#define inf 2000000009
#define ff first 
#define ss second 

typedef long long ll; 
int main(){
	int n,m; cin>>n>>m; 
	vector<pair<int,int> > v; 
	for(int i=0;i<m;i++){
		int a,b; cin>>a>>b; 
		v.push_back({b,a}); 
	}
	sort(v.begin(),v.end()); 
	int p=v[0].ff; 
	int ans=1; 
	for(int i=1;i<v.size();i++){
		if(v[i].ss>=p){
			ans++; 
			p=v[i].ff; 
		}
	}	
	cout<<ans; 

}

Measured memory_bytes: 1400
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	n, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return n
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	A := [4][3][10]int{}
	n := nextInt(sc)
	for i := 0; i < n; i++ {
		b := nextInt(sc) - 1
		f := nextInt(sc) - 1
		r := nextInt(sc) - 1
		A[b][f][r] += nextInt(sc)
	}
	for i, bs := range A {
		for _, fs := range bs {
			for _, r := range fs {
				fmt.Printf(" %d", r)
			}
			fmt.Println()
		}
		if i != len(A)-1 {
			fmt.Println("####################")
		}
	}

}



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

int main() {
  
  int a, b;
  cin >> a >> b;
  
  if(a < b) {
    for(int i = 0; i < b; i++) cout << a;
    cout << endl;
  }
  
  else for(int i = 0; i < a; i++) cout << b;
  cout << endl;
    
}

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

vector<pair<long long, long long> > prime_factorize(long long N) {
  vector<pair<long long, long long> > res;
  for (long long a = 2; a * a <= N; ++a) {
    if (N % a != 0) continue;
    long long ex = 0;  // 指数

    // 割れる限り割り続ける
    while (N % a == 0) {
      ++ex;
      N /= a;
    }

    // その結果を push
    res.push_back({a, ex});
  }

  // 最後に残った数について
  if (N != 1) res.push_back({N, 1});
  return res;
}

int main() {
  ll n;
  cin >> n;
  const auto &res = prime_factorize(n);
  int ans = 0;
  if (n == 1) {
    cout << 0 << endl;
  } else {
    for (auto p : res) {
      ll count = 0;
      ll sub = 1;
      ll n1 = p.second;
      while (n1 > 0) {
        n1 -= sub;
        if (n1 >= 0) {
          sub++;
          count++;
        }
      }
      ans += count;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3588
N,Q=map(int,input().split())
S=input()
t=[0,0]
for i in range(2,N+1):
    t.append(t[-1]+(S[i-2:i]=='AC'))
for _ in range(Q):
    l,r=map(int,input().split())
    print(t[r]-t[l])

Measured memory_bytes: 7684
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>

using namespace std;

namespace {

}
int main()
{
	int N = 0;
	cin >> N;

	vector<int> vctA(N);
	vector<int> vctB(N);
	vector<int> vctC(N);

	for (auto& elem : vctA) {
		cin >> elem;
	}
	for (auto& elem : vctB) {
		cin >> elem;
	}
	for (auto& elem : vctC) {
		cin >> elem;
	}

	sort(vctA.begin(), vctA.end());
	sort(vctB.begin(), vctB.end());
	sort(vctC.begin(), vctC.end());

	// Bに対してAの個数のBによるループ
	vector<long long> vctSumBa(N, 0);
	long long sumA = 0;
	for (int i = 0; i < N; ++i) {
		auto itr = lower_bound(vctA.begin(), vctA.end(), vctB[i]);
		if (itr == vctA.begin()) {
			continue;
		}
		int numA = 0;

		if (itr == vctA.end()) {
			numA = N;
		}
		else {
			numA = itr - vctA.begin();
		}
		sumA += numA;
		vctSumBa[i] = sumA;
	}

	// Cに対してBの個数のCによるループ
	long long sumBAll = 0;
	for (int i = 0; i < N; i++) {
		auto itm = lower_bound(vctB.begin(), vctB.end(), vctC[i]);
		if (itm == vctB.begin()) {
			continue;
		}
		long long curSumB = 0;

		if (itm == vctB.end()) {
			curSumB = vctSumBa[N - 1];
		}
		else {
			curSumB = vctSumBa[itm - vctB.begin() - 1];

		}
		sumBAll += curSumB;
	}

	// 全体の合計
	cout << sumBAll;

	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll N, K;
  cin >> N >> K;

  map<ll, ll> m;
  rep(i, N) {
    ll a, b;
    cin >> a >> b;
    m[a] += b;
  }

  ll count = 0;
  for (auto mm : m) {
    count += mm.second;
    if (count >= K) {
      RETURN(mm.first);
    }
  }
  return 0;
}

Measured memory_bytes: 7604
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
using ll = int64_t; using ull = uint64_t; using ld = long double;

// -----------------------------------------------------------------------------

const int N = 1e5 + 5;
int a[N];

int main() {
    fast_io;
    int n; cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int ans = 1, d = 0, cnt = 1;
    for (int i = 1; i < n; ++i) {
        int cd = 0;
        if (a[i] < a[i - 1]) cd = -1;
        if (a[i] > a[i - 1]) cd = 1;
        if (d == 0) {
            d = cd;
            continue;
        }
        if (cd == 0 || cd == d) {
            continue;
        }
        ++ans;
        d = 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)
int H,A[MAX+1];
void maxHeapify(int i){
  int l,r,largest;
  l=2*i;
  r=2*i+1;
  if(l<=H && A[l]>A[i])largest=l;
  else largest=i;
  if(r<=H && A[r]>A[largest])largest=r;
  if(largest !=i){
    swap(A[i],A[largest]);
    maxHeapify(largest);
  }
}
int extract(){
  int maxv;
  if(H<1)return -INFTY;
  maxv=A[1];
  A[1]=A[H--];
  maxHeapify(1);
  return maxv;
}
void increaseKey(int i,int key){
  if(key<A[i])return;
  A[i]=key;
  while(i>1 && A[i/2]<A[i]){
    swap(A[i],A[i/2]);
    i=i/2;
  }
}
void insert(int key){
  H++;
  A[H]= -INFTY;
  increaseKey(H,key);
}
int main(){
  int key;
  char com[10];
  while(1){
    scanf("%s",com);
    if(com[0]=='e' && com[1]=='n')break;
    if(com[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }else{printf("%d\n",extract());
    }
  }
  return 0;
}

Measured memory_bytes: 7124
#include <bits/stdc++.h> // Include every standard library
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;

typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpl;
double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1.0);
int dirx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };
int diry[8] = { 0, 1, -1, 0, -1, 1, -1, 1 };

#ifdef TESTING
#define DEBUG fprintf(stderr, "====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define DEBUG
#define VALUE(x)
#define debug(...)
#endif
#define REP(i,a,b) for (ll i = a; i <= b; i++)
#define sqr(x) ((ll)(x) * (x))
#define reset(a,b) memset(a, b, sizeof(a))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define len(v) (ll)v.size()
#define srt(v) sort( v.begin(), v.end())
#define rsrt(v) sort( v.rbegin(), v.rend())
#define rvrs(v) reverse( v.begin(), v.end())
#define PERMUTE next_permutation
#define tc(t) while (t--)
#define sc1(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld %lld",&a,&b)
#define sc4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define yes printf("YES\n")
#define no printf("NO\n")
#define minus1  printf("-1\n")
#define space printf(" ")
#define pf1(a) printf("%lld",a)
#define pf2(a,b) printf("%lld %lld",a,b)
#define case(a) printf("Case %lld: ",a)
#define ses printf("\n")
bool odd(ll n){if(n&1)return true;return false;}
//ll xor(ll a,ll b)return a^b;
ll power(ll x, ll y,ll M){ll res=1;while(y>0){ if(y&1)res=(res*x)%M;y=(y>>1)%M;x=(x*x)%M;}return res;}
ll mx(ll a,ll b){if(a>=b)return a;return b;}
ll mn(ll a,ll b){if(a<=b)return a;return b;}
int main()
{
    int k;
    cin>>k;
    cout<<k+sqr(k)+k*sqr(k)<<endl;
}



Measured memory_bytes: 3544
while True:
    s = input().split()
    a = int(s[0])
    b = int(s[2])

    if s[1]=="?":
       break
    if s[1]=="+":
        print(a+b)
    if s[1]=="-":
        print(a-b)
    if s[1]=="*":
        print(a*b)
    if s[1]=="/" :
        print(a//b)


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

int main(){
  int n;
  cin >> n;
  
  vector<int> kazu(n);
  for(int i=0; i<n; i++){
    cin >> kazu.at(i);
  }
  
  sort(kazu.begin(), kazu.end());
  reverse(kazu.begin(), kazu.end());
  
  int Alice=0;
  int Bob=0;
  
  for (int i=0; i<n; i++){
    if (i%2 == 0){
      Alice += kazu.at(i);
    }
    else{
      Bob += kazu.at(i);
    }
  }
  
  cout << Alice - Bob << endl;
}

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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll ans = 0;
  int n;
  cin >> n;
  string s;
  cin >> s;
  ll tmp = 0;
  rep(i, n) {
    if(s[i] == 'I')
      tmp++;
    else
      tmp--;
    chmax(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int N; cin >> N;
  string X; cin >> X;
  int cnt = 0;
  rep(i,N) if (X[i]=='1') cnt++;
  if (cnt==0){
    rep(i,N) cout << 1 << endl;
    return 0;
  }
  
  int pow2 = 1;
  int pow2mod[N][2];  
  rep(i,N){
    rep(j,2){
      int MOD = cnt+2*j-1;
      if (MOD==0){
        pow2mod[i][j] = 0;
        continue;
      }
      if (i==0) {
        pow2mod[0][j] = pow2%MOD;
        continue;
      } 
      pow2mod[i][j] = (pow2mod[i-1][j]*2)%MOD;
      //cout << pow2mod[i][j] << " " << pow_mod(2,i,MOD) << endl;
    }
  }


  int Xint_mod[2] = {0,0};
  rep(i,N){
    rep(j,2){
      int MOD = cnt+2*j-1;
      if (MOD==0) {
        Xint_mod[j] = 0;
        continue;
      }
      if (X[i]=='1') (Xint_mod[j] += pow2mod[N-1-i][j]) %= MOD;
    }
  }

  vector<int> f(200009,0);
  f[0] = 0;
  for (int i=1;i<=200008;i++){
    bitset<30> s(i);
    int p = s.count();
    f[i] = f[i%p] + 1;
  }

  /*
  rep(i,30){
    cout << i << " " << f[i] << endl;
  }
  */

  rep(i,N){
    if (X[i]=='1'){ // j=0に相当
      int MOD = cnt-1;
      if (MOD==0) {
        cout << 0 << endl;
        continue;
      }
      ll tmp = (Xint_mod[0]-pow2mod[N-1-i][0]+MOD)%MOD;
      ll ans = f[tmp] + 1;
      cout << ans << endl;
    }
    else { // j=1に相当
      int MOD = cnt+1;
      ll tmp = (Xint_mod[1]+pow2mod[N-1-i][1]+MOD)%MOD;
      ll ans = f[tmp] + 1;
      cout << ans << endl;
    }
  }
  




  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 6020
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n: usize = read_as_vec()[0];
    let mut a = read_as_vec::<i64>();
    let mut b = read_as_vec::<i64>();

    if a.iter().sum::<i64>() > b.iter().sum::<i64>(){
        println!("No");
        return;
    }

    let mut ops = b.iter().sum::<i64>() - a.iter().sum::<i64>();
    let (mut aops, mut bops) = (0, 0);
    for i in 0..n{
        if a[i] < b[i]{
            let c = (b[i]-a[i]+1)/2;
            aops += c;
            if (b[i]-a[i])%2 == 0{
                a[i] = b[i];
            }else{
                b[i] += 1;
                bops += 1;

                a[i] = b[i];
            }
        }else if b[i] < a[i]{
            bops += a[i] - b[i];
            b[i] = a[i];
        }
    }

    if aops <= ops && bops <= ops && (ops-aops)*2 == (ops-bops){
        println!("Yes");
    }else{
        println!("No");
    }
}


Measured memory_bytes: 4352
#D問題
N,M=map(int,input().split())

def warshall_floyd(dist,n):
    #dist[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                dist[i][j] = min(dist[i][j],dist[i][k] + dist[k][j])
    return dist

dist = [[float("inf") for i in range(N)] for i in range(N)] 
#dist[u][v] : 辺uvのコスト(存在しないときはinf)
xyz=[]
for i in range(M):
    x,y,z = map(int,input().split())
    xyz.append([x-1,y-1,z])
    dist[x-1][y-1] = z
    dist[y-1][x-1] = z
for i in range(N):
    dist[i][i] = 0 #自身のところに行くコストは０
wf=warshall_floyd(dist,N)
ans=M
for i in range(M):
    j=0
    flag=0
    for j in range(N):
        if wf[j][xyz[i][0]] + xyz[i][2] == wf[j][xyz[i][1]]:
            flag=1
            break
    if flag == 1:
        ans-=1
    flag=0
print(ans)

Measured memory_bytes: 3688
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=2000+10,mo=1000000007;
int f[2][maxn][2],sum[maxn];
int i,j,k,l,t,n,m,ans,now;
int main(){
	scanf("%d%d%d",&n,&m,&k);
	m--;k--;
	fo(i,1,k) f[0][i][1]=1;
	f[0][0][0]=1;
	fo(i,0,n)
		if (k-i<=m&&i%k==n%k&&(k-i)%k==m%k) (ans+=f[0][i][1])%=mo;
	now=0;
	fo(i,2,max(n,m)*2){
		now=1-now;
		fo(j,0,n) sum[j+1]=(sum[j]+(f[1-now][j][0]+f[1-now][j][1])%mo)%mo;
		fo(j,0,n){
			f[now][j][0]=(sum[j+1]-sum[j])%mo;
			l=max(j-k,0);
			f[now][j][1]=(sum[j]-sum[l])%mo;
		}
		fo(j,0,n)
			if (k*i-j<=m&&j%k==n%k&&(k*i-j)%k==m%k) (ans+=f[now][j][1])%=mo;
	}
	(ans+=mo)%=mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
vector<ll> adj[100005];
ll visited[100005];
ll dfs(ll x)
{
	if(visited[x]==1)
	return 0;
	else
	{
		visited[x]=1;
		for(ll s=0;s<adj[x].size();s++)
		dfs(adj[x][s]);
	}
	return 0;
}
int main()
{
ll n;
ll m;
cin>>n>>m;
for(ll i=0;i<m;i++)
{
	ll a;ll b;
	cin>>a>>b;
	adj[a].push_back(b);
	adj[b].push_back(a);
}
for(ll i=0;i<100005;i++)
visited[i]=-1;ll ans=0;
for(ll i=1;i<=n;i++)
{
	
	if(visited[i]==-1)
	{ans++;
		ll z=dfs(i);
	}
}ll v=0;
cout<<max(v,ans-1)<<endl;
return 0;
}

Measured memory_bytes: 11464
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <string>
#include <chrono>
#include <random>

using namespace std;

#define sqr(x) x * x
#define all(x) x.begin(), x.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
typedef long long ll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve() {
	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200)
		cout << s;
	else
		cout << "red" << endl;
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
# coding:utf-8

n = int(input())

a_arr = [a for a in map(int, input().split())]

a_ave = sum(a_arr)/n

min_frame_num = 0
for i in range(len(a_arr)):
    if i==0:
        min_frame_num = 0
        min_frame = abs(a_ave-a_arr[i])
    if min_frame > abs(a_ave-a_arr[i]):
        min_frame_num = i
        min_frame = abs(a_ave-a_arr[i])


print(min_frame_num)


Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main(){
	int N,K,gomi;
	scanf("%d %d",&N,&K);
	for(int i=0;i<N;i++){
		scanf("%d",&gomi);
	}
	printf("%d\n",(N+K-3)/(K-1));
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<string>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
using namespace std;
string s;
int main(void)
{
    sync;
    cin>>s;
    ll sum=0;
    for(char x:s)
    {
        sum+=(ll)(x-'0');
        sum%=9;
    }
    if(sum%9)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 3364
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

long long int ipow(long long int x, long long int y) {
    long long int temp = 1;
    for (long long int i = 0; i < y; i++) {
        temp *= x;
    }
    return temp;
}


int main() {
    long long int x;
    cin >> x;
    vector<long long int>jm;
    vector<long long int>jp;

    for (int i = 0; i < 1001; i++) {
        jm.push_back(ipow(-i, 5));
        jp.push_back(ipow(i, 5));
    }

    long long int tempa, tempb;

    for (int i = -1000; i < 1001; i++) {
        for (int j = -1000; j < 1001; j++) {
            if (i < 0) {
                tempa = jm[-i];
            } else {
                tempa = jp[i];
            }
            if (j < 0) {
                tempb = jm[-j];
            } else
            {
                tempb = jp[j];
            }
            if (tempa - tempb == x) {
                cout << i << " " << j;
                return 0;
            }
        }
    }



    return 0;
}

Measured memory_bytes: 3648
S = list(input())
for i in range(len(S)):
  if S[0] == "K":
    S.insert(0,"A")
for i in range(len(S)):
  if S[i] == "H" and S[i+1] != "A":
    S.insert(i+1,"A")
for i in range(len(S)):
  if S[i] == "B" and S[i+1] != "A":
    S.insert(i+1,"A")
for i in range(len(S)):
  if S[-1] == "R":
    S.append("A")

if "".join(S) == "AKIHABARA":
  print("YES")
else:
  print("NO")


Measured memory_bytes: 62020
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<61;
int iinf=1<<30;
double pi=3.141592653589793238462643383279L;
double eps=1e-8;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
//#define endl "\n"
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<int,int,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int a;cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;

int main(){
    ll n;
    cin>>n;
    double a[110];
    rep(i,0,n) cin>>a[i];
    double sum=0;
    rep(i,0,n)sum+=1/a[i];
    printf("%.12lf",1/sum);
   
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
//        string[] read = ReadLine().Split(' ');
//        int read_leng = read.Length;
//        int[] readR = new int[mochinum];
        int place = int.Parse(ReadLine());
        int NowTime = 0;
        int NowX = 0;
        int NowY = 0;
        
        string ans = "Yes";
        
        for(int i=0;i<place;i++){
            string[] read_txy = ReadLine().Split(' ');
            int time = int.Parse(read_txy[0]);
            int x = int.Parse(read_txy[1]);
            int y = int.Parse(read_txy[2]);
            int distance = Abs(x-NowX) + Abs(y-NowY);
            int time_sa = Abs(time - NowTime);
            if((time_sa - distance)%2 == 0 && time_sa >= distance){
                NowX = x;
                NowY = y;
                NowTime = time;
            }else{
                ans = "No";
                break;
            }
        }
        WriteLine(ans);
    }
}


Measured memory_bytes: 17336
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <fstream>
#include <cassert>
using namespace std;

//common
typedef long long i64,ll;

#define BR "\n"
#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,r) for(int i=(l);i<(int)(r);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

//debug
#ifdef NDEBUG
#define DUMP(x)
#define DUMPLN(x)
#define DEBUG(x)
#define DEBUGLN(x)
#define LINE()
#define LINELN()
#define CHECK(exp,act)
#define STOP(e)
#else
#define DUMP(x)  cerr << #x << " = " << (x)
#define DUMPLN(x)  DUMP(x) <<endl
#define DEBUG(x) DUMP(x) << LINE() << " " << __FILE__
#define DEBUGLN(x) DEBUG(x)<<endl
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl
#define CHECK(exp,act)  if(exp!=act){DUMPLN(exp);DEBUGLN(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}

template<class T> inline string toString(const vector<vector<T> >& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

string BITtoString(int bit){
    stringstream ss;
    while(bit!=0){ss<<(bit%2);bit/=2;}
    string res=ss.str();reverse(ALL(res));
    return res;
}

template<typename T,typename V> inline T pmod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}


ll MOD=1000000007;

class Main{
public:
	
	void run(){
        REP(i,4){
            int t,n;cin >> t >> n;
            if(t==1)cout <<6000*n<<endl;
            if(t==2)cout <<4000*n<<endl;
            if(t==3)cout <<3000*n<<endl;
            if(t==4)cout <<2000*n<<endl;
        }
	}
};

 int main(){
	//ios::sync_with_stdio(false);
 	Main().run();
 	return 0;
 }

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

int main()
{
int i;
int N;
int K;
int X;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> K;

	X = 1;
	for( i = 0; i < N; i++ )
	{
		if( X < K )
			X *= 2;
		else
			X += K;
	}

	cout << X << endl;

	return 0;
}






Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math

N = int(input())

sum_min = 10**12+1
ab = None

for a in range(1, int(math.sqrt(N))+1):
    if N % a == 0:
        b = N//a
        if b >= a and a+b-2 < sum_min:
            sum_min = a+b-2
            ab = (a, b)

print(sum_min)

Measured memory_bytes: 3060
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
using namespace std;
#define fastestiointhewest   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll          long long
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define mii         map<int,int>
#define vi          vector<int>
#define vll         vector<long long>
#define all(a)      (a).begin(),(a).end()
#define clz(a)      __builtin_clz(a) // count leading zeroes
#define ctz(a)      __builtin_ctz(a) // count trailing zeroes
#define popc(a)     __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define SIZE        1000005
#define F           first
#define S           second
#define debug(x)    cerr << #x << " = " << x << endl;
#define mod         998244353

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define endl        '\n'
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

void solve()
{ 
  int n,m; cin>>n>>m;
  priority_queue<ll,vll,greater<ll>> p;
  priority_queue<pair<ll,ll>> q;
  rep(i,0,n)
  {
    ll x; cin>>x;
    p.push(x);
  }
  rep(i,0,m)
  {
    ll b,c; cin>>b>>c;
    q.push({c,b});
  }
  while(!q.empty())
  {
    if(q.top().F<=p.top()) break;
    rep(i,0,q.top().S)
    {
      if(p.top()>=q.top().F) break;
      p.pop();
      p.push(q.top().F);
    }
    q.pop();
  }
  ll ans=0;
  while(!p.empty())
  {
    ans+=p.top();
    p.pop();
  }
  cout<<ans;
} 
int main()
{   
    fastestiointhewest;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 3188
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <cmath>
#include <functional>

using namespace std;

int main(void)
{
	int l, r, n;
	int sum = 0;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> l >> r;
		sum += (r - l + 1);
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

public class Main {

	public static void main(String[] args) {
		Task task = new Task();
		task.solve();
	}

	public static class Task {
		static final long MOD = (long) 1e9 + 7;

		public void solve() {
			Scan sc = new Scan();
			long n = sc.scanLong();
			long i = (long) Math.sqrt(n);
			for (; i >= 1; --i) {
				if (n % i == 0) {
					break;
				}
			}
			long other = n / i;
			long res = Math.max(String.valueOf(i).length(), String.valueOf(other).length());
			System.out.println(res);
		}
	}

	public static class Scan {
		private byte[] buf = new byte[1024];
		private int index;
		private InputStream in;
		private int total;

		public Scan() {
			in = System.in;
		}

		public int scan() {
			if (total < 0)
				throw new InputMismatchException();
			if (index >= total) {
				index = 0;
				try {
					total = in.read(buf);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				if (total <= 0)
					return -1;
			}
			return buf[index++];
		}

		public long scanLong() {
			long integer = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n)) {
				if (n >= '0' && n <= '9') {
					integer *= 10;
					integer += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			return neg * integer;
		}

		public double scanDouble() throws IOException {
			double doub = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n) && n != '.') {
				if (n >= '0' && n <= '9') {
					doub *= 10;
					doub += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			if (n == '.') {
				n = scan();
				double temp = 1;
				while (!isWhiteSpace(n)) {
					if (n >= '0' && n <= '9') {
						temp /= 10;
						doub += (n - '0') * temp;
						n = scan();
					} else
						throw new InputMismatchException();
				}
			}
			return doub * neg;
		}

		public String scanString() {
			StringBuilder sb = new StringBuilder();
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			while (!isWhiteSpace(n)) {
				sb.append((char) n);
				n = scan();
			}
			return sb.toString();
		}

		public char scanChar() {
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			return (char) n;
		}

		private boolean isWhiteSpace(int n) {
			if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
				return true;
			return false;
		}
	}
}


Measured memory_bytes: 32208
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		String[] arr = new String[n+1];
		for(int i = 0; i < n; i++) {
			arr[i] = sc.nextLine();
			char temparr[] = arr[i].toCharArray();
			Arrays.sort(temparr);
			arr[i] = new String(temparr);
		}
		arr[n] = "zzzzzzzzzzzzz";
		Arrays.sort(arr);
//		System.out.println(Arrays.toString(arr));
		long ans = 0;
		long freq = 1;
		for(int i = 0; i < n; i++) {
				if (arr[i].equals(arr[i + 1])) {
//					System.out.println("cnt");
					freq += 1;
				}
				else if (freq == 1) {
					continue;
				}
				else {
					ans += freq*(freq - 1)/2;
					freq = 1;
				}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 99752
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String w = sc.next();
    w = w.toLowerCase();
    int cnt = 0;
    while(true) {
      String t = sc.next();
      if (t.equals("END_OF_TEXT")) break;
      t = t.toLowerCase();
      if (t.equals(w)) cnt++;
    }
    System.out.println(cnt);
  }
}


Measured memory_bytes: 26376
from functools import reduce
from fractions import gcd


def gcd_arg(lst):
    return reduce(gcd, lst)


N, X = map(int, input().split())
lst_x = list(map(int, input().split())) + [X]
lst_x.sort()
lst_diff = [lst_x[i] - lst_x[i-1] for i in range(1, N+1)]
ans = gcd_arg(lst_diff)
print(ans)


Measured memory_bytes: 16308
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;

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

    if(S == "ABC"){
        cout << "ARC";
    }else{
        cout << "ABC";
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 3596
import { readFileSync } from "fs";

const { cin, nCin, biCin } = (() => {
  const inputs = readFileSync("/dev/stdin", "utf-8").split(/[\n|\s]+/);
  let count = 0;
  const cin = () => inputs[count++];
  return { cin: cin, nCin: () => Number(cin()), biCin: () => BigInt(cin()) };
})();

const range = (n: number | bigint) => [...Array(Number(n))].map((_, i) => i);

type Result = "AC" | "WA" | "TLE" | "RE";

{
  const n = nCin();
  const s = range(n).map((_) => cin() as Result);
  const map = new Map<Result, number>();
  const results: Result[] = ["AC", "WA", "TLE", "RE"];

  results.forEach((s) => {
    map.set(s, 0);
  });

  s.forEach((s) => {
    const cnt = map.get(s);
    if (cnt !== undefined) map.set(s, cnt + 1);
  });

  results.forEach((s) => {
    console.log(`${s} x ${map.get(s)}`);
  });
}


Measured memory_bytes: 42300
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

ll mod = 1000000007 ;
//long double pie = acos(-1) ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n ; cin >> n ;
	vll h(n) ;
	for(int i=0;i<n;i++) cin >> h.at(i) ;
	h.push_back(mod) ;
	for(int i=0;i<n;i++){
		if(h.at(i)<=h.at(i+1)) continue ;
		if(h.at(i)-1>h.at(i+1)){
			yorn(0) ;
			return 0 ;
		}
		h.at(i+1)++ ;
	}
	yorn(1) ;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
signed
main(){
	string s;
    cin >> s;
    for(int i=0;i<3;i++){
    	if(s[i]==s[i+1])
        {
        	cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}

Measured memory_bytes: 256
A = input()
B = input()
C = input()


order = A[0]
A = A[1:]

while True:
    if order == "a":
        if A == "":
            print('A')
            exit()
        order = A[0]
        A = A[1:]

    if order == "b":
        if B == "":
            print('B')
            exit()
        order = B[0]
        B = B[1:]

    if order == "c":
        if C == "":
            print('C')
            exit()
        order = C[0]
        C = C[1:]


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

int main() {
  string O, E;
  cin >> O >> E;

  for (int i = 0; i < E.size(); i++) {
    cout << O.at(i);
    cout << E.at(i);
  }
  if (O.size() > E.size()) cout << O.at(O.size()-1);
  cout << endl;
}

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

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

#define RFOR(i, b, a) for(int(i)=(b); (i)>=(a); (i)--)
#define RREP(i, n) FOR((i), (n), 0)

#define pb push_back
#define mp make_pair 

using namespace std;

const int INF=INT_MAX/4;
const int MOD=1000000007;
const double EPS=1e-14;

const bool debug_flag=true;

void debug(string str){
	if(debug_flag){
		cout<<str<<endl;
	}
}

void debugs(string str){
	if(debug_flag){
		cout<<str;
	}
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout.precision(10);

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

	if(m>=2*n){
		ans=n;
		m-=2*ans;
		ans+=m/4;
	}else{
		ans=m/2;
		n-=ans;
		m-=ans*2;
	}

	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 256
import sys


def main():
    input = sys.stdin.buffer.readline
    h, n = map(int, input().split())
    a = [0] * n
    b = [0] * n
    for i in range(n):
        a[i], b[i] = map(int, input().split())
    max_a = max(a)
    # dp[j]:jダメージ与える魔力の最小値
    dp = [1e9] * (h + max_a + 1)
    dp[0] = 0
    for i in range(n):
        for j in range(1, h + max_a + 1):
            dp[j] = min(dp[j], dp[max(j - a[i], 0)] + b[i])
    print(min(dp[h:]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 73956
#include<bits/stdc++.h>
#define M_PI       3.14159265358979323846
#define Speed_UP  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define 	pb	push_back 
#define 	ff	first 
#define 	ss	second 
#define sz(x) (int)x.size()
#warning Remeber to change t
using namespace std;
typedef long long ll;
inline void setIO(string name="") {
	#ifndef ONLINE_JUDGE 
	freopen((name+".in").c_str(), "r", stdin); 
	freopen((name+".out").c_str(), "w", stdout);
	#endif
	}
ll const M=1e9+7;
int main(){
	Speed_UP
	ll n;
  cin>>n;
  ll a=1;
  ll b=1;
  ll c=1;
  for(int i=1;i<=n;i++){
    a*=10LL;
    a%=M;
    b*=8LL;
    b%=M;
    c*=9LL;
    c%=M;
  }
  c*=2LL;
  c%=M;
  
  a+=b;
  a%=M;
  cout<<(a-c+M)%M;
  


}


Measured memory_bytes: 3652
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        int ans = x + (y / 2);
        
        System.out.println(ans);
        
        sc.close();
        
    }
}


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

using namespace std;

#define all(x) begin(x), end(x)

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

constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 4003;

int sum(int a, int b, int mod=MOD) {
    int c = a + b;
    if (c >= mod) {
        c -= mod;
    }

    return c;
}

inline int prod(int a, int b, int mod=MOD) {
    return (1LL * a * b) % mod;
}

int modpow(int base, int exp, int mod=MOD) {
    int res = 1;
    int cur = base;
    for (int p = 1; p <= exp; p <<= 1) {
        if (p & exp) {
            res = prod(res, cur, mod);
        }

        cur = prod(cur, cur, mod);
    }

    return res;
}

inline int inv(int x, int mod=MOD) {
    return modpow(x, mod - 2, mod);
}

int fact[MAXN], tcaf[MAXN];

void gen_fact() {
    fact[0] = 1;
    for (int i = 1; i < MAXN; ++i) {
        fact[i] = prod(fact[i - 1], i);
    }

    tcaf[MAXN - 1] = inv(fact[MAXN - 1]);
    for (int i = MAXN - 2; i >= 0; --i) {
        tcaf[i] = prod(tcaf[i + 1], i + 1);
    }
}

int choose(int n, int k) {
    if (k < 0 or k > n or n < 0) {
        return 0;
    }

    return prod(fact[n], prod(tcaf[k], tcaf[n - k]));
}

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

    gen_fact();

    int n, k;
    cin >> n >> k;

    for (int i = 1; i <= k; ++i) {
        // break up k balls into i non-empty groups
        // (k - 1) choose (i - 1)
        int splits = choose(k - 1, i - 1);

        // red + 1 places to put them
        int spots = choose(n - k + 1, i);

        cout << prod(splits, spots) << '\n';
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll a,b;
  cin >> a >> b;
  cout << (a * 3 + b) / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

std::string const YES = "YES";
std::string const NO = "NO";

bool solve(int64_t a, int64_t b, int64_t c) {
  int five = int(a == 5) + int(b == 5) + int(c == 5);
  int seven = int(a == 7) + int(b == 7) + int(c == 7);
  return five == 2 && seven == 1;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t a;
  std::cin >> a;
  int64_t b;
  std::cin >> b;
  int64_t c;
  std::cin >> c;
  auto const res = solve(a, b, c);
  std::cout << (res ? YES : NO) << std::endl;
  return 0;
}


Measured memory_bytes: 256
import fractions

def prime_factorization(N):
    tmp = N
    ans = []
    for i in range(2, int(N ** 0.5) + 1):
        count = 0
        while tmp % i == 0:
            tmp //= i
            count += 1
        if count != 0:
            ans.append([i, count])
    if tmp != 1:
        ans.append([tmp, 1])
    if ans == []:
        ans.append([N, 1])
    return ans

A, B = map(int, input().split())

gcdAB = fractions.gcd(A, B)

if gcdAB == 1:
    print(1)
else:
    print(len(prime_factorization(gcdAB)) + 1)

Measured memory_bytes: 5048
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb emplace_back
#define koto_memory(a) cout<<(sizeof(a)/1048576.0)<<" MB";
#define res(v) sort(all(v)),v.erase(unique(all(v)), v.end());
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
#define deb(x) cout<<"\n["<<#x<<" = "<<x<<"]\n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=4e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
bitset<N>dp1,dp2;int a[N],n,sum;
void solve(){
  cin>>n;dp2[0]=1;
  rep(i,1,n)cin>>a[i];
  rep(i,1,n)sum+=a[i];
  rep(i,1,n){
    dp1=dp2;
    dp1<<=a[i];
    dp2|=dp1;
  }
  rep(i,sum+1>>1,sum){
    if(dp2[i]==1){
      cout<<i;return;
    }
  }
}
int32_t main()
{
  ibs;cti;
  solve();return 0;
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

Measured memory_bytes: 4636
import sys

def main():
    # input = sys.stdin.read()
    # data = list(map(int, input.split()))

    s = input()
    p = input()
    cnt = 0
    for i in range(len(s) - len(p)+1):
        mx = 0
        for j in range(len(p)):
            if s[i+j] == p[j]:
                mx += 1
            # print(i, mx)
        cnt = max(cnt, mx)

    # print(p,cnt)
    print(len(p)-cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 8904
/*
  KUNAL ANAND
  MNNIT ALLAHABAD
*/  

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<assert.h>
using namespace std;
using namespace __gnu_pbds;
#define debug1(x) cout << # x << " " << x << endl;
#define debug2(x,y) cout << #x << " " << x << " " << #y << " " << y << endl;
#define debug3(x,y,z) cout << #x << " " << x << " " << #y << " " << y << " " << #z << " " << z << endl;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
typedef long long int ll;
const ll INF=1e16;
const ll mod=1e9+7;

ll power(ll x,ll y)
{
    if(y==0)
        return 1;
    ll a=power(x,y/2);
    a=(a*a)%mod;
    if(y%2)
        a=(a*x%mod)%mod;
    return a;
}


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

    ll t;
    ll n,q;
    ll i,j,k,a,b,m,c=1,ans1=0,ans2=0,x1,x2,y2,y1,s,mini=LLONG_MAX,idx,ans=0,l;

    cin >> n;

    ll dp[n+1][n+1],presum[n+1][n+1];

    memset(dp,0,sizeof(dp));
    memset(presum,0,sizeof(presum));

    string trouble;

    cin >> trouble;

    dp[1][1]=1;

    presum[1][1]=1;

    for(i=2;i<=n;i++)
    {
        for(j=1;j<=i;j++)
        {
            if(trouble[i-2]=='<')
            {
                dp[i][j]=presum[i-1][j-1];
            }
            else
            {
                dp[i][j]=(presum[i-1][i-1]-presum[i-1][j-1]+mod)%mod;
            }

            presum[i][j]=(presum[i][j-1]+dp[i][j])%mod;

        }
    }

    for(i=1;i<=n;i++)
    {
        ans+=dp[n][i];

        ans%=mod;
    }

    cout << ans << endl;


    return 0;
}    

Measured memory_bytes: 140928