akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

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

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int main(){
  string s;cin>>s;
  int n = (int)s.size();
  vector<vector<ll> > dp(n+1, vector<ll>(13, 0));
  dp[n][0]=1LL;
  ll digit=1LL;
  for(int i=n-1;i>=0;i--){
    ll v=(s[i]!='?'?ll(s[i]-'0'):-1LL);
    for(int j=0;j<13;j++){
      if(v==-1LL){
        rep(k, 10){
          dp[i][(j+(k*digit)%13)%13]+=dp[i+1][j];
          dp[i][(j+(k*digit)%13)%13]%=MOD;
        }
      }else{
        dp[i][(j+v*digit%13)%13]+=dp[i+1][j];
        dp[i][(j+v*digit%13)%13]%=MOD;
      }
    }
    digit = (digit*10)%13;
  }
  cout<<dp[0][5]<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


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

int main()
{
int a,b ; 		
cin>>a>>b; 

if(a==1) a+=13;	
if(b==1) b+=13;	


	if(a>b)
cout<<"Alice"<<endl;	
	else if(a<b)
cout<<"Bob"<<endl;
else
	cout<<"Draw"<<endl;
return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>
#include <sstream>
#include <bitset>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
#define MOD ((int)1e9+7)
//static const long double pi = 3.1415926535897932;

using namespace std;
using ll = long long int;
using ull = unsigned long long;

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

struct Combination {
	const int num=51e4;			//要素数
	const int mod=1e9+7;
	vector<ll> fact,inv,finv; //階乗,逆元,逆元の階乗.
	
	Combination():fact(num),inv(num),finv(num){
		fact[0]=fact[1]=1;
		inv[1]=1;
		finv[0]=finv[1]=1;
		for(int i=2;i<num;++i){
			fact[i]=fact[i-1]*i%mod;
			inv[i]=mod-inv[mod%i]*(mod/i)%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	
	int nCk(int n,int k){
		if(n<k) return 0;
		if(n<0 or k<0) return 0;
		return fact[n]*(finv[k]*finv[n-k]%mod)%mod;
	}
	int big_nCk(int n,int k){ //nが大きいとき
		ll res=1LL;
		for (int i = 0; i < k; i++) {
			res=res*(n-i)%mod;
		}
		res = res*finv[k]%mod;
		return res;
	}
	int nHk(int n,int k){return nCk(n+k-1,n-1);}//重複組み合わせ.
};

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

ll pow_mod(ll n, ll k, ll p) { // n^k(mod p)
	if (k == 0) {
		return 1;
	}
	ll res = pow_mod(n * n % p, k / 2, p);
	if (k & 1) {
		res = res * n % p;
	}
	return res;
}

bool vector_finder(std::vector<int> vec, int number) { // vector 内にnumberがあるかどうか
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance( vec.begin(), itr );
	if (index != vec.size()) { // 発見できたとき
		return true;
	}
	else { // 発見できなかったとき
		return false;
	}
}

int main() {
	string n;
	cin >> n;
	ll tmp = 0;
	for (ll i = 0; i < n.size(); i++) {
		tmp += (n[i] - '0');
	}
	if (tmp % 9 == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3720
import java.util.*;

class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int digit_1 = N % 10;
        String read = "hon";
        Integer[] pon = {0, 1, 6, 8};
        List<Integer> ponNew = Arrays.asList(pon);

        if (digit_1 == 3) {
            read = "bon";
        } else if (ponNew.contains(digit_1)) {
            read = "pon";
        }
        System.out.println(read);

    }
}

Measured memory_bytes: 35852
import numpy as np

H,W=map(int,input().split())
S=[list(input()) for _ in range(H)]
#print(S)
M=np.zeros((H,W))
M=M.tolist()
def mapsearch(S,x,y,H,W):
    count=0
    if S[x][y]=="#":
        return "#"
    else:
        for i in range(max(0,x-1),min(H,x+2)):
            for j in range(max(0,y-1),min(W,y+2)):
                if S[i][j]=="#":
                    count=count+1

    return count

for i in range(H):
    for j in range(W):
        M[i][j]=mapsearch(S,i,j,H,W)
for i in M:print(*i, sep='')

Measured memory_bytes: 12848
n, k = map(int, input().split())
v = list(map(int, input().split()))
M = 0

for left in range(k + 1):
    for right in range(k - left + 1):
        if left + right > n:
            break
        hold = []
        hold.extend(v[:left])
        hold.extend(v[n-right:])
        hold.sort()
        total = sum(hold)
        for i in range(min(k - left - right, left + right)):
            if 0 <= hold[i]:
                break
            total -= hold[i]
        M = max(M, total)

print(M)



Measured memory_bytes: 3188
import numpy as np
import itertools

N = int(input())
xi,yi,hi = [], [], []
for _ in range(N):
    x,y,h = map(int, input().split())
    xi.append(x)
    yi.append(y)
    hi.append(h)

max_hi = max(hi)
max_i = hi.index(max_hi)
max_xi = xi[max_i]
max_yi = yi[max_i]

xi = np.array(xi)
yi = np.array(yi)
hi = np.array(hi)

for Cx,Cy in itertools.product(range(101), repeat=2):
    H = abs(Cx - max_xi) + abs(Cy - max_yi) + max_hi
    hi_ = np.fmax( H - np.absolute(Cx-xi) - np.absolute(Cy-yi), 0)
    diff = hi-hi_
    if np.all(diff==0):
        print("{} {} {}".format(Cx, Cy, H))
        exit(0)


Measured memory_bytes: 21152
use std::io;


fn main() {
    let a = read_one::<isize>();
    let b = read_one::<isize>();
    let h = read_one::<isize>();
    println!("{}", (a + b) * h / 2);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <iostream>
#include <math.h>
using namespace std;

int N;
int c=0;

int main(){
  if(scanf("%d", &N)==0);
  int a[N]={0};
  for(int i=0; i<N; i++){
    if(scanf("%d", &a[i])==0);
  }
  int max=0;
  int max2=0;
  for(int i=0; i<N; i++){
    if(max < a[i]){
      max = a[i];
      c=i;
    }
  }
  for(int i=0; i<N; i++){
    if(max2 < a[i] && i!=c){
      max2 = a[i];
    }
  }
  for(int i=0; i<N; i++){
    if(i==c){
      printf("%d\n", max2);
    } else {
      printf("%d\n", max);
    }
  }
  
  return 0;
}

Measured memory_bytes: 2432
#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:https://atcoder-scores.herokuapp.com/index.html?user=clavis1107>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
ll solve(){
    ll res = 0;
    ll N; cin >> N;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    map<ll,ll> mp;
    ll sum = 0;
    mp[sum]++;
    for(auto v:A){ sum+=v; mp[sum]++;}
    for(auto p:mp){
        res += p.second*(p.second-1)/2;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 0, maxVal = -1;
	for (int i = 0; i < n; i++) {
		if (a[i] >= maxVal) ans++, maxVal = a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
#define fst first
#define snd second
#define fr(i, a, b) for(int i=a; i<b; i++)

ll a, b;
bool isprime(ll x) {
    if(x==1) return 1;
    for(ll i=2; i*i <=x; i++) if(x%i==0) return 0;
    return 1;
}
int main() {
    cin >> a >> b;
    set<ll> s, s2;
    for(ll i=1; i*i <= a; i++) {
        if(a %i ==0) {
            s.insert(i);
            s.insert(a / i);
        }
    }
    for(ll i=1; i*i <= b; i++) {
        if(b %i ==0) {
            if(s.count(i)) s2.insert(i);
            if(s.count(b/i)) s2.insert(b/i);
        }
    }
    int res = 0;
    for(auto it = s2.begin(); it!=s2.end(); it++) {
        if(isprime(*it)) res++;
    }
    cout << res << endl;
}


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

using namespace std;

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

string s;
ll acu = 0, res = 0;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> s;
	for (char c : s)
		if (c == 'B') acu++;
		else res += acu;
	cout << res << endl;

	return 0;
}

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

int N;
int number1[105];
int num1Size;
int number2[105];
int num2Size;
int sum;
int main(){
  std::cin>>N;
  for(int i=0;i<N;++i){
    int temp;
    std::cin>>temp;
    if(temp%10==0){
      number1[num1Size]=temp;
      ++num1Size;
    }
    else{
      number2[num2Size]=temp;
      ++num2Size;
    }
    sum+=temp;
  }
  
  if(num2Size!=0){
    if(sum%10==0){
      std::sort(number2,number2+num2Size);
      sum-=number2[0];
    }
    
    std::cout<<sum<<std::endl;
  }
  else
    std::cout<<"0"<<std::endl;
  
  return 0;
}

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



Measured memory_bytes: 3076
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
A, B, C, D = MAP()

a = min(B, D) - max(A, C)

print(a if a > 0 else 0)

Measured memory_bytes: 5204
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

fn main() {
    input! {
        n: usize,
        a: i64,
        b: i64
    }

    if a.count_ones() % 2 == b.count_ones() % 2 {
        println!("NO");
    } else {
        println!("YES");
        let ret = calc(a, b, n, 0);
        for i in 0..ret.len()-1 {
            print!("{} ", ret[i]);
        }
        println!("{}", ret[ret.len()-1]);
    }
}

fn calc(a: i64, b: i64, n: usize, invalid_bits: i64) -> Vec<i64> {
    if n == 1 {
        return vec![a, b]
    }

    let x = a ^ b;
    let diff_bit = x & -x;
    let diff_bit_mask = !diff_bit;
    let next_invalid_bits = invalid_bits | diff_bit;
    let next_valid_bits = !next_invalid_bits;
    let c = a ^ (next_valid_bits & -next_valid_bits);
    let left = calc(a & diff_bit_mask, c & diff_bit_mask, n - 1, next_invalid_bits);
    let right = calc(c & diff_bit_mask, b & diff_bit_mask, n - 1, next_invalid_bits);
    
    let mut ret = left.iter().map(|&k| k | (a & diff_bit)) .collect::<Vec<_>>();
    ret.extend(right.iter().map(|&k| k | (b & diff_bit)) .collect::<Vec<_>>());
    ret
}


Measured memory_bytes: 7728
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.close();
        boolean ans = false;
        for(int i = 0; i < 15; i++){
            int t = N < (7 * i) ? N : N - (7 * i);
            if(t % 4 == 0) {
                ans = true;
                break;
            }
        }
        if(ans) System.out.println("Yes");
        else System.out.println("No");

    }

}

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

int N[3];
int res;

int main() {
  cin >> N[0] >> N[1] >> N[2];
  sort(N, N + 3);
  int a = (N[2] - N[0]) / 2;
  int b = (N[2] - N[1]) / 2;
  N[0] += a * 2; N[1] += b * 2; res += a; res += b;
  int c = (3 - ((N[0] < N[2]) + (N[1] < N[2]))) % 3;
  res += c;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  int ans = vec.at(N-1) - vec.at(0);
  for (int i = 0; i < N-K+1; i++) {
    int tmp = vec.at(K+i-1) - vec.at(i);
    if(tmp < ans) ans = tmp;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<queue>
using namespace std;
int tu[100][100];
int a[100];
int d[100];
int n;
void bfs(int x){
    queue<int> q;
    q.push(x);
    for(int i=0;i<n;i++)d[i]=10000000;
    d[x]=0;
    int u;
    while(!q.empty()){
        u=q.front();
        q.pop();
        for(int i=0;i<n;i++){
            if(tu[u][i]==0)continue;
            if(d[i]!=10000000)continue;
            d[i]=d[u]+1;
            q.push(i);
        }
        }
        for(int i=0;i<n;i++){
            printf("%d ",i+1);
            if(d[i]==10000000)printf("-1");
            else printf("%d",d[i]);
            printf("\n");
        }
}
int main(){
    scanf("%d",&n);
    int v,m,k;
    for(int i=0;i<n;i++){
        scanf("%d%d",&v,&m);
        v--;
        for(int j=0;j<m;j++){
            scanf("%d",&k);
            k--;
            tu[v][k]=1;
        }
    }
    bfs(0);
    return 0;
}

Measured memory_bytes: 2752
#include <iostream>
#include <vector>
using namespace std;
int main(){
    long long A, B;
    cin >> A >> B;
    if(A % 2 == 0 && B % 2 == 0){
        long long C = B - A + 1;
        long long cnt = C / 2;
        if(cnt % 2 == 0) cout << B << endl;
        else {long long ans = B ^ 1;
        cout << ans << endl;
        }
    }
    else if(A % 2 == 0 && B % 2 == 1){
        long long C = B - A + 1;
        if(C / 2 % 2 == 0) cout << 0 << endl;
        else cout << 1 << endl;
    }
    else if(A % 2 == 1 && B % 2 == 0){
        long long C = B - A;
        long long ans;
        if(C / 2 % 2 == 0){
            ans = A ^ B;
        }
        else ans = A^ B ^ 1;
        cout << ans << endl;
    }
    else{
        long long cnt = (B - A + 1) / 2;
        if(cnt % 2 == 0){
            cout << A << endl;
        }
        else{
            long long ans = A^1;
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

int main(void){
  int a[2], b[2];
  cin >> a[0] >> a[1] >> b[0] >> b[1];
  sort(a, a+2);
  sort(b, b+2);
  cout << a[0] + b[0] << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define p(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
//#define int long long


using namespace std;


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




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll pow2(ll a, ll n) {//aのn乗を計算します。
	ll x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


const int MOD = 1000000007;

bool arr[1050000];
int sosuu[100010];
void Eratosthenes() {
	ll N = 1050000;
	int c = 0;
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (int i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (int j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for (int i = 2; i < N; i++) {
		if (arr[i]) {
			sosuu[c] = i;
			//cout << sosuu[c] << " ";
			c++;
		}
	}
	//cout << endl;
	//cout << c << endl;
}


vector<int> graph[100010];
deque<int> dq;
bool included[100010];
int main() {
	m0(included);
	int N, M; cin >> N >> M;
	REP(i, M) {
		int A, B; cin >> A >> B;
		graph[A].pb(B);
		graph[B].pb(A);
	}
	dq.push_back(1);
	included[1] = true;
	bool ok = true;
	while (ok) {
		ok = false;
		int pos = dq.back();
		for (auto x : graph[pos]) {
			if (!included[x]) {
				ok = true;
				dq.push_back(x);
				included[x] = true;
				break;
			}
		}
	}
	ok = true;
	ok = true;
	while (ok) {
		ok = false;
		int pos = dq.front();
		for (auto x : graph[pos]) {
			if (!included[x]) {
				ok = true;
				dq.push_front(x);
				included[x] = true;
				break;
			}
		}
	}
	int c = dq.size();
	cout << c << endl;
	auto itr = dq.begin();
	for (itr; itr != dq.end(); itr++) {
		cout << *itr << " ";
	}
	cout << endl;
}

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

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

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

int main(){
	
	int X;
	
	cin >> X;
	
	if( X >= 30 ){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	
	return 0;
	
}


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

int main() {
  int A,B,C,sum=0;
  cin >> A >> B >> C;
  bool a=false;
  for(int i=A;i<B*A+1;i+=A){
    sum+=A;
    if(sum%B==C){
      a=true;
      break;
    }
  }
  if(a){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 3492
# include<stdio.h>

int main()
{
	int a[3],t,i,j;
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
		for(j=0;j<3;j++)
	    {
	        for(i=0;i<3-j-1;i++)
	        {
	        	if(a[i]>a[i+1])
	        	{
	        		t=a[i];
		        	a[i]=a[i+1];
		        	a[i+1]=t;
				}
	        }
	    }
		printf("%d\n",a[0]+a[1]);
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll   long long
#define ld long double
#define endl '\n'
#define INF 10000000000000000
#define pll pair<ll,ll>
#define ff first
#define ss second

using namespace std;
const ll N = 200005;
const ll MOD = 998244353;
vector<ll> g[N];
bool use[N];
    ll n,m;
    ll in_degree[N];
ll bfs() {
    ll d[N]={0};
    for(ll i =1;i<=n;i++) {
        d[i]=INF;
    }
    priority_queue<pll> q;
    ll mx = 0;
    q.push(make_pair(0,0));
    while(!q.empty()) {
        ll v = q.top().ss;
        ll dw = q.top().ff;
        q.pop();
        if(d[v]>dw) continue;
        if(d[v]>mx) mx=d[v];
        for(ll i =0;i<g[v].size();i++) {
                ll to =g[v][i];

                if(in_degree[to]>=0)
                in_degree[to]--;
             //   cout<<i<<" "<<to<<" "<<in_degree[to]<<endl;
                if(d[to]==INF || d[to]<=d[v]) {
                    d[to]=d[v]+1;
                  //  q.push({d[to],to});
                }
                if(in_degree[to]==0) {
                    in_degree[to]--;
                    q.push({d[to],to});
                }
        }
    }
    //for(ll i =0;i<=n;i++) {
   //     cout<<in_degree[i]<<" "<<d[i]<<endl;
   // }
    return mx-1;
}
int main()
{
 //freopen("input.txt","r",stdin);
 //  freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin>>n>>m;
    for(ll i =1;i<=m;i++) {
        ll u,v;
        cin>>u>>v;
        g[u].push_back(v);
        use[v]=1;
        ++in_degree[v];
    }
    in_degree[0]=-1;
    for(ll i =1;i<=n;i++) {
        if(!use[i]) {g[0].push_back(i);  in_degree[i]++;}
    }
  //  cout<<endl;
    cout<<bfs();

}


Measured memory_bytes: 10872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    ll x,y,tmp,ans = 0;
    cin >> x >> y;
    tmp = x;
    while(tmp <= y){
        tmp *= 2;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sz(a) ((int) (a).size())
#define nl '\n'
#define sp ' '

int A, B;

int main() {
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> A >> B;
    if (A <= 8 && B <= 8) cout << "Yay!" << nl;
    else cout << ":(" << nl;
    return 0;
}


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

using namespace std;

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


    int k;
    cin >> k;
    int a, b;
    cin >> a >> b;

    if (a / k != b / k || a % k == 0 || b % k == 0) cout << "OK"; else cout << "NG";
    return 0;
}


Measured memory_bytes: 3636
N,M = map(int, input().split())
listA = list(map(int, input().split()))
listA.sort()
 
listBC = [list(map(int, input().split())) for i in range(M)]
listBC = sorted(listBC, key=lambda x: x[1], reverse=True)
countB = 0
 
for i in range(M):
  B, C = listBC[i][0], listBC[i][1]
  listA += [C]*B
  countB += B
  if countB >= N:
    break

listA.sort(reverse=True)
print(sum(listA[:N]))

Measured memory_bytes: 35648
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

ll a[100000];

int main()
{
	int n;
	int ans=0;
	
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);

	int i=0;
	while(i<n)
	{
		int t=a[i];
		int cnt=1;
		i++;
		while(t==a[i])
		{
			cnt++;
			i++;
		}
		if(cnt%2!=0)
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <stdlib.h>
int N;
int  h[100001];
int  dp[100001];
int  INF = INT_MAX;

int 
chmin(int  *a, int b) 
{
	 if (*a > b){
		 *a = b; //	printf("%ld\n",*a);
		 return 1; 
	 }
	 return 0;
}


int 
main(){
	int i;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&h[i]);
		dp[i]=INF;
	}
	
	dp[0]=0;
	
	#if 1
	for(i=0;i<N;++i){
        chmin(&dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        chmin(&dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }
    #else
    for (i = 1; i < N; i++) {
        chmin(&dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(&dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    #endif
	
	//for(i=0;i<N;i++){
		printf("%d\n",dp[N-1]);
	
	//}
	
 return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	int n,m;
	cin>>n>>m;
	int arr[n];
	float tot = 0;
	for (int i = 0; i<n; i++){
		cin>>arr[i];
		tot+=arr[i];
	}
	tot/=(4*m);
	sort(arr, arr+n, greater<int>());
	for (int i = 0; i<n; i++){
		if (arr[i] < tot){
			if (i >= m){
				cout<<"Yes";
				return 0;
			}
			else{
				cout<<"No";
				return 0;
			}
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 3604
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def Z_algorithm(s):
        n = len(s)
        z = [0]*n
        z[0] = n
        c = 1
        for i in range(1,n):
            if i+z[i-c] < c+z[c]:
                z[i] = z[i-c]
            else:
                j = max(0,c+z[c]-i)
                while i+j < n and s[j] == s[i+j]:
                    j += 1
                z[i] = j
                c = i
        return z
    n = I()
    s = input()
    ans = 0
    for i in range(n):
        z = Z_algorithm(s[i:])
        for j in range(n-i):
                ans = max(ans,min(j,z[j]))
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 49116
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif
#define FILE_IO freopen("input.txt","r",stdin)
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
int digsum(int n){
	if(n==0)return 0;
	return (n%10 + digsum(n/10));
}
void solve(){
    int n;
    cin>>n;
    if(n%10==0){cout<<10;return;}
    int mx=INT_MAX;
    for(int i=1;i<=n;i++){
      int x=n-i;
      mx=min(mx,digsum(x)+digsum(i));
    }
    cout<<mx<<endl;
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
    IOS;
    solve();
    #ifdef LOCAL_DEFINE
    cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
    #endif
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

ll fac[N];

ll power(ll x,ll n)
{
    if(n==0){return 1;}
    if(n==1){return x;}
    if(n%2==0){
        return power((x*x)%M,n/2);
    }
    if(n%2==1){
        return (power((x*x)%M,n/2)*x)%M;
    }
}

ll f(ll n,ll r)
{
    ll num=fac[n];
    ll denum=(fac[r]*fac[n-r])%M;
    ll ans=(num*power(denum,M-2))%M;
    return ans;
}

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

    fac[0]=1;
    for(ll i=1;i<N;++i){
        fac[i]=(i*fac[i-1])%M;
    }

    ll n,m;
    cin>>n>>m;
    ll ans=1;

    for(ll i=2;i*i<=m;++i){
        if(m%i==0)
        {
            ll count=0;
            while(m%i==0){
                ++count;
                m=m/i;
            }
            ans=(ans*f(count+n-1,n-1))%M;
        }
    }
    if(m!=1)
    {
        ans=(ans*f(n,n-1))%M;
    }
    cout<<ans;

    return (0);
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
ll h;
int main()
{
    cin>>h;
	ll ans=0;
	int tot=1;
	while(h>=1){
		ans+=pow(2,tot-1);
		h=h/2;
		tot++;
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
#define drep(i, a, b) for(int i = (a), i##_end_ = (b); i >= i##_end_; --i)
#define clear(a, b) memset((a), (b), sizeof(a))
typedef long long LL;
int read(){
	int x = 0, flag = 1;
	char ch = getchar();
	while(!isdigit(ch)) {
		if(ch == '-') flag = -1;
		ch = getchar();
	}
	while(isdigit(ch)) {
		x = (x << 3) + (x << 1) + (ch - 48);
		ch = getchar();
	}
	return x * flag;
}

#define Maxn 100009
int n, a[Maxn], cnt;
int main(){
	n = read();
	rep(i, 1, n) a[i] = read(), cnt += a[i] & 1;
	if(cnt & 1) puts("NO");
	else puts("YES");
	return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;


int N;
vector<int> X;


int main() {
    scanf("%d", &N);
    for(int i = 0; i < N; i++) {
        int x;
        scanf("%d", &x);
        X.push_back(x);
    }

    vector<int> Y = X;
    sort(Y.begin(), Y.end());
    int median1 = Y[Y.size()/2 - 1];
    int median2 = Y[Y.size()/2];

    for(int i = 0; i < N; i++) {
        int median;
        if(X[i] < median1) {
            median = median2;
        }
        else if(X[i] > median2) {
            median = median1;
        }
        else if(X[i] == median1) {
            median = median2;
        }
        else if(X[i] == median2) {
            median = median1;
        }
        printf("%d\n", median);
    }

    return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n; cin>>n;
    vector<int> a(n),b(n);
    rep(i,n) cin>>a[i]>>b[i];
    sort(btoe(a)); sort(btoe(b));
    if(n%2==0){
        int l=a[n/2]+a[n/2-1],r=b[n/2]+b[n/2-1];
        cout<<r-l+1<<endl;
    } 
    else{
        int l=a[(n-1)/2], r=b[(n-1)/2];
        cout<<r-l+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int h,w,m;
	int ans=0;
	cin >>h>>w>>m;
	Pi data;
	VPi tri;
	map<int,int> X, Y;
	vector<int> x, y;
	int ux = 0, uy = 0;
	rep(i, m) { cin >> data;
		tri.pb(data);
		X[data.F]++;
		Y[data.S]++;
	}
	tri.eb(INF, INF);
	sort(all(tri));
	repi(itr,X){
		if(ux<itr->S){
			ux = itr->S;
			x.clear();
		}
		if(ux==itr->S){
			x.pb(itr->F);
		}
	}
	repi(itr, Y) {
		if (uy < itr->S) {
			uy = itr->S;
			y.clear();
		}
		if (uy == itr->S) {
			y.pb(itr->F);
		}
	}
//	clog << ux <<" "<< uy << endl;
	ans = ux + uy - 1;
	rep(i,x.size()){
		rep(j, y.size()) { if (*lower_bound(all(tri),mp(x[i],y[j]))!=mp(x[i],y[j])){
				ans++;
				cout << ans << endl;
				return 0;
		} }
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 38180
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vector <int> X(N);
    loop(i,0,N) cin >> X[i];
    long double ans=0;
    loop(i,0,N)
    ans += (long double)1/X[i];
    ans=1/ans;
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

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

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

const int MAX_N = 100;
vector<int> r(MAX_N);
vector<int> c(MAX_N);
//DP????????????
//DP[i,j]???i????????????j????????????????????????????????£?????¨??????????°????????????°
vector<vector<int> > DP(MAX_N, vector<int>(MAX_N,-1));

int dev(int k, int l){
	//?¨????????????????????????´???
	if(DP[k][l]<0){
		int mini=INT_MAX;
		if(k==l){
			mini=0;
		}
		FOR(i,0,l-k){
			int left = dev(k,k+i);
			int right = dev(k+i+1,l);
			mini=min(mini, left + right + r[k]*c[k+i]*c[l]);
		}
		DP[k][l]=mini;
	}
	return DP[k][l];	
}

int main(){
	int n;
	cin>>n;
	REP(i,n){
		cin>>r[i]>>c[i];
	}
	int res = dev(0,n-1);
	/*
	REP(i,n){
		REP(j,n){
			cout<<"["<<i<<"]["<<j<<"] "<<DP[i][j]<<endl;
		}
	}*/
	cout<<res<<endl;
	return 0;
}

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

if N==1 or M==1:
    print(X)
    exit()

F=(N-1).bit_length()

A=[[0]*M for _ in range(F)]

for x in range(M):
    A[0][x]=(x*x)%M

for d in range(1,F):
    for x in range(M):
        A[d][x]=A[d-1][A[d-1][x]]

S=[[0]*M for _ in range(F)]
for x in range(M):
    S[0][x]=A[0][x]

for d in range(1,F):
    for x in range(M):
        S[d][x]=S[d-1][x]+S[d-1][A[d-1][x]]

Ans=0
depth=0
N-=1
Y=X
while N>0:
    if N%2:
        Ans+=S[depth][X]
        X=A[depth][X]
    depth+=1
    N>>=1
print(Ans+Y)

Measured memory_bytes: 121092
row1 = list(map(int, input().split(" ")))
row2 = list(map(int, input().split(" ")))
row3 = list(map(int, input().split(" ")))
col1 = [row1[0]] + [row2[0]] + [row3[0]] 
col2 = [row1[1]] + [row2[1]] + [row3[1]] 
col3 = [row1[2]] + [row2[2]] + [row3[2]]
cr_r = [row1[0]] + [row2[1]] + [row3[2]]
cr_l = [row1[2]] + [row2[1]] + [row3[0]]

n = int(input())
for _ in range(n):
  b = int(input())
  if b in row1:
    row1 = [n for n in row1 if n != b]
  if b in row2:
    row2 = [n for n in row2 if n != b]
  if b in row3:
    row3 = [n for n in row3 if n != b]

  if b in col1:
    col1 = [n for n in col1 if n != b]
  if b in col2:
    col2 = [n for n in col2 if n != b]
  if b in col3:
    col3 = [n for n in col3 if n != b]

  if b in cr_r:
    cr_r = [n for n in cr_r if n != b]
  if b in cr_l:
    cr_l = [n for n in cr_l if n != b]

if not row1 or not row2 or not row3 or not col1 or not col2 or not col3 or not cr_r or not cr_l:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3188
from bisect import bisect_right, bisect_left
from itertools import groupby, permutations, combinations
from fractions import gcd
import numpy as np
from sys import stdin, stderr


def lcm(x, y):
    return (x * y) // gcd(x, y)


def main():
    N = int(input())
    a = [int(x) for x in input().split()]
    cnt = 1
    ret = 0
    for i in range(N):
        if a[i] == cnt:
            cnt += 1
        else:
            ret += 1
    if ret == N:
        ret = -1
    return ret


if __name__ == "__main__":
    print(main())

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

using namespace std;
#define ll long long
int n,m;
int a,b;

int vis[55];
int p[55][55];
int es[55];
int ee[55];
void dfs(int start)
{
    for(int i = 1;i<=n;i++)
    {
        if((vis[i]!=1)&&(p[start][i]==1))
        {
            vis[i]=1;
            dfs(i);
        }
    }
    return ;
}
int sp(int x)
{
    int cnt = 0;
    memset(vis,0,sizeof(vis));
    p[es[x]][ee[x]]=0;
    p[ee[x]][es[x]]=0;
    for(int i = 1;i<=n;i++)
    {
        if(!vis[i])
        {
            dfs(i);
            cnt++;
            if(cnt!=1)
            {
                break;
            }
        }
    }
    p[es[x]][ee[x]]=1;
    p[ee[x]][es[x]]=1;
    if(cnt!=1)return 1;
    else return 0;
}
int main()
{

    int ans = 0;
    cin>>n>>m;
    memset(vis,0,sizeof vis);
    for(int i = 1;i<=m;i++)
    {
        cin>>a>>b;
        p[a][b]=1;
        p[b][a]=1;
        es[i]=a;
        ee[i]=b;
    }
    for(int i = 1;i<=m;i++)
    {
        if(sp(i))
        {
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <cassert>
// using namespace std;
// #define int long long
#define REP(i,s,n) for (int i = (s); i < (n); ++i)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) for (int i = n; i >= 0; i--)
#define INF (int)(1e9+7)
#define space " "
#define ENDL "\n"
#define MAXL 100

int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};

inline void init() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
}
// ??¢?????¬??????????????????????????????????????????!!
inline void nextInt(int *a) { scanf("%d", a); }
inline void nextInt(int *a, int *b) { scanf("%d %d", a, b); }
inline void nextInt(int *a, int *b, int *c) { scanf("%d %d %d", a, b, c); }
inline void nextDouble(double *a) { scanf("%lf", a); }
inline void nextDouble(double *a, double *b) { scanf("%lf %lf", a, b); }
inline void nextDouble(double *a, double *b, double *c) { scanf("%lf %lf %lf", a, b, c); }
inline void nextLine(char *c) { scanf("%s", c); getchar();/*?????????????????¨???*/ }
inline std::string nextLine() {
    std::string s = ""; char str[MAXL+1];
    scanf("%s", str); getchar(); /*?????????????????¨???*/
    return s += str;
}
inline void print(double *a, int n = 0) {
    std::cout << std::fixed << std::setprecision(n) << *a << ENDL;
}
inline void print(int a) {
    printf("%d\n", a);
}

/************************End of template*************************/

int main() {
    std::string s;
    bool flag = true;
    std::stack<char> st, ini;

    init();

    while (true) {
        s = "";
        st = ini;
        flag = true;
        std::getline(std::cin, s);
        //std::cout << "[" << s << "]" << ENDL;
        if (s[0] == '.') break;

        rep(i,s.size()) {
            if (s[i] == '(' || s[i] == '[') {
                st.push(s[i]);
            } else if (s[i] == ')') {
                if (st.empty()) {
                    flag = false;
                    break;
                } else if (st.top() == '(') {
                    st.pop();
                } else {
                    flag = false;
                    break;
                }
            } else if (s[i] == ']') {
                if (st.empty()) {
                    flag = false;
                    break;
                } else if (st.top() == '[') {
                    st.pop();
                } else {
                    flag = false;
                    break;
                }
            }
        }
        if (!st.empty()) flag = false;
        if (flag) std::cout << "yes" << ENDL;
        else std::cout << "no" << ENDL;
    }

    return 0;
}

Measured memory_bytes: 3160
// Optimise
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// #define MULTI_TEST
#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#define pc(...)
#endif

#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
auto TimeStart = chrono::steady_clock::now();
auto seed = TimeStart.time_since_epoch().count();
std::mt19937 rng(seed);
using ll = long long;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using Random = std::uniform_int_distribution<T>;

const int NAX = 2e3 + 5, MOD = 1000000007;

vector<int> adj[NAX];
int dist[NAX][NAX];
int ans[NAX + 10];
class Solution
{
private:
public:
    Solution() {}
    ~Solution() {}
    void solveCase()
    {
        int n, x, y;
        cin >> n >> x >> y;
        for (size_t i = 0; i < n; i++)
        {
            for (size_t j = 0; j < n; j++)
            {
                dist[i][j] = NAX;
            }
        }
        for (size_t i = 0; i < n; i++)
            dist[i][i] = 0;
        for (size_t i = 0; (i + 1) < n; i++)
        {
            adj[i].pb(i + 1);
            adj[i + 1].pb(i);
        }
        adj[x - 1].pb(y - 1);
        adj[y - 1].pb(x - 1);
        int V = n;
        for (int k = 0; k < V; k++)
        {
            queue<int> Q;
            Q.push(k);
            while (!Q.empty())
            {
                auto top = Q.front();
                Q.pop();
                for (auto &chil : adj[top])
                {
                    if (dist[k][chil] == NAX)
                    {
                        dist[k][chil] = dist[k][top] + 1;
                        Q.push(chil);
                    }
                }
            }
        }
        for (size_t i = 0; i < n; i++)
            for (size_t j = i + 1; j < n; j++)
                ans[dist[i][j]]++;
        for (size_t i = 1; i < n; i++)
            cout << ans[i] << '\n';
    }
};

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
#ifdef MULTI_TEST
    cin >> t;
#endif
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef TIME
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}

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

int dup[1000005];
bool box[1000005];

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
  int n;cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++){cin>>v[i];dup[v[i]]++;}
  sort(v.begin(), v.end());
  if(n==1){cout<<1<<endl;return 0;}
  if(v[0]==1&&v[1]==1){cout<<0<<endl;return 0;}
  if(v[0]==1){cout<<1<<endl;return 0;}
  int ans=0;
  for(int i=0;i<n;i++){
    auto t = v[i];
    if(box[t])continue;
    for(int j=t;j<=1000000;j+=t){
      box[j]=1;
    }
    if(dup[v[i]]<=1)ans++;
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 8972
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")

#include <iostream>
#include <string>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <queue>
#define PII pair<int, int>
#define T3I tuple<int, int, int>
#define STA(a, b) min(a, b), max(a, b)
using namespace std;

typedef long long ll;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;

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

    ll a, b, c;
    cin >> a >> b >> c;
    ll d = c-a-b;
    if(d <= 0) {
        cout << "No" << endl;
    }else {
        if(d*d > 4*a*b) {
            cout << "Yes" << endl;
        }else {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 256