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

class Main {

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

        do {
            int h = sc.nextInt();
            int l = sc.nextInt();

            if (h == 0 && l == 0) {
                break;
            } else {

                for (int i = 0; i < h; i++) {
                    for (int j = 0; j < l; j++) {
                        System.out.print('#');
                    }
                    System.out.println();
                }

                System.out.println();
            }

        } while (true);
    }

}

Measured memory_bytes: 36984
// 0bd35dc5e428754fa574049b6be8efe0

#include <bits/stdc++.h>

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef pair<int, int> pii;

const int INF = (int) 1e9;

const int MAXN = 15;

int n, m, sum = 0;

int w[MAXN + 5][MAXN + 5], s[MAXN + 5][MAXN + 5];

inline void input()
{
	n = read<int>(), m = read<int>();
	for(int i = 0; i < m; ++i)
	{
		int u = read<int>() - 1, v = read<int>() - 1, w0 = read<int>();
		sum += w0;
		w[u][v] = w[v][u] = w0;
	}
}

inline void solve()
{
	static int f[MAXN + 5][1 << MAXN], g[1 << MAXN], h[MAXN + 5][1 << MAXN];
	for(int i = 0; i < n; ++i) for(int S = 0; S < 1 << n; ++S) f[i][S] = h[i][S] = -INF;

	for(int S = 0; S < 1 << n; ++S)
	{
		g[S] = 0;
		for(int i = 0; i < n; ++i) if(S >> i & 1)
			for(int j = i + 1; j < n; ++j) if(S >> j & 1)
				g[S] += w[i][j];
	}

	h[0][0] = 0;
	for(int S = 1; S < 1 << n; ++S)
		for(int i = 0; i < n; ++i) if(S >> i & 1)
		{
			for(int T = S; T; T = (T - 1) & S) if(T >> i & 1) chkmax(f[i][S], h[i][S ^ T] + g[T]);
			for(int j = 0; j < n; ++j) if(!(S >> j & 1) && w[i][j]) chkmax(h[j][S], f[i][S] + w[i][j]);
		}

	printf("%d\n", sum - f[n - 1][(1 << n) - 1]);
}

int main()
{
#ifndef ONLINE_JUDGE
//	freopen("F.in", "r", stdin);
//	freopen("F.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}



Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 10000;
#define INF 0x3f3f3f3f

int main() {
  string s;
  cin>>s;
  int len = s.size();
  int sum = 0;
  for(int i = 0;i < len;i++) {
    sum += s[i]-'0';
  }
  cout<<(sum%9==0?"Yes\n":"No\n");
 	return 0;
}




Measured memory_bytes: 3728
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

int main() {

	int N, M;
	cin >> N >> M;

	vector<int> vec(N,10);

	for (int i = 0; i < M; i++) {
		int s, c;
		cin >> s >> c;
		s -= 1;
		if (s == 0 && c == 0 && N!=1)
		{
			cout << "-1";
			return 0;
		}
		else if (vec[s] == 10) {
			vec[s] = c;
		}
		else if (vec[s] != 10 && vec[s] != c) {
			cout << "-1";
			return 0;
		}
		 

		
	}

	for (int i = 0; i < N; i++) {
		if(vec[0]==10 && N!=1)vec[0] = 1;
		if (vec[i] == 10)vec[i] = 0;
		cout << vec[i];
	}
	return 0;

}

Measured memory_bytes: 888
// MOHIT KUMAR
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pin;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

#define ff(i, a, b) for ( ll i=a; i<(b); i++)
#define ffd(i, a, b) for ( ll i=a; i<= b; i++)
#define fr(i, a, b) for ( ll i = (b)-1; i >= a; i--)
#define ffr(i, a, b) for ( ll i = b ; i >= a; i--)
#define vl vector < ll >
#define vp vector < pl >
#define endl "\n"
#define sz(x) (ll)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const ld pi = acos(-1) ;
const ll maxn = 1e5 + 5 ;
const int mod = 1e9 + 7 ;
const ll INF = 1e10 ;
const int MX = 2000000001 ; // check the limits, dummy


int main() {
  ios_base::sync_with_stdio(0) , cin.tie(0);
  ll t, q, n, a, b, c, d, k, l, m, r,  x = 0, y = 0, z = 0 , sum = 0, ans = 0, temp = 0, res = 0 ;
  cin >> x >> y >> z >> k ;
  vl vx(x), vy(y), vz(z), vxy, vxyz ;
  for (auto &a : vx) cin >> a ;
  for (auto &a : vy) cin >> a ;
  for (auto &a : vz) cin >> a ;

  ff(i, 0, x) {
    ff(j, 0, y) vxy.pb(vx[i] + vy[j]) ;
  }
  sort(all(vxy), greater < ll > ()) ;
  ff(i, 0, min(k, sz(vxy))) {
    ff(j , 0 , z) vxyz.pb(vxy[i] + vz[j]) ;
  }
  sort(all(vxyz), greater < ll > ()) ;
  ff(i, 0, k) cout << vxyz[i] << endl ;
}

Measured memory_bytes: 44060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

struct Graph {
    static constexpr int64_t INF = (int64_t)1 << 60;
    struct Edge {
        int i, r;
        int64_t f;
    };
    Graph(int n) : v(n), h(n), q(n), e(n) {}
    void add_edge(int i, int j, int64_t f) {
        int r0 = e[j].size();
        int r1 = e[i].size();
        e[i].push_back({ j, r0, max(+f, (int64_t)0) });
        e[j].push_back({ i, r1, max(-f, (int64_t)0) });
    }
    void bfs(int i0, int i1) {
        fill(v.begin(), v.end(), -1);
        v[i0] = 0;
        int j0 = 0, j1 = 0;
        q[j1++] = i0;
        while (j0 < j1) {
            int i = q[j0++];
            for (Edge& o : e[i]) {
                if (v[o.i] >= 0 || o.f == 0) continue;

                v[o.i] = v[i] + 1;
                if (o.i == i1) return;
                q[j1++] = o.i;
            }
        }
    }
    int64_t dfs(int i, int i1, int64_t f0) {
        for (; h[i] < e[i].size(); h[i]++) {
            Edge& o = e[i][h[i]];
            if (v[o.i] <= v[i] || o.f == 0) continue;

            int64_t f = min(f0, o.f);
            if (o.i != i1) f = dfs(o.i, i1, f);
            if (f == 0) continue;

            o.f -= f;
            e[o.i][o.r].f += f;
            return f;
        }
        return 0;
    }
    int64_t max_flow(int i0, int i1) { // i0 != i1
        for (int64_t f = 0;;) {
            bfs(i0, i1);
            if (v[i1] < 0) return f;
            fill(h.begin(), h.end(), 0);
            while (1) {
                int64_t t = dfs(i0, i1, INF);
                if (t == 0) break;
                f += t;
            }
        }
    }
    vector<int> v, h, q;
    vector<vector<Edge>> e;
};

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

    Graph g(n * 2 + 2);
    int S = n * 2, T = n * 2 + 1;

    vector<int> a(n), b(n), c(n), d(n);

    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        g.add_edge(S, i, 1);
    }

    for (int j = 0; j < n; j++) {
        cin >> c[j] >> d[j];
        g.add_edge(n + j, T, 1);
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (a[i] < c[j] && b[i] < d[j]) {
                g.add_edge(i, n + j, 1);
            }
        }
    }

    cout << g.max_flow(S, T) << endl;

    return 0;
}

Measured memory_bytes: 384
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=[input().rstrip().split(" ") for i in range(n)]
for i in range(n):
    lis[i][1]=int(lis[i][1])
nl=[]
for i in range(n):
    nl.append([lis[i][0],lis[i][1],i])
nl.sort(key=lambda x:(x[0],-x[1]))
#print(nl)
for i in range(n):
    print(nl[i][2]+1)
        
            
    
    
        
        

    




Measured memory_bytes: 9432
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc =new Scanner(System.in);
		int n=sc.nextInt();
		int ans=0;
		if(Math.log10(n)%1==0) {
			ans=10;
		}
		else {
			while(n>0) {
				ans+=n%10;
				n=n/10;
			}
		}
		System.out.println(ans);
		
	}
	

}




Measured memory_bytes: 23764
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define free  freopen ("input.txt", "r", stdin);freopen ("output.txt", "w", stdout);
#define Fast  ios::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second

bool vowel(char che)
{
    if (che == 'A' || che == 'E' || che == 'I' || che == 'O' || che == 'U' || che == 'Y')
        return true;
    else
        return false;
}

const int N = 1e6+5;
const int mod = 1e9+7;
ll a[N], b[N], c[N], d, dp[N], dis;
//pair <ll, ll> p[N], p1[N];
char o;
bool mark[N], h;
string s, s1;
//stack <int> st;
//set <ll> st1, st2;
//deque <int> dq;
//vector <ll> vm, vp, vt[N];
//int a1[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main()
{
    Fast
    ll t, n, m, k = 0, f = 0, sum = 0, ans = 0;
    cin >> s >> s1;
    ll mn = 1e6;
    for (int i = 0; i <= s.size()-s1.size(); i++){
        f = 0;
        for (int j = 0; j < s1.size(); j++){
            if (s[i+j] != s1[j])
                f++;
        }
        mn = min (mn, f);
    }
    cout << mn << endl;
}


Measured memory_bytes: 3644
"use strict";

const main = arg => {
    const input = arg.trim().split("\n");
    let strS = input[0].split('');
    let strT = input[1].split('');
    let result = 0;
    
    for(let i = 0; i < strS.length; i++){
        if(strS[i] !== strT[i]) {
            result += 1;
        }
    }
    
    console.log(result)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

Measured memory_bytes: 36488
#include<stdio.h>
int main(void){
  int N;
  unsigned int R;
  scanf("%d%d",&N,&R);
  if(N>=10){
    printf("%d",R);
  }
  if(N<10){
    int x=(100*(10-N))+R;
printf("%d",x);
       }
  
    
return 0;
}

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

#define llong long long
#define inf 999999999
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<PP, int> PPP;
typedef struct data{
	int now;
	int cost;
}data;
int nh[4] = {1, 0, -1, 0};
int nw[4] = {0, 1, 0, -1};





int main(){
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	cout << min(0,a)*-1*c+(a<0?d:0)+(b-max(0,a))*e << endl;
	return 0;
}


Measured memory_bytes: 3064
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

d,n = iim()
num = 0
for i in range(n):
    num += 100**d
    if num%100**(d+1) == 0:
        num += 100**d
print(num)

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

class Graph
{
    private :
        int V;
        list<int> *adj;
    public :
        Graph(int V);
        void add_edge(int m,int n);
        int DFS(int s, int a[]);
};
Graph::Graph(int v)
{
    V = v;
    adj = new list<int>[V+1];
}
void Graph::add_edge(int m,int n)
{
    adj[m].push_back(n);
    adj[n].push_back(m);
}
int Graph::DFS(int s, int a[])
{
    // Mark the current node as visited and print it
    int val=a[s];
    if(adj[s].size()==0)return 1;
    // Recur for all the vertices adjacent to this vertex
    list<int>::iterator i;
    for(i = adj[s].begin(); i != adj[s].end(); ++i)
    {
      if(val>a[*i])
      continue;
      else
      {
        return 0;
      }
    }
  return 1;
}

int main()
{
    int n,m,a[100000],f[100000];
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    Graph g(n);
    while(m--)
    {
        int a,b;
        cin>>a>>b;
        g.add_edge(a,b);
    }
  long long int r = 0;
    for(int i=1;i<=n;i++)
    {
      r += g.DFS(i,a);
    }
    cout<<r<<endl;
    return 0;
}


Measured memory_bytes: 12588
N,M = map(int,input().split())
x = sorted(list(map(int,input().split())))

if M <= N:
	print(0)
	exit()
	

distance = [0]*(M-1)
distance[0] = x[1]-x[0]
for i in range(0,M-1):
	distance[i] = x[i+1]-x[i]

distance_sorted = sorted(distance)
ans = 0
for i in range(0,M-N):
	ans += distance_sorted[i]

print(ans)




Measured memory_bytes: 13960
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int gcd(int a, int b){
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


int factorial(int n){
  if(n == 0) return 1;
  return n*factorial(n-1);
}

int divisor(int a){
  int cnt = 0;
  for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
  return cnt;
}

int comb(int n, int k){
  return factorial(n) / (factorial(n-k)*factorial(k));
}

int answer(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}






int main(){
  int X;
  cin >> X;
  int ans = 1;
  for(int i = 2; i <= X; i++){
    int num = i*i;
    
    while(num <= X){
      ans = max(ans,num);
      num *= i;
    }
  }
  cout << ans << endl;
  

  
  return 0;
}









Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <string>
#include <iterator>

#define int long long

using namespace std;

#define N 16
signed main()
//int main()
{
    int A, B;
    cin >> A >> B;
    if (A <= N/2 && B <= N/2) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

template <class T> inline bool chmin(T &a, const T &b) {
  return (a > b) ? a = b, true : false;
}

template <class T> inline bool chmax(T &a, const T &b) {
  return (a < b) ? a = b, true : false;
}

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  int H, W;
  std::cin >> H >> W;
  std::vector<std::vector<char>> c(H, std::vector<char>(W));
  for (int i = 0; i < H; ++i)
    for (int j = 0; j < W; ++j)
      std::cin >> c[i][j];

  // Main
  std::pair<int, int> lu = std::make_pair(H, W);
  std::pair<int, int> rd = std::make_pair(-1, -1);
  std::pair<int, int> ru = std::make_pair(H, -1);
  std::pair<int, int> ld = std::make_pair(0, W);
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (c[i][j] == '.')
        continue;
      if (i + j < lu.first + lu.second)
        lu.first = i, lu.second = j;
      if (i + j > rd.first + rd.second)
        rd.first = i, rd.second = j;
      if (i + (W - j) < ru.first + (W - ru.second))
        ru.first = i, ru.second = j;
      if ((H - i) + j < (H - ld.first) + ld.second)
        ld.first = i, ld.second = j;
    }
  }

  // std::cout << lu.first << " " << lu.second << std::endl;
  // std::cout << rd.first << " " << rd.second << std::endl;
  // std::cout << ru.first << " " << ru.second << std::endl;
  // std::cout << ld.first << " " << ld.second << std::endl;

  int res = 0;
  // Output
  chmax(res, (rd.first - lu.first) + (rd.second - lu.second));
  chmax(res, (ld.first - ru.first) + (ru.second - ld.second));
  std::cout << res << std::endl;

  return 0;
}



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

using namespace std;

using ll =  long long int;

#define int  long long int
#define mod  1000000007

ll mod_pow(ll a,ll b,ll m){
    ll res = 1;
    while(b){
        if(b&1){
            res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

signed main() {
    
    ll n;
    
    cin >> n;
    
    if(n == 1) {
    	cout << 0;
    	return 0;
    }
    
    ll ans = mod_pow(10ll , n ,mod);
    ll t1 = mod_pow(9ll , n , mod);
    t1 = t1*2;
    t1 %= mod;
    ll t2 = mod_pow(8 , n , mod);
    
    t1 = (-t1+t2+mod) % mod;
    
    cout << (ans+t1+mod) % mod;
    
    return 0;
}

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

using namespace std;

int dp[10005][10];
int t[10];
int main(){
  for(int i=0;i<10005;i++) for(int j=0;j<10;j++) dp[i][j]=0;
  t[1]=2;t[2]=5;t[3]=5; t[4]=4;t[5]=5;t[6]=6;t[7]=3;t[8]=7;t[9]=6;
  t[0] = 100000000;
  vector<bool> v(10);
  int n,m; cin >> n >> m;
  for(int i=0;i<10;i++) v[i] = false;
  for(int i=0;i<m;i++){ 
    int temp; 
    cin >> temp;
    v[temp] = true;
  }
  for(int i=n;i>1;i--){
    int psum = 0;
    for(int k=1;k<=9;k++){psum += dp[i][k];}
    if(i!=n && psum==0) continue;
    psum++;
  	for(int j=1;j<=9;j++) if(v[j] && i-t[j] >= 0){
      int p = i-t[j], isum=0;
      for(int k=1;k<=9;k++){ isum += dp[p][k];}
      if(isum < psum){
      	for(int k=1;k<=9;k++) dp[p][k] = dp[i][k];
        dp[p][j]++;
      }
      else if(isum==psum){
      	bool flag = true;
        for(int k=9;k>=1;k--){
          if(dp[p][k] < dp[i][k] + (j==k ? 1 : 0)) break;
          else if(dp[p][k] == dp[i][k]) continue;
          else{flag = false; break;}
        }
        if(flag){
        	for(int k=1;k<=9;k++) dp[p][k] = dp[i][k];
        	dp[p][j]++;
        }
      }
    }
  }
  for(int i=9;i>=1;i--) for(int j=0;j<dp[0][i];j++) putchar('0'+i);
  cout << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>

using namespace std;

int main() {
	int s,w;
	cin >> s >> w;

	
	if (w >= s)
	{
		cout << "unsafe" << endl;


	}
	else
	{
		cout << "safe" << endl;

	}
	




	return 0;
}




Measured memory_bytes: 3552
#include<bits/stdc++.h>
#define N 255
using namespace std;
int m,n,d[N];
bool used[2][N],ans;
 
void dfs(int x,int idx){
  if(used[idx][x])return;
  used[idx][x]=true;
  x+=d[x];
  if(x<0)x=0;
  if(n+1<x)x=n+1;
  for(int i=1;i<=m;i++){
    int nx=x+i;
    if(n+1<nx)nx=n+1;
    dfs(nx,idx);
  }
}

int main(){
  while(1){
    cin>>m;
    if(!m)break;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>d[i];
    memset(used,0,sizeof(used));
    ans=true;
    dfs(0,0);
    if(!used[0][n+1])ans=false;
    for(int i=1;i<n+1;i++){
      if(!used[0][i])continue;
      for(int j=0;j<=n+1;j++)
	used[1][j]=false;
      dfs(i,1);
      if(!used[1][n+1])ans=false;
    }
    if(ans)cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1156
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
       int num=sc.nextInt();
       int count=0;
       for(int i=0;i<num;i++){
        int a=sc.nextInt();
        if((i+1)%2!=0&&a%2!=0)count++;
       }
       System.out.println(count);
       sc.close();
    }
} 

 


Measured memory_bytes: 35808
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
 
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
   	 
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll ans=max({a*c,a*d,b*c,b*d});
	cout<<ans<<'\n';
	return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int A,B,K;
    cin >> A >> B >> K;
    int count = 0;

    int i;

    if(A >= B)
        i = B;
    else
        i = A;
    
    while(count < K){
        if(A % i == 0 and B % i == 0)
            count++;
        i--;
    }
    cout << i+1 << endl;
}

Measured memory_bytes: 3648
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
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; }
typedef pair<int, int>P;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;
void solve() {
	int A, B, C; cin >> A >> B >> C;
	if (C - A - B < 0)print("No");
	else {
		if (4 * A*B < (C - A - B)*(C - A - B))print("Yes");
		else print("No");
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 256
A, B, M = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
x, y, c = [[], [], []]
for i in range(M):
    inp = input().split()
    x.append(int(inp[0]))
    y.append(int(inp[1]))
    c.append(int(inp[2]))
mi = min(a) + min(b)
for i in range(M):
    waribiki = a[x[i]-1] + b[y[i]-1] - c[i]
    if waribiki < mi:
        mi = waribiki
print(mi)

Measured memory_bytes: 24564
#include <bits/stdc++.h>
#define INF 1001001001
typedef long long ll;
using namespace std;
int ch, cw, dh, dw;
int h, w;
vector<int> g[1000010];
bool isr[1000][1000];
int label[1000][1000];
vector<pair<int, int>> labelv[1000010];
char s[1000][1000];
void dfs(int xx, int yy, int la) {
	if (0 > xx || xx >= w || 0 > yy || yy >= h || s[yy][xx] == '#' ||
		isr[yy][xx]) {
		return;
	}
	isr[yy][xx] = true;
	label[yy][xx] = la;
	labelv[la].push_back(make_pair(xx, yy));
	dfs(xx + 1, yy, la);
	dfs(xx - 1, yy, la);
	dfs(xx, yy + 1, la);
	dfs(xx, yy - 1, la);
}
vector<int> dist(1000010, -1);
void bfs(int st) {
	dist[st] = 0;
	queue<int> q;
	q.push(st);
	while (!q.empty()) {
		int n = q.front();
		for (auto v : g[n]) {
			if (dist[v] == -1) {
				dist[v] = dist[n] + 1;
				q.push(v);
			}
		}
		q.pop();
	}
}
int main() {
	cin >> h >> w >> ch >> cw >> dh >> dw;
	ch--;
	cw--;
	dh--;
	dw--;
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}
	int lab = 1;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			dfs(j, i, lab);
			lab++;
		}
	}
	for (int i = 1; i < 1000010; i++) {
		int sz = labelv[i].size();
		if (sz == 0)
			continue;
		set<int> ss;
		for (int j = 0; j < sz; j++) {
			for (int k = -2; k <= 2; k++) {
				for (int l = -2; l <= 2; l++) {
					int nx = labelv[i][j].first + k;
					int ny = labelv[i][j].second + l;
					if (0 > nx || nx >= w || 0 > ny || ny >= h)
						continue;
					if (label[ny][nx] >= 1) {
						ss.insert(label[ny][nx]);
					}
				}
			}
		}
		for (auto v : ss) {
			g[i].push_back(v);
			g[v].push_back(i);
		}
	}
	bfs(label[ch][cw]);
	if (dist[label[dh][dw]] == -1)
		printf("-1\n");
	else
		printf("%d\n", dist[label[dh][dw]]);
	return 0;
}


Measured memory_bytes: 72236
List=[list(map(int,input().split())) for i in range(3)]
N=int(input())
bingolist=[]
for i in range(N):
    bingolist.append(int(input()))

ans=[[0,0,0],[0,0,0],[0,0,0]]

flag=True

for j in range(N):
    for row in range(3):
        for col in range(3):
            if bingolist[j]==List[row][col]:
                ans[row][col]=1
for i in range(3):
    if ans[i][0]*ans[i][1]*ans[i][2]==1:
        print('Yes')
        flag=False
        break
    elif ans[0][i]*ans[1][i]*ans[2][i]:
        print('Yes')
        flag=False
        break
    elif ans[0][0]*ans[1][1]*ans[2][2]==1:
        print('Yes')
        flag=False
        break
    elif ans[0][2]*ans[1][1]*ans[2][0]==1:
        print('Yes')
        flag=False
        break
if flag:
    print('No')

Measured memory_bytes: 3064
H, W = map(int, input().split())
state = [[0 if s == '.' else 1 for s in list(input())] for _ in range(H)]

checked = [[False for _ in range(W)] for _ in range(H)]
qs = [(0, 0)]
checked[0][0] = True
goal = False
d = 0
while qs:
    qqs = []
    for qx, qy in qs:
        nexts = [(qx, qy+1), (qx, qy-1), (qx+1, qy), (qx-1, qy)]
        for nx, ny in nexts:
            if 0 <= nx <= W-1 and 0 <= ny <= H-1:
                if checked[ny][nx] or state[ny][nx] == 1:
                    continue
                qqs.append((nx, ny))
                checked[ny][nx] = True
            if nx == W-1 and ny == H-1:
                goal = True
                break
    d += 1
    if goal:
        break
    qs = qqs

black = 0
for h in range(H):
    for w in range(W):
        if state[h][w] == 1:
            black += 1

if goal:
    ans = H*W - black - d - 1
else:
    ans = -1

print(ans)

Measured memory_bytes: 3188
n, data = int(input()), [int(i) for i in input().split()]
dp = [0]*n
dp[1] = abs(data[1]-data[0])
for i in range(2, n):
    dp[i] = min(dp[i-2] + abs(data[i]-data[i-2]), dp[i-1] + abs(data[i]-data[i-1]))
print(dp[n-1])

Measured memory_bytes: 52208
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int dist[2005][2005];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, x, y;
	cin >> n >> x >> y;
	x--, y--;
	vector<vector<int>> G(n);
	REP(i,n-1){
		G[i].push_back(i+1);
		G[i+1].push_back(i);
	}
	G[x].push_back(y);
	G[y].push_back(x);

	REP(i,n) REP(j,n) dist[i][j] = -1;
	REP(i,n){
		queue<pair<int, int>> que;
		que.emplace(i, 1);

		while(!que.empty()){
			pair<int, int> cur = que.front();
			que.pop();

			for(auto nv: G[cur.first]){
				if(dist[i][nv]!=-1) continue;
				//cout << cur.first << " " << nv << " " << cur.second << '\n';
				dist[i][nv] = cur.second;
				que.emplace(nv, cur.second+1);
			}
		}
	}

	vector<int> ans(n-1, 0);
	REP(i,n) FOR(j,i+1,n) ans[dist[i][j]-1]++;

	REP(k,n-1) cout << ans[k] << '\n';	
	return 0;
}



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

int main(){
	double mt,max, min;
	cin>>mt;
	max=min=mt;
	while(cin>>mt){
		if(max<mt){
			max=mt;
		}else if(min>mt){
			min=mt;
		}
	}
	printf("%.1f\n", max-min);
	return 0;
}

Measured memory_bytes: 1236
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        int[] A = LineInt();
        double ans = 0;
        for (int i = 0; i < N; i++) ans += (1.0 / (A[i] + .0));
        Console.WriteLine(1.0/(ans+.0));
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[0] << c[0] << endl;
    return 0;
}


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

#define int long long

int N, A[100];

signed main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	int ans = LLONG_MAX/2;
	for (int i = -100; i <= 100; i++)
	{
		int sum = 0;
		for (int j = 0; j < N; j++)
		{
			sum += (i - A[j])*(i - A[j]);
		}
		ans = min(ans, sum);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{

    int i,j,n;
    n = 9;
    for(i = 1; i <= 9; i++){
        for(j = 1; j <= 9;j++ ){
            printf("%dx%d=%d\n" ,i,j,(i*j));
        }

    //printf("\n");

    }
return 0;

}


Measured memory_bytes: 2500
#include <bits/stdc++.h>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)
#define long long long

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef vector<int> vi;
typedef vector<pair<int, int>> vii;

const double PI = acos(-1.0), EPS = 1e-9;
const int MAXN = 100005, MAXM = 102, Mod = 998244353, MAXLog = 20;

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout
            << fixed;

    int n;
    cin >> n;
    for (int i = 1; i < 10; ++i) {
        for (int j = 1; j < 10; ++j) {
            if (i * j == n) {
                cout << "Yes\n";
                return 0;
            }
        }
    }

    cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#pragma region includes, macros
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef int64_t i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
    i64 from, to, cost;
    edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
    edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e : t) fill_v(e, v);
}
//

#pragma endregion

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

vector< int64_t > divisor(int64_t n) {
    vector< int64_t > ret;
    for (int64_t i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

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

// n = am + b (a == b)
// n = a(m + 1) 1, 2, 4, 8


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}


int main(){
	ll n;
	cin >> n;
	ll a[100010];
	FOR(i,n)cin >> a[i];

	ll ans=a[0]-1;
	a[0]=1;
	ll cnt=2;
	for(int i=1;i<n;i++){
		if(a[i]==cnt)cnt++;
		if(a[i]>cnt){
			if(a[i]%cnt==0){
				ans+=a[i]/cnt-1;
				a[i]=cnt;
				
			}else{
				ans+=a[i]/cnt;
				a[i]=a[i]%cnt;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
const int INF = 1001001001;

int main()
{
    int x,y,z;
    in x>>y>>z;
    bool flag=true;
    int i=1;
    while(flag){
        if(z+i*(y+z)<=x)i++;
        else flag=false;
    }
    cout<<i-1<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (int)(n); (i)++)
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define For(i, a, b)    for(int i = (a); (i) < (int)(b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

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

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



/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    string s; cin >> s;
    int s_size = s.size();

    rep(i, s_size){
        cout << 'x';
    }
    cout << endl;

return 0;
}

Measured memory_bytes: 3600
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iostream>
#include <cassert>
#include <cmath>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>

using namespace std;

#define INF 1e+9
#define mp make_pair
#define pb push_back
#define fi first
#define fs first
#define se second
#define i64 long long
#define li long long
#define lint long long
#define pii pair<int, int>
#define vi vector<int>

#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define fore(i, b, e) for (int i = (int)b; i <= (int)e; i++)

int main() {
#ifdef LOCAL
    freopen("inp", "r", stdin);
    //freopen("outp", "w", stdout);
#else
    // freopen(TASKNAME ".in", "r", stdin);
    // freopen(TASKNAME ".out", "w", stdout);
#endif
    int n, h;
    scanf("%d%d", &n, &h);
    vi a(n);
    vi b(n);
    forn(i, n) {
        scanf("%d%d", &a[i], &b[i]);
    }
    int maxx = a[0];
    forn(i, n)
        maxx = max(maxx, a[i]);
    vi bestb;
    forn(i, n)
        if (b[i] > maxx)
            bestb.pb(b[i]);
    sort(bestb.begin(), bestb.end());
    reverse(bestb.begin(), bestb.end());
    int ans = 0;
    forn(j, bestb.size()) {
        h -= bestb[j];
        ans++;
        if (h <= 0)
            break;
    }
    if (h > 0) {
        ans += h / maxx;
        if (h % maxx != 0)
            ans++;
    }
    printf("%d", ans);
}



Measured memory_bytes: 1660
#include<stdio.h>

int main(void){
  int n,i,rcnt=0,bcnt=0;
  scanf("%d",&n);
  char s[n+1];
  scanf("%s",s);
  for(i=0;i<n;i++){
    if(s[i]=='R') rcnt++;
    else bcnt++;
  }
  if(rcnt>bcnt) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0071
"""
import sys


def check_bombs(map, pos, dir, range=3):
    """
    ????¢¨????±???????????????\??????????????????????????§???????????????
    (?????°????????????????¢¨????±??????´?????§????????????????????????????????????????????§????????????????????????)
    :param map: ?????¨?????¶???
    :param pos: ???????????????????????????
    :param dir: ?????§????????????????¢¨????????? (up, down, left, right)
    :param range: ????¢¨????±??????????
    :return: ???????????????????????????????????? or None
    """
    if dir == 'up':
        x, y = pos
        while range > 0 and y > 0:
            if map[y-1][x] == '1':
                return (x, y-1)
            else:
                y -= 1
                range -= 1
    elif dir == 'down':
        x, y = pos
        while range > 0 and y < len(map)-1:
            if map[y+1][x] == '1':
                return (x, y+1)
            else:
                y += 1
                range -= 1
    elif dir == 'left':
        x, y = pos
        while range > 0 and x > 0:
            if map[y][x-1] == '1':
                return (x-1, y)
            else:
                x -= 1
                range -= 1
    elif dir == 'right':
        x, y = pos
        while range > 0 and x < len(map[0])-1:
            if map[y][x+1] == '1':
                return (x+1, y)
            else:
                x += 1
                range -= 1
    else:
        return None


def chain_bombs(map, init_pos):
    """
    ???????????£?????????????????¶???????¨??????????
    :param map: ???????????????????????¶???
    :param init_pos: (0, 0)?????????????????????????????????????????????????????§?¨?
    :return: ??????????????????????????¶???
    """
    lmap = map[:]               #  ??????????????¶????¨??????¨
    detonated = [init_pos]      #  ??±?????????????????????????????????(????????????)
    while detonated:
        x, y = detonated.pop()
        lmap[y][x] = '0'
        res = check_bombs(lmap, (x, y), 'up')
        if res:
            detonated.append(res)
        res = check_bombs(lmap, (x, y), 'down')
        if res:
            detonated.append(res)
        res = check_bombs(lmap, (x, y), 'left')
        if res:
            detonated.append(res)
        res = check_bombs(lmap, (x, y), 'right')
        if res:
            detonated.append(res)
    return lmap


def main(args):
    data_set = int(input())
    maps = []
    init_pos = []
    for i in range(data_set):
        _ = input()
        maps.append([list(input().strip()) for _ in range(8)])
        init_pos.append([int(input())-1, int(input())-1]) #  ??§?¨????0???????????????????????????

    count = 1
    for map, pos in zip(maps, init_pos):
        result = chain_bombs(map, pos)
        print('Data {}:'.format(count))
        for row in result:
            print(''.join(row))
        count += 1


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7904
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<math.h>
int main(void){
    uint_fast64_t a;
	float b;
    scanf("%" SCNuFAST64 " %f",&a,&b);
	printf("%" PRIuFAST64 "\n",a*(uint_fast16_t)nearbyintf(b*100)/100);
    exit(0);
}

Measured memory_bytes: 2276
import numpy as np

n, k, q = map(int, input().split())
i = np.array([k-q]*n)

# 計算
for l in range(q):
    a = int(input())-1
    i[a] += 1

# 出力
[print('No') if i[m]<=0 else print('Yes') for m in range(n)]


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

typedef long long ll;

ll Q;
typedef pair<ll, ll> Coord;
Coord X;
ll Y;
set<Coord> P;

int main() {
  cin >> Q;
  for (ll i = 0; i < Q; ++i) {
    ll kind;
    cin >> kind;
    if (kind == 1) {
      ll a, b;
      cin >> a >> b;
      Coord added = Coord(a, i);
      P.insert(added);
      Y += b;
      if (i == 0) {
        X = added;
      } else {
        if (added < X && (P.size() - 1) % 2 == 1) {
          Coord newx = *prev(P.find(X));
          Y += abs(newx.first - X.first);
          X = newx;
        } else if (X < added && (P.size() - 1) % 2 == 0) {
          Coord newx = *next(P.find(X));
          X = newx;
        }
        Y += abs(X.first - a);
      }
    } else {
      cout << X.first << " " << Y << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 12800