akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//  c
//
//  Created by 13B10694 on 2015/06/01.
//  Copyright (c) 2015????´ 13B10694. All rights reserved.
//

#include <iostream>
#include <vector>
#include<stdio.h>
#include <algorithm>
#include<string.h>
using namespace std;

int now=1;

class team{
    
public:
    int id, pen, sol;
    int wrong[12];
    vector <int> solved;
    team(){
        memset(wrong, 0, sizeof(wrong));
        id=now++;
        pen = 0;
        sol = 0;
    }
    ~team(){
        solved.clear();
    }
    
    bool operator < (const team& b) const
    {
        return solved.size()==b.solved.size() ? pen== b.pen ? id<b.id : pen<b.pen : solved.size()>b.solved.size();
    }
};

int main() {
    int t,p,r;
    while(cin>>t>>p>>r,t){
        now=1;
        vector<team> tea(t);

        for(int i=0;i<r;i++){
            int ti, pi, tim;
            string mes;
            cin>>ti>>pi>>tim>>mes;
            ti-=1;
            if(mes=="WRONG"){
                tea[ti].wrong[pi]++;
                continue;
            }
            if(find(tea[ti].solved.begin(),tea[ti].solved.end(),pi)!=tea[ti].solved.end()){
                continue;
            }
            tea[ti].solved.push_back(pi);
            tea[ti].pen += tea[ti].wrong[pi]*1200+tim;
  
        }
        sort(tea.begin(),tea.end());
        for(int i=0;i<t;i++){
            cout<<tea[i].id<<" "<<tea[i].solved.size()<<" "<<tea[i].pen<<endl;
        }
        tea.clear();
    }
    
    return 0;
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int INF=1e9;
int main(){
	int N;cin>>N;
	int j,c;int ans=0;
	rep(i,1,N+1){
		j=i;c=0;
		while(j>0){
			j/=10;
			c++;
		}if(c%2==1) ans++;
	}cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
map<P,bool> mp;
int main(){
int n;
cin>>n;
V<P> d(n);
for(int i=0;i<n;i++){
   cin>>d[i].fi>>d[i].se;
   mp[d[i]]=1;
}
int ans=n;
for(int i=0;i<n;i++){
   for(int j=0;j<n;j++){
      if(i==j)continue;
         ll a=d[j].fi-d[i].fi;
         ll b=d[j].se-d[i].se;
         int res=0;
         for(int k=0;k<n;k++){
            if(!mp[P(d[k].fi-a,d[k].se-b)])res++;
         }
         chmin(ans,res);
   }
}
cout<<ans<<endl;
}

Measured memory_bytes: 4096
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim S As String = NextString()
        Dim x, y As New HashSet(Of Char)

        For Each c As Char In S
            Select Case c & ""
                Case "N", "S"
                    y.Add(c)
                Case "W", "E"
                    x.Add(c)
            End Select
        Next

        WriteLine(New String() {"No", "Yes"}(B2I(x.Count Mod 2 = 0 And y.Count Mod 2 = 0)))
    End Sub

    Function B2I(ok As Boolean) As Integer
        If ok Then Return 1
        Return 0
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 20560
#include<iostream>

using namespace std;

int a[100010];
int N;

int main(){
	cin >> N;
	for(int i = 1; i <= N; i++){
		cin >> a[i];
	}
	int m = 0;
	int cnt = 0;
	for(int i = N; i; i--){
		if(a[i-1] >= a[i]) cnt++;
		else cnt = 0;
		m = max(cnt, m);
	}
	cout << m;
}

Measured memory_bytes: 640
N = int(input())
S = list(input())

# RGBとなる組み合わせの数を求める
sum_collection = S.count('R') * S.count('G') * S.count('B')

# RGBとなる組み合わせの数から、 j - i == k - jとなる組の数を減らす
for i in range(N):
    for j in range(i, N):
        # j - i == k - j　となる組を見つける
        k = j + (j - i)
        if k >= N:
            break
        # すべて違ったら　(R G Bの組み合わせであったら)
        if S[i] != S[j] != S[k] != S[i]:
            sum_collection -= 1

print(sum_collection)

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

#define REP(n) for(int i = 0;i < n;i++)
using namespace std;

int main(){

    int n;
    cin >> n;
    vector<bool> a(12,0);
    int tmp = 0;
    int count = 0;
    REP(n){
        cin >> tmp;
        if(tmp >=3200){
            count++;
        }
        a[tmp/400] = true;
    }

    int color_count = 0;
    REP(8){
        if(a[i] == true){
            color_count++;
        }
    }

    int mini = (color_count != 0) ? color_count : 1;
    int maxi = color_count+count;

    cout << mini << " " << maxi << endl;


    
   
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * The the time complexity of Binary Search is O(Log n).
 */
class Main {
    static int A[], B[];

    /**
     * return true if int x is in A.
     * otherwise, return false if x is not found in A.
     */
    static boolean contain(int l, int r, int x){
        int mid = (l + r) / 2;
        if(r < l) return false;

        if(A[mid] == x) return true;
        if(A[mid] > x) return contain(l,mid-1,x);

        return contain(mid+1,r,x);

    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(
                new InputStreamReader(System.in));

        // read the first list of integers
        int n = Integer.parseInt(br.readLine());
        A = new int[n];
        String[] nums = br.readLine().trim().split("\\s+");
        for (int i = 0; i < n; i++)
            A[i] = Integer.parseInt(nums[i]);

        // read the second list of integers
        n = Integer.parseInt(br.readLine());
        B = new int[n];
        nums = br.readLine().trim().split("\\s+");
        for (int i = 0; i < n; i++)
            B[i] = Integer.parseInt(nums[i]);

        int ans = 0;
        for (int b:B) {
            if(contain(0,A.length-1,b)) ans++;
        }


        System.out.println(ans);

    }

}



Measured memory_bytes: 53408
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    A2IN(ll, u, ll, v, N - 1);
    ll ans = 0;
    REP1(i, N)
    {
        ans += i * (N - i + 1);
    }
    REP(i, N - 1)
    {
        ll a = min(u[i], v[i]);
        ll b = max(u[i], v[i]);
        ans -= a * (N - b + 1);
    }
    OUT(ans);
}

Measured memory_bytes: 6420
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstring>
#include <complex>
#include <queue>
#include <stack>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}


void run(){
  int n;
  cin>>n;
  vi h(n+1);
  rep(i,n)cin>>h[i];
  bool f=false;
  int ans=0;
  do{
    f=false;
    rep(i,n){
      if(h[i]){
	f=true;
        int j;
	for(j=i+1;h[j];j++);
	ans++;
	Rep(k,i,j)h[k]--;
	i=j-1;
      }
    }
  }while(f);
  cout<<ans<<endl;
}


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

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");
		int q = Integer.parseInt(str[0]);
		SortedMap<String, Integer> mpa = new TreeMap<String, Integer>();
		for(int i = 0; i < q; i++){
			str = br.readLine().split(" ");
			int op = Integer.parseInt(str[0]);
			if(op == 0){
				String key = str[1];
				int x = Integer.parseInt(str[2]);
				mpa.put(key, x);
			}else if(op == 1){
				String key = str[1];
				if(mpa.containsKey(key)) System.out.println(mpa.get(key));
				else System.out.println(0);
			}else{
				String key = str[1];
				if(mpa.containsKey(key)) mpa.remove(key);
			}
		}
	}
}



Measured memory_bytes: 91652
import numpy as np
import sys

h, w = map(int, sys.stdin.readline().strip().split(" "))

a = np.zeros((h,w), dtype=int)

for i in range(h):
    l = sys.stdin.readline().strip()
    for j in range(w):
        a[i, j] = (l[j] == "#")

for i in range(h):
    for j in range(w):
        if a[i, j] == 0:
            continue
        check = True
        if i >= 1:
            check &= a[i-1, j] == 0
        if i < h-1:
            check &= a[i+1, j] == 0
        if j >= 1:
            check &= a[i, j-1] == 0
        if j < w-1:
            check &= a[i, j+1] == 0
        if check:
            print("No")
            quit()
print("Yes")

Measured memory_bytes: 12504
#include <cstdio>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#define fi first
#define sec second
#define INF 100000000
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int> P;

int n,m,k;
int cost[3000][3000];
int cnt[3000];
vector<P> e[3000];
bool shop[3000];
int ans;

void dijkstra(int s){
	rep(i,n) cost[s][i] = INF;
	if(!shop[s]) return; 
	cost[s][s] = 0;
	queue<P> que;
	que.push(P(s,0));
	while(true){
		if(que.size()==0) break;
		P p = que.front(); que.pop();
		if(p.sec > cost[s][p.fi]) continue;
		rep(i,e[p.fi].size()){
			if(shop[e[p.fi][i].fi])continue;
			if(cost[s][e[p.fi][i].fi] > cost[s][p.fi]+e[p.fi][i].sec){
				cost[s][e[p.fi][i].fi] = cost[s][p.fi]+e[p.fi][i].sec;
				que.push(P(e[p.fi][i].fi,cost[s][e[p.fi][i].fi]));
			}
		}
	}
}

int Abs(int x){
	return x>0?x:-x;
}

int main(){
	scanf("%d%d%d",&n,&m,&k);
	rep(i,m){
		int a,b,l; scanf("%d%d%d",&a,&b,&l);
		a--; b--;
		e[a].push_back(P(b,l));
		e[b].push_back(P(a,l));
	}
	rep(i,k){
		int s; scanf("%d",&s);
		s--;
		shop[s] = true;
	}
	rep(i,n) dijkstra(i);
	rep(i,n) cnt[i] = INF;
	rep(i,n){
		rep(j,n){
			cnt[i] = min(cnt[i],cost[j][i]);
		}
	}
	rep(i,n) ans = max(ans,cnt[i]);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < e[i].size(); j++){
			int f = e[i][j].fi, s = e[i][j].sec;
			ans = max(ans,max(cnt[i],cnt[f])+(s-Abs(cnt[i]-cnt[f])+1)/2);
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 39104
import math
N,D=map(int,input().split())
points = []
num = 0
for n in range(N):
    p = [ int(i) for i in input().split()]
    points.append(p)

for i in range(len(points)):
    for j in range(len(points) - i - 1):
        sum = 0
        for k in range(D):
            sum += (points[i][k]-points[i+j+1][k])**2
        if float.is_integer(math.sqrt(sum)):
            num += 1
print(num)

Measured memory_bytes: 3064
import math

n = int(input())
# s = input()
# n,k = map(int,input().split())
# da = list(map(int,input().split()))
# a = [int(input()) for i in range(n)]
# da = [list(map(int,input().split())) for i in range(m)]
st = set()

for i in range(1,int(math.sqrt(n))+1):
    if n%i == 0:
        st.add(i)
        st.add(n//i)
st.remove(1)
ans = 0
l = n-1
stt = set()
for i in range(1,int(math.sqrt(n))+1):
    if l%i == 0:
        stt.add(i)
        stt.add(l//i)
stt.remove(1)
ans += len(stt)

for i in st:
    m = n
    while m%i == 0:
        m //= i
    if m%i == 1:
        ans += 1

print(ans)


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define x first
#define y second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pi>
#define vpl vector<pl>
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005
using namespace std;
int n;
int dp[100001];
int hg[100001];
int main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    for(int i = 1 ; i<= n; i++){
        cin >> hg[i];
    }
    dp[n-1] = INF;
    for(int i = n; i > 1 ;i--){
        dp[i-1] = min(dp[i-1],dp[i] + abs(hg[i]-hg[i-1]));
        dp[i-2] = dp[i] + abs(hg[i]-hg[i-2]);
    }
    cout << dp[1];
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int x;
  cin>>x;
  if(x >= 30){
    cout << "Yes" << endl; 
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3676
#include<iostream>
#include<cstdio>

#include<vector>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
const int INF = 1e9+1;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}

//正解確率(1/2)^M の無限級数
//A = 1900*M+100+(N-M)
//A*(1/2)^M + 2A*(1/2)^2M + 3A*(1/2)^3M

int main() {
    ll N, M; 
    cin >> N >> M;
    ll A = 1900*M + 100*(N-M);
    ll res = 0;
    ll B = 1;
    for (int i = 0; i < M; i++) B *= 2;
    cout << A*B << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,K;
  cin>>N>>K;
  int l[N];
  REP(i,N)cin>>l[i];
  sort(l,l+N,greater<int>());
  int ans=0;
  REP(i,K)ans+=l[i];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
// A - Three-letter acronym

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;

	string ans = "";
	ans += toupper(s1[0]);
	ans += toupper(s2[0]);
	ans += toupper(s3[0]);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
#include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;
	using BigNum = std::vector<double>;

	class InputData {
	public:
		void getInput(void);
		void skipInput(void);
		Str getStr(void);
		Num getNum(void);
		BigNum getBigNum(void);
	private:
		Str str;
		Num num;
		BigNum bNum;
	};
	Str AtCoder::InputData::getStr(void) {
		return this->str;
	}
	Num AtCoder::InputData::getNum(void) {
		return this->num;
	}
	BigNum AtCoder::InputData::getBigNum(void) {
		return this->bNum;
	}
	void AtCoder::InputData::skipInput(void) {
		std::string buf = "";
		std::getline(std::cin, buf);
	}
	void AtCoder::InputData::getInput(void) {
		this->str.clear();
		this->num.clear();
		this->bNum.clear();

		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				this->str.push_back(row);
				this->num.push_back(std::atoi(row.c_str()));
				this->bNum.push_back(std::atof(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		this->str.push_back(row);
		this->num.push_back(std::atoi(row.c_str()));
		this->bNum.push_back(std::atof(row.c_str()));
	}

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(double);
		void decrement(void);
		void decrement(double);
		double getResult(void);
	private:
		double result;
	};
	void Ans::showResult(void) {
		printf("%.0lf\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(double value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(double value) {
		this->result -= value;
	}
	double AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
	void sort(std::vector<int>* vec) {
		std::sort(vec->begin(), vec->end());
	}
}

int main(void) {

	AtCoder::InputData* data = new AtCoder::InputData();
	data->getInput();

	AtCoder::Num num = data->getNum();

	const int a = num[0], b = num[1];
	
	int buf = 0, ans = 0;
	for (int i = 1; buf < a; i++) {
		buf += b;
		ans = i;
	}

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

	delete(data);

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    ll k;
    cin >> s >> k;
    rep(i,min(k,(ll)s.size())){
        if(s[i] != '1'){
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<sstream>
#include<iostream>
using namespace std;
int main(void){

    int n;
    cin>>n;
    int a[5];
    for(int i = 0;i < n;i++){
        cin>>a[i];
    }
    for(int i = 1;i < 100000000;i++){
        bool flg = true;
        for(int j = 0;j < n;j++){
            if(a[j]%i!=0)flg = false;
        }
        if(flg)cout<<i<<endl;
    }


    return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>

long long ru2(int n){
	int i;
	long long r=1;
	for(i=0;i<n;i++)r=r*2;
	return r;
}

long long unsigned ncm(int n,int m){
	if(n<m)return 0;
	if(m==0)return 1;
	if(m>n/2)m=n-m;
	int i;
	long long unsigned r=1;
	for(i=m-1;i>=0;i--)r=r*(n-i);
	for(i=m;i>=1;i--)r=r/i;
	return r;
	
}

int main(){
	int n,p,a[100],i;
	scanf("%d%d",&n,&p);
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	int guki[2]={0};
	for(i=0;i<n;i++)guki[a[i]%2]++;
	long long ang=ru2(guki[0]),ank=0;
	for(i=0;i+p<=guki[1];i+=2){
		ank+=ncm(guki[1],i+p);
	}
	printf("%lld\n",ang*ank);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String a = scanner.next(),b = scanner.next();
		if(a.equals("H")){
			System.out.println(b);
		}else{
			if(b.equals("H")){
				System.out.println("D");
			}else{
				System.out.println("H");
			}
		}
	}

}


Measured memory_bytes: 20820
#include <iostream>
using namespace std;
int main(void){
    int a,b,k;
    cin>>a>>b>>k;
    for(int i=0;i<k;i++){
        if(i%2==0){
            if(a%2==1){
                b+=(a-1)/2;
                a=(a-1)/2;
            }
            else{
                b+=a/2;
                a/=2;
            }
        }
        else{
            if(b%2==1){
                a+=(b-1)/2;
                b=(b-1)/2;
            }
            else{
                a+=b/2;
                b/=2;
            }
        }
    }
    cout<<a<<" "<<b<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9+9;
int g[103][103];
int edg[1004][3];
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            g[i][j] = inf;
        }
        g[i][i] = 0;
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<3;j++)cin>>edg[i][j];
        g[edg[i][0]][edg[i][1]] = min (edg[i][2],g[edg[i][0]][edg[i][1]]);
        g[edg[i][1]][edg[i][0]] = min (edg[i][2],g[edg[i][1]][edg[i][0]]);
    }
    int ans = m;
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                g[i][j] = min(g[i][j],g[i][k]+g[k][j]);
            }
        }
    }
    for(int i=0;i<m;i++){
        bool shortest = false;
        for(int j=1;j<=n;j++){
            if(g[j][edg[i][0]]+edg[i][2]==g[j][edg[i][1]])shortest = true;
        }
        if(shortest)ans--;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
L = [i for i in l if i%2 == 0]
M = [i for i in L if i%3 == 0 or i%5 == 0]
if len(L) == len(M):
    print("APPROVED")
else:
    print("DENIED")

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

string t,b;
long long dp[1001][1001];

int main(){
	cin >> t;
	cin >> b;
	t = "a" + t;
	b = "a" + b;
	
	int h = b.size();
	int w = t.size();
	for(int i = 0; i < w; i++){
		dp[0][i] = 1;
	}
	for(int i = 1; i < h; i++){
		dp[i][0] = 0;
	}

	for(int i = 1; i < h; i++){
		for(int j = 1; j < w; j++){
			if(t[j] == b[i]){
				dp[i][j] = dp[i-1][j-1];
			}
			else{
				dp[i][j] = 0;
			}
			dp[i][j] += dp[i][j-1];
			dp[i][j] %= 1000000007;
		}
	}
	cout << dp[h-1][w-1] << endl;

	return 0;
}



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

#define rep(i, n)  for (int i = 0; i < (n) ; ++i)

using namespace std;
using ll=long long;

const int INF = 100000;

int main() {
    ll N, M, A[10000] = {};
    ll res;
    cin >> N >> M;
    res = N;
    rep(i, M) {
        cin >> A[i];
        res -= A[i];
    }
    if (res < 0) {
        cout << -1;
    } else {
        cout << res;
    }
    return 0;
}


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

#define NM 10000001
bool prime[NM];

int main()
{
	for(int i=0; i<NM; i++)
	{
		prime[i] = true;
	}
	prime[0]=prime[1] = false;

	for(int i=0; i*i<NM; i++)
	{
		if(prime[i])
		{
			for(int j=i*2; j<NM; j+=i)
			{
				prime[j] = false;
			}
		}
	}

	int n;
	while(cin >> n, n)
	{
		while(true)
		{
			if(prime[n]&&prime[n-2]&&prime[n-6]&&prime[n-8])
			{
				cout << n << endl;
				break;
			}
			n--;
		}
	}
}

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

using namespace std;

int main()
{
    int n; cin >> n;
    int cur = 1;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        if (a == cur) cur++;
    }
    if (cur == 1) cout << -1 << "\n";
    else cout << n - cur + 1 << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <map>
#include <vector>
#include <cmath>
#include <string> // これがないとstringの出力がエラー
#include <sstream>
#include <algorithm>
#include <bitset>
#include <list>
#include <set>
using namespace std;

void pA()
{
	int N; cin >> N;
	multiset<int> points;
	for (int i = 0; i < N; ++i) {
		int p; cin >> p;
		points.insert(p);
	}

	int M; cin >> M;
	for (int i = 0; i < M; ++i) {
		int q; cin >> q;
		auto itr = points.find(q);
		if (itr == points.end()) {
			cout << "NO" << endl;
			return;
		}
		else {
			points.erase(itr);
		}
	}
	cout << "YES" << endl;
}

void pB()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	cout << A * 1728 + B * 144 + C * 12 + D << endl;
}

unsigned bit_count(unsigned n)
{
	unsigned i = 0;

	while (n) {
		i += n & 1;
		n >>= 1;
	}

	return i;
}

void pC()
{
	int N, C; cin >> N >> C;
	list<int> stick;
	for (int i = 0; i < N; ++i) {
		int in;
		cin >> in;
		stick.push_back(in);
	}

	stick.sort();

	int Cnum = 0;
	auto itr = stick.rbegin();
	while (true) {
		int value = *itr;
		int plus = 0;
		for (auto i = stick.begin(); i != stick.end(); ++i) {
			if (*i + value < C && plus != *i)
				plus = *i;
			else {
				auto deli = i; 
				if (deli != stick.begin()) {
					deli--;
					//cout << "delete " << *deli << endl;
					i = stick.erase(deli);
					//cout << "next " << *i << endl;
				}
				break;
			}
		}

		Cnum++;
		stick.erase(--(itr.base()));
		if (itr == stick.rend() || stick.size() == 0)
			break;
	}

	cout << Cnum << endl;
}

int main()
{
	pA();

	return 0;
}

Measured memory_bytes: 9600
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main(){
int a,b,c; cin >> a >> b >> c;
  b = 10*b+c;
  if( b%4 == 0){ cout <<"YES" << endl;}
  else{ cout << "NO" << endl;}
  
  return 0;
}
      


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using ll = int64_t;
using ld = long double;
using ull = uint64_t;
using namespace std;
using namespace __gnu_pbds;

const ll MOD = 1e9 + 7;
const ll REV2 = (MOD + 1) / 2;

ll pw(ll a, ll b) {
    if (!b) {
        return 1;
    }

    ll v = pw(a, b / 2);
    v = (v * v) % MOD;

    if (b & 1) {
        v = (v * a) % MOD;
    }

    return v;
}

ll rev(ll a) {
    return pw(a, MOD - 2);
}

const int MAXN = 200228;
pair<int, int> a[MAXN];
int n;

struct Fen {
    int vers = 1;
    ll f[MAXN];
    int v[MAXN];

    ll& at(int x) {
        if (v[x] < vers) {
            v[x] = vers;
            f[x] = 0;
        }

        return f[x];
    }

    void upd(int x, ll y) {
        for (int i = x; i <= n; i |= (i + 1)) {
            at(i) += y;
        }
    }

    ll gt(int x) {
        ll ans = 0;
        for (int i = x; i >= 0; i = (i & (i + 1)) - 1) {
            ans += at(i);
        }

        return ans;
    }
};

ll v[MAXN];

ll g(ll x) {
    x %= MOD;
    if (x < 0) {
        x += MOD;
    }

    return x;
}

Fen fc;
Fen sb;

int main() {
#ifdef PAUNSVOKNO
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20);  
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i].first;
        a[i].second = i;
    }

    sort(a, a + n);
   

    ll tot = 1;

    for (int i = 0; i < n; ++i) {
        v[i] = a[i].first - i;
        tot = (tot * v[i]) % MOD;
    }

    if (!tot) {
        cout << "0\n";
        return 0;
    }

    ll inveach = 0;
    ll sub = 0;
    ll mdf = 1;

    for (int i = n - 1; i >= 0; --i) {
        ll rv = rev(v[i]);

        inveach += fc.gt(a[i].second);
        fc.upd(a[i].second, 1);

        ll cur = (v[i] - 1) * rv % MOD;
        if (cur == 0) {
            sb.vers++;
            mdf = 1;
        } else {
            mdf = (mdf * cur) % MOD;
        }

        ll sl = sb.gt(a[i].second);
        ll sr = sb.gt(n) - sl;

        ll cs = g(sl - sr);
        cs = g(cs * mdf);
        cs = g(cs * v[i]);
        sub += cs;

        sub %= MOD;

        sb.upd(a[i].second, rv * rev(mdf) % MOD);
    }

    ll each = g(inveach - sub * REV2);

    cout << (tot * each) % MOD;
}

Measured memory_bytes: 8064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main {
	
	static class Scanner{
		BufferedReader br=null;
		StringTokenizer tk=null;
		public Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		public String next() throws IOException{
			while(tk==null || !tk.hasMoreTokens()) {
				String cad = br.readLine();
				if (cad == null)
					return null;
				tk=new StringTokenizer(cad);
			}
			return tk.nextToken();
		}
		public int nextInt() throws NumberFormatException, IOException{
			return Integer.valueOf(next());
		}
		public long nextLong() throws NumberFormatException, IOException{
			return Long.valueOf(next());
		}
		public double nextDouble() throws NumberFormatException, IOException{
			return Double.valueOf(next());
		}
	}
	
	
	public static void main(String args[]) throws NumberFormatException, IOException {
		Scanner sc = new Scanner();
		int N = sc.nextInt();
		int[] c = new int[100000 + 5];
		for(int i = 0; i < N; i++) {
			int n = sc.nextInt();
			c[n - 1 + 1]++;
			c[n + 0 + 1]++;
			c[n + 1 + 1]++;
		}
		int max = 0;
		int number = -1;
		for(int i = 0; i < c.length; i++)
			if (c[i] > max) {
				max = c[i];
				number = i - 1;
			}
		System.out.println(max);
		
	}

}


Measured memory_bytes: 35352
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
	double c1x = 0, c1y = 0, c1r = 0, c2x = 0, c2y = 0, c2r = 0;

	cin >> c1x >> c1y >> c1r >> c2x >> c2y >> c2r;

	double a = 0, b = 0, s = 0, t = 0, u = 0,
		   v1 = 0, v2 = 0, w1 = 0, w2 = 0;

	if (c1y == c2y) {
		b = (c1x + c2x + (c1r * c1r - c2r * c2r) / (c2x - c1x)) / 2;
		v1 = b;
		v2 = b;
		w1 = c1y - sqrt(c1r * c1r - (b - c1x) * (b - c1x));
		w2 = c1y + sqrt(c1r * c1r - (b - c1x) * (b - c1x));
	}
	else {
		a = (c1x - c2x) / (c2y - c1y);
		b = (c1r * c1r - c2r * c2r - c1x * c1x - c1y * c1y + c2x * c2x + c2y * c2y) / (2 * (c2y - c1y));

		s = a * a + 1;
		t = a * b - a * c1y - c1x;
		u = c1x * c1x + (b - c1y) * (b - c1y) - c1r * c1r;

		v1 = (-t - sqrt(t * t - s * u)) / s;
		v2 = (-t + sqrt(t * t - s * u)) / s;
		w1 = a * v1 + b;
		w2 = a * v2 + b;
	}

	cout << setiosflags(ios::fixed | ios::showpoint) << setprecision(8)
			<< v1 << " " << w1 << " " << v2 << " " << w2 << endl;

	return 0;
}


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

int main() {
    int n,k; cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    sort(h.begin(),h.end());
    if(k >= n) cout << 0 << endl;
    else {
        ll ans = 0;
        rep(i,n-k) ans += h[i];
        cout << ans << endl;
    }
    return 0;
}

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

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)


int main() {
  int n,d;
  cin >> n >> d;
  vector<vector<int>> vec(n, vector<int>(d, 0));
  REP(i,n) REP(j,d) cin >> vec[i][j];
  double tmp = 0;
  int ans = 0;
  REP(i,n) FOR(j,i+1,n){
    tmp = 0;
    REP(k,d) tmp += pow((vec[i][k] - vec[j][k]),2.0);    
    tmp = sqrt(tmp);
    // cout << tmp << " " << (int)tmp  << " " << i << j << endl;
    if (tmp - (int)tmp == 0) ans +=1; 
  }

  cout << ans << endl;
}

Measured memory_bytes: 3616
#まずそれぞれ大きい順にならべる
x,y,z,k = gets.split.map(&:to_i)

a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)

ab = []
for i in a
  for j in b
    ab << i + j
  end
end

ab.sort!
ab.reverse!

abc = []
0.upto(([ab.length, k].min - 1)) do |i|
  for j in c
    abc << ab[i] + j
  end
end

abc.sort!
abc.reverse!

puts abc[0...k]



Measured memory_bytes: 70128
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
using namespace std;
#define INF 100000000
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define rep(i, n) for(int (i)=1; (i)<=(n); (i)++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int K;
    cin >> K;
    int exist[110][110];
    for(int i=1; i<=K; i++){
        for(int j=1; j<=K; j++){
            exist[i][j] = 0;
        }
    }
    for(int i=1; i<=K; i++){
        for(int j=1; j<=K; j++){
            if(i == j) exist[i][j] = 0;
            else if(i != j){
                if((i%2 == 0 && j%2 != 0) || (i%2 != 0 && j%2 == 0))
                    exist[i][j]++;
            }
        }
    }
    int ans = 0;
    for(int i=1; i<=K; i++){
        for(int j=1; j<=K; j++){
            ans++;
        }
    }
    cout << ans/4 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.IllegalCharsetNameException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final List<Integer> list = IntStream.range(0, n)
                .mapToObj(i -> scanner.nextInt())
                .collect(Collectors.toList());

        final Map<Integer, Long> sumCount = new HashMap<>();
        final Map<Integer, Long> diffCount = new HashMap<>();
        for (int i = 0; i < list.size(); i++) {
            final int sum = i + list.get(i);
            final int diff = i - list.get(i);

            sumCount.compute(sum, (k, v) -> v == null ? 1 : v + 1);
            diffCount.compute(diff, (k, v) -> v == null ? 1 : v + 1);
        }

        long sum = 0;
        for (final Map.Entry<Integer, Long> entry : sumCount.entrySet()) {
            final int key = entry.getKey();
            if (diffCount.get(key) != null) {
                final long count = diffCount.get(key);
                sum += entry.getValue() * count;
            }
        }

        System.out.println(sum);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}
    

Measured memory_bytes: 80692
r="#"
s='.'
loop{
	h,w=gets.split(" ").map(&:to_i)
	break if h==0 and w==0
	h.times{|i|
		w.times{|j|
			if (i+j)%2==0
				print("#{r}")
			else
				print("#{s}")
			end
		}
		puts""
	}
	puts ""
}



Measured memory_bytes: 6860
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000100 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 2010

int h,w;
int a[SIZE][SIZE];
int a2[SIZE][SIZE];

void rotate(){
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      a2[j][h-1-i] = a[i][j];
    }
  }

  swap(w,h);
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      a[i][j] = a2[i][j];
      //printf("%d ",a[i][j]);
    }
    //puts("");
  }
  
}

int dp[2][SIZE][SIZE] = {};

int main(){
  int min_a = INF, max_a = 0;
  
  scanf("%d%d",&h,&w);

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      scanf("%d",a[i]+j);
      min_a = min(a[i][j], min_a);
      max_a = max(a[i][j], max_a);
    }
  }

  if(min_a == max_a){
    puts("0");
    return 0;
  }
  
  int ans = INF;
  
  for(int q=0;q<2;q++){

    for(int i=0;i<=h;i++){
      for(int j=0;j<=w;j++){
        dp[0][i][j] = dp[1][i][j] = INF;
      }
    }

    dp[0][0][0] = dp[1][0][0] = 0;
    
    //?¨?
    for(int i=0;i<h;i++){

      priority_queue<pair<int,int> > pq_max;
      priority_queue<pair<int,int> > pq_min;

      for(int j=0;j<w;j++){
        pq_max.push({a[i][j],j});
        pq_min.push({-a[i][j],j});
      } 
      
      int min_a2 = INF, max_a2 = 0;
      int dp_memo1 = INF, dp_memo2 = INF; 
      
      for(int j=0;j<=w;j++){
        while(pq_max.size() && pq_max.top().second < j) pq_max.pop();
        while(pq_min.size() && pq_min.top().second < j) pq_min.pop();

        dp_memo1 = min(dp_memo1, dp[0][i][j]);
        dp_memo2 = min(dp_memo2, dp[1][i][j]);

        int pq_max_f, pq_min_f;

        if(pq_max.size()){
          pq_max_f = pq_max.top().first;
        }else{
          pq_max_f = 0;
        }
        if(pq_min.size()){
          pq_min_f = -pq_min.top().first;
        }else{
          pq_min_f = INF;
        }
        
        // max\min
        if(min_a2 != min_a && pq_max_f != max_a){
          dp[0][i+1][j] = min(dp[0][i+1][j],
                              max({dp_memo1, max_a-min_a2, pq_max_f - min_a}));
        }

        // min\max
        if(max_a2 != max_a && pq_min_f != min_a){
          dp[1][i+1][j] = min(dp[1][i+1][j],
                              max({dp_memo2, max_a2-min_a, max_a - pq_min_f}));
        }
        
        min_a2 = min(min_a2,a[i][j]);
        max_a2 = max(max_a2,a[i][j]);
      }

    }

    int this_ans = INF;
    
    for(int i=0;i<=w;i++){
      ans = min({ans, dp[0][h][i],dp[1][h][i]});
      this_ans = min({this_ans, dp[0][h][i],dp[1][h][i]});
    }
    
    //debug(this_ans);
    
    rotate();
  }

  if(ans == INF){
    ans = max_a - min_a;
  }
  
  printf("%d\n",ans);
  
  return 0;
}

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

using namespace std;

int main()
{
	string s,t;
	cin >> s >> t;
	string ans;
	int n=-1;
	int k  = 0;
	int flag = 0;
	for(int i = 0;i<s.size();i++)
	{
		if(t.size() > s.size())
			break;
		if(s[i] == t[0] || s[i] == '?')
		{
			k = 0;
			int j;
			for(j = 0;j<t.size();j++)
			{
				if(s[i+j] == t[j] || s[i+j] == '?')
					k++;
				else
					break;
			}
			if(k == t.size())
				flag = 1,n = i;
		}
	}

	if(flag)
	{
		int k = 0;
		for(int i = n;i<n+t.size();i++)
			s[i] = t[k++];
		for(int i = 0;i<s.size();i++)
			if(s[i] == '?')
				s[i] = 'a'; 
		cout << s << endl;
	}
	else
		cout << "UNRESTORABLE" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int m,n;
string s[130];
map<vector<int>,int> mp;

int dfs(vector<int> v) {
  if (v.size() <= 1) return 0;
  if (mp.count(v)) return mp[v];
  int res = INF;
  for (int j = 0; j < m; j++) {
    vector<int> v0,v1;
    for (int i = 0; i < v.size(); i++) {
      if (s[v[i]][j] == '0') {
        v0.push_back(v[i]);
      } else {
        v1.push_back(v[i]);
      }
    }
    if (v0.size() != v.size() && v1.size() != v.size()) {
      CHMIN(res,max(dfs(v0),dfs(v1))+1);
    }
  }
  return mp[v] = res;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  while (cin >> m >> n, m) {
    mp.clear();
    REP(i,n) cin >> s[i];
    vector<int> v(n,0);
    iota(ALL(v),0);
    cout << dfs(v) << endl;
  }

  return 0;
}


Measured memory_bytes: 5732
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    S = "1" + S + "1";
    vector<ll> st[2];
    char c = S[0];
    st[c - '0'].push_back(0);
    REP(i, 1, N + 2) {
        if (S[i] != c) {
            st[S[i] - '0'].push_back(i);
            c = S[i];
        }
    }
    ll mark = 0;
    ll ans = 0;
    if ((ll)st[0].size() <= K) {
        ans = N;
    }
    while (mark + K < (ll)st[1].size()) {
        ll tmp;
        if (mark + K == (ll)st[1].size() - 1) {
            tmp = N - st[1][mark] + 1;
        } else {
            tmp = st[0][mark + K] - st[1][mark];
        }
        if (mark == 0) {
            tmp--;
        }
        ans = max(ans, tmp);
        mark++;
    }
    cout << ans << endl;
}


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

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

ll getSunuke(ll n)
{
    ll ret = 0;
    while (n){
        ret += (n % 10);
        n /= 10;
    }
    return ret;
}

ll getNextNum(ll n)
{
    ll plus = 1;
    double old = DBL_MAX;
    while (true){
        const ll k = n + plus;
        const double v = 1.0 * k / getSunuke(k);
        if (old <= v) return n + plus / 10;
        old = v;
        plus *= 10;
    }
}

int main()
{
    scanLLInt(N);
    ll n = 0;
    for (ll i = 0; i < N; ++i){
        n = getNextNum(n);
        cout << n << endl;
        // cout << n << " : " << 1.0 * n / getSunuke(n) << endl;
    }
}


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

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

	for(int a, b; cin >> a >> b, a;) {
		vector<vector<bool> > ng(a, vector<bool>(b, false));
		
		int n;
		cin >> n;
		
		for(int i = 0; i < n; ++i) {
			int x, y;
			cin >> y >> x;
			--y; --x;
			ng[y][x] = true;
		}
		
		vector<vector<int> > dp(a + 1, vector<int>(b + 1, 0));
		dp[0][0] = 1;
		
		for(int i = 0; i < a; ++i) {
			for(int j = 0; j < b; ++j) {
				if(ng[i][j])
					continue;
				
				dp[i + 1][j] += dp[i][j];
				dp[i][j + 1] += dp[i][j];
			}
		}
		
		cout << dp[a - 1][b - 1] << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1224
#include<stdio.h>
#define MAX 100001
int A[MAX] = {0}, N, Al[MAX], Ar[MAX];
int gcd(int x, int y) {return y? gcd(y, x%y): x;}

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	Al[0] = A[0];
	Ar[N-1] = A[N-1];
	for (int i = 1; i < N - 1; i++) {
		Al[i] = gcd(Al[i-1], A[i]);
		Ar[N-i-1] = gcd(Ar[N-i], A[N-i-1]);
	}
	int ans = Ar[1];
	for (int i = 1; i < N - 1; i++) {
		int t = gcd(Al[i-1], Ar[i+1]);
		if (t > ans) ans = t;
	}
	if (ans < Al[N-2]) ans = Al[N-2];
	printf("%d", ans);
}

Measured memory_bytes: 1280