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

int main() {
  int N,K;
  scanf("%d %d", &N,&K);
  string X;
  cin >> X;
  if(X[K-1] == 'A') X[K-1] = 'a';
  else if(X[K-1] == 'B') X[K-1] = 'b';
  else X[K-1] = 'c';

  cout << X << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const  int maxn=1e5+10;
const int  inf=0x3f3f3f3f;
int a[maxn];
ll ans=0,sum=0;
int main()
{
     int n;
     scanf("%d",&n);
     int  mins=inf;
       int couts=0;
     for(int i=0;i<n;i++)
      {
          scanf("%d",&a[i]);
          sum+=abs(a[i]);
          mins=min(mins,abs(a[i]));
          if(a[i]<=0)
            couts++;
      }
     // cout<<sum<<endl;
    //  cout<<mins<<endl;
       if(couts%2==0)
        cout<<sum<<endl;
        else
        cout<<sum-(ll)mins*2<<endl;
    return 0;
}


Measured memory_bytes: 640
s = input()
t = input()

ns= len(s)
nt = len(t)
ans =0


for i in range(ns-nt+1):
    count = 0
    for j in range(nt):
        if s[i+j] == t[j]:
            count +=1
    else:
        ans = max(ans, count)

print(nt-ans)

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

int par[100000];
long long islands[100000];

int find(int x) {
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    par[x] = y;
    islands[y] += islands[x];
}

long long count(int x) {
    return islands[find(x)];
}

int main(void) {
    int n, m;
    scanf("%d%d", &n, &m);
    vector<int> a(m), b(m);
    for (int i = 0; i < m; i++) {
        scanf("%d%d", &a[i], &b[i]);
    }

    for (int i = 0; i < n; i++) {
        par[i] = i;
        islands[i] = 1;
    }
    vector<long long> ans(m);
    long long inconvenience = (long long) n * (n - 1) / 2;
    for (int i = m - 1; i >= 0; i--) {
        ans[i] = inconvenience;
        if (find(a[i]) != find(b[i])) {
            inconvenience -= count(a[i]) * count(b[i]);
            unite(a[i], b[i]);
        }
    }
    for (int i = 0; i < m; i++) {
        printf("%lld\n", ans[i]);
    }
    return 0;
}

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

int main() {
    int n, k, cnt = 0;
    cin >> n >> k;
    map<int, int> mp;
    for (int i = 0; i < k; i++)
    {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            int a;
            cin >> a;
            mp[a]++;
        }
        
    }
    for (int i = 1; i <= n; i++) {
        if (mp[i] == 0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3632
from collections import defaultdict
from collections import deque
from collections import Counter
import math
import itertools

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
if n==1:
	print(0)
	exit()
mod = 10**9+7
a = pow(10,n,mod)
b = pow(8,n,mod)
c = pow(9,n,mod)
print((a-2*c+b)%mod)


Measured memory_bytes: 9476
#include "bits/stdc++.h" // {{{
using namespace std;
#define eb          emplace_back
#define emp         emplace
#define fi          first
#define se          second
#define X           first
#define Y           second
#define outl(x)     cout << (x) << '\n'
#define rep(i,n)    for(int i=0; i < (int)(n); ++i)
#define ALL(x)      begin(x), end(x)
#define TMPLT(T,U)  template<class T, class U>
#define ten(p)      (int)(1e##p)
#define FILL(a,val) memset((a), (val), sizeof(a))
#define FAST()      ios::sync_with_stdio(false), cin.tie(nullptr)
#ifdef DEBUG
#define debug(...)  fprintf(stderr, __VA_ARGS__)
#define show(x)     clog << #x << " \t= " << (x) << '\n'
#define line()      fputs("\n--------------------------------\n", stderr)
#else
#define debug(...)
#define show(x)
#define LN()
#endif
using ll  = long long;
using pii = pair<int,int>;
TMPLT(T,U) inline bool chmax(T &a, U b){return b>a ? a=b,1 : 0;}
TMPLT(T,U) inline bool chmin(T &a, U b){return b<a ? a=b,1 : 0;}
TMPLT(T,U) inline constexpr common_type_t<T,U> gcd(T x, U y) { return (x<y)? gcd(y,x) : (y <= 0)? x : gcd(y, x % y); }
TMPLT(T,U) inline constexpr ll lcm(T x, U y) { return (ll)x/gcd(x,y) * y; }
inline bool inner(int val, int min, int max){ return min <= val && val < max; }
constexpr int INF   = 0x3f3f3f3f;
constexpr ll LINF   = 0x3f3f3f3f3f3f3f3fLL;

namespace ydk{ // }}}

constexpr int MXN = ten(5) + 10;

int N, M;
vector<pii> vec[MXN];

signed _vim_is_god_()
{
    cin >> N >> M;
    rep(i, M) {
        int p, y;
        cin >> p >> y;
        vec[p].eb(y, i);
    }

    string ans[MXN];

    for (int i = 1; i <= N; ++i) {
        sort(ALL(vec[i]));

        char head[256];
        char tail[256];

        for (int j = 0; j < vec[i].size(); ++j) {
            debug("[%d][%d] %d %d\n", i, j, vec[i][j].fi, vec[i][j].se);
            sprintf(head, "%06d", i);
            sprintf(tail, "%06d", j+1);
            int num = vec[i][j].se;
            ans[num] = string() + head + tail;
        }
    }

    for (int i = 0; i< M; ++i) {
        outl(ans[i]);
    }


    return 0;
}

} // {{{

signed main(){cout << fixed << setprecision(9); ydk::_vim_is_god_(); return 0;} // }}}



Measured memory_bytes: 12416
a,b,k = map(int,input().split())
num=[]
for i in range(100):
    if(a%(i+1) == 0 and b%( i+1)==0):
        num.append(str(i+1))
x = len(num)
#print("num:"+str(num))
#print("x:"+ str(x))
print(num[x-k])

Measured memory_bytes: 9068
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <cstring> // memset
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define ALL(x) (x).begin(), (x).end()
#define INF 1e9
#define LOG(x) cout << #x << " = " << (x) << endl
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

void update(set<int>& setX, int count) {
    set<int> temp(setX);
    setX.clear();
    for (auto i: temp) {
        setX.insert(i + count);
        setX.insert(i - count);
    }
}


int main() {
    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;
    s += "T";
        
    set<int> setX = {0};
    set<int> setY = {0};

    int count = 0;
    int sign = -1;
    
    for (auto i: s) {
        if (i == 'F') {
            count++;
        } else if (i == 'T') {
            if (sign == -1) {
                setX.erase(0);
                setX.insert(count);
                sign = 1;
            } else if (sign == 1) {
                update(setX, count);
            } else if (sign == 0) {
                update(setY, count);
            }
            sign ^= 1;
            count = 0;
        } 
    }

    cout << ((setX.count(x) == 1 && setY.count(y) == 1) ? "Yes" : "No") << endl;
    
    return 0;
}


Measured memory_bytes: 768
#include<stdio.h>

int main(){
	char s[1001];
	int ans=0,i=0,ch;
	while(1){
		i=0;
		scanf("%s",s);
		ans=0;
		if(s[0]=='0') break;
	while(s[i]!='\0'){
			ans += s[i]-'0';
			i++;
		}
		printf("%d\n",ans);
	}
	return 0;
}
		

Measured memory_bytes: 536
fun main(arr:Array<String>) {
    val (n,m,x,y) = readLine()!!.split(" ").map { it.toInt() }
    val xPoints = readLine()!!.split(" ").map { it.toInt() }.union(listOf(x)).sorted()
    val yPoints = readLine()!!.split(" ").map { it.toInt() }.union(listOf(y)).sorted()
    if(xPoints.last() < yPoints.first()) {
       println("No War")
    } else {
        println("War")
    }
}


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

int main(){
    char S[100001],table1[5]={'d','r','e','a','m'},table2[4]={'e','r','a','s'},table3[2]={'e','r'};
    int state=0,indx=0,i,slen;
    cin >> S;
    slen = strlen(S);
    while(indx<slen){
        if(indx+2<=slen){
            if(S[indx]=='d'){
                state = 0;
            }else{
                if(S[indx]=='e'){
                    if(S[indx+2]=='a'){
                        state = 1;
                        //cout << "1" << endl;
                    }else{
                        //cout << indx << endl;
                        if(state==2){
                            cout << "NO" << endl;
                            return 0;
                        }else{
                            state = 2;
                        }  
                    }
                }else{
                    cout << "NO" << endl;
                    return 0;
                }
            }
        }else{
            state = 2;
        }

        if(state==0){
            for(i=0;i<5;i++){
                if(S[indx+i]!=table1[i]){
                    cout << "NO" << endl;
                    return 0;
                }
            }
            indx += 5;
        }else{
            if(state==1){
                for(i=0;i<4;i++){
                    if(S[indx+i]!=table2[i]){
                        cout << "NO" << endl;
                        return 0;
                    }
                }
                indx += 4;
                if(S[indx]!='e'){
                    cout << "NO" << endl;
                    return 0;
                }else{
                    indx++;
                    if(S[indx]=='d'){
                        state = 0;
                        //cout << "OK" << endl;
                    }else{
                        if(S[indx]=='r'){
                            state = 2;
                            indx++;
                        }else{
                            if(S[indx]=='e'){
                                state = 1;
                            }else{
                                if(indx!=slen){
                                    cout << "NO" << endl;
                                    return 0;
                                }
                            }
                        }
                    }
                }
            }else{
                for(i=0;i<2;i++){
                    if(S[indx+i]!=table3[i]){
                        cout << "NO" << endl;
                        return 0;
                    }
                }
                indx += 2;
                //cout << state << endl;
            }
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		if (a%2 == 0 || b%2 == 0) {
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}
	}

	static class FastScanner {

		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;

	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

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

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

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

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

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

	}

}


Measured memory_bytes: 23124
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String input = sc.next();
    String ans = "";
    for(int i=0; i<input.length(); i++){
      ans = pressKey(input.charAt(i), ans);
    }
    System.out.println(ans);
  }
  
  private static String pressKey(char c, String str){
    if(c == '0'){
      return str+"0";
    }
    if(c == '1'){
      return str+"1";
    }
    if(str.equals("")){
      return str;
    }
    if(c == 'B'){
      StringBuilder builder = new StringBuilder(str);
      builder.deleteCharAt(builder.length()-1);
      return builder.toString();
    }
    return null;
  }
}


Measured memory_bytes: 21972
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a[n];
	ll ans = 1;
	ll minus = 1;
	for(int i=0; i<n; i++){
		cin >> a[i];
		ans *= 3;
		if(a[i]%2){
			minus *= 1;
		}else{
			minus *= 2;
		}
	}

	cout << ans - minus << endl;

	return 0;
}

Measured memory_bytes: 256
package main

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

type cluster struct {
	status byte
	q      int
}

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)

func main() {
	buf := make([]byte, initialBufSize)
	scanner.Buffer(buf, maxBufSize)

	n := getInt()
	k := getInt()
	s := getString()

	clusters := make([]cluster, 0, n)
	clusters = append(clusters, cluster{status: s[0]})
	for i, j, sum := 0, 0, 0; ; i++ {
		if clusters[j].status != s[i] {
			clusters = append(clusters, cluster{status: s[i]})
			clusters[j].q = sum
			sum = 0
			j++
		}
		sum++

		if i == n-1 {
			clusters[j].q = sum
			break
		}
	}

	ans := 0
	i := 0
	m := len(clusters)
	for cnt := 0; i < m; i++ {
		ans += clusters[i].q
		if clusters[i].status == '0' {
			cnt++
		}
		if cnt == k {
			if i < m-1 {
				ans += clusters[i+1].q
				i++
			}
			break
		}
	}

	before := ans
	for ; i < m-1; i += 2 {
		tmp := before

		// しっぽ
		if i-k*2+1 == 0 {
			tmp -= clusters[0].q
		} else {
			tmp -= clusters[i-k*2].q + clusters[i-k*2+1].q
		}

		// あたま
		if m-i-2 == 0 {
			tmp += clusters[i+1].q
		} else {
			tmp += clusters[i+1].q + clusters[i+2].q
		}

		ans = max(ans, tmp)
		before = tmp
	}

	fmt.Println(ans)
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

// k = 2
// 0 1 0 1 0 1 0
// 8 2 2 5 1 3 1

//   0 1 0 1 0 1
// 1 0 1 0 1 0 1

// len(cluster) == 7
// k == 3
// 0 1 0 1 0 1 0
// 1 0 1 0 1 0 1

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 2560
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	cout << (H - h) * (W - w) << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    map<char, int> x;
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++)
    {
        x[s[i]]++;
    }
    for (char c = 'a'; c <= 'z'; c++)
    {
        if (x[c] == 0)
        {
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 3692
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto n = readln.chomp.to!int;
  auto a = readln.chomp.split.to!(int[]);
  auto p = 10000;
  int cnt;
  foreach (i; 1..n) {
    if (a[i-1] == a[i]) {
      a[i] = p;
      p--;
      cnt++;
    }
  }
  cnt.writeln;
}


Measured memory_bytes: 256
n,m = map(int,input().split())

a = [int(input()) for _ in range(m)]

dp_table = [0] * (n+1)

dp_table[0] = 1


#a[j]と考えるためのj
j = 0
for i in range(1,n+1):
    if j < m and i == a[j]:
        dp_table[i] = 0 #つまり変わらない
        j += 1
    elif i == 1:
        dp_table[i] = dp_table[i-1]
    else:
        dp_table[i] = dp_table[i-1] + dp_table[i-2]

print(dp_table[-1] % 1000000007)

Measured memory_bytes: 470520
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    int a, b, c; cin >> a >> b >> c;
    cout << min({a+b, b+c, a+c}) << endl;
}


Measured memory_bytes: 256
n, x = gets.chomp.split(" ").map(&:to_i)
n = n+1
hsh = {}
hsh[0] = [1, 1]
n.times do |i|
  if i == 0
    next
  end
  hsh[i] = [hsh[i-1][0] * 2+1, hsh[i-1][1]*2+3]
end
c = 0
idx = 0
n.times do |i|
  i = n - i - 1
  if i == 0
    if x > 0
      c += 1
    end
    break
  end

  if x == (hsh[i][1] -1)/2+1
    c += hsh[i-1][0]+1
    break
  elsif x > (hsh[i][1] -1)/2+1
    c += hsh[i-1][0]+1
    x = x -  ((hsh[i][1] -1)/2+1)
  elsif x < (hsh[i][1] -1)/2+1
     x = x -1
  end
end
puts c

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define maxn 500005
#define mod 1000000007
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<long long> vll;
typedef vector<bool> vb;
typedef set<int> si; 
#define fori(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,b,a) for(int i = (b); i >= (a); --i)
#define all(a) (a).begin(), (a).end()
#define __builtin_popcountll bitCountLL
#define __builtin_popcount bitCount
//__builtin_ctz 末尾0的个数, __builtin_clz 前导0的个数
//__builtin_ffs 最后一个1的位置
const int INF = 2e9;
const ll ML = 4e18;
ll Pow(ll x, ll p) {
    ll res = 1;
    while(p) {
        if(p & 1) res = (res * x) % mod;
        p >>= 1;
        x = (x * x ) % mod;
    }
    return res;
}
ll fac[maxn], inv[maxn];
void init() {
    fac[0] = fac[1] = 1;
    fori(i,2,maxn) fac[i] = (fac[i-1] * i) % mod;
    inv[maxn-1] = Pow(fac[maxn-1],mod-2);
    rep(i,maxn-2,0) inv[i] = (inv[i+1] * (i + 1)) % mod;
}
ll C(int a, int b) {
    return (fac[b] * inv[a] % mod * inv[b - a] % mod) % mod;
}
ll A(int a, int b) {
    return fac[b] * inv[b-a] % mod;
}
void solve() {
    int n,m;
   cin >> n >> m;
   //cout << A(n,m);
    ll ans = 0, flag = 1;
    fori(i,0,n+1) {
        ans = (mod + ans + flag * (A(n-i,m-i) * C(i,n) % mod)) % mod;
        flag *= -1;
    }
    ans = ans * A(n,m) % mod;
    cout << ans << endl;
}
int main() 
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    init();
    solve();
    return 0;
}

Measured memory_bytes: 11356
module IntPairMap = Map.Make (struct
  type t = int * int
  let compare = compare 
end)

let () = Scanf.scanf "%d %d\n" @@ fun n a ->
  let xs = Array.init n @@ fun _ ->
    Scanf.scanf "%d " @@ fun x -> x in
  let dp = 
    Array.fold_left (fun curr x ->
      IntPairMap.fold (fun (sum, n) count acc ->
        IntPairMap.add (sum + x, n + 1)
          (count + try IntPairMap.find (sum + x, n + 1) acc with Not_found -> 0) acc) curr curr) (IntPairMap.singleton (0, 0) 1) xs in
  Array.init n (fun i ->
    try IntPairMap.find (a * (i + 1), i + 1) dp with Not_found -> 0)
  |> Array.fold_left ( + ) 0
  |> Printf.printf "%d\n"



Measured memory_bytes: 7168
#define _USE_MATH_DEFINES

#include <iostream>
#include <math.h> 
#include <vector>
#include <algorithm>
#include <iomanip>      // std::setprecision
#include <map>
#include <unordered_map>
#include <string>
#include <set>

using namespace std;

namespace
{
	long long gcd(long long a, long long b)
	{
		if (a == 0)
			return b;
		return gcd(b%a, a);
	}

	// Function to calculate all common divisors 
	// of two given numbers 
	// a, b --> input integer numbers 
	std::vector<long long> commDiv(long long a, long long b)
	{
		// find gcd of a,b 
		long long n = gcd(a, b);
		std::vector<long long> common_div;
		// Count divisors of n. 
		long long result = 0;
		for (long long i = 1; i <= sqrt(n); i++)
		{
			// if 'i' is factor of n 
			if (n%i == 0)
			{
				// check if divisors are equal 
				if (n / i == i)
				{
					common_div.push_back(i);
				}
				else
				{
					common_div.push_back(i);
					common_div.push_back(n/i);
				}
			}
		}
		return common_div;
	}
}
int main()
{
	long long a, b;
	std::cin >> a >> b;
	std::vector<long long> common_div = commDiv(min(a,b), max(a,b));
	std::vector<long long> mask(common_div.size(), 0);
	std::sort(common_div.begin(), common_div.end());
	
	int sol = common_div.size();
	for (int i = common_div.size()-1; i >= 1; --i)
	{
		if (mask[i] == 0)
		{
			for (int j = i - 1; j >= 0; --j)
			{
				if (mask[j] == 0)
				{
					if (commDiv(common_div[i], common_div[j]).size() != 1)
					{
						mask[i] = 1;
						sol--;
						break;
					}
				}
			}
		}
	}
	
		std::cout << setprecision(10) << sol;	
}


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

int main() {
  std::string s, t, u;
  int a, b;
  std::cin >> s >> t >> a >> b >> u;
  if (s == u)
    a -= 1;
  else
    b -= 1;
  std::cout << a << " " << b << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int Selection(int *a,int n)
{
    int cnt=0;
    int minj;
    for(int i=0;i<n-1;++i)
    {
        minj=i;
        for(int j=i;j<n;++j)
        {
            if(a[j]<a[minj])
            {
                minj=j;
            }
        }
        swap(a[i],a[minj]);
        if(minj!=i)
        {
            cnt++;
        }
    }
    return cnt;
}
int main()
{
    int n;
    cin>>n;
    int a[105];
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
    }
    int cnt=Selection(a,n);
    for(int i=0;i<n;++i)
    {
        if(i>0)printf(" ");
printf("%d",a[i]);
    }
    cout<<endl;
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3244
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int A = nextInt();
		int B = nextInt();
		int C = nextInt();
		
		System.out.println(A+B>=C?"Yes":"No");

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int G[100001];
pair<int, int> E[200001];
pair<int, int>* P[100002];
int dfs(int A) {
	if (G[A] == 0) {
		int g = 0;
		G[A] = -1;
		for (auto p = P[A]; p < P[A + 1]; p++) {
			g ^= dfs((*p).second);
		}
		return G[A] = g + 1;
	}
	return 0;
}

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


	int N;
	cin >> N;
	for (int i = 0; i < N + N - 2; i += 2) {
		int x, y;
		cin >> x >> y;
		E[i] = mp(x, y);
		E[i + 1] = mp(y, x);
	}
	sort(E, E + N + N - 2);
	int k = 0;
	rep(i, N + N - 2) {
		if (k != E[i].first) {
			k++;
			P[k] = E + i;
		}
	}
	P[N + 1] = E + N + N - 2;

	dfs(1);

	if (G[1] - 1) co("Alice");
	else co("Bob");

	Would you please return 0;
}

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

typedef long long ll;
typedef long double ld;

ll cnt[1000005];

void dodaj(int l, int r, ll c){
    if(l > r) return;
    cnt[r+1] -= c;
    cnt[l] += c;
}

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

	int n, x, y;
	cin >> n >> x >> y;
	if(x > y) swap(x, y);
	for(int i=1; i<x; i++){
        dodaj(1, x-1-i, 1);
	}
	for(int i=y+1; i<=n; i++){
        dodaj(1, n-i, 1);
	}
    int sz = y-x+1;
    int tr = sz-1;
    int trdist = 0;
    while(tr >= 1){
        trdist++;
        if(tr == 1){
            dodaj(trdist, trdist, sz/2);
            dodaj(trdist+1, trdist+x-1, 1);
            dodaj(trdist+1, trdist+n-y, 1);
            tr--;
        }
        else{
            dodaj(trdist, trdist, sz);
            dodaj(trdist+1, trdist+x-1, 2);
            dodaj(trdist+1, trdist+n-y, 2);
            tr -= 2;
        }
    }
    dodaj(1, x-1, 1);
    dodaj(1, n-y, 1);
    for(int i=1; i<x; i++){
        dodaj(x-i+2, x-i+1+n-y, 1);
    }
    for(int i=1; i<n; i++){
        cnt[i] += cnt[i-1];
        cout << cnt[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
using namespace std;

#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=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    VI a(4);
    REP(i,4) cin >> a[i];
    sort(ALL(a));
    VI ok({1, 4, 7, 9});
    if (a == ok){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define GetAns(from, to, flag) a[from / M][from % M] = chr[flag][0], a[to / M][to % M] = chr[flag][1]
using namespace std;

const int inf = 0x3f3f3f3f;

struct edge {
	int to, cap;
	char flag; // 0: r -> l   1: u -> d
	edge(): flag(-1) {}
	edge(const int &t, const int &c, const char &f): to(t), cap(c), flag(f) {}
} ge[60000];
int n, m;
vector <int> gl[10010];
int depth[10010], q[10010];
int iter[10010];

int N, M;
char a[110][110];
char dir[4][2] = { 1, 0, 0, 1, -1, 0, 0, -1 };
char chr[4][2] = { 'v', '^', '>' , '<', '^', 'v', '<', '>' };
void AddEdge(const int &from, const int &to, const int &cap, const char &flag);
int MaxFlow(const int &from, const int &to);
int dfs(const int &from, const int &to, const int &flow);

int main() {
	scanf("%d%d", &N, &M);
	const int s = N * M, t = N * M + 1;
	for (int i = 0; i < N; ++i)
		scanf("%s", a[i]);

	for (int i = 0; i < N; ++i)
		for (int j = i & 1; j < M; j += 2)
			if (a[i][j] == '.') {
				if (i + 1 < N && a[i + 1][j] == '.')
					AddEdge(i * M + j, (i + 1) * M + j, 1, 0);
				if (j + 1 < M && a[i][j + 1] == '.')
					AddEdge(i * M + j, i * M + j + 1, 1, 1);
				if (i > 0 && a[i - 1][j] == '.')
					AddEdge(i * M + j, (i - 1) * M + j, 1, 2);
				if (j > 0 && a[i][j - 1] == '.')
					AddEdge(i * M + j, i * M + j - 1, 1, 3);
			}
	for (int i = 0; i < N; ++i)
		for (int j = 0; j < M; ++j)
			if (a[i][j] == '.')
				if (i + j & 1)
					AddEdge(i * M + j, t, a[i][j] == '.', -1);
				else
					AddEdge(s, i * M + j, a[i][j] == '.', -1);
	printf("%d\n", MaxFlow(s, t));

	for (int i = 0; ge[i].flag != -1; i += 2)
		if (!ge[i].cap)
			GetAns(ge[i ^ 1].to, ge[i].to, ge[i].flag);
	for (int i = 0; i < N; ++i)
		printf("%s\n", a[i]);
	return 0;
}


void AddEdge(const int &from, const int &to, const int &cap, const char &flag) {
	ge[m] = edge(to, cap, flag);
	gl[from].push_back(m++);
	ge[m] = edge(from, 0, -1);
	gl[to].push_back(m++);
}

int MaxFlow(const int &from, const int &to) {
	int flow = 0;
	while (true) {
		memset(depth, -1, sizeof(depth));
		depth[from] = 0;
		int h = 0, t = 1; q[h] = from;
		while (h < t) {
			int u = q[h++];
			for (int i = 0; i < gl[u].size(); ++i) {
				edge &e = ge[gl[u][i]];
				if (e.cap > 0 && depth[e.to] == -1)
					q[t++] = e.to, depth[e.to] = depth[u] + 1;
			}
		}
		if (depth[to] == -1)
			return flow;

		memset(iter, 0, sizeof(iter));
		int f;
		while (f = dfs(from, to, inf))
			flow += f;
	}
}

int dfs(const int &from, const int &to, const int &flow) {
	if (from == to)
		return flow;
	for (int &i = iter[from]; i < gl[from].size(); ++i) {
		edge &e = ge[gl[from][i]], &e1 = ge[gl[from][i] ^ 1];
		if (e.cap > 0 && depth[e.to] == depth[from] + 1) {
			int f = dfs(e.to, to, min(flow, e.cap));
			if (f) {
				e.cap -= f;
				e1.cap += f;
				return f;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 5412
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        System.out.println(A*B/LCM(A,B));

    }
    private static long LCM(long a, long b){
        if(a < b){
            long tmp = a;
            a = b;
            b = tmp;
        }
        if(a % b == 0){return b;}
        return LCM(b, a%b);
    }
}


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

int main() {
	// your code goes here
	int n;
	cin>>n;
	vector<int> dp(3);
	for(int i = 0; i<n; i++){
	
		vector<int>c(3);
		vector<int> temp_dp(3,0);
		cin>>c[0]>>c[1]>>c[2];
		
		for(int i = 0; i<3; i++){
			for(int j = 0; j<3; j++){
				if(i!=j){
					temp_dp[j] = max(temp_dp[j], dp[i]+c[j]);
				}
			}
		}
		dp = temp_dp;
	}
	//cout<<dp[0]<<dp[1]<<dp[2]<<endl;
	cout<< max({dp[0], dp[1], dp[2]})<<endl;
	return 0;
}

Measured memory_bytes: 256
def solve(d,c,s,k):
    last=[0]*27
    srate=[]
    ans=[]
    for i in range(1,d+1):
        a=0
        for j in range(1,27):
            a-=c[j-1]*(i-last[j])
        pa=0
        mlast=[0]*2
        for t in range(1,27):
            if s[i-1][t-1]+c[t-1]*(min(k*(k-1)/2,(366-d)*((366-d)-1)/2))>pa:
                mlast=[t,i]
                pa=s[i-1][t-1]+c[t-1]*(i-last[t])
        a+=pa
        last[mlast[0]]=mlast[1]           
        ans.append(mlast[0])
        srate.append(a)
    return [srate[-1]]+ans

def main():
    d=int(input())
    c=list(map(int,input().split()))
    s=[list(map(int,input().split())) for _ in range(d)]
    ans=[]
    for i in range(26):
        ans.append(solve(d,c,s,i))
    ans.sort(reverse=True)
    for i in ans[0][1:]:
        print(i)
    #print(srate[-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 9616
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s1,s2;
	getline(cin, s1);
	getline(cin, s2);
	int n = s1.size(), m = s2.size(),j;
	for (int i = 0; i < n; i++){
		if (s2[0] == s1[i])
		{
			int k = i;
			for (j = 0; j < m; j++){
				
				if (s2[j] != s1[k])
					break;
				k++;
				if (k == n)
					k = 0;
				
			}
			if (j == m)
			{
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
  
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N; cin >> N;
    vector<pair<ll, ll>> ba(N);
    
    for(int i=0; i<N; i++) cin >> ba[i].second >> ba[i].first;

    sort(ba.begin(), ba.end());
    int time = 0;

    for(int i=0; i<N; i++){
        if(time + ba[i].second <= ba[i].first){
            time += ba[i].second;
        } else {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 3328
import numpy as np
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))
n = int(input())
t = np.zeros(8,dtype=int)
count = 0
for i in range(n):
    b = int(input())
    for j in range(3):
        if a1[j] == b:
            a1[j] = 0
        if a2[j] == b:
            a2[j] = 0
        if a3[j] == b:
            a3[j] = 0
if a1[0] + a2[0] + a3[0] == 0:
    count +=1
if a1[1] + a2[1] + a3[1] == 0:
    count +=1
if a1[2] + a2[2] + a3[2] == 0:
    count +=1
if a1[0] + a1[1] + a1[2] == 0:
    count +=1
if a2[0] + a2[1] + a2[2] == 0:
    count +=1
if a3[0] + a3[1] + a3[2] == 0:
    count +=1
if a1[0] + a2[1] + a3[2] == 0:
    count +=1
if a3[0] + a2[1] + a1[2] == 0:
    count +=1
if count == 0:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 12488
#include<iostream>
#include<string>
#include <cstdlib>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include <iomanip>

// #pragma comment(linker, "/STACK:1024000000,1024000000")
// #define pi acos(-1)
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x7f7f7f7f //2139062143
#define INF1 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.141592653589793//23846264338327950254
#define pb push_back
#define ll long long
#define debug cout << "debug\n";
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
// ios::sync_with_stdio(false);cin.tie(NULL);
#define scai(x) scanf("%d", &x)
#define sca2i(x, y) scanf("%d %d", &x, &y)
#define scaf(x) scanf("%lf", &x)
#define sca2f(x, y) scanf("%lf %lf", &x, &y)
#define For(m,n) for (int i = m;  i < n; i++)

#define local
#ifdef local
#endif

#define MAX 10233
#define LCH(i) ((i) << 1)
#define RCH(i) ((i) << 1 | 1)

int main()
{
    int H, A;
    scai(H);
    scai(A);
    int ans = 0;
    ans = H/A;
    if (H%A)
    {
        ans++;
    }
    printf("%d\n", ans);
}


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

int main(){
  string S,T;
  cin >> S >> T;
  int N = S.size();
  int vvs[26][N];
  int vvt[26][N];
  

  for(char m = 'a';m <= 'z';m++){
    for(int i = 0;i < N;i++){
      if(S.at(i) == m){
        vvs[m - 'a'][i] = 1;
      }else{
        vvs[m - 'a'][i] = 0;
      }
      if(T.at(i) == m){
        vvt[m - 'a'][i] = 1;
      }else{
        vvt[m - 'a'][i] = 0;
      }
    }
  }
  int ok2 = 0;
  for(int i = 0;i < 26;i++){
    int ok3 = 0;
    for(int k = 0;k < 26;k++){
      int ok = 0;
      for(int j = 0;j < N;j++){
       if(vvs[i][j] == vvt[k][j]){
         ok++;
       }
      }
      if(ok == N){
        ok3++;
        break;
      }
    }
    if(ok3 == 1){
      ok2++;
    }
  }
  if(ok2 == 26){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N;
    cin >> N;
    ll Ai;
    set<ll> A;
    int dup=0;
    for(int i=0;i<N;i++){
        cin >> Ai;
        if(A.count(Ai)) dup++;
        A.insert(Ai);
    }
    cout<<(A.size()-dup%2)<<endl;

    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define vec vector
#define fi first
#define se second
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
#define bit(x) (1ll<<(x))

int main(){
	
	// ll testcase; cin >> testcase; rep(tc, testcase){ // comment out!
		
		string s;
		cin >> s;
		vec<ll> ss(s.size());
		rep(i,s.size()) ss[i] = s[i] - '0';
		
		ll res = 1e9;
		rep(i,s.size()-2){
			ll tmp=100*ss[i] + 10*ss[i+1] + ss[i+2];
			
			res = min(res, abs(tmp-753));
		}
		
		cout << res << endl;
	// } // comment out!
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
	int n, k, i;

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

	for (i = 1; i <= 30; i++)
		if ((int)pow(k, i - 1) <= n && n < (int)pow(k, i))
		{
			printf("%d" ,i);
			return 0;
		}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e9+5;
int32_t main(){
	/*ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    int n,W;
    cin>>n>>W;
    vector<int> value(n);
    vector<int> weight(n);
    for(int i = 0; i < n; i++) cin>>weight[i]>>value[i];
    int sum_value = 0;
    for(int i = 0; i < n; i++) sum_value += value[i];
    vector<int> dp(sum_value+1,INF);
    dp[0] = 0;
    //dp[i] = the min total weight of items with total value exactly equal to i
    for(int item = 0 ; item < n; item++){
        for(int value_already = sum_value-value[item]; value_already >= 0; value_already--){
            dp[value_already+value[item]] = min(dp[value_already+value[item]],dp[value_already]+weight[item]);
        }
    } 
   int ans = 0;
   for(int i = 0; i <= sum_value; i++){
        if(dp[i] <= W){
            ans = max(ans,i);
        }
   }
   cout<<ans;
}

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

int main()
{
    int n, k, a, b, c;
    cin >> n >> k;

    int long_dis = 0;

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

        if(i)
        {
            long_dis = max(long_dis, a - b);
            b = a;
        }
        else
            c = a;

        b = a;
    }

    long_dis = max(long_dis, ((n - b) + c));
    
    cout << (n - long_dis) << endl;

    return 0;
}


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

int n;
int res;

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i += 2) {
		int divs = 0;
		for (int j = 1; j <= i; j++)
			if (i % j == 0) divs++;
		if (divs == 8) res++;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#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;
  string s[252521];
  cin>>n;
  REP(i, n){
    cin>>s[i];
  }
  sort(s, s+n);
  int ans=1;
  REP(i, n-1){
    if(s[i]!=s[i+1]){
      ++ans;
    }
  }
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 11544
a=input()
b=[]
for i in range(a):
    b.append(input())
b.sort()
c=[]
pre=0
time=0
for i in b:
    if pre==i:
        time+=1
    else:
        if time%2==1:
            c.append(pre)
        pre=i
        time=1
if time%2!=0 and pre!=0:
    c.append(pre)
print len(c)

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n,a,b;
  cin >> n >> a >> b;

  vll h(n);
  REP(i, n)
    cin >> h[i];

  auto check = [&](ll cnt){
    ll sum = 0;
    REP(i, n){
      ll t = h[i]-b*cnt;
      sum += max(0LL, t)/(a-b);
      if(max(0LL, t)%(a-b)!=0)
        sum++;
    }

    return sum<=cnt;
  };

  ll ok = 1e9;
  ll ng = 0;
  while(ok-ng>1){
    ll mid = (ok+ng)/2;
    if(check(mid))
      ok = mid;
    else
      ng = mid;
  }

  cout << ok << endl;


}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  int n;cin>>n;
  if(n == 1)print("Hello World");
  else {
    int a,b;cin>>a>>b;
    print(a+b);
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());
		String S = sc.next();
		if(N%2!= 0) {
			System.out.println("No");
			return;
		}
		if(S.substring(0,N/2).equals(S.substring(N/2,N))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 26820
# -*- coding: utf-8 -*-
import numpy as np

N = int(input())
if (isinstance(N, int) != True) or (N < 1) or (N > 20):
    exit()
h = np.array([int(i) for i in input().split()])
if (np.any(h<1)==True) or (np.any(h>100)==True):
    exit()
c = 0
for j in range(len(h)):
    if j == 0:
        max = h[0]
        c += 1
        pass
    elif h[j] >= max:
        max = h[j]
        c += 1
print(c)


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

int main(){
    int n;
    cin>>n;
    
   
    int ans=0;
    for(int j=1;j<=n;j+=2){
        long double limit=sqrt(j);
        int honlimit=floor(limit);
        int cnt=0;
        for(int i=1;i<limit;i++){
            if(j%i==0){
                cnt+=1;
                
            }

        }
        if(honlimit==limit && j%honlimit==0 && cnt==4)ans+=0;
        else if(cnt==4)ans+=1;
        
    }
    cout<<ans<<endl;
}


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

inline bool check(ll a, ll b, ll c){ return a<b+c; }

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

  ll ans = 0;
  for(int i=0;i<n-2;i++){
    if(check(a[i],a[i+1],a[i+2])){
      for(int j=i+3;j<n-2;j++){
	if(check(a[j],a[j+1],a[j+2])){
	  ll sum = 0;
	  for(int k=0;k<3;k++)sum += a[i+k] + a[j+k];
	  ans = max(ans,sum);
	  goto END1;
	}
      }
    }
  }
 END1:;

  for(int i=0;i<n-5;i++){
    int comb = (1<<3)-1;
    while(comb < (1<<6)){
      vector<ll> A,B;
      for(int j=0;j<6;j++){
	if( (comb>>j)&1 )A.push_back(a[i+j]);
	else B.push_back(a[i+j]);
      }

      if(check(A[0],A[1],A[2]) && check(B[0],B[1],B[2])){
	ll sum = 0;
	for(int k=0;k<6;k++)sum += a[i+k];
	ans = max(ans,sum);
	goto END2;
      }

      int x = comb & -comb, y = comb + x;
      comb = ( ( (comb & ~y) /x ) >> 1) | y;
    }
  }

 END2: cout << ans << endl;
}

Measured memory_bytes: 1996
#include<algorithm> 
#include<cstdio>
#include<iostream>
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
const int maxn=1e5+50;
int n;
int to[maxn];
bool vis[maxn];
struct node
{
	int v,p;
	bool operator <(const node &other) const
	{
		return v<other.v;
	}
} a[maxn],b[maxn];
bool solve()
{
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	for(int i=1;i<=n;++i)
	{
		if(a[i].v>b[i].v)
		{
			return false;
		}
	} 
	for(int i=2;i<=n;++i)
	{
		if(a[i].v<=b[i-1].v)
		{
			return true;
		}
	}
	for(int i=1;i<=n;++i)
	{
		to[a[i].p]=b[i].p;
	}
	int u=1,cnt=1;
	vis[u]=1;
	while(!vis[to[u]])
	{
		u=to[u];
		vis[u]=1;
		++cnt;
	}
	return cnt!=n;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i].v);
		a[i].p=i;
	}
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&b[i].v);
		b[i].p=i;
	}
	puts(solve()?"Yes":"No");
	return 0;
}

Measured memory_bytes: 2304