akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n,c,a[405],b[405],q[405][405],s[405][405],f[405][405],ans,mx;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
int main(){
	for(int i=1;i<=400;++i){
		q[i][0]=1;
		for(int j=1;j<=400;++j) q[i][j]=(1ll*q[i][j-1]*i)%mod;
	}
	for(int i=0;i<=400;++i){
		s[i][0]=1;
		for(int j=1;j<=400;++j)
			s[i][j]=(s[i][j-1]+q[j][i])%mod;
	}
	n=read(),c=read();
	for(int i=1;i<=n;++i) a[i]=read();
	for(int i=1;i<=n;++i) b[i]=read();
	f[0][0]=1;
	for(int i=1;i<=n;++i)
		for(int j=0;j<=c;++j)
			for(int k=0;k<=j;++k)
				f[i][j]=(f[i][j]+1ll*f[i-1][k]*((s[j-k][b[i]]-s[j-k][a[i]-1]+mod)%mod))%mod;
	printf("%d",f[n][c]);
} 
//记s[i][j]为1-j所有数的i次方之和 
//记f[i][j]为前i个人分j个糖果的答案，对于f[i][j]，可以从f[i-1][k](0<=k<=j)转移，给i个人j-k个糖果， 
//f[i][j]+=f[i-1][k]*(s[j-k][b[i]]-s[j-k][a[i]-1]) 

Measured memory_bytes: 2176
#include <cstdio>

int main() {
  int A, B, X;
  scanf("%d %d %d", &A, &B, &X);

  X -= A;
  if (X < 0) {
    puts("NO");
  } else if (X > B) {
    puts("NO");
  } else {
    puts("YES");
  }
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
 
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)
template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long mod(long long a, long long b) { return (a%b+b)%b; }
long long gcd(long long x, long long y) { return __gcd(x, y); }
long long lcm(long long x, long long y) { return x * 1ll * y / gcd(x, y); }
 
 
const long long MAXN = 1e9 + 9;
const long long SIZE = 3e5 + 5;
const long long MOD = 1e9 + 7;


int N, L[101], res;


bool ok (int a, int b, int c) {
	if (a == b || a == c || b == c) return false;
	if (a + b > c && a + c > b && b + c > a)
		return true;
	else
		return false;
}


int main() { speedhack()

	cin >> N;
	forn (i, N)
		cin >> L[i];
	
	for (int i = 1; i <= N; i++) {
		for (int j = i + 1; j <= N; j++) {
			for (int k = j + 1; k <= N; k++) {
				if (ok (L[i], L[j], L[k]))
					++res;
			}
		}
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 3620
n,m,l=map(int,input().split())
a=[]
for i in range (n):
    a.append(list(map(int,input().split())))
b=[]
for i in range (m):
    b.append(list(map(int,input().split())))
for i in range(n):
    for j in range(l):
        c=0
        for k in range(m):
            c+=a[i][k]*b[k][j]
        if j == l-1:
            print(c)
        else:
            print(c,end=" ")


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9+7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amin(T& a,T b){ a=min(a,b);}
template <class T> void amax(T& a,T b){ a=max(a,b);}

int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	
	string s;
	cin >>s;
	
	if(s <="2019/04/30") puts("Heisei");
	else puts("TBD");
	return 0;
}



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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
bool check = 0;
string s;
int N = 3;
vector<int> v(N);
int a, b;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{

  cin >> s;
  rep(i, 3) if (s[i] == '1') ans++;
  pr(ans);

  return 0;
}

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

int main() {
	int N;
    string S;
    bool Check = false;
    cin >> N;
    for(int i = 0; i < N; i++){
    	cin >> S;
        if(S == "Y"){
        	Check = true;
            break;
        }
    }
    if(Check == true){
    	cout << "Four" << endl;
    }else{
    	cout << "Three" << endl;
    }
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<int> G[1000];
int cnt[1000];
int main(){
    scanf("%d %d", &N, &M);
    for(int i = 0; i < M; i++){
        int u, v;
        scanf("%d %d", &u, &v);
        u--, v--;
        G[u].push_back(v);
        cnt[v]++;
    }
    queue<int> q;
    for(int i = 0; i < N; i++) if(cnt[i] == 0) q.push(i);
    int sz = 0;
    while(!q.empty()){
        sz++;
        int u = q.front(); q.pop();
        for(int v : G[u]) if(--cnt[v] == 0) q.push(v);
    }
    printf("%d\n", -(sz == N));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <cmath>
#include <vector>
using namespace std;
#define pi M_PI

int main(){
    int x, a , b;
    cin >> x >> a >> b;

    if(b <= a){
        cout << "delicious" << endl;
    }
    else if((b - a) <= x){
        cout << "safe" << endl;
    }
    else if((b - a) > x){
        cout << "dangerous" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
N,X,Y=map(int,input().split())

A=[]
for _ in range(N-1):
    A.append(0)  

for i in range(1,N):
    for j in range(i+1,N+1):
        m=min(j-i,abs(X-i)+abs(Y-j)+1)
        A[m-1]+=1

for k in range(N-1):
    print(A[k])




Measured memory_bytes: 3444
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define  DESC std::greater<int>() //sort 3rd arg



int main()
{
	int ac = 0;
	int wa = 0;
	int tle = 0;
	int re = 0;

	int n;
	cin >> n;
	REP(i, n) {
		string str;
		cin >> str;
		if (str=="AC") {
			ac++;

		}
		else if (str == "WA") {
			wa++;
		}
		else if (str == "TLE") {
			tle++;
		}
		else {
			re++;
		}

	}

	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;

	return 0;
}



Measured memory_bytes: 3624
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

#n,m = [int(i) for i in readline().split()]

s = input()
k =int(input())

l = len(s)

s0 = s[0]

if all(i==s0 for i in s):
    print(l*k//2)    
else:
    same = (s0 == s[-1])


    now = "AA"
    res = 0
    c = 0
    c0 = 0
    first = 2
    s0 = s+"W"
    for i in s0:
        if now == i:
            c += 1
        else:
            res += c//2
            c = 1
            now = i

    if not same: print(res*k)
    else:
        s = s+s+"W"
        
        res1 = res

        res = 0
        c = 0
        c0 = 0
        first = 2
        for i in s:
            if now == i:
                c += 1
            else:
                res += c//2
                c = 1
                now = i

        res2 = res
        
        print(res1 + (k-1)*(res2-res1))


















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


using namespace std;
typedef long long ll;
const int MX=1e6+7;
const long double eps=-0.00000001;


int main()
{

    int n;
    cin>>n;
    cout<<n*(n+1)/2;


    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace test
{
    public class Point
    {
        public double x;
        public double y;
    }

    class Program
    {
        static void Main(string[] args)
        {
            Point point = new Point();
            point.x = 0;
            point.y = 0;
            int angle = 0;

            string input;
            while ((input = Console.ReadLine()) != "0,0")
            {
                string[] array = input.Split(',');
                int step = int.Parse(array[0]);
                point = GetPoint(point, step, angle);

                angle += int.Parse(array[1]);
            }



            Console.WriteLine(GetInt(point.x));
            Console.WriteLine(GetInt(point.y));


        }

        static Point GetPoint(Point p,int step,int angle)
        {
            p.x += step * Math.Sin(Math.PI * angle / 180);
            p.y += step * Math.Cos(Math.PI * angle / 180);

            return p;
        }

        static double GetInt(double a)
        {
            if (a >= 0)
            {
                return Math.Floor(a);
            }
            else
            {
                return Math.Ceiling(a);
            }

        }

    }
}

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

int main() {
string S;
    cin >> S ;
bool tap=true;
  for(int i=0; i<S.size(); i++){
  if(i%2==0&&S.at(i)=='L') tap=false;
  else if  (i%2==1&&S.at(i)=='R') tap=false;
  }
  if (tap==true) cout << "Yes" << endl;
  else cout << "No" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007

vector <int> dx = {-1,1,0,0};
vector <int> dy = {0,0,-1,1};

int main(){

	ll n;cin>>n;
	vector<int> a(n);
	int i;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans = 0; 
	ll sum = 0;
	for(i=0;i<=n-2;i++){
		sum += a[i];
		sum %= MOD;
	}
	sum = sum%MOD;
	for(i=n-1;i>=1;i--){
		ans += (a[i]* sum)%MOD;
		ans = ans%MOD;
		sum = (sum - a[i-1] + MOD)%MOD;
	}

	
	cout<< (ans+ MOD)%MOD<<"\n";
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    int n; long a, b; cin >> n >> a >> b;
    vector<long> h; long max_h = 0;
    rep(i, n){
        long x; cin >> x; h.push_back(x); max_h = max(max_h, x);
    }
    long m = 0, M = (max_h + b - 1) / b;
    while(M - m > 1){
        long x = (m + M) / 2;
        long nec = 0;
        rep(i, n){
            if(h[i] <= b * x) continue;
            nec += (h[i] - b * x + (a - b - 1)) / (a - b); 
        }
        if(nec <= x) M = x;
        else m = x;
    }
    cout << M << endl;
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> V(N);
    rep(i,0,N)cin >> V[i];
    ll sum = 0, num = 0;
    ll mini = INF;
    rep(i,0,N)sum += V[i];
    rep(i,0,N){
        num += V[i];
        mini = min(mini, abs(sum - num - num));
    }
    cout << mini << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main() {
	long long int h, w;
	cin >> h >> w;
	long long int ans = 10000000000;
	if (w % 3 != 0) {
		ans = min(ans, h);
	}
	if (h % 3 != 0) {
		ans = min(ans, w);
	}
	if (w % 3 == 0) {
		cout << 0;
		return 0;
	}
	if (h % 3 == 0) {
		cout << 0;
		return 0;
	}
	for (int i = 1; i <= w - 1; i++) {
		long long int s1 = i * h;
		long long int s2 = (w - i) * (h % 2 + h / 2);
		long long int s3 = (w - i) * (h / 2);
		long long int mins = min(s1, min(s2, s3));
		long long int maxs = max(s1, max(s2, s3));
		ans = min(ans, maxs - mins);
	}
	for (int i = 1; i <= h - 1; i++) {
		long long int s1 = i * w;
		long long int s2 = (h - i) * (w % 2 + w / 2);
		long long int s3 = (h - i) * (w / 2);
		long long int mins = min(s1, min(s2, s3));
		long long int maxs = max(s1, max(s2, s3));
		ans = min(ans, maxs - mins);
	}
	cout << ans;
}


Measured memory_bytes: 256
N = int(input())

ans = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}

for _ in range(N):
    s = input()
    ans[s] += 1

print(f"AC x {ans['AC']}")
print(f"WA x {ans['WA']}")
print(f"TLE x {ans['TLE']}")
print(f"RE x {ans['RE']}")


Measured memory_bytes: 9180
import math
N, K = map(int, input().split())
As = sorted(list(map(int, input().split())))
Bs = sorted(list(map(int, input().split())))[::-1]
Cs = [a*b for a, b in zip(As, Bs)]
BCs = list(zip(Bs, Cs))

def func(target):
    r = 0
    for b, c in BCs:
        r += math.ceil(max(0, c - target) / b)
    return r <= K

if __name__ == '__main__':
    min_i, max_i, index = 0, max(Cs)+1, 1
    while True:
        if func(index):
            index, max_i = (index-1 + min_i)//2, index-1
        else:
            index, min_i = (index+1 + max_i)//2, index+1
        if min_i > max_i:
            print(min_i)
            break

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

ll H, W;

tuple<ll, ll> half(ll x, ll y){
    if(abs((x / 2) * y - (x - x / 2) * y) < abs((y / 2) * x - (y - y / 2) * x)){
        return std::make_tuple((x / 2) * y, (x - x / 2) * y);
    }
    return std::make_tuple((y / 2) * x, (y - y / 2) * x);
}

ll solve(){
    ll res = 1001001001001001001ll;
    for(ll i=1;i<W;++i){
        ll a, b;
        tie(a, b) = half(H, W - i);
        
        res = min(res, max({i * H, a, b}) - min({i * H, a, b}));
    }

    return res;
}

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

    std::cin >> H >> W;

    ll res = solve();
    swap(W, H);
    res = min(res, solve());

    std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int main(){
	n=read();m=read();
	if(n==m)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
def is_prime(x):
    for i in range(2, int(x ** 0.5) + 1):
        if x % i == 0:
            return False
    else:
        return True


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

    while True:
        if is_prime(x):
            ans = x
            break
        x += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 63136
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<string, int> P;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}


int main()
{
	ios_base::sync_with_stdio(false);
	ll n , k, ans = 0;
	vector<char> s(3);
	cin >> s[0] >> s[1] >> s[2];
	sort(reall(s));
	n = (s[0] - '0') * 10 + (s[1] - '0');
	k = s[2] - '0';
	cout << n + k << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    Int N, K; cin >> N >> K;
    vector<Int> A(N + 1); for (auto &a : A) cin >> a;
    for (int i = 0; i < K; i++) {
        vector<Int> B(N + 1);
        for (int j = 0; j < N; j++) {
            B[max(j - A[j], 0LL)] += 1;
            B[min(j + A[j] + 1, N)] -= 1;
        }
        for (int j = 1; j < N; j++) {
            B[j] += B[j - 1];
        }
        bool fin = true;
        for (int j = 0; j < N; j++) {
            if (B[j] != N) {
                fin = false;
                break;
            }
        }
        swap(A, B);
        if (fin) break;
    }
    for (int i = 0; i < N; i++) {
        cout << A[i] << " \n"[i + 1 == N];
    }
    return 0;
}

Measured memory_bytes: 6364
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    string s;
    cin >> s;
    int n = s.length();
    string ans;

    if (s.length() < 26){
        VI x(26);
        for (char c : s) x[c - 'a'] = 1;
        REP(i,26){
            if (x[i] == 0){
                ans = s + (char)('a' + i);
                break;
            }
        }
    }else{
        int x = -1, p;
        FORR(i,n-1,0){
            if (s[i] - 'a' > x){
                x = s[i] - 'a';
                p = i;
            }else{
                break;
            }
        }
        if (p == 0){
            ans = "-1";
        }else{
            ans = s.substr(0, p-1);
            VI x(26);
            for (char c : ans) x[c - 'a'] = 1;
            FOR(i,s[p-1]-'a'+1,25){
                if (x[i] == 0){
                    ans += ('a' + i);
                    break;
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N, Z, W = getNM()
A = getList()

# 相手に手番を渡さない
if N == 1:
    print(abs(A[0] - W))
else:
    print(max(abs(A[-1] - W), abs(A[-1] - A[-2])))

Measured memory_bytes: 83356
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

int main() {
    int N;
    cin >> N;
    
    priority_queue<int> left, right;
    vector<int> mid;
    
    int x;
    ll suml=0, sumr=0;
    rep(i,N){ cin>>x; left.push(-x); suml+=x;}
    rep(i,N){ cin>>x; mid.push_back(x);}
    rep(i,N){ cin>>x; right.push(x); sumr+=x;}
    
    ll nums[100009], maxv=suml-sumr;
    mem(nums,0);
    
    ll tmp = suml;
    rep(i,N){
        if( mid[i] > -left.top() ){
            tmp += mid[i] + left.top();
            left.pop(); left.push(-mid[i]);
        }
        nums[i] = tmp;
    }
    
    maxv = max(maxv, nums[N-1]-sumr);
    
    tmp = sumr;
    rrep(i,N-1){
        if( mid[i] < right.top() ){
            tmp += mid[i] - right.top();
            right.pop(); right.push(mid[i]);
        }
        if( i && maxv < nums[i-1] - tmp ){
            maxv = nums[i-1] - tmp;
        }
    }
    
    maxv = max(maxv, suml-tmp);
    
    cout1(maxv);
}

Measured memory_bytes: 2296
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
//    cout << fixed << setprecision(10);
    long long N, M, K;
    const int MOD = 998244353;
    cin >> N >> M >> K;
    
    vector<long long>(K + 1);
    
    long long sum = 0;
    long long current = M;
    if (K == N - 1) {
        sum += current;
    }
    for (int i = 0; i < N - 1; i++) {
        current *= (N - i - 1);
        current %= MOD;
        current *= modinv(i + 1, MOD);
        current %= MOD;
        current *= (M - 1);
        current %= MOD;
        if (N - i - 2 <= K) {
            sum += current;
            sum %= MOD;
        }
    }
    
    cout << sum;
    
    return 0;
}


Measured memory_bytes: 4684
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
		
const double eps = 1e-9;																							   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

int n;
string tab[1005];
set<string> SET;

///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////



/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    bool check = true;
    string previous, s;
    cin >> n;
    for(int i = 0; i < n; i++){
		if(i == 0){
			cin >> previous;
			SET.insert(previous);
		}
		else{
			cin >> s;
			auto it = SET.find(s);
			if(it != SET.end()){
				check = false;
			}
			else{
				int len = previous.length();
				if(s[0] == previous[len - 1]){
					previous = s;
					SET.insert(previous);
				}
				else{
					check = false;
				}
			}
		}
	}
	
	
	if(check)
		cout << "Yes" << endl;
	else cout << "No" << endl;
 
	
	
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int p;
    int o;
    p=1;
    o=1;

   while(o<=9){
   	  p=1;
      while(p<=9){
        printf("%dx%d=%d\n",o,p,o*p);
        p++;
        }
        o++;
      }
    return 0;
}

Measured memory_bytes: 524
#include<stdio.h>
void call(int);
int main(void){
int n;
scanf("%d",&n);
call(n);
return 0;
}


void call(int n){
  int i ,x;
for(i=1;i<=n;i++){
  x = i;
  if ( x % 3 == 0 ){
     printf(" %d",i);
     }else{
  while(x>0){
     if ( x % 10 == 3 ){
        printf(" %d",i);
        break;
        }
    x = x / 10;
    }}
   }
  printf("\n");
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <string>

using namespace std;

void solve();

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

void solve() {
    int N;
    cin >> N;
    int A[N];
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for(int i = 0; i < N; i++) {
        A[i] %= 2;
    }
    int sumA = 0;
    int sumB = 0;
    for(int i = 0; i < N; i++) {
        if(A[i] == 0) sumA++;
        else sumB++;
    }
    if(sumB % 2 == 1) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }

}

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

int main()
{

    map<string,int> mp;

    int n;
    cin>>n;

    int ac,wa,tle,re;
    ac = wa = tle = re = 0;
    while(n--){
        string temp;
        cin>>temp;

        if(temp=="AC"){
            ac++;
        }
        else if(temp=="WA"){
            wa++;
        }
        else if(temp=="TLE"){
            tle++;
        }
        else{
            re++;
        }
    }

    cout<<"AC x "<<ac<<"\n";
    cout<<"WA x "<<wa<<"\n";
    cout<<"TLE x "<<tle<<"\n";
    cout<<"RE x "<<re<<"\n";
}




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

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<bool> isAC(n+10,false);
    int wa = 0,ac = 0;
    int p;
    string s;
    vector<int> wa_cnt(n+10,0);
    rep(i,m){
        cin >> p >> s;
        p--;
        if(s == "WA" && isAC[p] == false){
            wa_cnt[p]++;
        }else if(s == "AC" && isAC[p]==false){
            ac++;
            wa += wa_cnt[p];
            isAC[p] = true;
        }
    }

    cout << ac << " " << wa << endl;
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <cstring>

using namespace std;
int main(){
	while (true){
		string str; cin >> str;
		if (str == "0") break;
		int sum = 0;
		for (int i = 0; i < str.size(); ++i){
			char ch = str[i];
			sum += (ch - '0');
		}
		cout << sum << '\n';
	}
}

Measured memory_bytes: 1192
#include <algorithm>
#include <iostream>
using namespace std;
int main(void){
    int datas;
    cin>>datas;
    for(int i = 0; i < datas; i++)
    {
        int n;
        int k;
        cin >> n;
        cin >> k;
        int houses[n];
        if(n < k){
            k = n;
        }
        for(int j = 0; j < n;j++){
            cin >> houses[j];
        }
        int distances[n-1];
        for(int j = 0;j < n-1;j++){
            distances[j] = houses[j+1]-houses[j];
        }
        sort(distances,distances+n-1);
        int length = 0;
        for(int j = 0;j <= n - k - 1; j++){
            length += distances[j];
        }
        cout << length << endl;
    }
}

Measured memory_bytes: 3916
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<math.h>
#include<stack>
#include<sstream>
#include <typeinfo>
#include<sstream>
#include<queue>
using namespace std;



int main(){
	int N,q;//qがクオンタイム
	cin>>N>>q;
	queue<string>n;//name
	queue<int>t;//time
	vector<string>name;
	vector<int>time;
	
	for(int i=0;i<N;i++){
		string s;int a;
		cin>>s>>a;
		n.push(s);t.push(a);
	}
		int now=0;
	while(!t.empty()){
		int a=0;
		a=t.front();
		string b=n.front();
		if(a>q){//a>q今回処理が終了しない場合
			t.pop();
			n.pop();///
			a-=q;
			t.push(a);
			n.push(b);///
			now+=q;
		}
		else if(a<=q){
			t.pop();
			n.pop();///
			now+=a;
			time.push_back(now);
			name.push_back(b);
		}
	}
	for(int i=0;i<time.size();i++){
		cout<<name[i]<<" "<<time[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 4788
/*                                  /   \                                                                   (Hello)//JSM//*/      
/*                                 /*****\                                                                              */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K                                                            */
#include<bits/stdc++.h>            
#include<cmath>                  
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define pb push_back 
#define mkp make_pair    
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define rall(v )  reverse(v.begin(), v.end())      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vll vector< pair<ll,ll> > 
#define mpl map<ll, ll>
#define ee cout<<endl
#define pr pair<ll,ll>
ll pow1(ll n,ll p){if(p==0)return 1;ll x=pow1(n, p/2);x=(x*x)%MOD;if(p%2==0) return x;else return (x*n)%MOD;}
/*ll vis[100023];
ll a[100023];
vl v0[100023];
vl v1[100023];
vl V[100023];
ll col[100023];
ll ans=0;
vl L[100023];
ll mx=0;
void dfs(ll node,ll f)
{
	if(vis[node]==1)
	return;
	vis[node]=1;
	mx=max(mx,f);
	L[f].pb(node);
	for(i=0;i<V[node].size();i++)
	{
		dfs(V[node][i],f+1);
	}
}
*/
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll t=1;
	   //cin>>t;
	      while(t--)
{
string a;
ll c=0,i;
ll mx=0;
cin>>a;
fo(i,a.length())
{
	if(a[i]=='R')
	c++;
	else
	c=0;
	mx=max(mx,c);
}
cout<<mx;
ee;
/*ll n,m,j,k,l,i;
cin>>n;
ll a[n],b[n];
string s;
fo(i,n-1)
{
	cin>>a[i]>>b[i];
	V[a[i]].pb(b[i]);
	V[b[i]].pb(a[i]);
}
cin>>s;
ans=0;
mx=0;
fo(i,n)
vis[i+1]=0;
dfs(1,1);
ll h=2;
ans=0;
for(i=mx;i>=1;i--)
{
	if(L[i].size()>=h)
	{
		ans=-1;
		break;
	}
}
*/

/*
1  
7  
1 2  
1 3  
2 4  
2 5  
3 6  
3 7  
0010010*/
}
return 0;
}
















Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n, m;
  cin >> n >> m;
  vector<i64> edge[n * 3];
  for (i64 i = 0; i < m; i++)
  {
    i64 u, v;
    cin >> u >> v;
    u--;
    v--;
    edge[u].push_back(n + v);
    edge[n + u].push_back(n * 2 + v);
    edge[n * 2 + u].push_back(v);
  }
  i64 s, t;
  cin >> s >> t;
  s--;
  t--;
  vector<i64> cost(n * 3, 1e18);
  queue<i64> que;
  cost[s] = 0;
  que.push(s);
  while (que.size())
  {
    i64 p = que.front();
    que.pop();
    for (i64 i : edge[p])
      if (cost[p] + 1 < cost[i])
      {
        cost[i] = cost[p] + 1;
        que.push(i);
      }
  }
  if (cost[t] == 1e18)
    cout << -1 << endl;
  else
    cout << cost[t] / 3 << endl;
  return 0;
}


Measured memory_bytes: 18944
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		//入力
		int amount_btn = sc.nextInt();
		int answer = 1;

		//ボタンの遷移先リスト
		ArrayList<Integer> array_btn = new ArrayList<>();

		for (int i = 0; i < amount_btn; i++) {
			int btn_destination = sc.nextInt();
			array_btn.add(btn_destination);
		}

		//ボタンが使われたかどうかの確認マップ
		Map<Integer, Integer> btn_map = new HashMap<Integer, Integer>();

		//初期値の使われていない状態：0
		for (int i = 0; i <= amount_btn; i++) {
			btn_map.put(i,0);
		}

		int j = 0;

		loop: while(j <= amount_btn) {
			//もしボタンの遷移先が2であれば、終了
			if (array_btn.get(j) == 2) {
				break loop;
			}

			//もしボタンの遷移先が2でなければ、
			else {

				//もしボタンをすでに使用したことがあれば、ループしているので終了
				if (btn_map.get(j) == -1) {
					answer = -1;
					break loop;
				}
				//もしボタン未使用であれば、ボタンを使用した状態にして、次のボタンに遷移
				else {
					btn_map.put(j,-1);
					answer ++;
					j = array_btn.get(j) -1;
				}

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


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

int main(){
  int d;
  cin >> d;
  if( d == 25)
    cout << "Christmas\n";
  else if( d == 24 )
    cout << "Christmas Eve\n";
  else if( d == 23 )
    cout << "Christmas Eve Eve\n";
  else if( d == 22)
    cout << "Christmas Eve Eve Eve\n";
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		if (b - a > x) {
			pr.println("dangerous");
		} else if (b - a > 0) {
			pr.println("safe");
		} else {
			pr.println("delicious");
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


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

const int N = 50;

int first,second;
string n[50];
string m[50];

int main()
{
	cin >> first >> second;
	
	for(int i=0;i<first;i++)
	{
		cin >> n[i];	
	}
	
	for(int i=0;i<second;i++)
	{
		cin >> m[i];	
	}
	int ok = 0;
	for(int i=0;i + (second-1)<first;i++)
	{
		for(int j=0;j + (second-1)<first;j++)
		{
			ok = 0;
			int tmp = i;
			int tmp2 = j;
				for(int k=0;k<second;k++)
				{
					for(int l=0;l<second;l++)
					{
						tmp = i + k;
						tmp2 = j + l;
						if(m[k][l] == n[tmp][tmp2]) ok++;
						else break;
					}
				}
			if(ok == second * second)
			{
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
}






















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

int main() {
  ll x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<ll> a(x), b(y), c(z);
  rep(i, x) cin >> a[i];
  rep(i, y) cin >> b[i];
  rep(i, z) cin >> c[i];
  vector<ll> cur;
  rep(i, x) rep(j, y) { cur.push_back(a[i] + b[j]); }
  sort(cur.begin(), cur.end(), greater<>());
  if (cur.size() > k) cur.resize(k);
  vector<ll> res;
  rep(i, cur.size()) rep(j, z) { res.push_back(cur[i] + c[j]); }
  sort(res.begin(), res.end(), greater<>());
  rep(i, k) { cout << res[i] << endl; }
  return 0;
}


Measured memory_bytes: 44120
#include <iostream>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
//#define hell        1000000007
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.000000001
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e7+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

using namespace std;
#include <stdio.h>

ll power(ll x,ll y)
{
  ll res=1;
  while(y>0){
    if(y%2) res=(x%hell*res%hell)%hell;
    x=(x%hell*x%hell)%hell;
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,hell-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/

void solve(){
  int test;
  //cin>>test;
  test=1;
  
  while(test--){
      int h,n;
      cin>>h>>n;
      
      ll a[n],c[n];
      forn(i,0,n)
      cin>>a[i]>>c[i];
      
      ll dp[h+1][n+1];
      for(int i=0;i<=n;i++)
      dp[0][i]=0;
      
      for(int i=1;i<=h;i++)
      dp[i][0]=INT_MAX;
   
      for(int i=1;i<=h;i++){
          for(int j=1;j<=n;j++){
              dp[i][j]=dp[i][j-1];
              
              if(a[j-1]>i)
              dp[i][j]=min(dp[i][j],dp[0][j]+c[j-1]);
              else
              dp[i][j]=min(dp[i][j],dp[i-a[j-1]][j]+c[j-1]);
          }
      }
      cout<<dp[h][n];
  }    
}    

    




///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll a,ll b)
{
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}


Measured memory_bytes: 78464
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
#include<functional>
#include <tuple>
#include<iomanip>
#include<cmath>
using namespace std;
int main() {
	int n, m; cin >> n >> m;
	string a[2000],b[2000];
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> b[i];
	}
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			if (a[i][j] != b[i][j]) ++cnt;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 11304
#include <cstdio>
const int MAXN = 51;
const int ZERO = 2550;
const int MAXM = ZERO * 2;
typedef long long LL;
LL F[2][MAXM];
int main() {
	int n, a, i, j, x;
	scanf ( "%d%d", &n, &a );
	F[0][ZERO] = 1;
	for ( i = 1; i <= n; ++i ) {
		scanf ( "%d", &x );
		x -= a;
		for ( j = MAXN; j + MAXN < MAXM; ++j )
			F[i & 1][j] = F[ ( i - 1 ) & 1][j] + F[ ( i - 1 ) & 1][j - x];
	}
	printf ( "%lld\n", F[n & 1][ZERO] - 1 );
}


Measured memory_bytes: 256
x = int(input())
if x == 1:
  print(0,-1)
  exit()
  
def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

c = []
fct = factorize(x)
for div in divisorize(fct):
    c.append(num(div))
    
chk = False
for s in c:
  if chk:
    break
  for i in range(1000):
    if (i+s)**5-i**5 > x:
      break
    if (i+s)**5-i**5 == x:
      ans = (i+s,i)
      chk = True
      break
  if s <1000:    
    for p in range(s,1000):
      j = -1*p
      #print(s,(j+s)**5-j**5)
      if (j+s)**5-j**5 > x:
        break 
      if (j+s)**5-j**5 == x:
        ans = (j+s,j)
        chk = True
        break 
  for ww in range(1,(s+1)//2)[::-1]:
    jj = -1*ww
    if (jj+s)**5-jj**5 > x:
      break    
    if (jj+s)**5-jj**5 == x:
      ans = (jj+s,jj)
      chk = True
      break 
print(*ans)


Measured memory_bytes: 9248
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            // 条件を順番に潰していく。
            // WAの条件に引っかかった時点で出力し、最後まで残ったものがACになる。

            // Aから始まるか判定
            if (!S.StartsWith("A"))
            {
                Console.WriteLine("WA");
                return;
            }

            // 3文字目と末尾から2文字目の間にCがあるか判定
            var tmp = S.Substring(2, S.Length - 3);
            if (tmp.Where(x => x == 'C').ToList().Count != 1)
            {
                Console.WriteLine("WA");
                return;
            }

            // 3文字目と末尾から2文字目に存在する大文字Cの位置を求める
            var cindex = tmp.IndexOf('C') + 2;
            // AとCを消す
            S = S.Remove(cindex, 1).Remove(0, 1);

            bool ret = true;
            foreach (var item in S)
            {
                if (char.IsUpper(item))
                {
                    ret = false;
                    break;
                }
            }

            if (ret)
            {
                Console.WriteLine("AC");
            }
            else
            {
                Console.WriteLine("WA");
            }
        }
    }
}

Measured memory_bytes: 13408