akhauriyash/Code-Regression huggingface dataset:
# ABC 075: B – Minesweeper
h, w = map(int, input().split())
s = [input() for _ in range(h)]

mines = 0

for row in range(h):
    for column in range(w):
        if s[row][column] == '.':
            if row > 0 and column > 0: # top left
                mines = mines + 1 if s[row - 1][column -1] == '#' else mines
            if row > 0: # top
                mines = mines + 1 if s[row - 1][column] == '#' else mines
            if row > 0 and column < w - 1: # top right
                mines = mines + 1 if s[row - 1][column + 1] == '#' else mines
            if column > 0: # left
                mines = mines + 1 if s[row][column - 1] == '#' else mines
            if column < w - 1: # right
                mines = mines + 1 if s[row][column + 1] == '#' else mines
            if row < h - 1 and column > 0: # bottom left
                mines = mines + 1 if s[row + 1][column - 1] == '#' else mines
            if row < h -1 : # bottom
                mines = mines + 1 if s[row + 1][column] == '#' else mines
            if row < h - 1 and column < w - 1: # bottom right
                mines = mines + 1 if s[row + 1][column + 1] == '#' else mines
        
            #s[row][column].replace('.', str(mines))
            s[row] = s[row][:column] + str(mines) + s[row][column + 1:]
            mines = 0

for row in range(h):
    print(s[row])

Measured memory_bytes: 3064
n, m, v, p = map(int, input().split())

a = list(map(int, input().split()))
a.sort(reverse=True)

mv = m*max(0, v-p+1)
b = a[p-1:]

l, r = b[0], b[0]+m
while l < r:
    md = (l+r)//2
    c = 0
    for i in b:
        c += min(m, md-i)
    if mv <= c:
        r = md
    else:
        l = md + 1

result = p
for i in b[1:]:
    if i+m >= r:
        result += 1
    else:
        break
print(result)

Measured memory_bytes: 14484
#include<bits/stdc++.h>
#define MAX 20010
#define inf 1<<29
#define linf 1e16
#define eps (1e-8)
#define mod 1000000007
#define pi acos(-1)
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int main()
{
  int n;
  int p[MAX];
  int a[MAX],b[MAX];
  
  cin>>n;
  FOR(i,0,n)cin>>p[i];
  FOR(i,0,n)b[i]=n-i;
  FOR(i,0,n)a[i]=(i+1)*n;
  int count=n*n+1;
  FOR(i,0,n){
    b[p[i]-1]=count-a[p[i]-1];
    count++;
  }
  FOR(i,0,n){
    cout<<a[i];
    if(i!=n-1)cout<<" ";
  }
  cout<<endl;
  FOR(i,0,n){
    cout<<b[i];
    if(i!=n-1)cout<<" ";
  }
  cout<<endl;

  return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
using ll = long long;

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = max(a*c, a*d);
    ans = max(ans, b*c);
    ans = max(ans, b*d);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3192
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        private static long mod = 1000000007;

        static void Main(string[] args)
        {
            var r = ReadSplit();
            var x = r[0].Int();
            var n = r[1].Int();
            var l = new int[n];
            if (n == 0)
            {
                WriteRead(x);
                return;
            }
            var r2 = ReadSplit();            
            for (int i = 0; i < n; i++)
            {
                l[i] = r2[i].Int();
            }
            var j = 0;
            var now = x;
            var ans = mod;
            while (true)
            {
                if (!l.Any(xx => xx == now))
                {
                    ans = now;
                    break;
                }
                now++;
            }
            now = x;
            var ans2 = mod;
            while (true)
            {
                if (!l.Any(xx => xx == now))
                {
                    ans2 = now;
                    break;
                }
                now--;
            }
            if (Math.Abs(x - ans) < Math.Abs(x - ans2))
            {
                WriteRead(ans);
            }
            else
            {
                WriteRead(ans2);
            }
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 18888
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>
#include <iomanip>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define double long double
#define int long long
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define inf 10000000000000000 //10^16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
using namespace std;

signed main() {
	string s;
	cin >> s;
	int n = s.size();
	int a = 0, b = 0;
	rep(i, n) {
		if (i % 2 == 0) {
			if (s[i] == '1') a++;
		}
		else if (s[i] == '0') a++;
	}
	rep(i, n) {
		if (i % 2 == 0) {
			if (s[i] == '0') b++;
		}
		else if (s[i] == '1') b++;
	}
	cout << min(a, b) << endl;
}

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

Board = []
for i in range(2):
  Board.append(list(map(int, input().split())))

max_candies = 0
for gotodown_index in range(N):

  upper_candies = sum(Board[0][:gotodown_index+1])
  lower_candies = sum(Board[1][gotodown_index:])
  candies = upper_candies + lower_candies

  if candies > max_candies:
    max_candies = candies

print(max_candies)


Measured memory_bytes: 3060
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int a, b, c; cin >> a >> b >> c;
    vector<bool> used(60, 0);
    used[0] = 1;
    int cur = 0;
    while(true) {
        if(cur % 60 <= c && c <= cur % 60 + a) {
            cout << cur / 60 * 60 + c << endl;
            return;
        }
        if(cur % 60 <= c + 60 and c + 60 <= cur % 60 + a) {
            cout << cur / 60 * 60 + 60 + c << endl;
            return;
        }
        cur += a;
        cur += b;
        if(used[cur % 60]) {
            cout << -1 << endl;
            return;
        }
        used[cur % 60] = 1;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}


Measured memory_bytes: 3232
#include <stdio.h>
#include <inttypes.h>

int main(void) {
	uint64_t N, K;
	uint64_t asumi, iguti;
	if (scanf("%" SCNu64 "%" SCNu64, &N, &K) != 2) return 1;
	asumi = N % K;
	iguti = K - asumi;
	printf("%" PRIu64 "\n", asumi <= iguti ? asumi : iguti);
	return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import sys

n= int(input())
#tmp= float(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

ou=""
for i in range(n):
    ou+=str(hoge[n-1-i])
    if(i!=n-1):
        ou+=" "

print(ou)



Measured memory_bytes: 5600
#include<iostream>
#include<string>
using ll=long long;
using namespace std;

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

    int ans=to_string(n).length();

    for(ll i=1;i*i<=n;i++){
        if(n%i!=0) continue;
        ans=min(max((int)to_string(i).length(),(int)to_string(n/i).length()),ans);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int A, B;
    std::cin >> A >> B;

    int score = 0;
    for (int i = 0; i < 2; ++i)
    {
        if (A >= B)
        {
            score += A;
            A--;
        }
        else
        {
            score += B;
            B--;
        }
    }
    std::cout << score << std::endl;
    return 0;
}

Measured memory_bytes: 256
// Gaurav Aggarwal
 
/*
useful stl
array<ll,size> ar;         //size(),front(),back(),fill(),empty()
deque<ll> d                //push_back(),push_front(),pop_front(),pop_back()
vector<ll> v(size,val);    //push_back(),*max_element(v.begin(),v.end()),accumulate(v.begin(),v.end(),0)
stack<ll> g;               //push(),pop(),top(),size(),empty()         LIFO
queue<ll> q;               //push(),size(),front(),back(),empty()      FIFO
priority_queue<ll> pq
*/
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define mod 1000000007
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  

    int n,l;
    cin>>n>>l;

    int sum = 0;
    vi v;
    for(int i=1;i<=n;++i) {
        sum += l+i-1;
        v.pb(abs(l+i-1));
    }

    int diff = 1000;
    int ans = 0;


    for(int i=1;i<=n;++i) {

        int flav = l+i-1;
        int now = sum - flav;
        int d = abs(now - sum);
        if(d < diff) {
            diff = d;
            ans = now;
        }


    }

    cout<<ans;

    return 0;
}   

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


using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> P;

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define Rep(i, n) for(int i=n; i >= 0; i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える

const int INF = 50010;

int main() {
	int q; cin >> q;
	rep(i, q) {
		string x, y; cin >> x >> y;
		int n = x.size(), m = y.size();

		vvi dp(n + 1, vi(m + 1, 0));

		rep(i, n) rep(j, m) {
			if (x[i] == y[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
			else dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
		}

		cout << dp[n][m] << endl;
	}
}



Measured memory_bytes: 6828
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cmath>

using namespace std;
typedef pair<long long int, long long int> P;
typedef pair<P, long long int> PI;

vector<long long int> Pall[100001];

void solve()
{
	int N, M;
	cin >> N >> M;
	vector<int> p(M);
	vector<int> y(M);
	for (int i = 0; i < M; ++i)
	{
		cin >> p[i] >> y[i];
		Pall[p[i]].push_back(y[i]);
	}
	for (int i = 0; i < N; ++i)
	{
		sort(Pall[i + 1].begin(), Pall[i + 1].end());
	}
	for (int i = 0; i < M; ++i)
	{
		printf("%012lld\n", (long long int)p[i] * 1000000 + (int)(lower_bound(Pall[p[i]].begin(), Pall[p[i]].end(), y[i]) - Pall[p[i]].begin()) + 1);
	}
}

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

Measured memory_bytes: 7808
#include <bits/stdc++.h>
        using namespace std;
        #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
        #define M_PI 3.14159265358979323846
        #define data data_
        #define ff first
        #define ss second
        #define pb push_back
        #define ld long double
        #define int long long
        #define print(t) cout << "Case #" << t << ": ";
        int32_t main()
        {
            tani_nachi_ke  
            
            
            string s,t;
            cin >> s >> t;
            if(s == t.substr(0,s.size()))
                cout << "Yes" << endl;
            else 
                cout << "No" << endl;




           return 0;
        }
          

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

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  int plan1,plan2;
  plan1 = A * N;
  plan2 = B;
  if(plan1 > plan2)
    cout << plan2 << endl;
  else
    cout << plan1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool isPrime(int num);

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int x;
	cin>>x;
	bool a=true, b;
	while(a)
	{
		b=isPrime(x);
		if(!b)	x++;
		else
		{
			cout<<x;
			a=false;
		}
	}
}
bool isPrime(int num)
{
	bool flag = true;
	for (int i = 2; i <= num / 2; i++)
	{
		if (num % i == 0)
		{
			flag = false;
			break;
		}
	}
	return flag;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
using namespace std;
ll h,ans=1;
int main(void){
	cin>>h;
	int i;
	for(i=0;h>0;i++)h/=2;
	REP(j,i)ans*=2;
	ans--;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main (void){
  int n,a,b,c;
  scanf("%d",&n);
  a=n/100;
  b=(n%100)/10;
  c=n-a*100-b*10;
  if(
    (a==7)||(b==7)||(c==7)
    ){
    printf("Yes");
  }
    else
      printf("No");
    return 0;
}

Measured memory_bytes: 1728
#!/usr/bin/env python3
# ITP2_9_C: Set Operation - Set Difference


def diff(n, m, a, b):
    i, j = 0, 0
    while i < n and j < m:
        if a[i] < b[j]:
            yield a[i]
            i += 1
        elif a[i] > b[j]:
            j += 1
        else:
            i += 1
            j += 1

    while i < n:
        yield a[i]
        i += 1


def run():
    n = int(input())
    a = [int(i) for i in input().split()]
    m = int(input())
    b = [int(j) for j in input().split()]

    for v in diff(n, m, a, b):
        print(v)


if __name__ == '__main__':
    run()



Measured memory_bytes: 35908
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <functional>
typedef long long ll;
using namespace std;

int main() {
    int k;
    string s;
    cin >> k;
    cin >> s;
    if (s.length() <= k) cout << s << endl;
    else cout << s.substr(0,k)+"..." << endl;
    return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h> 
using namespace std ; 
#define ll long long int 
#define pb push_back
#define ff first 
#define dobara(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define ss second 
#define S(x) scanf("%d",&x) 
#define SL(x) scanf("%lld",&x)
#define M 1000000007
#define sz(x) (int)x.size()
#define all(a) (a).begin(),(a).end()

vector< pair<int,int> >  v ; 

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

	int curr = 0 ; 
    int strt = -1 , endd = -1 ; 

	for(int i=0;i<n;i++){
		if(s[i] == '1' && strt != -1){
			v.pb({strt,i-1}) ;
			strt = -1 ;  
		}
		else if(s[i] == '0'){
			if(strt == -1){
				strt = i ; 
			}
		}
	}

	if(strt != -1){
		v.pb({strt,n - 1}) ; 
	}

	int sz = v.size() ; 
    int ans = 0 ; 
	for(int i=0;i<sz;i++){
		//cout<<v[i].ff<<" "<<v[i].ss<<endl;
        int x = min(sz - 1 , i+k-1) ; 
        int L = 0 , R = n - 1 ; 
        if(i != 0){
        	L = v[i - 1].ss + 1 ; 
        }
        if(x != sz - 1){
        	R = v[x + 1].ff - 1; 
        } 
        ans = max(ans , R - L + 1) ; 
	}
    
    if(sz == 0)
    	ans = n ;
	cout<<ans<<"\n" ;
}

Measured memory_bytes: 1020
#include<iostream>
#include <algorithm>
#include<cmath>
using namespace std;
int main(){

long n;
std::cin >> n;
long nn=sqrt(n);
long flag=0;
long minnum=1+n;

for (long i = nn; i > 1; i--) {
  if(n%i==0){minnum=i+n/i;break;}
}
std::cout <<minnum-2 << '\n';

return 0;
}


Measured memory_bytes: 256
# ABC138E - Strings of Impurity
from bisect import bisect_left as bs
from collections import defaultdict


def main():
    S = input()
    T = input()
    # idx[c] := indices at which character c appears in S
    idx, ls = defaultdict(list), len(S)
    for i, s in enumerate(S):
        idx[s] += [i]
    roop, cur = 0, -1
    for t in T:  # binary search to find t's index > cur
        tgt = idx[t]  # sorted list of indices of t
        if tgt == []:  # t not in S
            print(-1)
            return
        x = bs(tgt, cur + 1)
        if x < len(tgt):  # find in current roop
            cur = tgt[x]
        else:  # move to next roop and pick up the first one
            cur = tgt[0]
            roop += 1
    print(roop * ls + cur + 1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 8052
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    while (1)
    {
        int n, l, r;
        cin >> n >> l >> r;
        if (n == 0)
            break;
        vector<int> a(n);
        rep(i, n) cin >> a[i];
        int ans = 0;
        for (int y = l; y <= r; y++)
        {
            bool uruu = false, f = true;
            rep(i, n) if (y % a[i] == 0)
            {
                f = false;
                if (i % 2 == 0)
                    uruu = true;
                break;
            }
            if (f && n % 2 == 0)
                uruu = true;
            if (uruu)
                ans++;
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3076
N, M = gets.split.map(&:to_i)

a = []
M.times {
	a << gets.split.map(&:to_i)
}
a.sort!
	
i = 1
c = 0
loop {
	c += 1
	max = -1
	while !a.empty? && a[0][0] <= i
		max = [max, a.shift[1]].max
	end

	if max < 0
		puts 'Impossible'
		break
	end

	if max == N
		puts c
		break
	end

	i = max + 1
}

Measured memory_bytes: 6108
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
string s;
int n,m;
vector<pair<bool,int> > a(10);
string ans="";
int dp[10100];
int main(int argc,char const* argv[])
{
  for(int i=1;i<=9;i++)
    {
      a[i].first=false;
    }
  cin >> n >> m;
  int digit=0;
  for(int i=0;i<m;i++)
    {
      int num;
      cin >> num;
      a[num].first=true;
      if(num==1)
	{
	  a[num].second=2;
	}
      else if(num==2 || num==3 || num==5)
	{
	  a[num].second=5;
	}
      else if(num==4)
	{
	  a[num].second=4;
	}
      else if(num==6 || num==9)
	{
	  a[num].second=6;
	}
      else if(num==7)
	{
	  a[num].second=3;
	}
      else if(num==8)
	{
	  a[num].second=7;
	}
    }
  for(int j=0;j<=n;j++)
    {
      dp[j]=INF*-1;
    }
  dp[0]=0;
  for(int i=1;i<=9;i++)
    {
      if(a[i].first) dp[a[i].second]=1;
    }
  for(int j=2;j<=n;j++)
    {
      for(int i=9;i>=1;i--)
	{
	  if(a[i].first==true)
	    {
	      if(j-a[i].second>=0)
		{
		  dp[j]=max(dp[j],dp[j-a[i].second]+1);
		}
	    }
	}
    }
  int num[8]={-1,-1,1,7,4,2,6,8};
  if(a[3].first) num[5]=3;
  if(a[5].first) num[5]=5;
  if(a[9].first) num[6]=9;
  int tmp=n;
  for(int i=0;i<dp[n];i++)
    {
      for(int j=9;j>=1;j--)
	{
	  if(a[j].first && tmp-a[j].second>=0)
	    {
	      if(dp[tmp-a[j].second]==dp[tmp]-1)
		{
		  cout << num[a[j].second];
		  tmp-=a[j].second;
		  break;
		}
	    }
	}
    }
  cout << endl;
  return 0;
  //cout << dp[n] << endl;
  //cout << ans << endl;
}


Measured memory_bytes: 256
x,y = map(int,raw_input().split())
if x%y==0:
        print '-1'
else:
        i=2
        while x*i<10**18+1:
                if x*i%y!=0:
                        print x*i
                        break
                i=i+1

##t=[1]
##while t[len(t)-1]*2<=n:
##	t.append(t[-1]*2)
##x=0
##i=0
##while i<len(t) and x+t[i]<=n:
##	x=x+t[i]
##	i=i+1
##
##if n&(n+1)==0:
##	print n
##elif k==1:
##	print n
##else:
##	print 2*t[-1]-1


Measured memory_bytes: 2568
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	int N; cin >> N;
	vector<LLONG> as(N); REP(i, N) cin >> as[i];
	LLONG max = 0;
	LLONG sum = 0;
	REP(i, N)
	{
		if (as[i] >= max) {
			max = as[i];
		}
		else
		{
			sum += max - as[i];
		}
	}
	cout << sum << endl;
}

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

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
const ll MAX_N = 3000;
/**/
int main() {
	// 入力
	ll N,M;cin>>N>>M;
	ll H[N];
    REP(i,N)cin>>H[i];
    bool good[N];REP(i,N)good[i] = true;
	REP(i,M){
		ll a,b;cin>>a>>b;a--;b--;
		if (H[a]==H[b]){
			good[a] = false;
			good[b] = false;
		} else if (H[a]<H[b])good[a] = false;
		else good[b] = false;
	}

	// 解法
	ll ans = 0;
	REP(i,N){
		if (good[i]==true)ans++;
	}
	
	//出力
	printf("%lld\n", ans);	
}


Measured memory_bytes: 4640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple


int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n; cin>>n;
	int s1=0,s2=0;
	for(int i=0;i<n;i++)
	{
	    int p; cin>>p;
	    s1+=p; s2+=p*p;
	}
	int y1=s1/n; int y2=y1+1;
	int m1 = s2 - (2*y1*s1) + (n*y1*y1);
	int m2 = s2 - (2*y2*s1) + (n*y2*y2);
	cout<<min(m1,m2);
	
	
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define ll long long
#define int ll

using namespace std;

const int MN = 1e5+7;
int MOD, n, dp[MN], dpbig[MN], mark[MN];
vector<int> g[MN];

void dfs(int now, int dis){
    mark[now] = dis;
    int zz = 1;
    for(int i = 0; i < g[now].size(); i++){
        if(mark[g[now][i]] == -1){
            dfs(g[now][i], dis+1);
            zz = (zz * (dp[g[now][i]] + 1)) % MOD;
        }
    }
    dp[now] = zz;
}

void adfs(int now, int last){
    //cout << now << ' ' << last << endl;
    last %= MOD;
    mark[now] = 1;
    dpbig[now] = (last * dp[now]) % MOD;
    if(g[now].size() == 0)return;
    int pef[g[now].size()], suf[g[now].size()];
    int sw = 0;
    for(int i = 0; i < g[now].size(); i++){
        if(mark[g[now][i]] != -1 && sw == 0)pef[i+1] = 1;
        if(mark[g[now][i]] != -1 && sw)pef[i+1] = pef[i];
        if(mark[g[now][i]] == -1 && sw){
            pef[i+1] = (dp[g[now][i]]+1) * pef[i] % MOD;
        }
        if(mark[g[now][i]] == -1 && sw == 0){
            sw = 1;
            pef[i+1] = dp[g[now][i]]+1;
        }
    }
    sw = 0;
    for(int i = g[now].size()-1; i >= 0; i--){
        if(mark[g[now][i]] != -1 && sw == 0)suf[i] = 1;
        if(mark[g[now][i]] != -1 && sw)suf[i] = suf[i+1];
        if(mark[g[now][i]] == -1 && sw){
            suf[i] = (dp[g[now][i]]+1) * suf[i+1] % MOD;
        }
        if(mark[g[now][i]] == -1 && sw == 0){
            sw = 1;
            suf[i] = dp[g[now][i]]+1;
        }
    }
    suf[g[now].size()] = 1;
    pef[0] = 1;
    for(int i = 0; i < g[now].size(); i++){
        if(mark[g[now][i]] == -1){
            adfs(g[now][i], (last * (pef[i] * suf[i+1] % MOD) % MOD)+ 1);
        }
    }
}

signed main()
{
    cin >> n >> MOD;
    for(int i = 0; i < n-1; i++){
        mark[i] = -1;
        int x, y;
        cin >> x >> y;
        x--;y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    mark[n-1] = mark[n] = -1;
    dfs(0, 0);
    for(int i = 0; i < n; i++)mark[i] = -1;
    adfs(0, 1);
    for(int i = 0; i < n; i++){
        cout << dpbig[i] << endl;
    }
}


Measured memory_bytes: 22784
require "set"

c = nil
s = Set.new
v = true

gets.chomp.to_i.times do
  w = gets.chomp
  
  if s.member?(w) || (c && !w.start_with?(c))
    v = false
    break
  end
  
  c = w[-1]
  s << w
end

puts(v ? "Yes" : "No")


Measured memory_bytes: 2044
import java.util.Scanner;

public class Main {

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

        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        int result = X-A;
        result = result - ((result/B)*B);
        System.out.println(result);
    }
}

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

int main(){
  int n;
  cin >> n;
  
  if(n % 10 == 2 ||n % 10 == 4 ||n % 10 == 5 ||n % 10 == 7 ||n % 10 == 9) {
    cout << "hon" << endl;
  }
  else if(n % 10 == 0 || n % 10 ==1 || n % 10 ==6 ||n % 10 == 8) {
    cout << "pon" << endl;
  }
  else {
    cout << "bon" << endl;
  }
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define Cin cin>>a;

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
vector<ll>divisor(ll n) {
	vector<ll>value;
	for (ll i = 1; i < pow(n, 0.5) + 1; i++) {
		if (n % i == 0) {
			if (i > 1) {
				if (n % (i - 1) == n / i) {
					value.push_back(i - 1);
				}
			}
			if (n / i > 1) {
				if (n % (n / i - 1) == i) {
					value.push_back(n / i - 1);
				}
			}
		}
	}
	return value;
}
int main(void){
	ll n;
	cin >> n;
	vector<ll>a;
	a = divisor(n);
	
	ll ans = 0;
	rep(i, a.size()) {
		ans +=a[i];
		//cout << a[i] << endl;
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e9+5;
signed main(){
	int n;
	cin>>n;
	vector<int> v(n,0);
	for(int& x:v){
		cin >> x;
	}
	vector<int> dp(n,INF);
	dp[0]=0;
	for(int i=0;i<n;++i){
		for(int j:{i+1,i+2}){
			if(j<n){
				dp[j] = min(dp[j],dp[i]+abs(v[i]-v[j]));
			}
		}
	}
	cout << dp[n-1] ;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

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

  int t[1000000], x[1000000], y[1000000];
  t[0] = x[0] = y[0] = 0;
  for(int i=0; i<n; ++i) cin >> t[i+1] >> x[i+1] >> y[i+1];
  
  bool can = true;
  for(int i=0; i<n; ++i){
    int dt = t[i+1] - t[i];
    int dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]);
    if(dt < dist) can = false;
    if(dt%2 != dist%2) can =false;
  }

  if(can) cout << "Yes";
  else cout << "No";
    
}

Measured memory_bytes: 4736
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
string s, t;

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

  cin >> s >> t;

  sort(ALL(s));
  sort(ALL(t));
  reverse(ALL(t));


  cout << (s<t ? "Yes": "No") << "\n";
  return 0;
}

Measured memory_bytes: 256
n=int(input())
l=[]
for i in range(n):
    l.append(int(input()))
m=sorted(l)
m1=m[-1]
m2=m[-2]
c=l.count(m1)

for j in l:
    if j==m1:
        if c>1:
            print(m1)
        else:
            print(m2)
    else:
        print(m1)


Measured memory_bytes: 14112
// 2011/08/16 Tazoe

#include <iostream>
using namespace std;

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

	int C[200];
	for(int i=0; i<2*n; i++)
		C[i] = i+1;

	int m;
	cin >> m;

	for(int i=0; i<m; i++){
		int k;
		cin >> k;

		int T[200];

		if(k==0){
			for(int j=0; j<n; j++){
				T[2*j]   = C[j];
				T[2*j+1] = C[n+j];
			}
		}
		else{
			for(int j=k; j<2*n; j++)
				T[j-k]     = C[j];
			for(int j=0; j<k; j++)
				T[2*n-k+j] = C[j];
		}

		for(int j=0; j<2*n; j++)
			C[j] = T[j];
	}

	for(int i=0; i<2*n; i++)
		cout << C[i] << endl;

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();
        int ans = (n - h + 1) * (n - w + 1);
        System.out.println(ans);
    }
}


Measured memory_bytes: 23892
function main()
    d,t,s = reads(Int,Int,Int)
    f = d <= s*t
    println(f ? "Yes" : "No")
end

import Base.parse
import Base.StringVector

parse(::Type{String},  str::AbstractString) = str
isdelim(x::UInt8, xs::Set{UInt8}) = x in xs
const delimset = Set([0x0a, 0x20])

function myreaduntil(s::IO, delims::Set{UInt8})::Vector{UInt8}
    out = StringVector(0)
    c::UInt8 = 0x00
    while !eof(s)
        c = read(s, UInt8)
        !isdelim(c, delims) && break
    end
    push!(out, c)
    eof(s) && return out
    while !eof(s)
        c = read(s, UInt8)
        isdelim(c, delims) && break
        push!(out, c)
    end
    return out
end
function readword(io::IO = stdin, delims = delimset)::String
    word = myreaduntil(io, delims)
    i = length(word)
    if i == 0 || word[i] != 0x0a
        return String(word)
    elseif i < 2 || word[i-1] != 0x0d
        return String(resize!(word,i-1))
    else
        return String(resize!(word,i-2))
    end
end

pread(ty) = parse(ty, readword())

reads(tys...)::Tuple{tys...} = Tuple{tys...}(pread(ty) for ty in tys)

function readvec(tys::Tuple , len::Signed)::Tuple{map(x -> Vector{x},tys)...}
    rv = Tuple{map(x -> Vector{x},tys)...}(Vector{ty}(undef,len) for ty in tys)
    for i in 1:len
        for j in 1:length(tys)
            @inbounds rv[j][i] = pread(tys[j])
        end
    end
    rv
end

readvec(ty::Type, len::Signed)::Vector{ty} = @inbounds ty[pread(ty) for i in 1:len]

function readmat(ty::Type, s...)::Matrix{ty}
    v = Matrix{ty}(undef, s...)
    @inbounds for i in 1:s[1]
        v[i,:] = readvec(ty, s[2])
    end
    v
end

main()


Measured memory_bytes: 190808
#include<cstdio>
#include<cstring>

const int N = 1e5 + 10;

char s[N];
int n, x, y;

bool ok(){
    for(int i=2; i<n; i++){
		if(s[i]==s[i-1] || s[i]==s[i-2]){
			x = i-2;
			y = i;
			return 1;
		}
    }
    if(n == 2 && s[0]==s[1]){
		x = 0;
		y = 1;
		return 1;
    }
    return 0;
}

int main(){
	scanf("%s", s);
	n = strlen(s);
	if(ok()){
		printf("%d %d\n", x+1, y+1);
	} else {
		puts("-1 -1");
	}
	return 0;
}


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

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";


#define     SPEED     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	ll          long long int
#define 	pb          push_back
#define 	pii         pair<int,int>
#define 	vi          vector<int>
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(i=0;i<n;i++)
#define 	repe(i,a,b) for(i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search
#define 	mp          make_pair

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2);
	if(b%2==0)
		return((c%hell)*(c%hell))%hell;
	return ((((c%hell)*(c%hell))%hell)*(a%hell))%hell;
}

/********************************************************/
ll h[100005],dp[100005],n;

ll f(ll x)
{
	if(x>n-1)
		return hell;
	if(x==n-1)
		return 0;
	if(dp[x]==-1)
	{
		dp[x]=f(x+1)+abs(h[x+1]-h[x]);
		if(x<n-2)
			dp[x]=min(dp[x],f(x+2)+abs(h[x+2]-h[x]));
	}
	// debug2(x,dp[x]);
	return dp[x];
}

int main()
{
	SPEED;
	ll k,t,c=0,i,j,m,cs=0;
	t=1;

	//cin>>t;
	string s;
	while(t--)
	{
		cin>>n;
		// n=s.length();
		// ll a[n];
		rep(i,n)
		{
			cin>>h[i];
			dp[i]=-1;
		}
		
		cout<<f(0);
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

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

long long  dp[110][25];
int s[110];

int main(){
    int n;
    cin >> n;
    for(int i=1; i <= n; i++) cin >> s[i];

    for(int i=0; i < 110; i++)for(int j=0; j < 25; j++) dp[i][j] = 0;

    dp[1][s[1]] = 1;
    for(int i=2; i < n; i++){
        for(int j=0; j <= 20; j++){
            if(j+s[i] <= 20)
                dp[i][j+s[i]] += dp[i-1][j];
            if(0 <= j-s[i])
                dp[i][j-s[i]] += dp[i-1][j];
        }
    }
    cout << dp[n-1][s[n]] << endl;
}

Measured memory_bytes: 1176
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	int K, X; scanf("%d%d", &K, &X);
	for (int i = X - K + 1; i <= X + K - 1;i++){
		if (-1000000 <= i&&i <= 1000000){
			printf("%d\n", i);
		}
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		ArrayList<Integer> height = new ArrayList<Integer>();

		for (int i = 0; i < 10; i++) {
			height.add( sc.nextInt() );
		}

		top_three(height);
	}

	private static void top_three(ArrayList<Integer> height) {
		Collections.sort(height, Comparator.reverseOrder());

		for (int i = 0; i < 3; i++) {
			System.out.println( height.get(i) );
		}
	}
}


Measured memory_bytes: 26280
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define mset(x,y) memset(x,y,sizeof(x))
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define rng(i,a,b) for(int i=int(a);i<=int(b);i++)
#define gnr(i,b,a) for(int i=int(b);i>=int(a);i--)
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
#ifdef LOCAL
#define dmp(...) _dmp(#__VA_ARGS__, __VA_ARGS__)
#else
#define dmp(...) (__VA_ARGS__)
#endif
template<class T> using vt=vector<T>;
template<class T> using vvt=vt<vt<T>>;
template<class TA,class TB> void chmax(TA&a,TB b){if(a<b)a=b;}
template<class TA,class TB> void chmin(TA&a,TB b){if(b<a)a=b;}
template<class TA,class TB>
ostream& operator<<(ostream& os,const pair<TA,TB>& p){
	return os<<"{"<<p.fi<<","<<p.se<<"}";
}
template<class T> ostream& operator<<(ostream& os,const vt<T>& v){
	os<<"{";for(auto& e:v)os<<e<<",";return os<<"}";
}
template<class TH> void _dmp(const char *sdbg, TH h){cout<<sdbg<<"="<<h<<endl;}
template<class TH, class... TA> void _dmp(const char *sdbg, TH h, TA...a){
while(*sdbg!=',')cout<<*sdbg++;cout<<"="<<h<<","; _dmp(sdbg+1, a...);
}
template<class T> void make_unique(vt<T>& v) {
	sort(all(v));v.erase(unique(all(v)),v.end());
}
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
int ri(){int x;cin>>x;return x;}
ll rll(){ll x;cin>>x;return x;}
vi rvi(int n){vi v;rep(i,n)v.pb(ri());return v;}
ll n, m;
void MAIN() {
	cin>>n>>m;
	ll ans=n*(n-1)/2+m*(m-1)/2;
	cout<<ans;
}
int main() {
	ios::sync_with_stdio(false);cin.tie(0);
	int T=1;
	//cin>>T;
	for(int tt=1;tt<=T;tt++) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int	i,j,flg;
	double m5,m10;
	double m5t[8]={35.5,37.5,40.0,43.0,50.0,55.0,70.0};
	double m10t[8]={71.0,77.0,83.0,89.0,105.0,116.0,148.0};
	char ran[8][8]={"AAA","AA","A","B","C","D","E"};
	while(scanf("%lf %lf",&m5,&m10)!=EOF){
		flg=0;
		for(i=0;i<=7;i++){
			if(m5<m5t[i] && m10<m10t[i]){
				printf("%s\n",ran[i]);
				flg=1;
				break;
			}
		}
		if(flg==0) printf("NA\n");
	}
	return 0;
}

Measured memory_bytes: 1036
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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

struct wood{
    double L;ll N;double M;
    bool operator<(const wood& a) const{
        return L < a.L;
    }
};

int main(){
    ll N,K;
    cin>>N>>K;
    v A(N);
    rep(i,0,N)cin>>A[i];
    ll l = 0;ll r = 1000000000;
    
    while(l!=r){
        ll sum = 0;
        ll now = (l+r)/2;
        if(now==0){
            cout<<1;
            return 0;
        }
        rep(i,0,N){
            sum += ((A[i]-1)/now);
        }
        if(sum > K){
            l = now+1;
        }
        else{
            r = now;
        }
    }
    cout<<r;

    return 0;
}

Measured memory_bytes: 4836
import java.io.*;

class Main {
        public static void main(String[] args) throws IOException {
                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                int n = Integer.parseInt(br.readLine());
                
                if(n < 1000)
                        System.out.println("ABC");
                else
                        System.out.println("ABD");
        }
}


Measured memory_bytes: 19924
from string import lowercase
s = raw_input().strip()
if len(s) < 26:
    for c in lowercase:
        if c not in s:
            print s + c
            break
else:
    c = ' '
    for i in xrange(25, -1, -1):
        if s[i] < c:
            s = s[:i+1]
            for c in lowercase:
                if c > s[-1] and c not in s:
                    print s[:-1] + c
                    quit()
        c = s[i]
    print -1


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

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

using namespace std;

int main(){
	int n,m; scanf("%d%d",&n,&m);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	int sum=accumulate(a.begin(),a.end(),0);
	int cnt=0;
	rep(i,n) if(a[i]*4*m>=sum) cnt++;
	puts(cnt>=m?"Yes":"No");

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    // ?¨??????\???????????????????????????????????????
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x;
    int i=1;
    while(true){
      x = i;
      if(x%3==0){
        System.out.printf(" %d",i);
      }else{
        while(true){
          if(x%10==3){
            System.out.printf(" %d",i);
            break;
          }
          x = x / 10;
          if(x==0)break;
        }
      }
      if(++i<=n)continue;
      else break;
    }
    System.out.printf("\n");
  }
}

Measured memory_bytes: 37000
package main

import "fmt"




func main() {
	var x int
	fmt.Scan(&x)

	ans := 0
	if x >= 400 && x <= 599 {
		ans = 8
	}
	if x >= 600 && x <= 799 {
		ans = 7
	}
	if x >= 800 && x <= 999 {
		ans = 6
	}
	if x >= 1000 && x <= 1199 {
		ans = 5
	}
	if x >= 1200 && x <= 1399 {
		ans = 4
	}
	if x >= 1400 && x <= 1599 {
		ans = 3
	}
	if x >= 1600 && x <= 1799 {
		ans = 2
	}
	if x >= 1800 && x <= 9999 {
		ans = 1
	}


	fmt.Println(ans)
}



Measured memory_bytes: 1772
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>

using namespace std;

//#define DEB
#ifdef DEB
ifstream ifs("input.txt");
ofstream ofs("output.txt");
#define cin ifs
#define cout ofs
#endif

const int MAX_PRIME = 1300000;

int prime[MAX_PRIME+1];
bool isPrime[MAX_PRIME+1];
int p;

void erats(){
	// primeツδ環スツトツづーツ渉可甘コツ可サ
	fill(isPrime,isPrime+MAX_PRIME,true);
	p = 0;
	isPrime[0] = isPrime[1] = false;

	for(int i = 2; i <= MAX_PRIME; i++){
		if(isPrime[i]){
			prime[p++] = i;
		}
		else
			continue;
		// ツづ督づゥツつ「ツづ可つゥツつッツづゥ
		for(int j = 2*i; j <= MAX_PRIME; j+=i){
			isPrime[j] = false;
		}
	}
}

int main(){

	erats();
	int n;
	while(cin>>n&&n!=0){
		if(isPrime[n])cout<<0<<endl;
		else{
			int idx=(upper_bound(prime,prime+p,n))-prime;
			//cout<<idx<<endl;
			int len=abs(prime[idx-1]-prime[idx]);
			cout<<len<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))


n=input()
if n[-1]=="3":
    print("bon")
elif n[-1] in list("0168"):
    print("pon")
else:
    print("hon")

Measured memory_bytes: 9056
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;

struct puntos{
    ll a,b,c;
};

ll solve(vector<puntos> v,ll N){
    ll dp[N+1][3];
    dp[0][0] = v[0].a; dp[0][1] = v[0].b; dp[0][2] = v[0].c;
    dp[1][0] = v[1].a; dp[1][1] = v[1].b; dp[1][2] = v[1].c;

    rep(i,2,N+1){
        dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + v[i].a;
        dp[i][1] = max(dp[i-1][2],dp[i-1][0]) + v[i].b;
        dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + v[i].c;
    }

    return max({dp[N][0],dp[N][1],dp[N][2]});
}

int main(){
    ios;
    ll N;
    cin >> N;
    vector <puntos> v(N+1);
    v[0].a = 0; v[0].b = 0; v[0].c = 0;
    rep(i,1,N+1) cin >> v[i].a >> v[i].b >> v[i].c;

    cout << solve(v,N) << endl;
    return 0;
}


Measured memory_bytes: 7296
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	n := readInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = readInt()
	}

	x := 1
	c := 0
	for i := 0; i < n; i++ {
		if a[i] == x {
			x++
		} else {
			c++
		}
	}

	if c == n {
		fmt.Println(-1)
	} else {
		fmt.Println(c)
	}
}

var stdin *bufio.Scanner

func read() string {
	if stdin == nil {
		stdin = bufio.NewScanner(os.Stdin)
		stdin.Split(bufio.ScanWords)
		stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	}
	stdin.Scan()
	return stdin.Text()
}

func readInt() int {
	n, _ := strconv.Atoi(read())
	return n
}

func readFloat64() float64 {
	n, _ := strconv.ParseFloat(read(), 64)
	return n
}


Measured memory_bytes: 3968