akhauriyash/Code-Regression huggingface dataset:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

K = INT()

q = [str(i) for i in range(1, 10)]
q = deque(q)
# print(q)

l = []
while len(l) != K:
    a = q.popleft()
    l.append(a)
    for i in range(0, 10):
        last = int(a[-1])
        b = deepcopy(a)
        if last == 0:
            if i == 1 or i == 0:
                b = b + str(i)
                q.append(b)
        elif last == 9:
            if i == 8 or i == 9:
                b = b + str(i)
                q.append(b)
        else:
            if last - 1 <= i <= last + 1:
                b = b + str(i)
                q.append(b)
        
        # print(q)
        # exit()
print(l[-1])

Measured memory_bytes: 123772
#include<stdio.h>

int main(){
	
	int a=1000,b,ans=0;
	
	while(1){
		scanf("%d",&b);
		if(b==0)break;
		else{
			a=1000,ans=0;
			a=a-b;
			while(a>=500){
				ans+=1;
				a-=500;
			}
			while(a>=100){
				ans+=1;
				a-=100;
			}
			while(a>=50){
				ans+=1;
				a-=50;
			}
			while(a>=10){
				ans+=1;
				a-=10;
			}
			while(a>=5){
				ans+=1;
				a-=5;
			}
			while(a>=1){
				ans+=1;
				a-=1;
			}
			printf("%d\n",ans);
		}
	}
	 
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N, C; 
  cin >> N >> C;

  vector<vector<int>> D(C, vector<int>(C));
  REP(i, C) REP(j, C) cin >> D[i][j];

  vector<vector<int>> c(N, vector<int>(N));
  REP(i, N) REP(j, N) cin >> c[i][j];


  vector<vector<int>> vec(3, vector<int>(C, 0));
  REP(i, N) REP(j, N){
    vec[(i+j)%3][c[i][j]-1]++;
  }

  int ans = INF;
  REP(i, C) REP(j, C) REP(k, C){
    if(i == j || j == k || k == i) continue;
    int ret = 0;
    REP(y, C){
      ret += vec[0][y]*D[y][i];
      ret += vec[1][y]*D[y][j];
      ret += vec[2][y]*D[y][k];
    }
    chmin(ans, ret);
  }

  cout << ans << endl;

  return 0;
}

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

int n, x;
int l[100];

int main() {
	int i;
	
	cin >> n >> x;
	for (i = 0; i < n; i++) cin >> l[i];
	
	int sumL = 0;
	for (i = 0; i < n; i++) {
		sumL += l[i];
		if (sumL > x) break;
	}
	cout << i + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
 int n,i,max,min;
 scanf("%d",&n);
 int a[n];
 for(i=0;i<n;i++){
  scanf("%d",&a[i]);
 }
 max=min=a[0];
 for(i=1;i<n;i++){
  if(a[i]<min) min=a[i];
  if(a[i]>max) max=a[i];
 }
 printf("%d\n",max-min);
 return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 1000000007
int main(){
  int a,b;cin>>a>>b;
  int ans=0;
  if(a>b){ans+=a;a--;}
  else{ans+=b;b--;}
  ans+=max(a,b);
  cout<<ans<<endl;

}


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

int dp[105][4][2];

int main()
{
  string s; cin >> s;
  int n = s.size();
  int K; cin >> K;
  dp[0][0][0] = 1;
  rep(i, n) {
    rep(j, 4) {
      rep(k, 2) {
        int nd = s[i] - '0';
        rep(d, 10) {
          int ni = i + 1;
          int nj = j;
          int nk = k;
          if (d != 0) nj++;
          if (nj > K) continue;
          if (k == 0) {
            if (d > nd) continue;
            if (d < nd) nk = 1;
          }
          dp[ni][nj][nk] += dp[i][j][k];
        }
      }
    }
  }
  int ans = dp[n][K][0] + dp[n][K][1];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
A=int(input())
B=int(input())
C=int(input())
X=int(input())
res=0
for i in range(A+1):
	for j in range(B+1):
		for k in range(C+1):
			if 500*i + 100*j +50*k ==X:
				res+=1
print(res)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;


void solve(){
    int n, k;
    cin >> n >> k;
    int ans = 1;
    while (n--) {
        if(2 * ans < ans + k) ans *= 2;
        else ans += k;
    }
    cout << ans;
}
int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Long[] a = new Long[n];
        Arrays.setAll(a, i -> Long.parseLong(sc.next()));
        sc.close();

        // 主処理
        PriorityQueue<Long> pq = new PriorityQueue<>(Collections.reverseOrder());
        pq.addAll(Arrays.asList(a));
        List<Long> list = new ArrayList<>();
        while (list.size() < 2 && 1 < pq.size()) {
            long max = pq.poll();
            long second = pq.peek();
            if (max == second) {
                list.add(pq.poll());
            }
        }
        long result = 0;
        if (2 <= list.size()) {
            result = list.get(0) * list.get(1);
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 51188
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define len(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "YES" << endl
#define pyes cout << "Yes" << endl
#define POK cout << "OK" << endl
#define PNO cout << "NO" << endl
#define pno cout << "No" << endl
#define PNG cout << "NG" << endl
#define ret return 0

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>

signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  cin >> n;
  map<string, int> res;
  res["AC"] = 0;
  res["WA"] = 0;
  res["TLE"] = 0;
  res["RE"] = 0;
  rep(i, n) {
    string s;
    cin >> s;
    res[s]++;
  }
  cout << "AC x " << res["AC"] << endl;
  cout << "WA x " << res["WA"] << endl;
  cout << "TLE x " << res["TLE"] << endl;
  cout << "RE x " << res["RE"] << endl;

  ret;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = INT_MAX / 2;

int main() {
    int H, W; cin >> H >> W;
    vector<vector<bool>> m(H, vector<bool>(W));
    vector<vector<int>> dist(H, vector<int>(W,INF));
    ll bcnt = 0;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            char c; cin >> c;
            if(c=='#'){
                m[i][j] = false;
                bcnt++;
            } 
            else m[i][j] = true;
        }
    }

    queue<pair<int,int>> pos;
    pos.push(make_pair(0, 0));
    dist[0][0] = 0;

    const int dx[] = {1, -1, 0, 0};
    const int dy[] = {0, 0, 1, -1};
    while (!pos.empty())
    {
        auto from = pos.front();
        pos.pop();
        for (size_t i = 0; i < 4; i++)
        {
            auto to = make_pair(from.first + dy[i], from.second + dx[i]);
            if(to.first<0 || to.first>H-1 || to.second<0 || to.second>W-1) continue;
            if(m[to.first][to.second] != true || dist[to.first][to.second] != INF) continue;
            dist[to.first][to.second] = dist[from.first][from.second] + 1;
            pos.push(to);
        }    
    }
    if(dist[H-1][W-1]!=INF){
        cout << H*W - bcnt - dist[H-1][W-1] - 1 << endl;
    } else {
        cout << -1 << endl;
    }

}

Measured memory_bytes: 256
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;

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

	ll ans = 1;
	while (1) {
		ll num = X * pow(2, ans);
		if (num > Y) break;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N = ni()
    N match {
      case 1 =>
        out.println("Hello World")
      case 2 =>
        val A, B = ni()
        out.println(A + B)
    }
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int): Array[Int] = map(n)(_ => ni())
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    rep(as.length)(i => s += as(i))
    s
  }
}

Measured memory_bytes: 25424
#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <stack>
#include <string>
#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;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, nuint_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define int long long
#define MOD 1000000007
#define what_is(x) cerr << #x << " is " << x << endl;
#define loop(i,a,n) for(int i=a;i<n;i++)

#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, szof(x))
#define sortall(x) sort(aint(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int, int> pt;

signed main() {
	
	fastio();
	//#define LOCAL_DEFINE
	#ifdef LOCAL_DEFINE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	int a,b,c;
	cin>>a>>b>>c;
	if(a>b)
		swap(a,b);
	if(a<=c && c<=b)
	{
		cout<<"Yes"<<endl;
	}else{
		cout<<"No";
	}
	return  0;

}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
s = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        for k in range(j, n):
            if (l[i] == l[j]) | (l[j] == l[k]) | (l[i] == l[k]):
                continue
            if l[i] + l[j] <= l[k]:
                continue
            if abs(l[i]- l[j]) >= l[k]:
                continue
            s += 1
print(s)

Measured memory_bytes: 68248
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t a,b,c;
  cin >>a>>b>>c;
  
    if(c>(a+b)&&4*a*b<(c-a-b)*(c-a-b)){
    cout <<"Yes"<<endl;
  }
  else{
    cout <<"No"<<endl;
  }
  }
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define cases int t; cin >> t; while (t--)
using namespace std;

int main()
{
    ll n; cin >> n;
    ll ans; cin >> ans;
    ll a[n-1]; 
    for (int i = 0; i < n-1; i++)
    {
        cin >> a[i];
        ans = __gcd(ans, a[i]);
    }
    cout << ans << endl;
    return 0;
}

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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/2;
const ll MOD = 1e9+7;
const double EPS=1e-12;

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;cin>>S;
  if(S[0]==S[1]){
    cout<<(S[2]==S[3]&&S[0]!=S[2]? "Yes":"No")<<endl;
  }else if(S[0]==S[2]){
    cout<<(S[1]==S[3]? "Yes":"No")<<endl;
  }else if(S[0]==S[3]){
    cout<<(S[1]==S[2]? "Yes":"No")<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#East[north][top] -> E
class Dice():
 East = [ [0,3,5,2,4,0]
		 ,[4,0,1,6,0,3]
		 ,[2,6,0,0,1,5]
		 ,[5,1,0,0,6,2]
		 ,[3,0,6,1,0,4]
		 ,[0,4,2,5,3,0]
		 ]
 def __init__(self,N):
  self.label = N
  self.top = 1
  self.north = 5
 def move(self,ori):
  #print(self.top,self.north,ori)
  if ori=='S':
   t = self.top
   self.top = self.north
   self.north = 7-t
  elif ori=='N':
   t = self.top
   self.top = 7-self.north
   self.north = t
  elif ori=='E':
   east = self.East[self.north-1][self.top-1]
   self.top = 7-east
  elif ori=='W':
   east = self.East[self.north-1][self.top-1]
   self.top = east
 def gettop(self):
  return( self.label[self.top-1] )
  

label = list(map(int, input().split() ))
D = Dice(label)
q = int(input())
for qi in range(q):
 t,s = list(map(int, input().split() ))
 t = D.label.index(t)
 s = D.label.index(s)
 n = 5-s
 e = D.East[n][t]
 print(label[e-1])



Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
#define int long long int
const int MOD=1e9+7;
vector<int> white,black;
vector< vector<int> > adj;
void dfs(int curr, int prev)
{
  for(auto u:adj[curr])
  { //int u=adj[curr][i];
    if(u!=prev)
	dfs(u,curr);	
  }
  white[curr]=1;black[curr]=1;
  for(auto u:adj[curr])
  {// int u=adj[curr][i];
  	if(u!=prev)
  	{
  	 	white[curr]=(white[curr]*((white[u]+black[u])%MOD))%MOD;
  	 	black[curr]=(black[curr]*white[u])%MOD;
	}
  }
}
//This is a program to compute the painters partition problem;
signed main()
{
 int n;cin>>n;
 adj.resize(n+1);white.resize(n+1);black.resize(n+1);
 for(int i=1;i<n;i++)
 {
 	int x,y;cin>>x>>y;
 	adj[x].push_back(y);
 	adj[y].push_back(x);
 }
 dfs(1,0);
 cout<<(white[1]+black[1])%MOD<<endl;
}


Measured memory_bytes: 14576
import math

N = int(input())

x = N
n = math.floor(math.sqrt(N))
p = {}
i = 2

while i <= n:
    while x % i == 0:
        p.setdefault(i, 0)
        p[i] += 1
        x //= i
    i += 1

if x != 1:
    p.setdefault(x, 1)

ans = 0

for v in p.values():
    i = 1
    while v - i >= 0:
        v -= i
        ans += 1
        i += 1

print(ans)


Measured memory_bytes: 9208
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	private static int[] heap = new int[2000000];
	private static int heapSize = 0;

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

		String line;
		while (!(line = br.readLine()).equals("end")) {
			if (line.startsWith("insert")) {
				insert(Integer.parseInt(line.substring(line.indexOf(" ") + 1)));
			} else {
				int val = extractMax();
				System.out.println(val);
			}
		}

		if (br != null) {
			br.close();
			br = null;
		}
	}

	private static int extractMax() {
		int max = heap[1];
		heap[1] = heap[heapSize];
		heapSize--;
		maxHeapify(1);
		return max;
	}

	private static void maxHeapify(int i) {
		int l = left(i);
		int r = right(i);

		int largest;
		if (l <= heapSize && heap[l] > heap[i]) {
			largest = l;
		} else {
			largest = i;
		}
		if (r <= heapSize && heap[r] > heap[largest]) {
			largest = r;
		}

		if (largest != i) {
			swap(i, largest);
			maxHeapify(largest);
		}
	}

	private static void swap(int i, int j) {
		int tmp = heap[i];
		heap[i] = heap[j];
		heap[j] = tmp;
	}

	private static int parent(int i) {
		return i / 2;
	}

	private static int left(int i) {
		return i * 2;
	}

	private static int right(int i) {
		return i * 2 + 1;
	}

	private static void insert(int key) {
		heapSize++;
		heap[heapSize] = Integer.MIN_VALUE;
		increaseKey(key);
	}

	private static void increaseKey(int key) {
		heap[heapSize] = key;
		int i = heapSize;
		while (i > 1 && heap[parent(i)] < heap[i]) {
			swap(i, parent(i));
			i = parent(i);
		}
	}
}

Measured memory_bytes: 111108
#WA理由分からず
a,b,k = gets.chomp.split(' ').map(&:to_i)
arr = []
i = a
while i < a + k && i < b
  arr.push(i)
  i += 1
end
if i - 1 < b - k
  i = b - k + 1
end
while i <= b
  arr.push(i)
  i += 1
end
puts arr

Measured memory_bytes: 14312
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"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 main() {
	sc.Split(bufio.ScanWords)

	N := nextInt()
	L := make([]int, 2*N)
	for i := 0; i < 2*N; i++ {
		L[i] = nextInt()
	}

	sort.Ints(L)
	ans := 0
	for i := 0; i < 2*N; i += 2 {
		ans += L[i]
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vs vector<string>
#define pb push_back
#define rep(i,n) for(int i = 0;i<n;i++)
#define repk(k,n) for(int i = k;i<n;i++)
#define all(v) v.begin(),v.end()
#define print(v) for(auto n:v){cout << n << "\t";}
#define input(v) for(auto &i:v){cin >> i;}
#define mod 1000000007
#define quick                    \
    ios::sync_with_stdio(false); \
    cin.tie(0);
using namespace std;

void solve(){
	double d,t,s;
	cin >>d>>t>>s;
	double p = d/s;
	if(p<=t){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	

}


int main(){
	int t = 1;
	// cin >> t;
	while(t--){
		solve();
	}

	return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pq              priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); 
	cin.tie(0);
	cout.tie(0);
/*
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
*/
}

int32_t main()
{
	c_p_c();
	string s;
	cin>>s;
	if(s=="ARC")
	cout<<"ABC"<<endl;
	else if(s=="ABC")
	cout<<"ARC"<<endl;
	
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int a[1000001];
int main()
{
   int n,d,x,ans=0;
   cin>>n>>d>>x;
   for (int i=1; i<=n;++i)
   {
       cin>>a[i];
       for (int j=0; j<=d; ++j)
	         if (j*a[i]+1<=d)
	            ++ans;
   }
   cout<<ans+x<<endl;
}

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

int main() {
  int N, Y = 0;
  string S;
  
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> S;
    if(S == "Y") {
      Y = 1;
      cout << "Four" << endl;
      break;
    }
  }
  if(Y == 0) {
    cout << "Three" << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

	int x;
	cin >> x;

	cout << 1 - x << endl;
}


Measured memory_bytes: 3644
#!/usr/bin/env python3


def main():
    K, S = map(int, open(0).read().split())
    # n = 0
    # for X in range(K + 1):
    #     for Y in range(S - X + 1):
    #         if (Y <= K) & (S - X - Y <= K):
    #             n += 1
    # print(n)
    print(
        len(
            [
                0
                for X in range(K + 1)
                for Y in range(S - X + 1)
                if (Y <= K) & (S - X - Y <= K)
            ]
        )
    )


main()


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

int main(){
	int n,m,cnt=0,a=1;
	cin>>n>>m;
	cnt+=100*(n-m);
	for(int i=0; i<m; i++)a*=2;
	cnt+=1900*m;
	cnt*=a;
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        int x = scn.nextInt();
        int y = scn.nextInt();

        while ((x != 0) || (y != 0)) {
            if (x < y) {
                System.out.println(x + " " + y);
            }else{
                System.out.println(y + " " + x);
            }
            x = scn.nextInt();
            y = scn.nextInt();
        }

    }
}


Measured memory_bytes: 35884
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
using namespace std;


int main() {
	int A, B;
	cin >> A >> B;
	string S;
	cin >> S;

	bool flag = true;
	for (int i = 0; i < A + B; i++)
	{
		if (i == A) {
			if (S[i] != '-') {
				flag = false;
				break;
			}
		}
		else {
			if (S[i] == '-') {
				flag = false;
				break;
			}
		}
	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int totalPrice = 0;
		int max = 0;
		for (int i = 0; i < N; i++) {
			int p = sc.nextInt();
			totalPrice += p;
			max = Math.max(max, p);
		}
		System.out.println(totalPrice - max/2);
	}
}


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

using namespace std;

int main()
{
    long long int n,sum=0;
    cin>>n;
    string s;
    vector<string> allstr;
    for(long long int i=0;i<n;i++)
    {
        cin>>s;
        allstr.push_back(s);
    }
    sort(allstr.begin(),allstr.end());
    for(long long int i=0;i<n-1;i++)
    {
        if(allstr[i]!=allstr[i+1])
        {
            sum++;
        }
    }
    cout<<sum+1<<endl;
    return 0;
}

Measured memory_bytes: 11656
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int& ai : a) {
    cin >> ai;
  }
  // reverse(a.begin(), a.end());
  long long ret = 0;
  int max_so_far = 0;
  for (int i = 0; i < n; ++i) {
    max_so_far = max(max_so_far, a[i]);
    if (a[i] < max_so_far) {
      ret += (max_so_far - a[i]);
    }
  }

  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 4040
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k = 0;
  char s;
  cin >> n;
  for(int i = 0;i<n;i++){
    cin>>s;
    if (s == 'Y'){
      k++;
      break;
  }
  }
    if (k == 0){
      cout<<"Three"<<endl;
    }
     else{
      cout<<"Four"<<endl;
    }
 
  // ここにプログラムを追記
}

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

int main() {
  int N;
  cin >> N;
  set<string> s;
  REP(i, N) {
    string S;
    cin >> S;
    s.insert(S);
  }
  cout << s.size() << endl;
}

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

using namespace std;

char map[8][9];

char solve() {
	for (int i=0; i<8; ++i) {
		for (int j=0; j<8; ++j) {
			if (map[i][j] == '1') {
				if (i<7 && j<7 && map[i][j+1]=='1' && map[i+1][j]=='1' && map[i+1][j+1]=='1') return 'A';
				if (i<5 && map[i+1][j]=='1' && map[i+2][j]=='1' && map[i+3][j]=='1') return 'B';
				if (j<5 && map[i][j+1]=='1' && map[i][j+2]=='1' && map[i][j+3]=='1') return 'C';
				if (i<6 && j>0 && map[i+1][j]=='1' && map[i+1][j-1]=='1' && map[i+2][j-1]=='1') return 'D';
				if (i<7 && j<6 && map[i][j+1]=='1' && map[i+1][j+1]=='1' && map[i+1][j+2]=='1') return 'E';
				if (i<6 && j<7 && map[i+1][j]=='1' && map[i+1][j+1]=='1' && map[i+2][j+1]=='1') return 'F';
				if (i<7 && j<7 && j>0 && map[i][j+1]=='1' && map[i+1][j]=='1' && map[i+1][j-1]=='1') return 'G';
			}
		}
	}
}

int main() {
	while (scanf("%s", map[0]) != EOF) {
		for (int i=1; i<8; ++i) scanf ("%s", map[i]);
		char ans = solve();
		printf ("%c\n", ans);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

///////////////////////////////////////////////////////////////////////////

int main(){
	int n,x = 0,ans = 0;
	string s;
	cin >> n >> s;

    rep(i,0,n){
        if(s[i] == 'I')x++;
        else x--;

        ans = max(ans,x);
    }
    cout << ans << endl;
	
	return  0;
}

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

int w,h;
char data[100][100];

void clear(int i,int j)
{
  char tmp= data[i][j];
  data[i][j]='x';
  int dx[]={0,0,1,-1};
  int dy[]={1,-1,0,0};
  for(int xx=0;xx<4;xx++)
    {
      if(i+dx[xx]>=0 && i+dx[xx]<w && j+dy[xx]>=0 && j+dy[xx]<h)
	{
	  if(data[i+dx[xx]][j+dy[xx]]==tmp &&data[i+dx[xx]][j+dy[xx]]!='x')
	    clear(i+dx[xx],j+dy[xx]);
	}
    }
}

int main()
{

  for(;cin>>w>>h,w;)
    {
      //      char data[w][h];
	for(int i=0;i<w;i++)
	  for(int j=0;j<h;j++)
	    {
	      cin>>data[i][j];
	    }
	
	int ans=0;
	for(int i=0;i<w;i++)
	  for(int j=0;j<h;j++)
	    {
	      if(data[i][j]!='x')
		{
		  //	  cout<<i<<" "<<j<<endl;
		  clear(i,j);
		  ans++;
		}
	    }
	cout<<ans<<endl;
      
    }
}

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

int main() {
  int n;
  cin>>n;
  if(n<10){
    cout<<n<<endl;
  }
  else if(n<100){
    cout<<9<<endl;
  }
  else if(n<1000){
    cout<<9+n-99<<endl;
  }
  else if(n<10000){
    cout<<909<<endl;
  }
  else if(n<100000){
    cout<<909+n-9999<<endl;
  }
  else{
    cout<<90909<<endl;
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
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-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<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 & (1<<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 count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(x) cout<<x<<endl
#define Gput(a,b) G[a].push_back(b)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll fact(ll x){
  ll y=1;
  for(ll i=1;i<=x;i++){
   y*=i;
   y%=1000000007;
  }
  return y;
}
int main() {
  ll n,x;
  cin>>n>>x;
  vec a(n);
  loop(i,n){
  cin>>a[i];
  }
ll ans=abs(x-a[0]);
loop(i,n){
ans=__gcd(ans,abs(x-a[i]));
}
putout(ans);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

int G[50][50];
bool seen[50];
int n,m;

void dfs(int v) {
  seen[v] = true;
  rep(nv, n){
    if(seen[nv] || G[v][nv] == 0) continue;
    dfs(nv);
  }
}

int main(){
  cin >> n >> m;
  vi a(m),b(m);
  rep(i, m){
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    G[a[i]][b[i]]++;
    G[b[i]][a[i]]++;
  }
  int ans = 0;
  rep(i, m) {
    memset(seen,false,sizeof(seen));
    G[a[i]][b[i]]--; G[b[i]][a[i]]--;
    dfs(0);
    bool bridge = false;
    rep(v, n) if(!seen[v]) bridge = true;
    if(bridge) ans++;
    G[a[i]][b[i]]++; G[b[i]][a[i]]++;
  }

  std::cout << ans << '\n';
}


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

int main(){
  int N;
  cin>>N;
  vector<int> L(N);
  int sum=0;
  for(int i=0;i<N;++i){
    cin>>L.at(i);
    sum=sum+L.at(i);
  }

  sort(L.begin(),L.end(),greater<int>());
  if(sum-L.at(0)>L.at(0)){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> a[i];
	}

	auto result = 0;
	auto current = 1;
	for (auto i = 0; i < N; ++i)
	{
		if (a[i] == current)
		{
			++current;
		}
		else
		{
			++result;
		}
	}

	if (result >= N)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << result << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

// https://atcoder.jp/contests/abc139/tasks/abc139_a
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		String T = sc.nextLine();
		sc.close();

		int ans = 0;

		String[] arrayS = S.split("");
		String[] arrayT = T.split("");

		for(int i=0;i<arrayS.length;i++) {
			if(arrayS[i].equals(arrayT[i])) {
				ans++;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 23508
#include<stdio.h>
#define MAX 100000
int parent(int i) {return i/2;}
int left(int i) {return 2*i;}
int right(int i){ return 2*i+1;}

int main(){
  int H,i,A[MAX+1];

  scanf("%d",&H);

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

  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1) printf("parent key = %d, ",A[parent(i)]);
    if(left(i)<=H) printf("left key = %d, ",A[left(i)]);
    if(right(i)<=H) printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2048
from collections import Counter
MOD = 998244353
def solve(n, d):
    if d[0] > 0:
        return 0
    d = sorted(d)  
    if (n > 1) and (d[1] == 0):
        return 0
    D = Counter(d) 
    k = sorted(list(D.keys()))
    m = len(k)  
    if m -1 != k[-1]:
        return 0
    res = 1
    for i in range(1, m):
        p = D[k[i-1]]
        q = D[k[i]]
        res = (res * (p**q)) % MOD
    return res
n = int(input())
d = list(map(int, input().split()))
print(solve(n, d))



Measured memory_bytes: 20704
n = int(input())
a = list(map(int, input().split()))
sum_a = sum(a)
total = 0
min_diff = 10**10
min_idx = 0
total_tmp = 0
for i in range(n):
    total += a[i]
    diff = abs(total - sum_a/2)
    if diff < min_diff:
        min_diff = diff
        min_idx = i
        total_tmp = total

print(abs(total_tmp - sum(a[min_idx+1:])))


Measured memory_bytes: 26060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int m,d,ans=0;
    cin>>m>>d;
    rep(i,m)rep(j,d){
        int a=i+1;
        int b=j+1;
        int d1=b%10,d10=b/10;
        if(a==d1*d10&&d1>=2&&d10>=2) ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iostream>
#include<map>
#include<cstring>
#define INF 0x3f3f3f3f
#define eps 1e-10
using namespace std;
string s;
map<pair<int,int>,bool>exist;
long long n,a[200005],sum[200005],ans,presum;
int main(){
    scanf("%lld",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
        sum[i]=sum[i-1]+a[i];
    }
    for(int i=1;i<n;i++){
        presum=sum[n]-sum[i];
        presum%=1000000007;
        ans+=a[i]*(presum);
        ans%=1000000007;
        
    }
    printf("%lld",ans);
}


Measured memory_bytes: 6352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = Integer.parseInt(sc.next());
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		sc.close();

		//
		if(A- B >= 0) {
			System.out.println("delicious");
		}else {
			if(X >= Math.abs(A - B)) {
				System.out.println("safe");
			}else {
				System.out.println("dangerous");
			}
		}
		
	}
}

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


int main(){	
	string s;
	long long K;
	long long N;
	scanf("%lld",&N);
	scanf("%lld",&K);
	cin >> s;
	queue<int> que1, que2;
	int start = 0, res = 0, now = 0;
	bool flg = true;
	if (s[0] == '1') flg = false;
	for (int i=1; i<s.length(); i++) {
		if (s[i-1] == '1' && s[i] == '0') {
			que2.push(i-start);
			res = max(res, now+i-start);
			now += i-start;
			start = i;
		} 
		if (s[i-1] == '0' && s[i] == '1') {
			que1.push(i-start);
			if (que1.size() == K+1) {
				if (flg) {
					res = max(res, now-que1.front()+(i-start));
					now = now-que1.front()+(i-start);
					que1.pop();
					flg = false;
				} else {
					res = max(res, now-que1.front()-que2.front()+(i-start));
					now = now-que1.front()-que2.front()+(i-start);
					que1.pop();
					que2.pop();
				}
			} else {
				res = max(res, now+i-start);
				now += i-start;
			}
			start = i;
		}
	}
	if (s[s.length()-1] == '1') {
		res = max(res, now+(int)s.length()-start);
	} 
	if (s[s.length()-1] == '0') {
		que1.push(s.length()-start);
		if (que1.size() == K+1) {
			if (flg) {
				res = max(res, now-que1.front()+((int)s.length()-start));
				now = now-que1.front()+((int)s.length()-start);
				que1.pop();
				flg = false;
			} else {
				res = max(res, now-que1.front()-que2.front()+((int)s.length()-start));
				now = now-que1.front()-que2.front()+((int)s.length()-start);
				que1.pop();
				que2.pop();
			}
		} else {
			res = max(res, now+(int)s.length()-start);
		}
	}

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



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_H = 81;
const int MAX_W = 81;
int A[MAX_H][MAX_W];
int B[MAX_H][MAX_W];
int t[MAX_H][MAX_W];

bool dp[MAX_H][MAX_W][162 * 162];

int main2() {
  int H = nextInt();
  int W = nextInt();
  REP(i, H) REP(j, W) A[i][j] = nextInt();
  REP(i, H) REP(j, W) B[i][j] = nextInt();
  REP(i, H) REP(j, W) t[i][j] = A[i][j] - B[i][j];
  CLR(dp, 0);

  const int M = 162 * 162;
  const int O = M/2;
  dp[0][0][O - t[0][0]] = true;
  dp[0][0][O + t[0][0]] = true;
  REP(h, H) REP(w, W) {
    REP(k, M) if (dp[h][w][k]) {
      if (h + 1 < H) {
        dp[h+1][w][k + t[h+1][w]] = true;
        dp[h+1][w][k - t[h+1][w]] = true;
      }
      if (w + 1 < W) {
        dp[h][w+1][k + t[h][w+1]] = true;
        dp[h][w+1][k - t[h][w+1]] = true;
      }
    }
  }
  int ans = 1001001001;
  REP(k, M) {
    if (dp[H-1][W-1][k]) {
      chmin(ans, abs(k - O));
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 168448
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Typical Stairs
            var line = ReadLine();
            int N = line[0];
            int M = line[1];

            var a = GetBrokenFloors(M);

            var ans = new long[N + 1];
            ans[0] = 1;

            for(int i = 1; i <= N; i++)
            {
                if (!a.ContainsKey(i))
                {
                    if (i == 1)
                    {
                        ans[i] = 1;
                    }
                    else
                    {
                        long sum = ans[i - 1] + ans[i - 2];
                        ans[i] = sum % 1000000007;
                    }
                }
            }

            Console.WriteLine(ans[N]);
        }

        static Dictionary<int, int> GetBrokenFloors(int M)
        {
            var dic = new Dictionary<int, int>();

            for (int i = 0; i < M; i++)
            {
                int a = int.Parse(Console.ReadLine());
                dic.Add(a, 0);
            }

            return dic;
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 19040
N = int(input())
A = []
for i in range(0,N):
    A.append(list(map(int,input().split())))

dp = [[0 for _ in range(3)] for _ in range(N)]
for i in range(N):
    for j in range(3):
        if i == 0:
            dp[i][j]= A[i][j]
        else:
            tmp = [0] 
            for k in range(3):
                if j !=k:
                    tmp.append(dp[i-1][k])
            dp[i][j] = max(tmp) + A[i][j]
print(max(dp[-1]))


Measured memory_bytes: 47280
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>

int main(){

  char C;
  std::cin >> C;
  std::cout << (char)((int)C+1) << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstring>
#include<map>

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<b;++i)
#define fj(a,b) for(int j=a;j<b;++j)
#define fo(a,b) for(int o=a;o<b;++o)
#define fdi(a,b) for(int i=a-1;i>=b;--i)
#define fdj(a,b) for(int j=a-1;j>=b;--j)
#define fdo(a,b) for(int o=a-1;o>=b;--o)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
//////////////////////

int const N = 2e7 + 41;

int n, k, d[41], have[41];
int ans;

bool can(int n){
	while(n){
		int c = n % 10;
		if(have[c]) return false;
		n /= 10;
	}
	return true;
}

void solve(){
	fi(0, k) have[d[i]] = 1;
	fi(n, N){
		if(can(i)){
			ans = i;
			return;
		}
	}
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	scanf("%d %d",&n,&k);
	fi(0, k) scanf("%d",&d[i]);

	solve();

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

	return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
num_A = [0]*(N+1)
for a in A:
  num_A[a]+=1

s=0
for n in num_A:
  s+=n*(n-1)//2
#print(s)
for a in A:
  ans = s - (num_A[a]*(num_A[a]-1)//2) + ((num_A[a]-1)*(num_A[a]-2)//2)
  print(ans)



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

int main() {
  int n,k;
  int group = 1;
  string s;
  cin >> n >> k >> s;
  for (int i=0; i < n-1; i++){
    if (s.at(i) != s.at(i+1)){
      group++;
    }
  }
  if (group/2 <= k){
    cout << n-1 << endl;
  }
  else{
    group -= 2*k;
    cout << (n-1)-(group-1) << endl;
  }
}

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

int main(){
    int N;
    int64_t ans = 0;

    cin >> N;

    vector<int> A(N);

    for(int i = 0; i < N; i++) cin >> A[i];

    for(int i = 0; i < N - 1; i++){
        if(A[i] <= A[i+1]){
            continue;
        } else {
            ans += (A[i] - A[i+1]);
            A[i+1] = A[i];
        }
    }

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

Measured memory_bytes: 4024
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
const int maxn=1e5+10;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
int a[maxn],fa[maxn];
vector<int> ve[maxn],vc[maxn];
inline int find(int x){
	if(fa[x]==x) return x;
	return fa[x]=find(fa[x]);
}
void merge(int x,int y){fa[find(x)]=find(y);}
int main(){
	int n=read(),m=read();
	REP(i,1,n) a[i]=read(),fa[i]=i;
	while(m--){
		int x=read(),y=read();
		merge(x,y);
	}
	int ans=0;
	REP(i,1,n) ve[find(i)].push_back(i),vc[find(i)].push_back(a[i]);
	REP(i,1,n) if(fa[i]==i){
		sort(vc[i].begin(),vc[i].end());
		REP(j,0,ve[i].size()-1){
			int u=lower_bound(vc[i].begin(),vc[i].end(),ve[i][j])-vc[i].begin();
			if(u!=iend+1 && vc[i][u]==ve[i][j]) ++ans;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 11904
import sys
from collections import OrderedDict
AZC = OrderedDict((chr(i), 0) for i in range(97,97+26))

import fileinput
for line in fileinput.input():
 S = line.strip().lower()
 for i in S:
  if i in AZC:
   AZC[i] += 1

for  s, n in AZC.items():
 print(s + " : " + str(n)) 

Measured memory_bytes: 7884