akhauriyash/Code-Regression huggingface dataset:
import java.io._
import java.util.StringTokenizer

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

object Main {
  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val S = sc.next()
    val N = S.length

    def calc(flg: Boolean) = {
      var ans = N
      rep(N) { i =>
        if (S(i) == '1' == flg) {
          val l = i
          val r = N - 1 - i
          val x = min(l + 1, r + 1)
          val k = max(max(l, r), x)
          if (ans > k) ans = k
        }
      }
      ans
    }

    out.println(max(calc(true), calc(false)))
  }

  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }


  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)
  }
  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
  }

  implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
    // todo Orderingだとboxing発生するので自作Orderを用意したい
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
      if (as.nonEmpty) Some(as.maxBy(f)) else None
    }

    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
      val map = mutable.Map.empty[K, ArrayBuffer[A]]
      rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))
      map
    }

    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      var sum = num.zero
      rep(as.length)(i => sum = num.plus(sum, f(as(i))))
      sum
    }

    def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.lt)
    }

    def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.gt)
    }

    private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {
      var limA = as(ixRange.head)
      var limB = f(limA)

      for (i <- ixRange.tail) {
        val a = as(i)
        val b = f(a)
        if (cmp(b, limB)) {
          limA = a
          limB = b
        }
      }
      (limA, limB)
    }
  }

  implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))
    }
  }
}


Measured memory_bytes: 29032
package main

import (
	"bufio"
	"fmt"
	"os"
	"unicode"
)

func main() {
	defer stdout.Flush()
	n := readInt()
	p := make([]int, n+1)
	for i := 1; i <= n; i++ {
		p[i] = readInt()
	}
	total := 0
	for i := 1; i <= n; i++ {
		if p[i] == i {
			total += 1
			if i+1 > n {
				break
			}
			if p[i+1] == i+1 {
				i++
				continue
			}
		}
	}
	println(total)
}

var (
	stdin  *bufio.Reader
	stdout *bufio.Writer
)

func init() {
	stdin = bufio.NewReader(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func scanf(f string, args ...interface{}) (int, error) {
	n, err := fmt.Fscanf(stdin, f, args...)
	for {
		r, _, err := stdin.ReadRune()
		if err != nil || !unicode.IsSpace(r) {
			stdin.UnreadRune()
			break
		}
	}
	return n, err
}

func readInt() int {
	var n int
	scanf("%d", &n)
	return n
}

func readIntSlice(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		scanf("%d", &a[i])
	}
	return a
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func readString() string {
	var s string
	scanf("%s", &s)
	return s
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}


Measured memory_bytes: 3072
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

bool isValidMonth(string s)
{
    int a = s[0] - '0', b = s[1] - '0';
    a = 10 * a + b;
    return a >= 1 && a <= 12;
}

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    string S;
    cin >> S;
    string p1 = S.substr(0, 2), p2 = S.substr(2);
    int ret = isValidMonth(p1) + isValidMonth(p2);
    if (ret == 2)
        cout << "AMBIGUOUS";
    else if (ret == 0)
        cout << "NA";
    else {
        if (isValidMonth(p1))
            cout << "MMYY";
        else
            cout << "YYMM";
    }
    cout << endl;
    return 0;
};


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){ 
  int n, q; string s; cin >> n >> q >> s;
  vector<int> S(n+1);
  rep(i, n){
    S[i+1] = S[i];
    if(i<n-1 && s[i]=='A' && s[i+1]=='C')S[i+1]++;
  }

  vector<int> ans(q);
  rep(i, q){
    int l, r; cin >> l >> r; l--; r--;
    ans[i] = S[r] - S[l];
  }
  for(auto res: ans) cout << res << ln;
}


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

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

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


const long long int mod = 1000000007;
const long long int INF = 1e18;

long long int N,M,s,w;

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


Measured memory_bytes: 3624
N=int(input())
d=[int(n) for n in input().split()]
memo=[]
ans=0
for i in range(N):
    for j in range(N):
        if (i,j) in memo or (j,i) in memo or i==j:
            pass
        else:
            ans += d[i]*d[j]
            memo.append((i,j))
print(ans)

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


int main()
{
    string s;
    cin >> s;
    int count = 0;
    ll ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'B') {
            count++;
        }
        else
            ans += count;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int r = scanner.nextInt();
		int d = scanner.nextInt();
		int x2000 = scanner.nextInt();
		
		int x = x2000;
		for (int i = 1; i <= 10; i++) {
			x = ( r * x ) - d;
			System.out.println(x);
		}
	}
}


Measured memory_bytes: 21844
#include "bits/stdc++.h"
 
using namespace std;
 
#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238
 
typedef pair<int, int> P;
 

void solve(string s){
    vector<int> v(4);
    REP(i,4){
        v[i]=s[i]-48;
    }
    string ans;
    int kekka;
    for(int bit=0; bit<(1<<3); bit++){
        ans = to_string(v[0]);
        kekka  =v[0];
        REP(i,3){
            if(bit&(1<<i)){
                ans+="+"+to_string(v[i+1]);
                kekka+=v[i+1];
            } else {
                ans+="-"+to_string(v[i+1]);
                kekka-=v[i+1];
            }
        }
        if(kekka==7){
            cout<<ans+"=7"<<endl;
            break;
        }
    }
}
 
signed main(){
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    string s;
    cin>>s;
    solve(s);
    return 0;
}


Measured memory_bytes: 256
#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 n, x, y;
  cin >> n >> x >> y;
  x--; y--;

  vector<int> ans(n, 0);
  rep(i, n) rep(j, n) {
    if (i >= j) continue;
    int d = min(j - i, abs(x - i) + abs(y - j) + 1);
    ans.at(d)++;
  }

  for (int i = 1; i < n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3636
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

H, N = MAP()
AB = []
for i in range(N):
    a, b = MAP()
    AB.append((a, b))

dp = [INF] * 20007
dp[0] = 0
for a, b in AB:
    for i in range(20007):
        if i-a >= 0:
            dp[i] = min(dp[i], dp[i-a] + b)
ans = min(dp[H:])
print(ans)


Measured memory_bytes: 40940
n, m = map(int, input().split())
h = list(map(int, input().split()))
x = [1 for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    if h[a - 1] >= h[b - 1]:
        x[b - 1] = 0
    if h[a - 1] <= h[b - 1]:
        x[a - 1] = 0
print(sum(x))


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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

#define all(v) v.begin(), v.end()

#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  ll x, a;
  cin >> x >> a;

  if (x < a) {
    cout << 0 << endl;
  } else {
    cout << 10 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

const int ms = 100100;

int a[ms];

int main()
{
	int n;
	while(std::cin >> n)
	{
		for(int i = 0; i < n; i++)
			std::cin >> a[i];
		if(n <= 2)
		{
			std::cout << "1" << '\n';
			continue;
		}
		int on = 0;
		int ans = 0;
		while(on < n)
		{
			int start = on;
			on++;
			while(on < n && a[on] == a[on - 1])
				on++;
			if(a[on] > a[on - 1])
			{
				while(on < n && a[on] >= a[on - 1])
					on++;
			}
			else
			{
				while(on < n && a[on] <= a[on - 1])
					on++;
			}
			ans++;
			//std::cout << "from " << start << " to " << on - 1 << '\n';
		}
		std::cout << ans << '\n';
	}
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
    using namespace std;
     
    #define za ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define mod %1000000007
    #define moz 1000000007
    #define nl "\n"
    #define S second
    #define F first
    #define PB push_back
    #define MP make_pair
    #define V vector
    //#define P pair
    #define LEN length()
    #define SZ size()
    #define loop(i,a,b) for(int i=(a);i<=(b);i++)
    typedef long long ll;
    typedef complex<ll> P;
    #define X real()
    #define Y imag()
     
     
    int main()
    {
        za ;
        int x[100009];
        int n;
        cin >> n;
        loop(i,1,n)
        {
            cin >> x[i];
        }
        int co=0;
        loop(i,1,n)
        {
            if(x[i]==i)
            {
                if(i==1) swap(x[i],x[i+1]);
                else if(i==n) swap(x[i-1],x[i]);
                else if(x[i-1]==i) swap(x[i],x[i+1]);
                else if(x[i+1]==i) swap(x[i], x[i-1]);
                else swap(x[i],x[i+1]);
                co++;
            }
        }
        cout << co << nl;
    }

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
int a[100001];
long long sum=0;
int main(){
	int i,j,k,n;
	cin>>n>>k;
	for(i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1);
	for(i=n;i>n-k;i--)sum+=a[i];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <stack>
#include <unordered_map>
#include <queue>
using namespace std;

int main () {
	int n;
	cin >> n;
	int last = -1;
	for (int i = 0; i < n; i++) {
		int temp;
		cin >> temp;
		if (i == 0)
			last = temp;
		else {
			while (temp != 0 && last != 0) {
				if (last < temp) {
					temp %= last;
				}
				else {
					last %= temp;
				}
			}
			last = max(last, temp);
		}
	}
	cout << last;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node *Node;

void insert(int);
void Inorder(Node);
void Preorder(Node);

Node root;

int main(){
  char s[10];
  int k, n, i;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%s", s);

    if(s[0] == 'i'){
      scanf("%d", &k);
      insert(k);
    }
    else{
      Inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    }
  }
  
  return 0;
}

void insert(int k){
  Node z, x = root, y = NULL;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NULL;
  z->right = NULL;

  while(x != NULL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NULL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void Inorder(Node u){
  if(u == NULL) return;
  Inorder(u->left);
  printf(" %d", u->key);
  Inorder(u->right);
}

void Preorder(Node u){
  if(u == NULL) return;
  printf(" %d", u->key);
  Preorder(u->left);
  Preorder(u->right);
}

Measured memory_bytes: 24040
x=int(input())
y=input()
z=y.split(" ")
a=int(z[0])
b=int(z[1])
over=0
multiples=[x*d for d in range(1000)]
for c in multiples:
    if(over==0):
        if(c>=a and c<=b):
            print('OK')
            over+=1
if(over==0):
    print('NG')

Measured memory_bytes: 9136
#include<iostream>
using namespace std;
int main(){
    int H,W;
    while(1){
        cin>>H>>W;
        if(H==0 &&W==0){
            break;
        }
        else{
            for ( int i = 0; i < H; i++ ){
                for ( int j = 0; j < W; j++ ){
                    cout << "#";
                }
                cout << endl;
                }
                cout <<endl;
            }
    }
    
    
    return 0;
}


Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {

    private static int N;
    private static int M;
    private static int A[];
    private static int B[];

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();
        A = new int[M];
        B = new int[M];
        for (int i = 0; i < M; i++) {
            A[i] = sc.nextInt()-1;
            B[i] = sc.nextInt()-1;
        }
        System.out.println(solve());
    }

    static int solve() {
        int ans = 0;
        for (int i = 0; i < M; i++) {
            if( isBridge(i) ) {
                ans++;
            }
        }
        return ans;
    }

    static boolean isBridge(int exclude) {
        int a_ex = A[exclude];
        int b_ex = B[exclude];

        UnionFind uf = new UnionFind(N);
        for (int i = 0; i < M; i++) {
            if( a_ex == A[i] && b_ex == B[i] ) continue;

            uf.unite(A[i], B[i]);
        }

        int rootZero = uf.root(0);
        for (int i = 1; i < N; i++) {
            if( uf.root(i) != rootZero ) {
                return true;
            }
        }
        return false;
    }

    static class UnionFind {

        private int[] parent;
        private int[] rank;

        public UnionFind(int n) {
            parent = new int[n];
            rank = new int[n];
            for (int i = 0; i < n; i++) {
                parent[i] = i;
                rank[i] = 0;
            }
        }

        int root(int i) {
            if( parent[i] == i ) {
                return i;
            } else {
                parent[i] = root(parent[i]);
                return parent[i];
            }
        }

        void unite(int x, int y) {
            x = root(x);
            y = root(y);
            if( x == y ) return;

            if( rank[x] < rank[y] ) {
                parent[x] = y;
            } else {
                parent[y] = x;
                if( rank[x] == rank[y]) rank[x]++;
            }
        }
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include <ext/rope>
using namespace std;
using namespace __gnu_cxx;

using ci = const int;
using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii = pair <int,int>;
using pcc = pair <char,char>;
using pll = pair <ll,ll>;
using pss = pair <string,string>;
using vi = vector <int>;
using vb = vector <bool>;
using vpii = vector <pii>;
using vll = vector <ll>;
using vii = vi::iterator;

#define INF (0x3f3f3f3f)
#define MOD 1000000007
#define mt make_tuple
#define all(c) c.begin(), c.end()
#define ms(name,val) memset(name, val, sizeof (name))
#define np nullptr
// inline functions



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

    int n, l, tmp = 0, ntmp = 0;
    cin >> n >> l;

    for (int t1 = 1; t1 <= n; ++t1)
    {
        int flav = l+t1-1;
        tmp += flav;
    }

    ntmp = -1;

    for (int t1 = 1; t1 <= n; ++t1)
    {
        int flav = l+t1-1;
        int cur = tmp-flav;

        if (ntmp == -1 || abs(tmp-cur) < abs(tmp-ntmp))
            ntmp = cur;
    }

    cout << ntmp << '\n';



























































    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

// 二項係数計算
long long COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
int par[114514], rrank[114514];//親、木の深さ
void init(int n) {
	rep(i, n) {
		par[i] = i;
		rrank[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rrank[x] < rrank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rrank[x] == rrank[y])rrank[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
int keta(int x) {
	int ans = 0, n = 1;
	while (n <= x) {
		ans++;
		n *= 10;
	}
	return ans;
}
int s[10][10];
signed main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		s[i / (mod_pow(10, keta(i) - 1, inf))][i % 10]++;
	}
	int ans = 0;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			ans += s[i][j] * s[j][i];
		}
	}
	cout << ans << endl;
	ggr
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#include <functional>
#include <iomanip>
#define rep(i,N) for(ll i=0;i<N;i++)
#define disp(a) cout << a << endl;
#define PI 3.1415926535897932384626433
//cout << fixed << setprecision(20) << ** << endl;
typedef long long ll;
using namespace std;
double deg2rad(double degree)
{
    return degree * PI / 180.0000000000;
}
int main()
{
	char s;
	cin>>s;
	if(isupper(s)){
		cout<<"A"<<endl;
	}
	else{
		cout<<"a"<<endl;
    }
}

Measured memory_bytes: 3068
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
	ll n;
	cin>>n;
	cout << n/3 << endl;
	return 0;
}

Measured memory_bytes: 764
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			while (true) {
				int n = cin.Int();
				int x = cin.Int();
				if (n == 0 && x == 0) {
					break;
				}

				int ans = 0;
				for (int i = 1; i <= n; i++) {
					for (int j = i + 1; j <= n; j++) {
						for (int k = j + 1; k <= n; k++) {
							if (i + j + k == x) {
								ans++;
							}
						}
					}
				}

				Console.WriteLine(ans);
			}
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}


Measured memory_bytes: 17960
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int H, W, K;
    cin >> H >> W >> K;
    int sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy;
    sx--; sy--; gx--; gy--;
    vector<vector<bool>> avail(H);
    for(int i=0; i<H; i++){
        string s;
        cin >> s;
        avail[i].resize(W);
        for(int j=0; j<W; j++) avail[i][j] = (s[j] == '.');
    }
 
    int dx[] = {-1, 1, 0, 0};
    int dy[] = {0, 0, -1, 1};
    auto inside = [&](int i, int j){ return i>=0 && i<H && j>=0 && j<W && avail[i][j]; };
 
    vector<vector<int>> dist(H, vector<int>(W, 1e9));
    queue<pair<int, int>> que;
    que.emplace(sx, sy);
    dist[sx][sy] = 0;
 
    while(que.size()){
        auto [i, j] = que.front(); que.pop();
        for(int k=0; k<4; k++) for(int d=1; d<=K; d++){
            int x = i+d*dx[k], y = j+d*dy[k];
            if(!inside(x, y) || dist[x][y] <= dist[i][j]) break;
            if(dist[x][y] == 1e9){
                dist[x][y] = dist[i][j] + 1;
                que.emplace(x, y);
            }
        }
    }
 
    int ans = dist[gx][gy];
    if(ans == 1e9) ans = -1;
    cout << ans << endl;
    return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define Ans(s) cout << s << endl

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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; }

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

typedef long long ll;
typedef vector<int> inv;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main()
{
	int s_i[4];
	string s;
	cin >> s;
	rep(i, 4)
	{
		s_i[i] = s[i];
	}

	int now = s[0];
	for (int i = 1; i < 4; i++)
	{
		if (now == s[i])
		{
			cout << "Bad" << endl;
			return 0;
		}
		else now = s[i];
	}
	cout << "Good" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    int a[n+5];
    double sum=0.0,x;
    for(int i=0; i<n; i++) {
        cin>>a[i];
    }
    sort(a,a+n);
    sum=((double)(a[0]+a[1]))/2.0;
    //cout<<sum<<endl;
    for(int i=2; i<n; i++) {
        sum=(sum+a[i])/2.0;
    }
    cout<<sum<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
typedef priority_queue <int> pi;
typedef priority_queue <int, vector<int>, greater<int>> pg;
typedef unsigned long long int ulli;

int main() {
    int A, B, X;
    cin >> A >> B >> X;
    X -= A;
    if(X < B && X >= 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
int main(){
    ll d,g;cin >> d >>g;
    vl p(d),c(d);
    rep(i,d)cin >> p[i] >>c[i];
    ll ans=inf;
    rep(bit,1<<d){
        ll poi=0,cos=0;
        rep(i,d){
            if(bit&1<<i){
                poi+=p[i]*(i+1)*100;
                poi+=c[i];
                cos+=p[i];
            }
        }
        if(poi>=g){chmin(ans,cos);continue;}
        ll r=g-poi;
        bool check=false;
        per(i,d){
            if((bit&1<<i)==0){
                rep(j,p[i]-1){
                    poi+=(i+1)*100;
                    cos++;
                    if(poi>=g){
                        chmin(ans,cos);
                        check=true;
                        break;
                    }
                }
            }
            if(check)break;
        }
    }
    cout <<ans <<endl;
}

Measured memory_bytes: 256
import Data.List

main = do
    all <- getContents
    mapM_ (putStrLn) (calc $ map read $ words all)


calc :: [Int] -> [String]
calc [] = []
calc (0:0:_) = []
calc xs =
    (unwords $ map show (sort (take 2 xs))) : calc (drop 2 xs)


Measured memory_bytes: 4564
#include<iostream>
#include<vector>
#include<algorithm>

int main()
{
int n, k; std::cin >> n >> k;
int a;
std::vector<int> h;
for(int i = 0; i < n; ++i)
{
std::cin >> a;
h.emplace_back(a);
}
std::sort(h.begin(), h.end());


auto itr = std::find_if(h.begin(), h.end(), [k](int x){return x >= k;});

std::cout << h.end() - itr;

}


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

using namespace std;

using u32 = uint32_t;
using u64 = uint64_t;
using i64 = int64_t;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= a; i--)
#define RF0(i,b) RFO(i,0,b)

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

  int H, W, K;
  cin >> H >> W >> K;

  vector<vector<bool>> grid(H);

  F0R(y, H) {
    F0R(x, W) {
      char c;
      cin >> c;
      grid[y].push_back(c == '1');
    }
  }

#if 0
  // Print grid
  F0R(y, H) {
    F0R(x, W) {
      cout << (grid[y][x] ? '1' : '0');
    }
    cout << '\n';
  }
#endif

  constexpr int DivCntMax = 10 * 1000;

  int min = DivCntMax;

  // H分割数
  F0R(hDivCnt, H) {
    if (min <= hDivCnt) {
      break;
    }

    // H分割線
    vector<int> hDiv(hDivCnt);  // 0
    iota(hDiv.begin(), hDiv.end(), 1);

    while (true) {

      // Debug
#if 0
      cout << "hDiv:";
      for (auto i : hDiv) {
        cout << i << ",";
      }
      cout << '\n';
#endif

      int divCnt = hDivCnt; // H+V分割数
      vector<int> white(hDivCnt + 1);  // それぞれのH分割に含まれる白の数

      // V分割していく
      for (int x = 0; x < W ; /*NOP*/) {

        // 前回V分割したときのx
        int prevVDiv = -1;

        // V分割が必要か
        bool needVDiv = false;

        // H分割ごとに白を数える
        F0R(scanline, hDivCnt + 1) {
          int yStart = scanline > 0 ? hDiv[scanline - 1] : 0;
          int yEnd = scanline < hDivCnt ? hDiv[scanline] : H;

          FOR(y, yStart, yEnd) {
            if (grid[y][x]) {
              white[scanline]++;
            }
          }

          // 白が規定数をオーバーした
          if (white[scanline] > K) {
            needVDiv = true;
            break;
          }
        }

        // V分割が必要？
        if (needVDiv) {

          // x が前回と同じ = 横幅 1 なのに白がオーバーしてしまった
          if (x == prevVDiv) {
            // このH分割では不可能なのでやめる
            divCnt = DivCntMax;
            break;
          }

          // V分割する
          if (++divCnt >= min) {
            // 判明している最小分割数に到達 : 探索を切り上げる
            break;
          }
          prevVDiv = x;

          // 白カウントをリセット
          fill(white.begin(), white.end(), 0);
        }
        else {
          x++;
        }
      }

      // 最小分割数の更新
      if (divCnt < min) {
        min = divCnt;
      }


      if (hDivCnt > 0) {

        int di;

        // H分割線を1つ進める
        F0R(i, hDivCnt) {
          di = hDivCnt - 1 - i;
          hDiv[di]++;

          if (hDiv[di] < H - i) {
            break;
          }
        }

        // 今進めた線の奥の線は順に +1 していく
        FOR(i, di + 1, hDivCnt) {
          hDiv[i] = hDiv[i - 1] + 1;
        }

        // 最後の線が範囲外なら全処理を終了
        if (*(--hDiv.end()) > H - 1) {
          break;
        }
      }
      else {
        // H分割線 0 のときは次へ
        break;
      }
    }
  }

  cout << min;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int a,b,h;
    
    cin>>a>>b>>h;
    cout <<(a+b)*h/2 << endl;


}


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

int main() {
	char s1[15], s2[15], s3[15];
	scanf("%s %s %s", s1, s2, s3);
	
	printf("%c%c%c", s1[0] - 32, s2[0] - 32, s3[0] - 32);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();
        if (Integer.parseInt(s.substring(5, 7)) > 4) {
            System.out.println("TBD");
        } else {
            System.out.println("Heisei");
        }
    }
}


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

using namespace std;

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

#define F first
#define S second

const int MAXN = 1e5 + 10;
const int INF = 1e9;

int n, ans;
vector<int> adj[MAXN];
bool del[MAXN];

bool dfs(int v, int p = -1){
	int cc = 0, ch = 0;
	for (int u:adj[v])
		if (u^p) {
			cc += dfs(u, v);
			ch++;
		}

	ans += max(0, ch-cc-1);
	if (cc || ch > 1)
		return true;
	return false;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n-1; i++){
		int a, b;	cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	int mx = -1, root = -1;
	for (int v = 0; v < n; v++)
		if ((int)adj[v].size() > mx) {
			root = v;
			mx = adj[v].size();
		}

	dfs(root);
	cout << max(1, ans) << "\n";
	return 0;
}


Measured memory_bytes: 11904
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
ll n,ans=0;
void dfs(ll a,ll b,ll c,ll now) {
  if(now>n) {
    return;
  }
  if(a&&b&&c) {
    ans++;
  }
  dfs(a+1,b,c,now*10+3);
  dfs(a,b+1,c,now*10+5);
  dfs(a,b,c+1,now*10+7);
}
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  dfs(0,0,0,0);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
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 N, M;
	cin >> N >> M;
	while (N != 0) {
		vi SN(N), SM(M);
		int sumn = 0, summ = 0;
		REP(i, N) {
			int n;
			cin >> n;
			sumn += n;
			SN[i] = n;
		}
		REP(i, M) {
			int m;
			cin >> m;
			summ += m;
			SM[i] = m;
		}
		pair<int, int> ans(-1, -1);
		int cur = INF;
		REP(i, N) {
			REP(j, M) {
				if (sumn - SN[i] + SM[j] == summ - SM[j] + SN[i]) {
					if (cur > SN[i] + SM[j]) {
						cur = SN[i] + SM[j];
						ans = pair<int,int>(SN[i], SM[j]);
					}
				}
			}
		}
		if (ans.first == -1) {
			cout << -1 << endl;
		}
		else {
			cout << ans.first << " " << ans.second << endl;
		}
		cin >> N >> M;
	}
	return 0;
}



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

int main()
{
    int n; cin >> n;
    vector<int> x(n), y(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        y[i] = x[i];
    }
    sort(y.begin(), y.end());
    for (int i = 0; i < n; i++) {
        cout << (x[i] >= y[n/2] ? y[n/2-1] : y[n/2]) << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>
#include <deque>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define v_in(v) for(auto&& i : v) cin >> i
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;


int main(void){
    FAST_IO
    ll n,m;
    cin >> n >> m;
    
    vvll edge(n+1,vll()); // edge[RoomNo.] -> {1, 2, 4...(行けるRoomNo.)} 

    rep(i,m){
        ll a,b;
        cin >> a >> b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    deque<ll> que = {1};
    
    vll sirube(n+1,-1);
    sirube[1] = 0;
    while(!que.empty()){
        ll room_no = que.front();
        for(auto&& i : edge[room_no]){
            if(sirube[i] == -1){
                sirube[i] = room_no;
                que.push_back(i);
            }
        }
        que.pop_front();
    }

    rep(i,n){
        if(sirube[i+1] == -1){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    for(ll i = 2;i < n+1;i++){
        cout << sirube[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 12416
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}
void input(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
}
void swap(int& a, int& b){
	int t=a;
	a = b;
	b = t;
}
 
void solveTest(){
	
	int n,x,d;
	cin>>n>>d>>x;
	int sum=0;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		sum += ceil(d/(float)a);
	}
	cout<<sum+x<<endl;
	return ;
}
 
int main(){
	fastio();
	//input();
 
	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	
	return 0;
}

Measured memory_bytes: 256
x, n = map(int, input().split())
if(n == 0):
  print(x)
  exit()

p = set(map(int, input().split()))
a = set([i for i in range(105)])
np = a-p

ans = 0
dist = 1000000
for i in np:
  if(abs(x-i) < dist):
    dist = abs(x-i)
    ans = i
  elif(abs(x-i) == dist):
    ans = min(i, ans)
  else:
    pass
  
print(ans)

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

int main() {
    int n; cin>>n;
    vector<int>v1(n);
    vector<int>v2(n);
    vector<int>sorted(n);

    vector<vector<int>>ans;
    for(int i = 0; i < n; i++){
        int x = 0;
        cin >> x;
        v1[i] = x;
        sorted[i] = x;
    }
    for(int i = 0; i < n; i++){
        int y = 0;
        cin >> y;
        v2[i] = y;
    }
    sort(sorted.begin(),sorted.end());
    int i = 1;
    int A = 0, B = 0;
    while(next_permutation(sorted.begin(),sorted.end())){
        if(equal(sorted.begin(), sorted.end(), v1.begin())){
            A = i;
        }
        if(equal(sorted.begin(), sorted.end(), v2.begin())){
            B = i;
        }
        i++;
    }

    cout << abs(A - B) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

string A = "AKIHABARA";

int main() {
  string S;
  cin >> S;

  int i{}, j{}, n = S.size();
  while (i < n || j < (int)A.size()) {
    if (S[i] == A[j]) ++i, ++j;
    else if (A[j] == 'A') ++j;
    else break;
  }

  cout << (i == n && j > 7 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 3600
n, a, b = map(int, input().split())
shou = n // (a + b)
amari = n % (a + b)
if amari == 0:
  print(shou * a)
elif shou * (a+b) + a > n:
  print(a*shou + amari)
else:
  print(a*shou + a)

Measured memory_bytes: 38384