akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

int f(ll a, ll b) {
	ll tmp = max(a, b);
	int ret = 0;
	while (tmp > 0) {
		tmp /= 10;
		ret++;
	}

	return ret;
}

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

	ll n;
	cin >> n;

	int res = INT_MAX;
	for (ll i = 1; i * i <= n; i++) {
		ll a, b;
		if (n % i == 0) {
			a = i;
			b = n / a;

			res = min(res, f(a, b));
		}
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

#include <bits/stdc++.h>


using namespace std;

#define INPUT_INT(valName) int valName; cin >> valName
#define INPUT_LLINT(valName) long long int valName; cin >> valName;
#define INPUT_STR(valName) string valName; cin >> valName;
#define INPUT_LINE(valName) string valName; getline(cin,s);
#define INPUT_VECTOR_INT(valName, N) vector<int> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }
#define INPUT_VECTOR_DOUBLE(valName, N) vector<double> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }

#define OUTPUT(A) cout << (A) << endl;
#define OUTPUT2(A, B) cout << (A) << " " << (B) << endl;
#define OUTPUT3(A, B, C) cout << (A) << " " << (B) << " " << (C) << endl;

#define REP(valName, N) for(int valName = 0; valName < N; ++valName)

vector<string> split(const string& str, char delimiter) {
	vector<string> ret;
	string tmp = "";
	for (auto c : str) {
		if (c != delimiter) {
			tmp.push_back(c);
		} else {
			ret.push_back(tmp);
			tmp = "";
		}
	}
	ret.push_back(tmp);
	return ret;
}

template <typename T> void sortAsc(vector<T>& v) { sort(v.begin(), v.end(), less<T>()); }
template <typename T> void sortDesc(vector<T>& v) { sort(v.begin(), v.end(), greater<T>()); }

template <typename T> void insert(vector<T>& dest, const vector<T>& src) { copy(src.begin(), src.end(), back_inserter(dest)); }

template <long long int MOD> long long int mod_inv(long long int a) {
	long long b = MOD, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;
	return u;
}

template <long long int MOD> long long int mod_add(long long int a, long long int b) {
	return (a + b) % MOD;
}

template <long long int MOD> long long int mod_sum(long long int a, long long int b) {
	return (a - b) % MOD;
}

template <long long int MOD> long long int mod_mul(long long int a, long long int b) {
	return (a % MOD) * (b % MOD) % MOD;
}

template <long long int MOD> long long int mod_mul(long long int a, long long int b, long long int c) {
	return mod_mul<MOD>(a, mod_mul<MOD>(b, c));
}

template <long long int MOD> long long int mod_div(long long int a, long long int b) {
	return (a % MOD) * mod_inv<MOD>(b) % MOD;
}

int sign(long long int a) {
	return a >= 0 ? 1 : -1;
}


//------------------------------------------------------------------------------------------------------------------------------



int main() {

	// TODO: streamやめる

	cin.tie(0); ios::sync_with_stdio(false);

	INPUT_LLINT(K);
	
	int arr[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };


	OUTPUT(arr[K-1]);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int x[8]={0};
int y[8]={0};
int N;
int main () {
  double answer=0;
  int counter,counter2,a,b;
  int aaa=1;
  cin >> N ;
  int p[8]={0};
  counter=0;counter2=0;
  for (int j = 0; j < N; j++) {
    cin>>x[j];}
  for (int j = 0; j < N; j++) {
    cin>>y[j];}
    for (int i = 0; i < N ; i++) {
    p[i]=i+1;}
   do{aaa++;counter=0;counter2=0;
     for (int j = 0; j < N; j++) {
     if(p[j]==x[j])
     counter++;
     if(p[j]==y[j])
     counter2++;
     }
     if(counter==N){
     a=aaa;}
     if(counter2==N){
     b=aaa;} 
   }while (next_permutation(p,p+N));
    cout << abs(a-b)<< endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>

using namespace std;




int main(){
  int N;
  int A[2][100];
  cin>>N;
  for(int i=0;i<N;i++)cin>>A[0][i];
  for(int i=0;i<N;i++)cin>>A[1][i];
  int max=-1;
  for(int i=0;i<N;i++){
    int sum=0;
    for(int j=0;j<=i;j++){
      sum+=A[0][j];
    }
    for(int j=i;j<N;j++){
      sum+=A[1][j];
    }
    if(sum>max)max=sum;
  }

  cout<<max<<endl;




  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		C_WhenIHitMyPocket solver = new C_WhenIHitMyPocket();
		solver.solve(1, in, out);
		out.close();
	}

	static class C_WhenIHitMyPocket {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			long k = in.nextLong();
			long a = in.nextLong();
			long b = in.nextLong();
			if (k < a - 1) {
				out.println(k + 1);
				return;
			}
			k -= a - 1;
			long ans = a;
			if (k % 2 == 1) {
				++ans;
				--k;
			}
			if (b - a > 2) {
				ans += (b - a) * (k / 2);
			} else {
				ans += k;
			}
			out.println(ans);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

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

	}
}



Measured memory_bytes: 21460
import java.util.Scanner;

class Main {

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

  private static Scanner sc = new Scanner(System.in);

  private void run() {
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int D = sc.nextInt();

    int ans = Math.min(B, D) - Math.max(A, C);
    System.out.println(Math.max(ans, 0));
  }
}


Measured memory_bytes: 35892
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<tuple>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int n;
	cin>>n;
	priority_queue<int> q;
	int a;
	rep(i, n){
		cin>>a;
		q.push(a);
	}
	while(q.size()>1){
		a=q.top();
		q.pop();
		if(q.top()==a){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}


Measured memory_bytes: 1400
x, y = map(int, input().split())
if x == 0:
    if y == 100:
        print(101)
    else:
        print(y)
elif x == 1:
    if y == 100:
        print(10100)
    else:
        print(y*100)
else:
    if y == 100:
        print(1010000)
    else:
        print(y*10000)


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

using ll = long long;
using ld = long double;
const ld PI = 3.14159265358979323846264338327950L;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int tc = 1;
    // cin >> tc;
    while(tc--) {
        int n, m;
        cin >> n >> m;
        vector<vector<int>> adj(n);
        vector<int> res(n, -1);
        
        while(m--) {
            int u, v;
            cin >> u >> v;
            adj[u-1].push_back(v-1);
            adj[v-1].push_back(u-1);
        }
        
        // for(int i=0; i<n; i++) {
        //     cout << i +1 << ": ";
        //     for(int nei : adj[i]) cout << nei+1 << " ";
        //     cout << endl;
        // }
        
        queue<int> q;
        q.push(0);
        while(q.size()) {
            int node = q.front();
            q.pop();
            for(int nei : adj[node]) {
                if(res[nei] >= 0 || nei == 0) {
                    continue;
                }
                // cout << nei << " " << node << endl;
                res[nei] = node;
                q.push(nei);
            }
        }
        
        bool poss = true;
        for(int i=1; i<n; i++) {
            if(res[i] == -1) poss = false;
        }
        
        if(!poss) {
            cout << "No" << endl;
            continue;
        }
        cout << "Yes" << endl;
        for(int i=1; i<n; i++) {
            cout << res[i] + 1 << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 10248
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int n, a[3004];
long long dp[3004][3004];

int main() {
	cin>>n;
	for(int i = 1;i<=n;i++)
		cin>>a[i];
	for(int i = 1;i<=n;i++)
		dp[i][i] = a[i];
	for(int i = n-1;i>=0;i--)
		for(int j = i+1;j<=n;j++){
			dp[i][j] = max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
		}
	cout<<dp[1][n];
	return 0;
}

Measured memory_bytes: 70016
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int main() {
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
a1,a2 = [],[]
for i in range(n):
    a1.append(i+a[i])
    a2.append(i-a[i])
a1,a2 = Counter(a1),Counter(a2)
rng = max(a2)
ans = 0
for i in range(1,rng+1):
    if i in a1 and i in a2:
        ans += a1[i]*a2[i]
print(ans)

Measured memory_bytes: 63612
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

s = input()
t = ""

i = 0
while i < len(s):
	if s[i:i+2] == "BC":
		t += "D"
		i += 2
	else:
		t += s[i]
		i += 1

D_cnt = []
cnt = 0
for x in t[::-1]:
	if x == "D":
		cnt += 1
		D_cnt.append(cnt)
	elif x == "A":
		D_cnt.append(cnt)
	else:
		cnt = 0
		D_cnt.append(cnt)

D_acc = D_cnt[::-1]

ans = 0
for i in range(len(t)):
	if t[i] == "A":
		ans += D_acc[i]

print(ans)



Measured memory_bytes: 14688
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;
typedef int  ll;
typedef long double ld;
typedef pair<ll,ll> pp;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> super_set;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> multi_set;
#define x1 dfds
#define y1 dsfdsfe
#define pb push_back
#define forn(i,n) for(ll i = 1;i<=n;++i)
#define fi first
#define sc second
#define endl '\n'
#define po(x) (1ll<<x)
const ll DIM = 1e5+7;
const ll INF = 1e9;
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());

int main(){

    ll n,m;
    cin>>n>>m;
    cout<<n*(n-1)/2+(m-1)*m/2<<endl;
    return 0;
}



Measured memory_bytes: 256
import Control.Applicative

type MinMax = (Int, Int)

updateMax :: Int -> MinMax -> MinMax
updateMax val (min, max)
  | max == 0  = (min, val)
  | max < val = (min, val)
  | otherwise = (min, max)

updateMin :: Int -> MinMax -> MinMax
updateMin val (min, max)
  | val < min = (val, max)
  | otherwise = (min, max)

cmp :: MinMax -> MinMax -> MinMax
cmp p1 p2
  | d p1 > d p2 = p1
  | d p1 < d p2 = p2
  | otherwise   = cmpMin p1 p2
    where
        d (min, max) = max - min

cmpMin :: MinMax -> MinMax -> MinMax
cmpMin p1@(f1, _) p2@(f2, _)
  | f1 < f1   = p1
  | otherwise = p2

main :: IO ()
main = do
    n  <- read <$> getLine :: IO Int
    r0 <- read <$> getLine :: IO Int
    r1 <- read <$> getLine :: IO Int
    (min, max) <- loop (n - 2) (r0, r1) (r1, 0)
    print $ max - min
    where
        loop :: Int -> MinMax -> MinMax -> IO MinMax
        loop 0 s _ = return s
        loop n s p = do
            v <- read <$> getLine :: IO Int
            let s' = updateMax v s
                p' = updateMax v p
            if s' == cmp s' p'
               then loop (n - 1) s' (updateMin v p)
               else loop (n - 1) p' (v, 0)



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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var Q = Console.ReadLine().ToInt();
            var l = new LinkedList<string>();
            foreach (var item in S)
            {
                l.AddLast(item.ToString());
            }
            var isReverse = false;
            for (int i = 0; i < Q; i++)
            {
                var a = Console.ReadLine().Split(' ');
                var T = a[0].ToInt();
                if (T == 1)
                {
                    isReverse = !isReverse;
                }
                else
                {
                    var F = a[1].ToInt();
                    var C = a[2];
                    if (F == 1)
                    {
                        if (isReverse)
                        {
                            l.AddLast(C);
                        }
                        else
                        {
                            l.AddFirst(C);
                        }
                    }
                    else
                    {
                        if (isReverse)
                        {
                            l.AddFirst(C);
                        }
                        else
                        {
                            l.AddLast(C);
                        }
                    }
                }
            }
            var sb = new StringBuilder();
            if (isReverse)
            {
                foreach (var item in l.Reverse())
                {
                    sb.Append(item);
                }
            }
            else
            {
                foreach (var item in l)
                {
                    sb.Append(item);
                }
            }
            Console.WriteLine(sb.ToString());
        }
    }

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

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


Measured memory_bytes: 39328
A,B,C = map(int,input().split())
ax = A // 2
ay = A - ax
da = (ay-ax)*B*C

bx = B // 2
by = B - bx
db = (by-bx)*A*C

cx = C // 2
cy = C - cx
dc = (cy-cx)*A*B

print(min(da,db,dc))


Measured memory_bytes: 3060
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 99999999999999999;

long long int N,M,Q,A[200055],sum=0,res=0;

int main()
{
    cout << fixed << setprecision(18);
	cin>>N;
	cout<<(N+1)/2<<endl;
}



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

int main()
{
	int q1, b, c1, c2, q2, x, y;

	cin >> q1;

	while (q1) {
		cin >> b >> c1 >> c2 >> q2;

		x = q2;

		while (c1 * x + c2 * (q1 - x) > b || c1 * x > b)
			x--;

		if (x <= 0)
			cout << "NA" << endl;
		else {
			y = q1 - x;

			while (c1 * x + c2 * y < b)
				y++;

			if (c1 * x + c2 * y > b)
				y--;

			cout << x << " " << y << endl;
		}

		cin >> q1;
	}

	return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main()
{
    int i;

    int sum = 0;
    char W[11], T[1001];

    scanf("%s", W);
    for( i = 0; W[i]; ++i ) W[i] = tolower(W[i]);
    while( 1 ){
        scanf("%s", T);
        if( strcmp("END_OF_TEXT", T) == 0 ) break;
        for( i = 0; T[i]; ++i ) T[i] = tolower(T[i]);
        if( strcmp(W, T) == 0 ) ++sum;
    }

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

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

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

void solve() {
  int h, w;
  cin >> h >> w;
  vstr board(h);
  rep(i, h) cin >> board[i];

  queue<tuple<int, int, int>> q;
  vector<vi32> dist(h, vi32(w, 1e9));
  rep(i, h) rep(j, w) {
    if (board[i][j] == '#') {
      q.emplace(i, j, 0);
    }
  }
  int ans = 0;
  while (q.size()) {
    int x, y, c;
    tie(x, y, c) = q.front(); q.pop();
    if (dist[x][y] != 1e9) continue;
    dist[x][y] = c;
    amax(ans, c);
    rep(i, 4) {
      int fx = x + dx[i];
      int fy = y + dy[i];
      if (fx < 0 || fx >= h || fy < 0 || fy >= w) continue;
      q.emplace(fx, fy, c + 1);
    }
  }
  cout << ans << endl;
}


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

int gcd(int a,int b){
  int r=max(a,b)%min(a,b);
  if(r==0){
    return min(a,b);
  }
  gcd(min(a,b),r);
}
int main(){
  int64_t A,B,C,D,CD;
  cin >> A >> B >> C >> D;
  int64_t all,cn,dn,cdn,ans;
  bool cf=false;
  bool df=false;
  bool cdf=false;
  if(A%C==0){
    cf=true;
  }
  if(A%D==0){
    df=true;
  }
  if(cf){
    cn=B/C-A/C+1;
  }else{
    cn=B/C-A/C;
  }
  if(df){
    dn=B/D-A/D+1;
  }else{
    dn=B/D-A/D;
  }
  CD=(C*D)/gcd(C,D);
  if(A%CD==0){
    cdf=true;
  }
  if(cdf){
    cdn=B/CD-A/CD+1;
  }else{
    cdn=B/CD-A/CD;
  }
  all=B-(A-1);
  ans=all-cn-dn+cdn;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
long long v[200005],msum[200005];
int main() {
    int n;
    long long x;
    scanf("%d%lld",&n,&x);
    for(int i=1;i<=n;i++){
        scanf("%lld",&v[i]);
        msum[i]+=v[i]+msum[i-1];
    }
    long long ans=100000000000000000;
    for(int k=1;k<=n;k++){
        long long ff=0;
        for(int j=1,r=n,l=0;r>0&&ff+k*x<ans;r=l-1,j++){
            l=(r-k+1)>1?(r-k+1):1;
            ff+=(j==1?5:(j*2+1))*(msum[r]-msum[l-1]);
        }
        ans=min(ff+k*x,ans);
    }
    printf("%lld\n",ans+n*x);
    return 0;
}


Measured memory_bytes: 3328
L=input().split( )

n=int(L[0])
m=int(L[1])
l=int(L[2])

A=[[0 for i in range(m)] for j in range(n)]
B=[[0 for i in range(l)] for j in range(m)]
C=[[0 for i in range(l)] for j in range(n)]
i=0
j=0

while i<n:
    StrCollum = input().split( )
    for k in range(m):
        A[i][k] = int(StrCollum[k])
    i+=1

while j<m:
    StrCollum = input().split( )
    for k in range(l):
        B[j][k] = int(StrCollum[k])
    j+=1

for a in range(n):
    for b in range(l):
        sum=0
        for k in range(m):
            sum = sum + A[a][k]*B[k][b]
            C[a][b]=sum
        #C[a][b]のインデントの位置がおかしかった。ここだとb=l-1の時しかC[][]が更新されない。
for i in range(n):
    for j in range(l):
        if j!=l-1:
            print(C[i][j],end=' ')
        else:
            print(C[i][j])



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

#define NMAX 1000

using namespace std;

//ifstream fin("f.in");
//ofstream fout("f.out");

int biscuits, moment, totalTime;

int main()
{
    cin >> moment >> biscuits >> totalTime;
    cout << biscuits * (totalTime / moment) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type &a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	vi a(n);
	REP(i,n) a[i]=i+1;
	
	map<int,llong> mp;
	for(int i=1;i<n;++i){
		int j=2;
		while(a[i]>=2){
			//cout<<j<<endl;//!!!
			if(a[i]%j){
				j++;
			}else{
				mp[j]++;
				a[i]/=j;
			}
		}
	}
	
	llong ans=1;
	for(auto elem:mp){
		ans*=elem.second+1;
		ans%=MOD;
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main(void){
	int h,w;
	int i,j;
	char s[100][101];
	
	scanf("%d %d",&h,&w);
	for(i=0;i<h;i++)	scanf("%s",s[i]);
	for(i=0;i<w+2;i++)	printf("#");
	printf("\n");
	for(i=0;i<h;i++){
		for(j=0;j<w+2;j++){
			if(j==0||j==w+1)	printf("#");
			else				printf("%c",s[i][j-1]);
		}
		printf("\n");
	}
	for(i=0;i<w+2;i++)	printf("#");
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 要素の入力、格納
		int H = sc.nextInt();
		int W = sc.nextInt();
		int D = sc.nextInt();
		int masu[][] = new int[H * W + 1][2];
		int tmp = 0;
		for (int i = 1; i < H + 1; i++) {
			for (int j = 1; j < W + 1; j++) {
				tmp = sc.nextInt();
				masu[tmp][0] = i;
				masu[tmp][1] = j;
			}
		}
		int Q = sc.nextInt();
		int L[] = new int[Q];
		int R[] = new int[Q];
		for (int i = 0; i < Q; i++) {
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
		}
		int ans = 0;

		int memo[] = new int[H * W + 1];
		for (int i = 1; i < H * W + 1; i++) {
			if (i + D <= H * W) {
				memo[i] = Math.abs(masu[i][0] - masu[i + D][0]) + Math.abs(masu[i][1] - masu[i + D][1]);
			}
		}
		int memo2[] = new int[H * W + 1];
		for (int i = 1; i < H * W + 1; i++) {
			if (i > D) {
				memo2[i] = memo2[i - D] + memo[i - D];
			}
		}

		// 出力
		for (int i = 0; i < Q; i++) {
			ans = 0;
			ans += memo2[R[i]] - memo2[L[i]];
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 101320
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    int D;
    int N;
    
    cin >> D;
    cin >> N;

    int bet = 1;
    for( int di = 0 ; di < D ; di++ ){
        bet = bet * 100;
    }

    if(N<100)    cout << bet * N << endl;
    else    cout << bet * (N + 1) << endl;
    

}

Measured memory_bytes: 256
/// IN THE NAME OF METAL
#include <bits/stdc++.h>

using namespace std;

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

#define sz(x)                       (ll) x.size()
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second

ll Pow(ll a, ll b, ll md, ll ans = 1) {
    for (; b; b >>= 1, a = a * a % md)
        if (b & 1)
            ans = ans * a % md;
    return ans % md;
}

const ll MAXN = 1e6 + 10;
const ll INF = 818;
const ll MOD = 1e9 + 7;
ll ind[MAXN], fen[MAXN], A[MAXN], ps[MAXN], ans = 0, n, P;
vector<ll> compress;

void update(ll ind, ll val) {
    for (; ind < MAXN; ind += ind & -ind) fen[ind] += val;
}

ll get(ll ind, ll res = 0) {
    for (; ind; ind -= ind & -ind) res += fen[ind];
    return res;
}

int main() {
    scanf("%lld%lld", &n, &P);
    for (ll i = 1; i <= n; i++) {
        scanf("%lld", &A[i]);
    }
    for (ll i = 1; i <= n; i++) {
        A[i] -= P;
    }
    partial_sum(A, A + MAXN, ps);
    for (ll i = 0; i <= n; i++) {
        compress.push_back(ps[i]);
    }
    sort(all(compress));
    compress.resize(unique(all(compress)) - compress.begin());
    for (ll i = 0; i <= n; i++) {
        ind[i] = lower_bound(all(compress), ps[i]) - compress.begin() + 1;
        ans += get(ind[i]);
        update(ind[i], 1);
    }
    printf("%lld", ans);
    return 0;
}



Measured memory_bytes: 22384
#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>

using namespace std;

int main(){
  int n;
  vector<int> nums;

  cin >> n;
  for(int i=0; i<n*3; i++){
    int temp;
    cin >> temp;
    nums.push_back(temp);
  }

  sort(nums.begin(), nums.end(), greater<int>());

  long ans = 0;
  for(int i=1; i<nums.size() - nums.size()/3; i++){
    if(i%2 == 1){
      ans += nums.at(i);
    }
  }

  cout << ans;
}


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

using namespace std;

int n, a[101];

void init()
{
	scanf("%d", &n);
	int N = n * 2;
	for (int i = 0; i < N; ++i)
		{
			scanf("%d", &a[i]);
		}
	sort(a , a + N);
	long long mn = 0;
	for (int i = 0; i < N; i=i+2)
	{
		mn += a[i];
		//printf("%d\n", mn);
	}
	printf("%lld\n", mn);

}

int main()
{

	//#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	//#endif

	init();

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void swap(int*a,int*b){
	int temp = *a;
	*a = *b;
	*b = temp;
}

int bubbleSort(int A[],int N){
	int i,j;
	int sw=0;
	unsigned short flag=1;
	for(i=0;flag;i++){
		flag=0;
		for(j=N-1;j>= i+1;j--){
			if(A[j]<A[j-1]){
				swap(&A[j],&A[j-1]);
				flag=1;
				sw++;
			}
		}
	}
	return sw;
}

int main (){
	int i,A[100],N,sw;
	scanf ("%d",&N);
	for(i=0;i<N;i++)scanf("%d",&A[i]);
	sw = bubbleSort(A,N);
	
	for(i=0;i<N;i++){
		if (i)printf(" ");
		printf("%d",A[i]);
	}
	printf("\n%d\n",sw);
	return 0;
}



Measured memory_bytes: 2000
#include<stdio.h>

int main(){
  int n;
  int flag=0;
  scanf("%d",&n);
  
  int h[n+1];
  for(int i=1;i<=n;i++){
    scanf("%d",&h[i]);
  }
  
  for(int i=n;i>=2;i--){
    if(h[i]<h[i-1]){
      h[i-1]=h[i-1]-1;
    }
    if(h[i]<h[i-1]){
      flag=1;
      break;
    }
  }
  
  if(flag==0){
    printf("Yes");
  }else{
    printf("No");
  }
  
  return 0;
}

Measured memory_bytes: 512
program multiple_of_2019
  implicit none
  character(200000) :: s
  integer :: n, d, k, i, j, l = 0
  integer(8) :: dp(0:1,0:2018) = 0, a = 0
  read(*,*) s
  n = len_trim(s)
  do i = 1, n
    l = 1-l
    dp(l,:) = 0
    d = ichar(s(i:i))-48
    do j = 0, 2018
      k = mod(10*j+d,2019)
      dp(l,k) = dp(l,k)+dp(1-l,j)
    end do
    a = a+dp(1-l,0)
    dp(l,d) = dp(l,d)+1
  end do
  write(*,'(i0)') a+dp(l,0)
end program multiple_of_2019

Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

const int mod = 1e9+7;

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<int>> c(h, vector<int>(w, 0));
    int black_raw = 0;
    rep (i, h) {
        string s;
        cin >> s;
        rep (j, w) {
            if (s[j] == '#') {
                c[i][j] = 1;
                black_raw++;
            }
        }
    }
    int ans = 0;
    rep (i, (1<<h)) {
        rep (j, (1<<w)) {
            int ctr = 0;
            rep (y, h) {
                rep (x, w) {
                    if ((1<<y & i) || (1<<x & j)) {
                        ctr += c[y][x];
                    }
                }
            }
            int res = black_raw - ctr;
            if (res == k) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 3640
a,b,c,x = 4.times.map{gets.to_i}

ans = 0
0.upto(a) do |ai|
  0.upto(b) do |bi|
    0.upto(c) do |ci|
      ans += 1 if ai*500 + bi*100 + ci*50 == x
    end
  end
end

puts ans

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

int main(){
	
	while(1){
		string str, left, right;
		int m, h;

		cin>>str;
		if(str == "-") break;

		cin>>m;
		for(int i=0;i<m;i++){
			cin>>h;
			left  = str.substr(0, h);
			right = str.substr(h, str.length()-h);
			str = right + left;
		}

		cout<<str<<endl;
	}

	return 0;
}

Measured memory_bytes: 1216
// 20:16 - 20:28
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pint;
typedef tuple<int, int, int> tint;

const int N = 200000 + 5;
const int M = 2e6 + 5;
const int C = 26 + 2;
const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;

struct AhoCorasick {
	int ch[M][C], f[M], pre[M];
	vector<int> isEnd[M];
	int idx;

	void Insert(string &s, int id, int op) {
		int o = 0;
		for (int i = op; i < s.size(); i++) {
			// 注意加入的是 [0, 26)
			int c = s[i] - 'a';
			if (ch[o][c])
				o = ch[o][c];
			else
				o = ch[o][c] = ++idx;
		}
		isEnd[o].push_back(id * (op ? -1 : 1));
	}

	void GetFail() {
		queue<int> q;
		for (int c = 0; c < C; c++)
			if (ch[0][c]) q.push(ch[0][c]);

		while (!q.empty()) {
			int o = q.front();
			q.pop();
			for (int c = 0; c < C; c++) {
				int &u = ch[o][c];
				int j = f[o];
				if (!u) {
					u = ch[j][c];
					continue;
				}
				q.push(u);
				while (j && !ch[j][c]) j = f[j];
				f[u] = ch[j][c];
				pre[u] = isEnd[f[u]].size() ? f[u] : pre[f[u]];
			}
		}
	}

	void GetMatchPos(string &s, vector<int> &pos) {
		int o = 0;
		for (int i = 0; i < s.size(); i++)
			o = ch[o][s[i] - 'a'];

		int p = o;
		// 即使不是接受态，往前跳几下就可能是接受态了
		if (!isEnd[o].size() && pre[o]) p = pre[o];
		while (isEnd[p].size()) {
			for (auto id: isEnd[p])
				if (id < 0) pos.push_back(-id);
			if (p == 0) break;
			p = pre[p];
		}
	}
};
AhoCorasick ac;

string s[N];
int pos[N][C];

int main() {
	ios::sync_with_stdio(0);

	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
		memset(pos[i], 0x3f, sizeof(pos[i]));
		for (int j = 0; j < s[i].size(); j++) {
			int c = s[i][j] - 'a';
			pos[i][c] = min(pos[i][c], j);
		}
		ac.Insert(s[i], i, 0);
		ac.Insert(s[i], i, 1);
	}
	ac.GetFail();

	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		vector<int> fail;
		ac.GetMatchPos(s[i], fail);
		for (auto p: fail) {
			if (p == i) continue;
			int c = s[p].front() - 'a';
			int len = s[i].size() - (s[p].size() - 1);
			ans += pos[i][c] < len;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 291884
import math

n = int(input())

k = math.floor(math.log10(n)) + 1

if k % 2 == 0:
    ks = k // 2
    ans = 9 * (100 ** ks - 1) // 99
else:
    ks = (k - 1) // 2
    ans = 9 * (100 ** ks - 1) // 99 + (n - 10**(k-1) + 1)

print(ans)

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

int main()
{
	int n, max, min;
	int a; 
	cin >> n;
	max = 0;
	min = 1001;
	
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		if (max < a){max = a;}
		if (min > a){min = a;}
	}
	cout << max - min << endl;
	
}


Measured memory_bytes: 256
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;
use std::cmp::min;

fn main() {
    let _n: usize = read();
    let s: Vec<char> = read::<String>().chars().collect();
    let t: Vec<char> = read::<String>().chars().collect();

    println!("{}", (0..min(s.len(), t.len()) + 1).filter(|&i| s[s.len() - i..] == t[..i]).map(|i| s.len() + t.len() - i).min().unwrap());
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

int main(){
  ll N, K;
  cin >> N >> K;
  double p = 1.0/(double)(N);
  double ans = 0.0;
  rep(i,0,N){
    ll s = i+1;
    ll cnt = 0;
    while(s < K){
      s *= 2;
      cnt++;
    }
    ans += p/(double)(pow(2,cnt));
  }
  cout << std::fixed << std::setprecision(12) << ans << endl;
  return 0;
}

Measured memory_bytes: 4116
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const long long MOD = 1000000007;

vector<int> places[210000];
long long dp[210000];
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }

int main() {
    // 入力
    int N; cin >> N;
    vector<int> c(N);
    for (int i = 0; i < N; ++i) cin >> c[i];

    // places[i] := (c[j] = i となるような j の集まり)
    for (int i = 0; i < 210000; ++i) places[i].clear();
    for (int i = 0; i < N; ++i) places[c[i]].push_back(i);

    // DP
    dp[0] = 1;
    for (int i = 0; i < N; ++i) {
        // 特に操作しない場合
        add(dp[i+1], dp[i]);

        // 操作する場合
        int color = c[i];
        int it = lower_bound(places[color].begin(), places[color].end(), i)
            - places[color].begin(); // c[i] が color 色の何番目の要素か
        if (it > 0) {
            int j = places[color][it - 1]; // c[j] = c[i] となる j
            if (i - j > 1) add(dp[i+1], dp[j+1]);
        }
    }
    cout << dp[N] << endl;
}


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

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

    if(K % 2 == 0){
        cout << K * K / 4 << endl;
    }

    else{
        cout << K / 2 * (K / 2 + 1) << endl;
    }
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct ss {
	string a, b;
	bool operator < (ss o) const {
		return tie(a, b) < tie(o.a, o.b);
	}
};

int N;
string str;
map<ss, ll> cnt;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	
	cin >> N;
	cin >> str;
	
	for (int mask = 0; mask < (1<<N); mask++) {
		string x, y;
		for (int i = 0; i < N; i++) {
			if (mask & (1<<i)) x += str[i];
			else y += str[i];
		}
		cnt[{x, y}]++;
	}
	
	ll ans = 0;
	for (int mask = 0; mask < (1<<N); mask++) {
		string x, y;
		for (int i = 0; i < N; i++) {
			if (mask & (1<<i)) x += str[2*N-1-i];
			else y += str[2*N-1-i];
		}
		ans += cnt[{x, y}];
	}
	cout << ans << "\n";
	
	return 0;
}


Measured memory_bytes: 91904
import sys
from itertools import permutations
from math import factorial
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
XY = [list(map(int, readline().split())) for _ in range(N)]

dist = 0
for route in permutations(XY, N):
    acc = 0
    dists = [
        pow(
            pow(route[i][0] - route[i + 1][0], 2) +
            pow(route[i][1] - route[i + 1][1], 2), .5) for i in range(N - 1)
    ]
    dist += sum(dists)
print(dist / factorial(N))

Measured memory_bytes: 3188
#include<stdio.h>
#include<math.h>
int main(){
int n,num,kazu,i,j;
int A[10000];
double b;

scanf("%d",&n);

kazu=0;

for(i=0;i<n;i++){
 scanf("%d",&A[i]);
 num=0;
 b=sqrt(A[i]);

 for(j=1;j<=b;j++){
  if(A[i]%j==0){ num++;}
 }
 
 if(num==1){ kazu++;}

}


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

return 0;
}

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

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

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

    string str;
    cin >> str;
    string ans;
    for(int i = 0; i < str.length()-8; i++){
        ans += str[i];
    }

    cout << ans << '\n';


   return 0;
}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 10010010010010;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

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

    int N,D;cin >> N >> D;
    vector<bool> hate(10);
    for(int i = 0;i<D;i++) {
        int a;cin >> a;
        hate.at(a) = true;
    }

    for(int i = N;i<=100000;i++){
        int now = i;
        bool ok = true;
        string S;S = to_string(now);
        for(int j = 0;j<S.size();j++){
            if(hate.at(S.at(j)-'0')){
                ok = false;
            }
        }
        if(ok) {
            cout << now << endl;
            return 0;
        }
    }

}


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

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

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

int main(){
   string S;
   cin >> S;
   bool flag = true;
  if(S.size()%2 == 1) cout << "No" << endl;
  else{
    for(int i = 0;i<S.size()-1;i += 2){
     if(!(S[i] == 'h' && S[i+1] == 'i')){
       flag = false;
       break;
     }
   }
   if(flag) cout << "Yes" << endl;
   else cout << "No" << endl;
  }
 }

Measured memory_bytes: 256
n = int(input())
*L, = map(int, input().split())
#L = [int(i) for i in input().split()]

def SelectionSort(A,N):
	cnt = 0
	for i in range(N):
		minj = i
		for j in range(i,N):
			if A[j] < A[minj]:
				minj = j
		if A[i] > A[minj]:
			A[i], A[minj] = A[minj], A[i]
			cnt += 1
	return cnt

cnt = SelectionSort(L,n)

print(*L)
print(cnt)


Measured memory_bytes: 5612
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(){
    long long int x,ans=0,mod;
    scanf("%lld",&x);
    ans=((x-1)/11)*2+2;
    mod=x%11;
    if(mod<=6 &&mod>=1)ans--;
    printf("%lld",ans);
    
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<set>
using namespace std;
string a,b;

int main()
{
int s,w;
cin>>s>>w;
if(w>=s)
    cout<<"unsafe";
    else cout<<"safe";
    
return 0;   
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
using namespace std;


 
//階乗先に計算
long long int kaizyou[200005] = { 1 };
long long int kai(long long int a, long long int b, long long int mod) {
             long long int tmp = 1;
             for (long long int i = a; i <= b; i++) {
                           tmp *= i;
                           tmp %= mod;
 
                           kaizyou[i] = tmp;
             }
             return tmp;
}
 
 
//累乗(繰り返し2乗法)　aのb乗(mod)を求める。
long long int rui(long long int a, long long int b, long long mod) {
             int memo[65] = {};
             long long int A[65] = {};
             long long int tmp = 1;
             for (int i = 0; i < 65; i++) {
                           memo[i] = b % 2;
                           b /= 2;
             }
 
             A[0] = a;
             A[0] %= mod;
 
             for (int i = 1; i < 65; i++) {
                           A[i] = A[i - 1] * A[i - 1];
                           A[i] %= mod;
             }
             for (int i = 0; i < 65; i++) {
                           if (memo[i] == 1) {
                                        tmp *= A[i];
                                        tmp %= mod;
                           }
             }
             tmp %= mod;
             return tmp;
}
 
//コンビネーション計算
long long int comb(long long int n, long long int r, long long int mod) {
             long long int tmp;
 
             tmp = (kaizyou[n] * rui(kaizyou[r], mod - 2, mod)) % mod;
             tmp *= rui(kaizyou[n - r], mod - 2, mod);
             tmp %= mod;
             if (tmp < 0) { tmp = (mod - tmp) % mod; }
             return tmp;
}
 

int main() {
	long long int n,dp[5500],mod=1000000007,two[6000]={1},three[6000]={1},res=0,tmp;
	queue<int>que;
	string str;
	int count=0;
	cin>>str;
	if(str.length()%2==1&&str[0]==str[str.length()-1]||str.length()%2==0&&str[0]!=str[str.length()-1])
	{
		cout<<"Second";
	}else{
		cout<<"First";
	}
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <math.h>
#include <algorithm>
#include <vector>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))

using namespace std;

#define MOD 1000000007

long n;
long a[200005];
long h[200005];
long long BIT[200005];

void Update( long i, ll val )
{
    for(; i<=n; i+=(i&-i)) {
        BIT[i]=MAX(BIT[i],val);
    }
}

ll Get( long i )
{
    ll ans=0;
    for(; i>0; i-=(i&-i) ) {
        ans = MAX(ans,BIT[i]);
    }
    return ans;
}

int main(int argc, char* argv[])
{
    scanf("%ld", &n );
    
    long i;
    for(i=1; i<=n; i++) {
        scanf("%ld", &(h[i]));
    }
    for(i=1; i<=n; i++) {
        scanf("%ld", &(a[i]));
    }

    ll ans = 0;
    for(i=1; i<=n; i++) {
        ll tmp = Get(h[i]-1);
        tmp += a[i];
        Update( h[i], tmp );
        ans = MAX(ans, tmp);
    }

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

    return 0;
}


Measured memory_bytes: 4864