akhauriyash/Code-Regression huggingface dataset:
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var K = one[1];
  var list = nextIntArray();
  for(var i = 0; i < N; i++){
    var sum = 0;
    for(var j = 1; j <= list[i]; j++){
      sum += j / list[i];
    }
    list[i] = sum;
  }
  var sum = 0;
  var max = 0;
  for(var i = 0; i < N; i++){
    if(i < K){
      sum += list[i];
      max = sum;
    }else{
      sum -= list[i - K];
      sum += list[i];
      max = Math.max(max, sum);
    }
  }
  myout(max);
}



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

int main(){
    string s;
    cin >> s;
    bool ok_fl = true;
    rep(i,s.size()){
        if(i%2 == 0 && s.at(i) == 'L'){
            ok_fl = false;
            break;
        } else if(i%2 == 1 && s.at(i) == 'R'){
            ok_fl = false;
            break;
        }
    }
    if(ok_fl) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

alph = 'abcdefghijklmnopqrstuvwxyz'
n = int(input())
S = [input() for _ in range(n)]
cntS = [None] * n
for i in range(n):
    cntS[i] = Counter(S[i])

ans = []
for c in alph:
    ans += [c * min(cntS[i][c] for i in range(n))]

print(''.join(ans))

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/11/29  Problem: 078_arc_a / Link: https://arc078.contest.atcoder.jp/tasks/arc078_a ----- */
/* ------問題------


-----問題ここまで----- */
/* -----解説等-----

累積和で300なのか、険しいね

----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	VL a(N, 0);
	VL cum(N + 1, 0);
	FOR(i, 0, N) {
		cin >> a[i];
		cum[i + 1] = cum[i] + a[i];
	}

	ans = numeric_limits<long long>::max();
	FOR(i, 1, N) {
		ans = min(ans, abs(cum[i] - (cum[N] - cum[i])));
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <stack>
#include <algorithm>
#include <string>

using namespace std;
int c[2010][2010];
struct Rectangle{long long height,pos; };
long long getRectangleArea(long long size, long long buffer[]){
	stack<Rectangle> S;
	long long maxv = 0;
	buffer[size] = 0;
	for (int i=0;i<=size;i++){
    	Rectangle rect;
        rect.height = buffer[i];
        rect.pos = i;
        if (S.empty()){
        	S.push(rect);
		}else{
       		if(S.top().height<rect.height){
            	S.push(rect);
       		}else if(S.top().height>rect.height){
            	int target = i;
            	while (!S.empty() && S.top().height>=rect.height){
            		Rectangle pre = S.top(); S.pop();
                	long long area = pre.height * (i - pre.pos+1);
                	maxv = max(maxv,area);
                	target = pre.pos;
            	}
            	rect.pos = target;
            	S.push(rect);
       		}
      	}
     }
     return maxv;
}

int main(){
	long long i,j,h,w,ans,a[2010];
	string s[2010];
	cin >> h >> w;
	for(i=0;i<h;i++){
		cin >> s[i];
	}
	
	for(i=0;i<h-1;i++){
		int l = 0,r = 0;
		while(r<=w){
			r++;
			if(r<w && s[i][l]==s[i+1][l]^s[i][r]!=s[i+1][r]){
				continue;
			}else{
				for(j=l;j<r;j++){
					c[i][j] = r-1;
				}
				l = r;
				r = l;
			}
		}
	}
	/*for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			cout << c[i][j] << " ";
		}
		cout << endl;
	}*/
	ans = max(h,w);
	for(j=0;j<w;j++){
		for(i=0;i<h-1;i++){
			a[i] = 1+c[i][j]-j;
		}
		ans = max(ans,getRectangleArea(h-1,a));
	}
	cout << ans << endl;
}

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

namespace ProblemC
{
    class Program
    {
        static int[] initAs;
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var N = read[0];
            var K = read[1];
            initAs = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            
            var res = Solve(N, K, initAs);
            Console.WriteLine(String.Join(" ", res));
        }

        static int[] Solve(int N, int K, int[] initAs)
        {
            var res = initAs;
            for (int i = 0; i < K; i++)
            {
                res = GetBs(res, N);
                if (res.All(x => x >= N))
                    break;
            }
            return res;
        }

        static int[] GetBs(int[] As, int N)
        {
            var Bs = new int[N];
            for (int i = 0; i < As.Length; i++)
            {
                var l = Math.Max(0, i - As[i]);
                var r = Math.Min(N - 1, i + As[i]);
                Bs[l]++;
                if (r + 1 < N) Bs[r + 1]--;
            }
            for (int i = 1; i < Bs.Length; i++)
            {
                Bs[i] += Bs[i - 1];
            }
            return Bs;
        }

        //static void Solve(int K, ref int[] As)
        //{
        //    if (K == 0)
        //        As = initAs;
        //    else
        //    {
        //        Solve(K - 1, ref As);
        //        for (int i = 0; i < length; i++)
        //        {

        //        }
        //    }
        //}
    }
}


Measured memory_bytes: 62480
#include <bits/stdc++.h>
#define lowbit(x) ((x) & -(x))
using namespace std;

struct query {
	int l, r, seq;
	inline bool operator < (const query &a) {
		return r < a.r;
	}
} b[500010];

int n, q;
int a[500010], c[500010];
int ans[500010];
map <int, int> m;

int main() {
	scanf("%d%d", &n, &q);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	for (int i = 1; i <= q; ++i) {
		scanf("%d%d", &b[i].l, &b[i].r);
		b[i].seq = i;
	}

	sort(b + 1, b + q + 1);
	for (int i = 1, j = 1; i <= q; ++i) {
		for (; j <= b[i].r; ++j) {
			if (m.find(a[j]) != m.end())
				for (int k = m[a[j]]; k <= n; k += lowbit(k))
					--c[k];
			m[a[j]] = j;
			for (int k = j; k <= n; k += lowbit(k))
				++c[k];
		}

		int &sum = ans[b[i].seq];
		for (int j = b[i].r; j > 0; j -= lowbit(j))
			sum += c[j];
		for (int j = b[i].l - 1; j > 0; j -= lowbit(j))
			sum -= c[j];
	}

	for (int i = 1; i <= q; ++i)
		printf("%d\n", ans[i]);
	return 0;
}



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

int main(){

    int n;
    cin >> n;
    int a[n],b[100000];
    for(int i=0;i<100000;i++){
        b[i] = 0;
    }
    for(int i = 0;i<n;i++){
        cin >> a[i];
        b[a[i]] += 1;
    }
    int Max = 0;
    for(int i = 2;i<100000;i++){
        int sun = b[i-2] + b[i-1] + b[i];
        Max = max(Max,sun);
    }
    cout << Max << endl;



    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main(){
  string a,b;
  cin >> a >> b;
  string c = a+b;
  int d = stoi(c);
  for(int i=0;i<1000;i++){
    if(d == i*i){
      cout << "Yes" << "\n";
      return 0;
    }
  }
  cout << "No" << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    long int a,b,W;
    scanf("%ld%ld%ld",&W,&a,&b);
    if (((a<=b)&&(b<=a+W)) || ((b<=a)&&(a<=b+W)) ) puts("0");
    else printf("%ld\n",(b-a-W)>(a-b-W)?(b-a-W):(a-b-W));
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

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

int a, b, n = 1, cnt = 0;

int main() {

  cin >> a >> b;

  while(true) {
    if(n>=b) {
      cout << cnt << endl;
      break;
    }
    n += a-1;
    ++cnt;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <utility>
#include <math.h>

using namespace std;

#define ll long long

int main(){
    int X, A;
    cin >> X >> A;
    cout << (X >= A) * 10 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
using namespace std;
int main()
{
	float H, A;
	cin >> H >> A;
	float res = H / A;
	int result = H / A;
	if (res != result || result <= 0)
		cout << result + 1 << endl;
	else
		cout << result << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n, k;
	cin >> n >> k;
	vi a(n); cin >> a;
	vi s(n + 1);
	REP(i, n) s[i + 1] = s[i] + a[i];
	vi v;
	REP(i, n + 1)REP(j, i)
	{
		v.push_back(s[i] - s[j]);
	}
	for(int p = 60; p >= 0; p--)
	{
		vi w;
		for (auto x : v)
		{
			if ((x >> p) & 1)
			{
				w.push_back(x);
			}
		}
		if (w.size() >= k)
		{
			v = w;
		}
	}
	ll ans = v[0];
	for (auto x : v) ans &= x;
	cout << ans << endl;
	return 0;
}

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

int main()
{
	long long int n,ans = 0,a = 1;

	cin >> n;

	for (; a*a < n;) {
		a += 10;
	}

	for (; a > 0; a--) {
		if (a*a <= n && ans < a*a)ans = a*a;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 2000000

int n,A[MAX+1];

void maxHeapify(int);

int main(){
  int i;

  scanf("%d",&n);
  for(i=1;i<=n;i++)
    scanf("%d",&A[i]);

  for(i=n/2;i>=1;i--)
    maxHeapify(i);
  for(i=1;i<=n;i++)
    printf(" %d",A[i]);
  printf("\n");

  return 0;
}

void maxHeapify(int i){
  int l,r,larg,tmp;

  l = 2 * i;
  r = 2 * i + 1;

  if(l <= n && A[l] > A[i])larg = l;
  else larg = i;

  if(r <= n && A[r] > A[larg])larg = r;

  if(larg != i){
    tmp = A[i];
    A[i] = A[larg];
    A[larg] = tmp;
    maxHeapify(larg);
  }

}


Measured memory_bytes: 3648
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

const int MAXH = 105;
const int MAXW = 105;

struct Graph {
    int to, cap, rev;
    Graph(int t, int c, int r) : to(t), cap(c), rev(r) {}
};

vector<Graph> G[MAXH + MAXW];
bool used[MAXH + MAXW];
char grid[MAXH][MAXW];

int H, W;

int dfs(int v, int t, int flow) {
    if (v == t || flow == 0) return flow;
    if (used[v]) return 0;
    used[v] = true;

    for(auto &e: G[v]) {
        if (e.cap == 0) continue;
        int f = dfs(e.to, t, min(flow, e.cap));
        if (f > 0) {
            e.cap -= f;
            G[e.to][e.rev].cap += f;
            return f;
        }
    }

    return 0;
}

void add_edge(int from, int to, int cap) {
    G[from].eb(to, cap, (int) G[to].size());
    G[to].eb(from, 0, (int) G[from].size() - 1);
}

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

    cin >> H >> W;

    REP(i, H) REP(j, W) {
        cin >> grid[i][j];
    }

    int s = 0, t = MAXH + MAXW - 1;
    Pin sp, tp;
    REP(h, H) REP(w, W) {
        if (grid[h][w] == '.') continue;

        if (grid[h][w] == 'S') {
            add_edge(s, 1 + w, inf);
            add_edge(s, 1 + h + W, inf);
            sp = {h, w};
        }
        else if (grid[h][w] == 'T') {
            add_edge(1 + w, t, inf);
            add_edge(1 + h + W, t, inf);
            tp = {h, w};
        } else {
            add_edge(1 + w, 1 + W + h, 1);
            add_edge(1 + W + h, 1 + w, 1);
        }

    }

    if (sp.fi == tp.fi || sp.se == tp.se) {
        print(-1);
        return 0;
    }

    int ans = 0;
    while (true) {
        memset(used, false, sizeof(used));
        auto f = dfs(s, t, inf);
        if (f == 0) break;
        ans += f;
    }

    print(ans);
}


Measured memory_bytes: 896
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] numbers = new int[3];
		for (int i = 0; i < numbers.length; i++) {
			numbers[i] = sc.nextInt();
		}
		sc.close();
		long count = IntStream.rangeClosed(numbers[0], numbers[1]).boxed().filter(s -> numbers[2] % s == 0).count();
		System.out.println(count);
	}
}


Measured memory_bytes: 32336
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat64() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	//sc.Buffer(nil, 100000000)

	d, t, s := nextInt(), nextInt(), nextInt()

	ans := "No"
	if (t * s) >= d {
		ans = "Yes"
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1772
# Stable Sort

n = int(input())
C = list(input().split(' '))

C1, C2 = [], []
for v in C:
	tmp = v[0]
	num = int(v[1])
	C1.append([tmp, num])
	C2.append([tmp, num])

def bubble(A):
	n = len(A)
	for i in range(n):
		for j in range(n - 1, 0, -1):
			if A[j][1] < A[j - 1][1]:
				A[j], A[j - 1] = A[j - 1], A[j]
	return 0

def selection(A):
	n = len(A)
	for i in range(n):
		minj = i
		for j in range(i, n):
			if A[j][1] < A[minj][1]: minj = j
		A[i], A[minj] = A[minj], A[i]
	return 0

def is_Stable(C1, C2):
	# bubble sort is always stable
	n = len(C1)
	for i in range(n):
		if C1[i][0] != C2[i][0]:
			return False
	return True

def pprint(A):
	res = []
	for v in A:
		tmp1 = v[0]
		tmp2 = str(v[1])
		res.append(tmp1 + tmp2)
	print(*res)
	return
	
bubble(C1)
selection(C2)

pprint(C1)
print('Stable')
pprint(C2)
print('Stable') if is_Stable(C1, C2) else print('Not stable')



Measured memory_bytes: 5608
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
 int a,b;
  cin >> a >> b;
  if(a>12) {
    cout << b << endl;
  }
  if(a>5&&a<13) {
    cout << b/2 << endl;
  }
  if(a<6) {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1<<15;
int n,m,c[15][15];
int p[N],dp[N][15];
void pre()
{
    memset(p,0,sizeof(p));
    for(int i=0;i<(1<<n);i++)
        for(int j=0;j<n;j++)
            dp[i][j]=-1;
    for(int i=0;i<(1<<n);i++)
        for(int j=0;j<n;j++){
            if(((i>>j)&1)==0)continue;
            for(int k=j+1;k<n;k++){
                if(((i>>k)&1)==0)continue;
                p[i]+=c[j][k];
            }
        }
}
int main()  
{  
    scanf("%d%d",&n,&m);
        int sum=0;
		int u,v,w;
        memset(c,0,sizeof(c));
        for(int i=1;i<=m;i++){
            scanf("%d%d%d",&u,&v,&w);
            u--,v--;
            c[u][v]=c[v][u]=w;
            sum+=w;
        }
        pre();
        dp[1][0]=0;
        for(int i=0;i<(1<<n);i++){
            for(int j=0;j<n;j++){
                if(dp[i][j]==-1)continue;
                int x=(((1<<n)-1)^i)|(1<<j);
                for(int y=x;y>=0;y--)  
                    y&=x,dp[i|y][j]=max(dp[i|y][j],dp[i][j]+p[y]);
                for(int k=0;k<n;k++){
                    if((i>>k)&1)continue;
                    if(c[j][k]==0)continue;
                    dp[i|(1<<k)][k]=max(dp[i|(1<<k)][k],dp[i][j]+c[j][k]);
            	}
            }
        }
        int ans=1e9;
        for(int i=0;i<(1<<n);i++)
            ans=min(ans,sum-dp[i][n-1]);
        cout<<ans<<endl;
    return 0;  
}  

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

ll power_mod(ll a, ll n, int p = MOD) {
    ll ret = 1;
    for (; n; n >>= 1) {
    if (n & 1) ret = ret * a % p;
    a = a * a % p;
    }
    return ret;
}

int main() {
    ll n;
    cin >> n;
    ll ret = power_mod(10, n);
    ret = (ret + MOD - power_mod(9, n)) % MOD;
    ret = (ret + MOD - power_mod(9, n)) % MOD;
    ret = (ret       + power_mod(8, n)) % MOD;

    cout << ret << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    if (n == 0)
    {
        cout << 0 << endl;
        return 0;
    }

    int array[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &array[i]);
    }
    if (n == 1)
    {
        cout << array[0] << endl;
        return 0;
    }

    if (n == 2)
    {
        cout << abs(array[1] - array[0]) << endl;
        return 0;
    }

    int a = 0, b = abs(array[1] - array[0]), c = abs(array[1] - array[0]);
    for (int i = 2; i < n; i++)
    {
        c = min(abs(array[i] - array[i - 2]) + a, abs(array[i] - array[i - 1]) + b);
        a = b;
        b = c;
    }
    cout << b << endl;
    return 0;
}

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

int main(){
    int N;
    string s;
    cin>>N;
    cin>>s;
    string ans="Yes";
    if(N%2==1){
        ans="No";
        cout<<ans<<endl;
        return 0;
    }
    rep(i,N/2){
        if(s[i]!=s[i+N/2])ans="No";
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	set<int> s;
	while(n--)
	{
		int a;
		cin>>a;
		s.insert(a);
	}
	int ans=s.size();
	if(ans%2==0) ans-=1;
	cout<<ans;
	return 0;
}

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

//wierd debugging stuff
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << "\n" ; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
//end of weird debugging stuff
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
 
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define fo(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define foe(i,x) for(auto& i: x)
#define ar array
#define pb push_back
#define vt vector
#define F first
#define S second

template<class T> bool umin(T& a,const T& b){return b<a?a=b,1:0;}
template<class T> bool umax(T& a,const T& b){return b>a?a=b,1:0;}

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {cin>>x;}
void read(double& d) {string t;read(t);	d=stod(t);}
void read(long double& d) {	string t;read(t);d=stold(t);}
template<class H, class... T> void read(H& h, T&... t) {read(h);read(t...);}
template<class A> void read(vt<A>& x) {	foe(a, x)read(a);}
int nxt(){int a;read(a);return a;}   // iota(all(v),0); genrate(all(v),nxt);

// no change 
const ll MOD = 1e9+7;  
int mx = 1e6+1;
void Titan(){
	int n;
	read(n);
	int a = 1;

	while((a*(a+1)/2) < n)a++;
	cout << a;



}

	

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int T = 1;
	//cin >> T;		//cmt if one test case
    fo(T){
		//cout << "Case #" << i+1 << ": " ;
		Titan();
	}
}
/*///////////////////////////////////////////////////////////
Important Notes : 
* check long long 
* check base cases
* do not loose Hope
* if case fails on 2nd test case maybe some cases are missing check them
* do not sit idle
* try to do it using pen/paper.
*/


Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&a==c){
        cout<<"No"<<endl;
    }else if(a==b||c==b||c==a){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define MX 100005
ll dp[MX][2];
int wt[101], val[101];
int main() {
	int n, w;
	cin >> n >> w;
	for (int i = 1; i <= n; ++i)
		cin >> wt[i] >> val[i];
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= w; ++j) {
			if (wt[i] > j)
				dp[j][1] = dp[j][0];
			else
				dp[j][1] = max(dp[j][0], val[i] + dp[j - wt[i]][0]);
		}
		for (int j = 1; j <= w; ++j)
			dp[j][0] = dp[j][1];
	}
	cout << dp[w][1] << endl;
}


Measured memory_bytes: 1792
# frozen_string_literal: true

n, k = gets.split.map &:to_i
p = gets.split.map &:to_i
sum = p[0...k].inject(:+)
temp = sum
(k...n).each do |i|
  temp = temp - p[i-k] + p[i]
  sum = temp if sum < temp
end
puts (sum+k)/2.0


Measured memory_bytes: 16816
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 35;
const int MAXK = 510;
const int MAXQ = 200010;

// class ReconstructNumber {
// public:
//     string smallest(string);
// };

// string ReconstructNumber::smallest(string s) {
// }

int n, m, s, t, d[MAXN][3];
vector<int> a[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m;
    FOR(i,1,m) {
        int u, v;
        cin >> u >> v;
        a[u].emplace_back(v);
    }
    queue<II> q;
    FOR(i,1,n)
        FOR(j,0,2) d[i][j] = 1000000000;
    cin >> s >> t;
    d[s][0] = 0;
    q.push(II(s, 0));
    while (!q.empty()) {
        II r = q.front();
        q.pop();
        int u = r.FI;
        int k = r.SE;
        FOR(i,0,SZ(a[u])-1) {
            int v = a[u][i];
            if (d[v][(k+1) % 3] > d[u][k] + 1) {
                d[v][(k+1) % 3] = d[u][k] + 1;
                q.push(II(v, (k+1) % 3));
            } 
        }
    }
    if (d[t][0] == 1000000000) cout << -1;
    else cout << d[t][0] / 3;
    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;


struct Data {
    int p;
    ll id;
    Data(int p, ll id) : p(p), id(id){}
    bool operator < (const Data &d) const {
        return p > d.p;
    }
};

int main() {
    ll H, W, M;
    cin >> H >> W >> M;
    ll h[M], w[M];
    set<ll> s;
    int ch[H]{}, cw[W]{};
    for (int i = 0; i < M; i++) {
        cin >> h[i] >> w[i];
        h[i]--;
        w[i]--;
        s.insert(h[i] * W + w[i]);
        ch[h[i]]++;
        cw[w[i]]++;
    }
    vector<Data> dh, dw;
    for (int i = 0; i < H; i++) {
        dh.push_back(Data(ch[i], i));
    }
    for (int i = 0; i < W; i++) {
        dw.push_back(Data(cw[i], i));
    }
    sort(dh.begin(), dh.end());
    sort(dw.begin(), dw.end());
    
    vector<Data> dh_max, dw_max;
    int maxH = dh[0].p;
    int maxW = dw[0].p;

    for (int i = 0; i < H; i++) {
        if (maxH == dh[i].p) {
            dh_max.push_back(dh[i]);
        } else {
            break;
        }
    }
    
    for (int i = 0; i < W; i++) {
        if (maxW == dw[i].p) {
            dw_max.push_back(dw[i]);
        } else {
            break;
        }
    }
    ll ans = dh_max[0].p + dw_max[0].p - 1;
    for (int i = 0; i < dh_max.size(); i++) {
        for (int j = 0; j < dw_max.size(); j++) {
            ll id = dh_max[i].id * W + dw_max[j].id;
            if (s.count(id) == 0) {
                cout << ans + 1 << "\n";
                return 0;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 50760
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

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

  vector<double> elst(n);
  rep(i, n) {
    double p_i;
    cin >> p_i;
    elst[i] = p_i * (p_i + 1) / 2.0 / p_i;
  }

  double acc = 0;
  rep(i, k) acc += elst[i];
  double ans = acc;
  for (ll i = k; i < n; i++) {
    acc += elst[i];
    acc -= elst[i - k];
    chmax(ans, acc);
  }

  printf("%.15f\n", ans);

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  int num,sum;
  sum=0;
  num=N;
  while(num){
    sum+=num%10;
    num/=10;
  }
  if(N%sum==0){
    cout << "Yes"<<endl;
  }
  else
    cout <<"No"<<endl;
}

Measured memory_bytes: 256
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B);}
#define in_edges3(M) repp(I, 1, M){int A, B, C; cin >> A >> B >> C; v[A].pb(B, C), v[B].pb(A, C);}
#define endl "\n"

const ll MOD = 1000000007;
const ll INF = 1e18;
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    string s;
    cin >> s;
    ll sum = 0;
    for(auto i : s) sum += (i - '0');
    if(sum % 9 ==0 ) cout << "Yes";
    else cout << "No";
}

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

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

pair<int, int> INF = { 1000000000, -1 };

class SegmentTree {
private:
	vector<pair<int, int> > Node;
public:
	SegmentTree(vector<int>& V) : Node(V.size() * 2, INF) {
		for (int i = 0; i < V.size(); i++) {
			Node[i + V.size()] = { V[i], i };
		}
		for (int i = V.size() - 1; i >= 1; i--) {
			Node[i] = min(Node[i * 2], Node[i * 2 + 1]);
		}
	}
	pair<int, int> Query(int L, int R) {
		L += Node.size() / 2, R += Node.size() / 2;
		pair<int, int> ANS = INF;
		while (L < R) {
			if (L & 1) {
				ANS = min(ANS, Node[L]);
				L++;
			}
			if (R & 1) {
				ANS = min(ANS, Node[R - 1]);
				R--;
			}
			L >>= 1, R >>= 1;
		}
		return ANS;
	}
};

struct Range {
	pair<int, int> MAX1, MAX2;
	int L, R;
};

bool operator< (Range R1, Range R2) {
	return R1.MAX1.first > R2.MAX1.first;
}

int main() {
	int N;
	cin >> N;
	vector<int> P(N), VE(N, INF.first), VO(N, INF.first);
	for (int i = 0; i < N; i++) cin >> P[i], i % 2 == 0 ? VE[i] = P[i] : VO[i] = P[i];
	SegmentTree Even(VE), Odd(VO);
	priority_queue<Range> PQ;
	Range R;
	R.L = 0, R.R = N;
	R.MAX1 = Even.Query(0, N);
	R.MAX2 = Odd.Query(R.MAX1.second + 1, N);
	PQ.push(R);
	vector<long long> ANS;
	while (!PQ.empty()) {
		Range P = PQ.top();
		PQ.pop();
		ANS.push_back(P.MAX1.first);
		ANS.push_back(P.MAX2.first);
		if (P.L != P.MAX1.second) {
			Range NR;
			NR.L = P.L, NR.R = P.MAX1.second;
			if (NR.L % 2 == 0) {
				NR.MAX1 = Even.Query(NR.L, NR.R);
				NR.MAX2 = Odd.Query(NR.MAX1.second + 1, NR.R);
			}
			else {
				NR.MAX1 = Odd.Query(NR.L, NR.R);
				NR.MAX2 = Even.Query(NR.MAX1.second + 1, NR.R);
			}
			PQ.push(NR);
		}
		if (P.MAX1.second + 1 != P.MAX2.second) {
			Range NR;
			NR.L = P.MAX1.second + 1, NR.R = P.MAX2.second;
			if (NR.L % 2 == 0) {
				NR.MAX1 = Even.Query(NR.L, NR.R);
				NR.MAX2 = Odd.Query(NR.MAX1.second + 1, NR.R);
			}
			else {
				NR.MAX1 = Odd.Query(NR.L, NR.R);
				NR.MAX2 = Even.Query(NR.MAX1.second + 1, NR.R);
			}
			PQ.push(NR);
		}
		if (P.MAX2.second + 1 != P.R) {
			Range NR;
			NR.L = P.MAX2.second + 1, NR.R = P.R;
			if (NR.L % 2 == 0) {
				NR.MAX1 = Even.Query(NR.L, NR.R);
				NR.MAX2 = Odd.Query(NR.MAX1.second + 1, NR.R);
			}
			else {
				NR.MAX1 = Odd.Query(NR.L, NR.R);
				NR.MAX2 = Even.Query(NR.MAX1.second + 1, NR.R);
			}
			PQ.push(NR);
		}
	}
	for (int i = 0; i < N; i++) {
		cout << ANS[i] << (i == N - 1 ? '\n' : ' ');
	}
}

Measured memory_bytes: 12832
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

vs64 a, f;
s64 solve(s64 x)
{
    s64 ret = 0;
    rep (i, a.size())
    {
        if (a[i] * f[i] > x)
        {
            ret += CEIL(a[i] * f[i] - x, f[i]);
        }
    }
    return ret;
}

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

    int n;
    s64 k;
    cin >> n >> k;
    a.resize(n);
    f.resize(n);
    rep (i, n) cin >> a[i];
    rep (i, n) cin >> f[i];

    sort(a.begin(), a.end());
    sort(f.begin(), f.end(), greater<s64>());

    s64 l = -1;
    s64 r = (s64)1e12;
    while (l + 1 < r)
    {
        s64 m = (l + r) / 2;
        if (solve(m) > k)
        {
            l = m;
        }
        else
        {
            r = m;
        }
        
    }

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



Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {
	
	int X; cin >> X;

	int ans = 1;

	while(1) {
		if ((ans * X) % 360 == 0) {
			break;
		}
		ans++;	
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll t, ans = 1;
    for(int i=0;i<n;i++){
    	cin >> t;
    	ll g = __gcd(t, ans);
    	ans /= g;
    	ans *= t;
    }
    cout << ans << endl;
    return 0;

}


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

using namespace std;

int a[100000];
int b[100000];

int main() {
    int n, i;
    long long ans = 0;
    vector <pair<int, int>> v;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) scanf("%d %d", &a[i], &b[i]);
    
    for (i = 0; i < n; i++) v.push_back(make_pair(a[i] + b[i], i));
    
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    
    for (i = 0; i < n; i++) {
        if (i % 2 == 0) {
            ans += a[v[i].second];
        } else {
            ans -= b[v[i].second];
        }
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 2168
// テ・ツ淞コテヲツ慊ャテ」ツδ?」ツδウテ」ツδ療」ツδャテ」ツδシテ」ツδ?

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, M, K;
int dp[1<<16], to[1<<16][110];
int v[110][110];
int d[20], dark[110];

signed main() {
    cin >> N >> M >> K;
    memset(dark, -1, sizeof(dark));
    rep(i,0,M) {
        cin >> d[i]; d[i]--;
        dark[ d[i] ] = i;
    }
    rep(i,0,N) rep(j,0,K) cin >> v[i][j], v[i][j]--;

    rep(bit,0,1<<M) rep(i,0,K) {
        int nbit = 0;
        rep(k,0,M) {
            if(bit >> k & 1) {
                if(dark[ v[d[k]][i] ] < 0) continue;
                nbit |= (1 << dark[ v[d[k]][i] ]);
            }
        }
        to[bit][i] = nbit;
    }

    rep(i,0,(1<<M)-1) dp[i] = INF;
    queue<int> q; q.push((1<<M)-1);
    while(!q.empty()) {
        int bit = q.front(); q.pop();
        rep(i,0,K) {
            int nbit = to[bit][i];
            if(dp[nbit] > dp[bit] + 1) {
                dp[nbit] = dp[bit] + 1;
                q.push(nbit);
            }
        }
    }
    cout << dp[0] << endl;
    return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
  gearup;
  string s,t; cin >> s >> t;
  int n = s.size();
  bool is_res = false;
  rep(i,n){
      if(s==t)is_res = true;
      s = s.substr(1) + s[0];
  }
  if(is_res)out("Yes");
  else out("No");
}


Measured memory_bytes: 256
package main

import "fmt"

const Limit = 50

var matrix [Limit][Limit]bool
var a [Limit]int
var b [Limit]int
var visited [Limit]bool
var n, k int

func check(node int) {
	if visited[node] {
		return
	} else {
		visited[node] = true
		for i := 0; i < n; i++ {
			if matrix[node][i] {
				check(i)
			}
		}
	}
}

func main() {
	fmt.Scan(&n, &k)
	//
	for i := 0; i < k; i++ {
		fmt.Scan(&a[i], &b[i])
		a[i]--
		b[i]--
		matrix[a[i]][b[i]] = true
		matrix[b[i]][a[i]] = true
	}
	//
	//
	bridge := 0
	for i := 0; i < k; i++ {
		matrix[a[i]][b[i]] = false
		matrix[b[i]][a[i]] = false
		for j := 0; j < n; j++ {
			visited[j] = false
		}

		check(0)
		true_cnt := 0
		for j := 0; j < n; j++ {
			if visited[j] {
				true_cnt++
			}
		}
		if true_cnt != n {
			bridge++
		}

		matrix[a[i]][b[i]] = true
		matrix[b[i]][a[i]] = true
	}

	fmt.Println(bridge)
}


Measured memory_bytes: 512
#include<bits/stdc++.h> 
using namespace std;
int n;
int f[130];
int a[130];
string st;
int main(){
    cin>>n; 
    memset(f,127,sizeof(f)); 
    for(int i=1; i<=n; i++){
        cin>>st;
        memset(a,0,sizeof(a)); 
        for(int j=0; j<st.size(); j++)a[st[j]]++;  
        for(int j=97; j<=122; j++)
        f[j]=min(a[j],f[j]);
    }
    for(int i=97; i<=122; i++)for(int j=1; j<=f[i]; j++) cout<<char(i);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>
#include <cmath>
#define maxn 300010
#define maxm 1000010
#define ls x << 1
#define rs x << 1 | 1
#define inf 1000000007
#define inc(i) (++ (i))
#define dec(i) (-- (i))
#define mid ((l + r) >> 1)
#define int long long
#define XRZ 1000000007
#define debug() puts("XRZ TXDY");
#define mem(i, x) memset(i, x, sizeof(i));
#define Next(i, u) for(register int i = head[u]; i ; i = e[i].nxt)
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout);
#define Rep(i, a, b) for(register int i = (a) , i##Limit = (b) ; i <= i##Limit ; inc(i))
#define Dep(i, a, b) for(register int i = (a) , i##Limit = (b) ; i >= i##Limit ; dec(i))
int dx[10] = {1, -1, 0, 0};
int dy[10] = {0, 0, 1, -1};
using namespace std;
inline int read() {
    register int x = 0, f = 1; register char c = getchar();
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
} int a[maxn], ans;
signed main() { int n = read();
	Rep(i, 1, n) { a[i] = read();
		if(a[i - 1] > a[i]) ans += a[i - 1] - a[i], a[i] = a[i - 1];
	} printf("%lld", ans);
	return 0; int zmy = 123345;
}

Measured memory_bytes: 5196
// based on editorial.pdf
#include <iostream>
#include <algorithm>
#define REP(i, n) for (ull i = 0; i < (n); i++)
using ull = unsigned long long int;
using namespace std;

int main() {
  ull N;
  cin >> N;
  ull a = 0, b;
  ull ans = 0;
  REP(n, N) {
    cin >> b;
    if (b == 0) {
      a = 0;
      continue;
    }
    if (a) { // a is 0 or 1.
      ans++;
      b--;
    }
    ans += b / 2;
    a = b % 2;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
	int n, q, m, num=0, sum=0;
	vector<int> A, Q;

	cin>>n;
	for(int i=0;i<n;i++){
		cin>>m;
		A.push_back(m);
		sum += m;
	}

	cin>>q;
	for(int i=0;i<q;i++){
		cin>>m;
		Q.push_back(m);

		if(m > num)
			num = m;
	}

	int M = max(num, sum);
	vector<vector<bool> > B;

	B.resize(A.size()+1);
	for(int i=0;i<A.size()+1;i++)
		B[i].resize(M+1);

	B[0][0] = true;
	for(int j=1;j<M+1;j++)
		B[0][j] = false;

	for(int i=1;i<A.size()+1;i++){
		for(int j=0;j<M+1;j++){
			if(j < A[i-1])
				if(B[i-1][j])
					B[i][j] = true;
				else
					B[i][j] = false;
			else
				if(B[i-1][j] || B[i-1][j-A[i-1]])
					B[i][j] = true;
				else
					B[i][j] = false;
		}
	}

	for(int i=0;i<q;i++){
		if(B[A.size()][Q[i]])
			cout<<"yes"<<endl;
		else
			cout<<"no"<<endl;
	}

	return 0;
}

Measured memory_bytes: 1232
import java.util.*;
import java.lang.Math;

class Main{

public static void main(String[] args){
Scanner scanner1 = new Scanner(System.in);
Scanner scanner2 = new Scanner(System.in);
int a=scanner1.nextInt();

if(a==1) System.out.print(0);
if(a==0) System.out.print(1);
}
}

Measured memory_bytes: 35720
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let n:usize = read();
    let v:Vec<usize> = (0..n).map(|_| read()).collect();
    let mut cnt = 0;
    let mut tmp = v[0];
    for i in 1..n {
        if v[i] < tmp {
            cnt += tmp - v[i];
        }
        if v[i] > tmp {
            tmp = v[i];
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 3536