akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main{

        public static void main(String[] args) throws Exception{

            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;

            InputReader in = new InputReader(inputStream);
            PrintWriter out = new PrintWriter(outputStream);

            Task solver = new Task();
            solver.solve(in,out);
            out.close();
        }

        static class Task{

            public void solve(InputReader in, PrintWriter out){

                int n = in.nextInt();

                int[][] happiness = new int[n][3];
                long[][] result = new long[n][3];

                for(int i = 0;i<n;i++){
                    for(int j = 0;j<3;j++)
                        happiness[i][j] = in.nextInt();
                }

                out.println(go(happiness, result));
            }

            public long go(int[][] happiness, long[][] result){
                return Math.max(goIter(happiness,result, 0, 0), Math.max(goIter(happiness,result,0,1), goIter(happiness,result,0,2)));
            }

            // public long goRec(int[][] happiness,int row, int col){

            //     if(row < happiness.length){
            //         return (happiness[row][col] + Math.max(goRec(happiness, row+1, (col+1)%3), goRec(happiness, row+1, (col+2)%3)));
            //     }
            //     return 0;
            // }

            public long goIter(int[][] happiness, long[][] result, int row, int col){

                if(row > happiness.length-1)
                    return 0;

                if(result[row][col] != 0)
                    return result[row][col];

                if(row < happiness.length)
                    result[row][col] = happiness[row][col] + Math.max(goIter(happiness,result, row+1, (col+1)%3), goIter(happiness,result, row+1, (col+2)%3));

                return result[row][col];
            }
        }

        static class InputReader{

            BufferedReader reader;
            StringTokenizer tokenizer;

            public InputReader(InputStream inputStream){

                reader = new BufferedReader(new InputStreamReader(inputStream));
                tokenizer = null;

            }

            public String next(){
                while(tokenizer == null || !tokenizer.hasMoreTokens()){
                    try{
                        tokenizer = new StringTokenizer(reader.readLine());
                    }
                    catch(IOException e){
                        throw new RuntimeException(e);
                    }
                }

                return tokenizer.nextToken();
            }

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


Measured memory_bytes: 70376
open System

let str = stdin.ReadLine()

let has2char =
    str
    |> Seq.distinct
    |> Seq.length
    |> (=) 2

let isTwice =
    str
    |> Seq.sort
    |> Seq.tail
    |> Seq.take 2
    |> Seq.distinct
    |> Seq.length
    |> (=) 2

if has2char && isTwice then "Yes" else "No"
|> printfn "%s"

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

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

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a % 2 == 0) cnt++;
  }

  if (cnt == N && P == 0) {
    cout << (long long)pow(2, N) << endl;
    return 0;
  } else if (cnt == N && P == 1) {
    cout << 0 << endl;
    return 0;
  }

  cout << (long long)pow(2, N - 1) << endl;
}

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

int main(){
    int n; cin >> n;
    vector<int> a(n), b(n, 0);
    for (auto i = 0; i < n; i++) cin >> a[i];
    for (auto i = n - 1; i >= n / 2; i--) if(a[i] == 1) b[i]++;
    for (auto i = n / 2 - 1; i >= 0; i--) {
        int cnt = 0, mul = 2;
        while(true) {
            auto j = (i + 1) * mul++;
            if(j > n) break;
            cnt += b[j - 1];
        }
        if(cnt % 2 != a[i]) b[i]++;
//        cout << i << " " << cnt << " " << a[i] << " " << b[i] << endl;
    }

    cout << count(b.begin(), b.end(), 1) << endl;
    for (auto i = 0; i < n; i++) if(b[i]) cout << i + 1 << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 4748
using System;

class Program
{
    static void Main()
    {
        string[] array = Console.ReadLine().Split(' ');
        int x1 = int.Parse(array[0]);
        int y1 = int.Parse(array[1]);
        int x2 = int.Parse(array[2]);
        int y2 = int.Parse(array[3]);

        int xl = x2 - x1;
        int yl = y2 - y1;

        Console.WriteLine((x2 - yl) + " " + (y2 + xl) + " " + (x1 - yl) + " " + (y1 + xl));
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>;
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

string s;
bool j = false;

int main() {

	cin >> s;

	if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2])j = true;
	else if (s[0] == s[2] && s[1] == s[3] && s[0] != s[1])j = true;
	else if (s[0] == s[3] && s[1] == s[2] && s[0] != s[1])j = true;

	if (j)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

constexpr ll mod = 1000000007;

class modint {
	static constexpr std::int_fast64_t Modulus = 1e9 + 7;
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
};

int main() {
    int n;
    cin >> n;
    vector<int> vs(n);
    rep(i, n) {
        cin >> vs[i];
    }
    vector<int> colors(3, 0);
    modint all = 1;
    rep(i, n) {
		int same = 0;
		rep(j, 3) {
			if (colors[j] == vs[i]) same++;
		}
		all *= same;
		rep(j, 3) {
			if (colors[j] == vs[i]) {
				colors[j]++;
				break;
			}
		}
    }
	cout << all.a << endl;
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

#define print(a) {for(auto xxxxx : (a)) cout << xxxxx << ' '; cout << '\n';}
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

ll next(){ll x; cin >> x;return x;}
const int maxn = 3e5 + 2, intf = 2e9;
const ll inf = 2e18, mod = 998244353;
const ld eps = 1e-9;

int N = 1;
vector <int> tree;

int get_max(int l , int r){
	l += N , r += N;
	int ans = 0;
	while(l <= r){
		if (l % 2 == 1) ans = max(ans , tree[l++]);
		if (r % 2 == 0) ans = max(ans , tree[r--]);
		l /= 2 , r /= 2;
	}
	return ans;
}

void solve(){
	int n, k, c;
	string s;
	cin >> n >> k >> c >> s;

	if (c == 0){
		int cnt = 0;
		for (auto t : s){
			cnt += t == 'o';
		}
		if (cnt == k){
			for (int i = 0; i < n; i ++){
				if (s[i] == 'o')
					cout << i + 1 << '\n';
			}
		}
		return;
	}

	vector <int> pref(n , 0) , suff(n , 0);
	pref[0] = s[0] == 'o';
	suff[n - 1] = s[n - 1] == 'o';

	for (int i = 1; i < n; i ++){
		if (s[i] == 'x'){
			pref[i] = pref[i - 1];
			continue;
		}
		pref[i] = 1;
		if (i - c - 1 >= 0) pref[i] += pref[i - c - 1];
		pref[i] = max(pref[i] , pref[i - 1]);
	}

	for (int i = n - 2; i >= 0; i --){
		if (s[i] == 'x'){
			suff[i] = suff[i + 1];
			continue;
		}
		suff[i] = 1;
		if (i + c + 1 < n) suff[i] += suff[i + c + 1];
		suff[i] = max(suff[i] , suff[i + 1]);
	}

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


	while(N < n) N *= 2;
	tree.assign(2*N , 0);
	for (int i = N; i < n + N; i ++)
		tree[i] = pref[i - N];
	for (int i = N - 1; i > 0; i --)
		tree[i] = max(tree[i*2] , tree[i*2 + 1]);

	vector <int> ans;

	//print(pref);
	//print(tree);

	if (suff[1] < k){
		ans.pb(0);
	}

	for (int i = 1; i < n; i ++){
		if (get_max(max(0 , i - c) , i - 1) < k){
			ans.pb(i);
		}
	}
	for (auto x : ans)
		cout << x + 1 << '\n';

}

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(20);
    
    for (int t = 1; t--;) solve();

	return 0;
}
/*


*/



Measured memory_bytes: 4244
n,k,q = map(int,input().split())
a = []; b = [0]*n
for i in range(q):
    c = int(input())
    a.append(c)
    b[c-1] += 1
for i in b:
    if k-(q-i) <= 0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 13700
import scala.io.{StdIn => in}

object Main extends App {
  val Array(a, b, k) = in.readLine.split(" ").map(_.toLong)
  val tk = (a - k) max 0l
  val kk = (k - a) max 0l
  val ai = (b - kk) max 0l
  println(tk + " " + ai)
}

Measured memory_bytes: 27208
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
  s << vv[i] << endl;
  }
  return s;
}

int N,K;
vector<int> x;
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N >> K;
  x.resize(N);
  rep(i,N){
    cin >> x[i];
  }

  int ret = INF;

  for(int i = 0 ; i + K-1 < N ; i++){
    int l = i;
    int r = i + K-1;
    int cand1 = abs(x[l]) + x[r] - x[l];
    int cand2 = abs(x[r]) + x[r] - x[l];
    chmin(ret,min(cand1,cand2));
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 640
"""
hash法を構成する
"""
class Dictionary():
    def __init__(self):
        self.MEMO = {'A':1, 'G':2, 'C':3, 'T':4}
        SIZE = 13
        POW = [1]*SIZE 
        for i in range(1, 13):
            POW[i] = POW[i-1]*4
        self.POW = POW
        self.DICT = [False]*POW[12]
    
    def makekey(self, value):
        l = len(value)
        key = -1 #アルファベットを数値に変換する準備
        for i in range(l):
            key += self.MEMO[value[i]]*self.POW[i]
        return key #このkeyの最大値は2**24-1
    
    def insert(self, value):
        key = self.makekey(value)
        self.DICT[key] = True
    
    def find(self, value): 
        key = self.makekey(value)
        if self.DICT[key] == False: #停止条件
            print('no')
        else:
            print('yes')

n = int(input())

d = Dictionary() 

for i in range(n):
    command, tmp_str = map(str, input().split())
    if command[0] == "i":
        d.insert(tmp_str)
    else:
        d.find(tmp_str)

    


Measured memory_bytes: 136668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define F first
#define S second
#define PB push_back
#define INF 1000000001
#define INFL 1000000000000000001
#define M 1000000007
int c[2050],ans=INF;
int main(void){
	ll l,r;
	cin>>l>>r;
	r=min(r,l+5000LL);
	for(int i=l;i<=r;i++)c[i%2019]++;
	for(int i=0;i<2019;i++){
		for(int j=i;j<2019;j++){
			if(c[i]==0||c[j]==0)continue;
			if(i==j&&c[i]<2)continue;
			ans=min(ans,i*j%2019);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int maxn = 200001;
const int INF = 0x7fffffff;

int L[maxn], R[maxn];
long long merge(int A[], int n, int left, int mid, int right)
{
    int i, j, k;
    long long cnt = 0;
    int n1 = mid - left;
    int n2 = right - mid;

    for(int i = 0; i < n1; i++) L[i] = A[left + i];
    for(int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = R[n2] = INF;

    i = j = 0;
    for(int k = left; k < right; k++)
    {
        if(L[i] <= R[j])
            A[k] = L[i++];
        else
        {
            A[k] = R[j++];
            cnt += n1 - i;
        }
    }
    return cnt;
}

long long mergeSort(int A[], int n, int left, int right)
{
    int mid;
    long long v1, v2, v3;
    if(left + 1 < right)
    {
        mid = (left + right) / 2;
        v1 = mergeSort(A, n, left, mid);
        v2 = mergeSort(A, n, mid, right);
        v3 = merge(A, n, left, mid, right);
        return v1 + v2 + v3;
    }
    else
        return 0;
}

int main()
{
    int A[maxn], n;

    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> A[i];

    long long ans = mergeSort(A, n, 0, n);
    cout << ans << endl;
    return 0;
}


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

string s,t;
int n;
int judge = 1;
string u;
vector<int> a(200010);

int main(int argc, char const *argv[]){
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a.at(i);
	}

	sort(a.begin(),a.end(),greater<int>());
	// for(int i = 0; i<n;i++) cout << a.at(i) << endl;

	for (int i = 0; i < n; ++i) {
		if(a.at(i)==a.at(i+1)){judge = 0; break;}
	}

	if(judge==1) cout << "YES" << endl;
	if(judge==0) cout << "NO" << endl;
	return 0;
}

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

using std::cerr;
using std::cin;
using std::cout;

using std::abs;
using std::min;
using std::max;
using std::swap;

using std::map;
using std::pair;
using std::set;
using std::string;
using std::vector;

using ll = long long;
using uint = unsigned int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ff first
#define ss second
#define pb emplace_back
template<typename T> 
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h <<"\n"; 
}
template<typename T, typename... Ts>
void _dbg(const char* _s, T _h, Ts... _t) {
    int _b = 0;
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++; 
    cerr << " = " << _h << ","; 
    _dbg(_s+1, _t...);
}
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...) 
#endif

struct init {
    init() {
        cin.tie(0);
        std::iostream::sync_with_stdio(0);
        cout << std::fixed << std::setprecision(10);
        cerr << std::fixed << std::setprecision(5);
        #ifdef LOCAL
        srand(300); 
        #else
        using namespace std::chrono;
        srand(duration_cast<nanoseconds>(high_resolution_clock::now().time_since_epoch()).count()); 
        #endif
    }
    ~init() {
        #ifdef LOCAL
        cerr << "Time elapsed: " << (double)clock() / CLOCKS_PER_SEC << "s.\n";
        #endif
    }
} init;

const int MAXA = 4e6 + 1, MAXN = 2017;

int a[MAXN];

int main() {
    
    int n;
    cin >> n;
    std::bitset<MAXA> dp;
    dp[0] = 1;
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        dp |= dp << a[i];
        sum += a[i];
    }

    for (int i = (sum + 1) / 2; ; ++i)
        if (dp[i]) {
            cout << i << '\n';
            break;
        }
    
    return 0;
}


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

int a[55];

long long dp[55][55][3000];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, A; cin >> n >> A;
	for (int i = 1; i <= n; i++) cin >> a[i];
	dp[0][0][0] = 1;
	long long ans = 0;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= i; j++) {
			for (int k = 0; k <= 2500; k++) {
				if (i < n) {
					if (dp[i][j][k]) {
						dp[i + 1][j + 1][k + a[i + 1]] += dp[i][j][k];
						dp[i + 1][j][k] += dp[i][j][k];
					}
				}
				else {
					if (A * j == k) ans += dp[i][j][k];
				}
			}
		}
	}
	cout << ans - 1 << endl;
	return 0;
}



Measured memory_bytes: 65792
s = gets.chomp
t = gets.chomp

s_structure = Array.new(26){[]}
s.chars.each_with_index do |x, index|
  target_index = x.ord - 'a'.ord
  s_structure[target_index] << index
end

t_structure = Array.new(26){[]}
t.chars.each_with_index do |x, index|
  target_index = x.ord - 'a'.ord
  t_structure[target_index] << index
end

n = s.size
check = Array.new(26, false)
n.times do |i|
  s_char_code = s[i].ord - 'a'.ord
  t_char_code = t[i].ord - 'a'.ord
  next if check[s_char_code]
  unless s_structure[s_char_code].size == t_structure[t_char_code].size
    puts 'No'
    exit
  end

  m = s_structure[s_char_code].size
  m.times do |j|
    unless s_structure[s_char_code][j] == t_structure[t_char_code][j]
      puts 'No'
      exit
    end
  end

  check[s_char_code] = true
end

puts 'Yes'


Measured memory_bytes: 46880
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;

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

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint 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(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
    
  int main(){
     lint N;
     cin>>N;
     lint A[N];
     rep(i,N)cin>>A[i];
    rep(i,N){
        if(A[i]%2==0){
            if(A[i]%3==0||A[i]%5==0)continue;
            else {
                cout<<"DENIED";
                return 0;
            }
        }
    }
    cout<<"APPROVED";
    }
     
  


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

int main() 
{
  int n;
  cin >> n;
  vector<int> b(n);
  for (int i = 1; i <= n-1; i++) cin >> b[i];
  vector<int> a(n+1);
  for (int i = 1; i <= n; i++){
    if(i == 1){
      a[i] = b[i];
    }else if(i == n) {
      a[i] = b[i-1];
    }else{
      a[i] = min(b[i], b[i-1]);
    }
  }
  int sum = 0;
  for (int i = 1; i <= n; i++) sum += a[i];
  cout << sum << endl;

  return 0;
}


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

int main(){
	while(1){
		vector<double> x(3);
		cin>>x[0]>>x[1]>>x[2];
		if(x[0]==0&&x[1]==0&&x[2]==0)break;
		int n;
		cin>>n;
		sort(x.begin(),x.end());
		for(int i=0;i<n;i++){
			double r;
			cin>>r;
			int y=sqrt((x[0]*x[0])+(x[1]*x[1]));
			//cout<<r<<" "<<x[1]<<endl;
			if(2*r>y){
				cout<<"OK"<<endl;
			}else{
				cout<<"NA"<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3232
#include <iostream>
#include <stdio.h>
#include <cstdlib>
using namespace std;

const int N = 2e5;
int h,w,n;
int G[105][105];
int a[N];
void init()
{
    cin >> h >> w;
    cin >> n;
    for(int i=0; i<n; i++)
    {
        cin >> a[i];
    }
}

void solve()
{
    int cnt=0,flag=0;
    for(int i=0; i<h; i++)
    {
        if(i%2 == 0)
        {
            for(int j=flag%w; j<w; j++)
            {
                if(a[cnt] > 0){G[i][j]=cnt+1; a[cnt]--;}
                else if(a[cnt] == 0){cnt++; G[i][j]=cnt+1; a[cnt]--;}
                flag++;
            }

        }else
        {
            for(int j=w-flag%w-1; j>=0; j--)
            {
                if(a[cnt] > 0){G[i][j]=cnt+1; a[cnt]--;}
                else if(a[cnt] == 0){cnt++; G[i][j]=cnt+1; a[cnt]--;}
                flag++;
            }
        }
    }
    for(int i=0; i<h; i++)
    {
        for(int j=0; j<w; j++)
        {
            if(j != w-1)
                cout << G[i][j] << " ";
            else
                cout << G[i][j] << " " << endl;
        }
    }
}

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

Measured memory_bytes: 888
// ABC115_B
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

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

    // input
    ll N;
    cin >> N;
    vector<ll> vec(N);
    REP(i, N) cin >> vec[i];
    
    sort(vec.begin(), vec.end(), greater<>());  // int big -> small
    ll sum = vec[0]/2;
    // calculation
    for (ll j = 1; j < N; ++j) {
        sum += vec[j];
    }
    
    cout << sum << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a,b,c,m;
	scanf("%d",&a);
	scanf("%d",&b);
	
	if(a>b){
		m=a;
		a=b;
		b=m;
	}

	scanf("%d",&c);
	if(c<b){
		m=c;
		c=b;
		b=m;	
		if(a>b){
			m=a;
			a=b;
			b=m;
		}
	}

	m=0;
	m=b-a;
	m+=c-b;

	printf("%d",m);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<ll,ll> P;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000007;
const int mod=10007;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}
int main(){
  int n,k,ans=0;cin>>n>>k;
  vi v(n);
  rep(i,n)cin>>v[i];
  rep(i,n+1){
    int ret=0;
    vi x;
    rep(l,i){
        ret+=v[l];
        if(v[l]<0)x.push_back(v[l]);
    }
    rep(j,n-i+1){
      if(i+j>k)break;
      int sum=ret;
      vi c=x;
      rep(l,j){
        sum+=v[n-1-l];
        if(v[n-1-l]<0)c.push_back(v[n-1-l]);
      }
      sort(c.begin(),c.end());
      rep(l,c.size()){
        if(i+j+l>=k)break;
        sum-=c[l];
      }
      chmax(ans,sum);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<60
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);  
  //問題文を読む時間をケチらない！！

  string s;
  cin >> s;

  REP(i,s.size()){
    if(i == 5 || i == 13) cout << " ";
    else cout <<s[i];
  }

  cout << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int a = Integer.parseInt(sc.next());
		long b = Long.parseLong(sc.next());
		long n = Long.parseLong(sc.next());
		
		long x = Math.min(b-1, n);
		
		long ans = (long)(x * a)/b;
		System.out.println(ans);
	}

}


Measured memory_bytes: 35640
#pragma GCC diagnostic ignored "-Wunused-result"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int N = (int)1e6 + 34;
const ll INF = (ll)1e18 + 41;
//const int INF = (int)1e9 + 41;
const ll MD = (ll)1e9 + 7;
bool D = false;

void solve() {
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	for (int i = 0; i < n; i++) cin >> v[i];
	sort(v.begin(), v.end());
	int ans = v.back() - v[0];
	for (int i = 0; i + k <= n; i++) {
		ans = min(ans, v[i + k - 1] - v[i]);
	}
	cout << ans << "\n";
}

int main() {
#ifdef LOCAL
	freopen("a.in", "r", stdin);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tst = 1;
	//scanf("%d", &tst);
	//cin >> tst;
#ifdef MADE_BY_SERT
	D = true;	
	tst = 2;
	while (tst--) {
		solve();
	}
#else
	while (tst--) solve();
#endif
}


Measured memory_bytes: 640
package main

import (
	"fmt"
)

func solution(n, k int) int {
	t := n % k
	return min(t, k-t)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	fmt.Println(solution(n, k))
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		double x1,x2,y1,y2,rr;

		Scanner scan = new Scanner(System.in);
		x1 = scan.nextDouble();
		y1 = scan.nextDouble();
		x2 = scan.nextDouble();
		y2 = scan.nextDouble();

		rr = Math.pow( (x1-x2), 2) + Math.pow( (y1-y2), 2);

		System.out.printf("%.5f\n",Math.sqrt(rr) );

		scan.close();
	}
}

Measured memory_bytes: 28076
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

string S;

int keta(long long int K) {
	int ret = 0;

	while (K > 0) { ret++; K /= 10; }
	return ret;
}

long long int dp[2][200005];
long long int ans;
int main(void) {

	cin >> S;
	long long int N = S.size();
	long long int M;

	for (int i = 0; i < N; i++) {
		long long int k = S[i] - '0';
		for (int j = 0; j <= 2018; j++) {
			dp[(i + 1)%2][j] = 0;
		}
		for (int j = 0; j <= 2018; j++) {
			long long int g = ((j * 10) + k) % 2019;
			dp[(i + 1)%2][g] += dp[i%2][j];
		}
		dp[(i + 1)%2][k]++;
		ans += dp[(i + 1)%2][0];
	}

	cout << ans << endl;

	return 0;
}


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

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; //最大値

ll dp[MX][MX];
inline void chmax(ll& a, ll b) {
  a = max(a, b);
}

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define PB push_back


int main(){
    ll k;
    string s;
    cin >> k >> s;
    
    ll n = s.size();
    if (k < n) {
        string ans = s.substr(0, k);
        cout << ans << "..." << endl;
    }
    else cout << s << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
  long long X; cin >> X;

  for (int a = 1; a < 1000; a++) {
    for (int b = -1000; b < 1000; b++) {
      long long fifth_a = pow(a, 5);
      long long fifth_b = pow(b, 5);
      if (fifth_a - fifth_b == X) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }

}


Measured memory_bytes: 3592
#include <iostream>

int main() {
  // 入力
  int current_time;
  std::cin >> current_time;

  // 計算
  int two_days_hour = 48;
  int left_time = two_days_hour - current_time;

  // 出力
  std::cout << left_time << std::endl;

  return 0;
}


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

using namespace std;

int n;
int trueans = 99999;
vector<int> data;

int dfs(int i,int asum,int bsum){
	if(i == n){
		trueans = min(trueans,abs(asum-bsum));
		return trueans;
	}
	else{
		dfs(i+1,asum+data[i],bsum);
		dfs(i+1,asum,bsum+data[i]);
	}
}

int main(){
	while(1){
		cin >> n;
		if(!n)break;
		data.resize(n);
		trueans = 99999;
		for(int i=0;i<n;++i){
			cin >> data[i];
		}
		cout << dfs(0,0,0) << endl;
	}
	return 0;
}

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

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define rep(n) for(ll i = 0 ; i<n ; i++) 
#define repd(n) for(ll i = n-1 ; i>=0 ; i--)
#define MOD 1000000007

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

	string s; cin>>s;
  bool a=0,b=0;
  for(auto i:s) if(i=='A') a=1; else b=1;
  if(a && b) cout<<"Yes"; else cout<<"No";
	return 0;
}


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

int main() {
    int n, k, ans=0;
    cin >> n >> k;
    vector<int> p(n);
    rep(i,n){
        cin >> p.at(i);
    }
    sort(p.begin(), p.end());
    rep(i,k){
        ans = ans + p.at(i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3604
#include<map>
#include<cstdio>
using namespace std;
const long long kkk=1000000007;
map<long long,long long> dp;
long long cd(long long x)
{
	if(dp[x])return dp[x];
	else dp[x]=(cd(x/2)+cd((x-1)/2)+cd((x-2)/2))%kkk;
	return dp[x];
}
int main(){
	long long n;
	dp[0]=1;dp[1]=2;dp[2]=4;
	scanf("%lld",&n);
	long long k=cd(n);
	printf("%lld",k);
	return 0;
}

Measured memory_bytes: 888
import math

N = int(input())
data = []
for _ in range(N-1):
    data.append(list(map(int,input().split())))

def time(t, i):
    if t <= data[i][1]:
        return data[i][0] + data[i][1]
    else:
        k = math.ceil((t - data[i][1]) / data[i][2])
        return data[i][0] + data[i][1] + k * data[i][2]

for i in range(N):
    ans = 0
    for j in range(i, N - 1):
        ans = time(ans, j)
    print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,x[100010],k;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    rep(i,n)cin>>x[i];
    int ans=1;
    rep(i,n){
        k++;
        if(x[i]<2*k-1){
            ans*=k;
            ans%=mod;
            k--;
        }
    }
    for(int i=1;i<=k;i++){
        ans*=i;
        ans%=mod;
    }
    cout<<ans<<endl;
	return 0;
}


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

int main(){
    int a, b;
    cin >> a >> b;
    
    int ans = a*b-(a+b-1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n;
	cin >> n;
	char s[100];
	cin >> s;
	int r = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R')
			r++;
	}
	if (r * 2 > n)
		cout << "Yes";
	else
		cout << "No";
}

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

#define MAX_N 1000
int P[MAX_N + 1];
int N, M;
int table[(MAX_N + 1) * (MAX_N + 1)];

int main(){
	while(1){		
		scanf("%d%d", &N, &M);
		
		if(N == 0 && M == 0) return 0;
		
		P[0] = 0;
		for(int i = 1; i <= N; i++) scanf("%d", &P[i]);
	
		for(int i = 0; i < N + 1; i++){
			for(int j = 0; j < N + 1; j++){
				table[(N + 1) * i + j] = P[i] + P[j];
			}
		}
		sort(table, table + (N + 1) * (N + 1));
		
		int right = (N + 1) * (N + 1) - 1;
		int res = 0;
		for(int i = 0; i < (N + 1) * (N + 1); i++){
			while(right >= 0){
				if(table[i] + table[right] <= M){
					res = max(res, table[i] + table[right]);
					break;
				}
				if(table[i] == table[right]) goto OUT;
				right--;
			}
		}
		OUT:
		
		printf("%d\n", res);
	}
}

Measured memory_bytes: 4960
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
int main()
{
    string b;
    cin >> b;
    if (b == "A")
    {
        cout << "T" << endl;
    }
    else if (b == "T")
    {
        cout << "A" << endl;
    }
    else if (b == "G")
    {
        cout << "C" << endl;
    }

    else if (b == "C")
    {
        cout << "G" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int D, G;
    cin >> D >> G;
    int p[11], c[11];
    rep(i, D) cin >> p[i] >> c[i];
    int ans = INF;
    rep(bit, (1 << D)) {
        rep(i, D) {
            int tmp = 0;
            int cnt = 0;
            rep(j, D) {
                if(bit & (1 << j)) {
                    if(i != j) {
                        tmp += p[j] * (j + 1) * 100;
                        tmp += c[j];
                        cnt += p[j];
                    }
                }
            }
            //cout << "*" << bitset<2>(bit) << " " << tmp << " " << cnt << endl;
            if(bit & (1 << i)) {
                int solved = 0;
                while(tmp < G && solved < p[i]) {
                    tmp += (i + 1) * 100;
                    solved++;
                    cnt++;
                    if(solved == p[i]) tmp += c[i];
                }
            }
            if(tmp >= G) ans = min(ans, cnt);
            //cout << bitset<2>(bit) << " " << tmp << " " << cnt << endl;
        }
        
    }
    cout << ans << endl;

    return 0;
}


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

public class Solution
{
    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var X = new int[N];
        var Y = new int[N];
        var P = new long[N];
        for (int i = 0; i < N; i++)
        {
            var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            X[i] = vals[0];
            Y[i] = vals[1];
            P[i] = vals[2];
        }

        var maxBit = 1 << N;
        var xCosts = new long[maxBit][];
        var yCosts = new long[maxBit][];
        for (int bit = 0; bit < maxBit; bit++)
        {
            var indexes = Enumerable.Range(0, N).Where(i => (bit & (1 << i)) != 0).ToArray();
            var xx = indexes.Select(i => X[i]).ToList();
            xx.Add(0);
            var yy = indexes.Select(i => Y[i]).ToList();
            yy.Add(0);
            xCosts[bit] = Enumerable.Range(0, N).Select(i => xx.Min(x => Math.Abs(X[i] - x) * P[i])).ToArray();
            yCosts[bit] = Enumerable.Range(0, N).Select(i => yy.Min(y => Math.Abs(Y[i] - y) * P[i])).ToArray();
        }

        var min = Enumerable.Repeat(long.MaxValue, N + 1).ToArray();
        for (int pattern = 0; pattern < (int)Math.Pow(3, N); pattern++)
        {
            var p = pattern;
            var xBit = 0;
            var yBit = 0;
            int count = 0;
            for (int i = 0; i < N; i++)
            {
                xBit <<= 1;
                yBit <<= 1;
                switch (p % 3)
                {
                    case 1:
                        xBit |= 1;
                        count++;
                        break;
                    case 2:
                        yBit |= 1;
                        count++;
                        break;
                }
                p /= 3;
            }
            long cost = 0;
            for (int i = 0; i < N; i++)
            {
                cost += Math.Min(xCosts[xBit][i], yCosts[yBit][i]);
            }
            min[count] = Math.Min(min[count], cost);
        }

        Console.WriteLine(string.Join(Environment.NewLine, min));
    }
}

Measured memory_bytes: 56064
N, M = map(int, input().split())
div = 10**9+7
A = [0 for i in range(N+1)]
A[0] = 1
for i in range(M):
    a = int(input())
    A[a] = -1
for i in range(N):
    if A[i] == -1:
        continue
    now = A[i]
    if A[i+1] != -1:
        A[i+1] += now * 1
    if i < N-1 and A[i+2] != -1:
        A[i+2] += now * 1
# print(A)
print(A[-1] % div)


Measured memory_bytes: 465304
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int K = sc.nextInt();

		int R = sc.nextInt();
		int S = sc.nextInt();
		int P = sc.nextInt();

		String T = sc.next();
		char[] t = T.toCharArray();

		sc.close();

		char[] a = new char[N];
		Arrays.fill(a, ' ');

		long ans = 0;
		for (int i = 0; i < N; i++) {
			switch (t[i]) {
			case 'r':
				if (i < K || a[i - K] != 'p') {
					ans += P;
					a[i] = 'p';
				}
				break;
			case 's':
				if (i < K || a[i - K] != 'r') {
					ans += R;
					a[i] = 'r';
				}
				break;
			case 'p':
				if (i < K || a[i - K] != 's') {
					ans += S;
					a[i] = 's';
				}
				break;
			}
		}

		out.println(ans);
	}

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


Measured memory_bytes: 28528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
using P = pair<int, int>;
const ll inf =1e9;
const int minus_inf = -1e9;

struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

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

Measured memory_bytes: 1024
N=int(input())
S=input()
X=[[0]*(N+1) for i in range(3)]
d={'R':0,'G':1,'B':2}
for i,s in enumerate(S):
  X[d[s]][i]+=1
  X[0][i+1]=X[0][i]
  X[1][i+1]=X[1][i]
  X[2][i+1]=X[2][i]
ans=0
for i,s in enumerate(S):
  _=1
  for j in range(3):
    if d[s]==j:
      continue
    _*=X[j][-1]-X[j][i]
  ans+=_
for i in range(1,(N+1)//2):
  j=0
  while j+2*i<N:
    if S[j]!=S[j+i] and S[j]!=S[j+2*i] and S[j+i]!=S[j+2*i]:
      ans-=1
    j+=1
print(ans)

Measured memory_bytes: 9348
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}
int main()
{
    int a,b;
    string s;
    cin>>a>>b;
    cin>>s;
    bool flag=true;
    for(int i=0;i<a+b+1;i++){
        if(i!=a){
        if(s[i]=='-')
        flag=false;
        }
    }
    if(s[a]!='-') flag=false;
    if(flag==true) yes();
    else no();
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define INF (2 << 28)
#define fr first
#define sc second
using namespace std;

typedef long long ll;
typedef pair<int, int> iP;

int main(){
  
  int n, k;
  
  while(cin >> n >> k, n||k){
    bool judge = false;
    int a[111111] = {0};

    for(int i = 0; i < k; i++){ 
      int tmp; cin >> tmp; a[tmp]++;
      if(tmp == 0) judge = true;
    }

    int dp[111111][2] = {0};
    for(int i = 1; i <= n; i++){
      if(judge || a[i]){
        if(judge && a[i])
          dp[i][1] = max(dp[i][1], max(dp[i - 1][1] + a[i], dp[i - 1][0] + 1));
        else if(judge)
          dp[i][1] = max(dp[i][1], dp[i - 1][0] + 1);
        if(a[i])
          dp[i][0] = max(dp[i][0], dp[i - 1][0] + a[i]);
      }
      else dp[i][0] = dp[i][1] = 0;
    }
    
    int ans = 0;
    for(int i = 0; i < 2; i++){
      for(int j = 1; j <= n; j++){
        //cout << dp[j][i] << " ";
        ans = max(ans, dp[j][i]);
      }
      //cout << endl;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 2468
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s; cin >> s;
	string hitachi = "";
	for (int i = 1; i <= 5; i++) {
		hitachi += "hi";
		if (hitachi == s) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
const ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  int ans=0;
  rep(i,1,n){
    ans+=(n-1)/i;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;

int main()
{
    IOS
     // freopen("input.txt","r",stdin);
     // freopen("output.txt","w",stdout);
     // freopen("error.txt","w",stderr);
     ll n;
     cin>>n;
     ll cnt=0;
     set<ll> a;
     set<ll> vis;
     map<ll,ll>f;
     for(ll i=0;i<n;i++)
     {
        ll x;
        cin>>x;
        a.insert(x);
        f[x]++;
     }
     for(ll x:a)
     {
        if(f[x]==1 && vis.count(x)==0)
        {
            ++cnt;
        }
        if(vis.count(x)==0)
        {
            for(ll j=2*x;j<1000001;j+=x)
            {
                if(a.count(j))
                vis.insert(j);
            }
        }
     }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 34824
fn main() {
    loop {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.trim().split_whitespace();
        let h: i32 = iter.next().unwrap().parse().unwrap();
        let w: i32 = iter.next().unwrap().parse().unwrap();

        if h == 0 && w == 0 {
            break;
        }
        for _ in 0..h {
            for _ in 0..w {
                print!("#");
            }
            println!();
        }
        println!();
    }
}



Measured memory_bytes: 5028