akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define pr1(x) cout<<"[" << #x << ": " << x << "] \n";
#define pr2(x, y) cout<<"[" << #x << ": " << x <<", "<< #y << ": " << y <<"] \n";
#define mod 1000000007
#define int long long
#define sz(v) (int)(v).size()

void solve() {
        int n, m; cin >> n>> m;
        int an= 0;
        lp(i, n) {
                int a, b; cin >> a>> b;
                if (a* a+ b* b<= m* m) {
                        an++;
                }
        }
        cout << an<< "\n";
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while ( t-- ) {
                solve();
        }
return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) cin >> c[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  ll res = 0;
  for (int i = 0; i < n; i++) {
    ll x = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
    ll y = n - (upper_bound(c.begin(), c.end(), b[i]) - c.begin());
    res += x * y;
  }
  cout << res << endl;
}


Measured memory_bytes: 1408
def main():
    n = int(input())
    a = list(map(int, input().split()))
    ma = max(a)
    ma2 = ma/2
    a.remove(ma)
    ans = 0
    diff = 10**10
    for i in a:
        if diff > abs(ma2-i):
            ans = i
            diff = abs(ma2-i)
    print(ma, ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 62704
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>
#include<map>
#include<iterator>
#include<set>
#include<stack>
#include<queue>
#include<fstream>
#include<iomanip>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include<cmath>
#include<list>
#include <sstream>
#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define rep0(i, n) for(int i = (0); i < (n); i++)
#define repd(i,m,n) for(int i=(m); i > (n); i--)
#define ll long long
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plli pair<pll,int>
#define mp make_pair
#define endl '\n'
#define pb push_back
//#define x first
//#define y second
#define pt pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpt vector<pt>
#define vb vector<bool>
#define vvb vector<vb>
#define pdd pair<long double, long double>
#define vpll vector<pll>
#define vpdd vector<pair<long double, long double> >
#define pq priority_queue
#define M_PI 3.14159265358979323846
using namespace std;


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

	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	
	int n;
	cin >> n;
	vi arr(n);
	rep(i, 0, n) {
		cin >> arr[i];
	}
	vi b(n);


	int fi = 0, li = n - 1;
	int ind = n-1;
	int parity = n % 2;
	while (fi <= li) {
		if (ind % 2 == parity) {
			b[li--] = arr[ind--];
		}
		else {
			b[fi++] = arr[ind--];
		}
	}

	rep(i, 0, n) {
		cout << b[i] << " ";
	}
	return 0;
}

Measured memory_bytes: 3712
n, k = gets.split.map(&:to_i)
r, s, p = gets.split.map(&:to_i)
t = gets

def calcpoint(sel, r, p, s)
  res = 0
  sel.each_char do |char|
    case char
    when "r" then
      res += r
    when "p" then
      res += p
    when "s" then
      res += s
    end
  end
  res
end

res = t.gsub(/r|p|s/, "r" => "p", "p" => "s", "s" => "r")
#2以下の場合分け
(k..n-1).each do |i|
  #puts i
  if res[i] == res[i-k]
    res[i] = "x"
  end
end
#puts res
puts calcpoint(res, r, p, s)



Measured memory_bytes: 2044
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum, ans, dp[10000][2], a[2000000],b[2000000];
string str, ss,dd;
bool f[2000000],ff;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { LL to, cost; };
vector<Edge>vec[10000];
vector<LL>v;
map<string, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		b[a[i]] = i;
	}
	rep(i, n) {
		LL nex = i+1;
		cnt = 0;
		while (b[nex + 1] > b[nex] && i + 1 <= n&&f[nex] == 0) {
			cnt++;
			f[nex] = 1;
			nex++;
		}
		ans = max(ans, cnt);
	}
	cout << n - ans -1<< endl;
	return 0;
}

Measured memory_bytes: 6784
# -*- coding: utf-8 -*-
target_array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = int(input())
print(target_array[K-1])


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

int main()
{
    int n , m , a , b , cnt[60] ;

    memset(cnt , 0 , sizeof cnt) ;

    scanf("%d %d" , &n , &m) ;

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

    for(int i = 1 ; i <= n ; i++){
        printf("%d\n" , cnt[i]) ;
    }

    return 0 ;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

	public static void main (String[] args) {

		Main main = new Main ();
		main.solve();
	}

	private void solve() {

		Scanner sc = new Scanner (System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int k = sc.nextInt();

		if (b-a>k||
			 c-a>k||
			 d-a>k||
			 e-a>k||
			 c-b>k||
			 d-b>k||
			 e-b>k||
			 d-c>k||
			 e-c>k||
			 e-d>k
			) {
			System.out.println(":(");
		} else {
			System.out.println("Yay!");
		}
	}
}

Measured memory_bytes: 21844
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((n (read))
         (k (read))
         (s (make-array n :element-type 'bit))
         (cumul (make-array (1+ n) :fill-pointer 0 :element-type 'uint32)))
    (declare (uint31 n k))
    (dotimes (i n)
      (setf (aref s i) (- (read-byte *standard-input*) 48)))
    (vector-push 0 cumul)
    (loop with base = 0
          with base-bit = (aref s 0)
          for i below n
          unless (= base-bit (aref s i))
          do (vector-push (- i base) cumul)
             (setf base i
                   base-bit (aref s i))
          finally (vector-push (- i base) cumul))
    (dotimes (i n)
      (incf (aref cumul (1+ i)) (aref cumul i)))
    (println
     (loop for l below (length cumul)
           for width = (if (zerop (aref s 0))
                           (if (evenp l)
                               (* 2 k)
                               (+ (* 2 k) 1))
                           (if (evenp l)
                               (+ (* 2 k) 1)
                               (* 2 k)))
           for r = (min n (+ l width))
           maximize (- (aref cumul r) (aref cumul l))))))

#-swank(main)


Measured memory_bytes: 22120
n=int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
M=0
for i in range(n):
    if a[i] >= b[i]:
        M+=b[i]
    else:
        a[i+1]-=b[i]-a[i]
        if a[i+1] < 0:
            c=abs(a[i+1])
            a[i+1]=0
            M+=b[i]-c
        else:
            M+=b[i]
print(M)



Measured memory_bytes: 19116
N=int(input())
table=[True for _ in range(N+1)]
table[0]=False
table[1]=False
for i in range(2,N+1):
    if table[i]==False:
        continue
    for j in range(2,N//i):
        table[i*j]=False
p=[]
for i in range(N+1):
    if table[i]:
        p.append(i)

n=len(p)
cnt=[0 for _ in range(n)]
for i in range(2,N+1):
    x=i
    j=0
    while x>1:
        while x%p[j]==0:
            cnt[j]+=1
            x//=p[j]
        j+=1
ans=1
MOD=1000000007
for i in range(n):
    ans*=cnt[i]+1
    ans%=MOD
print(ans)


Measured memory_bytes: 9220
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		while (in.hasNext()) {
			int lenH = in.nextInt();
			int lenW = in.nextInt();

			if (lenH == 0) {
				break;
			}
			
			String line = repeat('#', lenW);
			for (int i = 0; i < lenH; i++) {
				sb.append(line).append("\n");
			}
			
			sb.append("\n");
		}
		System.out.print(sb.toString());
	}

	private static String repeat(char c, int len) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < len; i++) {
			sb.append(c);
		}
		return sb.toString();
	}
}

Measured memory_bytes: 17204
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
#define inf 0x3f3f3f3f
#define endl '\n'
// #define case(i) "Case #" << i << ": "
 
int n, k;
vector<int> v;
int dp[100001];
 
int solve(int i) {
    if(i == 0) return 0;
    else {
        if(dp[i] != -1) return dp[i];
        int mn = inf;
        for(int j = 1; j <= k && i - j >= 0; ++j) {
            mn = min(mn, abs(v[i] - v[i-j]) + solve(i-j));
        }
        dp[i] = mn;
        return mn;
    }
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
 
    memset(dp, -1, sizeof(dp));
 
    cin >> n >> k;
    v.resize(n);
 
    for(int i = 0; i < n; ++i) cin >> v[i];
 
    cout << solve(n-1) << endl;
}

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


bool linearSearch(int A[], int N, int x) {
    A[N] = x;
    int i = 0;
    while (A[i] != x) i++;
    if (i == N) return false;
    return true;
}

int main() {
    int n, q, m=0;
    int S[10010], T[510];
    cin >> n;
    for (int i=0; i < n; i++) scanf("%d", &S[i]);
    cin >> q;
    for (int i=0; i < q; i++) scanf("%d", &T[i]);
    
    for (int i=0; i < q; i++) {
        if (linearSearch(S, n, T[i])) m++;
    }

    cout << m << endl;
    return 0;
} 


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

int main(void)
{
    int n,k,x[100000],i,j,length,posi=-1,turn,end,sarae,ans;

    scanf("%d %d",&n,&k);
    for ( i = 0; i < n; i++)
    {
        scanf("%d",x+i);
    }

    ans=3*((abs(x[0])>abs(x[n-1]))? abs(x[0]):abs(x[n-1]));

    for ( i = 0; i < n; i++)
    {
        if(x[i]==0)
        {
            for ( j = i; j <= n-2; j++)
            {
                x[j]=x[j+1];
            }
            k--;
            n--;
            break;
        }
    }

    if (k==0)
    {
        printf("%d",0);
        return 0;
    }

    for ( i = 0; i < n; i++)
    {
        if (x[i]>=0)
        {
            posi=i;
            break;
        }
    }

    if(posi==-1)
    {
        printf("%d",-x[n-k]);
        return 0;
    }

    for ( turn = 0; turn < n; turn++)
    {
        if(x[turn]<0)
        {
            sarae=posi-turn;
            if(sarae<k) end=turn+k-1;
            else if(sarae==k) end=turn;
            else continue;
        }
        else if (x[turn]>0)
        {
            sarae=turn-posi+1;
            if(sarae<k) end=turn-k+1;
            else if(sarae==k) end=turn;
            else continue;
        }
        if(end<0||n-1<end) continue;
        length=abs(x[turn])+abs(x[end]-x[turn]);
        if(ans>length) ans=length;
    }

    printf("%d",ans);

    return 0;
}

Measured memory_bytes: 512
def main():

    from bisect import bisect_left as bl, bisect_right as br, insort
    import sys,heapq,math
    from collections import defaultdict as dd, deque
    def data(): return sys.stdin.readline().strip()
    def mdata(): return list(map(int, data().split()))
    out = sys.stdout.write
    # sys.setrecursionlimit(100000)
    INF = int(1e9)
    mod = int(1e9)+7

    k=int(data())
    a,b=mdata()
    if k*(b//k)>=a:
        print('OK')
    else:
        print("NG")



if __name__ == '__main__':
    main()


Measured memory_bytes: 65276
s=str(input())
st=list(s)
l=len(st)
if st[0]=="k" and st[1]=="e" and st[2]=="y" and st[3]=="e" and st[4]=="n" and st[5]=="c" and st[6]=="e":
  print("YES")
elif st[l-7]=="k" and st[l-6]=="e" and st[l-5]=="y" and st[l-4]=="e" and st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]=="k" and st[l-6]=="e" and st[l-5]=="y" and st[l-4]=="e" and st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]=="k" and st[1]=="e" and st[l-5]=="y" and st[l-4]=="e" and st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]=="k" and st[1]=="e" and st[2]=="y" and st[l-4]=="e" and st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]=="k" and st[1]=="e" and st[2]=="y" and st[3]=="e" and st[l-3]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]=="k" and st[1]=="e" and st[2]=="y" and st[3]=="e" and st[4]=="n" and st[l-2]=="c" and st[l-1]=="e":
  print("YES")
elif st[0]=="k" and st[1]=="e" and st[2]=="y" and st[3]=="e" and st[4]=="n" and st[5]=="c" and st[l-1]=="e":
  print("YES")
else:
  print("NO")

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

int main(){
	string S, T;
	char last;
	cin >> S >> T;
	int num = S.size();
	for(int i = 0; i < num; i++)
	{
		last = S.back();
		S.pop_back();
		S.insert(S.begin(), last);
		if(S == T){
			cout << "Yes" << endl;
			return 0;
		}		
	}
	cout << "No" << endl;
	return 0;

}



Measured memory_bytes: 256
LI = lambda: list(map(int, input().split()))

N = int(input())
A = LI()


def main():
    ans = 0
    for i in range(1, N):
        if A[i] < A[i - 1]:
            ans += A[i - 1] - A[i]
            A[i] = A[i - 1]
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n;
  ll a[100];
  cin>>n;
  REP(i, n){
    cin>>a[i];
  }
  ll mo=1000, cnt=1000/a[0], cur=1000-cnt*a[0], price=a[0];
  FOR(i, 1, n){
    if(a[i]>price){
      mo=cur+cnt*a[i];
    }
    cnt=mo/a[i];
    cur=mo-a[i]*cnt;
    price=a[i];
  }
  cout<<mo<<'\n';
  return 0;
}


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

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| min!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| max!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


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

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    put!(sc.cin::<String>().chars().map(|c| if c=='1' { "9" } else { "1" }).collect::<Vec<_>>().join(""));
}

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

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


Measured memory_bytes: 4352
MOD = 1000000007
FACT = []
INV = []

def conv(s,t)
  (FACT[s] * INV[s-t] % MOD) * INV[t] % MOD
end

def calc_fact(n)
  FACT[0] = 1
  INV[0] = pow(FACT[0], MOD-2)
  for i in 1..n
    FACT[i] = FACT[i-1] * i % MOD
    INV[i] = pow(FACT[i], MOD-2)
  end
end

def pow(x,n)
  if n == 0
    1
  elsif n % 2 == 0
    pow(x*x%MOD, n/2) % MOD
  else
    x * pow(x, n-1) % MOD
  end
end

h, w, a, b = gets.chomp.split(' ').map{|x| x.to_i}
calc_fact(h+w-2)

ans = 0
for i in 1..(h-a)
  ans = (ans + (conv(i+b-2, i-1) * conv(h+w-b-i-1, w-b-1))) % MOD
end

print (ans)

Measured memory_bytes: 5104
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

template<typename T> vector<T> part(const vector<T> & v) {
	auto w = v;
	sort(ALL(w));
	
	vector<pair<int, T>> a;
	inc(i, SI(w)) {
		if(i == 0 || w[i] != w[i - 1]) { a.EB(1, w[i]); } else { a.back().FI++; }
	}
	sort(RALL(a));
	
	w.clear();
	inc(i, SI(a)) {
	inc(j, a[i].FI) {
		w.PB(a[i].SE);
	}
	}
	assert(SI(w) == SI(v));
	
	vector<T> x;
	if(SI(a) == 0 || a[0].FI > ce(SI(v), 2)) { return x; }
	
	inc(i, SI(w)) { x.PB(w[fl(i, 2) + (i % 2) * ce(SI(w), 2)]);  }
	return x;
}

#define FD(v, x) distance(v.begin(), find(ALL(v), x))

int n, k, a[50];
vector<int> b[51];

int main() {
	cin >> n >> k;
	inc(i, n) { cin >> a[i]; }
	
	vector<int> v;
	int s = 0;
	inc(i, n) {
		int c = k + 1 - a[i];
		setmax(s, c);
		inc(j, c) { v.PB(i); }
	}
	
	if(SI(v) > k || s > ce(k, 2)) {
		cout << -1 << endl;
	} else {
		inc(i, n) {
			while(SI(v) < k && count(ALL(v), i) < ce(k, 2)) { v.PB(i); }
		}
		assert(SI(v) == k);
		
		auto w = part(v);
		
		inc(i, k + 1) {
		inc(j, n) {
			b[i].PB(j);
		}
		}
		
		inc(i, k) {
			swap(b[i + 0][ FD(b[i + 0], w[i]) ], b[i + 0][n - 1]);
			swap(b[i + 1][ FD(b[i + 1], w[i]) ], b[i + 1][    0]);
		}
		
		vector<int> ans;
		inc(i, k + 1) {
		inc(j, n) {
			if(i > 0 && j == 0) { continue; }
			ans.PB(b[i][j]);
		}
		}
		
		cout << SI(ans) << endl;
		inc(i, SI(ans)) { cout << (i == 0 ? "" : " ") << ans[i] + 1; }
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
def is_stairs(h):
    
    if len(h) == 1:
        return('Yes')
    for i in range(1, len(h)):
        if h[i-1] - h[i] > 0:
            return('No')
        h[i] = max(h[i-1],h[i]-1)
        #print(h)
    return('Yes')
print(is_stairs(h))

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------
const int INF = 1e9+1000;
ll n, a, b;
ll h[111111];

int main() {
   cin >> n >> a >> b;
   rep (i, n) cin >> h[i];

   int c = a - b;
   int left = 0, right = INF;
   while (left+1<right) {
      ll mid = (left+right)/2;
      ll cnt = 0;
      rep (i, n) {
         ll t = max(h[i] - mid * b, 0LL);
         cnt += (t+c-1) / c;
      }
      if (cnt <= mid) right = mid;
      else left = mid;
   }
   cout << right << endl;

   return 0;
}

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

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

int main(){
    int N;
    string S,T;
    cin >> N >> S >> T;
    Rep(i,N){
        cout << S[i] << T[i];
    }
    //cin >> N;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <functional>

#define big ((long long)(1e9) + 7)

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define DBG(x) cerr << #x << ": " << (x) << " (L" << __LINE__ << ")" << endl;

int main()
{
   int h_1,m_1,h_2,m_2,k;
   cin >> h_1 >> m_1 >> h_2 >> m_2 >> k;
   int h,m;

   if(m_1 > m_2)
   {
       m = m_2-m_1;
       m = 60+m;
       h = h_2-h_1-1;
   }
   else {
       h = h_2-h_1;
       m = m_2-m_1;
   }
   int ans = h*60+m;
   if(k <= ans){
       cout << ans-k << endl;
   }
   else{
       cout << 0 << endl;
   }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int h,w,n;
	cin >> h >> w >> n;
	cout << min((n + h - 1) / h,(n + w - 1) / w) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> v(m);
    for (int i = 0; i < m; ++i) {
        scanf("%d %d", &v[i].first, &v[i].second);
    }
    sort(v.begin(),v.end());
    vector<pair<int, int>> dp(n);
    for (int i = 0; i < n; ++i) {
        dp[i] = {i, i+1};
    }
    for (int i = 0; i < m; ++i) {
        int x = v[i].second;
        pair<int, int> a {
            min(dp[x].first, dp[x-1].first), max(dp[x-1].second, dp[x].second)
        };
        dp[x] = dp[x-1] = a;
    }
    for (int i = 0; i < n; ++i) {
        if(i) printf(" ");
        printf("%d", dp[i].second-dp[i].first);
    }
    puts("");
    return 0;
}


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

const int z = 80 * 80 * 2;
 
bool dp[81][81][z];
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
 
	int n, m;
	cin >> n >> m;
	
	vector<vector<int>> v(n, vector<int>(m));
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			cin >> v[i][j];
		}
	}
 
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			int a;
			cin >> a;
			v[i][j] = abs(a - v[i][j]);
		}
	}
 
	dp[0][0][v[0][0]] = true;
	for(int i = 1; i < m; i++) {
		for(int j = 0; j < z; j++) {
			int a = v[0][i];
			dp[0][i][j] = dp[0][i-1][abs(j-a)] | dp[0][i-1][j+a];
		}
	}
 
	for(int i = 1; i < n; i++) {
		for(int j = 0; j < z; j++) {
			int a = v[i][0];
			dp[i][0][j] = dp[i-1][0][abs(j-a)] | dp[i-1][0][j+a];
		}
	}
 
	for(int i = 1; i < n; i++) {
		for(int j = 1; j < m; j++) {
			int a = v[i][j];
			for(int k = 0; k < z; k++) {
				dp[i][j][k] = dp[i-1][j][abs(k-a)] | dp[i-1][j][k+a] | dp[i][j-1][abs(k-a)] | dp[i][j-1][k+a];
			}
		}	
	}
 
	for(int i = 0; i < z; i++) {
		if(dp[n-1][m-1][i]) {
			cout << i << '\n';
			break;
		}
	}
 
	return 0;
}

Measured memory_bytes: 82176
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String s = saori.nextHayami();
		boolean ans = false;
		for(int i = 0;i <= s.length();i++){
			for(int j = i;j <= s.length();j++){
				String s1 = s.substring(0, i);
				String s2 = s.substring(j, s.length());
				if((s1+s2).equals("keyence")){
					ans = true;
					break;
				}
			}
		}
		if(ans){
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 38176
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    cout << fixed << setprecision(10);
    
    int N, W; cin >> N >> W;
    vector<P> wv(N);
    rep(i, N) {
        ll w, v;
        cin >> w >> v;
        wv[i] = make_pair(w, v);
    }

    vector<vector<ll>> dp(N+1, vector<ll>(W+1, 0));

    rep(i, N) {
        rep(j, W+1) {
            ll w, v;
            w = wv[i].first;
            v = wv[i].second;
            if (j-w >= 0) {
                dp[i+1][j] = max(dp[i][j], dp[i][j-w] + v);
            } else {
                dp[i+1][j] = dp[i][j];
            }
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 80256
#include <stdio.h>

char s[10];

int main(void)
{
    scanf("%s", s);

    if (s[0] == 'S') {
        printf("Cloudy");
    } else if (s[0] == 'C') {
        printf("Rainy");
    } else {
        printf("Sunny");
    }

    return 0;
}

Measured memory_bytes: 128
N=int(input())
#ラス２を相手に食べさせる
#残り1種類の奇数→偶数を自分が担当
#残り1種類、偶数で　相手に渡す
#奇数が一個でもあれば勝てる？（全部偶数にして相手に渡せる）
# 2 3
ok=False
for i in range(N):
    a=int(input())
    if a%2==1:
        ok=True
if ok:
    print("first")
else:
    print("second")


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

#define REP(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define PI M_PI
#define bf printf("\n");

int main(void){
    char S[10], T[10];
    
    scanf("%s",S);
    scanf("%s",T);

    int ctr = 0;
    if(S[0] == T[0]) ctr++;
    if(S[1] == T[1]) ctr++;
    if(S[2] == T[2]) ctr++;
    
    printf("%d",ctr);
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
#define INF 1e8
typedef long long ll;
typedef long double ld;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> c(n);
    rep(i, n) cin >> c[i].first >> c[i].second;
    int mmax = 0, cnt = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i==j) continue;
            int p = c[i].first - c[j].first;
            int q = c[i].second - c[j].second;
            for(int k = 0; k < n; k++){
                for(int l = 0; l < n; l++){
                    if(k==l)continue;
                    if(c[k].first - c[l].first == p
                       && (c[k].second - c[l].second) == q) {
                        cnt++;
                    }
                }
            }
            mmax = max(mmax, cnt);
            cnt = 0;
        }
    }
    cout << n - mmax << endl;
}



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

int main(){

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n,m;
    cin >> n >> m;
    vector<ll> v(m);
    ll sum = 0;
    for(ll i=0;i<m;++i){
    	cin >> v[i];
    	sum+=v[i];
    }
    if( n>=sum){
    	cout << n-sum << "\n";
    }
    else{
    	cout << -1 << "\n";
    }
    
	return 0;
}

Measured memory_bytes: 3740
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}
ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}

void solve()
{
	int n, k;
	cin >> n >> k;
	if (k == 1)
		cout << "0";
	else
		cout<<n - k;
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
		solve();
	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout << (a + b + 1) / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define fi first
#define se second
#define endl '\n'
// #define int int64_t
#define double long double
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using reverse_queue = priority_queue<T, vector<T>, greater<T>>;
mt19937_64 rnd(time(0));
const int64_t FIXED_RANDOM = rnd();
template<typename T> struct custom_hash{T operator()(T x)const{return (T) x^FIXED_RANDOM;}}; // check hash in whether int64 or int32
template<typename T1, typename T2> using hash_map = gp_hash_table<T1, T2, custom_hash<T1>>;
// Tao luyện kỹ thuật trong 8 năm mày luyện kỹ thuật trong buồng tắm nam
const int MAXN = (int) 2e5 + 2;
const int INF = numeric_limits<int>::max() >> 1;
const int MOD = (int) 1000000009;
signed main(){
  ios_base::sync_with_stdio(0); 
  cin.tie(0);
  // freopen("FDT.txt", "r", stdin);
  string s;
  cin >> s;
  if(s[s.size() - 1] == 's') s += "es";
  else s += "s";
  cout << s;
}

Measured memory_bytes: 3624
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    int h, w;
    cin >> h >> w;
    char answ = 0;
    int ansh = 0;
    rep(i, h) {
        rep(j, w) {
            string str;
            cin >> str;
            if (str == "snuke") {
                answ = 'A' + j;
                ansh = i + 1;
            }
        }
    }
    cout << answ << ansh << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main() {
  char c;
  int n;
  while ((c = getchar()) != EOF) {
    if (c == '@') {
      n = getchar() - '0';
      c = getchar();
      while (n--) putchar(c);
    } else {
      putchar(c);
    }
  }
  return 0;
}

Measured memory_bytes: 896
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <utility>

using namespace std;

const int N = 100'009;

int cnt[2][N];
pair<int, int> w[2][3];

int main() {
  int n;
  scanf("%d", &n);
  memset(cnt, 0, sizeof cnt);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    ++cnt[i % 2][x];
  }
  memset(w, 0, sizeof w);
  for (int j = 0; j < 2; ++j) {
    for (int i = 0; i < N; ++i) {
      w[j][2] = {-cnt[j][i], i};
      sort(w[j], w[j] + 3);
    }
  }
  int ans = 1'000'000'000;
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 2; ++j) {
      if (w[0][i].second == w[1][j].second) {
        continue;
      }
      ans = min(ans, n + w[0][i].first + w[1][j].first);
    }
  }
  printf("%d\n", ans);
}


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

#define _ cin.tie(0);ios::sync_with_stdio(false);
using namespace std;
using LL = long long;
int main(){ _
    LL n, m;
    while(cin >> n){
        for(LL i = 1; i*i <= n; i++) m = i * i;
        cout << m << endl;
    }
}


Measured memory_bytes: 256
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> x(n);

  int ans = 0;
  rep(i, n) {
    cin >> x[i];
    if (x[i] * 2 >= k) {
      ans += k - x[i];
    } else {
      ans += x[i];
    }
  }
  cout << 2 * ans;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
cnt = 0
flag = 0
check = 7
for i in range(n):
    a, b = map(int, input().split())
    if a == b:
        cnt += 1
        if cnt == 3:
            flag = 1
    else:
        cnt = 0
        check = 7
if flag == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9172
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String[] S = sc.nextLine().split(" ");
    int ans = 0;
    for(int i = 0; i < N; i++){
      int n = Integer.parseInt(S[i]);
      while(n % 2 == 0){
        n /= 2;
        ans++;
      }
    }
    System.out.println(ans);
  }
}

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

int main(){
  int x, a, b;
  cin >> x >> a >> b;
  if(pow(x-a, 2)<pow(x-b, 2)){
    cout << "A" << endl;
  }
  else{
    cout << "B" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        String words;
        words = scan.next();
        int result;
        
        while(!words.equals("0")){
            result=0;
            for(int i=0; i<words.length(); i++){
                result+=(int)(words.charAt(i)-'0');
            }
            
            System.out.println(result);
            words = scan.next();
        }
    }
}


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) {
    cin >> a.at(i);
  }
  int res = ceil((double) (n - 1) / (k - 1));
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3768
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> x(N);
    rep(i, N) cin >> x[i];

    int total = 0;

    rep(i, N)
    {
        int distance = 0;
        distance = min(x[i], K - x[i]);
        total += distance * 2;
    }
    cout << total << endl;
}


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

using namespace std;
typedef long long ll;

const int N = 200010;
int n, pw2u[N], pw2d[N];

int subtract(int a, int b, int mod) { return (a - b) % mod + (a >= b ? 0 : mod); }

int calc(int a) {
    int res = 0;
    while (a) {
        a %= __builtin_popcount(a);
        res++;
    }
    return res;
}

int main() {
    string x;
    cin >> n >> x;
    int mod = 0;
    for (int i = 0; i < n; i++) {
        if (x[i] == '1') mod++;
    }
    int up = 0, down = 0;
    for (int i = 0; i < n; i++) {
        up = (up * 2) % (mod + 1);
        down = (down * 2) % max(mod - 1, 1);
        if (x[i] == '1') up++, down++;
    }
    pw2u[0] = pw2d[0] = 1;
    for (int i = 1; i <= n; i++) {
        pw2u[i] = (2 * pw2u[i - 1]) % (mod + 1);
        pw2d[i] = (2 * pw2d[i - 1]) % max(mod - 1, 1);
    }
    for (int i = 0; i < n; i++) {
        if (x[i] == '1') printf("%d\n", calc(subtract(down, pw2d[n - i - 1], max(mod - 1, 1))) + (mod > 1));
        else printf("%d\n", calc((up + pw2u[n - i - 1]) % (mod + 1)) + 1);
    }
}


Measured memory_bytes: 5400
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define vec vector
typedef long long ll;
typedef pair<ll,ll> P;
//const ll big=998244353;
const ll big=1000000007LL;
const ll INF=1000000000000000000LL;//1e18
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int n,k;cin >> n >> k;
    int r,s,p;
    cin >> r >> s >> p;
    string t;cin >> t;
    ll ans=0;
    vec<bool> best(n,false);
    rep(i,n){
        if(i>=k&&t[i]==t[i-k]&&best[i-k]){
            continue;
        }
        best[i]=true;
        if(t[i]=='r')ans+=p;
        else if(t[i]=='s')ans+=r;
        else ans+=s;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3744
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
using Int = long long;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,f,t) for(int i=f;i<t;i++)
#define P(ary) do { for(auto i:ary){ cout << i << " "; } cout << endl; } while (0)
int main()
{
    string S; cin >> S;
    for (char c = 'a'; c <= 'z'; c++) {
        bool found = false;
        for(char ch : S) {
            if (c == ch) {
                found = true;
                break;
            }
        }
        if (!found) {
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#define N 8

int queen[N][N],row[N],col[N],dpos[2*N-1],dneg[2*N-1];
void print();
void move(int );

int main(){
  int n,r,c;
  int i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    scanf("%d%d",&r,&c);
    queen[r][c] = 1;
  }
 
  move(0);  
   
  return 0;
}
 
void move(int i){
  int j,p,q;
   
  if(i==N)
  {
    print();
    return;
  }

  for(j=0;j<N;j++)
  {
    p = i+j;
    q = i-j+N-1;
    if(col[j]==1 || dpos[p]==1 || dneg[q]==1)
          continue;

    row[i] = j;
    col[j] = dpos[p] = dneg[q] = 1;
    move(i+1);
    row[i] = col[j] = dpos[p] = dneg[q] = 0;
  }
 
}

void print(){
  int i,j;

  for(i=0;i<N;i++)
  {
    for(j=0;j<N;j++)
    {
      if(queen[i][j])
      {
        if(row[i] != j) return;
      }
    }
  }

  for(i=0;i<N;i++)
  {
    for(j=0;j<N;j++)
    {
      if(row[i] == j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }

}


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

int main()
{
	int a,b,i;
	
	cin>>a>>b;
	
	for(i=1;i<=10000/8;i++)
	   if(floor(i*0.1)==b&&floor(i*0.08)==a)
	   {
	   	 cout<<i;
	   	 return 0; 
       }
       
    cout<<"-1";
    
    return 0;
    
}

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

#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif

int main(){
    int n;
    cin >> n;
    REP(i,n){
        int a, p1 = 0, p2 = 0;
        bool flag = true;
        REP(j,10){
            cin >> a;
            if(p1 < a){
                p1 = a;
            } else if(p2 < a){
                p2 = a;
            } else {
                flag = false;
            }
            pf("DEBUG: %d %d %d\n", a, p1, p2);
        }
        cout << (flag?"YES":"NO") << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
a,b,c,t;
G(x,y){
	if( y ){
		c++;
		return G(y,x%y);
	}else{
		return x;
	}
}
main(){
	for(c=0;scanf("%d%d",&a,&b),a|b;c=0){
		if( a<b ){t=a;a=b;b=t;}
		printf("%d %d\n",t,c,t=G(a,b));
	}
	exit(0);
}

Measured memory_bytes: 0