akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}


//for(int i = ; i < ; i++){}

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  cout<<min(n*a,b)<<endl;
  return 0;
}




Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-6;
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
const char nl = '\n';

template <typename T> inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> void ckmin(T& a, T b) { a = min(a, b); }
template <class T> void ckmax(T& a, T b) { a = max(a, b); }

// (Integer/Long).bitCount(x)
int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }

void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) { cerr << h; if (sizeof...(t)) cerr << ", "; DBG(t...); }

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
void setIO(string s = "") {
	unsyncIO();
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); }
}

// Binary Exponentiation
ll pow(ll b, ll e, ll m = 0LL, ll ans = 1LL) { while (e) { if (e & 1LL) { ans *= b; if (m) ans %= m; } b *= b, e >>= 1LL; if (m) b %= m; } return ans; }



void solve(int tcn) {
	int n;
	cin >> n;
	int a[n];
	F0R(i, n) cin >> a[i];
	sort(a,a+n);
	int ans = 0;
	F0R(i, n) {
		FOR(j, i+1, n) {
			FOR(k, j+1, n) {
				if (a[i] + a[j] > a[k] && a[i] != a[j] && a[j] != a[k]) {
					++ans;
				}
			}
		}
	}
	cout << ans << nl;
}

int main() {
    setIO();

    int t = 1; //cin >> t;
	for (int i = 1; i <= t; ++i) {
		//cout << "Case #" << i << ": ";
		solve(i);
	}
	return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include<vector>
using namespace std;
int main(void){
    int n,m;
    cin>>n>>m;
    vector<int> v(n,0);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        v[a-1]++;
        v[b-1]++;
    }
    for(int i=0;i<n;i++){
        cout<<v[i]<<endl;
    }
    return 0;
    // Your code here!
    
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  # @lru_cache(None)
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**6)
# ----------------------------------------------------------- #

x, n = (int(x) for x in input().split())
if n == 0:
    print(x)
    exit()
P = list(int(x) for x in input().split())

for i in range(53):
    if x-i not in P:
        print(x-i)
        exit()
    if x+i not in P:
        print(x+i)
        exit()

Measured memory_bytes: 72452
n = int(input())
brackets_plus = []
brackets_minus = []
right = 0
left = 0
for i in range(n):
    s = input()
    cur = 0
    m = 0
    for j in range(len(s)):
        if s[j] == "(":
            left += 1
            cur += 1
        else:
            right += 1
            cur -= 1
            m = min(m,cur)
    if cur >= 0:
        brackets_plus.append((m,cur))
    else:
        brackets_minus.append((m,cur,m-cur))
if right != left:
    print("No")
    exit()
cur = 0
brackets_plus.sort(reverse = True)
for i in brackets_plus:
    if i[0] + cur < 0:
        print("No")
        exit()
    cur += i[1]
brackets_minus.sort(key = lambda x:x[2])
for i in brackets_minus:
    if i[0] + cur < 0:
        print("No")
        exit()
    cur += i[1]
print("Yes")

Measured memory_bytes: 176140
import java.util.*;

public class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(Math.min(n*a,b));


    }
}


Measured memory_bytes: 23764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		int x = Integer.parseInt((new BufferedReader(new InputStreamReader(System.in))).readLine());
		System.out.println((x * x * x));
	}
}

Measured memory_bytes: 24280
S =list(input())

former = int(S[0])*10+int(S[1])
latter = int(S[2])*10+int(S[3])
former_YY=False
former_MM=False
latter_YY=False
latter_MM=False

if former <= 99:
    former_YY = True
    
if former <= 12 and former > 0:
    former_MM = True

if latter <= 99:
    latter_YY = True

if latter <= 12 and latter > 0:
    latter_MM = True

if former_YY and former_MM and latter_YY and latter_MM:
    print("AMBIGUOUS")
elif former_YY and latter_MM:
    print("YYMM")
elif former_MM and latter_YY:
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3064
/* 
 * Project: M-SOLUTIONS プロコンオープン 2020 D - Road to Millionaire
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/07/28
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
using namespace std;

int n;
int a[80];

void solve() {
    long money = 1000;
    for (int i=0;i<n-1;i++) {
        if (a[i] < a[i+1]) {
            money += (a[i+1]-a[i]) * (long)(money/a[i]);
        }
    }
    printf("%ld\n", money);
}

int main() {

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

    solve();
}

Measured memory_bytes: 3200
<?php

	$str = trim( fgets( STDIN ) );
	$n = trim( fgets( STDIN ) );
	while( $n-- ) {
		$cmds = explode( " ", trim( fgets(STDIN) ) );
		$s = $cmds[1];
		$e = $cmds[2];
		$len = $e-$s+1;
		if( "print" == $cmds[0] ) {
			print substr( $str, $s, $len ).PHP_EOL;
		} else if( "reverse" == $cmds[0] ) {
			$arr = preg_split( '//', substr( $str, $s, $len ), -1, PREG_SPLIT_NO_EMPTY );
			$t = array_reverse( $arr );
			$str = substr( $str, 0, $s ).implode( '', $t ).substr( $str, $e+1 );
		} else if( "replace" == $cmds[0] ) {
			$str = substr( $str, 0, $s ).$cmds[3].substr( $str, $e+1 );
		}
	}
	return;
?>

Measured memory_bytes: 15724
-- FileName   : 163d
-- CreatedDate: 2020-04-19 21:19:49

import Control.Monad
import Data.List

count n e = ((times e n) + e - (times e e) + 1) `mod` base

main = do
   [n,k] <- getIntegerList
   putStrLn $ show $ (sum $ map (count n) [k..n+1]) `mod` base


--------------------------------------------
getIntList        = map (read :: String -> Int) . words <$> getLine
getIntegerList    = map (read :: String -> Integer) . words <$> getLine
getIntegerListN m = map (read :: String -> Integer) <$> replicateM m getLine


base :: Integer
base = 1000000007

plus :: Integer -> Integer -> Integer
plus a b = (a+b) `mod` base

times :: Integer -> Integer -> Integer
times a b = a * b `mod` base

minus :: Integer -> Integer -> Integer
minus a b
   | a < b     = a-b + base
   | otherwise = a-b

power :: Integer -> Integer -> Integer
power n k
   | k == 0         = 1
   | k `mod` 2 == 0 = power (times n n) (k`div`2)
   | otherwise      = times n $! power n (k-1)

inv :: Integer -> Integer
inv n = power n $ base - 2

binom :: Integer -> Integer -> Integer
binom n m
   | (n-m) < m = times (foldr times 1 [m+1..n]) $ inv $ foldr times 1 [1..n-m]
   | otherwise = times (foldr times 1 [n-m+1..n]) $ inv $ foldr times 1 [1..m]


Measured memory_bytes: 5012
IDENTIFICATION DIVISION.
 PROGRAM-ID. TEST01.

 ENVIRONMENT DIVISION.

 DATA DIVISION.
 WORKING-STORAGE SECTION.

  01 INP.
   03 N  PIC 9(1).
  01 S   PIC 9(3).
  01 ANS PIC ZZ9.

 PROCEDURE DIVISION.
 
  ACCEPT INP.
 
  COMPUTE S = N * N * N
  MOVE S TO ANS.      
  DISPLAY ANS.
 
  STOP RUN. 

Measured memory_bytes: 384
#include <stdio.h>

int main(){
  long long int a, b, c, k;
  scanf("%lld %lld %lld %lld", &a, &b, &c, &k);

  long long int ans;
  if(k%2)
    ans = b - a;
  else
    ans = a - b;

  printf("%lld\n", ans);
  return 0;
}


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

using namespace std;

int main() {
  int x,a,b,c;
  int count=0;
  cin >>a >> b >> c >>x;
  
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b; j++){
      for(int k=0 ;k<=c;k++){
        if(x == 500*i+100*j + 50*k)
          count++;
      }
    }
  }
  cout << count <<endl;
}


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

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

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

#define BIT_ON(x,b) ((x)|=(b))
#define BIT_OFF(x,b) ((x)&=~(b))
#define BIT_IS_ON(x,b) (((x)&(b))==(b))


using namespace std;

typedef pair<int, int> P;

int main(void){
  int n,m,i,x,y;
  cin >> n >> m;
  vector<pair<int,bool>> box(n);
  vector<P> operation(m);

  REP(i,n){
    box[i].first = 1;
    box[i].second = false;
  }

  REP(i,m){
    scanf("%d%d",  &operation[i].first, &operation[i].second);
  }

  box[0].second = true;
  
  REP(i,m){
    x = operation[i].first - 1;
    y = operation[i].second - 1;
    box[x].first--;
    box[y].first++;

    if(box[x].second == true) box[y].second = true;
    if(box[x].first == 0) box[x].second = false;

  }
  int c = 0;
  REP(i,n) if(box[i].second) c++;
  //REP(i,m) dump(box[x].second);
  cout << c << endl;
  return 0;
}


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

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

int main() {
  int N;
  cin >> N;
  map<string, int> v;
  rep(i, N) {
    string s;
    cin >> s;
    v[s]++;
  }
  int m = 0;
  for (auto p : v) {
    if (p.second > m) m = p.second;
  }
  for (auto p : v) {
    if (p.second == m) cout << p.first << endl;
  }
}

Measured memory_bytes: 25216
use std::fmt;
use std::io::stdin;
use std::io::BufRead;
use std::str;
use std::str::FromStr;
use std::vec::Vec;

fn main() {
    let stdin = stdin();
    let mut scan = InputScanner::new(stdin.lock(),256);

    let n:usize = scan.next();
    let m:usize = scan.next();

    let ab:Vec<(usize,usize)> = (0..m).map(|_| (scan.next(),scan.next())).collect::<Vec<(usize,usize)>>();

    let mut g:Vec<Vec<usize>> = (0..n).map(|_| Vec::new()).collect::<Vec<Vec<usize>>>();

    for &(a,b) in &ab {
        g[a-1].push(b-1);
        g[b-1].push(a-1);
    }

    let m = (0..n).map(|_| false).collect::<Vec<bool>>();

    let answer = search(&g,0,&m,g.len());

	println!("{}",answer);
}
fn search(g:&Vec<Vec<usize>>,x:usize,m:&Vec<bool>,nodes:usize) -> usize {
    if m[x] || g.len() == 0 {
        return 0;
    }

    if nodes == 1 {
        return 1;
    }

    let mut m = m.clone();

    m[x] = true;

    let mut count = 0;

    for &y in &g[x] {
        count += search(g,y,&m,nodes-1);
    }

    count
}
struct InputScanner<R: BufRead> {
	reader: R,
	buf: Vec<u8>, // Should never be empty
	pos: usize,   // Should never be out of bounds as long as the input ends with '\n'
}
impl<R: BufRead> InputScanner<R> {
	fn new(reader: R, capacity: usize) -> Self {
		InputScanner {
			reader: reader,
			buf: Vec::with_capacity(capacity),
			pos: 0,
		}
	}

	#[inline]
	fn next<T: FromStr>(&mut self) -> T
	where
		T::Err: fmt::Debug,
	{
		if self.buf.is_empty() {
			self._read_next_line();
		}
		let mut start = None;
		loop {
			match (self.buf[self.pos], start.is_some()) {
				(b' ', true) | (b'\n', true) | (b'\r', true) => break,
				(_, true) | (b' ', false) => self.pos += 1,
				(b'\n', false) | (b'\r', false) => self._read_next_line(),
				(_, false) => start = Some(self.pos),
			}
		}
		let target = &self.buf[start.unwrap()..self.pos];
		unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
	}

	#[inline]
	fn _read_next_line(&mut self) {
		self.pos = 0;
		self.buf.clear();
		if self.reader.read_until(b'\n', &mut self.buf).unwrap() == 0 {
			panic!("Reached EOF");
		}
	}
}


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

#define ll long long

int main() {
    string str;
    getline(cin, str);
    int size = str.size();
    int count = 0;
    int max_count = 0;
    for(int i = 0;i < size;i++) {
        if(str[i] == 'A' || str[i] == 'T' || str[i] == 'G' || str[i] == 'C') {
            count++;
        }else{
            count = 0;
        }
        max_count = max_count < count ? count : max_count;
    }
    printf("%d\n", max_count);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scn = new Scanner(System.in);
        int N = scn.nextInt();
        int M = scn.nextInt();
        System.out.println((N*(N-1)/2) + (M*(M-1)/2));
    }
}


Measured memory_bytes: 35748
// AOJ Volume 0 Problem 0029

#include <stdio.h>
#include <string.h>

typedef struct {
	char word[33];
	int freq;
} WORDS;

WORDS list[1000];

int main(void)
{
	int no_words;
	char word[33];
	int i;
	int max_freq, max_len;
	char *str_max_freq, *str_max_len;
	
	no_words = 0;
    while (scanf("%s", word) != EOF){
		for (i = 0; i < no_words; i++){
			if (strcmp(word, list[i].word) == 0){
				list[i].freq++;
				break;
			}
		}
		if (i == no_words){
			strcpy(list[i].word, word);
			list[i].freq = 1;
			no_words++;
		}
    }
	
	max_freq = max_len = 0;
	
	for (i = 0; i < no_words; i++){
		if (max_len < strlen(list[i].word)){
			max_len = strlen(list[i].word);
			str_max_len = list[i].word;
		}
		if (max_freq < list[i].freq){
			max_freq = list[i].freq;
			str_max_freq = list[i].word;
		}
	}
	
	printf("%s %s\n", str_max_freq, str_max_len);
	
    return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int main(){
	while(1){
		int m,n;
		cin>>m>>n;
		if(!m)break;
		const int MAX=7368792;
		bool f[MAX]={};
		int c=0;
		REP(i,m,MAX){
			if(f[i])continue;
			if(c==n){
				cout<<i<<endl;
				break;
			}
			for(int j=i;j<MAX;j+=i)f[j]=true;
			c++;
		}
	}
	return 0;
}


Measured memory_bytes: 10292
def smallest_factor(integer):
    j = 2
    while j :
        if j ** 2 > integer:
            return integer
        elif integer % j == 0:
            return j
        else:
            j += 1

n = int(input())
start = str(n)
prime_factors = []
while n >= 2:
    prime_factors.append(str(smallest_factor(n)))
    n //= smallest_factor(n)

print(start +  ': '+ ' '.join(prime_factors))


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.000000000001
#define pi 3.141592653589793
#define pii pair<int,int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
int main()
{  
    FAST
    ll n,d;
    cin>>n>>d;
    d=d+d+1;
    ll ans=(n+d-1)/d;
    cout<<ans;
}

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


int main() {
    int n;
    double d;
    cin >> n >> d;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        double x, y;
        cin >> x >> y;
        double dist = sqrt(x*x + y*y);
        if (dist <= d) {
            sum++;
        }
    }    
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long a, b, c, d;
  cin >> a >> b >> c >> d;

  if (a >= 0) {
    if (c >= 0) {
      cout << b*d << endl;
    } else if (d <= 0) {
      cout << a*d << endl;
    } else {
      cout << b*d << endl;
    }
  } else if (b <= 0) {
    if (c >= 0) {
      cout << b*c << endl;
    } else {
      cout << a*c << endl;
    }
  } else if (a*c > b*d) {
    cout << a*c << endl;
  } else {
    cout << b*d << endl;
  }
}

Measured memory_bytes: 3616
#include <cstdio>
using namespace std;
int main(){
	register int n, tmp, ans;
	ans = 0;
	scanf("%d", &n);
	tmp = n;
	while (tmp % 10 == 0) tmp /= 10;
	if (tmp == 1) {
		puts("10");
		return 0;
	}
	while (n) {
		if (n % 10) ans += n % 10;
		n /= 10;
	}
	printf("%d", ans);
	return 0;
}

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

int main()
{
    int n;
    scanf("%d", &n);
        if(n % 2 == 0)
            printf("%d\n", n / 2);

        else
            printf("%d\n", (n / 2) + 1);

    return 0;
}


Measured memory_bytes: 3644
#define _USE_MATH_DEFINES
#include<iostream>
#include<math.h>
#include<cmath>
#include <algorithm>
#include <iomanip>
#include<vector>
int DISTANCE(int p, std::vector<double> x, std::vector<double> y) {
	double result = 0.;
	if(p==0){
		std::vector<double> SUB(x.size(), 0.);
		for(unsigned int i=0;i<SUB.size();++i){
			SUB[i] = std::abs(x[i] - y[i]) ;
		}
		result = *std::max_element(SUB.begin(), SUB.end());
		std::cout << std::fixed << std::setprecision(8) << result << std::endl;
	}
	else{
		for (unsigned int i = 0; i < x.size(); ++i) {
			result += std::pow(std::abs(x[i] - y[i]) , p);
		}
		std::cout << std::fixed << std::setprecision(8) << std::pow(result, 1. / p)<<std::endl;
	}
	return 0;
}
int main(void) {
	int n;
	std::cin >> n;
	std::vector<double>x(n, 0.);
	std::vector<double>y(n, 0.);
		for (int i = 0; i <  n; ++i) {
		std::cin >> x[i];
	}for (int i = 0; i < n; ++i) {
		std::cin >> y[i];
	}
	DISTANCE(1,  x,  y);
	DISTANCE(2, x, y);
	DISTANCE(3, x, y);
	DISTANCE(0, x, y);
	//		system("pause");
	return 0;
}

Measured memory_bytes: 3424
h,w=gets.split.map(&:to_i)
mat=h.times.map{gets.chomp}
row=Array.new(h,0)
col=Array.new(w,0)
h.times{|i|w.times{|j|
  if mat[i][j]==?.
    row[i]+=1
    col[j]+=1
  end
}}
h.times{|i|
  w.times{|j|
    print mat[i][j] unless row[i]==w||col[j]==h
  }
  puts unless row[i]==w
}

Measured memory_bytes: 1788
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
template<class S> void arrInsert(const int k, int &sz, S a[], const S aval){
  int i;
  sz++;
  for(i=sz-1;i>k;i--){
    a[i] = a[i-1];
  }
  a[k] = aval;
}
template<class S, class T> void arrInsert(const int k, int &sz, S a[], const S aval, T b[], const T bval){
  int i;
  sz++;
  for(i=sz-1;i>k;i--){
    a[i] = a[i-1];
  }
  for(i=sz-1;i>k;i--){
    b[i] = b[i-1];
  }
  a[k] = aval;
  b[k] = bval;
}
template<class S, class T, class U> void arrInsert(const int k, int &sz, S a[], const S aval, T b[], const T bval, U c[], const U cval){
  int i;
  sz++;
  for(i=sz-1;i>k;i--){
    a[i] = a[i-1];
  }
  for(i=sz-1;i>k;i--){
    b[i] = b[i-1];
  }
  for(i=sz-1;i>k;i--){
    c[i] = c[i-1];
  }
  a[k] = aval;
  b[k] = bval;
  c[k] = cval;
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int N;
char S[202];
int main(){
  int KL2GvlyY, Lj4PdHRW;
  int i;
  int k = 0;
  int m = 0;
  rd(N);
  rd(S);
  for(i=(0);i<(N);i++){
    if(S[i]=='('){
      k++;
    }
    else{
      k--;
    }
    chmin(m, k);
  }
  for(Lj4PdHRW=(0);Lj4PdHRW<(-m);Lj4PdHRW++){
    arrInsert(0, N, S, '(');
    k++;
  }
  for(KL2GvlyY=(0);KL2GvlyY<(k);KL2GvlyY++){
    arrInsert(N, N, S, ')');
  }
  wt_L(S);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190921-1

// --- original code ---
// int N;
// char S[202];
// {
//   int i, k = 0, m = 0;
//   rd(N,S);
//   rep(i,N){
//     if[S[i]=='(', k++, k--];
//     m <?= k;
//   }
//   rep(-m){
//     arrInsert(0, N, S, '(');
//     k++;
//   }
//   rep(k) arrInsert(N, N, S, ')');
//   wt(S);
// }


Measured memory_bytes: 256
package main

import "fmt"

func contains(arr []string, str string) bool {
	for _, v := range arr {
		if str == v {
			return true
		}
	}
	return false
}

func main() {
	var n, flag int
	var last_char, tmp string
	fmt.Scan(&n)
	ws := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&tmp)
		if contains(ws, tmp) {
			flag = 1
		}
		ws[i] = tmp
	}
	if flag == 1 {
		fmt.Println("No")
		return
	}
	for i, word := range ws {
		if i == 0 {
			last_char = word[(len(word) - 1):]
		} else {
			if word[:1] != last_char {
				fmt.Println("No")
				return
			} else {
				last_char = word[(len(word) - 1):]
			}
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        Graph graph;
        boolean[] used;
        boolean can = false;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            graph = new Graph(n);
            for (int i = 0; i < n - 1; i++) {
                int a = in.nextInt() - 1;
                int b = in.nextInt() - 1;
                graph.addUndirectedEdge(a, b);
            }

            used = new boolean[n];
            if (rec(0) == 1) {
                can = true;
            }

            out.println(can ? "First" : "Second");
        }

        int rec(int x) {
            used[x] = true;
            ArrayList<Integer> list = graph.get(x);
            int sum = 0;
            for (int to : list) {
                if (!used[to]) {
                    sum += rec(to);
                }
            }

            if (sum >= 2) {
                can = true;
            }

            return 1 - sum;
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }

    static class Graph {
        int n;
        ArrayList<Integer>[] G;

        public Graph(int n) {
            this.n = n;
            G = new ArrayList[n];
            for (int i = 0; i < n; i++) {
                G[i] = new ArrayList<>();
            }
        }

        public void addUndirectedEdge(int from, int to) {
            G[from].add(to);
            G[to].add(from);
        }

        public ArrayList<Integer> get(int from) {
            return G[from];
        }

    }
}



Measured memory_bytes: 57412
#include <cstdio>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;
typedef long long ll;

const int MAXN = 102;


int n,w;
ll w0;
vector<ll> a[4];


int main(){
    scanf("%d%d", &n, &w);
    for(int i=0;i<n;++i){
        int x,y;
        scanf("%d%d", &x, &y);
        if(i==0) w0=x;
        a[x-w0].push_back(y);
    }
    for(int i=0;i<4;++i){
        sort(a[i].begin(), a[i].end(), greater<ll>());
        for(int j=1;j<a[i].size();++j){
            a[i][j]+=a[i][j-1];
        }
    }
    ll sol=0;
    for(int i=0;i<=n && i*w0<=w && i<=a[0].size();++i){
        for(int j=0;i+j<=n && i*w0+j*(w0+1)<=w && j<=a[1].size();++j){
            for(int k=0;i+j+k<=n && i*w0+j*(w0+1)+k*(w0+2)<=w && k<=a[2].size();++k){
                for(int l=0; i+j+k+l<=n && i*w0+j*(w0+1)+k*(w0+2)+l*(w0+3)<=w && l<=a[3].size();++l){
                    ll csol=0;
                    if(i) csol+=a[0][i-1];
                    if(j) csol+=a[1][j-1];
                    if(k) csol+=a[2][k-1];
                    if(l) csol+=a[3][l-1];
                    sol=max(sol, csol);
                }
            }
        }
    }
    printf("%lld", sol);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int N;

int main(){
    while(cin >> N){
        vi A(N + 1);
        rep(i, N)scanf("%d", &A[i+1]);
        N++;
        ll ans = 0;
        FOR(i, 1, N){
            int mini = min(A[i - 1], A[i]);
            ans += mini;
            A[i] -= mini;
            if(A[i] >= 2){
                ans += A[i] / 2;
                A[i] = A[i] & 1;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
  cin>>n;
  long sm=0;
  long arr[n+1];
  for(int i=0;i<n;i++){
  cin>>arr[i];

  }
sm=0;
  long ans[n+1];
  ans[0]=0;
  //ans[1]=arr[1];
  ans[1]=abs(arr[0]-arr[1]);
  for(int i=2;i<n;i++){
  ans[i]=min(abs(arr[i]-arr[i-1])+ans[i-1],abs(arr[i]-arr[i-2])+ans[i-2]);
  }
cout<<ans[n-1]<<endl;
}


Measured memory_bytes: 1792
# tenka1-2017-beginnerC - 4/N
# exhaustive search
def main():
    N = int(input())
    for h in range(1, 3501):
        for n in range(1, 3501):
            numerator = N * h * n
            denominator = 4 * h * n - N * n - N * h
            if denominator > 0 and numerator % denominator == 0:
                w = numerator // denominator
                print(h, n, w)
                return


if __name__ == "__main__":
    main()

Measured memory_bytes: 38896
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

void solve(int m, int n){
    vector<bool> s(8000000, false);
    int y = m;
    while(true){
        if(s[y]){
            y++;
            continue;
        }

        if(n == 0){
            cout << y << endl;
            return;
        }

        for(int i = y; i < (int)s.size(); i += y){
            s[i] = true;
        }
        n--;
    }
}

signed main(){
    while(true){
        int m, n;
        cin >> m >> n;

        if(m == 0 && n == 0){
            break;
        }

        solve(m, n);
    }

    return 0;
}



Measured memory_bytes: 4020
A = int(input())
B = int(input())
C = int(input())
X = int(input())
pattern = 0

for a in range(0,A+1):
    for b in range(0,B+1):
        for c in range(0,C+1):
            if 500 * a + 100 * b + 50 * c == X:
                pattern += 1

print(pattern)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    string S;
    cin >> S;
    int c1 = 0,c2 = 0;
    for(auto c:S){
        if(c == '0')c1++;
        else c2++;
    }
    cout << min(c1,c2) * 2 << endl;
}

Measured memory_bytes: 512
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
import           Data.Maybe
import           Data.Int
import           Data.List
import           Data.Char
  -- import qualified Data.Vector.Unboxing as VU
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import           Data.List (scanl')
import           Data.IORef
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Control.Applicative

readInt = BS.readInt . BS.dropWhile isSpace
getVector f = VU.unfoldr f <$> BS.getLine
getIntVector = getVector readInt
getBSVector = getVector BS.uncons

solve' n s = do
  digit1 <- VUM.replicate 1001 False
  forM_ [0..n-3] $ \i -> do
    forM_ [i+1..n-2] $ \j -> do
      forM_ [j+1..n-1] $ \k -> do
        let n1 = s VU.! i
            n2 = s VU.! j
            n3 = s VU.! k
            index = n1*100 + n2*10 + n3
        b <- VUM.read digit1 index
        unless b $ do
          VUM.write digit1 index True
  print . VU.length . VU.filter (\n -> n) =<< VU.freeze digit1

solve :: String -> IO ()
solve s = do
  digit <- VUM.replicate 1000 False

  forM_ [0..999] $ \i -> do
    let v = intToString i
    when ( test s v ) $ do
      VUM.write digit i True

  print . VU.length . VU.filter (\n -> n) =<< VU.freeze digit

intToString v
  | 0 <= v && v <= 9 = '0':'0':show v
  | 10 <= v && v <= 99 = '0':show v
  | 100 <= v && v <= 999 = show v


test s v = loop s v
  where
    loop _ [] = True
    loop [] _ = False
    loop (x:xs) (vj:vs) = if x == vj
                          then loop xs vs
                          else loop xs (vj:vs)


main = do
  _ <- readLn :: IO Int
  s <- getLine
  solve s


Measured memory_bytes: 2812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// check if it is judged online
double a, b, x;
int main() {
#ifdef LOCAL
	freopen("textname.in", "r", stdin);
	freopen("textname.out", "w", stdout);
#endif
	cin >> a >> b >> x;
	x = x / (a * a);
	if (x <= b / 2) {
		double s = a * x;
		double ss = 2 * s / b;
		printf("%.10lf", 90.0 - atan(ss / b) * 180.0 / 3.14159265358);
	}
	else {
		double s = a * b - a * x;
		double ss = 2 * s / a;
		printf("%.10lf", atan(ss / a) * 180.0 / 3.14159265358);
	}
	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;

int main(){
    int n;
    cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    if(count(a.begin(),a.end(),0)!=0){
        cout<<0<<endl;
        return 0;
    }
    ll ans=1;
    rep(i,n){
        if(a[i]<=1000000000000000000/ans){
            ans*=a[i];
        }
        else{cout<<-1<<endl; return 0;}
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4044
#include <cstdio>

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

using namespace std;

int main()
{
  int a, b, i, j;

  while (scanf("%d%d", &a, &b), (a + b)){
    int n, x, y;
    int dp[20][20] = {0};
    bool flag[20][20] = {false};
    dp[0][1] = 1;

    scanf("%d", &n);
    REP(i, n){
      scanf("%d%d", &x, &y);
      flag[x][y] = true;
    }
    FOR(i, 1, a + 1){
      FOR(j, 1, b + 1){
        if (!flag[i][j]) dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
      }
    }
    printf("%d\n", dp[a][b]);
  }
}

Measured memory_bytes: 1032
#include<bits/stdc++.h>
#define LL long long
#define db long double

using namespace std;
const int N=3e5+10;
int rd()
{
	int x=0,w=1;char ch=0;
	while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return x*w;
}
int to[N<<1],nt[N<<1],hd[N],tot=1;
void adde(int x,int y)
{
	++tot,to[tot]=y,nt[tot]=hd[x],hd[x]=tot;
	++tot,to[tot]=x,nt[tot]=hd[y],hd[y]=tot;
}
int n,m,sq[N],ff[N],st[N],tp;
LL a[N],b[N],f[N],g[N];
bool vs[N];
bool cmp(int aa,int bb){return a[aa]-b[aa]<a[bb]-b[bb];}
int findf(int x){return ff[x]==x?x:ff[x]=findf(ff[x]);}

int main()
{
	n=rd(),m=rd();
	for(int i=1;i<=n;++i) a[i]=rd(),b[i]=rd(),sq[i]=ff[i]=i;
	sort(sq+1,sq+n+1,cmp);
	for(int i=1;i<=m;++i) adde(rd(),rd());
	for(int i=1;i<=n;++i)
	{
		int x=sq[i];
		g[x]=b[x],vs[x]=1;
		for(int j=hd[x];j;j=nt[j])
		{
			int y=findf(to[j]);
			if(!vs[y]||y==x) continue;
			ff[y]=x,g[x]+=g[y],st[++tp]=y;
		}
		if(!tp) f[x]=max(a[x],b[x]);
		else
		{
			f[x]=1ll<<50;
			while(tp)
			{
				int y=st[tp--];
				f[x]=min(f[x],-g[y]+max(f[y],max(a[x]-b[x],0ll)));
			}
			f[x]+=g[x];
		}
	}
	printf("%lld\n",f[sq[n]]);
	return 0;
}


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


int main(){
  int N;
  string S;
  cin >> N >> S;
  long long int ans = 0;
  map<char, vector<int>> count;
  count['R'] = vector<int>(N, 0);
  count['G'] = vector<int>(N, 0);
  count['B'] = vector<int>(N, 0);
  count[S[N-1]][N-1]++;
  for(int ii=N-2; ii>=0; ii--){
    count['R'][ii] = count['R'][ii+1];
    count['G'][ii] = count['G'][ii+1];
    count['B'][ii] = count['B'][ii+1];
    count[S[ii]][ii]++;
  }
  for(int ii=0; ii<N; ii++){
    for(int jj=ii+1; jj<N; jj++){
      if(S[ii]==S[jj]) continue;
      char target;
      if(S[ii]!='R'&&S[jj]!='R'){
        target = 'R';
      }
      if(S[ii]!='G'&&S[jj]!='G'){
        target = 'G';
      }
      if(S[ii]!='B'&&S[jj]!='B'){
        target = 'B';
      }
      ans += count[target][jj];
      if(jj+jj-ii>N) continue;
      if(S[jj+jj-ii]==target) ans--;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3696
#include<iostream>
#include<cstdio>
using namespace std;
long long sum[101000],sum2[101000],a[101000],ans=0;
int main()
{
	int n,k;scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++){sum[i]=sum[i-1]+a[i];sum2[i]=sum2[i-1];if(a[i]>0)sum2[i]+=a[i];}
	for(int i=1;i<=n-k+1;i++)
	{
		ans=max(ans,sum2[n]-(sum2[i+k-1]-sum2[i-1])+(sum[i+k-1]-sum[i-1]));
		ans=max(ans,sum2[n]-(sum2[i+k-1]-sum2[i-1]));
	}
	printf("%lld",ans);return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define int long long
// #define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const signed INF_=1001001001; const ll INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
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;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2) cout<<"Borys"<<endl;
    else cout<<"Alice"<<endl;
    return 0;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    lint N;
    cin >> N;
    vector<lint> A(N, 0);
    rep(i, N) { cin >> A[i]; }
    vector<lint> B(N, 0);
    rep(i, N) { B[i] = A[i] + i; }
    vector<lint> C(N, 0);
    C[0] = -1000000;
    for (int x = 1; x <= N - 1; x++) {
        C[x] = x - A[x];
    }
    // dump(A);
    // dump(B);
    // dump(C);
    map<int, vector<int>> mp;
    for (int i = 0; i < C.size(); i++) {
        mp[C[i]].push_back(i);
    }
    lint cnt = 0;
    for (int i = 0; i < N; i++) {
        lint x = B[i];
        if (mp.count(x) == 0) { continue; }
        // d(x);
        // dump(mp[x]);
        auto itr = lower_bound(all(mp[B[i]]), i);
        int d    = mp[B[i]].end() - itr;
        cnt += d;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 28076
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using Debug;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var num = Input.num;
        var ps = Enumerable.Repeat(0, num).Select(v => Input.num).ToArray();
        var index = new int[num];
        for (var i = 0; i < num; i++)
            index[ps[i] - 1] = i;
        var max = 1;
        var len = 1;
        for(var i = 0; i < num - 1; i++)
        {
            if (index[i] < index[i + 1])
                len++;
            else len = 1;
            max = Max(len, max);
        }
        WriteLine(num - max);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

Measured memory_bytes: 18908
from itertools import permutations

n = int(input())
p = list(map(str,input().split()))
p = ''.join(p)
q = list(map(str,input().split()))
q = ''.join(q)

arr = list(range(1,n+1))

l = []
for v in permutations(arr,n):
    v = list(v)
    v = list(map(str,v))
    l.append(''.join(v))

a = 0
b = 0
for i in range(len(l)):
    if l[i] == p:
        a = i
    if l[i] == q:
        b = i

print(abs(a-b))


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

using namespace std;

const int MAXN = 1e7 + 10;

int n, T, k, m;

int a[MAXN], dp[MAXN];

string s, t;

const int MOD = 1e9 + 7;

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    for (int i = 1; i <= k; i++) {
        bool isPos = 0;
        for (int j = 0; j < n; j++)
            if (i - a[j] >= 0 && !dp[i - a[j]])
                isPos = 1;
        
        dp[i] = isPos;
    }

    if (dp[k] == 1)
        cout << "First";
    else
        cout << "Second";
}


Measured memory_bytes: 4008
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const ll longinf = 1LL << 60;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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




int ans[200005];
int n;


int main() {

	cin >> n;

	rep(i, n - 1) {
		int tmp;
		cin >> tmp;
		ans[tmp]++;
	}

	rrep(i, n) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 4360
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    int N,ans = 0;
    cin >> N;
    rep(i, N + 1) ans = ans + i;
    cout << ans;
    return 0;
}

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

int main(){
  int N;
  cin >>N;
  
  string ans = "No";
  
  for(int i=1;i<10;i++){
    if(N%i==0 and N/i<10){
      ans = "Yes";
      if(ans =="Yes") break;
    }
  }
  
  cout<< ans<< endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve();
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve()
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int a = vs[0];
			int b = vs[1];
			int ans = Math.Max(a + b, Math.Max(a - b, a * b));
			Console.WriteLine(ans);

		}
	}
}


Measured memory_bytes: 27952