akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}

int dsu[100005];
priority_queue<long long> comp[100005];

int find(int node){
    if(dsu[node] == node) return node;
    return dsu[node] = find(dsu[node]);
}
void combine(int a, int b){
    a = find(a); b = find(b);
    if(a == b) return;
    if(comp[a].size() < comp[b].size()){
        dsu[a] = b;
        for(;!comp[a].empty(); comp[a].pop())
            comp[b].push(comp[a].top());
    } else if(comp[b].size() < comp[a].size()){
        dsu[b] = a;
        for(;!comp[b].empty(); comp[b].pop())
            comp[a].push(comp[b].top());
    } else {
        dsu[a] = b;
        for(;!comp[a].empty(); comp[a].pop())
            comp[b].push(comp[a].top());
    }
}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    long long num;
    int n, m, a, b; cin >> n >> m;

    if(n < 2 * (n - m - 1)){
        cout << "Impossible\n";
        return 0;
    }
    
    if(n == m + 1){
        cout << "0\n";
        return 0;
    }

    for(int i = 0; i < n; ++i){
        cin >> num;
        comp[i].push(-num);
        dsu[i] = i;
    }

    for(int i = 0; i < m; ++i){
        cin >> a >> b;
        combine(a, b);
    }

    bitset<100005> vis;
    vector<int> yikes;
    long long cost = 0;
    //priority_queue<pair<int, int>> pq;

    for(int i = 0; i < n; ++i){
        //cout << "LEADER " << i << " " << find(i) << en
        if(vis[find(i)]){
            yikes.push_back(-comp[find(i)].top());
            comp[find(i)].pop();
            continue;
        }
        vis[find(i)] = 1;
        cost -= comp[find(i)].top();
        comp[find(i)].pop();
        //pq.push(make_pair(comp[find(i)].top(), find(i)));
        //cout << "ADD " << comp[find(i)].front() << " " << find(i) << endl;
    }

    /*long long cost = 0;

    while(pq.size() > 1){
        pair<int, int> x, y;
        x = pq.top(); pq.pop();
        y = pq.top(); pq.pop();
        cost -= comp[x.second].top() + comp[y.second].top();
        comp[x.second].pop(); comp[y.second].pop();
        combine(x.second, y.second);
        if(!comp[find(x.second)].empty())
            pq.push(make_pair(comp[find(x.second)].top(), find(x.second)));
    }*/

    sort(yikes.begin(), yikes.end());

    for(int i = 0; i < n - m - 2; ++i){
        //cout << yikes[i] << endl;
        cost += yikes[i];
    }

    cout << cost << "\n";

    return 0;

}


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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int ch(int n) {
  vector<int> v;
  rep(i, 4) {
    v.pb(n % 10);
    n /= 10;
  }
  sort(v.begin(), v.end());
  int la = 0, sm = 0;
  rep(i, 4) {
    la += v[i] * pow(10, i);
    sm += v[3 - i] * pow(10, i);
  }
  return la - sm;
}

signed main() {
  ll n;
  while(cin >> n) {
    if(n == 0000) break;
    if(n % 1111 == 0) {
      cout << "NA" << endl;
      continue;
    }
    ll cnt = 0;
    while(1) {
      if(n == 6174) {
        cout << cnt << endl;
        break;
      }
      n = ch(n);
      cnt++;
    }
  }
	return 0;
}


Measured memory_bytes: 3364
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdin = new Scanner(System.in);
		int max=0, a, b, n, amax = 0;
		n = stdin.nextInt();
		for (int i = 0; i < n; i++) {
			a = stdin.nextInt();
			b = stdin.nextInt();
			if (a > amax) {
				amax = a;
				max = a + b;
			}

		}
		System.out.println(max);

	}

}


Measured memory_bytes: 65188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		
		long ans = 1;
		for(long i = 1;i <= Math.sqrt(N)+1;++i) {
			if(i * i > N) {
				ans = (i-1) * (i-1);
				break;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 25172
import sys
# from collections import defaultdict
# from collections import Counter
from queue import Queue
# sys.setrecursionlimit(2000000)

def main():
    K = int(input())

    queue = Queue()
    for i in [ 1, 2, 3, 4, 5, 6, 7, 8, 9, ]:
        queue.put(i)

    for i in range(1, K+1):
        lunlun = queue.get()
        digit = lunlun % 10

        new_lunluns = []
        # pushする順番は小さい順にする必要がある
        if digit == 0:
            new_lunluns.append(lunlun * 10 + digit)
            new_lunluns.append(lunlun * 10 + digit + 1)
        elif digit == 9:
            new_lunluns.append(lunlun * 10 + digit - 1)
            new_lunluns.append(lunlun * 10 + digit)
        else:
            new_lunluns.append(lunlun * 10 + digit - 1)
            new_lunluns.append(lunlun * 10 + digit)
            new_lunluns.append(lunlun * 10 + digit + 1)

        for new_lunlun in new_lunluns:
            queue.put(new_lunlun)

    print(lunlun)
    return 0

if __name__ == '__main__':
    sys.exit(main())


Measured memory_bytes: 18864
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	priority_queue<int> Q;
	while(true){
		string S=in<string>();
		if(S=="insert"){
			int v=in();
			Q.push(v);
		}
		else if(S=="extract"){
			out(Q.top());
			Q.pop();
		}
		else{
			break;
		}
	}
	
	return 0;
}



Measured memory_bytes: 7028
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main(){
    fast;
    int H, A;
    cin >> H >> A;
    if(H % A == 0)
    cout << H/A;
    else
        cout << H/A + 1;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

#define LL long long
string s;
int x, a, b, c, num[5];

int main() {
	cin >> num[0] >> num[1] >> num[2];
	sort(num, num + 3);
	cout << num[0] << " " << num[1] << " " << num[2] << endl;

	return 0;
}


Measured memory_bytes: 3208
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

ll f(ll v) {
	string s=to_string(v);
	ll e=0;
	for(char c: s) e+=c-'0';
	return e;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	while(cin>>N) {
		ll t=1,ans=f(N);
		while(t<=N) {
			ll v=N/t*t-1;
			maxUpdate(ans, f(v));
			t*=10;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <sstream>
#include <set>
#include <list>
#include <queue>
#include <utility>
#include <algorithm>
#include <functional>
#include <bitset>
#include <array>
#include <stdlib.h>
#include <thread>
#include <chrono>
#include <map>
#include <set>
#include <stdio.h>
#include <math.h>
#include <fenv.h>
using namespace std;

using namespace std;

template<class T>
void printVector(const std::vector<T>& vs)
{
    for(auto t : vs)
        std::cout << t << " ";
    std::cout << std::endl;
}




int main()
{

    int n, a, b;
    string s;
    std::cin>>n>>a>>b>>s;
    int p = 0, pb = 0;
    for(int i=0; i<n;++i)
    {
        if(s[i] == 'c')
            std::cout << "No" << std::endl;
        else if(s[i] == 'a')
        {
            if(p<a+b)
            {
                ++p;
                std::cout << "Yes" << std::endl;
            }
            else
                std::cout << "No" << std::endl;
        }
        else
        {
            if(p<a+b && pb < b)
            {
                ++p, ++pb;
                std::cout << "Yes" << std::endl;
            }
            else
                std::cout << "No" << std::endl;
        }
    }
    return 0;
}


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

int main(void){
   int N,M;
   cin>>N>>M;
   vector<vector<char>> A(N,vector<char>(N));
   vector<vector<char>> B(M,vector<char>(M));
   for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
         cin>>A[i][j];
      }
   }
   for(int i=0;i<M;i++){
      for(int j=0;j<M;j++){
         cin>>B[i][j];
      }
   }
   for(int dx=0;dx<N;dx++){
      for(int dy=0;dy<N;dy++){
         if(dx+M-1>N-1||dy+M-1>N-1) continue;
         bool flag=true;
         for(int i=0;i<M;i++){
            for(int j=0;j<M;j++){
               if(A[dx+i][dy+j]!=B[i][j]){
                  flag=false;
                  break;
               }
            }
         }
         if(flag){
            cout<<"Yes"<<endl;
            return 0;
         }
      }
   }
   cout<<"No"<<endl;
   return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a  = sc.nextLong();
        if (a%2==0 || a%5==0){
            System.out.println(-1);
        }
        else{
            long count = 0;
            long n = 7;
            while(true){
                if(n%a==0){
                    break;
                }
                else{  
                    n = (n%a)*10+7 ;
                    count++;
                }
            }
            System.out.println(count+1);
        }
    }
}

Measured memory_bytes: 35608
#include <stdio.h>

#define W 21
#define H 20

int tileCount(char room[H][W], int row, int col, int h, int w);

int main()
{
  char room[H][W];
  int h;    // 部屋の行方向のタイルの枚数
  int w;    // 部屋の列方向のタイルの枚数
  int row;  // 最初に人が立っている行位置
  int col;  // 最初に人が立っている列位置
  int i, j;

  // 部屋の情報を、配列room[]に文字列として読み込む
  scanf("%d%d", &w, &h);
  while (h != 0 && w != 0) {
    for (i = 0; i < h; i++) {
      scanf("%s", room[i]);
      for (j = 0; j < w; j++) {
        if (room[i][j] == '@') {
          row = i;  // 最初に人が立っている行位置
          col = j;  // 最初に人が立っている列位置
        }
      }
    }
    printf("%d\n", tileCount(room, row, col, h, w));

    scanf("%d%d", &w, &h);
  }
  
  return(0);
}

int tileCount(char room[H][W], int row, int col, int h, int w){
  int dx[4]={0,1,0,-1};
  int dy[4]={1,0,-1,0};
  int nx,ny;
  int i,j;
  int cnt=1;
  if(row<0 || col<0 || col>=w || row>=h || room[row][col]=='#')return 0;
  room[row][col]='#';
  for(i=0;i<4;i++){
    nx=col+dx[i];
    ny=row+dy[i];
    cnt+=tileCount(room,ny,nx,h,w);
  }
  return cnt;
}

Measured memory_bytes: 1072
# coding: utf-8
N=int(input())
A=list(map(int,input().split()))
L=[0 for i in range(N)]
R=[0 for i in range(N)]

for i in range(N):
    if i-A[i]>=0:
        L[i-A[i]]+=1
    if i+A[i]<=N-1:
        R[i+A[i]]+=1
ans=0
for i in range(N):
    ans+=L[i]*R[i]


print(ans)

Measured memory_bytes: 32296
#include<bits/stdc++.h>
using namespace std;
#define IL inline
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define repd(i,j,k) for(int i=j;i>=k;--i)
#define pb push_back
#define db double
#define mp make_pair
#define mp3(a,b,c) mp(a,mp(b,c))
#define pii pair<int,int>
#define fr first
#define se second
#define ll long long 
#define pbc(x) __builtin_popcount(x)
IL int read(){int x;int _w=scanf("%d",&x);return x;}
IL void write(int x){printf("%d\n",x);}
template<typename T>IL void debug(T x){cerr<<x;return;}
const int maxn=1e5+10;
int n;
int v[maxn];
int main(){
	n=read();
	map<int,int>eve,odd;
	rep(i,1,n)i&1?eve[read()]++:odd[read()]++;
	int ans1=n/2,ans11=n/2,ans2=n/2,ans22=n/2;
	for(auto p:eve){
		if(n/2-p.se<ans1){
			ans11=ans1;
			ans1=n/2-p.se;
		}
		else ans11=min(ans11,n/2-p.se);
	}
	for(auto p:odd){
		if(n/2-p.se<ans2){
			ans22=ans2;
			ans2=n/2-p.se;
		}
		else ans22=min(ans22,n/2-p.se);
	}
	vector<int>l,r;
	for(auto p:eve)if(n/2-p.se==ans1)l.pb(p.fr);
	for(auto p:odd)if(n/2-p.se==ans2)r.pb(p.fr);
	if(l[0]!=r[0]||max(l.size(),r.size())>=2)cout<<ans1+ans2<<endl;
	else {
		cout<<min(ans11+ans2,ans1+ans22)<<endl;
	}
	return 0;
}

Measured memory_bytes: 5504
var
  ans, i, n, t: integer;
  a: array[1..100005] of integer;
begin
  readln(n);
  for i := 1 to n do
  begin
    read(t);
    if a[t] = i then ans := ans + 1;
    a[i] := t;
  end;
  writeln(ans);
end.

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << x << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  string s;
  cin >> s;
  string ans;
  if (s == "Sunny") ans = "Cloudy";
  if (s == "Cloudy") ans = "Rainy";
  if (s == "Rainy") ans = "Sunny";
  cout << ans << endl;
  return 0;
}

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

int main (void){
  int a,b,k;
  cin >> a >> b >> k;

  if(b - a + 1 >= 2*k){
    for(int i = 0;i < k;i++){
      cout << a + i << '\n';
    }
    for(int i = 0;i < k;i++){
      cout << b - k + 1 + i << '\n';
    }
  }else if(b - a + 1 >= k){
    for(int i = 0;i < k;i++){
      cout << a + i << '\n';
    }
    for(int i = 0;i < b - a + 1 - k;i++){
      cout << a + k + i  << '\n';
    }
  }else{
    for(int i = 0;i < b - a + 1;i++){
      cout << a + i << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(void){
    int A,B;
    cin>>A>>B;
    if (A==B){
        cout<<"Draw"<<endl;
    }else if(A==1){
        cout<<"Alice"<<endl;
    }else if(B==1){
        cout<<"Bob"<<endl;
    }else if (A>B){
        cout<<"Alice"<<endl;
    }else if (A<B){
        cout<<"Bob"<<endl;
    }
    
    
    }

Measured memory_bytes: 256
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    n = inp()
    a = inlt()
    q = sorted([[a[i],i + 1] for i in range(n)])
    print(*[q[i][1] for i in range(n)])
            
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1],1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)

def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))

def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))
#-----------------------------------------------------------------------#
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
main()

Measured memory_bytes: 100340
from sys import stdin
input = stdin.readline


def main():
  H, N = list(map(int, input().split()))
  A = [0]*N
  B = [0]*N
  for i in range(N):
    A[i], B[i] = map(int, input().split())

  # dp = [[0]*(H+1) for _ in range(N+1)]
  dp = [0]*(H+1)
  for j in range(H+1):
    dp[j] = float('inf')
  dp[0] = 0

  for i in range(1, N+1):
    for j in range(1, H+1):
      # dp[i][j] = dp[i-1][j]
      if j > A[i-1]:
        dp[j] = min(dp[j], dp[j-A[i-1]]+B[i-1])
      else:
        dp[j] = min(dp[j], B[i-1])

  # for i in range(N+1):
  #   print(dp[i])
  print(dp[H])


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

Measured memory_bytes: 74044
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll count = n/(a+b);
    ll d = n%(a+b);
    if(a == 0) {
        cout << 0 << endl;
        return 0;
    }
    if(count == 0) {
        if(n-a > 0) {
            cout << a << endl;
        }
        else if(n-a <= 0) {
            cout << n << endl;
        }
    }
    else {
        if(d > a) {
            cout << count*a + a << endl;
        }
        else {
            cout << count*a + d << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<long long,long long>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
#define LONGLONG_MAX 100000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a);}
                a=(a*a);
                b>>=1;
        }
    return ans;
        
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    srand(time(0));
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
using namespace std;

int n, m;
int d[100000];
int t = 0;
int c[100000];
queue<int> q;
vector<int> v[100000];
int ans = 2;

void bfs(int u){
  q.push(u);
  c[u] = 1;

  while(q.empty() == 0){
    u = q.front();
    q.pop();
    for(int i = 0; i < v[u].size(); i++){
      if(c[v[u][i]] == 0){
        q.push(v[u][i]);
        c[v[u][i]] = 1;
      }

    }
    c[u] = ans;
  }

}


int main(){

  cin >> n;

  for(int i = 0; i < n; i++){
    c[i] = 0;
  }

  cin >> m;

  for(int i = 0; i < m; i++){
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }

  for(int i = 0; i < n; i++){
    if(c[i] == 0){
      bfs(i);
      ans++;
    }
  }

  int q;
  cin >> q;

  for(int i = 0; i < q; i++){
    int x, y;
    cin >> x >> y;
    if(c[x] == c[y]) cout << "yes" << endl;
    else cout << "no" << endl;
  }

  return 0;
}


Measured memory_bytes: 9024
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int N,i,j;
    cin>>N;
    long long int A[N][3];
    for(i=0;i<N;i++)
        cin>>A[i][0]>>A[i][1]>>A[i][2];

    for(i=1;i<N;i++)
    {
        A[i][0] = max((A[i][0]+A[i-1][1]) , (A[i][0]+A[i-1][2]));
        A[i][1] = max((A[i][1]+A[i-1][0]) , (A[i][1]+A[i-1][2]));
        A[i][2] = max((A[i][2]+A[i-1][0]) , (A[i][2]+A[i-1][1]));
    }
    cout<<max(max(A[N-1][0],A[N-1][1]),A[N-1][2])<<endl;
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<bool> a(n+1);
	int sum=0;
	for(int i=1;i<=n;++i){
		sum+=i;
		a.at(i)=true;
		if(sum>=n){
			a.at(sum-n)=false;
			break;
		}
	}
	rep(i,n+1){
		if(a.at(i)) cout << i << endl;
	}
}

Measured memory_bytes: 1536
#include<stdio.h>

int main(void){

int N, i;
int V[20];
int C[20];
int defference[20];
int sum = 0;

scanf("%d", &N);

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

for(i = 0; i < N; i++){
    scanf("%d", &C[i]);
    defference[i] = V[i] - C[i];
}



for(i = 0; i < N; i++){
    if(defference[i] > 0){
        sum += defference[i];
    }
}

printf("%d\n", sum);


return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#define M 1001
void Print_lCS(char x[],char y[]);
int main()
{
    char x[M],y[M];
    int q;
    scanf("%d",&q);
    while(q--){
        scanf("%s%s",x,y);
        Print_lCS(x,y);
    }
}

void Print_lCS(char x[],char y[])
{
    int nx = strlen(x);
    int ny = strlen(y);
    int i,j;
    int c[nx+1][ny+1];
    //边界条件
    for(i = 0;i <= nx;i++)
        c[i][0] = 0;
    for(j = 0;j <= ny;j++)
        c[0][j] = 0;
    //
    for(i = 1;i <= nx;i++){
    for(j = 1;j <= ny;j++){
        if(x[i-1] == y[j-1])
                c[i][j] = c[i-1][j-1] + 1;
            else if(c[i][j-1] >= c[i-1][j])
                c[i][j] = c[i][j-1];
            else
                c[i][j] = c[i-1][j];
        }
    }
    printf("%d\n",c[nx][ny]);
}


Measured memory_bytes: 5652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ge(a, b) get<(b)>((a))
#define SZ(x) (x).size()
#define ft front()
#define bk back()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
    if (DEBUG) std::cerr
const int xd[4] = {0, 1, 0, -1}, yd[4] = {1, 0, -1, 0};
template <typename t>
bool ckmin(t& a, const t& b) {
    return a > b ? a = b, true : false;
}
template <typename t>
bool ckmax(t& a, const t& b) {
    return a < b ? a = b, true : false;
}

const ll p = 1e9 + 7;

ll binpow(ll a, ll b) {
    a %= p;
    ll res = 1;
    while (b > 0) {
        if (b & 1) res = res * a % p;
        a = a * a % p;
        b >>= 1;
    }
    return res;
}

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

    ll n, k;
    cin >> n >> k;
    vector<ll> dp(k + 1);
    for (ll i = k; i >= 1; --i) {
        ll nums = k / i;
        dp[i] = binpow(nums, n);
        for (int j = i << 1; j <= k; j += i) dp[i] = (dp[i] + p - dp[j]) % p;
    }
    ll sum = 0;
    for (ll i = 1; i <= k; ++i) sum = (sum + dp[i] * i) % p;
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 4000
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<numeric>
#include<map>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

typedef long long int ll;


int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n){
        cin >> a[i];
    }

    map<int,int> odd,even;

    REP(i,n){
        if(i % 2 == 0){
            even[a[i]]++;
        }else{
            odd[a[i]]++;
        }
    }

    int odd_maxi = -INF,odd_maxi_num,odd_second_maxi = 0,odd_second_maxi_num = 0;
    int even_maxi = -INF,even_maxi_num,even_second_maxi = 0,even_second_maxi_num = 0;

    for(auto itr:odd){
        if(odd_maxi < itr.second){
            odd_maxi = itr.second;
            odd_maxi_num = itr.first;
        }
    }

    for(auto itr:even){
        if(even_maxi < itr.second){
            even_maxi = itr.second;
            even_maxi_num = itr.first;
        }
    }
    for(auto itr:odd){
        if(odd_second_maxi < itr.second && itr.first != odd_maxi_num){
            odd_second_maxi = itr.second;
            odd_second_maxi_num = itr.first;
        }
    }
    for(auto itr:even){
        if(even_second_maxi < itr.second && itr.first != even_maxi_num){
            even_second_maxi = itr.second;
            even_second_maxi_num = itr.first;
        }
    }

    int ans = 0;
    

    //cout << odd_maxi << " " << odd_maxi_num << endl;
    //cout << even_maxi << " " << even_maxi_num << endl;
    //cout << odd_second_maxi << " " << odd_second_maxi_num << endl;
    //cout << even_second_maxi << " " << even_second_maxi_num << endl;

    if(odd_maxi_num != even_maxi_num){
        ans = n/2-odd_maxi + n/2-even_maxi;
    }else{
        int tmp = n/2-odd_maxi + n/2-even_second_maxi;
        int tmp2 = n/2-odd_second_maxi + n/2-even_maxi;
        ans = min(tmp,tmp2);
    }
    cout << ans << endl;


    return 0;
}

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

int main(){
  int n;
  cin >> n;
  long a[n];
  rep(i,n)cin>> a[i];
  sort(a,a+n, greater<>());
  long ans = a[0];
  int flag = 1;
  int mm = 1;
  for(int i=2;i<n;i++){
    if(flag){
      ans += a[mm];
      flag = 0;
    }else{
      ans += a[mm];
      mm++;
      flag = 1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5200
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#include<complex>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef complex<double> P;
typedef vector<P> G;
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};
P pin(){
	double x,y;
	cin>>x>>y;
	P p(x,y);
	return p;
}
void PIN(P* a,int n){
	rep(i,n)a[i]=pin();
}
double dot(P a,P b){
	return real(conj(a)*b);
}
double cross(P a,P b){
	return imag(conj(a)*b);
}
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}
P projection(L a,P p){
	double t=dot(p-a[0],a[0]-a[1])/norm(a[0]-a[1]);
	return a[0]+t*(a[0]-a[1]);
}
P reflection(L a,P p){
	return p+2.0*(projection(a,p)-p);
}
bool intersectLL(const L &l, const L &m) {
  return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || // non-parallel
         abs(cross(l[1]-l[0], m[0]-l[0])) < EPS;   // same line
}
bool intersectLS(const L &l, const L &s) {
  return cross(l[1]-l[0], s[0]-l[0])*       // s[0] is left of l
         cross(l[1]-l[0], s[1]-l[0]) < EPS; // s[1] is right of l
}
bool intersectLP(const L &l, const P &p) {
  return abs(cross(l[1]-p, l[0]-p)) < EPS;
}
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}
P intersect_ls(L a,L b){
	double t1=abs(cross(a[1]-a[0],b[0]-a[0]));
	double t2=abs(cross(a[1]-a[0],b[1]-a[0]));
	return b[0]+(b[1]-b[0])*t1/(t1+t2);
}
double distanceLP(const L &l, const P &p) {
  return abs(p - projection(l, p));
}
double distanceLL(const L &l, const L &m) {
  return intersectLL(l, m) ? 0 : distanceLP(l, m[0]);
}
double distanceLS(const L &l, const L &s) {
  if (intersectLS(l, s)) return 0;
  return min(distanceLP(l, s[0]), distanceLP(l, s[1]));
}
double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}
double distanceSS(const L &s, const L &t) {
  if (intersectSS(s, t)) return 0;
  return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
             min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}
double area(const G& g){
    double S =0;
    for(int i =0;i <g.size();i++){
        S +=(cross(g[i],g[(i+1)%g.size()]));
    }
    return abs(S/2.0);
}
int main(){
	int n;
	cin>>n;
	G g(n);
	PIN(&g[0],n);
	double S=area(g);
	printf("%.1f\n",area(g));
}

Measured memory_bytes: 1252
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iterator>
#include <math.h>
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define dd double
#define mp make_pair
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // int T,p;
    // cin>>T;
    // for(p=1;p<=T;p++)
    // {
      string s,w;
      cin>>s>>w;
      ll i,j,k,a,count=1e15;
      for(i=0;i<=s.length()-w.length();i++)
      {
        a=0;
        for(j=0;j<w.length();j++)
        { 
          if(s.at(i+j)!=w.at(j))
          a++;
        }
        count=min(count,a);
      }
      cout<<count;
      return 0;
}

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


void solve(long long N, std::vector<long long> A){
    map<long long, long long>cnts;
    for(auto a: A)cnts[a]++;

    vector<long long> paths;
    auto it=cnts.rbegin();
    while(it != cnts.rend() && paths.size()<2){
        if((*it).second >= 2)paths.push_back((*it).first);
        it++;
    }

    long long cand=-1;
    it=cnts.rbegin();
    while(it != cnts.rend() && cand<0){
        if((*it).second >= 4)cand=(*it).first*(*it).first;
        it++;
    }
    if(paths.size()<2 && cand<0)cout << 0 << endl;
    else cout << max(paths[0]*paths[1], cand) << endl;
}

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


Measured memory_bytes: 7296
/* Krishna */
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <cstdlib>
#define ll long long
#define endl "\n"
using namespace std;

int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll pro1 = max(a,b);
     ll pro2 = min(a,b);
     ll pre1 = max(c,d);
     ll pre2 = min(c,d);
    
    ll result = pro1*pre1;
  
    result = max(result,pro1*pre2);
    
    result= max(result,pro2*pre1);
   
    result = max(result,pro2*pre2);
    cout<<result;

}


Measured memory_bytes: 3620
object Main extends App {
  val X=readLine.split(" ")(1).toInt
  val xs=readLine.split(" ").map(_.toInt)
  def gcd(n:Int,m:Int):Int={
    val (g,l)=(List(n,m).max,List(n,m).min)
    if (l==0) g else gcd(l,g%l)
  }
  val xs2=xs.map(_ - X).map(_.abs)
  println(xs2.fold(xs2(0))(gcd(_,_)))
}


Measured memory_bytes: 79568
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> p(N), mn(N, 0), mx(N, 0);
	vector<bool> moto(N, 0);
	for(int i=0; i<N; ++i) cin >> p[i];
	deque<int> dq, dr, ds;
	int cnt=0;
	for(int i=0; i<N; ++i){
	    while(dq.size()>0){
	        if(p[dq.back()]<p[i]) break;
	        dq.pop_back();
	    }
	    dq.push_back(i);
	    if(dq[0]==i-K-1) dq.pop_front();
	    if(K<=i) mn[i]=dq[0];
	    while(dr.size()>0){
	        if(p[dr.back()]>p[i]) break;
	        dr.pop_back();
	    }
	    dr.push_back(i);
	    if(dr[0]==i-K-1) dr.pop_front();
	    if(K<=i) mx[i]=dr[0];
	    while(ds.size()>0){
	        if(p[ds.back()]<p[i]) break;
	        ds.pop_back();
	    }
	    ds.push_back(i);
	    if(dq[0]==i-K) ds.pop_front();
	    if(ds.size()==K){
	        moto[i]=1;
	        ++cnt;
	    }
	}
	int ans=N-K+1-max(0, cnt-1);
	for(int i=K; i<N; ++i){
	    if(mn[i]==i-K && mx[i]==i && !moto[i-1] && !moto[i]) --ans;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<stdio.h>//printf("%.9f\n",*********);
#include<vector>//文字列.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char(小文字-32=大文字) to_string,string,char
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define str string
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int SED(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}//stringのほうが効率よくないか？

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	rapid_pleaseAC_fast;

	int n, m, c;
	cin >> n >> m >> c;
	vint b(m);
	int ans = 0;
	int sum = c;
	rep(i, m) {
		cin >> b[i];
	}

	int a = 0;

	rep(i, n) {
		int x = sum;
		rep(j, m) {
			cin >> a;
			x += (a*b[j]);
		}
		if (x > 0) {
			ans++;
		}
	}
	cout << ans << rt;

	please AC;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
using ll=long long int;
using ppi=pair<ll,ll>;
using pql =priority_queue<ll, vector<ll>, greater<ll>>;
using pq=priority_queue<ll>;

int main()
{
    ll n,k;
    cin>>n>>k;
    cout<<min(n%k,k-n%k)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
        int an[5],k;
        for(int i=0; i<5; i++) cin>>an[i];
        cin>>k;
        for(int i=0; i<4; i++){
                for(int j=i+1; j<5; j++){
                        if((an[j]-an[i])>k){
                                cout<<":("<<endl;
                                return 0;
                        }
                }
        }
        cout<<"Yay!"<<endl;
        return 0;
}


Measured memory_bytes: 256
use std::cmp::max;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n:usize,
        k:usize,
        p:[f64;n]
    }
    let mut sum_prob:f64 = 0.0;
    for i in 0..k{
        sum_prob += ( p[i] + 1.0 ) / 2.0;
    }
    let mut ans:f64 = sum_prob;
    for i in k..n{
        sum_prob += ( p[i] + 1.0 ) / 2.0;
        sum_prob -= ( p[i-k] + 1.0 ) / 2.0;
        if ans < sum_prob{
            ans = sum_prob;
        }
    }
    println!("{}", ans);
}


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

#define forn(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) begin(x),end(x)
#define ll long long
#define vi vector<int>

using namespace std;

const int NMAX=1000001;
vi isPrime(NMAX,1);

void fillP(int n){
        isPrime[0]=0,isPrime[1]=0;
        for(int i=2; i<=n; i++)
                if(isPrime[i])
                        for(int j=2*i; j<=n; j+=i)
                                isPrime[j]=false;
}



int main(){
        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
        int a,ans;
        cin>>a;
        fillP(NMAX);
        ans=a;
        while(!isPrime[ans]){
                ans++;
        }
        cout<<ans;
        return 0;
}

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

using namespace std;
int main() {
    int n, k;
    int num = 1;

    cin >> n >> k;

    for (int i = 0; i < n; i++) {
        if (num < k) {
            num *=2;
        } else {
            num += k;
        }
    }

    cout << num << endl;
    return 0;
}



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

const int N = 200010;
int a, b;
char s[N];

int main() {
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	bool flag = 1;
	for(int i = 1; i <= n; ++i) {
		if(s[i] == 'U' || s[i] == 'D') continue;
		if(i & 1) if(s[i] != 'R') flag = 0;
		if(!(i & 1)) if(s[i] != 'L') flag = 0;
	}
	if(flag) puts("Yes");
	else puts("No");
}

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

using namespace std;

#define ll long long 
#define Fastest ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"

int main()
{
	int n,arr[100005];
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> arr[i];
	
	int ans = 0, sum = 0;
	
	for(int i = 1; i < n; i++)
	{
		if(arr[i] >= arr[i+1])
		{
			ans++;
		}
		else
		{
			sum = max(ans,sum);
			ans = 0;
		}
	}
	
	sum = max(sum,ans);
	
	cout << sum << endl;
	
	return 0;
}


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

using namespace std;
 
#define int1(a) scanf("%d",&a)
#define int2(a,b) scanf("%d %d",&a,&b)
#define int3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define int4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
 
#define lint1(a) scanf("%lld",&a)
#define lint2(a,b) scanf("%lld %lld",&a,&b)
#define lint3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define lint4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define ll long long int
#define lli long long int
 
#define pint(x) printf("%d",x)
#define plint(x) printf("%lld",x)
#define endl '\n'
#define nl printf("\n");
#define ps printf(" "); 
 
#define all(x) x.begin(),x.end()
#define pb push_back
#define Set(a, s) memset(a, s, sizeof (a))
#define mod1 (lli)(1e9 + 7)
#define mod2 (lli)(1e9 + 9)
#define EPS 1e-9

#define fore(i,n) for(int i=n; i>=0; i--)
#define fors(i,a,n) for(int i=a; i<n; i++)
#define fora(i,ele) for(auto i: ele)
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<lli> vli;
 
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
 
double tick(){static clock_t oldt,newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}
float roundoff(float val, float p){ return floor(val*pow(10.0,p)+0.5)/pow(10.0,p);}
lli power(lli a, lli b, lli mod){lli x=1,y=a; while(b > 0){if(b&1){x=(x*y)%mod;}y = (y*y)%mod; b /= 2;}return x;}
 
const int INF = 0x3f3f3f3f;
const float pi = 3.14159265;
 
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};
//int dx[]={1,-1,0,0}; int dy[]={0,0,1,-1};



int main(){
    int r;
    cin>>r;
    cout<<(3*r*r);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//*******************
// Mahmoud Magdy    *
//*******************
#define ll long long
#define endl "\n"

void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m ;
    cin>>m;
    return m ;
}
int main()
{
    int m=D();
    cout<<48-m<<endl;
}



Measured memory_bytes: 256
### main

n = gets.strip.to_i

a, b = gets.strip.split(' ').map{|s| s.to_i}
c = gets.strip.to_i

ds = []
n.times do
  di = gets.strip.to_i
  ds << [di.to_f / b, di]
end

ds.sort!{|a, b| b <=> a}

cp = a
cc = c
max_cp = cc.to_f / cp

for di in ds
  dc = di[1]
  cp += b
  cc += dc

  ccp = cc.to_f / cp
  max_cp = ccp if max_cp < ccp
end

puts max_cp.to_i

Measured memory_bytes: 6120