akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
#define Length 80000
using namespace std;
typedef pair<ll, ll> P;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

bool used[110];

bool cmp(const pair<int,int> &a,const pair<int,int> &b) {
	return a.first * a.first + a.second * a.second > b.first*b.first + b.second * b.second;
}

void solve(int n) {
	vector<pair<int, int>>p(n), q(n);
	for (int i = 0;i < n;i++) {
		cin >> p[i].first >> p[i].second;
	}
	for (int i = 0;i < n;i++) {
		cin >> q[i].first >> q[i].second;
	}
	int dist = Length, flag = 0;
	int ans = 0;
	sort(p.begin(), p.end());
	for (int i = 0;i < n;i++) {
		dist = Length;
		flag = 0;
		for (int j = 0;j < n;j++) {
			if (!used[j]) {
				int x = q[j].first - p[i].first;
				int y = q[j].second - p[i].second;
				if ((x > 0) && (y > 0) && y < dist) {
					dist = y;
					flag = j;
				}
			}
		}
		if (dist < Length) {
			ans++;
			used[flag] = true;
		}
	}
	cout << ans << endl;
}

ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}

char board[110][110];
	
int main(void){
	ll a, b, c;
	cin >> a >> b >> c;
	if ((a % 2 == 0) || (b % 2 == 0) || (c % 2 == 0))cout << 0 << endl;
	else {
		ll ans = a * b*(c - (c / 2) * 2);
		ans = min(ans, b*c*(a - (a / 2) * 2));
		ans = min(ans, c*a*(b - (b / 2) * 2));
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
while True:
    tmp = input().split(' ')
    a = int(tmp[0])
    b = int(tmp[2])
    if (tmp[1] == '+'):
        print(a+b)
    elif(tmp[1] == '-'):
        print(a-b)
    elif(tmp[1] == '/'):
        print(int(a/b))
    elif(tmp[1] == '*'):
        print(a*b)
    else:
        break


Measured memory_bytes: 5596
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)

func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func()
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx++
		return cur
	}
	this.initWordIdx = func() {
		idx = 0
	}
	return &this
}

func (me *ReaderEx) ScanAndSplit() (isScanned bool) {
	isScanned = me.baseScanner.Scan()

	me.words = strings.Fields(me.baseScanner.Text())
	me.initWordIdx()
	return
}

func (me *ReaderEx) Scan() (ok bool) {
	ok = me.baseScanner.Scan()
	return
}
func (me *ReaderEx) getString() string {
	return me.baseScanner.Text()
}

func (me *ReaderEx) getInt() int {
	n, err := strconv.Atoi(me.baseScanner.Text())
	defer func() {
		if err != nil {
			panic(err)
		}
	}()

	return n
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, fa)
		}
	}
	if n > 1 {
		facts = append(facts, factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func solve(stdin io.Reader, stdout io.Writer) {
	r := NewScannerEx(stdin)
	r.ScanAndSplit()
	n, m := r.nextInt(), r.nextInt()
	max := func(a int, vs ...int) int {
		for _, v := range vs {
			if a < v {
				a = v
			}
		}
		return a
	}
	if m == 1 {
		m = 3
	}
	if n == 1 {
		n = 3
	}
	fmt.Fprintln(stdout, max(0, m-2)*max(0, n-2))

}



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

char s[100];

int main()
{
	scanf("%s",s+1);
	int len=strlen(s+1);
	if(s[1]!='A')
	{
		puts("WA");
		return 0;
	}
	int cnt=0;
	for(int i=3;i<=len-1;++i)
	{
		if(s[i]=='C')++cnt;
	}
	if(cnt!=1)
	{
		puts("WA");
		return 0;
	}
	cnt=0;
	for(int i=2;i<=len;++i)
	{
		if(isupper(s[i]))
		{
			if(s[i]=='C' && i>=3 && i<=len-1)
			{
				if(cnt)
				{
					puts("WA");
					return 0;
				}
				else ++cnt;
			}
			else
			{
				puts("WA");
				return 0;
			}
		}
	}
	puts("AC");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, a, b; cin >> n >> a >> b;
  a--; b--;
  if(abs(a-b)%2==0) {
    cout << abs(a-b)/2 << endk;
  } else {
    ll mn = min(a, b);
    ll mx = max(a, b);
    cout << min(mn+1, n-mx)+(mx-mn-1)/2 << endk;
  }
  return 0;
}


Measured memory_bytes: 3648
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a / gcd(a, b) * b ;
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */

signed main() {
    int x,y,a,b,c;cin >> x >> y >> a >> b >> c;
    vector<P> v;
    rep(i, a) {
		int k;cin >> k;
		v.pb({k,0});
	}
	rep(i, b) {
		int k;cin >> k;
		v.pb({k,1});
	}
	rep(i, c) {
		int k;cin >> k;
		v.pb({k,2});
	}
	resort(v);
	int count = 0;
	int sum = 0;
	int i = 0;
	while(x+y-count>0) {
		if(v[i].second==0) {
			if(x) {
				sum+=v[i].first;
				x--;
			}
		}
		else if(v[i].second==1) {
			if(y) {
				sum+=v[i].first;
				y--;
			}
		}
		else {
			sum+=v[i].first;
			count++;
		}
      i++;
      //cout << sum << endl;
	}
	cout << sum << endl;
    return 0;
}


Measured memory_bytes: 11616
from copy import deepcopy
import sys
input = sys.stdin.readline


def floyd_warshall(dist):
    v = len(dist)
    for k in range(v):
        for i in range(v):
            for j in range(v):
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])


N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
dist = deepcopy(A)
floyd_warshall(dist)
edges = []
for u in range(N-1):
    for v in range(u+1, N):
        edges.append((A[u][v], u, v))
edges.sort()
ans = 0
for d, u, v in edges:
    if dist[u][v] < d:
        ans = -1
        break
    ok = False
    for w in range(N):
        if w == u or w == v:
            continue
        if dist[u][w] + dist[w][v] == dist[u][v]:
            ok = True
            break
    if not ok:
        ans += d
print(ans)


Measured memory_bytes: 61056
A,B,C=(int(x) for x in input().split())

if B==0:
    x=C//A
    if C%A!=0:
        x=x+1

elif A>C:
    x=1
elif C//A<7:
    x=C//A+1
else:
    t=0
    y=A*7
    y=y+B
    z=C%y
    if 0<z<A:
        t=1
    z=z//A
    if z>7:
        t=7-z
    s=C//y
    s=s*7
    x=z+s+t
print(x)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;cin >> N;
    vector<LL> a(N);
    vector<LL> b(N);
    rep(i,N)cin >> a[i] >> b[i];
    vector<LL> ans(N);
    LL A = 1;
    LL B = 1;
    rep(i,N){
        ans[i] = max((A+a[i]-1)/a[i],((B+b[i]-1)/b[i]));
        A = ans[i]*a[i];
        B = ans[i]*b[i];
    }
    cout << A + B << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

ll n;
vvl G(202020);
vl a(202020);
vl ans(202020);
vl dp;
ll siz = 0;

void dfs(ll u, ll p){
	ll id = inf;
	ll tmp = 0;
	auto itr = lower_bound(all(dp),a[u]);
	if(itr == dp.end()){
		dp.push_back(a[u]);
	}else{
		id = itr - dp.begin();
		tmp = *itr;
		*itr = a[u];
	}
	ans[u] = dp.size();
	for(auto v : G[u]){
		if(v == p) continue;
		dfs(v,u);
	}
	if(id == inf) dp.pop_back();
	else dp[id] = tmp;
}


int main(){
	ll n; cin >> n;
	rep(i,n) cin >> a[i];
	rep(i,n-1){
		ll u,v; cin >> u >> v; u--; v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(0,-1);
	rep(i,n){
		cout << ans[i] << "\n";
	}
}

Measured memory_bytes: 28824
#include <stdio.h>

int Count(int N, int H, int W){
  int i, j, c;
  c = 0;
  for(i = 0;i < N;i++) for(j = 0;j < N;j++) if(i + H <= N && j + W <= N) c++;
  return c;
}

int main(void){
  int N, H, W;
  scanf("%d %d %d", &N, &H, &W);
  printf("%d\n", Count(N, H, W));
  return 0;
}


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

using namespace std;

int main()
{
	int N;
	cin>>N;
	int a,b,c;
	a=N%10;
	b=(N%100)/10;
	c=N/100;
	if(a==7 || b==7 || c==7)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <cmath>
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

//bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


int main() {

    cpp_int  a, b;

    cin >> a >> b;

    cout << (a * b) << endl;

}



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

int main() {
	int n, k;
	cin >> n >> k;

	vector<int> p;

	int tmp;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		p.push_back(tmp);
	}

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

	int ans = 0;
	for (int i = 0; i < k; i++) {
		ans += p[i];
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3596
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] h = new int[n];
		List<List<Integer>> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
			list.add(new ArrayList<>());
		}
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			list.get(a).add(b);
			list.get(b).add(a);
		}
		int count = 0;
		boolean[] dp = new boolean[n + 3];
		for (int i = 0; i < n; i++) {
			if (dp[i]) {
				continue;
			} else {
				boolean flag = true;
				int val = h[i];
				for (int j = 0; j < list.get(i).size(); j++) {
					if (val <= h[list.get(i).get(j)]) {
						flag = false;
						dp[i] = true;
						break;
					} else {
						dp[list.get(i).get(j)] = true;
					}
				}
				
				if (flag) {
					++count;
				}
			}
		}
		System.out.println(count);
	}
}


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


int main() {
  string S; cin >> S;
  int n = S.size();
  ll ans = 0;
  rep(bit, (1<<n-1)){
    ll sum = 0;
    rep(i,n){
      if(bit &(1<<i-1)){
        ans += sum;
        sum = S[i] - '0';
      } else {
        sum = sum * 10 + S[i] -'0';
      }
    }
    ans += sum;
  }
  cout << ans << endl;
	return 0;
}



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

int main(){
	int n;
  	cin>>n;
  	int arr[n];
  	for(int i=0;i<n;i++){
    	cin>>arr[i];
    }
  	int dp[n];
  	dp[0] = 0;
  	dp[1] = abs(arr[1]-arr[0]);
  	for(int i=2;i<n;i++){
    	dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
  	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<queue>

#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 1000000007
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;
ll dx[4] = {1,0,0,-1};
ll dy[4] = {0,1,-1,0};

#define ARRAY_MAX 100005

int dp[ARRAY_MAX];

int main(){

    int n;
    cin >> n;
    REP(i,n+1){
        dp[i] = i;
    }

    dp[0] = 0;

    for(int i = 1;i <= 6;i++){
        int tmp = int(pow(6,i));
        for(int j = 1;j <= n;j++){
            if(j >= tmp){
                dp[j] = min(dp[j],dp[j-tmp]+1);
            }
            
        }
    }
   
    for(int i = 1;i <= 5;i++){
        int tmp = int(pow(9,i));
        for(int j = 1;j <= n;j++){
            if(j >= tmp){
                dp[j] = min(dp[j],dp[j-tmp]+1);
            }
        }
    }

    cout << dp[n] << endl;
    return 0;
}

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

vector<int> primes(){
   vector<int> result;
   result.push_back(2);

   for(int i=2; i<1120; i++){
      for(int j=2; j<i; j++){
         if(i%j==0) break;
         if(j==i-1) result.push_back(i);
      }
   }
   return result;
}

int main(){
   vector<int> prime = primes();
   vector<vector<long>> table(14+1, vector<long>(1120+1, 0));
   table[0][0] = 1;
   for(int p : prime){
      for(int i=14; i>0; i--){
         for(int k=p; k<=1120; k++){
            table[i][k] += table[i-1][k-p];
         }
      }
   }
   
   int n,k;
   while(cin>>n>>k, n||k){
      cout << table[k][n] << endl;
   }
}



Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,counta,countall,countb;
  cin>>N;
  counta=0;
  countall=0;
  vector <int> vec(N);
  for(int i=0;i<N;i++)
    cin>>vec.at(i);
  sort(vec.begin(),vec.end());
  reverse (vec.begin(),vec.end());
  for (int i=0;i<N;i+=2)
    counta+=vec.at(i);
  for (int i=0;i<N;i++)
    countall+=vec.at(i);
  countb=countall-counta;
  cout<<counta-countb<<endl;
}

Measured memory_bytes: 256
x, y = gets.split.map(&:to_i)

kame = (y - 2 * x) / 2.0
tsuru = (4 * x - y) / 2.0

if (kame % 1 == 0 && tsuru % 1 == 0 && kame >= 0 && tsuru >= 0)
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 14416
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
using namespace std;

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

    long long pattern = 0;
    for(int s = 0;s<=K;s++)
    {
        for(int t = 0;t<=K;t++)
        {
            if(s+t<=S)
            {
                int u = S-(s+t);
                if(u<=K)pattern++;
            }
        }
    }
    cout<<pattern<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    vector <ll> nums;
    ll d = 14;
    REP(i, d){
        nums.push_back(pow(26, i));
    }
    //dumparr(nums)
    ll n; cin >> n;
    ll n_orig = n;
    vector <ll> ans;
    REP(i, d){
        ll num = nums[d-1-i];
        if (n_orig >= num){
            ans.push_back(n / num);
        } else {
            ans.push_back(-1);
        }
        n %= num;
    }
    dumparr(ans)
    REP(_, 15){
        REP(i, d-1){
            if ((ans[i] != -1) && (ans[i+1] == 0)){
                ans[i] -= 1;
                ans[i+1] = 26;
            }
        }
    }
    dumparr(ans)
    REP(i, d){
        if (ans[i] > 0) {
            cout << char(ans[i]-1 + 'a');
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4108
n=int(input())
l=[0]*(n)
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            k=x**2+y**2+z**2+x*y+x*z+y*z
            if k<=n:
                l[k-1]+=1
print(*l,sep="\n")

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

int N,K;
int f(int n) {
    int q = 0;
    while(n < K) {
        q++;
        n *= 2;
    }
    return q;
}
int main(){
    cin >> N >> K;
    double ans=0;
    for (int i = 1; i <= N; i++)
    {
        double a = 1.0 / N;
        int p = i;
        while(p < K) {
            p *= 2;
            a *= 0.5;
        }
        ans += a;
        
    }
    cout << fixed << setprecision(12) << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<malloc.h>
#include<cstring> 
#include<cctype>
#include <algorithm>
using namespace std;
const int maxn=5e5+5;

int main(){
	std::string s ;
      cin>>s;
	 int q;
	 cin>>q;
     int k; 
	 while(q--){
	 	 int x;
	 	 cin>>x;
	 	 if(x==1)
	 	 {  k++;
		  }
	 	 else
	 	 {    
		     int y;
	 	 	cin>>y;
	 	 	char l;
	 	 	cin>>l;
	 	 	if(y==1){
	 	 		  string::iterator p = s.begin();
	 	 		  if(k%2==0)
	 	 	     s.insert(s.begin(),l);
	 	 	     else 
	 	 	      s.insert(s.end(),l);
			  }
			if(y==2){
			string::iterator p = s.end();
			   if(k%2==0)
	 	 	     s.insert(s.end(),l);
	 	 	     else 
	 	 	      s.insert(s.begin(),l);
			}
			
	 }} 
	    if(k%2==1) 
	    reverse(s.begin(),s.end());
	    cout<<s<<endl; 
} 



Measured memory_bytes: 900
#include "bits/stdc++.h"
using namespace std;
 
int main(void) {
	int k, s;
	cin >> k >> s;

	int count=0;
	int z;

	for(int x=0;x<=k;x++) {
		for(int y=0;y<=k;y++) {
			z = s-x-y;
			if(0<=z && z<=k) count++;
		}
	}

	cout << count << endl;
}


Measured memory_bytes: 256
N = int(input())
sets = []

cnt = 0
s2c = {} #counter

for i in range(N):
  s = input()
  s = ''.join(sorted(s))
  if s in s2c.keys():
    cnt += s2c[s]
    s2c[s] += 1
  else:
    s2c[s] = 1
print(cnt)

Measured memory_bytes: 17808
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    int n, ans = 0;
    cin >> n;
    int a[n];
    rep(i, n)
    {
        cin >> a[i];
        ans ^= a[i];
    }
    if (ans == 0)//全要素の排他的論理和がゼロの時題意をみたす
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
int main() {
    string s ;
    cin >> s ;
    reverse(s.begin(), s.end()) ;
    if(s[0] == 's'){
        reverse(s.begin(), s.end()) ;
        cout << s + "es" << endl ;
    }
    else {
        reverse(s.begin(), s.end()) ;
        cout << s + 's' << endl ;
    }
} 

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

int main() {
    int n,i,r;
    cin >> n;
    vector<int> a(n);

    for(i=0; i<n; i++)
        cin >> a.at(i);
    sort(a.begin(), a.end());

    for(i=0; i<n-1; i++)
        if(a.at(i) >= a.at(a.size()-1)/2)
            break;
    if(i == n-1)
        r = a.at(i-1);
    else if(abs(a.at(a.size()-1)/2-a.at(i)) > abs(a.at(a.size()-1)/2-a.at(i-1)))
        r = a.at(i-1);
    else
        r = a.at(i);

    cout << a.at(a.size()-1) << " " << r << endl;
}

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

public class Main {

  private static void solve() {
    int n = nextInt();
    long k = nextLong();

    int[] cnt = new int[64];

    long[] a = new long[n];
    long ans = 0;
    for (int i = 0; i < n; i++) {
      a[i] = nextLong();
      ans ^= a[i];

      for (int j = 0; j < 64; j++) {
        if ((a[i] & (1L << j)) != 0) {
          cnt[j]++;
        }
      }
    }

    long ans2 = 0;
    for (int i = 0; i < n; i++) {
      ans2 += a[i] ^ k;
    }

    ans = Math.max(ans, ans2);

    for (int i = 0; i < 64; i++) {
      if ((k & (1L << i)) != 0) {
        long xor = 0;
        for (int j = i + 1; j < 64; j++) {
          if ((k & (1L << j)) != 0) {
            xor |= (1L << j);
          }
        }

        for (int j = 0; j < i; j++) {
          if (cnt[j] < n - cnt[j]) {
            xor |= (1L << j);
          }
        }

        long temp = 0;
        for (int j = 0; j < n; j++) {
          temp += (a[j] ^ xor);
        }

        if (ans < temp) {
          ans = temp;
        }
      }
    }

    System.out.println(ans);
  }

  private static void run() {
    br = new BufferedReader(new InputStreamReader(System.in));
    out = new PrintWriter(System.out);

    solve();

    out.close();
  }

  private static StringTokenizer st;
  private static BufferedReader br;
  private static PrintWriter out;

  private static String next() {
    while (st == null || !st.hasMoreElements()) {
      String s;
      try {
        s = br.readLine();
      } catch (IOException e) {
        return null;
      }
      st = new StringTokenizer(s);
    }
    return st.nextToken();
  }

  private static int nextInt() {
    return Integer.parseInt(next());
  }

  private static long nextLong() {
    return Long.parseLong(next());
  }

  public static void main(String[] args) {
    run();
  }
}

Measured memory_bytes: 51048
import java.io.*;
import java.util.*;
public class Main {
static long[][] memo;
static int I,J;
static String h,s;
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
	   h=sc.nextLine();
	   s=sc.nextLine();
	   I=h.length();
	   J=s.length();
	   memo=new long[3003][3003];
	   for(long []a:memo)
		   Arrays.fill(a,-1);
	   solve(0,0);
	 //  System.out.println(memo[0][0]);
	   trace(0,0);
	}
	static long solve(int i, int j)
	{
		if(i >= I || j >= J)
		{
			return 0;
		}
		if(memo[i][j] != -1)	return memo[i][j];
		long opt1 = solve(i + 1, j);
		long opt2 = solve(i, j + 1);
		long opt3 = s.charAt(j) == h.charAt(i) ? solve(i + 1, j + 1) + 1 : 0;
		return memo[i][j] =(long) Math.max(opt1, Math.max(opt2, opt3));
	}
//	static void trace(int i, int j)
//	{
//		if(i >= I || j >= J)	return;
//	 
//		long opt1 = solve(i + 1, j);
//		long opt2 = solve(i, j + 1);
//		if(s.charAt(i) == h.charAt(i))
//		{
//			System.out.println(s.charAt(j));
//			trace(i + 1, j + 1);
//			return; 
//		}
//		else if(opt2 > opt1)
//			trace(i, j + 1);
//		else
//			trace(i + 1, j);
//	 
//	}
	static void trace(int i,int j) {
		if(i==I || j==J)
			return;
		if(h.charAt(i)==s.charAt(j)) {
			System.out.print(s.charAt(j));
			trace(i+1,j+1);
			return;
		}
		if(solve(i+1,j)>solve(i,j+1))
			trace(i+1,j);
		else
			trace(i,j+1);
	}
//	static long dp(int i,int j) {
//		if(i==I || j==J)
//			return 0;
//		if(memo[i][j]!=-1)
//			return memo[i][j];
//		long v=0;
//		if(h.charAt(i)==s.charAt(j))
//	        	v=1+dp(i+1,j+1);
//		return memo[i][j]=Math.max(v, Math.max(dp(i,j+1),dp(i+1,j)));
//	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;
 
		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 130252
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int a, b, c;

	scanf("%d %d %d", &a, &b, &c);

	if (a == b)
		printf("%d", c);
	else if (a == c)
		printf("%d", b);
	else
		printf("%d", a);
	return 0;
}

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

int main() {
  int n;
  int l;
  int r;
  cin >> n;
  int ans = 0;
  
  for (int i = 0; i < n; i++) {
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 200000;

typedef tuple<ll, ll, int> tup;
typedef pair<ll, int> pli;

int main() {
	int n, q;
	cin >> n >> q;
	ll s[N], t[N], x[N];
	rep(i, n) cin >> s[i] >> t[i] >> x[i];
	ll d[N];
	rep(i, q) {
		cin >> d[i];
		d[i] = -d[i];
	}

	vector<tup> interval;
	rep(i, n) interval.push_back(tup(x[i] - t[i], x[i] - s[i], i));
	sort(interval.begin(), interval.end());

	vector<ll> ans;
	bool seen[N];
	rep(i, n) seen[i] = false;
	priority_queue<pli, vector<pli>, greater<pli>> right_lim;
	priority_queue<pli, vector<pli>, greater<pli>> left_x;
	int idx_ival = 0;
	for(int i = q - 1; i >= 0; i--) {
		ll tmp_ans = -1;
		while(idx_ival < n && get<0>(interval[idx_ival]) < d[i]) {
			int j = get<2>(interval[idx_ival]);
			right_lim.push(pli(x[j] - s[j], j));
			left_x.push(pli(x[j], j));
			idx_ival++;
		}
		while(!right_lim.empty() && right_lim.top().first < d[i]) {
			seen[right_lim.top().second] = true;
			right_lim.pop();
		}
		while(!left_x.empty() && seen[left_x.top().second]) {
			left_x.pop();
		}
		if(!left_x.empty()) {
			tmp_ans = left_x.top().first;
		}
		ans.push_back(tmp_ans);
	}

	reverse(ans.begin(), ans.end());
	rep(i, q) cout << ans[i] << endl;
}


Measured memory_bytes: 27372
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <cassert>
using namespace std;

int main(){
    int N;
    cin >> N;
    map<string, long long> mp;
    for(int i=0; i<N; i++){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    long long ans = 0;
    for(auto x : mp){
        ans += x.second*(x.second-1);
    }
    ans /= 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

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

int main() {
  double A, B;
  cin >>  A >> B;
  int e = (A+0.9)/0.08;
  int b = B/0.1;
  int tmp1, tmp2, ans;
  bool flag = false;

  for(int i = b; i <= e; i++){
    tmp1 = i * 0.08;
    tmp2 = i * 0.10;
    if (tmp1==A && tmp2 == B){
      flag = true;
      ans = i;
      break;
    }
  }
  if (flag){
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }

}


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

typedef long long ll;

const int MAXV = 1e5 + 10;
const int MAXN = 1e3 + 10;
const ll INF = 1e13;

ll dp[MAXV];
int N, W, V, wi[MAXN], vi[MAXN];

int main() {
    cin >> N >> W;
    for (int i = 1; i <= N; i++) {
        cin >> wi[i] >> vi[i];
        V += vi[i];
    }

    for (int i = 1; i <= V; i++) dp[i] = INF;
    dp[0] = 0;

    for (int item = 1; item <= N; item++) {
        int w = wi[item], v = vi[item];
        for (int i = V; i >= v; i--) {
            dp[i] = min(dp[i], dp[i - v] + w);
        }
    }

    for (int i = V; i >= 0; i--) {
        if (dp[i] <= W) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    int a, b;

    cin >> a >> b;

    cout << max(a+b, max(a-b, a*b)) << endl;
}


Measured memory_bytes: 256
m = int(input())
keta = 0
goukei = 0
for i in range(m):
    d , c = map(int,input().split())
    keta += c
    goukei += d*c
ans = keta-1 + goukei//9
if goukei % 9 == 0:
    ans -= 1
print(ans)

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

int main() {
	int a,b,x,c1,c2;
	cin >> x >> a >> b;
	if (a<x)c1=x-a;
	else c1=a-x;
	if (b<x) c2=x-b;
	else c2=b-x;
	if (c1<c2) cout << "A";
	else cout << "B";
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
typedef pair<int,int>pi;
#define ff first
#define ss second
#define inf 1000000000
#define IOS ios_base::sync_with_stdio(0)
#define bitseT(y,pos) (1<<pos)|y
#define bitchecK(y,pos) ((1<<pos)&y)
#define meM(y,a) memset(y,a,sizeof y)
#define sC(a) scanf("%d",&a)
#define alL(a) a.begin(),a.end()
#define prinT(a,sz)  cout<<a[0];for(int i=1;i<sz;i++)cout<<" "<<a[i];cout<<endl
int ara[100004];
int main()
{
    IOS;
    int n;cin>>n;
    int pos=-1,mx=0;
    for(int i=1;i<=n;i++)
    {
        int a;cin>>a;
        ara[i]=a;
        if(mx<abs(a)){
            mx=abs(a);
            pos=i;
        }
    }
    if(pos==-1){
        cout<<0<<endl;
        return 0;
    }
    vector<pi>ans;
    for(int i=1;i<=n;i++)
    {
        if(1LL*ara[i]*ara[pos]<=0)
        {
            ans.pb({pos,i});
            ara[i]+=ara[pos];
        }
    }
//    cout<<"pos = "<<pos<<" "<<ara[pos]<<endl;
//    prinT(ara,n+1);
    if(ara[pos]>0){
        for(int i=1;i<n;i++)
        {
            ara[i+1]+=ara[i];
            ans.pb({i,i+1});
        }
    }
    else if(ara[pos]<0)
    {
        for(int i=n;i>1;i--)
        {
            ans.pb({i,i-1});
            ara[i-1]+=ara[i];
        }
    }
    cout<<ans.size()<<endl;
    for(int i=0;i<ans.size();i++)cout<<ans[i].ff<<" "<<ans[i].ss<<endl;
//    prinT(ara,n+1);
}



/*
6
4 -8 5 2 -4 3

*/


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,a,b,x;
	scanf("%d %d %d",&n,&a,&b);
	x=n*a;
	if(x<b){
		printf("%d\n",x);
	}
	else{
		printf("%d\n",b);
	}
	return 0;
}

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

int main(){
    ll n;
    cin >> n;
    vector <ll> a(n+1),b(n+1);
    rep(i,n+1){
        cin >> a[i];
    }
    rep(i,n){
         cin >> b[i+1];
    }
    b[0]=0;
    ll no,ans;
    ans=0;
    rep(i,n+1){
        no=a[i]-b[i];
        ans+=min(a[i],b[i]);
        //cout << ans << endl;
        if(no<0){
            no=0;
        }
        if(no>0 and i!=n){
            b[i+1]-=no;
            ans+=min(no,b[i+1]+no);
            
            if(b[i+1]<0){
                b[i+1]=0;

            }
            
        }

    }
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std; 
int main(){
	char s[100005];
	cin>>s;
	int l=strlen(s),t=1,v[30];
	char a[30];
	for(int i=0;i<26;i++){
		a[t]='a'+i;
		v[t]=1;
		t++;
	}
	for(int i=0;i<l;i++){
		v[s[i]-96]=0;
	}
	for(int i=1;i<=26;i++){
		if(v[i]==1){
			cout<<a[i]<<endl;
			return 0;
		}
	}
	cout<<"None"<<endl;
	return 0;
}

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

int main() {
  int num[2];
  int answer;
  cin >> num[0] >> num[1];
  if (num[0] >= 10 || num[1] >= 10)
    answer = -1;
  else
    answer = num[0] * num[1];
  cout << answer << endl;
}


Measured memory_bytes: 256
from fractions import gcd
# from datetime import date, timedelta
# from heapq import *
import heapq
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def lcm(a, b):
    return a * b / fractions.gcd(a, b)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


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 is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res


def modinv(a, mod):
    return modpow(a, mod - 2, mod)


def cnk(a, b):
    MOD = 10**9+7
    ret = 1
    for i in range(b):
        ret *= (a-i)
        ret %= MOD
        ret = ret * modinv(i+1, MOD) % MOD
    return ret


class UnionFind:
    def __init__(self, n):
        self.sz = [-1 for i in range(n)]

    # 検索
    def find(self, x):
        if self.sz[x] < 0:
            return x
        else:
            self.sz[x] = self.find(self.sz[x])
            return self.sz[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.sz[x] > self.sz[y]:
            x, y = y, x
        self.sz[x] += self.sz[y]
        self.sz[y] = x

    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xが含まれている集合のサイズを求める
    def size(self, x):
        return -self.sz[self.find(x)]


def main():   
    h, n = map(int, input().split())
    ab = [list(map(int, input().split())) for i in range(n)]
    
           
    dp = [float("inf")] * (h + 1)
    dp[0] = 0
    for i in range(1,h+1):
        for j in range(n):
            dp[i] = min(dp[i], dp[max(0, i - ab[j][0])] + ab[j][1])
    print(dp[h])


            
    # print(dp[h][n - 1])
    # print(dp)




            


    




    


if __name__ == '__main__':
    main()


Measured memory_bytes: 68456
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a)
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;

inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=100005;
//i_am_noob
int n,cnt,ans=0;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n;
	rep2(i,2,n+1){
	    if(i*i>n) break;
	    if(n%i==0){
            cnt=0;
            while(n%i==0){
                cnt++;
                n/=i;
            }
            rep1(j,10000000) if(cnt<j*(j+1)/2){
                ans+=j-1;
                break;
            }
	    }
	}
	if(n>1) ans++;
	print1(ans);
	return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

int main(void) {
    char c[7];
    std::scanf("%s %s", c, c + 3);
    if (c[0] == c[5] && c[1] == c[4] && c[2] == c[3]) {
        std::puts("YES");
    }
    else {
        std::puts("NO");
    }
    return 0;
}

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

using std::cin;
using std::cout;
using std::endl;

template<class T>
struct heap{
  std::vector<T> data;
  size_t sz;
  constexpr inline bool cmp(T const& lhs,T const& rhs)const noexcept{
    // max := <
    // min := >
    return lhs < rhs;
  }
  heap():data(1){
    data.reserve(100000);
  }
  heap(std::vector<T> const& v){
    int n = v.size();
    data.resize(n+1);
    sz = n;
    for(int i=0;i<n;++i){
      data[i+1] = v[i];
    }
    for(int i=sz/2;i>0;--i){
      heapify(i);
    }
  }
  bool empty()const{
    return sz==0;
  }
  size_t size()const{
    return sz;
  }
  void heapify(int k){
    int l = k<<1;
    int r = k<<1|1;
    int key = k;
    if(l<=sz && cmp(data[k],data[l]))key=l;
    if(r<=sz && cmp(data[key],data[r]))key=r;
    if(key!=k){
      std::swap(data[k],data[key]);
      heapify(key);
    }
  }
  void pop(){
    data[1] = data.back();
    data.pop_back();
    heapify(1);
    sz--;
  }
  void push(T x){
    data.emplace_back(x);
    int pos = ++sz;
    int par = pos>>1;
    while(pos>1 && cmp(data[par],data[pos])){
      std::swap(data[pos],data[par]);
      pos = par;
      par = pos>>1;
    }
  }
  T top()const{
    return data[1];
  }
  void dump(){
    int a=1,b=0;
    for(int i=1;i<=sz;++i){
      cout<<data[i];
      b++;
      if(a==b){
        a<<=1,b=0;
        cout<<",";
      }else{
        cout<<" ";
      }
    }
    cout<<endl;
  }
};

signed main(){

  int n,q;
  cin>>n>>q;
  std::vector<heap<int>> ques(n);
  while(q--){
    int c;cin>>c;
    if(c==0){
      int t,x;cin>>t>>x;
      ques[t].push(x);
    }
    else if(c==1){
      int t;cin>>t;
      if(ques[t].size())cout<<ques[t].top()<<endl;
    }
    else {
      int t;cin>>t;
      if(ques[t].size())ques[t].pop();
    }
  }

}


Measured memory_bytes: 7640
#include <stdio.h>
#include <string.h>
typedef struct{
	int top;
	int north;
	int east;
	int west;
	int south;
	int bottom;
}DICE;

void Reset(DICE *d){
	d->top = 1;
	d->north = 5;
	d->east = 3;
	d->west = 4;
	d->south = 2;
	d->bottom = 6;
}

int North(DICE *d){
	int buf;
	buf = d->top;
	d->top = d->south;
	d->south = d->bottom;
	d->bottom = d->north;
	d->north = buf;
	return d->top;
}

int East(DICE *d){
	int buf;
	buf = d->top;
	d->top = d->west;
	d->west = d->bottom;
	d->bottom = d->east;
	d->east = buf;
	return d->top;
}

int West(DICE *d){
	int buf;
	buf = d->top;
	d->top = d->east;
	d->east = d->bottom;
	d->bottom = d->west;
	d->west = buf;
	return d->top;
}

int South(DICE *d){
	int buf;
	buf = d->top;
	d->top = d->north;
	d->north = d->bottom;
	d->bottom = d->south;
	d->south = buf;
	return d->top;
}

int Right(DICE *d){
	int buf;
	buf = d->south;
	d->south = d->east;
	d->east = d->north;
	d->north = d->west;
	d->west = buf;
	return d->top;
}

int Left(DICE *d){
	int buf;
	buf = d->south;
	d->south = d->west;
	d->west = d->north;
	d->north = d->east;
	d->east = buf;
	return d->top;
}

int Dice(int n){
	int sum=1;
	char oper[5];
	DICE dc;
	Reset(&dc);
	while(n != 0){
		scanf("%s",oper);
		if(strcmp(oper,"North") == 0){
			sum += North(&dc);
		}else if(strcmp(oper,"East") == 0){
			sum += East(&dc);
		}else if(strcmp(oper,"West") == 0){
			 sum += West(&dc);	
		}else if(strcmp(oper,"South") == 0){
			sum += South(&dc);
		}else if(strcmp(oper,"Right") == 0){
			sum += Right(&dc);
		}else if(strcmp(oper,"Left") == 0){
			sum += Left(&dc);
		}
		n--;
	}
	return sum;
}

int main(void) {
	int n,result;
	scanf("%d",&n);
	while(n != 0){
		result = Dice(n);
		printf("%d\n",result);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 604
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
void init() {
	iostream::sync_with_stdio(false);

}

#define int ll

void solve() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> cnter;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		a--;
		cnter.push_back(mp(a, b));
	}
	for (int i = 0; i < 1e5; ++i) {
		string s = to_string(i);
		if (s.length() != n) continue;
		int ok = 1;
		REP(q, cnter.size()) {
			if (s[cnter[q].first] != cnter[q].second + '0') {
				ok = 0;
			}
		}
		if (ok == 1) {
			cout << i << endl;
			return;
		}
	}
	cout << -1 << endl;
}

#undef int

int main() {
	init();
	solve();
}

Measured memory_bytes: 256