akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(std::io::stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.read()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item=U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(104_857_600)
        .spawn(solve)
        .unwrap()
        .join()
        .unwrap();
}

fn bubble_sort(c: &mut Vec<(char, u8, usize)>) {
    let n = c.len();
    for i in 0..n {
        for j in (i+1..n).rev() {
            if c[j].1 < c[j-1].1 {
                c.swap(j, j-1);
            }
        }
    }
}

fn selection_sort(c: &mut Vec<(char, u8, usize)>) {
    let n = c.len();
    for i in 0..n {
        let mut minj = i;
        for j in i..n {
            if c[j].1 < c[minj].1 {
                minj = j;
            }
        }
        c.swap(i, minj);
    }
}

fn is_stable(c: &Vec<(char, u8, usize)>) -> bool {
    let n = c.len();
    for i in 0..n {
        for j in i+1..n {
            if c[i].1 == c[j].1 && c[i].2 > c[j].2 {
                return false;
            }
        }
    }
    true
}

fn solve() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n = sc.read();
    let v: Vec<(char, u8, usize)> = (0..n).map(|i| {
        let s: String = sc.read();
        let mut it = s.chars();
        let c = it.next().unwrap();
        let k = it.next().unwrap();
        (c, k as u8 - b'0', i)
    }).collect();

    let mut bsorted = v.clone();
    bubble_sort(&mut bsorted);
    println!("{}", bsorted.iter().map(|&(c, k, _)| format!("{}{}", c, k)).join(" "));
    println!("{}table", if is_stable(&bsorted) { "S" } else { "Not s" });
    
    let mut ssorted = v.clone();
    selection_sort(&mut ssorted);
    println!("{}", ssorted.iter().map(|&(c, k, _)| format!("{}{}", c, k)).join(" "));
    println!("{}table", if is_stable(&ssorted) { "S" } else { "Not s" });
}



Measured memory_bytes: 9076
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		boolean ok = false;
		int ans = 0;
		for(int i = 1; i <= N; i++) {
			if(sc.nextInt() == i && !ok) {
				ans++;
				ok = true;
			}
			else
				ok = false;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 48308
/*
  Fuad Ashraful Islam
  University of Asia Pacific,Bangladesh
  Date:12th April 2020
  TODO:
 */
#include<bits/stdc++.h>
#define dbg(x) cerr << #x << " = " << x << endl
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define pb push_back

using namespace std;
template <class T>
inline void read(T &res)
{
  res = 0; bool bo = 0; char c;
  while (((c = getchar()) < '0' || c > '9') && c != '-');
  if (c == '-') bo = 1; else res = c - 48;
  while ((c = getchar()) >= '0' && c <= '9')
    res = (res << 3) + (res << 1) + (c - 48);
  if (bo) res = ~res + 1;
}
typedef long long ll;
const int N=1e5+1;
ll _,n,k,m,l,c,cs=1;
 

void Solve()
{
  ll sum=0LL;
  cin>>n;
  for(ll i=1;i<=n;++i)
  {
    if(i%3==0 || i%5==0)continue;
    sum+=i;
  }
  cout<<sum<<"\n";
  
}
int main()
{
  Solve();
  return 0;
}

Measured memory_bytes: 3580
#include<stdio.h>
#include<string.h>

const int maxn = 100 + 10;
char s[maxn];

int main()
{
    while(scanf("%s",s) == 1)
    {
        int ok = 1;
        if(strlen(s) < 4 || s[0] != 'Y' || s[1] != 'A' || s[2] != 'K' || s[3] != 'I')
            ok = 0;
        if(ok) printf("Yes\n");
        else printf("No\n");
    }
}

Measured memory_bytes: 128
N,Y = map(int, input().split())
n = 0
t5 = 0
t10 = 0
n = int(Y/1000)
if n < N:
    n = -1
    t5 = -1
    t10 = -1


ms = n+t5+t10
while(ms > N):
    if n > 4:
        n -= 5  
        t5+=1
    elif t5 > 1:
        t5 -= 2
        t10 +=1
    else:
        n = -1
        t5 = -1
        t10 = -1
    ms = int(n+t5+t10)

if N -ms == 3:
    if t5 > 2:
        n+=5
        t5-=3
        t10+=1
    else:
        n = -1
        t5 = -1
        t10 = -1
if N -ms==2:
    if t5 > 4:
        n+=5
        t5-=5
        t10+=2
    else:
        n = -1
        t5 = -1
        t10 = -1
if N -ms==1:
    if t5 > 6:
        n+=5
        t5-=7
        t10+=3
    else:
        n = -1
        t5 = -1
        t10 = -1
print(t10,t5,n)



Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
    private final static StringBuilder sortedSeq = new StringBuilder();
    private final static String lb = System.getProperty("line.separator");
 
    private static int count;
    public static void main(String[] args) throws IOException {
        int[] seq = getSequence();
        shellSort(seq);
        printSequence(seq);
    }
 
    public static void insertionSort(final int[] seq, final int gap) {
        for (int i = gap; i < seq.length; ++i) {
            final int key = seq[i];
            int j = i - gap;
            while (0 <= j && key < seq[j]) {
                seq[j+gap] = seq[j];
                j = j - gap;
                ++count;
            }
            seq[j+gap] = key;
        }
    }
 
    public static void shellSort(final int[] seq) {
        count = 0;
         
        final int greatestSize = seq.length/3 + 1;
        int gap = 0;
        int sizeOfGaps = 0;
        for (int tmp = 1; tmp <= greatestSize; tmp = 3*gap + 1) {
            gap = tmp;
            ++sizeOfGaps;
        }
        sortedSeq.append(sizeOfGaps).append(lb);
 
        int[] gaps = new int[sizeOfGaps];
        for (int i = 0; i < sizeOfGaps; ++i) {
            gaps[i] = gap;
            sortedSeq.append(gap).append(i < sizeOfGaps-1 ? " " : lb);
            insertionSort(seq, gap);
             
            gap = (gap-1)/3;
        }
        sortedSeq.append(count).append(lb);
    }
 
    public static void printSequence(final int[] seq) {
        for (int i = 0; i < seq.length; i++) {
            sortedSeq.append(seq[i]).append(lb);
        }
        System.out.print(sortedSeq.toString());
    }
 
    public static int[] getSequence() throws IOException {
        final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        final int seqLength = Integer.parseInt(reader.readLine());
 
        final int[] seq = new int[seqLength];
        for (int i = 0; i < seqLength; ++i) {
            seq[i] = Integer.parseInt(reader.readLine());
        }
        reader.close();
 
        return seq;
    }
}

Measured memory_bytes: 131440
def main():
	import sys
	input = sys.stdin.readline
	N = int(input())
	P = list(map(int, input().split()))
	Q = sorted(P)
	count = 0
	for i in range(N):
		if P[i] != Q[i]:
			count += 1
			if count == 3:
				print('NO')
				sys.exit()
	print('YES')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
def show(nums):
    for i in range(len(nums)):
        if i != len(nums)-1:
            print(nums[i],end=" ")
        else:
            print(nums[i])

N = int(input())
nums =list(map(int,input().split()))
show(nums)

for i in range(1,N):
    v = nums[i]
    j = i - 1
    while (j >= 0 and nums[j] > v):
        nums[j+1] = nums[j]
        j -= 1
    nums[j+1] = v
    show(nums)


Measured memory_bytes: 5984
//abc119c
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i < (n);++i)
using namespace std;
using ll = long long;
const ll mod = 1e9+7;
int INF = 1e9;

/*
bit全探索
指定したセットをすべて解く 100*(i+1)*p[i] + c[i]
余ったセットで最高のものを取っておいて後で足してもG点に届かないならそのセットは実現不可
less 足りない点数
最小の問題数を出力
if(less > )
*/
int solve_prob(int d,int g,vector<int> &p, vector<int> &c){
int ans = INF;
  
   for(int i=0;i < (1<<d);i++){
    int solve = 0;
    int score = 0;
    int partial = -1;
     for(int j=0;j<d;j++){
       if(i & (1<<j)){ 
         score += 100*(j+1) * p[j] + c[j];
         solve += p[j];
       }else{
         //残ったセットで最も高得点なもの
         partial = j;
       }
     }
     //less = 目標-組み合わせの総点数
     int less = g - score;
     //得点が足りない
     if(less > 0){
       int problem_s = 100*(partial+1) ;//含まれていないもので最大
       if(less > problem_s* p[partial]) continue;
      //pertial番目の問題数と足らない点数をp[partial]目の問題の点数で割ったものを比較
      //全部使わなくてもよかったら後者を代入A/Bの切り上げ(A+B-1)/B
       solve += min(p[partial], (less+(problem_s-1)) / problem_s); 
     }
     ans = min(ans,solve);
   }
  return ans;
}

int main(){
  int d ,g;
  cin >> d >> g;
  vector<int> p(d,0);
  vector<int> c(d,0);
  for(int i=0;i<d;i++) cin >> p[i] >> c[i];
  int ans = solve_prob(d,g,p,c);
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();
            int[] a = new int[M];
            int[] b = new int[M];
            ArrayList<ArrayList<Integer>> adj = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                adj.add(new ArrayList<>());
            }
            for (int i = 0; i < M; i++) {
                a[i] = in.nextInt() - 1;
                b[i] = in.nextInt() - 1;
                adj.get(a[i]).add(b[i]);
                adj.get(b[i]).add(a[i]);
            }
            dfs(0, adj, 1 << 0, N);
            System.out.println(count);
        }
    }

    private static int count = 0;

    private static void dfs(int index, ArrayList<ArrayList<Integer>> adj, int used, int N) {
        if ((used & ((1 << N) - 1)) == ((1 << N) - 1)) {
            count++;
            return;
        }

        for (Integer i : adj.get(index)) {
            if ((used & (1 << i)) == (1 << i)) {
                continue;
            }
            dfs(i.intValue(), adj, used | (1 << i.intValue()), N);
        }
    }
}


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

int main(){
  int N;
  cin>>N;
  vector<int>D(2*N);
  for(int i=0;i<2*N;i++){
    cin>>D[i];
  }

  bool Q=false;
  for(int i=0;i<2*N-5;i++){
    if(D[i]==D[i+1]&&D[i+2]==D[i+3]&&D[i+4]==D[i+5]){
      Q=true;
    }
  }
  
 if(Q){
   cout<<"Yes"<<endl;
 }
 else{
   cout<<"No"<<endl;
 }
 
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int N,table[100002]={};
  cin >> N;
  for(int i = 0 ; i < N ; i++){
    int a,b;
    cin >> a >> b;
    for(int i = a ; i <= b ; i++ ) table[i]++;
  }
  int res = 0;
  for(int i = 0 ; i <= N + 1 ; i++ ){
    if( ++table[i] >= i) res = i - 1;
  }
  cout << res << endl;
}

Measured memory_bytes: 1560
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    int a[15],b[5],c[5],i,j,hit,blow;
    while(scanf("%d%d%d%d",&b[1],&b[2],&b[3],&b[4])!=EOF)
    {
        hit=blow=0;
        memset(a,0,sizeof(a));
        scanf("%d%d%d%d",&c[1],&c[2],&c[3],&c[4]);
        for(i=1;i<=4;i++)
        {
            a[b[i]]++;
            a[c[i]]++;
            if(b[i]==c[i]){hit++;a[b[i]]=0;}
        }
        for(i=0;i<=9;i++)
        {
            if(a[i]==2)
            {
                blow++;
            }
        }
        printf("%d %d\n",hit,blow);
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll long long
//#define int long long
#define pb push_back
#define x first
#define ld long double
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) a.begin(),a.end()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int cnt = 0, ans = 0;
    for (int i = 0; i < (int)s.length(); i++) {
        if (s[i] == 'p') {
            if (cnt > 0) --cnt;
            else {
                ++cnt;
                --ans;
            }
        }
        else {
            if (cnt > 0) {
                --cnt;
                ++ans;
            }
            else ++cnt;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 512
# APC001
# 方針：a > b がやっかい。a > bのときのa-bの合計をsとする
# a < bのときの(b-a)/2の合計をtとするときs <= tならYES
n = gets.to_i
a = gets.split.map &:to_i
b = gets.split.map &:to_i

s = 0
t = 0
n.times do |i|
  if a[i] > b[i]
    s += a[i] - b[i]
  else
    t += (b[i] - a[i])/2
  end
end

ans = s <= t
puts ans ? "Yes" : "No"



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
using namespace std;
int aa[100],a;
signed main(){
	aa[0]=2;
	aa[1]=1;
	cin>>a;
	rep(i,a-1){
		aa[i+2]=aa[i]+aa[i+1];
	}
	cout<<aa[a];
}

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

using namespace std;

int main(void) {
	int n, a, b;
	int count = 0;
	int now;
	string p;

	cin >> n >> a >> b;

	for (int i = 1; i <= n; i++) {
		p = to_string(i);
		now = 0;
		for (int j = 0; j < p.size(); j++) {
			now += p[j] - '0';
		}
		if (now >= a && now <= b) {
			count += i;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
from bisect import bisect_right
n,d,a=map(int,input().split())
xh=[list(map(int,input().split()))for _ in range(n)]
xh.sort()
x=[]
h=[]
for xx,hh in xh:
  x.append(xx)
  h.append(hh)

not_imos=[0]*(n+1)
atk_n=0
ans=0
for i in range(n):
  atk_n-=not_imos[i]
  h[i]-=atk_n*a
  if h[i]<0:h[i]=0
  atk_i=0--h[i]//a
  ans+=atk_i
  atk_n+=atk_i
  not_imos[bisect_right(x,x[i]+d*2)]+=atk_i
print(ans)

Measured memory_bytes: 102744
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  string str1, str2;
  cin >> str1 >> str2;
  int n = str1.size();
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += (str1[i] != str2[i]);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3784
var input = ""
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
 
process.stdin.on('end', function() {
  input = input.split("\n");
  arr = input[1].split(" ");
  arr.reverse();
  console.log(arr.join(" "));
});

Measured memory_bytes: 7640
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let a:u32 = sc.read();
    let b:u32 = sc.read();
    if a*b%2 == 0 {
        println!("No");
    }else {
        println!("Yes");
    }
}

use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
 
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
map<ll, ll>ins;
void facterize(ll n) {
	ll a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
			ins[a]++;
			ins[a] = ins[a] % 1000000007;
			n /= a;
		}
		else {
			a++;
		}
	}
	ins[n]++;
}

vector<ll>relation[20], money(20, 1);
char s[110][110];
int dp[110][110];

int keta(int x) {
	int y = 0;
	while (x > 0) {
		y++;
		x /= 10;
	}
	return y;
}

int main() {
	string s;
	cin >> s;
	int n = s.length();
	int ans = 0;
	rep(i, n) {
		int res = 0;
		for (int j = i;j < n;++j) {
			if (s[j] != 'A' && s[j] != 'C' && s[j] != 'G' && s[j] != 'T') {
				break;
			}
			res++;
			ans = max(ans, res);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){

  //変数の受け取り
  int A, B;
  scanf("%d%d", &A, &B);
  
  //AとBが1以上9以下だったら計算
  if(1 <= A && A <= 9 && 1 <= B && B <= 9){
  	printf("%d\n", A*B);
  }else{
  	printf("-1\n");
  }
  
  return 0;
}  

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

using namespace std;

int main() {
	int n, ans = 0;
	ignore = scanf("%d", &n);
	for (int i = 0, f = 0, last = -1, x; i < n; i++) {
		ignore = scanf("%d", &x);
		if (x == last) {
			f ^= 1;
			ans += f;
		}
		else {
			last = x;
			f = 0;
		}
	}
	
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int n,a[N],b[N],tot,now;
struct Tree{
	int l,r,num,flag;
}T[N*80];
inline int ef(int x){
	int l=1,r=tot;
	while (l<r){
		int mid=(l+r)/2;
		if (b[mid]<x)l=mid+1;
		else r=mid;
	}
	return l;
}
inline void build(int x,int l,int r){
	T[x].l=l;T[x].r=r;T[x].flag=-1;T[x].num=0;
	if (l==r)return;
	int mid=(l+r)/2;
	build(x*2,l,mid);
	build(x*2+1,mid+1,r);
}
inline void down(int x){
	if (T[x].flag!=-1){
		T[x*2].flag=T[x*2].num=T[x].flag;
		T[x*2+1].flag=T[x*2+1].num=T[x].flag;
		T[x].flag=-1;
	}
}
inline void insert(int x,int l,int r,int z){
	if (T[x].l>r||l>T[x].r)return;
	if (T[x].l>=l&&T[x].r<=r){
		T[x].num=z;
		T[x].flag=z;
		return;
	}
	down(x);
	insert(x*2,l,r,z);
	insert(x*2+1,l,r,z);
	T[x].num=min(T[x*2].num,T[x*2+1].num);
}
inline void insert2(int x,int y){
	if (T[x].l==T[x].r){
		T[x].num++;
		return;
	}
	down(x);
	int mid=(T[x].l+T[x].r)/2;
	if (y<=mid)insert2(x*2,y);
	else insert2(x*2+1,y);
	T[x].num=min(T[x*2].num,T[x*2+1].num);
}
inline int find(int x,int l,int r){
	if (T[x].l>r||l>T[x].r)return 1e9;
	if (T[x].l>=l&&T[x].r<=r)return T[x].num;
	down(x);
	return min(find(x*2,l,r),find(x*2+1,l,r));
}
inline void Find(int x,int l,int r,int ans){
	if (T[x].l>r||l>T[x].r)return;
	if (T[x].l>=l&&T[x].r<=r){
		if (T[x].num<ans){
			if (now==-1||T[now].l<T[x].l)now=x;
		}
		return;
	}
	down(x);
	Find(x*2,l,r,ans);
	Find(x*2+1,l,r,ans);
}
inline int EF(int x,int ans){
	if (T[x].l==T[x].r)return T[x].l;
	down(x);
	if (T[x*2+1].num==ans)return EF(x*2,ans);
	return EF(x*2+1,ans);
}
inline int check(int ans){
	build(1,1,b[tot]);
	for (int i=1;i<=n;i++){
		if (i==1){
			insert(1,1,a[i],1);
			continue;
		}
		int x=a[i];
		if (x<a[i-1])insert(1,x+1,a[i-1],0);
		if (x>a[i-1]){
			insert(1,a[i-1]+1,x,1);
			continue;
		}
		now=-1;
		Find(1,1,x,ans);
		if (now==-1)return 0; 
		int l=EF(now,ans);
		insert(1,l+1,x,1);
		insert2(1,l);
	}
	return 1;
}
int main(){
	scanf("%d",&n);
	int ans=0;
	for (int i=1;i<=n;i++)scanf("%d",&a[i]),b[++tot]=a[i];
	sort(b+1,b+tot+1);
	int num=1;
	for (int i=2;i<=n;i++)
		if (b[i]!=b[num])b[++num]=b[i];
	tot=num;
	for (int i=1;i<=n;i++)a[i]=ef(a[i]);
	int delta=0;
	for (int i=1;i<=tot;i++){
		b[i]-=delta;
		if (b[i]-b[i-1]>18){
			int k=b[i]-b[i-1]-18;
			delta+=k;
			b[i]-=k;
		}
	}
	for (int i=1;i<=n;i++)a[i]=b[a[i]];
	build(1,1,b[tot]);
	for (int i=1;i<=n;i++){
		if (i==1){
			ans=1;
			insert(1,1,a[i],1);
			continue;
		}
		int x=a[i];
		if (x<a[i-1])insert(1,x+1,a[i-1],0);
		if (x>a[i-1]){
			insert(1,a[i-1]+1,x,1);
			continue;
		}
		if (find(1,1,x)==ans)insert(1,x,x,++ans);
		else {
			now=-1;
			Find(1,1,x,ans);
			int l=EF(now,ans);
			insert(1,l+1,x,1);
			insert(1,l,l,find(1,l,l)+1);	
		}
	}
	int l=1,r=ans;
	while (l<r){
		int mid=(l+r)/2;
		if (check(mid))r=mid;
		else l=mid+1;
	} 
	printf("%d\n",l);
}

Measured memory_bytes: 134912
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b / gcd(a,b);}

int main() {
    int a,b;
    cin >> a >> b;
    cout << ceil((double)(a+b)/2) << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define N 111111
using namespace std;
int n,c,x[N],y[N];
int sum1[N],sum2[N];
int f1[N],f2[N],g1[N],g2[N];
int ans=0;
signed main(){
	cin>>n>>c;
	for(int i=1;i<=n;i++)cin>>x[i]>>y[i];
	for(int i=1;i<=n;i++){
		sum1[i]=sum1[i-1]+y[i];
		f1[i]=max(f1[i-1],sum1[i]-x[i]);
		g1[i]=max(g1[i-1],sum1[i]-x[i]*2);
	}
	for(int i=n;i>0;i--){
		sum2[i]+=sum2[i+1]+y[i];
		f2[i]=max(f2[i+1],sum2[i]-(c-x[i])*2);
		g2[i]=max(g2[i+1],sum2[i]-(c-x[i]));
	}
	rep(i,n+1){
		ans=max(ans,f1[i]+f2[i+1]);
		ans=max(ans,g1[i]+g2[i+1]);
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 6912
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	const int mod=1000000007;
	static void Main(){
		Sc sc=new Sc();
		string s=sc.S,t=sc.S;
		int[] sn=new int[s.Length+1];
		int[] tn=new int[t.Length+1];
		for(int i=1;i<=s.Length;i++){sn[i]=s[i-1]=='A'?sn[i-1]+1:sn[i-1];}
		for(int i=1;i<=t.Length;i++){tn[i]=t[i-1]=='A'?tn[i-1]+1:tn[i-1];}
		int n=sc.I;
		string[] ans=new string[n];
		for(int i = 0;i<n;i++) {
			int[] q=sc.Ia;
			ans[i]=((3+((sn[q[1]]-sn[q[0]-1])%3)-((tn[q[3]]-tn[q[2]-1])%3))%3)==((3+(((q[1]-q[0]+1)-(sn[q[1]]-sn[q[0]-1]))%3)-(((q[3]-q[2]+1)-(tn[q[3]]-tn[q[2]-1]))%3))%3)?"YES":"NO";
		}
		Console.WriteLine(String.Join("\n",ans));
	}
}

class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 23096
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias Goods = Tuple!(long, "w", long, "v");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

auto dp = new long[][](110, 100_100);
void main()
{
    long N, W;
    scan(N, W);
    auto goods = new Goods[](N);
    foreach (i; iota(N))
    {
        long w, v;
        scan(w, v);
        goods[i] = Goods(w, v);
    }
    foreach (i; iota(N))
    {
        foreach (j; iota(W))
        {
            dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]);
            if (j + goods[i].w <= W)
            {
                dp[i + 1][j + goods[i].w] = dp[i][j] + goods[i].v;
            }
            // dp[i + 1].take(W + 1).writeln();
        }
    }
    // foreach (i, e; dp)
    // {
    //     if (i < N)
    //         e.take(W).writeln();
    // }
    dp[N].take(W + 1).reduce!(max).writeln();
}


Measured memory_bytes: 78460
#include<bits/stdc++.h>
#include<vector>
#include<math.h>
#include<iostream>
#include<float.h>
#include<string>

#define llong long long;
using namespace std;

int main(){
  long long int n; cin >> n;
  long long num = 0;
  int a = n;
  while(n > 0){
    num += n% 10;
    n /= 10;
  }
  if(a % num == 0){
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 256
from collections import Counter

def solve():
    N = int(input())
    R = map(int, input().split())
    counter = Counter(R)
    rect = []
    ret = 0
    edges = sorted(counter.items(), key=lambda x: -1*x[0])
    for a,b in edges:
        if b >= 4:
            rect.append(a)
            rect.append(a)
        elif b >= 2:
            rect.append(a)
        
        if len(rect) >= 2: 
            ret = rect[0]*rect[1]
            break
            
    print(ret)
    
solve()

Measured memory_bytes: 29140
#include <iostream>
using namespace std;
int n,k,i,j,d,f[250],x,code;
int main()
{
    cin>>n>>k;
    for (i=1;i<=k;++i)
    {
        cin>>d;
        for (j=1;j<=d;++j)
        {
            cin>>x;
            f[x]=1;
        }
    }
    for (i=1;i<=n;++i)
         if (!f[i]) code++;
    cout<<code<<"\n";
}


Measured memory_bytes: 3636
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn main() {
    let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let a = line[0];
    let b = line[1];
    if a < b {
        println!("0");
    } else {
        println!("10");
    }
}


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

using namespace std;

typedef long long ll;

ll N;

set <ll> check;
multiset <ll> check_i;
multiset <ll> check_j;

int main() {
	ll i, j;

	cin >> N;

	for (i = 0; i < N; i++) {
		ll a;
		cin >> a;
		check.insert(i + a);
		check_i.insert(i + a);
		check_j.insert(i - a);

	}

	ll n = 0;
	for (auto itr: check) {
		n+= check_i.count(itr) * check_j.count(itr);
	}
	cout << n << endl;

}

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

int mod = 1000000007;

int main()
{
    int H, W;
    cin >> H >> W;

    vector<vector<char>> list(H, vector<char>(W));
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> list[i][j];
        }
    }
    for (int i = 0; i < H; i++)
    {
        for (int k = 0; k < 2; k++)
        {
            for (int j = 0; j < W; j++)
            {
                cout << list[i][j];
            }
            cout << endl;
        }
    }
}

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

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

const int MOD = 1000000007;

struct Pony
{
    long a, b;
 
    Pony(long a_, long b_)
    {
        a = a_;
        b = b_;
    }
 
    bool operator<(const Pony &another) const
    {
        return b < another.b;
    };
};

int fac(int k){
    int sum = 0;
    for (int i = 1; i <= k; ++i)
    {
        sum += i;
    }
    return sum;
}

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

  int n;

  cin >> n;

  vector<long> a(n);

  fillLong(a, n);

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

  now = (a[n-1] - now)/2;
  rep(i, n){
    cout << (now*2) << " ";
    now = a[i] - now;
  }

  cout << endl;

}


Measured memory_bytes: 2176
N = int(input())
S = [input() for _ in range(N)]

tailA = 0
headB = 0
same = 0
inside = 0
for s in S:
    inside += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        same += 1
    else:
        if s[0] == 'B':
            headB += 1
        if s[-1] == 'A':
            tailA += 1

ans = 0

if same >= 1:
    if tailA >= 1:
        ans += same
        tailA -= 1
    else:
        ans += same - 1

    if headB >= 1:
        ans += 1
        headB -= 1

ans += max(min(tailA, headB), 0)
print(ans + inside)

Measured memory_bytes: 3700
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <vector>

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

int main() {

	int a, b, c;
	int N;
	int l[1234][4];
	int r[1234];

	for (;;) {
		scanf("%d %d %d", &a, &b, &c);
		if (a + b + c == 0) break;
		rep(i, a + b + c) r[i + 1] = 2;
		scanf("%d", &N);
		rep(i, N) scanf("%d %d %d %d", &l[i][0], &l[i][1], &l[i][2], &l[i][3]);

		rep(i, N) {
			if (l[i][3] == 1) {
				r[l[i][0]] = 1;
				r[l[i][1]] = 1;
				r[l[i][2]] = 1;
			}
		}

		rep(i, N) {
			if (l[i][3] == 0) {
				if (r[l[i][0]] == 1 && r[l[i][1]] == 1) r[l[i][2]] = 0;
				else if (r[l[i][1]] == 1 && r[l[i][2]] == 1) r[l[i][0]] = 0;
				else if (r[l[i][2]] == 1 && r[l[i][0]] == 1) r[l[i][1]] = 0;
			}
		}
		
		rep(i, a + b + c) printf("%d\n", r[i + 1]);
	}

	return 0;
}

Measured memory_bytes: 2564
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int n,m;
vector <vector <int> > g;
vector <int> start,fin;
vector <bool> visited;
vector <int> depth;
int c=0;
int dfs(int s,int depth2);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    n=nxt();m=nxt();
    vector <int> r;
    g.resize(n+1,r);
    start.resize(n+1,-1);
    fin.resize(n+1,-1);
    visited.resize(n+1,0);
    depth.resize(n+1,0);
    for(int i=0;i<m;i++)
    {
        int u=nxt(),v=nxt();
        g[u].push_back(v);
        g[v].push_back(u);
    }
    
    dfs(1,0);
    cout<<c<<endl;
    
    return 0;   
}

int dfs(int s,int depth2)
{
    visited[s]=1;
    depth[s]=depth2;
    int ret=n+1;
    for(auto i:g[s])
    {
        if(!visited[i])
        {
            int x=dfs(i,depth2+1);
            if(x>depth2)
                c++;
            ret=min(ret,x);
        }
        else
        {
            if(depth[i]!=depth[s]-1)
                ret=min(ret,depth[i]);
        }
    }
    //cout<<s<<" "<<ret<<endl;
    return ret;

}




 
 


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>

using namespace std;

int main() {
    string s;

    cin >> s;

    int first = s.find_first_of('A');
    int last  = s.find_last_of('Z');
    int ans   = last - first + 1;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

char itoc(int i)
{
    return static_cast<char>(i + '0');
}

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

    string S;
    cin >> S;

    int cnt = 0;
    for (int i = 0; i <= 9; i++)
    {
        for (int j = 0; j <= 9; j++)
        {
            for (int k = 0; k <= 9; k++)
            {
                char ci = itoc(i), cj = itoc(j), ck = itoc(k);
                bool fi = false, fj = false, fk = false;

                // cout << ci << cj << ck;

                for (int is = 0; is < S.length(); is++)
                {
                    if (fi == false && S[is] == ci)
                    {
                        fi = true;
                        is++;
                    }

                    if (fi == true && fj == false && S[is] == cj)
                    {
                        fj = true;
                        is++;
                    }

                    if (fj == true && fk == false && S[is] == ck)
                    {
                        fk = true;
                        cnt++;
                        break;
                    }
                }
                // cout << (fk ? ": found" : "") << endl;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
while True:
    m, f, r = [int(i) for i in input().strip().split()]
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50:
        print("C")
    elif m + f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


Measured memory_bytes: 5600
//
//  main.cpp
//  Stone
//
//  Created by Mihozil on 4/27/19.
//  Copyright © 2019 Mihozil. All rights reserved.
//

#include <iostream>
using namespace std;

long n;
long a[200005];

void solve() {
    long b = 0;
    long w = 0;
    for (int i=1; i<=n; i++) {
        if (a[i]==1)
            w+=1;
        else b+=1;
    }
    
    long result = n+1;;
    long cb = 0;
    long cw = 0;
    for (int i=0; i<=n; i++) {
        if (a[i]==1)
            cw += 1;
        if (a[i] == 2)
            cb+=1;
        
        long current = cb + (w-cw);
        if (result>current)
            result = current;
    }
    cout<<result;
}

void read() {
    cin>>n;
    a[0] = 0;
    for (int i=1; i<=n;i++) {
        char ch;
        cin>>ch;
        if (ch=='.')
            a[i] = 1; // white
        else
            a[i] = 2; // black
    }
    solve();
}

int main(int argc, const char * argv[]) {
    // insert code here...
    read();
    return 0;
}


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

/* snippet: useful macros and functions */
#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T rng(const T &a, const T &b){ return a < b ? b - a : a - b; }
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

/* snippet: modint library */
template<class T, int MOD>
class Modint{
	T val;
public:
	Modint(T val = 0) : val(val) {}
	operator T(){ return val; }
	Modint &operator+=(const Modint &a){ val += a.val; if(val >= MOD) val -= MOD; return *this; }
	Modint &operator-=(const Modint &a){ val -= a.val; if(val < 0) val += MOD; return *this; }
	Modint &operator*=(const Modint &a){ val = val * a.val % MOD; return *this; }
	void inverse(){T x[2]={MOD,val},a[2]={0,1};int i;for(i=0;x[!i];i^=1){a[i]-=x[i]/x[!i]*a[!i];x[i]=x[i]%x[!i];}if(!i)a[i]+= MOD;val=a[i];}
	Modint &operator/=(Modint a){ a.inverse(); return *this *= a; }
	friend Modint modpow(Modint a, int n){ Modint ret(1); while(n){ if(n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
	friend Modint operator+(Modint a, const Modint &b){ return a += b; }
	friend Modint operator-(Modint a, const Modint &b){ return a -= b; }
	friend Modint operator*(Modint a, const Modint &b){ return a *= b; }
	friend Modint operator/(Modint a, const Modint &b){ return a /= b; }
	friend std::ostream &operator<<(std::ostream &os, const Modint &a){ return os << a.val; }
};

/* snippet: using declarations */
using Int = int;
using namespace std;
using Mint = Modint<long long, 1000000007>;

int main(){
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
#include <cmath>
#include<stdio.h>
#define MAX 1000000000000000000LL
long long inf=1000000007;
using namespace std;
    int H,A[2000001];

void maxheapify(int i){
    int l,r,largest;
    l=2*i;
    r=2*i+1;
    if(l<=H&&A[l]>A[i])largest=l;
    else largest=i;
    if(r<=H&&A[r]>A[largest])largest=r;
    
    if(largest!=i){
        swap(A[i],A[largest]);
    maxheapify(largest);
    }
        
}
       
int main(){
    cin>>H;
    for(int i=1; i<=H; i++){
        cin>>A[i];
    }
    for(int i=H/2; i>=1; i--){
        maxheapify(i);
    }
    for(int i=1; i<=H; i++){
        cout<<" "<<A[i];
    }
    cout<<endl;
    
    return 0;

}

Measured memory_bytes: 5056
n = int(input())
A = list(map(int,input().split()))
from collections import deque
q = deque(A)
i = 1
ans = []
while i <= n and q:
    a = q.popleft()
    if a==i:
        ans.append(a)
        i += 1
if len(ans)==0:
    print(-1)
else:
    print(n-len(ans))



Measured memory_bytes: 100964
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    if(n==2) printf("%d %d\n",a[1],a[0]);
    else
    {
        int ans=1000000001,m=0;
        for(int i=0;i<n-1;i++)
        {
            int t=abs(a[n-1]-2*a[i]);
            if(t<ans)
            {
                ans=t;
                m=a[i];
            }
        }
        printf("%d %d\n",a[n-1],m);
    }
    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

ll solve(){
    ll res = LINF;
    ll N,M; cin >> N >> M;
    {
        ll num = 0;
        ll uku = 2*N,ei = 2*M;
        ll uku_dame = 0,ei_dame = 0;
        while(true){
            if(num%2 == 0){
                ll uku_num = (uku-uku_dame)/2;
                ei_dame+=uku_num;
            }else{
                ll ei_num = min(M,ei-ei_dame);
                uku_dame+=ei_num;
            }
            if(uku-uku_dame<=0) break;
            if(ei-ei_dame<=0) break;
            num++;
        }
        res = min(res,num);
    }
    {
        ll num = 0;
        ll uku = 2*N,ei = 2*M;
        ll uku_dame = 0,ei_dame = 0;
        while(true){
            if(num%2 == 0){
                ll uku_num = min(N,uku-uku_dame);
                ei_dame+=uku_num;
            }else{
                ll ei_num = (ei-ei_dame)/2;
                uku_dame+=ei_num;
            }
            if(uku-uku_dame<=0) break;
            if(ei-ei_dame<=0) break;
            num++;
        }
        res = min(res,num);
        
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}



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

int main() {
  int H, W; cin >> H >> W;
  bool S[H][W];
  for (int i = 0; i < H; i++) {
    string str; cin >> str;
    for (int j = 0; j < W; j++) {
      S[i][j] = (str[j] == '.');
    }
  }
  int l[H][W], r[H][W], u[H][W], d[H][W];
  for (int i = 0; i < H; i++) {
    l[i][0] = S[i][0];
    r[i][W-1] = S[i][W-1];
  }
  for (int j = 0; j < W; j++) {
    u[0][j] = S[0][j];
    d[H-1][j] = S[H-1][j];
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (j) {
        l[i][j] = (l[i][j-1] + 1) * S[i][j];
        r[i][W-1-j] = (r[i][W-j] + 1) * S[i][W-1-j];
      }
      if (i) {
        u[i][j] = (u[i-1][j] + 1) * S[i][j];
        d[H-1-i][j] = (d[H-i][j] + 1) * S[H-1-i][j];
      }
    }
  }
  int max_sq = 1;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      max_sq = max(max_sq, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3);
    }
  }
  cout << max_sq << endl;
}

Measured memory_bytes: 66688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
string s;
int n;
ll ans;
int tim = 0;
void go(int idx, ll lst,ll sm){
    if(idx==n){
            ans+=sm+lst;
            return ;
    }
    tim++;
  //  cout<<idx<<" "<<lst<<" "<<sm<<" "<<tim<<endl;
    go(idx+1,s[idx]-'0',sm+lst);
    ll trt = lst*10+int(s[idx]-'0');
    go(idx+1,trt,sm);
    return ;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>s;
    n = s.size();
    go(1,s[0]-'0',0);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n, k = map(int,input().split())
l = []
for i in range(1,n+1):
  l.append(i)
for i in range(k):
  d = int(input())
  a = list(map(int,input().split()))
  for j in range(d):
    if a[j] in l:
      l.remove(a[j])
print(len(l))

Measured memory_bytes: 9128