akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
    unsigned int key;
    struct node *next;
    struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
    NodePointer t;
    for (t = nil->next; (t != nil) && (t->key != key); t = t->next);//fantastic
    return t;
}

void init(){
    nil = malloc(sizeof(struct node));
    nil->next = nil;
    nil->prev = nil;
}

void printList(){
    NodePointer cur = nil->next;
    int isf = 1;
    while(1){
	if ( cur == nil ) break;
	if ( isf == 0)  printf(" ");
	printf("%d", cur->key);
	cur = cur->next;
	isf = 0;
    }
    printf("\n");
}

void deleteNode(NodePointer t){
    /*if (t->next == nil){
	t->prev->next = nil;
	free(t);
    }else{
	t->next->prev = t->prev;
	t->prev->next = t->next;
	free(t);
    }
    return ;
    */
    if ( t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst(){
    NodePointer t = nil->next;
    if ( t == nil ) return;
    deleteNode(t);
}

void deleteLast(){
    deleteNode(nil->prev);
    //t = nil;
    //there are no data in the list
    //if (nil->next == nil) return ;
    //traverse the list to the end of the list
    //while(t->next != nil) t = t->next;
}

void delete(int key){
    NodePointer t;
    t = listSearch(key);
    if (t == nil) return ;
    else deleteNode(t);
    return ;
}

void insert(int key){
    NodePointer x;
    x = malloc(sizeof(struct node));
    x->key = key;
    //insert the new pointer into the head of the list
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}
//------------------------------------------------------------
int main(){
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for ( i = 0; i < n; i++ ){
	scanf("%s%d", com, &key);
	if ( com[0] == 'i' ) {insert(key); np++; size++;}
	else if ( com[0] == 'd' ) {
	    if (strlen(com) > 6){
		if ( com[6] == 'F' ) deleteFirst();
		else if ( com[6] == 'L' ) deleteLast();
	    } else {
		delete(key); 
	    }
	    size--;
	}
    }

    printList();
    return 0;
}



Measured memory_bytes: 32960
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))

int main() {
	int W, H, N;
	int x, y, a;

	int xMin, xMax, yMin, yMax;

	scanf("%d %d %d", &W, &H, &N);
	xMin = 0;
	xMax = W;
	yMin = 0;
	yMax = H;
	for (int i = 0; i < N; i++) {
		scanf("%d %d %d", &x, &y, &a);
		if (a == 1)xMin = MAX(x, xMin);
		else if (a == 2)xMax = MIN(x, xMax);
		else if (a == 3)yMin = MAX(y, yMin);
		else if (a == 4) yMax = MIN(y, yMax);
	}
  int height = MAX(xMax-xMin, 0);
  int width = MAX(yMax - yMin, 0);
	printf("%d", height * width);
	return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
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; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数,
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

//--------------入力受け取る場所----------------------------------------------------
intl x[5];

void input_var(){
    cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];
}
//-------------------------------------------------------------------------------


signed main(){
    cout << fixed << setprecision(10);
    input_var();
    if(x[0] == 0)cout << 1 << endl;
    else if(x[1] == 0)cout << 2 << endl;
    else if(x[2] == 0)cout << 3 << endl;
    else if(x[3] == 0)cout << 4 << endl;
    else cout << 5 << endl;
    return 0;
}


Measured memory_bytes: 3572
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

a = inpl()
cnt = 0
for i in a:
    if i%2:
        print(cnt)
        quit()
if a[0] == a[1] == a[2]:
    print(-1)
else:
    while True:
        for i in a:
            if i%2:
                print(cnt)
                quit()
        b = [0] * 3
        b[0] = (a[1] + a[2]) // 2
        b[1] = (a[0] + a[2]) // 2
        b[2] = (a[1] + a[0]) // 2
        cnt += 1
        a[::] = b[::]



Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define MEM 100001
#define sanic ios_base::sync_with_stdio(0)
using namespace std;
typedef long long ll;
const ll INF = 1e9+9;
ll a,b;
ll dp[MEM];
int main() {
    cin >> a >> b;
    fill(dp, dp+MEM, INF);
    dp[0] = 0;
    for(int i=0; i<b; i++){
        int q1, q2;
        cin >> q1 >> q2;
        for(int j=0; j<=a; j++){
            int f=max(0, j-q1);
            dp[j]=min(dp[j], dp[f]+q2);
        }
    }
    cout << dp[a];

}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var x = long.Parse(Console.ReadLine());

			long count = x / (6 + 5) * 2;

			if(x % (6 + 5) == 0)
			{

			}
			else if (x % (6 + 5) > 6)
			{
				count += 2;
			}
			else
			{
				count++;
			}

			Console.WriteLine(count);
        }
	}
}


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

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

using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
	
	int a;
	
	cin >> a;
	
	cout << a + a * a + a * a * a;
	
	return 0;
	
}


Measured memory_bytes: 3636
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib> 
#include <ctime>
#include <unordered_map>
using namespace std;
typedef long long ll;
int N, X[100004], K = 0; vector<pair<int, int>>E[100004];
void f(int u, int p, int c) {
	int i, v, x = 1, idx;
	K = max(K, (int)E[u].size());
	for (i = 0; i < E[u].size(); i++) {
		v = E[u][i].first; idx = E[u][i].second;
		if (v == p) continue;
		if (x == c) x++;
		X[idx] = x;
		f(v, u, x);
		x++;
	}
}
int main() {
	cin >> N;
	int i, a, b;
	for (i = 0; i < N - 1; i++) {
		cin >> a >> b;
		E[a].push_back({ b,i });
		E[b].push_back({ a,i });
	}
	f(1, -1, -1);
	cout << K << endl;
	for (i = 0; i < N - 1; i++) {
		cout << X[i] << endl;
	}
}

Measured memory_bytes: 9344
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    // 素集合データ構造
    struct UnionFind
    {
        // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
        vector<int> par;
        // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
        vector<int> sizes;

        UnionFind(int n) : par(n), sizes(n, 1)
        {
            // 最初は全てのデータiがグループiに存在するものとして初期化
            for (int i = 0; i < n; i++)
            {
                par[i] = i;
            }
        }

        // データxが属する木の根を得る
        int find(int x)
        {
            if (x == par[x])
                return x;
            return par[x] = find(par[x]); // 根を張り替えながら再帰的に根ノードを探す
        }

        // 2つのデータx, yが属する木をマージする
        void unite(int x, int y)
        {
            // データの根ノードを得る
            x = find(x);
            y = find(y);

            // 既に同じ木に属しているならマージしない
            if (x == y)
                return;

            // xの木がyの木より大きくなるようにする
            if (sizes[x] < sizes[y])
                swap(x, y);

            // xがyの親になるように連結する
            par[y] = x;
            sizes[x] += sizes[y];
            // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
        }

        // 2つのデータx, yが属する木が同じならtrueを返す
        bool same(int x, int y)
        {
            return find(x) == find(y);
        }

        // データxが含まれる木の大きさを返す
        int size(int x)
        {
            return sizes[find(x)];
        }
    };

    int N, M;
    cin >> N >> M;
    UnionFind uf(N);

    vector<int> p(N);
    for (int i = 0; i < N; i++)
    {
        cin >> p[i];
        p[i]--;
    }

    vector<pair<int, int>> x_y(M);
    for (int i = 0; i < M; i++)
    {
        cin >> x_y[i].first >> x_y[i].second;
        x_y[i].first--;
        x_y[i].second--;
    }

    for (int i = 0; i < x_y.size(); i++)
    {
        uf.unite(x_y[i].first, x_y[i].second);
    }

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if (uf.same(i, p[i]))
        {
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2176
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() int64 {
  sc.Scan()
  data, _ := strconv.ParseInt(sc.Text(), 10, 64)
  return data
}

func main() {
  var num = nextLine()
  args := []int64{nextLine(),nextLine(),nextLine(),nextLine(),nextLine()}

  var max = num / args[0]
  for _, arg := range args {
    var value = int64(math.Ceil(float64(num) / float64(arg)))
    if value > max {
      max = value
    }
  }
  fmt.Println(max + 4)
}



Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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 (b<a) { a=b; return 1; } return 0; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll all_wh(string &s){

  ll cnt=0;
  for(auto c:s){
    if(c!='.') cnt++;
  }
  return cnt;
}

ll all_bl(string &s){

  ll cnt=0;
  for(auto c:s){
    if(c!='#') cnt++;
  }
  return cnt;
}

ll change_bl(string &s,ll n){
  ll cnt=0;
  for(int i=n;i<s.size();i++){
    if(s[i]!='#') cnt++;
  }
  return cnt;
}

ll change_wh(string &s,ll n){

  ll cnt=0;
  for(int i=0;i<n;i++){
    if(s[i]!='.') cnt++;
  }
  return cnt;

}

int main(void){

  ll n;
  string s;
  cin>>n;
  cin>>s;

  ll f_wh=-1;
  ll f_bl=-1;
  ll af_wh=-1;
  ll sc_wh=-1;
  ll af_bl=-1;

  char pre='a';

  vector<ll> w;
  vector<ll> b;
  ll _w=0;
  ll _b=0;

  for(ll i=0;i<n;i++){

    

    //cout << pre << "," << s[i] << endl;
    if(f_wh==-1 && s[i]=='.') f_wh = i;
    if(f_bl==-1 && s[i]=='#') f_bl = i;

    if(pre=='#' && s[i]=='.' && af_wh==-1) af_wh=i;
    else if(pre=='#' && s[i]=='.' && af_wh!=-1) sc_wh=i;
    else if(pre=='.' && s[i]=='#' && af_bl==-1) af_bl=i;
    pre=s[i];
    if(s[i]=='.') _w++;
    else _b++;
    w.pb(_w);
    b.pb(_b);
  }

  //cout << f_wh << "," << f_bl << "," << af_wh << "," << af_bl << "," << sc_wh << endl;

  if(af_wh==-1){
    cout << 0 << endl;
    return 0;
  }
  else{
    ll ans=1LL<<20;
    ans=min(ans,all_bl(s));
    ans=min(ans,all_wh(s));
    
    if(sc_wh!=-1){
      rep(i,n){
        //cout << b[i]+(w[n-1]-w[i]) << endl;
        ans = min(ans, b[i]+(w[n-1]-w[i]) );
      }
    }
    
    cout << ans << endl;
  }

  return 0;

}


Measured memory_bytes: 3816
H, W, A, B = gets.split.map(&:to_i)

if A > W / 2 || B > H / 2
  puts 'No'
  exit 0
end

B.times do
  puts ((W - A).times.map { '1' } + A.times.map { '0'}).join
end
(H - B).times do
  puts ((W - A).times.map { '0' } + A.times.map { '1' }).join
end


Measured memory_bytes: 3324
/* Selection Sort */
#include <stdio.h>

int selectionSort(int* A, int N) { 
  int flag = 1; // 逆の隣接要素が存在する
  int counter = 0;
  int i;

  for (i=0; i<N; i++) {
    int j, minj = i;
    
    for(j=i; j<N; j++) {
      if (A[j] < A[minj])
	minj = j;
    }
    if (i != minj) {
      int tmp;
      tmp = A[i];
      A[i] = A[minj];
      A[minj] = tmp;
      counter++;
    }
  }
  
  return counter;
}

int main(void) {
  int A[100]; // 数列
  int N; // 数列の長さ
  int i;
  int count; // 交換回数
  
  scanf("%d", &N);

  // 数列読み込み
  for (i=0; i<N; i++)
    scanf("%d", &A[i]);

  count = selectionSort(A, N);

  for (i=0; i<N; i++) {
    printf("%d", A[i]);
    if (i != N-1)
      putchar(' ');
  }
  putchar('\n');

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

  return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  vector<int> S(m), C(m), D(n, -1);
  rep(i, m) {
    cin >> S[i] >> C[i];
    S[i]--;
    if(D[S[i]] == -1) D[S[i]] = C[i];
    else if(D[S[i]] != C[i]) {
      cout << -1 << "\n";
      return 0;
    }
  }
  if(n != 1 && D[0] == 0) {
    cout << -1 << "\n";
    return 0;
  }
  ll ans = 0;
  rep(i, n) {
    if(D[i] == -1) {
      if(n == 1) D[i] = 0;
      else if(i == 0) D[i] = 1;
      else D[i] = 0;
    }
    ans += D[i] * pow(10, n-1-i);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3780
#include"bits/stdc++.h"

int main (int, char**) {
    int N, X, Y;
    std::cin >> N >> X >> Y;
    int count[N-1];
    for (int i=0; i<N-1; i++) {
        count[i] = 0;
    }

    for (int i=0; i<N-1; i++) {
        int distance[N];
        for (int k=0; k<N; k++) {
           distance[k] = std::abs(k -i);
        }

        int min_distance[N];
        for (int k = 0; k<N; k++) {
            int dist = distance[X-1] + 1 + std::abs((Y - 1) - k);
            min_distance[k] = std::min(distance[k], dist);
        
        }
        for (int j=i+1; j<N; j++) {
            int dist;
            if (min_distance[i] == min_distance[j]) dist = 1;
            else dist = std::abs(min_distance[i] - min_distance[j]);
            count[dist - 1] += 1;
        }
    }

 
    for (int i=0; i<N-1; i++) {
        std::cout << count[i] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<queue>
#include<string.h>
const int maxk=100001;
using namespace std;
int main()
{
    char s[maxk];
    scanf("%s",s);
    int ans=0;
    char stand=s[0];
    for(int i=1;i<strlen(s);i++)
    {
        if(stand==s[i])
        {
            continue;
        } else{
            ans++;
            stand=s[i];
        }
    }
    cout<<ans;


}

Measured memory_bytes: 384
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
ll n;
vector<ll> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        ll temp;
        cin >> temp;
        a.push_back(temp);
    }
    bool dp[n+1][3];
    int now[3];
    now[0]=0;
    now[1]=0;
    now[2]=0;
    memset(dp,-1,sizeof dp);
    dp[0][0]=1;
    dp[0][1]=1;
    dp[0][2]=1;
    ll ans=1;
    for(int i=1;i<=n;i++){
        ll count=0;
        ll c;
        for(int j=0;j<3;j++){
            if(now[j]==a[i-1]){
                count++;
                c=j;
            }
        }
        ans*=count;
        ans%=MOD;
        now[c]++;
    }
    cout << ans << "\n";
}



Measured memory_bytes: 1524
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int a, b;
    cin >> a >> b;
    int res{};
    for( int i = a; i <= b; ++i )
    {
        string A = to_string( i ), B = to_string( i );
        reverse( ALL( B ) );
        if( equal( ALL( A ), ALL( B ) ) )
        {
            ++res;
        }
    }
    cout << res << endl;
}

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

long long int arr[200001];

int main() {
	long long int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	long long int ans=0;
	for(int i=1;i<n;i++){
		if(arr[i-1]>arr[i]){
			int x=arr[i-1]-arr[i];
			arr[i]+=x;
			ans+=x;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 5156
#include <bits/stdc++.h>
#define ll long long
#define MAX_N 100
using namespace std;

int main(){
    int n;
    cin>>n;
    int a[n];
    set<int>st;
    for(int i = 0; i<n; i++){
        cin>>a[i];
        st.insert(a[i]);
    }

    int st_size = st.size();

    cout<< st_size <<endl;
}

Measured memory_bytes: 256
s = input()
K = int(input())
S = set()

for i in range(len(s)):
    S.add(s[i])
    for j in range(i+1, K+i+1):
        ss = ''
        if j >= len(s):
            continue
        ss = s[i] + s[i+1:j+1]
        S.add(ss)
        
S = list(S)
S.sort()

print(S[K-1])


Measured memory_bytes: 4848
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  int n;cin>>n;
  map<string,ll> mp;
  for(int i=0;i<n;++i){
    string s;
    cin >> s;
    std::vector<string> tmp;
    for(int j=0;j<10; ++j){
      tmp.push_back(s.substr(j,1));
    }
    sort(all(tmp));
    string out ="";
    for(int j=0;j<10; ++j){
      out += tmp[j];
    }
    if(mp.find(out) != mp.end()){
      mp[out] += 1LL;
    } else {
      mp[out] = 1LL;
    }
  }
  ll cnt=0;
  for(auto itr = mp.begin();itr != mp.end();++itr){
    if(itr->second == 1) continue;
    cnt += (itr->second)*(itr->second - 1LL)/2LL;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 12800
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int iniNum, RiNum;
        iniNum = scan.nextInt();
        int buyPrice=1000000001, maxProfit=-1000000001;
        
        for(int i=0; i<iniNum; i++){
            RiNum = scan.nextInt();

            maxProfit= i==0? -1000000000: Math.max(maxProfit,RiNum-buyPrice);
            buyPrice=Math.min(buyPrice,RiNum);

        }
        System.out.println(maxProfit);            
    }
}


Measured memory_bytes: 98496
import math

while True:
    x = int(input())
    # x = 5
    if x==0:
        break
    data = list(map(float, input().split()))
    # data = list(map(float, '70 80 100 90 20'.split()))
    average = sum(data)/x
    temp = 0
    for d in data:
        temp += math.pow(d - average, 2)
        # print(math.pow(d - average, 2))
    stdev = math.sqrt(temp / x)
    print(stdev)


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
 
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)
template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long mod(long long a, long long b) { return (a%b+b)%b; }
long long gcd(long long x, long long y) { return __gcd(x, y); }
long long lcm(long long x, long long y) { return x * 1ll * y / gcd(x, y); }
 
 
const long long MAXN = 1e9 + 9;
const long long SIZE = 3e5 + 5;
const long long MOD = 1e9 + 7;

long long X, K, D;

int main() { speedhack()

	cin >> X >> K >> D;

	X = abs (X);

	long long d = X / D;


	if (d >= K) {
		X -= K * D;
		cout << X << endl;
	} else {
		X -= d * D;
		K -= d;
		if (K % 2) {
			cout << min (abs(X - D), abs(X + D)) << endl;
		} else cout << X << endl;
			
	}
	return 0;
}

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

#define int long long

using namespace std;

const int MOD = 1e9+7;

#ifdef LOCAL 
#include "/media/brayand/7801-B00D/debugger.h"
#else
template<typename... Args>
void db(Args... args){}
#endif

int qpow(int a, int b)
{
	int res = 1;
	while(b)
	{
		if(b&1)res = res*a%MOD;
		a = a*a%MOD;
		b /= 2;
	}
	return res;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int N;
    cin >> N;

    vector<int> vect;

    for(int i = 0 ; i < N ; i++)
    {
    	int n;
    	cin >> n;
    	vect.push_back(n);
    }

    sort(vect.begin(),vect.end());

    int res = 0;

    for(int i = 0 ; i < N ; i++)
    {
    	int tam = N-i;
    	int val = vect[i];
    	val %= MOD;
    	val *= qpow(4,i);
    	val %= MOD;
    	val *= qpow(2,tam);
    	val %= MOD;
    	val *= (tam*qpow(2,tam-1)%MOD+MOD-(tam-1)*qpow(2,tam-2)%MOD)%MOD;
    	val %= MOD;
    	
    	res = (res+val)%MOD;
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 2420
n = input()
a = [int(x) for x in input().split(" ")]
b = [int(x) for x in input().split(" ")]

negatives = 0
positives = 0

for aa, bb in zip(a,b):
    if aa - bb < 0:
        negatives += (bb-aa)//2*2
    else:
        positives += aa-bb

if negatives >= 2*positives:
    print("Yes")
else:
    print("No")



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

int main(){
	int x, y;
	scanf("%d%d", &x, &y);
	if (!x){
		printf("%d\n", y > 0 ? y : -y + 1);
		return 0;
	}
	if (!y){
		printf("%d\n", x < 0 ? -x : x + 1);
		return 0;
	}
	if (x > 0 && y > 0 || x < 0 && y < 0){
		printf("%d\n", x > y ? x - y + 2 : y - x);
		return 0;
	}
	printf("%d\n", std::abs(std::abs(x) - std::abs(y)) + 1);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int n,m,nf,ne,s,d;scanf("%d%d%d%d%d%d",&n,&m,&nf,&ne,&s,&d),n|m|nf|ne|s|d;){ // 頂点数,何分保つか,冷凍施設数,辺数,首都の番号,病院の番号
		vi fs(nf);
		rep(i,nf) scanf("%d",&fs[i]);
		vvi dp(n,vi(n,INFTY));
		rep(i,n) dp[i][i]=0;
		rep(i,ne){
			int a,b,t; scanf("%d%d%d",&a,&b,&t);
			dp[a][b]=dp[b][a]=t;
		}
		
		rep(k,n) rep(i,n) rep(j,n)
			dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
		
		vvi dp2(n,vi(n,INFTY));
		rep(i,n) dp2[i][i]=0;
		dp2[s][d]=dp[s][d]<=m?dp[s][d]:INFTY;
		rep(i,nf){
			dp2[s][fs[i]]=dp[s][fs[i]]<=m?dp[s][fs[i]]:INFTY;
			dp2[fs[i]][d]=dp[fs[i]][d]<=m?dp[fs[i]][d]:INFTY;
			rep(j,nf)
				dp2[fs[i]][fs[j]]=dp[fs[i]][fs[j]]<=m?dp[fs[i]][fs[j]]:INFTY;
		}
		
		rep(k,n) rep(i,n) rep(j,n)
			dp2[i][j]=min(dp2[i][j],dp2[i][k]+dp2[k][j]);
		
		if(dp2[s][d]==INFTY)
			cout<<"Help!"<<endl;
		else
			cout<<dp2[s][d]+max(dp2[s][d]-m,0)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1312
import sys
input = sys.stdin.readline
import collections
N = int(input())
a = [int(x) for x in input().split()]
c = collections.Counter(a)
X = -100
X_c = 0
for i in range(min(a) - 1, max(a) + 2):
    temp = c[i-1] + c[i] + c[i+1]
    if temp >= X_c:
        X = i
        X_c = temp
print(X_c)


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

int main()
{
    set<int> s[3];
    s[0].insert(1);
    s[0].insert(3);
    s[0].insert(5);
    s[0].insert(7);
    s[0].insert(8);
    s[0].insert(10);
    s[0].insert(12);
    s[1].insert(4);
    s[1].insert(6);
    s[1].insert(9);
    s[1].insert(11);
    s[2].insert(2);
    

    int x, y;
    bool is_found = false;
    cin >> x >> y;
    for(int i = 0; i < 2; i++){
	    if(s[i].find(x) != s[i].end() && s[i].find(y) != s[i].end()){
		    is_found = true;
	    }
    }
    if(is_found){
	    cout << "Yes" << endl;
    }else{
	    cout << "No" << endl;
    }

    return 0;
}


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

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		long a=in.nextLong();
		long b=in.nextLong();
		long k=in.nextLong();
		if(k>=a)
		{
			k=k-a;
			a=0;
		}
		else
		{
			a=a-k;
			k=0;
		}
		if(k>b)
		{
			b=0;
		}
		else
		{
			b=b-k;
		}
		System.out.println(a+" "+b);
	}
}
	

Measured memory_bytes: 23252
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iostream>
#include<map>
#include<cstring>
#define INF 0x3f3f3f3f
using namespace std;
set<int>pf;
map<int,int>deg;
void gf(int x){
    for(int i=2;i<=x;i++){
        deg[i]=0;
        while(x%i==0){
            pf.insert(i);
            x/=i;
            deg[i]++;
        }
    }
    return;
}
int n,nw,nr,con=1,ans;
char c[200005],f;
int main(){
    scanf("%d",&n);
    for(int i=0;i<=n;i++){
        scanf("%c",&c[i]);
        if(c[i]=='W')
            nw++;
        else if(c[i]=='R')
            nr++;
    }
    for(int i=1;i<=n;i++){
        if(c[i]=='R')
            nr--;
        else if(c[i]=='W'&&nr>0){
            nr--;
            ans++;
        }
        if(nr==0)
            break;
    }
    printf("%d",ans);
}

Measured memory_bytes: 3416
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int DX[] = {0, 1, 0, -1};
const int DY[] = {-1, 0, 1, 0};


//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(int argc, char const *argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int w, n;
	int index = 1;
	while(true){
		cin >> w;
		if(w == 0) break;
		cin >> n;
		VVI dp(n + 1, VI(w + 1));
		char comma;
		VI values(n);
		VI weights(n);
		REP(i, n){
			cin >> values[i] >> comma >> weights[i];
		}
		REP(i, n){
			REP(j, w + 1){
				if(j + weights[i] <= w){
					int &value = dp[i + 1][j + weights[i]];
					 value = max(value, values[i] + dp[i][j]);
				}
				dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
			}
		}
		int weight = max_element(ALL(dp[n])) - dp[n].begin();
		int value_sum = dp[n][weight]; 
		cout << "Case " << index << ":" << endl;
		cout << value_sum << endl;
		cout << weight << endl;

		index++;
	}



	return 0;
}

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

typedef pair<int, int> P;

int main() {
    int N;
    cin >> N;
    vector<P> tasks(N);
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        tasks[i] = P(b, a);
    }
    sort(tasks.begin(), tasks.end());
    long long time = 0;
    for (int i = 0; i < N; i++) {
        P p = tasks[i];
        time += p.second;
        if (time > p.first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1ll << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return -1;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll A, B;
    cin >> A >> B;
    vector<string> field(100);
    string pre;
    loop(i, 100) pre += '.';
    loop(i, 100) field[i] = pre;
    loop(i, 50) loop(j, 100) field[i][j] = '#';
    ll x = 0, y = 0;
    loop(i, A - 1)
    {
        field[x][y] = '.';
        x += 2;
        if (x >= 45)
        {
            y += 2;
            x = 0;
        }
    }
    x = 53, y = 0;
    loop(i, B - 1)
    {
        field[x][y] = '#';
        x += 2;
        if (x >= 96)
        {
            y += 2;
            x = 53;
        }
    }
    cout << 100 << " " << 100 << endl;
    loop(i, 100) putout(field[i]);
    return 0;
}


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

int gcd(int m,int n)
{
	if(n==0)
		return m;
		
	return gcd(n,m%n);
}

int main()
{
	while(true){
		int a,b;
		cin>>a>>b;
		
		if(cin.eof())
			break;
			
		int g=gcd(a,b);
		cout<<g<<' '<<a/g*b<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3100
#https://atcoder.jp/contests/abc085/tasks/abc085_d
import math
N, H = map(int, input().split(' '))
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split(' '))
    A.append(a)
    B.append(b)
max_A = max(A)
B = sorted(B, reverse=True)
ans = H
for k in range(N):
    H -= B[k]
    if H > 0:
        cnt = math.ceil(H / max_A) + (k + 1)
    else:
        cnt = k + 1
    ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int a[7];
    int b[7]; 	
	int n;
	int i,j;
	for(i=1;i<7;i++){
		cin>>a[i];
		b[i]=a[i];
	}
	cin>>n;
	int wk;
	int x,y;
	int ans[25];
	for(int k=0;k<n;k++){
		cin>>x>>y;
		for(i=0;i<6;i++){
			for(j=1;j<7;j++){
				a[j]=b[j];
			}
			if(i==0){}
			else if(i==1){
				swap(a[1],a[5]);
				swap(a[1],a[6]);
				swap(a[1],a[2]);
			}
			else if(i==2){
				swap(a[1],a[2]);
				swap(a[1],a[6]);
				swap(a[1],a[5]);
			}
			else if(i==3){
				swap(a[1],a[4]);
				swap(a[1],a[6]);
				swap(a[1],a[3]);
			}
			else if(i==4){
				swap(a[1],a[3]);
				swap(a[1],a[6]);
				swap(a[1],a[4]);
			}
			else{
				swap(a[1],a[4]);
				swap(a[1],a[6]);
				swap(a[1],a[3]);
				swap(a[1],a[4]);
				swap(a[1],a[6]);
				swap(a[1],a[3]);
			}
			for(j=0;j<4;j++){
				wk=a[2];
				a[2]=a[4];
				a[4]=a[5];
				a[5]=a[3];
				a[3]=wk;
				
				if(a[1]==x&&a[2]==y){
					ans[k]=a[3];
				}
			}
		}
	}
	for(i=0;i<n;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3080
n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]

def doit(index, fora, forb, forc):
    if index == len(l):
        if min(fora, forb, forc) > 0:
            return abs(fora - a) + abs(forb - b) + abs(forc - c)
        else:
            return 10000
    return min(doit(index + 1, fora, forb, forc),
               doit(index + 1, fora + l[index], forb, forc) + 10,
               doit(index + 1, fora, forb + l[index], forc) + 10,
               doit(index + 1, fora, forb, forc + l[index]) + 10)

print(doit(0, 0, 0, 0) - 30)

Measured memory_bytes: 43996
#include <iostream>
#include <utility>
#include <vector>
#include <cstdio>
#include <algorithm>
using namespace std;

bool great( const pair<int,double>& left, const pair<int,double>& right ) {
    return left.second < right.second;
}

int main(){
	int n;
	double t;
	vector<pair<int,double> > v1,v2;
	for(int j = 0;j < 3;j++){
		for(int i = 0;i < 8;i++){
			cin >> n >> t;
			v1.push_back(make_pair(n,t));
		}
		sort(v1.begin(),v1.end(),great);
		printf("%d %.2f\n%d %.2f\n",v1[0].first,v1[0].second,v1[1].first,v1[1].second);
		for(int k = 2;k < 8;k++) v2.push_back(v1[k]);
		v1.clear();
	}
	sort(v2.begin(),v2.end(),great);
	printf("%d %.2f\n%d %.2f\n",v2[0].first,v2[0].second,v2[1].first,v2[1].second);
	return 0;
}

Measured memory_bytes: 1256
#include <stdio.h>
long long p = 998244353;
long long n, m, k, ans, c;
long long inv[200005];
long long rui[200005];
void makeinv(void) {
	long long arraynumber = sizeof inv / sizeof inv[0];
	inv[1] = 1;
	for (int invcount = 2; invcount < arraynumber; invcount++) {
		inv[invcount] = p - inv[p % invcount] * (p / invcount) % p;
	}
}
int main() {
	makeinv();
	scanf("%lld%lld%lld", &n, &m, &k);
	rui[0] = 1;
	for (int i = 1; i < 200005; i++) {
		rui[i] = rui[i - 1] * (m - 1);
		rui[i] %= p;
	}
	c = 1;
	ans = rui[n - 1];
	for (int i = 1; i <= k; i++) {
		c *= (n - i);
		c %= p;
		c *= inv[i];
		c %= p;
		ans += c * rui[n - 1 - i];
		ans %= p;
	}
	printf("%lld\n", ans * m % p);
}

Measured memory_bytes: 4860
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;
int n,k;
llong T[MAX];


int check(llong p){
  int i=0;
  for(int j=0;j<k;j++){
    llong s =0;
    while(s+T[i]<=p){
      s+=T[i];
      i++;
      if(i==n) return n;
    }
  }
  return i;
}


int solve(){
  llong l=0;
  llong r=100000*10000;
  llong m;
  while(r-l>1){
    m=(l+r)/2;
    int v=check(m);
    if(v>=n) r=m;
    else l=m;
  }

  return r;
}


main(){
  
  cin >> n >> k;
  for(int i=0;i<n;i++) cin >> T[i];
  llong ans =solve();
  cout << ans << endl;
}



Measured memory_bytes: 3884
s = int(input())
result_list=[s]
i=1
while len(set(result_list))==len(result_list):
    i+=1
    if(s%2==0):
        out = int(s/2)
        result_list.append(out)
        s = out
    else:
        out = int(3*s + 1)
        result_list.append(out)
        s=out

print(i)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a==b&&b!=c)||(a==c&&a!=b)||(b==c)&&(b!=a))
    cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

using ll = long long;

const ll INF = 1LL << 60;

int main() {
    ll N, X;
    cin >> N >> X;

    ll sum[N + 1];
    sum[0] = 0;
    for (int i = 1; i <= N; ++i) {
        ll x;
        cin >> x;
        sum[i] = sum[i - 1] + x;
    }

    ll ans = INF;
    for (ll t = 1; t <= N; ++t) {
        // ゴミ捨てとゴミ拾いに消費するエネルギー
        ll cost = (N + t) * X;

        ll now = N;  // 右端

        cost += sum[now] * 5;
        now -= t * 2;
        while (now > 0) {
            cost += sum[now] * 2;
            now -= t;

            // オーバーフロー対策
            if (cost < 0) {
                cost = INF;
                break;
            }
        }
        ans = min(ans, cost);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main(void)
{
	int n,i,ans=0;
	int v[20];
	int c[20];
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
		scanf("%d",&v[i]);
	for(i=0;i<n;i++)
		scanf("%d",&c[i]);
	for(i=0;i<n;i++){
		if(v[i]-c[i]>0)
			ans+=v[i]-c[i];
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long int
#define M 1000000007
#define pb push_back
#define pf push_front
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
const int INF = 1e18L+5;
const int LG = 20;
const int N = 1e5+9;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int power(int x,int y){int res=1;while(y>0){if(y%2==1)res=(res*x)%M;x=(x*x)%M;y=y/2;}return res;}
bool isvowel(char c){if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u' || c=='A' || c=='E' || c=='I' || c=='O' || c=='U')return true;return false;}
int32_t main()
{
	//cout.precision(15);
	//cout.setf(ios::fixed,ios::floatfield);
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int T=1;
	//cin>>T;
	while(T--)
	{
		int i,n,ans=0;
		cin>>n;
		string s[n];
		map<string,int> mp;
		for(i=0;i<n;i++)
		{
			cin>>s[i];
			if(mp[s[i]]==0)
			ans++;
			mp[s[i]]++;
		}
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 25456
using System;

class program
{
    public static int Main()
    {
        bool flag = true;

        while (flag)
        {
            var str = Console.ReadLine();
            var a = int.Parse(str.Split(' ')[0]);
            var op = str.Split(' ')[1];
            var b = int.Parse(str.Split(' ')[2]);
            switch (op)
            {
                case "+":
                    Console.WriteLine(a + b);
                    break;
                case "-":
                    Console.WriteLine(a - b);
                    break;
                case "*":
                    Console.WriteLine(a * b);
                    break;
                case "/":
                    Console.WriteLine(a / b);
                    break;
                case "?":
                    flag = false;
                    break;
            }
        }
        return 0;
    }
}

Measured memory_bytes: 5708
import scala.io.Source

object Main extends App {
  val src = Source.stdin.getLines
  val org_dice = src.next.split(" ").map(_.toInt).toList
  val directions = src.next

  def sDirection(dice: List[Int]) = List(dice(4), dice(0), dice(2), dice(3), dice(5), dice(1))
  def nDirection(dice: List[Int]) = List(dice(1), dice(5), dice(2), dice(3), dice(0), dice(4))
  def wDirection(dice: List[Int]) = List(dice(2), dice(1), dice(5), dice(0), dice(4), dice(3))
  def eDirection(dice: List[Int]) = List(dice(3), dice(1), dice(0), dice(5), dice(4), dice(2))

  def roll(dice: List[Int], direction: Char): List[Int] = {
    if (direction == 'N') nDirection(dice)
    else if (direction == 'S') sDirection(dice)
    else if (direction == 'E') eDirection(dice)
    else wDirection(dice)
  }

  println(directions.foldLeft(org_dice)(roll).head)
}

Measured memory_bytes: 44256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;

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

template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==v.size()?"":" ");
    return os;
}

ll r,c,n;

inline bool online(ll x,ll y){
    return x==0 or x==r or y==0 or y==c;
}

ll parse(ll x,ll y){
    if(y==0) return x;
    if(x==r) return r+y;
    if(y==c) return 2*r+c-x;
    return 2*r+2*c-y;
}

signed main(){
    cin>>r>>c>>n;
    vector<pair<ll,int>> v;
    rep(i,n){
        ll x,y,z,w;cin>>x>>y>>z>>w;
        if(online(x,y) and online(z,w)){
            v.push_back({parse(x,y),i});
            v.push_back({parse(z,w),i});
        }
    }
    sort(ALL(v));

    stack<int> st;
    for(auto p:v){
        if(st.empty()){
            st.push(p.second);continue;
        }
        if(st.top()==p.second) st.pop();
        else st.push(p.second);
    }
    cout<<(st.empty()?"YES":"NO")<<endl;
    return 0;
}


Measured memory_bytes: 7396
package main

import "fmt"

func main()  {
	var H,W,N,max int
	fmt.Scan(&H,&W,&N)
	if H > W {
		max = H
	} else {
		max = W
	}
	if N%max != 0 {
		fmt.Println(N/max+1)
	} else {
		fmt.Println(N/max)
	}

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,x,n) for(long i=long(x);i<long(n);i++)
int main() 
{
    //ifstream cin("input.in");
    //ofstream cout("output.out");
    ios::sync_with_stdio(0);cin.tie(0);
    long n,m,x,y;
    set<long> O,N;
    for(cin>>n>>m;m--;)
    {
        cin>>x>>y;
        if(x==1)
            O.insert(y);
        else if(y==1)
            O.insert(x);
        if(x==n)
            N.insert(y);
        else if(y==n)
            N.insert(x);
    }
    for(auto i:O)
        if(N.find(i)!=N.end()){
            cout<<"POSSIBLE";
            return 0;
        }
    cout<<"IMPOSSIBLE";
    return 0;
}

Measured memory_bytes: 9600
#include <stdio.h>

#define MAX 100005
#define NIL -1

typedef struct { int p, l, r;} Node;

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if( T[u].p == NIL ) printf("root, ");
  else if( T[u].l == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i=0, c=T[u].l; c != NIL; i++, c=T[c].r) {
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

void rec(int u, int p) {
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r,p);
  if(T[u].l != NIL) rec(T[u].l,p+1);
}

int main(void) {
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;
  for(i=0;i<n;i++) {
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++) {
      scanf("%d",&c);
      if(j==0) T[v].l=c;
      else T[l].r =c;
      l = c;
      T[c].p = v;
    }
  }
  for(i=0;i<n;i++) {
    if(T[i].p == NIL) r = i;
  }
  
  rec(r,0);
  
  for(i=0;i<n;i++) print(i);
  
  return 0;
}


Measured memory_bytes: 6396
using System;
using System.Numerics;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
      string[] str=Console.ReadLine().Split(' ');
    BigInteger H=BigInteger.Parse(str[0]);
    BigInteger T=BigInteger.Parse(str[1]);
	BigInteger seki=H*T;
    if(H==1||T==1){
      Console.WriteLine(1);
    }else{
     if((seki)%2==0){
       
      Console.WriteLine(seki/2);
     }else{
       Console.WriteLine((seki/2)+1);
     }
    }
    }
    
  }

}

Measured memory_bytes: 27636