akhauriyash/Code-Regression huggingface dataset:
#######################################
import numpy as np
import math
import copy
import re
import sys
#sys.exit(0)

inf = float("inf")
prime = 1

def check_print(check_flag, text, end="\n"):
  if check_flag:
    print(text, end=end)

def c2i(x):
    if str.isdecimal(x):
        return int(x)
    else:
        return x

def cout(*args):
  arglist = []
  for arg in args:
    if hasattr(arg, "__iter__"):
      arglist.extend(arg)
    else:
      arglist.append(arg)
      
  arglist = list(map(str, arglist))
  print(" ".join(arglist))
  
def count2(num):
  count=0
  while num%2==0:
    num/=2
    count+=1
  return count

def ketasum(num):
  nums = [int(s) for s in str(num)]
  return sum(nums)

#math
def gcd(a, b): #最大公約数
  while b:
    a, b = b, a % b
  return a

def lcm(a, b): #最小公倍数
  return a * b // gcd (a, b)

def gcd3(lis): #最大公約数(3over)
  ans = lis[0]
  for li in lis:
    ans = gcd(ans,li)

def lcm3(lis): #最小公倍数(3over)
  ans = lis[0]
  for li in lis:
    ans = lcm(ans,li)

def divisor(n): #nの約数を全て求める
  i = 1
  table = []
  while i * i <= n:
    if n%i == 0:
      table.append(i)
      table.append(n//i)
    i += 1
  table = list(set(table))
  return table

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

def is_prime(n):
  for i in range(2, n + 1):
    if i * i > n:
      break
    if n % i == 0:
      return False
  return n != 1

#input stock
"""
n = int(input())

#list
a = map(int, input().split())
a,b = map(int, input().split())

#縦1dim-list
a = [int(input()) for i in range(n)]

d=[]
for i in range(n):
  d[i]=int(input())

#2dim-list
a = [list(map(int, input().split())) for i in range(n)]

s = input()
ss =  [int(si) for si in s]
"""

#processing stock
"""
a = sorted(a)
a = sorted(a, reverse=True)

"""

#regex
"""
pattern = ""
result = re.search(pattern, s)

result = re.fullmatch(pattern, s)

result = re.finditer(pattern, s)
for res in result:
    print res.group()   # 1回目: ca      2回目: ca   
    print res.start()   # 1回目: 0       2回目: 6      
    print res.end()     # 1回目: 2       2回目: 8      
    print res.span()    # 1回目: (0, 2)  2回目: (6, 8)
"""


#math
"""
#切り捨て
math.floor()
# 切り上げ
math.ceil()
"""

#######################################
n = int(input())
a = [int(input()) for i in range(n)]
a = np.array(a)
max_idx = np.argmax(a)
max_val = np.max(a)

for i in range(max_idx):
  print(max_val)

tmp = np.delete(a, max_idx)
print(np.max(tmp))

for i in range(n-max_idx-1):
  print(max_val)


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

int result = 0;
long long int n;

void dfs(long long int x, int a, int b, int c){
    if(x > n){
        return;
    }
    if(a && b && c){
        result++;
    }

    dfs(10*x + 3, 1, b, c);
    dfs(10*x + 5, a, 1, c);
    dfs(10*x + 7, a, b, 1);
}

int main(){
    
    cin >> n;
    dfs(0, 0, 0, 0);
    cout << result << endl;
}

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

int main(void){
    int A,B,C,K;
    cin>>A>>B>>C>>K;
    while(A>=B){
        B*=2;
        K--;
        if(K<0){
            cout<<"No\n";
            return 0;
        }
    }
    while(B>=C){
        C*=2;
        K--;
        if(K<0){
            cout<<"No\n";
            return 0;
        }
    }
    cout <<"Yes\n";
    return 0;
}

Measured memory_bytes: 3640
/*Author : Kartik Bansal
 *Date : 07/09/19
 *Time : 16:14 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
#define tc int t ;cin>>t ;while(t--)
#define pb push_back
#define FOR(i,n) for(int i =0;i<n;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin() , v.end()
#define sort(v) sort(all(v))
#define vi  vector<int>
#define vll  vector<long long >
#define inf INT_MAX
#define minf INT_MIN



int32_t main()
{
  ios::sync_with_stdio(0) ;
  cin.tie(0) ; cout.tie(0) ;
  ll a,b ;
  char s ; 
  
  cin>>a>>s>>b ;
  if(s == '+')
  cout<<a+ b  ;
  else
       cout<<a-b ; 


  return 0 ;
}


Measured memory_bytes: 256
n = int(input())
dic = []

for i in range(n):
    tmp = input().split()
    dic.append([tmp[0], int(tmp[1]), i + 1])
 
dic.sort(key= lambda x: x[1], reverse= True)
dic.sort(key= lambda x: x[0])

for i in range(n):
    print(dic[i][2])

Measured memory_bytes: 3064
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Int
import Data.Foldable
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

iscanl :: (Int -> a -> b -> a) -> a -> V.Vector b -> V.Vector a
iscanl !k !a !v = V.scanl' (\(!x) (!i, !v) -> k i x v) a (V.indexed v)

iscanlU
  :: (VU.Unbox a, VU.Unbox b)
  => (Int -> a -> b -> a)
  -> a
  -> VU.Vector b
  -> VU.Vector a
iscanlU !k !a !v = VU.scanl' (\(!x) (!i, !v) -> k i x v) a (VU.indexed v)

ipostscanlU
  :: (VU.Unbox a, VU.Unbox b)
  => (Int -> a -> b -> a)
  -> a
  -> VU.Vector b
  -> VU.Vector a
ipostscanlU !k !a !v = iscanlU (\(!i) (!a) (!b) -> k (i + 1) a b)
                               (k 0 a (VU.unsafeHead v))
                               (VU.unsafeTail v)

solve :: Int -> VU.Vector Int8 -> Double
solve !n !pn = V.last dp VU.! ((n + 1) `div` 2)
 where
  dp :: V.Vector (VU.Vector Double)
  dp =
    iscanl
        ( \(!i) (!prev) (!pint) -> VU.generate
          (i + 2)
          ( \(!j) ->
            let
              pi = fromIntegral pint / 100
              qi = 1 - pi
            in
              if j == 0
              then
                1
              else
                prev
                VU.! (j - 1)
                *    pi
                +    (if j == i + 1 then 0 else prev VU.! j * qi)
          )
        )
        (VU.singleton 1)
      $ V.convert pn

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt
  let readDouble :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readDouble b = readInt $ B.drop 2 b

  n  <- (\vec -> (vec VU.! 0)) . VU.unfoldrN 1 readInt <$> B.getLine
  pn <- VU.unfoldrN n readDouble <$> B.getLine
  print $ solve n pn


Measured memory_bytes: 3452
#include<bits/stdc++.h>
#define ll long long 

using namespace std;
int main(){
ll n;
ll sum;
ll M=1000000007;
cin>>n;
ll a[n+1];
for(int i=0;i<n;i++){
cin>>a[i];}
ll ans = 0;
 
  for(int i=0;i<60;i++) {
    ll x = 0;
   for(int j=0;j<n;j++) if (a[j]>>i&1) ++x;
    ll now = x *(n - x) % M;
     for(int j=0;j<i;j++) now = now * 2 % M; // オーバーフロー対策
    ans += now;
    ans %= M;
  }

cout<<ans<<endl;

}

Measured memory_bytes: 2560
import java.util.*;

public class Main{
public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int M = scan.nextInt();
    UF uf = new UF(N);
    for(int i=0;i<M;i++) {
        int a = scan.nextInt() - 1;
        int b = scan.nextInt() - 1;
        uf.unite(a, b);
    }

    scan.close();

    HashSet<Integer> st = new HashSet<>();
    for ( int i=0;i<N;i++) {
        st.add(uf.root(i));
    }
    
    System.out.println((st.size() - 1));
}

    static class UF {
        static int[] par;
        UF(int n) {
            par = new int[n];
            for (int i=0;i<n;i++) {
                par[i] = i;
            }
        }
        int root(int x) {
            if (par[x] == x) return x;
            return par[x] = root(par[x]);
        }
        void unite(int x, int y) {
            int rx = root(x);
            int ry = root(y);
            if (rx == ry) return;
            par[rx] = ry;
        }

        boolean same(int x, int y) {
            int rx = root(x);
            int ry = root(y);
            return rx == ry;
        }
    }
}


Measured memory_bytes: 59036
#include<iostream>
#include<algorithm>
#define ll long long int

using namespace std;


main()
{
	ll l,r,d;
	cin>>l>>r>>d;
	ll ans=0;
	
	for(ll i=l;i<=r;i++)
	{
		if(i%d==0)
			ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3584
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
#define vecout(v,n) for(int i=0; i<n; i++)cout<<v[i]<<" "; cout<<endl;

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}

//x未満の要素数を返す二分探索関数
int b_s(vector<int>&vecxx, int xx) {
	if (xx <= vecxx[0]) { //x以下の要素数を返させる時は"<"に変える
		return 0;
	}
	if (vecxx.back() < xx) { //x以下の要素数を返させる時は"<="に変える
		return vecxx.size();
	}
	int aa1 = 0, aa2 = vecxx.size() - 1, aa3;
	while (aa1 + 1 < aa2) {
		aa3 = (aa1 + aa2) / 2;
		if (vecxx[aa3] >= xx) { //x以下の要素数を返させる時は">"に変える
			aa2 = aa3;
		}
		else {
			aa1 = aa3;
		}
	}
	return aa2;
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
//グループが0個でもいいときはnにxを足す

int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}




signed main() {
	int n, c, ans = 0;
	string s;
	cin >> n >> s;
	rep(i, n) {
		set<char>se;
		c = 0;
		rep(j, i) {
			se.insert(s[j]);
		}
		for (int j = i; j < n; j++) {
			if (se.count(s[j])) {
				c++;
				se.erase(s[j]);
			}
		}
		ans = max(ans, c);
	}
	cout << ans << endl;
}




Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
  long int l, r, i, j;
  int min = 2019;
  scanf("%ld", &l);
  scanf("%ld", &r);
  
  if ( r-l >= 2019-1 ) {
    min = 0;
    printf("%d", min);
    return 0;
  }

  for ( i = l; i <= r-1; i++ ) {
    for ( j = i+1; j <= r; j++ ) {
      if( ( (i*j) % 2019 ) < min ) min = (i*j) % 2019;
    }
  }
  printf("%d", min);

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
bool is_palindrome(string s)
{
    string t(s.rbegin(),s.rend());
    return s==t;
}
int main()
{
    string s;
    cin>>s;
    int n=s.size();
    if(is_palindrome(s)&&is_palindrome(s.substr(0,(n-1)/2))&&is_palindrome(s.substr((n+1)/2)))
    cout<<"Yes";
    else
    cout<<"No";
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort(reverse=True)
    rect = []
    prev = 0
    for a in A:
        if a == prev:
            rect.append(a)
            prev = 0
            if len(rect) == 2:
                break
        else:
            prev = a

    if len(rect) == 2:
        ans = rect[0] * rect[1]
    else:
        ans = 0
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14244
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
#include <queue>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n, c, k;
    cin >> n >> c >> k;
    vector<ll> t(n);
    REP(i,n) cin >> t[i];
    sort(t.begin(), t.end());
    ll ans = 1;
    int dead = t[0]+k;
    int now = 0;
    for (int i = 0; i < n; ++i) {
        if (dead >= t[i] && now < c) now++;
        else {
            ans++;
            now = 0;
            dead = t[i]+k;
            i--;
        }
    }
    cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    int s[n], ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        ans += s[i];
    }
    sort(s, s+n);
    if (ans % 10 == 0) {
        for (int i = 0; i < n; i++) {
            if ((ans - s[i]) % 10) {
                ans -= s[i];
                break;
            }
            if (i == n - 1) ans = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int** table;
int** ruisekiwa;
int N,D,num[100],index[100],total[100];

void func(){
	for(int i = 0; i < N; i++)index[i] = 1;

	int sum,minimum = BIG_NUM,maximum = -1,second;
	bool FLG;

	for(int i = 0; i < N; i++){
		scanf("%d",&num[i]);

		sum = 0;

		for(int k = 0; k < num[i]; k++){
			scanf("%d",&table[i][num[i]-k]);

			ruisekiwa[i][num[i]-k] = table[i][num[i]-k];
			sum += table[i][num[i]-k];

		}
		total[i] = sum;
		minimum = min(minimum,sum);
		maximum = max(maximum,sum);

		for(int k = 1; k <= num[i];k++){
			ruisekiwa[i][k] += ruisekiwa[i][k-1];
		}
	}

	while(true){
		FLG = false;

		for(int i = 0; i < N; i++){

			if(total[i]-ruisekiwa[i][index[i]-1] == maximum){

				second = -1;
				for(int k = 0; k < N; k++){
					if(k != i){
						second = max(second,total[k]-ruisekiwa[k][index[k]-1]);
					}
				}

				while(abs(second-(total[i]-ruisekiwa[i][index[i]]) <= D) && abs(minimum-(total[i]-ruisekiwa[i][index[i]]) <= D) && index[i] <= num[i]){
					index[i]++;
					FLG = true;
				}
				if(FLG){
					maximum = second;
				}

			}else{

				while(abs(maximum-(total[i]-ruisekiwa[i][index[i]]) <= D) && abs(minimum-(total[i]-ruisekiwa[i][index[i]]) <= D) && index[i] <= num[i]){
					index[i]++;
					FLG = true;
				}
			}
		}
		if(!FLG)break;

		minimum = BIG_NUM,maximum = -1;
		for(int i = 0; i < N; i++){
			maximum = max(maximum,total[i]-ruisekiwa[i][index[i]-1]);
			minimum = min(minimum,total[i]-ruisekiwa[i][index[i]-1]);
		}
	}


	FLG = true;

	for(int i = 0; i < N; i++){
		if(index[i] <= num[i]){
			FLG = false;
			break;
		}
	}

	if(FLG){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

}

int main(){

	table = new int*[100];
	ruisekiwa = new int*[100];
	for(int i = 0; i < 100; i++){
		table[i] = new int[10001];
		ruisekiwa[i] = new int[10001];
	}
	for(int i = 0; i < 100; i++)ruisekiwa[i][0] = 0;

	while(true){
		scanf("%d %d",&N,&D);
		if(N == 0 && D == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

bitset<12801> dp[82][82];
int a[82][82];
int b[82][82];

int main(){
    int h,w;
    cin >> h >> w;
    rep(i,h)rep(j,w) cin >> a[i][j];
    rep(i,h)rep(j,w) cin >> b[i][j];
    dp[0][0][6400+a[0][0]-b[0][0]] = 1;
    dp[0][0][6400-b[0][0]+a[0][0]] = 1;
    rep(i,h)rep(j,w){
        int d = abs(a[i][j] - b[i][j]);
        if(i>0) dp[i][j] |= ((dp[i-1][j]<<d) | (dp[i-1][j]>>d)) ;
        if(j>0) dp[i][j] |= ((dp[i][j-1]<<d) | (dp[i][j-1]>>d)) ;
    }
    
    int ans = INF;
    rep(i,12801){
        if(dp[h-1][w-1][i]) ans = min(ans,abs(i-6400));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10624
N, M = map(int, input().split())
v = set()


def dfs(graph, start, visited):
    stack = [start]
    visited.add(start)
    while stack:
        label = stack.pop(0)
        for node in g[label]:
            if node not in visited:
                visited.add(node)
                stack.append(node)
    return visited


g = {i: [] for i in range(1, N + 1)}
for i in range(M):
    x, y, z = map(int, input().split())
    g[x].append(y)
    g[y].append(x)
ans = 0
for i in range(1, N + 1):
    if i not in v:
        ans += 1
        dfs(g, i, v)
print(ans)

Measured memory_bytes: 38204
#include <iostream>
#define NODE_MAX 100000
#define NIL -1
using namespace std;

struct Node
{
    int parent_node = NIL;
    int leftChild_node = NIL;
    int rightSibling_node = NIL;
};

Node Tree[NODE_MAX];
int Depth_of_Node[NODE_MAX];

void CalcDepthByRecursion(int node_id, int depth) 
{
    Depth_of_Node[node_id] = depth;
    if (Tree[node_id].rightSibling_node != NIL) 
    {
        CalcDepthByRecursion(Tree[node_id].rightSibling_node, depth);
    }
    if ( Tree[node_id].leftChild_node != NIL )
    {
        CalcDepthByRecursion(Tree[node_id].leftChild_node, depth+1);
    }
}

// Print out children nodes
void PrintChildrenNodes(int node_id) 
{
    printf("[");
    int child_node = Tree[node_id].leftChild_node, i = 0;
    while (child_node != NIL) 
    {
        if (i) printf(", ");
        printf("%d", child_node);
        child_node = Tree[child_node].rightSibling_node;
        ++i;
    }
    printf("]");
}

int main() 
{
    int num_node, node_id, num_child, root;
    scanf("%d", &num_node);
    for (int i = 0; i < num_node; ++i) 
    {
        scanf("%d %d", &node_id, &num_child);
        int child_node, prev_node;
        for (int j = 0; j < num_child; ++j) 
        {
            scanf("%d", &child_node);
            if (!j) Tree[node_id].leftChild_node = child_node; // set left_child node
            Tree[child_node].parent_node = node_id; // set parent_node
            if (j) Tree[prev_node].rightSibling_node = child_node; // set rightSibling of previous node
            prev_node = child_node; // set current node as prev node
        }
    }

    // search node
    for (int i = 0; i < num_node; ++i) 
    {
        if (Tree[i].parent_node == NIL) 
        {
            root = i;
            break;
        }
    }

    CalcDepthByRecursion(root, 0);
    for (int i = 0; i < num_node; ++i) 
    {
        printf("node %d: parent = %d, depth = %d, ", i, Tree[i].parent_node, Depth_of_Node[i]);
        if (Tree[i].parent_node == NIL) printf("root, ");
        else if (Tree[i].leftChild_node == NIL) printf("leaf, ");
        else printf("internal node, ");
        PrintChildrenNodes(i);
        printf("\n");
    }
}


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


int a1, b1, a2, b2;

int main(){
	cin >> a1 >> b1 >> a2 >> b2;
	int x =a2-a1;
	int y =b2-b1;
	cout << a2 - y << " " << b2 + x << " " << a1 - y << " " << b1 + x << endl;
	return 0;
}


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


int main() {
	
	int h, n;
	cin >> h >> n;
	vector<int> a(n), b(n);
	for(int i=0; i<n; i++) cin >> a.at(i) >> b.at(i);
	
	vector<int> dp(2*pow(10,8));
	for(int i=0; i<10+pow(10,8); i++){
		if(dp.at(i)>=h) {
			cout << i << endl;
			break;
		}
		for(int j=0; j<n; j++){
			if(dp.at(i)+a.at(j) > dp.at(i+b.at(j))) dp.at(i+b.at(j)) = dp.at(i)+a.at(j);
		}
	}
	
	
	return 0;
}

Measured memory_bytes: 781568
import java.util.Scanner;

class Main{
	public static void main (String[]args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(a < b) System.out.println("a < b");
		if(a > b) System.out.println("a > b");
		if(a == b) System.out.println("a == b");
		sc.close();
		}
}


Measured memory_bytes: 26404
#include <iostream>

using namespace std;
int n,sol,nr,x;
int main()
{
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        cin>>x;
        if(x==i) ++nr;
        else
        {
            sol=sol+nr/2+nr%2;
            nr=0;
        }
    }
    sol=sol+nr/2+nr%2;
    cout<<sol;
    return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;

inline void read(int &x) {
	char ch; bool f = 0; while((ch = getchar()), (ch < '0' || ch > '9')) f |= (ch == '-');
	x = ch - '0'; while((ch = getchar()), (ch >= '0' && ch <= '9')) x = x * 10 + (ch  - '0');
	if(f) x = -x;
}

const int MAXN = 100010;
int A[MAXN], N;

int main() {
	int i, t, Ans = 0, MaxV = 0; read(N);
	for(i = 1; i <= N; i++) read(t), A[t - 1]++, A[t]++, A[t + 1]++, MaxV = max(MaxV, t + 1);
	for(i = 1; i <= MaxV; i++) Ans = max(Ans, A[i]);
	printf("%d", Ans);
}

Measured memory_bytes: 512
from collections import Counter
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
a = list(map(int, input().split()))

a_cnt = Counter(a)

a_comb = {}
for key, val in a_cnt.items():
    if val >= 2:
        a_comb[key] = combinations_count(val, 2)
    else:
        a_comb[key] = 0

sum_v = sum(a_comb.values())

for num in a:
    print(sum_v-a_cnt[num]+1)

Measured memory_bytes: 32276
#include<stdio.h>

int main()
{
	int c1,c2,c3, i, cnt;
	int arr[11] = { 0 };

	while (scanf("%d%d%d", &c1,&c2,&c3) != EOF) 
	{
		cnt = 0;
		arr[c1] = arr[c2] = arr[c3] = 1;
		for (i = 1; i <11; i++)
		{
			if (arr[i]==0&&i <= (20 - c1 - c2))
			{
				++cnt;
			}
			else
			{
				arr[i] = 0;
			}
		}

		if (cnt < 4)
		{
			puts("NO");
		}
		else
		{
			puts("YES");
		}
		
	}
	return 0;
}


Measured memory_bytes: 576
// A - Zero-Sum Ranges

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

ll A[200000];
ll S[200001];

ll comb2(ll n) {
	return n * (n-1) / 2;
}

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

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

	for (int i=0; i<N; i++) {
		S[i+1] = S[i] + A[i];
	}

	unordered_map<ll, ll> cnt;
	for (int i=0; i<=N; i++) {
		cnt[S[i]]++;
	}

	ll ans = 0;
	for (auto itr : cnt) {
		ll val = itr.second;
		ans += comb2(val);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 14384
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;
  int count = 0;
  int* numa = new int[30];
  int* numb = new int[30];
  for(int i=0;i<n;i++){
    int cand = 0;
    for(int j=0;j<30;j++) numa[j] = 0;
    for(int j=0;j<i;j++){
      numa[s[j]-'a'] = 1;
    }
    for(int j=0;j<30;j++) numb[j] = 0;
    for(int j=i;j<n;j++){
      numb[s[j]-'a'] = 1;
    }
    for(int j=0;j<30;j++) cand += numa[j] * numb[j];
    count = max(count,cand);
  }
  
  cout <<count  << endl;
  return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N, M;
    cin >> N >> M;

    vector<int> v[15];
    for(int i = 0; i < M; ++i) {
        int k;
        cin >> k;
        for(int j = 0; j < k; ++j) {
            int a;
            cin >> a;
            v[i].pb(a);

        }
    }

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

    }

    int res = 0;
    for(int i = 0; i < (1 << N); ++i) {
        int cnt = 0;
        for(int j = 0; j < M; ++j) {
            int c = 0;
            for(int k = 0; k < v[j].size(); ++k) {
                if(i >> (v[j][k] - 1) & 1) ++c;

            }
            if(c % 2 == p[j]) ++cnt;

        }
        if(cnt == M) ++res;
    }
    cout << res << endl;

    return 0;
}



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

using namespace std;

int main() {
  ios::sync_with_stdio(false); cin.tie(NULL);
  int m, d; cin >> m >> d;
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= d; j++) {
      int d1 = j % 10;
      int d10 = (j / 10) % 10;
      if (j >= 10 && j <= 99 && d1 >= 2 && d10 >= 2 && d1 * d10 == i) ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
import sys
#import time
from collections import deque, Counter, defaultdict
#from fractions import gcd
import bisect
import heapq
#import math
import itertools
import numpy as np
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
x = ri()
for i in range(-200, 200):
    for j in range(-200, 200):
        if i**5 - j**5 == x:
            print(i,j)
            sys.exit()

Measured memory_bytes: 26864
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)
    if op=="?":
        break
    elif op=="+":
        print(a+b)
    elif op=="-":
        print(a-b)
    elif op=="*":
        print(a*b)
    elif op=="/":
        print(a//b)


Measured memory_bytes: 5592
n = int(input())
D = [tuple(int(x) for x in input().split()) for _ in range(n)]
tmp = 0
for d1, d2 in D:
    if d1 == d2:
        tmp += 1
    else:
        tmp = 0
    if tmp == 3:
        print("Yes")
        exit()
print("No")

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

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

	long a[100];
	a[0] = 2;
	a[1] = 1;
	for (int i=2;i<n+1;i++){
		a[i] = a[i-1]+a[i-2];
	}

	cout << a[n] << endl;
}

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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

//#define _USE_MATH_DEFINES
//#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef int long long i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 1000000007; // 10000000000000007ll;

const double eps = 1e-8;

const i64 MAXN = 1'000'000 + 6;

i64 n;
i64 a[MAXN] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    i64 h, w;
    cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1 << endl;
        return 0;
    }
    i64 R = (w / 2 + w % 2) * (h / 2 + h % 2) + (w / 2) * (h / 2);
    cout << R << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n; cin>>n;
    int p[n]; rep(i,n) cin>>p[i];
    int cnt=0;
    rep(i,n){
        if(p[i]==i+1){
            if(i!=n-1) swap(p[i],p[i+1]);
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 640
import sys


s = int(input())
A = [0, s]

for i in range(2, 1000001):
    n = A[i-1]
    if n % 2 == 0:
        tmp = n / 2
        if tmp in A:
            print(i)
            sys.exit()
        else:
            A.append(tmp)
    else:
        tmp = 3 * n + 1
        if tmp in A:
            print(i)
            sys.exit()
        else:
            A.append(tmp)


Measured memory_bytes: 3060
fun main(args: Array<String>){
    val (n,x) = readLine()!!.split(" ").map(String::toInt)
    val list = readLine()!!.split(" ").map(String::toInt)

    val difflist = mutableListOf<Int>()

    for(i in 0..list.size-1){
            difflist.add(Math.abs(x-list[i]))
    }

    var answer = difflist[0]
    for(i in 0..difflist.size-2){
        answer = gcd(answer,difflist[i+1])
    }

    //println(difflist)
    println(answer)


}


fun gcd(a: Int, b: Int): Int = if(a < b) gcd(b, a) else if(b == 0) a else gcd(b, a % b)
fun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)

Measured memory_bytes: 51620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;

int main() {
  int64_t N,answer=0;
  cin>>N;
  for(int64_t i=1;i*i<N;i++){
    if(N%i==0&&i<(N/i)-1) answer+=(N/i)-1;
  }
  cout<<answer;
}


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

using namespace std;


int main()
{
	int N, A, B;
	cin >> N >> A >> B;
	int sum = 0;
	int ans = 0;
	for (int i = 1; i <=N; i++) {
		int t=i;
		sum = 0;
		while (t>0) {
			sum += t % 10;
			t /= 10;
		}
		if (A <= sum && B >= sum) {
			ans+= i;
		}
	}
cout << ans << endl;
}


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

int main() {
   string a,b; cin >> a >> b;
   int n = a.size();
   int m = b.size();

   if(n != m){
       if(n > m)print("GREATER");
       else if(n < m)print("LESS");
       else print("EQUAL");
   }else{
       for (int i = 0; i < n; ++i) {
           if(a[i] == b[i]){
               if(i != n - 1)continue;
               else print("EQUAL");
           }
           else{
               if(a[i] > b[i])print("GREATER");
               else if(a[i] < b[i])print("LESS");
               break;
           }
       }
   }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
using namespace std;
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<vector<pair<int,int>>> xy(n);
    for (int i = 0; i < n; i++)
    {
        int a; cin >> a;
        for (int j = 0; j < a; j++)
        {
            int b, c; cin >> b >> c;
            b--;
            xy[i].emplace_back(b, c);
        }
    }
    
    int ans = 0;
    for (int bit = 0; bit < (1<<n); bit++)
    {
        int tmp = 0;
        bool ok = true;
        for (int i = 0; i < n; i++)
        {
            if (bit & (1<<i)) {
                tmp++;
                for (auto v: xy[i]) {
                    if (v.second == 1 && !(bit&(1<<v.first))) ok = false;
                    if (v.second == 0 && (bit&(1<<v.first))) ok = false;
                }
            }
        }

        if (ok) ans = max(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;




int main(){

	int n, m; cin >> n >> m;

	vector <int> a(n), b(n);

	vector < pair <int, int> > v(n);

	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
		v[i].first = a[i];
		v[i].second = b[i];
	}

	map <int, vector <int> > count;


	for(int i = 0; i < n; i++){
		count[a[i]].push_back(b[i]);
	}

	int ans = 0;

	multiset <int> s;

	for(int i = 1; i <= m; i++){
		for(int j = 0; j < count[i].size(); j++){
			s.insert(count[i][j]);
		}
		if(!s.empty()){
			ans += *prev(s.end());
			s.erase(prev(s.end()));
		}
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 14708
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long kai = x / 11;
        long amari = x % 11;
        if (amari == 0) {
            System.out.println(kai * 2);
        } else if (amari <= 6) {
            System.out.println(kai * 2 + 1);
        } else {
            System.out.println(kai * 2 + 2);
        }

    }
}

Measured memory_bytes: 21972
#include<iostream>

using namespace std;

int main() {
	int N;
	cin >> N;
	bool f = true;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		if (a % 2 == 1)continue;
		if ((a % 3 == 0 || a % 5 == 0));
		else f = false;
	}
	if (f)cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;
	return 0;
}

Measured memory_bytes: 888
#include <stdio.h>

#define MAX 200000
#define SENTINAL 2000000000
typedef long long llong;

int L[MAX / 2+2], R[MAX / 2+2];

llong merge(int A[], int n, int left, int mid, int right)
{
	int i, j, k;
	llong cnt = 0;
	int n1 = mid - left;
	int n2 = right - mid;
	for(i=0; i<n1; i++){
		L[i] = A[left + i];
	}
	for(i=0; i<n2; i++){
		R[i] = A[mid + i];
	}
	L[n1] = R[n2] = SENTINAL;
	i =0;
	j = 0;
	for(k=left; k<right; k++){
		if(L[i] <= R[j])
		{
			A[k] = L[i++];
		}
		else
		{
			A[k] = R[j++];
			cnt += n1 - i;
		}
	}
	return cnt;
}


llong mergeSort(int A[], int n, int left, int right)
{
	int mid;
	llong v1, v2, v3;
	if(left + 1 < right)
	{
		mid = (left + right) /2;
		v1 = mergeSort(A, n, left, mid);
		v2 = mergeSort(A, n, mid, right);
		v3 = merge(A, n, left, mid, right);
		return v1 + v2 + v3;
	}
	else return 0;
}


int main (void)
{
	int A[MAX], n, i;
	
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", &A[i]);
	}
	
	llong ans = mergeSort(A, n, 0, n);
	printf("%lld\n", ans);
	
	return 0;
}


Measured memory_bytes: 3360
import itertools
inf=10**8
n,m,R=map(int,input().split())
r=list(map(int,input().split()))
d=[[inf]*n for i in range(n)]
for i in range(n):
    d[i][i]=0
ans=inf
for i in range(m):
    a,b,c=map(int,input().split())
    d[a-1][b-1]=c
    d[b-1][a-1]=c
for k in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j]=min(d[i][j],d[i][k]+d[k][j])
for i in itertools.permutations(r):
    preans=0
    for j in range(R-1):
        preans+=d[i[j]-1][i[j+1]-1]
    ans=min(ans,preans)
print(ans)

Measured memory_bytes: 46808
#include <stdio.h>
#include <stdlib.h>
 
struct node_t {
    int key;
    struct node_t *parent;
    struct node_t *left;
    struct node_t *right;
};
typedef struct node_t Node;
 
Node *tree_insert(Node *top, Node *z) {
    Node *y, *x;
 
    y = NULL;
    x = top;
    while (x != NULL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    z->parent = y;
    if (y == NULL) {
        top = z;
    } else if (z->key < y->key) {
        y->left = z;
    } else {
        y->right = z;
    }
    return top;
}
 
Node *tree_find(Node *node, int key) {
    if (node == NULL)
        return NULL;
    if (node->key == key)
        return node;
    if (key < node->key)
        return tree_find(node->left, key);
    return tree_find(node->right, key);
}
 
Node *tree_minimum(Node *x) {
    while (x->left != NULL) {
        x = x->left;
    }
    return x;
}
 
Node *tree_successor(Node *x) {
    Node *y;
 
    if (x->right != NULL) {
        return tree_minimum(x->right);
    }
    y = x->parent;
    while (y != NULL && x == y->right) {
        x = y;
        y = y->parent;
    }
    return y;
}
 
Node *tree_delete(Node *top, Node *z) {
    Node *y, *x;
 
    if (z->left == NULL || z->right == NULL) {
        y = z;
    } else {
        y = tree_successor(z);
    }
 
    if (z->left != NULL) {
        x = y->left;
    } else {
        x = y->right;
    }
 
    if (x != NULL) {
        x->parent = y->parent;
    }
    if (y->parent == NULL) {
        top = x;
    } else if (y == y->parent->left) {
        y->parent->left = x;
    } else {
        y->parent->right = x;
    }
 
    if (y != z) {
        z->key = y->key;
    }
    return top;
}
 
void inorder_walk(Node *node) {
    if (node->left != NULL) {
        inorder_walk(node->left);
    }
    printf(" %d", node->key);
    if (node->right != NULL) {
        inorder_walk(node->right);
    }
}
 
void preorder_walk(Node *node) {
    printf(" %d", node->key);
    if (node->left != NULL) {
        preorder_walk(node->left);
    }
    if (node->right != NULL) {
        preorder_walk(node->right);
    }
}
 
int main(void) {
    int n, i, key;
    char cmd[20];
    Node *top = NULL, *p;
 
    scanf("%d ", &n);
    for (i = 0; i < n; i++) {
        scanf("%s %d ", cmd, &key);
        if (cmd[0] == 'i') {
            p = malloc(sizeof(Node));
            p->key = key;
            p->parent = p->left = p->right = NULL;
            top = tree_insert(top, p);
        } else if (cmd[0] == 'f') {
            puts(tree_find(top, key) != NULL ? "yes" : "no");
        } else if (cmd[0] == 'd') {
            p = tree_find(top, key);
            if (p != NULL) {
                top = tree_delete(top, p);
            }
            //free(p);
        } else {
            inorder_walk(top);
            putchar('\n');
            preorder_walk(top);
            putchar('\n');
        }
    }
    return 0;
}

Measured memory_bytes: 20504
#include <stdio.h>
int main(){
  int h,w,i,j,p=1,q=1;
  while(1){
    scanf("%d %d",&h,&w);
    if(h==0 && w==0){
      break;
 }
    for(i=1;i<=h;i++){ 
      if(i%2==0){
    for(j=1;j<=w;j++){
      if(j%2==0){
        printf("#");
      }else{
        printf(".");
        }
    }
      } else {
    for(j=1;j<=w;j++){
      if(j%2==0){
        printf(".");
      }else{
        printf("#");
      }
    }
      }
      printf("\n");
    }
    printf("\n"); 
  }
  return 0;
}


Measured memory_bytes: 2032
#!/usr/bin/env python3
import sys


def solve(N: int, K: int):
    count = 0

    if K % 2 == 0:
        count += (N//K)**3
        # a,b,c == 0 mod K//2
        count += (N//(K//2) - N//K)**3
    else:
        count += (N//K)**3
    print(count)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N, K;
  cin >> N >> K;
  string S;
  cin >> S;

  ll border = 0;
  char now = S[0];
  for (ll i = 1; i < N; i++) {
    if (S[i] != now) {
      border++;
    }
    now = S[i];
  }
  ll before_score = N - 1 - border;
  ll after_score = min((N - 1), (before_score + (K * 2)));

  cout << after_score << endl;
  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[]arr = new int[5];
    int ans =0;
    for(int i=0;i<5;i++){
      arr[i]=sc.nextInt();
      if(arr[i]==0){
        ans=i+1;
      }
    }
    System.out.println(ans);
    System.out.flush();
    sc.close();
  }
}


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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

int main(){
    fcin;

    int n;
    cin >> n;
    string s;   
    cin >> s;
    for(int len = 0; len < n; len++){
        for(int i = 0; i < n; i++){
            if(i + len > n) continue;
            string t = s.substr(i, len);
            if(s == t + t) return cout << "Yes" << endl, 0;
        }
    }
    cout << "No" << endl;
    return 0;
}



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

int main() {
	ll n, k,i=1;
	cin >> n >> k;
	n = n % k;
	while (i != 0) {
		if (n < abs(k - n)) {
			i = 0;
			break;
		}else {
			n = abs(k - n);
		}
	}
	cout << n << endl;
	return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    string s,t;
    cin >> s >> t;

    int ans = 0;
    if( s[0] == t[0] ) ans++;
    if( s[1] == t[1] ) ans++;
    if( s[2] == t[2] ) ans++;
    cout << ans << endl;


}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 1000000000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    multiset<ll>s;
    ll q;cin>>q;
    while(q--){
        ll a,x;cin>>a>>x;
        if(a==0){
            s.insert(x);
            cout<<s.size()<<endl;
        }
        else if(a==1){
            cout<<s.count(x)<<endl;
        }
        else if(a==2){
                s.erase(x);
        }
        else{
            ll l=x;
            ll r;cin>>r;

            auto left=s.lower_bound(l);

            auto right=s.upper_bound(r);
            for(auto it=left;it!=right;it++){
                cout<<*it<<endl;
            }
        }
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





































Measured memory_bytes: 12372
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let l: i64 = input();
    let r: i64 = input();
    const MOD: i64 = 2019;

    let r = std::cmp::min(r, l + 4096);

    let mut ans = i64::max_value();
    for i in l..r + 1 {
        for j in i + 1..r + 1 {
            ans = std::cmp::min(ans, i % MOD * j % MOD);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 
ll Abs(ll x,ll y){
    if(x>=y)return x-y;
    else return y-x;
}

int main(void){
    ll x,y;
    cin>>x>>y;
    if(Abs(x,y)<=1)cout<<"Brown"<<endl;
    else cout<<"Alice"<<endl;
    return 0;
}



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

int main(){
    while(1){
        int n, x, count = 0;
        cin >> n >> x;
        if(n == 0 && x == 0) break;
        for(int i=1; i<=n; i++){
            for(int j=i+1; j<=n; j++){
                for(int k=j+1; k<=n; k++){
                    if(x == (i+j+k)) count++;
                }
            }
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 3096