akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

void dfs(int u, vector <int> adj[], vector <int> &dp, vector <bool> &vis)
{
  int i,j;
  vis[u] = true;
  for(i=0;i<adj[u].size();i++)
  {
    if(vis[adj[u][i]] == false)
      dfs(adj[u][i],adj,dp,vis);
    dp[u] = max(dp[u],1+dp[adj[u][i]]);
  }
}

int main()
{
  int n,m,i,j,u,v;
  cin >> n >> m;
  vector <int> adj[n+1];
  for(i=0;i<m;i++)
  {
    cin >> u >> v;
    adj[u].push_back(v);
  }
  vector <int> dp(n+1,0);
  vector <bool> vis(n+1,false);
  int ans =-1;
  for(i=1;i<=n;i++)
  {
    if(vis[i] == false)
      dfs(i,adj,dp,vis);
    ans = max(ans,dp[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12448
def main():
    inputs = input()
    data = inputs.split(" ")
    data = [int(d) for d in data]
    m = max(data)
    ans = 15
    if int(m) > 15:
        print("x")
    else:
        s = sum(data)
        if data[0] * data[1] == 15:
            print("*")
        elif s == 15:
            print("+")
        else:
            print("x")
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n,k,ans=1;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>k;
    for(int i=0;i<n;i++)
    	cin.ignore();
    int i=k;
    while(1)
    {
    	if(i>=n)
    	{
    		cout<<ans<<endl;
    		return 0;
		}
    	ans++;
    	i+=(k-1);
	}
	return 0;
}


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

int main(int argc, char const *argv[]) {
#ifdef LOCAL_TESTING
	freopen("in", "r", stdin);
#endif
	int n; cin>>n; ll arr[n], sum = 0;
	for(int i = 0; i < n; i++) 
		cin>>arr[i], sum += arr[i]; 
	ll Min = 1e18, sum2 = 0;
	for(int i = 0; i+1 < n; i++) {
		sum -= arr[i]; 
		sum2 += arr[i];
		Min = min(Min, abs(sum - sum2)); 
	} cout<<Min<<endl;

}

Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
	int i, n, v[100001];
	scanf("%d", &n);
	for (i = 1; i <= n; i++) scanf("%d", &(v[i]));
	
	int j, count[2][100001] = {}, max[2][2] = {}, argmax[2][2] = {};
	for (i = 1; i * 2 <= n; i++) {
		count[0][v[i * 2 - 1]]++;
		count[1][v[i * 2]]++;
	}
	for (i = 1; i <= 100000; i++) {
		for (j = 0; j < 2; j++) {
			if (count[j][i] > max[j][0]) {
				max[j][1] = max[j][0];
				max[j][0] = count[j][i];
				argmax[j][1] = argmax[j][0];
				argmax[j][0] = i;
			} else if (count[j][i] > max[j][1]) {
				max[j][1] = count[j][i];
				argmax[j][1] = i;
			}
		}
	}
	
	if (argmax[0][0] != argmax[1][0]) printf("%d\n", n - max[0][0] - max[1][0]);
	else if (max[0][0] + max[1][1] >= max[0][1] + max[1][0]) printf("%d\n", n - max[0][0] - max[1][1]);
	else printf("%d\n", n - max[0][1] - max[1][0]);
	fflush(stdout);
	return 0;
}

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

int main(){
    string s,t = "";
    cin >> s;
    string u = s;
    s += "  ";
    int i = 0;
    while(1){
        if(s.substr(i,5) == "dream"){
            i += 5;
            if(s.substr(i,2) == "er"){
                if(s.substr(i+2,1) == "d"){
                    i += 2;
                    t += "dreamer";
                }else if(s.substr(i+2,1) == "e"){
                    i += 2;
                    t += "dreamer";
                }else if(s.substr(i+2,1) == "a"){
                    t += "dream";
                }else if(s.substr(i+2,1) == " "){
                    i += 2;
                    t += "dreamer";
                }
            }else if(s.substr(i,1) == "d"){
                t += "dream";
            }else if(s.substr(i,1) == " "){
                t += "dream";
            }
        }


        else if(s.substr(i,5) == "erase"){
            i += 5;
            if(s.substr(i,1) == "r"){
                i += 1;
                t += "eraser";
            }else if(s.substr(i,1) == "e"){
                t += "erase";
            }else if(s.substr(i,1) == "d"){
                t += "erase";
            }else if(s.substr(i,1) == " "){
                t += "erase";
            }
        }
        else break;
    }
    if(u == t)cout << "YES" <<endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 640
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                void solve(){
                    ll n;
                    cin>>n;
                    ll k = ceil(n/(double)1000)*1000;
                    cout<<k-n;
                }
                int main(){ 
                        hs;
                        ll t;
                        t=1;
                        // cin>>t;
                        for (int i=1; i<=t; i++){
                                //cout<<"Case #"<<i<<": ";
                                solve();
                         }
        return 0; 
}         
 
 

Measured memory_bytes: 3668
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, x: "List[float]", u: "List[str]"):
    rate = 380000.0
    print(sum(xi * (rate if ui == "BTC" else 1.0) for xi, ui in zip(x, u)))


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
    x = [float()] * (N)  # type: "List[float]"
    u = [str()] * (N)  # type: "List[str]"
    for i in range(N):
        x[i] = float(next(tokens))
        u[i] = next(tokens)
    solve(N, x, u)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
N, M, X = map(int, input().split())

As = [[] for _ in range(N)]
C = [0] * N

for i in range(N):
    *c_as, = map(int, input().split())
    C[i], As[i] = c_as[0], c_as[1:]
    
INF = 10**9
ans = INF
    
# bit全探索
for s in range(1 << N):
    understandings = [0] * M
    cost_sum = 0
    for i in range(N):
        if (s >> i) % 2 == 0: continue
        cost_sum += C[i]
        for j in range(M):
            understandings[j] += As[i][j]
        is_able = True
        for i in range(M):
            if understandings[i] < X:
                is_able = False
        if is_able:
            ans = min(cost_sum, ans)
if ans == INF:
    ans = -1
print(ans)

Measured memory_bytes: 9132
# https://atcoder.jp/contests/abc073/tasks/abc073_c
# C - Write and Erase
import collections

n = int(input().split()[0])
a_list = []

for _ in range(n):
    a_list.append(int(input().split()[0]))

counter = collections.Counter(a_list)
no_list = [k for k, c in counter.items() if c % 2 == 1]
ans = len(no_list)
print(ans)


Measured memory_bytes: 16628
h,w=map(int,input().split())
ans=[['']*w for _ in range(h)]
char={}
for _ in range(h):
  s=input()
  for c in s:
    if c not in char:
      char[c]=1
    else:
      char[c]+=1
ch=h//2
cw=w//2
fh=False
fw=False
if h%2==1:
  ch+=1
  fh=True
if w%2==1:
  cw+=1
  fw=True
for i in range(ch):
  for j in range(cw):
    if (i==ch-1 and fh==True) and (j==cw-1 and fw==True):
      for c in char.keys():
        if char[c]%2==1:
          ans[i][j]=c
          char[c]-=1
          if char[c]==0:
            del char[c]
          break
    elif i==ch-1 and fh==True:
      for c in char.keys():
        if char[c]%4==2:
          ans[i][j]=c
          ans[i][w-j-1]=c
          char[c]-=2
          if char[c]==0:
            del char[c]
          break
      else:
        for c in char.keys():
          if char[c]>=2:
            ans[i][j]=c
            ans[i][w-j-1]=c
            char[c]-=2
            if char[c]==0:
              del char[c]
            break
    elif j==cw-1 and fw==True:
      for c in char.keys():
        if char[c]%4==2:
          ans[i][j]=c
          ans[h-i-1][j]=c
          char[c]-=2
          if char[c]==0:
            del char[c]
          break
      else:
        for c in char.keys():
          if char[c]>=2:
            ans[i][j]=c
            ans[h-i-1][j]=c
            char[c]-=2
            if char[c]==0:
              del char[c]
            break
    else:
      for c in char.keys():
        if char[c]>=4:
          ans[i][j]=c
          ans[i][w-j-1]=c
          ans[h-i-1][j]=c
          ans[h-i-1][w-j-1]=c
          char[c]-=4
          if char[c]==0:
            del char[c]
          break
fy=True
for i in range(ch):
  for j in range(cw):
    if ans[i][j]=='':
      fy=False
if fy==True:
  print('Yes')
else:
  print('No')

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

int n;
vector<int> a(12);
int ans;

void calc(int i, int x) {
  if(i == n) {
    if(x % 2 == 0) ans++;
    return;
  }
  calc(i+1, x * (a[i] + 1));
  calc(i+1, x * (a[i]));
  calc(i+1, x * (a[i] - 1));
  return;

}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ans = 0;
  cin >> n;
  for(int i=0;i<n;i++)
    cin >> a[i];
  calc(0, 1);
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main()
{
    int i; 
    int a[1000005]={0};
    for (i=1; i<=1000005; i++) 
    { 
 
        if (i%15 == 0)         
            a[i]=0;     
 
        else if ((i%3) == 0)     
            a[i]=0;                 
 
        else if ((i%5) == 0)                        
            a[i]=0;                  
      
        else            
            a[i]=i;                  
  
    } 
    
    int n;
    cin>>n;
    long long int s=0;
    for(int i=0;i<=n;i++)
    {
        s+=a[i];
    }
    cout<<s;
  
    return 0; 
}


Measured memory_bytes: 7048
S = input()

def check(word):
    if word == word[::-1]:
        return True
    else:
        return False

count = 0

w1 = S[:len(S)//2]
w2 = S[:len(S)//2-1:-1]

for a,b in zip(w1,w2):
    if a != b:
        count += 1

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define ALL(a)  (a).begin(),(a).end()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse -> greater<long long>()
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back
int n;
void solve(string s, char mx){
   if(sz(s)==n){
      cout<<s<<endl;
      return;
   }
   for(char i='a';i<=mx+1;i++){
      if(s=="" && i!='a')continue;
      solve(s+i,(char)c_max(mx,i));
   }
}
int main(){
   cin>>n;
   solve("",'a');
}

Measured memory_bytes: 3632
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
--import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Fixed
import Data.Tuple
--import Data.Array
import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete

pattern n = map concat $ splitRec n $ map (printf "%3d" :: Int -> String) $map snd $ sort $ flip zip [1..] $ concat [(if even s then reverse else id) [(i,s-i) | i <- [0..s], i<n, s-i<n] | s <- [0..2*n-2]]

main = sub 1
sub :: Int -> IO ()
sub i = do
    n <- getInt
    when (n/=0) $ do
        printf "Case %d:\n" i
        mapM_ putStrLn $ pattern n
        sub (i+1)


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

int main() {

int a;
cin >>a;

int b;
cin >>b;

int c;
cin >>c;

int ans;

if(a>=b&&a>=c){ans=10*a+b+c;}

if(b>=c&&b>=a){ans=10*b+c+a;}

if(c>=a&&c>=b){ans=10*c+a+b;}

cout <<ans;


}

Measured memory_bytes: 256
function check_sosu(number) {
  var lower = Math.floor(Math.sqrt(number));
  if(number == 2) return 1;
  else if(!(number % 2)) return 0
  // for(let i = 2; i <= lower; i++) {
  for(let i = 3; i <= lower; i+=2) {
      if(!(number % i)) {
        return 0;
    }
  }
  return 1;
}
function Main(input) {
  var sosu = 0;
  input = input.split("\n").map(Number);
  var num_array = input.slice(1);
  for(let i = 0; i < Number(input[0]); i++) sosu += check_sosu(num_array[i]);
  console.log(sosu);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 18168
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    ll n,m;
    cin >> n >> m;
    if(2*n < m) cout << n+(m-2*n)/4 << endl;
    else cout << m/2 << endl;
    return 0;     
}

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

int main(){
    int N;  cin >> N;
    map<int, int> mp;
    for(int i=0; i<N; i++){
        int a;  cin >> a;
        if(mp[a] == 0) mp[a]++;
        else {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}   

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

using namespace std;

int n, m;
int c[21];
int memo[21][50001];

int solve(int id, int money){

    if(memo[id][money] != -1) return memo[id][money];

    int ret;

    if(id == m) ret = 1 << 30;
    else if(money == 0) ret = 0;
    else if(money < c[id]) ret = solve(id + 1, money);
    else ret = min(min(solve(id + 1, money), solve(id + 1, money - c[id]) + 1), solve(id, money - c[id]) + 1);

    return memo[id][money] = ret;

}

int main(){

    cin >> n >> m;

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

    memset(memo, -1, sizeof(memo));

    cout << solve(0, n) << endl;

}

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

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    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 a: i32 = input();
    let b: i32 = input();
    println!(
        "{}",
        if a <= 5 {
            0
        } else if a <= 12 {
            b / 2
        } else {
            b
        }
    );
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

ll N,a,pre=1,ans=1,di=998244353,maxi=0;

ll max(ll a, ll b){
    if(a>b)return a;
    else return b;
}

int main(){
    cin>>N;
    ll D[N];
    rep(i,N)D[i]=0;
    rep(i,N){
        cin>>a;
        if(!i){
            if(a!=0){
                out(0);
                return 0;

            }
        }
        D[a]++;
        maxi=max(maxi,a);
    }
    rep(i,maxi){
        if(!D[i]){
            out(0);
            return 0;
        }
    }
    if(D[0]!=1){
        out(0);
        return 0;
    }
    rep(i,N){
        rep(j,D[i]){
            ans=(ans*pre)%di;
        }
        pre=D[i];
    }
    out(ans%di);
    
    
}


Measured memory_bytes: 1024
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    double sum = 0;
    for(int i = 0; i < n; i++){
      double a = sc.nextInt();
      sum += 1/a;
    }
    double ans = 1/sum;
    System.out.print(ans);
  }
}


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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (long long)1e18 + 1;

/**
 *  最長増加部分列(LIS)を導出する
 *  @origin:     元の数列
 *  @continuous: 以下の式を満たすような最長増加部分列を取るかどうか
 *               LIS_{i} = LIS_{i + 1} - 1, where 1 <= i < len(LIS)
 *  @Return:     最長増加部分列
 */
template<typename T>
std::vector<T> pick_up_LIS(const vector<T>& origin, bool continuous = false) {
    std::vector<T> lis;
    if(continuous) {
        auto max_val = *max_element(origin.begin(), origin.end());
        auto min_val = *min_element(origin.begin(), origin.end());
        auto range   = max_val - min_val + 1;
        auto offset  = (0 <= min_val) ? 0 : -min_val;
        std::vector<T> buf(range + 1, std::numeric_limits<T>::max());
        for(T i = 0; i < (T)origin.size(); i++) {
            buf[origin[i] + offset] = i + 1;
        }
        std::cout << std::endl;
        T max_cnt = 1, max_start = 0, cnt = 1, start = 0;
        for(T i = 1; i < (T)buf.size(); i++) {
            if(buf[i - 1] < buf[i] && buf[i] != std::numeric_limits<T>::max()) {
                cnt++;
            }
            else {
                if(max_cnt < cnt) {
                    max_cnt   = cnt;
                    max_start = start;
                }
                cnt   = 1;
                start = i;
            }
        }
        if(max_cnt < cnt) {
            max_cnt   = cnt;
            max_start = start;
        }
        lis.reserve(max_cnt);
        for(T i = 0; i < (T)max_cnt; i++) {
            lis.push_back(max_start + i - offset);
        }
    }
    else {
        std::vector<T> buf(origin.size() + 1, std::numeric_limits<T>::max());
        buf[0] = std::numeric_limits<T>::min();
        for(const auto& v : origin) {
            auto itr   = lower_bound(buf.begin(), buf.end(), v);
            auto index = distance(buf.begin(), itr);
            buf[index] = (v < buf[index]) ? v : buf[index];
        }
        auto itr = lower_bound(buf.begin(), buf.end(), std::numeric_limits<T>::max());
        std::move(buf.begin() + 1, itr, std::back_inserter(lis));
    }
    return lis;
}

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

    int N;
    std::cin >> N;

    vector<int> P(N);
    REP(i, N) {
        std::cin >> P[i];
    }

    auto lis = pick_up_LIS(P, true);
    std::cout << N - lis.size() << std::endl;

    return 0;
}


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

using namespace std;

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

    vector<int> v1(100010), v2(100010);
    for (int i = 0; i < 100010; i++) {
        v1[i] = 0;
        v2[i] = 0;
    }

    for (int i = 0; i < n; i++) {
        cin >> k;

        if (i % 2 == 0) {
            v1[k]++;
        } else {
            v2[k]++;
        }
    }

    vector<int> v1c(v1), v2c(v2);

    sort(v1.begin(), v1.end(), greater<int>());
    sort(v2.begin(), v2.end(), greater<int>());


    if (find(v1c.begin(), v1c.end(), v1.front())-v1c.begin() == find(v2c.begin(), v2c.end(), v2.front())-v2c.begin()) {
        cout << n - v1.front() - max(v1[1], v2[1]) << endl;
    } else {
        cout << n - v1.front() - v2.front() << endl;
    }
}


Measured memory_bytes: 1792
// g++ -std=c++17 -O2 -Wall C.cpp -o C -D _DEBUG

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

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false); 
    cin.tie(NULL);
    
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i < n; i++) ans += (n - 1) / i;
    cout << ans;
}

Measured memory_bytes: 3628
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	a := scanInt()
	b := scanString()
	c, _ := strconv.Atoi(strings.Replace(b, ".", "", 1))

	fmt.Fprintln(wr, (a*c)/100)
}


Measured memory_bytes: 1764
#include <stdio.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define N 200010

int main() {
	int n, a[N], b[N] = { 0 }, c[N] = { 0 }; long long k;
	scanf("%d %lld", &n, &k);
	Rep(i, 1, n + 1)scanf("%d", &a[i]);
	int ch = 1, start, end;//行ってみる,startはループ開始,endはループ2周目の最初の何番目か
	if(a[1]==1){printf("1");return 0;}
	if(k==1){printf("%d",a[1]);return 0;}
	Rep(i, 1, N+10) {
		if (b[ch]!=0){ start = b[ch]; end = i; break; }
		b[ch] += i;
		ch = a[ch];
    }
	c[0]=ch;
	Rep(i,1,end-start+1) {
		c[i] = a[ch];
		ch = a[ch];
	}
	if (k<=start) {
		ch=1;int K = k;
		rep(i,K) {
			ch = a[ch];
		}
		printf("%d",ch);
	}
	else if(end-start==1){
    	a[0]=1;
		printf("%d", ch);
	}
	else{
		k++;
		k = k-start;
		k = k%(end-start);
		printf("%d",c[k]);
	}
}

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

int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  for(int i=0; i<N; i++){
    cin >> S[i];
  }
  sort(S.begin(), S.end());
  string s= S[0];
  int count =1;
  vector<pair<int, string> > P;
  for(int i=1; i<N; i++){
    if(S[i]==s){
      count++;
      continue;
    }
    P.push_back(make_pair(count, s));
    s=S[i];
    count=1;
  }
  P.push_back(make_pair(count, s));
  sort(P.begin(), P.end(), greater<pair<int,string> >());
  vector<string> ans;
  ans.push_back(P[0].second);
  int num = P[0].first;
  for(int i=1; i<P.size(); i++){
    if(num==P[i].first){
      ans.push_back(P[i].second);
      continue;
    }
    break;
  }
  sort(ans.begin(), ans.end());
  for(int i=0; i<ans.size(); i++){
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 21488
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.stream.Collectors;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();
        int m = in.nextInt();
        boolean[] ac = new boolean[n];
        int[] wrongAnswerCount = new int[n];
        int totalWA = 0;

        for (int i = 0; i < m; i++) {
            int p = in.nextInt() - 1;
            String s = in.next();
            if (s.equals("AC")) {
                if (!ac[p]) {
                    totalWA += wrongAnswerCount[p];
                }
                ac[p] = true;
            } else {
                if (!ac[p]) {
                    wrongAnswerCount[p]++;
                }
            }
        }

        int totalAC = 0;
        for (boolean b : ac) {
            if (b) totalAC++;
        }

        out.println(totalAC + " " + totalWA);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 41708
X = gets.to_i
m = {}
120.times do |a|
  a5 = a**5
  m[a5] = a;
  b5 = X - a5
  if b5 >= 0
    if m[b5]
      puts "#{a} #{-m[b5]}"
      break
    end
  else
    if m[-b5]
      puts "#{a} #{m[-b5]}"
      break
    end
  end
end

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

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair< int ,int > pii;
typedef istringstream iss;
typedef ostringstream oss;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define ln length()
#define rep(i,n) for(int i=0;i<n;i++)
#define fu(i,a,n) for(int i=a;i<=n;i++)
#define fd(i,n,a) for(int i=n;i>=a;i--)
#define all(a)  a.begin(),a.end()
#define ESP (1e-9)

#define gi(n) scanf("%d",&n)
#define gl(n) cin >> n
#define pi(n) printf("%d",n)
#define pl(n) cout << n
#define ps printf(" ")
#define pn printf("\n")
#define dg(n,s); printf("%s %d",s,n)
#define imax numeric_limits<int>::max()
#define imin numeric_limits<int>::min()
#define lmax numeric_limits<ll>::max()
#define lmin numeric_limits<ll>::min()

template <typename T> inline T square(T x){return x*x;}
template < class T > inline T max_(T a,T b) {return a > b ? a : b ;}
template < class T > inline T min_(T a,T b) {return a < b ? a : b ;}
template < class T > inline T gcd(T a,T b) {if(a < 0) return gcd(-a,b); if(b < 0)return gcd(a,-b); return (b == 0) ? a : gcd(b ,a % b);}
template < class T > inline T lcm(T a,T b) {if(a < 0) return lcm(-a,b); if(b < 0)return lcm(a,-b); return a * (b / gcd(a , b));}

#define L1 1000000000000LL

ll rec(ll a, ll b, ll c, ll cost, ll cnt)
{
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				if(i*500+j*100+k*50 == cost)cnt++;
			}
		}
	}
	return cnt;
}

int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<rec(a,b,c,d,0);
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <iterator>

#include <cmath>

int main(void){
	using namespace std;

	map<int,int> input_dic;
	list<int> input;
	int k;

	while(cin >> k){
		input.push_back(k);
		input_dic[k] = 0;
	}

	int k_max = ( input_dic.rbegin() )->first;
	vector<bool> sieve(k_max, false);

	int sq_k_max = sqrt(k_max);
	for (int x=1; x<=sq_k_max; ++x) {
		for (int y=1; y<=sq_k_max; ++y) {
			int n = 4*x*x + y*y;
			if ( n<=k_max && (n%12==1 || n%12==5) ){
				sieve[n] = !sieve[n];
			}
			n = 3*x*x + y*y;
			if ( n<=k_max && n%12==7 ){
				sieve[n] = !sieve[n];
			}
			n = 3*x*x - y*y;
			if ( x>y && n<=k_max && n%12==11 ){
				sieve[n] = !sieve[n];
			}
		}
	}
	for (int n=5; n<=sq_k_max; ++n){
		if (sieve[n]){
			for (int k=n*n; k<=k_max; k+=n*n){
				sieve[k] = false;
			}
		}
	}
	sieve[2] = sieve[3] = true;

	int primeCount = 0;
	auto sieveItr = sieve.begin();
	for( auto itr=input_dic.begin(); itr!=input_dic.end(); itr++){
		for( ; distance(sieve.begin(),sieveItr) <= itr->first; sieveItr++){
			if( *sieveItr ){
				primeCount++;
			}
		}
		itr->second = primeCount;
	}

	for(auto itr=input.begin(); itr!=input.end(); itr++){
		cout << input_dic[*itr] << endl;
	}

}

Measured memory_bytes: 1320
import kotlin.comparisons.compareBy
fun main(args: Array<String>) {
    val N = nextInt()
    val AB = Array<Pair<Int, Int>>(N, {
        val (a, b) = listOfInt()
        Pair(a, b)
    }).toList().sortedWith(compareBy({ it.second }, { it.first }))
    var ans = true
    var t = 0
    repeat(N) {
        t += AB[it].first
        if (t > AB[it].second) ans = false
    }
    println("${if (ans) "Yes" else "No"}")
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }


Measured memory_bytes: 131180
S = input()

# Sから文字を抜いていって、空文字列になればいいはず
# *erとerase*の先頭がぶつかるのでeraserから調べる
# dreamerを巻き込んでもdreamで拾えるので
S = S.replace("eraser", "")
S = S.replace("erase", "")
S = S.replace("dreamer", "")
S = S.replace("dream", "")

if (len(S) == 0) :
    print("YES")
else :
    print("NO")

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

int main() {
  int N, b=0, cnt=0;
  cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a.at(i);
  while(1){
    rep(i, N){
      if(a.at(i)%2!=0){
        b=1;
        break;
      }
      else a.at(i)=a.at(i)/2;
    }
    if(b==1) break;
    else cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;





int main(void){
  int h,w,d;
  cin >> h >> w >> d;
 
  pair<int,int> a[h*w+1];
  rep(i,h){
	rep(j,w){
	  int tmp;
	  cin >> tmp;
	  a[tmp].first = i+1;
	  a[tmp].second = j+1;
	}
  }
  vector<vector<int> > cost(d);
  rep(i,d){
	int num = 0;
	cost[i].push_back(0);
	for(int j=i;j+d<=h*w;j+=d){
	  cost[i].push_back(cost[i][num]+abs(a[j].first-a[j+d].first)+abs(a[j].second-a[j+d].second));
	  num++;
	  
	}
  }

  /*rep(i,d){
	rep(j,cost[i].size()){
	  cout << cost[i][j] << " ";
	}
	cout << endl;
	}*/

  int q;
  cin >> q;
  rep(i,q){
	int l,r;
	cin >> l >> r;
	cout << cost[r%d][(r-r%d)/d]-cost[l%d][(l-l%d)/d] << endl;
  }

  return 0;
}


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

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

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    sort(begin(a), end(a));

    vector<vector<int>> dp(n + 1, vector<int>(n + 1));
    REP(i, n) dp[i][n] = 1;
    REP(i, n) {
        for (int j = i + 1; j < n; ++j) {
            chmax(dp[j][i], dp[i][n] + 1);
        }
        REP(j, i + 1) {
            int d = a[i] - a[j];
            auto itr = lower_bound(begin(a), end(a), a[i] + d);
            if (itr == end(a) || *itr != a[i] + d) {
                continue;
            }
            int idx = itr - begin(a);
            chmax(dp[idx][i], dp[i][j] + 1);
        }
    }
    int ans = 0;
    REP(i, n) {
        REP(j, n) {
            chmax(ans, dp[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 198512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll n;
    cin >> n;
    if(n % 1000 == 0) cout << 0 << endl;
    else cout << 1000 - n % 1000 << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"	
	typedef long long LL;
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define mod2 998244353
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define sz(v) ((ll)(v).size())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
	#define forn(i,n) for (ll i=0; i<(n); ++i)
	#define fornd(i,n) for (ll i=(n)-1; i>=0; --i)	
	#define forab(i,a,b) for (ll i=(a); i<=(b); ++i)
	#define read(a) ll a; cin >> a;
	#define reads(s) string s; cin >> s;
	#define readb(a, b) ll a, b; cin >> a >> b;
	#define readc(a, b, c) ll a, b, c; cin >> a >> b >> c;
	#define readarr(a, n) int a[(n) + 1] = {}; forab(i, 0, (n-1)) {cin >> a[i];}
	#define readmat(a, n, m) int a[n + 1][m + 1] = {}; forab(i, 1, n) {forab(j, 1, m) cin >> a[i][j];}
	#define readv(A,n) vll A(n,0); forn(i,n) cin>>A[i]; 
	#define print(a) cout << a << endl;
	#define printarr(a, n) forab (i, 1, n) cout << a[i] << " "; cout << endl;
	#define printv(v) for (int i: v) cout << i << " "; cout << endl;
	#define printmat(a, n, m) forab(i, 1, n) {forab (j, 1, m) cout << a[i][j] << " "; cout << endl;}
	 
	#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
	bool isPowerOfTwo(int x) {
    return x && (!(x & (x - 1)));
	}
	int takemod(int x) {
    return (x % mod + mod) % mod;
	}
 
	int fpow(int base, int power, int MOD) {
    int result = 1;
    base = base % MOD;
    while (power) {
        if (power & 1)
            result = (result * base) % MOD;
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result;
	}
 
	int modinv(int x) {return fpow(x, mod - 2, mod);}
	void solve()
	{
		ll n,m;
		cin>>n>>m;
		ll A[n][m];
		forn(i,n)
		{
			string x;
			cin>>x;
			forn(j,m)
			{
				if(x[j]=='#')
					A[i][j]=0;
				else
					A[i][j]=1;
			}
		}
		// forn(i,n)
		// {
		// 	forn(j,m)
		// 		cout<<A[i][j]<<" ";
		// 		cout<<endl;
		// }
		ll dp[n+1][m+1];
		mem(dp,0);
		dp[0][0]=1;
		forn(i,n)
		{
			forn(j,m)
			{
				if(A[i][j]==1)
				{
					if(i==0&&j==0)continue;
					else if(j==0)dp[i][j]=dp[i-1][j]%mod;
					else if(i==0)dp[i][j]=dp[i][j-1]%mod;
					else
					{
						dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
					}
				}
			}
		}
		cout<<dp[n-1][m-1]<<endl;
	}
	int main()
	{	
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif
		fast_io;
		int T=1;
		//cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			solve();
		}
		return 0;
	}

	
	

Measured memory_bytes: 19280
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef pair<int, int> P;
const long long LINF = 1000000000000000018ll;
const int INF = 1000000009;
const int mod = 1000000007;
const int mod2 = 998244353;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::setprecision(20) << std::fixed;

  string s;
  cin >> s;

  if (s.back() == 's') {
    cout << s + "es" << endl;
  } else {
    cout << s + "s" << endl;
  }

  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  set<int> a;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    if (a.count(x)) {
      a.erase(x);
    } else {
      a.insert(x);
    }
  }
  cout << a.size() << endl;
  return 0;
}


Measured memory_bytes: 4864
def gcd(a,b):
    a=abs(a)
    b=abs(b)
    while a:
        a, b = b%a, a
    return b

firstline=input("")
N,X=firstline.split()
N=int(N)
X=int(X)
secondline=input("")
xi=secondline.split()
dis = list(map(lambda x: abs(int(x)-X), xi))
result = dis[0]
for i in dis[1:]:
    result = gcd(result, i)

print(result)


Measured memory_bytes: 16216
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}

macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;
fn gcd(a: i64, b: i64) -> i64 { if b == 0 { a } else { gcd(b, a % b) } }

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let k: i64 = sc.cin();
    let xs: Vec<i64> = (0..n).map(|_| sc.cin()).collect();
    if k > *xs.iter().max().unwrap() {
        put!("IMPOSSIBLE");
    } else {
        let g = xs.iter().fold(xs[0], |x, &y| gcd(x, y));
        if k % g == 0 {
            put!("POSSIBLE");
        } else {
            put!("IMPOSSIBLE");
        }
    }
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 11768
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
int main(int argc, char *argv[])
{
  for(;;) {
    int n;
    cin >> n;
    if(n == 0) break;
    vector<pair<int,int>> abs;
    for(int i = 0; i < n; i++) {
      int a, b;
      cin >> a >> b;
      abs.push_back(make_pair(a, b));
    }
    sort(abs.begin(), abs.end());
    int s = 0;
    int best = 0;
    for(int k = 1; k <= n; k++) {
      while(s < n && abs[s].first <= k+1) s++;
      int c = k;
      for(int j = s - 1; c > 0 && j >= 0; j--) {
        if(abs[j].second >= k+1) c--;
      }
      if(c == 0) { best = k; }
    }
    cout << best << endl;
    break;
  }
  return 0;
}

Measured memory_bytes: 3868
S = input()
N = len(S)


def kaibun(s):
    if s == s[::-1]:
        return True
    else:
        return False

if kaibun(S) == True and kaibun(S[0:round((N-1)/2)]) == True and kaibun(S[round((N+1)/2):N])==True:
    print('Yes')
else:
    print('No')


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

bool cmp(char a, char b){ 

	return a > b;
}

int main()
{ 
    string s, t;

    cin >> s;
    cin >> t;

    sort(s.begin(), s.end()); 
	sort(t.begin(), t.end(), cmp);

    if (s < t)
       cout << "Yes" << endl; 
	else
       cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
/*
 ID: bradyawn
 PROG: contest
 LANG: C++11
 */

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <deque>
#include <string>
#include <cmath>
#include <map>
#include <unordered_map>
#include <utility>
#include <set>
#include <unordered_set>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <random>
#include <cstring>
#include <complex>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int,int> i2;
typedef pair<ll,ll> ll2;

int n;

int arr[200001];

bool a[20][200001];

//int prev[20][200001]; //last bit you've seen
int pre[200001]; //last bit OVERALL

void solve(int type)
{
    int seen = 0;
    for (int i = 1; i <= n; i++)
    {
        if (a[type][i] == 1) pre[i] = max(pre[i], seen);
        else pre[i] = max(pre[i], pre[seen]);
        if (a[type][i] == 1) seen = i;
    }
}

int main()
{
    //ifstream inf("");
    //ofstream outf("");
    //cout << setprecision(10);
    ios::sync_with_stdio(0); cin.tie(0);
    
    cin >> n;
    
    for (int i = 1; i <= n; i++) cin >> arr[i];
    
    for (int i = 1; i <= n; i++)
        for (int j = 0; j < 20; j++) a[j][i] = ((1<<j) & arr[i]);

    //for (int i = 1; i <= n; i++) cout << a[0][i] << " \n"[i==n];
    //for (int i = 1; i <= n; i++) cout << a[1][i] << " \n"[i==n];
    //for (int i = 1; i <= n; i++) cout << a[2][i] << " \n"[i==n];
    
    for (int i = 0; i < 20; i++) solve(i);
    
    ll ret = 0;
    
    for (int i = 1; i <= n; i++) ret += i-pre[i];
    
    cout << ret << '\n';
    
    return 0;
    
}




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

int arr[3001][3001];

int main(){
	string s1,s2;
	cin>>s1>>s2;
	int n1=s1.length(), n2=s2.length();
	for(int i=0;i<n1+1;i++){
		for(int j=0;j<n2+1;j++){
			if(i==0||j==0)
				arr[i][j]=0;
			else{
				if(s1[i-1]==s2[j-1])
					arr[i][j]=arr[i-1][j-1]+1;
				else{
					if(arr[i][j-1] < arr[i-1][j])
						arr[i][j]=arr[i-1][j];
					else
						arr[i][j]=arr[i][j-1];
				}
			}
		//	cout<<arr[i][j]<<" ";
		}
		//cout<<endl;
	}
	int i=n1,j=n2;
	int index=arr[n1][n2]-1;
	char ans[arr[n1][n2]+1];
	ans[arr[n1][n2]]='\0';
	while(i>0 && j>0){
		if(arr[i][j]==arr[i][j-1])
			j--;
		else if(arr[i][j]==arr[i-1][j])
			i--;
		
		else{
			//cout<<s1[i-1]<<endl;
			ans[index--]=s1[i-1];
			i--;j--;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 35456
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#define ll long long
using namespace std;
void Delete(char ch[],int n,int k,int x)
{
    for(int i=0; i<k; i++)
    {
        //删除数组中第x个元素（下标是x-1）,后续元素向前移动
        for(int j=x-1; j<n-1; j++)
        {
            ch[j]=ch[j+1];//后续元素向前移动一位
        }
        n--;//元素个数减1
    }
}


//        for(int i=0; i<strlen(ch); i++)
//        {
//            if(ch[i]=='B')
//            {
//                cc++;
//                Delete(ch,strlen(ch),1,i+1);
//                Delete(ch,strlen(ch),1,i);
//            }
//        }

int main()
{
    string s1,s2;
    while(cin>>s1)
    {
        s2="";
        for(int i=0;i<s1.size();i++)
        {
            if(s1[i]=='0')
            {
                s2+=s1[i];
            }
            if(s1[i]=='1')
            {
                s2+=s1[i];
            }
            if(s1[i]=='B')
            {
                s2=s2.substr(0,s2.size()-1);
            }
        }
        cout<<s2<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

typedef pair<string, int> P;
typedef long long int LL;

int main() {
    int n, q;
    cin >> n >> q;
    queue<P> que;
    for (int i = 0; i < n; i++) {
        string s;
        int a;
        cin >> s >> a;
        que.push(mp(s, a));
    }

    int t = 0;
    while (!que.empty()) {
        P a = que.front(); que.pop();
        if (a.second <= q) {
            t += a.second;
            cout << a.first << " " << t << endl;
        } else {
            t += q;
            que.push(mp(a.first, a.second - q));
        }
    }

    return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

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

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vll a(n), k(n);
  REP(i, n) {
    cin >> a[i] >> k[i];
  }

  ll ans = 0;
  REP(i, n) {
    while(a[i] % k[i] && a[i] / k[i] > 1) {
      ll diff = a[i] / k[i] + 1;
      a[i] -= (a[i] - a[i] / k[i] * k[i] - 1) / diff * diff;
      a[i] -= diff;
    }

    if(a[i] / k[i] > 1) ans ^= a[i] / k[i];
    else if(a[i] / k[i] == 1) ans ^= (a[i] - k[i] + 1) % 2;
  }

  cout << (ans ? "Takahashi" : "Aoki") << endl;

}
























Measured memory_bytes: 256