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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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

const int INF = 1e9;

int main(void){

	int N, M; cin >> N >> M;
	vector<int> X(M);
	REP(i,M) cin >> X[i];
	SORT(X);

	int ans = 0;
	if(N >= M) ans = 0;
	else{
		vector<int> d(M-1, 0);
		REP(i,M-1){
			d[i] = (X[i+1] - X[i]);
		}
		SORT(d);

		REP(i,M-N){
			ans += d[i];
		}

	}

	cout << ans << endl;




	return 0;

}


Measured memory_bytes: 1024
import heapq

def main():
    _, k, q = map(int, input().split())
    a = tuple(map(int, input().split()))

    gs = [a]
    m = float('inf')
    for y in sorted(set(a)):
        gs = groups(gs, y, k)
        x = find_x(gs, y, k, q)
        if x is None:
            break
        m = min(m, x - y)
    
    print(m)

def find_x(gs, y, k, q):
    xs = []

    for g in gs:
        xs.extend(heapq.nsmallest(len(g) - k + 1, g))
    
    xss = heapq.nsmallest(q, xs)
    if len(xss) < q:
        return None
    
    return xss[-1]

def groups(gs, m, k):
    new_gs = []
    for g in gs:
        new_gs.extend(groups_1(g, m, k))
    return new_gs

def groups_1(a, m, k):
    g = []

    pos = 0
    while pos < len(a):
        i = pos
        while i < len(a) and a[i] < m:
            i += 1
        
        j = i
        while j < len(a) and a[j] >= m:
            j += 1
        
        if j - i >= k:
            g.append(a[i:j])
        
        pos = j
    
    return g

main()

Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp) for(auto& i:mp)

const int INF = 1001001001;
long nCr(int n, int r) {
  long ans = 1;
  for (int i = n; i > n - r; --i) {
    ans = ans*i;
  }
  for (int i = 1 ; i < r + 1; ++i) {
    ans = ans / i;
  }
  return ans;
}

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


  int ans = 0;
  ans += nCr(n, 2);
  ans += nCr(m, 2);
  cout << ans << endl;
  return 0;
}


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

vector<int> sieve(int n) {
	vector<int> res{2};
	vector<bool> is_prime(n, true);

	for(int i = 3; i < n; i += 2) {
		if(is_prime[i]) {
			res.emplace_back(i);

			for(int j = i + i; j < n; j += i) {
				is_prime[j] = false;
			}
		}
	}

	return res;
}

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

	constexpr int MAX = 10000;
	const auto primes = sieve(MAX);

	for(int x; cin >> x && x;) {
		int ans = 0;

		for(unsigned i = 0; i < primes.size(); ++i) {
			if(primes[i] > x) break;

			int sum = 0;
			for(unsigned j = i; j < primes.size(); ++j) {
				sum += primes[j];
				if(sum >= x) break;
			}

			if(sum == x) ++ans;
		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1240
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		String s = String.valueOf(scan.nextInt());
		if(s.charAt(0) == s.charAt(2)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
// kyoupro.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

//#include "pch.h"


#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <iomanip>

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

using namespace std;
using std::swap;

vector<long long int> v;
vector<long long int> w;



int main() {
	long long int ANS = 0;
	int K;
	cin >> K;
	for (int i = 1; i < K + 1; i++) {
		for (int j = 1; j < K + 1; j++) {
			for (int m = 1; m < K + 1; m++) {
				ANS += gcd(m,gcd(i,j));
			}
		}
	}
	cout << ANS << "\n";
	return 0;
}

Measured memory_bytes: 3604
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
H = list(map(int, sys.stdin.readline().split()))

ans = 0
cnt = 0
for i in range(N - 1):
    if H[i] >= H[i + 1]:
        cnt += 1
    else:
        ans = max(cnt, ans)
        cnt = 0

ans = max(cnt, ans)
print(ans)


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

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    int all_xor = 0;
    rep(i,n) {
        cin >> a[i];
        all_xor ^= a[i];
    }
    rep(i,n){
        cout << (all_xor ^ a[i]) << (i < n-1? " " : "\n");
    }
    return 0;
}


Measured memory_bytes: 4040
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
    set<int> s;
    rep(i, 3) {
        int a;
        cin >> a;
        s.insert(a);
    }

    if(s.size() == 2) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var a,b,c int
    fmt.Scan(&a,&b,&c)
    ok := false
    for i:=1;i<100000;i++{
        if a*i%b==c{
            ok = true
        }
    }
    ans := "NO"
    if ok{
        ans = "YES"
    }
    fmt.Println(ans)
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func makeTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func sortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}

func reverseString(s string) string{
    t := []rune(s)
    for i,j := 0, len(s)-1 ; i < j ; i, j = i+1, j-1 {
        t[i], t[j] = t[j], t[i]
    }
    return string(t)
}

func inside(h,w,H,W int) bool{
    if h>=0 && h<H && w>=0 && w<W{
        return true
    }
    return false
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

int solve()
{
    ll N, M;

    std::cin >> N >> M;

    vector<int> a  = fetch_vec<int>(M);

    ll sum = std::accumulate(a.begin(), a.end(), 0ll);

    if (sum > N)
        return -1;
    else
        return N - sum;
}

int main()
{
    std::cout << solve() << std::endl;
//    solve();

    return 0;
}

Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {

	public static long Gcd(long m, long n) {
		if(m < n) {
			long tmp = m;
			m = n;
			n = tmp;
		}
		if(m % n == 0)
			return n;
		else {
			m %= n;
			return Gcd(m, n);
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextInt();
		long b = sc.nextInt();
		long ans = a * b / (Gcd(a, b));
		System.out.println(ans);
	}

}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cout << a[i] << " "; cout << "\n"; }
template<class T> void verr(const vector<T>& v){ for(auto& a : v) cout << a << " "; cout << "\n"; }
ll dbgt = 1; void err() { cout << "passed " << dbgt++ << "\n"; }
template<class H, class... T> void err(H&& h,T&&... t){ cout<< h << (sizeof...(t)?" ":"\n"); if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, K;
    cin >> N >> K;
    
    ll t = N % K;

    cout << min(t,K-t) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=105,M=1e9+7;
int n,m,dp[N][N*N],ans;
signed main(){
	scanf("%lld%lld",&n,&m);
	dp[n][0]++;
	for (int i=n;i;i--)
		for (int j=0;j<=(n-i+1)*m;j++)
			if (dp[i][j])for (int k=0;k<=m;k++)
				if (k<=i)(dp[i-1][j+(k+j)/i]+=dp[i][j])%=M;
				else (dp[i-1][j]+=dp[i][j])%=M;
	for (int j=0;j<=n*m;j++)(ans+=M-dp[0][j]*j%M)%=M;
	int fac=1;		
	for (int i=1;i<n;i++)(fac*=m+1)%=M;
	for (int i=0;i<=m;i++)(ans+=fac*n%M*i)%=M;
	printf("%lld\n",ans);
}

Measured memory_bytes: 6656
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();
        s = s.replaceAll("W+", "W");
        s = s.replaceAll("B+", "B");
        System.out.println(s.length() - 1);
    }
}

Measured memory_bytes: 35160
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
    int A, B , tap = 1, ans =0;
    cin >> A >> B;
    while (tap < B){
        tap += A-1;
        ++ans;
    }
    cout << ans;
 }




Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF 1LL<<60

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

	vector<ll> S(3, 0LL);
	rep (i, 3) cin >> S[i];	 

	sort(ALL(S));
	ll res = INF;

	if (S[0] % 2LL == 0LL || S[1] % 2LL == 0LL || S[2] % 2LL == 0LL){
		res = 0LL;
	}else{
		rep (i, 3){
			ll curr = 1LL;
			rep (j, 3){
				if (i == j){
					continue;
				} // end if
				curr *= S[j];
			} // end rep
			res = min(res, curr);
		} // end rep
	} // end if

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector <int> des[1000100];
int size[1000100],md[1000100];
long long ans;
char st[1000100];
void prework(int s,int pre=0)
{
	if (st[s]=='1') size[s]++;
	for (int k=0;k<des[s].size();k++) if (des[s][k]!=pre)
	{
		prework(des[s][k],s);
		size[s]+=size[des[s][k]];
		md[s]=max(md[s],md[des[s][k]]+1);
	}
}	
void dfs(int s,int pre=0,int d=0)
{//cerr<<s<<' '<<d<<endl;
	int l=(st[s]=='0')*2100000000,mx=d,cimx=0;
	if (size[s]!=size[1]) l=min(l,d);
	for (int k=0;k<des[s].size();k++) if (des[s][k]!=pre)
	{
		cimx=max(cimx,md[des[s][k]]+1);if (cimx>mx) swap(cimx,mx);
		if (size[des[s][k]]) l=min(l,md[des[s][k]]+1);
	}
	ans+=max(0,min(cimx+1,mx-1)-l+1);//cerr<<min(cimx+1,mx-1)-l+1<<endl;
	for (int k=0;k<des[s].size();k++) if (des[s][k]!=pre)
		dfs(des[s][k],s,(md[des[s][k]]+1!=mx)?mx+1:cimx+1);
}
int main()
{
	int n;scanf("%d",&n);
	for (int i=1;i<n;i++)
	{
		int u,v;scanf("%d%d",&u,&v);
		des[u].push_back(v);des[v].push_back(u);
	}
	scanf("\n%s",st+1);
	prework(1);
	dfs(1);
	printf("%lld\n",ans+1);
}	
	
	

Measured memory_bytes: 45440
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,=pin()
    A=lispin()
    #累積を入れて引き算でいけ
    left=[0]*N
    left[-2]=A[-1]    

    temp=0
    for i in A:
        temp=temp^i
    left[-1]=temp
    #print(left)

    left[0]=A[0]^left[-1]
    #print(left)

#    left[1]=11^left[-1]^left[0]
#    print(left)
    for i in range(1,N-2):
        left[i]=A[i]^left[-1]^left[i-1]
    #output
    ans=[left[0]]
    for i in range(1,N):
        ans.append(left[i]^left[i-1])
    print(*ans)
#%%submit!
resolve()


Measured memory_bytes: 117140
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
using namespace std;
string button[] = {
  "",
  "',.!?",
  "abcABC",
  "defDEF",
  "ghiGHI",
  "jklJKL",
  "mnoMNO",
  "pqrsPQRS",
  "tuvTUV",
  "wxyzWXYZ"
};
char cal(int buf,int cnt){
  return button[buf][cnt%button[buf].size()];
}
int main(){
  string line;
  while(cin >> line){
	string ans;
	int buf=-1,cnt=0;
	 
	for(char c:line){
	  int index = c-'0';
	  if(index == 0){
		if(buf == 0){
		  ans += " ";
		}else if(buf != -1){
		  ans +=cal(buf,cnt);
		  buf = index;
		  
		}
		continue;
	  }
	  if(buf==index)cnt++;
	  else{
		if(buf > 0)
		  ans += cal(buf,cnt);
		buf = index;
		cnt = 0;
	  }
	}
	if(buf > 0)ans+=cal(buf,cnt);
	cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
#define INF	100000000
#define pb	push_back
#define fi first
#define sec second
#define SS stringstream
using namespace std;
typedef pair<int, int> P;
typedef long long int	ll;

int a, b, n;

int main(){
	while(cin >> a >> b >> n){
		int s = 0;
		a = a%b;
		for(int i = 1; i <= n; i++){
			a = a*10;
			s += a/b;
			a = a%b;
		}
		cout << s << endl;
	}
}

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

int candidates[100000002];

using namespace std;
int main() {
    int n;
    cin >> n;
    int cnt = 0;
    int a;

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

        if (a == 1) {
            continue;
        }
        if (a == 2) {
            cnt++;
            continue;
        }

        if ((a & 1) == 0) {
            continue;
        }
        bool isprime = true;
        int s = sqrt(a) + 1;
        for (int j = 3; j < s; j+=2) {
            if (candidates[j] == -1) { continue; }
            if (a % j == 0) {
                isprime = false;
                break;
            }
        }
        if (isprime) {
            candidates[a] = 1;
            //cerr << a << endl;
            cnt++;
        } else {
            candidates[a] = -1;
        }
    }
    cout << cnt << endl;
}


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

int main() {
string O,E;
cin >> O >> E;
string C,J,K,L;
int S= O.size()-E.size();
for(int i=0;i<O.size() ;i++){
  if(i==0){
  K=O.at(i);
  L=E.at(i);
  J=K+L;
  C=J;
  }
  else if(S==1&&i==O.size()-1){
    C+=O.at(i);
  }
  else{
  K=O.at(i);
  L=E.at(i);
  J=K+L;
  C +=J;
  }
}
cout<< C <<endl;

}

Measured memory_bytes: 256
n, k = map(int, input().split())
snukes = []
for _ in range(k):
    okashi = int(input())
    snukes += [int(v) for v in input().split()]
target = 1
cnt = 0
l = list(set(snukes))
s = [int(v) for v in range(1, n + 1)]

for p in s:
    if p not in l:
        cnt += 1
print(cnt)

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

int main(){
    int n,q;
    cin >> n >> q;
    string name;
    int time = 0;
    int ans = 0;
    queue< pair<string,int> > task;
    for(int i=0;i<n;i++){
        cin >> name >> time;
        task.push(make_pair(name,time));
    }
    while(!task.empty()){
        name = task.front().first;
        time = task.front().second;
        task.pop();
        if(time <= q){
            ans += time;
            cout << name << " " << ans << endl;
        }else{
            ans += q;
            time -= q;
            task.push(make_pair(name,time));
        }
    }
    return 0;

}


Measured memory_bytes: 6256
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<list>
using namespace std;
constexpr auto MOD = 1000000007;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VLL;

int gcm(int a, int b) {
   if (!a || !b)return -1;
   if (a < b) {
	  a = a ^ b;
	  b = a ^ b;
	  a = a ^ b;
   }
   if (!(a%b)) return b;
   return gcm(a%b, b);
}
long long gcm(long long a, long long b) {
   if (!a || !b)return -1;
   if (a < b) {
	  a = a ^ b;
	  b = a ^ b;
	  a = a ^ b;
   }
   if (!(a%b)) return b;
   return gcm(a%b, b);
}

int main() {
   ll a, b;
   cin >> a >> b;
   ll g=gcm(a,b);
   ll num = 3;
   int cnt = 0;
   if (g % 2 == 0) {
	  while (g % 2 == 0) {
		 g /= 2;
	  }
	  cnt++;
   }
   bool flg = 0;
   while (g > 1) {
	  if (g%num == 0) {
		 g /= num;
		 if (flg);
		 else {
			flg = true;
			cnt++;
		 }
	  }
	  else {
		 flg = false;
		 num += 2;
	  }
	  if (num > 10000000) {
		 cnt++;
		 break;
	  }
   }
   cout << cnt + 1<<endl;
}

Measured memory_bytes: 256
# coding: utf-8
s = input()
# 0始まりと1始まりのどちらに近いか？を調べて、より近いものにする際の差分を取る
with_zero, with_one = 0, 0
for i, c in enumerate(s):
    if i % 2 == 1:
        # 奇数桁: 0 -> 0始まりのものとマッチしているので+1
        #         1 -> 1始まりのものとマッチしているので+1
        if c == "0":
            with_zero += 1
        elif c == "1":
            with_one += 1
    else:
        # 偶数桁: 1 -> 0始まりのものとマッチしているので+1
        #         0 -> 1始まりのものとマッチしているので+1
        if c == "1":
            with_zero += 1
        elif c == "0":
            with_one += 1

min_diff = len(s) - (with_zero if with_zero > with_one else with_one)
print(min_diff)

Measured memory_bytes: 3188
//
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define MOD 1000000007
#define PI 3.14159265
#define EPS 1e-9
#define Pi acos(-1.0)
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;

/*CODE START HERE*/

string s, t;
bool sol;

int main(){
    ios::sync_with_stdio(0);
    cin >> s >> t;
    sol = false;
    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());

    if(s < t){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
package main
 
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

func main(){
    
    S := nextString();
	sm := 0
	N := uint(len(S))
    // bit全探索
	for i := uint(0); i < 1 << N; i++ {
        l := ""
		for j := uint(0); 1 << j <= i; j ++ {
			if ((1 << j) & i) > 0 {
				l += S[j:j + 1]
			} else {
				a, _ := strconv.Atoi(l)
				sm += a
				l = ""
			}
		}
		a, _ := strconv.Atoi(l)
		sm += a
	}
	fmt.Println(sm)
}

/* templates */


func Max(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r < a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Min(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r > a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Sum(a []int) (r int) {
    for i := range a {
        r += a[i]
    }
    return r
}
 
func Abs(a float64) float64 {
    if a < 0 {
        return -a
    }
    return a
}
 
type Pair struct {
    a, b int
}
 
type Pairs []Pair
 
func (p Pairs) Len() int {
    return len(p)
}
 
func (p Pairs) Swap(i, j int) {
    p[i], p[j] = p[j], p[i]
}
 
func (p Pairs) Less(i, j int) bool {
    return p[i].b < p[j].b
}
 
var nextReader func() string
 
func init() {
    nextReader = NewScanner()
}
 
func NewScanner() func() string {
    r := bufio.NewScanner(os.Stdin)
    r.Buffer(make([]byte, 1024), int(1e+11))
    r.Split(bufio.ScanWords)
    return func() string {
        r.Scan()
        return r.Text()
    }
}

func nextString() string {
    return nextReader()
}
 
func nextInt64() int64 {
    v, _ := strconv.ParseInt(nextReader(), 10, 64)
    return v
}
 
func nextInt() int {
    v, _ := strconv.Atoi(nextReader())
    return v
}
 
func nextInts(n int) []int {
    r := make([]int, n)
    for i := 0; i < n; i++ {
        r[i] = nextInt()
    }
    return r
}

func nextStrings(n int) []string {
    r := make([]string, n)
    for i := 0; i < n; i++ {
        r[i] = nextString()
    }
    return r
}

func nextFloat64() float64 {
    f, _ := strconv.ParseFloat(nextReader(), 64)
    return f
}


Measured memory_bytes: 768
var
 n,i,s,max:longint;
 ch:string;
begin
 readln(n);
 readln(ch);
 for i:=1 to n do
  begin
   if ch[i]='I' then inc(s)
                else dec(s);
   if s>max then max:=s;
  end;
 writeln(max);
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
ll k;
ll u=0;
void print(char a)
{
	cout<<a<<endl;
	exit(0);
}
int main()
{
	cin>>s;
	cin>>k;
	if(s.length()==1)
		print((char)s[0]);
	if(s[0]!='1') print((char)s[0]);
	u=s.find_first_not_of('1');
	//cout<<u<<endl;
	if(u==-1) print('1');
	if(u>=k) print('1');
	else print((char)s[u]);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

//const double PI = 3.1415926535897932384626433832795;

int main() {
  int n, m;
  cin >> n >> m;
  if(n == m) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define ll long long
#define mp make_pair
#define pb push_back
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define N 100010
#define Pa 99991
#define Maxi 1e18
ll dp[100001][101];
ll findans(ll wt[],ll val[],ll Wt,ll i,ll n)
{
    if(i==n)
    return 0;
    if(dp[Wt][i]!=-1)
    return dp[Wt][i];
    if(wt[i]<=Wt)
    return dp[Wt][i]=max(val[i]+findans(wt,val,Wt-wt[i],i+1,n),findans(wt,val,Wt,i+1,n));
    else
    return dp[Wt][i]=findans(wt,val,Wt,i+1,n);
}
int main()
{
    ll n,Wt;
    cin>>n>>Wt;
    ll i;
    ll wt[n],val[n];
    memset(dp,-1,sizeof(dp));
    for(i=0;i<n;i++)
    {
        cin>>wt[i]>>val[i];
    }
    cout<<findans(wt,val,Wt,0,n);
    return 0;
}

Measured memory_bytes: 79104
a=list(map(str,input()))
for i in range(len(a)):
  a.append(a[i])
b=list(map(str,input()))
for i in range(len(a)):
  if a[i]==b[0]:
    if a[i:(i+len(b))]==b:
      print('Yes')
      break
else:
  print("No")



Measured memory_bytes: 5564
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

using namespace std;
#define int long long
using ll = long long;
const int MX = 1e6;
const ll inf = 1e13;
const int mod = 1e9+7;

signed main() {
    int n;
    string s;
    cin >> n >>s;
    int ans = 0;
    rep(i,10) {
        rep(j,10) {
            rep(k,10) {
                int now = i;
                int cnt = 0;
                    
                rep(l,n) {
                    //cout << s[l] << endl;
                    if((int)(s[l]-'0')==now) {
                        cnt++;
                        if(cnt==3) {
                            ans++;
                            break;
                        }
                        if(cnt==1)now=j;
                        else now=k;
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
void solve(int n) {
  vector<P> v(n);
  int su = 0;
  for(int i=0;i<n;++i) {
    cin >> v[i].first >> v[i].second;
    su += v[i].first + v[i].second;
  }
  sort(v.rbegin(), v.rend());
  int subook = 0;
  for(int i=1;i<n;++i) {
    subook += v[i].first;
  }
  if(v[0].first <= subook) {
    cout << su << endl;
    return;
  }
  vector<vector<bool>> dp(n, vector<bool>(v[0].first - subook + 1, false));
  dp[0][0] = true;
  for(int i=1;i<n;++i) {
    for(int j=0;j<v[0].first - subook + 1;++j) {
      if(!dp[i-1][j] || j + v[i].second > v[0].first - subook) continue;
      dp[i][j+v[i].second] = true;
      dp[i][j] = true;
    }
  }
  int ma = 0;
  for(int i=0;i<v[0].first - subook + 1;++i) {
    if(dp[n-1][i]) ma = max(ma, i);
  }
  cout << su + (v[0].first - subook - ma) << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    int n; cin >> n;
    if(n == 0) break;
    solve(n);
  }
}



Measured memory_bytes: 3268
U,R,D,L="URDL"
d={i:[]for i in"URDL"}
_,*a=map(str.split,open(0))
for*z,u in a:d[u]+=[*map(int,z)],
N,P,M=9e9,"x+y,","x-y,"
for*F,S in(D,U,"x,y,"),(L,R,"y,x,"),(U,R,P+M),(L,D,P+M),(L,U,M+P),(D,R,M+P):
 n=p=-9e9
 for x,y,r in sorted(eval(f"[({S}Q)for Q,P in enumerate(F)for x,y in d[P]]")):
  if r:n,p=x,y
  elif x==n:N=min(N,y-p)
print(["SAFE",N*5][N<9e9])

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n)cin>>a[i];
	ll sum = 0;
	rep(i,n){
		sum ^= a[i];
	}
	rep(i,n){
		cout << (sum^a[i]) << endl;
	}
}


Measured memory_bytes: 4776
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on
int H, W;
int h, w;

int main(void)
{
  cin >> H >> W;
  cin >> h >> w;
  cout << W * H - (h * W + w * H - (h * w)) << endl;
  return 0;
}


Measured memory_bytes: 888
import sys
from io import StringIO
import unittest

doTest=0

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    n,m=list(map(int, readline().strip().split()))
    a=[0]*n
    b=[0]*n
    c=[0]*m
    d=[0]*m

    for i in range(n):
        a[i],b[i]=list(map(int, readline().strip().split()))
    for i in range(m):
        c[i],d[i]=list(map(int, readline().strip().split()))

    for i in range(n):
        minDiff=999999999
        minpnt=9999999
        for j in range(m):
            diff=abs(a[i]-c[j])+abs(b[i]-d[j])
            if diff < minDiff:
                minDiff = diff
                minpnt=j
        print(minpnt+1)
    return

if doTest==0:
    resolve()
    sys.exit()

### ----------------
### ここまでコピぺえ 
### ----------------

Measured memory_bytes: 5616
#include <stdio.h>

int main() {
	int N,K;
	scanf("%d %d",&N,&K);
	char S[N];
	scanf("%s",S);
	char c[2];
	c[0] = S[K-1];
	S[K-1] = c[0] + 32;
	printf("%s\n",S);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll n, k;
  cin >> n >> k;
  unordered_map<ll, ll> m;
  rep(i, k) {
    ll d;
    cin >> d;
    m[d]++;
  }

  rep2(i, n, 100003) {
    ll num = i;
    rep(j, get_digit(i)) {
      ll a = num % 10;
      num /= 10;
      if (m[a] != 0) break;
      if (j == get_digit(i) - 1) {
        COUT(i);
        return 0;
      }
    }
  }

  return 0;
}

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

bool isBatch(string S, int start, int end) {
  int n = ceil((end - start + 1) / 2);
  for (int i = 0; i < n; i++) {
    if (S.at(start + i) != S.at(end - i)) {
      return false;
    }
  }

  return true;
}

int main() {
  string S;
  cin >> S;

  if (
    isBatch(S, 0, S.size() - 1) and
    isBatch(S, 0, (S.size() - 1) / 2 - 1) and
    isBatch(S, (S.size() + 1) / 2, S.size() - 1)
  )
  {
    cout << "Yes" << endl;
  } 
  else {
    cout << "No" << endl;
  }
}


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

long long gcd(long long x, long long y){
  long long r = x % y;
  while(r!=0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

int main(){
  long long A,B,C,D;
  cin >> A >> B >> C >> D;
  if(C>D){
    int tmp = C;
    C = D;
    D = tmp;
  }
    
  long long tmp1 = B/D-(A-1)/D;
  long long tmp2 = B/C-(A-1)/C;
  
  long long E = C*D/gcd(C,D);
  long long tmp3 = B/E-(A-1)/E;
  long long N = B-A+1;
  cout << N - (tmp1 + tmp2 - tmp3);
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define  all(x) (x).begin(),(x).end()
typedef long long ll;

#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; i++) L[i] = A[left+i];
    for (int i = 0; i < n2; i++) R[i] = A[mid+i];
    L[n1] = R[n2] = SENTINEL;
    int i = 0, j = 0;
    for (int k = left; k < right; k++){
        cnt++;
        if (L[i] <= R[j]){
            A[k] = L[i++];
        }
        else {
            A[k] = R[j++];
        }
    }
}

void mergeSort(int A[], int n, int left, int right){
    if (left +1 < right){
        int mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int main(){
    int A[MAX], n, i;
    cnt = 0;

    cin >> n;
    rep(i,n) cin >> A[i];

    mergeSort(A, n, 0, n);

    rep(i,n){
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl << cnt << endl;

    return 0;
}


Measured memory_bytes: 6904
N,M,Q=map(int,input().split())
A=[[0]*(N+1) for _ in range(N+1)]
for _ in range(M):
  L,R=map(int,input().split())
  A[L][R]+=1
  
for i in range(1,N+1):
  for j in range(1,N+1):
    A[i][j]+=A[i][j-1]
for i in range(1,N+1):
  for j in range(1,N+1):
    A[i][j]+=A[i-1][j]

for i in range(Q):
  L,R=map(int,input().split())
  ans=A[R][R]-A[L-1][R]-A[R][L-1]+A[L-1][L-1]
  print(ans)

Measured memory_bytes: 13400
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
string fillText(string s, LL d) {
    string ret = s;
    while(ret.size() < d) ret = "0" + ret;
    return ret;
}
string decimalToBinary(LL n, LL d) {
    if(n == 0) return fillText("0", d);
    string ret;
    LL ln = abs(n);
    while(ln) {
        ret = string((ln & 1) ? "1" : "0") + ret;
        ln /= 2;
    }
    ret = fillText(ret, d);
    if(n < 0) ret = "-" + ret;
    return ret;
}
void xorSum(LL N, LL pow2[], LL D, LL nXor[]) {
    LL ret = 0;
    string nStr = decimalToBinary(N, D);
    LL nXorStock[D][D];
    for(LL i = 0; i < D; i++){
        int ci = nStr[i] - '0';
        for(LL j = 0; j < D; j++){
            int cj = nStr[j] - '0';
            if(j <  i) nXorStock[i][j] = (pow2[D - 1 - i]) * ci * cj;
            if(j == i) nXorStock[i][j] = 1 * ci;
            if(j >  i) nXorStock[i][j] = (pow2[D - 1 - i] / 2) * ci;
        }
    }
    for(LL i = 0; i < D; i++) nXor[i] = 0;
    for(LL j = 0; j < D; j++) for(LL i = 0; i < D; i++) nXor[j] += nXorStock[i][j], nXor[j] %= 2;
}
int main() {
    LL A, B;
    cin >> A >> B;
    const int LIMIT = 40;
    LL pow2[LIMIT];
    pow2[0] = 1;
    for(LL i = 1; i < LIMIT; i++) pow2[i] = 2 * pow2[i - 1];
    LL xorA[LIMIT], xorB[LIMIT];
    if(A > 0) A--;
    xorSum(A, pow2, LIMIT, xorA);
    xorSum(B, pow2, LIMIT, xorB);
    LL ans = 0;
    for(int i = 0; i < LIMIT; i++) if(xorA[i] != xorB[i]) ans += pow2[LIMIT - 1 - i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*  (: ///////|||||| BEGINS |||||||\\\\ :) */
/* REMEMBER
Deletes all characters except first one     Deletes 4 characters from index number 1
    str.erase(1);                               str.erase(1,4);
Deletes character at position 4
 str.erase(str.begin() + 4);
bool compare(const pair<int, int>&a, const pair<int, int>&b)
{
   return a.second<b.second;
}
maxn = max_element(mp.begin(), mp.end(), compare)->second;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second < b.second);
}
priority_queue <int, vector<int>, greater<int>> gquiz; // to create min heap
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
const int inf=0x3f3f3f3f;
#define mod  1000000007
#define fo(i,n) for(int i=1;i<=n;i++)
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define three_max(n1,n2,n3) (n1 > n2)?(n1>n3?n1:n3):(n2>n3?n2:n3)
#define lb lower_bound
#define ub upper_bound
#define tr(it, a) for(auto it = a.begin();it!=a.end();it++)
#define gcd(a,b) __gcd(a,b)
#define pq priority_queue 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
long long isprime(long long n)
{
    for(long long i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)return 0;
    }
    return 1;
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int n;
cin>>n;
if(n>=30)cout<<"Yes"<<endl;
else cout<<"No";

return 0;
}

Measured memory_bytes: 3696
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	try (Scanner sc = new Scanner(System.in)){
		final int n = sc.nextInt();
		int i = 1;
		do {
			int x = i;
			if (x % 3 == 0) {
				System.out.print (" " + i);
			} else {
				do {
					if (x % 10 == 3) {
						System.out.print(" " + i);
						break;
					}
					x /= 10;
				} while (x != 0);
			}
		} while (++i <= n);
		System.out.println();
	}
}}

Measured memory_bytes: 28696
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define int long long
#define ll long long
#define mod (int)1000000007
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = DBL_EPSILON;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline int gcd(int a, int b) {
	while (b) {
		int c = a;
		a = b; b = c % b;
	}
	return a;
}
inline int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
bool isprime(int n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
int mypow(int a, int b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	int memo = mypow(a, b >> 1);
	return memo * memo;
}
int modpow(int a, int b, int m = mod) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	int memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
int n, m, s, c;
signed main() {
	cin >> n >> m;
	if (n == 1 && m == 0) {
		cout << 0 << endl;
		return 0;
	}
	string ans(n, '.');
	rep(i, m) {
		cin >> s >> c;
		if (ans[s - 1] == '.')ans[s - 1] = '0' + c;
		else if (ans[s - 1] - '0' != c) {
			cout << -1 << endl;
			return 0;
		}
	}
	rep(i, n) {
		if (ans[i] == '.') {
			if (i)ans[i] = '0';
			else ans[i] = '1';
		}
	}
	if (ans.size() > 1 && ans[0] == '0')cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

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;

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int maxn = 55;
const int inf = 0x3f3f3f3f;

int n,m;
string g[maxn];
int dist[maxn][maxn];
pair<int,int> prv[maxn][maxn];

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

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

  memset(dist, inf, sizeof dist);
  for (int i=0; i<n; i++) {
    for (int j=0; j<m; j++) {
      prv[i][j].first = -1;
      prv[i][j].second = -1;
    }
  }


  queue<pair<pair<int,int>,pair<int,pair<int,int>>>> q;
  q.push({ {0,0}, {0, {-1,-1}}});

  while (!q.empty()) {
    auto cur = q.front(); q.pop();
    auto at = cur.first;
    int dst = cur.second.first;
    auto previous = cur.second.second;
    dist[at.first][at.second] = dst;
    prv[at.first][at.second] = previous;

    vector<pair<int,int>> moves = { {-1,0}, {0,-1}, {1,0}, {0,1} };
    for (auto mo: moves) {
      int x = mo.first + at.first; int y = mo.second + at.second;
      if (x<0 || y<0 || x>=n || y>=m || dist[x][y] <= dst+1 || g[x][y]=='#') continue;
      dist[x][y] = dst+1;
      q.push({ {x,y}, {dst+1, at} });
    }
  }

  if (dist[n-1][m-1] == inf) out(-1);
  
  int x = n-1; int y = m-1;
  while (x!=-1 && y!=-1) {
    g[x][y] = '#';
    int x2 = prv[x][y].first;
    int y2 = prv[x][y].second;
    x = x2; y = y2;
  }

  int ans = 0;
  for (int i=0; i<n; i++) {
    for (int j=0; j<m; j++) {
      ans += (g[i][j] == '.');
    }
  }


  out(ans);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vec             vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define no_of_test(x)   int x; cin>>x; while(x--)

const int mod = 1e9 + 7;
void very_fast()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int gcd(int a, int b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}
int binary_exponentation(int a, int b)
{
	int ret = 1;
	while (b)
	{
		if (b & 1) ret = (ret * a) % mod;
		b >>= 1;
		a = (a * a) % mod;
	}
	return ret;
}

int32_t main()
{
	very_fast();
//	no_of_test(x)
	{
		int n, cnt = 0;
		cin >> n;
		string s;
		cin >> s;
		for (int i = 0; i < n;)
		{
			if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
			{
				cnt++;
				i += 3;
			}
			else
				i++;
		}
		cout << cnt << "\n";
	}
	return 0;

}


Measured memory_bytes: 3640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

ll A[31];

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    A[0] = 1;
    rep(i,31) {
        if (i >= 1) A[i] += A[i-1];
        if (i >= 2) A[i] += A[i-2];
        if (i >= 3) A[i] += A[i-3];
    }
    while(true) {
        int N; cin >> N;
        if (N == 0) break;
        ll ans = (A[N] + 3649) / 3650;
        cout << ans << endl;
    }

}



Measured memory_bytes: 3128