akhauriyash/Code-Regression huggingface dataset:
import           Control.Applicative   ((<$>))
import           Data.Bits             (xor)
import           Data.Char             (isSpace)
import           Data.List             (foldl1', unfoldr)
import           Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as BSC8

getIL :: IO [Int]
getIL = unfoldr f <$> BSC8.getLine
  where
    -- f :: ByteString -> Maybe (Int, ByteString)
    f s = do
      (n, s') <- BSC8.readInt s
      return (n, BSC8.dropWhile isSpace s')

main :: IO ()
main = do
  BSC8.getLine
  ai <- getIL
  putStrLn $ unwords $ map show $ map (xor (foldl1' xor ai)) ai


Measured memory_bytes: 19944
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const ll INFL = (1LL << 62);
const ll MOD = 1000000007;
template <class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T>
ll mod_pow(ll a, ll n, T mod) {
    mod = (ll)mod;
    ll res = 1, p = a % mod;
    while (n) {
        if (n & 1) res = res * p % mod;
        p = p * p % mod;
        n >>= 1;
    }
    return res;
}
void print() { std::cout << std::endl; }
template <typename T, typename... A>
void print(const T& first, const A&... rest) {
    cout << sizeof...(rest) << endl;
    std::cout << first;
    if (sizeof...(rest)) std::cout << " ";
    print(rest...);
}
template <typename... A>
void print(const A&... rest) {
    print(rest...);
}
template <typename A>
void print(const std::vector<A>& v) {
    std::for_each(v.begin(), v.end(), [](A x) { std::cout << x << " "; });
    std::cout << std::endl;
}

bool isOk(const string& s, const string& t) {
    unordered_map<char, bool> str1;
    for (auto& c : s) {
        str1[c] = true;
    }
    for (auto& c : t) {
        if (!str1[c]) {
            return false;
        }
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    if (!isOk(s, t)) {
        cout << -1 << endl;
        return 0;
    }
    const ll N = s.size();
    unordered_map<char, vector<int>> index;
    rep(i, N) { index[s[i]].push_back(i); }
    ll l = 0LL;
    int id = index[t[0]].front();  // 1文字目
    const ll M = t.size();
    for (int i = 1; i < M; i++) {
        int j = upper_bound(all(index[t[i]]), id) - index[t[i]].begin();
        if (j == (int)index[t[i]].size()) {
            l++;
            id = index[t[i]][0];
        } else {
            id = index[t[i]][j];
        }
    }
    cout << (ll)(id + 1) + l * (ll)N << endl;

    return 0;
}

Measured memory_bytes: 1228
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e14 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug() {
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

bool isNumber(char c) {
    if(c >= '0' && c <= '9') return true;
    else return false;
}

string check(long long a, long long b, string s) {
    if(s[a] != '-') return "No";
    for(long long i = 0; i <= a + b; i++) {
        if(i == a) continue;
        if(!isNumber(s[i])) return "No";
    }
    return "Yes";
}

int main() {
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    long long a, b; cin >> a >> b;
    string s; cin >> s;

    cout << check(a, b, s);

    return 0;
}


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

int main(){
    using namespace std;
    unsigned long N, K;
    cin >> N >> K;
    unsigned long ans{0};
    ++N;
    for(unsigned long i{K}; i <= N; ++i)(ans += i * (N - i) + 1) %= 1000000007;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <math.h>
int main(int argc, char *argv[])
{
	int n,num,count=0,i,j,flag=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&num);
		if(num==2||num==3)
		{
			count++;
			continue;
		}
		for(j=2;j<=sqrt(num);j++)
		if(num%j==0)
		{
		flag=1;	
		break;
		}
		
		if(flag==0)
		count++;
		flag=0;
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 1816
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=104;
int n,a[N],ans;
inline bool ok(int i,int j,int k) {
	if (a[i]^a[j]&&a[j]^a[k]&&a[k]^a[i]&&a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i]) {
//		printf("%d %d %d\n",i,j,k);
		return true;
	}
	return false;
}
int main() {
	cin>>n;
	for (int i=1;i<=n;++i) cin>>a[i];
	for (int i=1;i<n-1;++i)
		for (int j=i+1;j<n;++j)
			for (int k=j+1;k<=n;++k)
				ans+=ok(i,j,k);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3556
S = input()
if S =="SUN":
  print(7)
elif S =="MON":
  print(6)
elif S =="TUE":
  print(5)
elif S =="WED":
  print(4)
elif S =="THU":
  print(3)
elif S =="FRI":
  print(2)
elif S=="SAT":
  print(1)

Measured memory_bytes: 3060
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
 
def isfeasible(L):
  k = 0
  for a in A:
    if a < L:
      break
    if a%L == 0:
      dk = a//L - 1
    else:
      dk = a//L
    k += dk
    if k > K:
      return False
  return True
 
l = 0
r = A[0]

while r-l>1:
  L = (r+l)//2
  if isfeasible(L):
    r = L
  else:
    l = L
print(r)

Measured memory_bytes: 30876
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();

    int[] H = new int[N];

    for (int i = 0; i < N; i++) {
      H[i] = sc.nextInt();
    }

    sc.close();

    String result = "Yes";

    for (int i = N - 1; 0 < i; i--) {
      if (H[i] < H[i - 1]) {
        if (H[i - 1] - H[i] <= 1) {
          H[i - 1] -= H[i - 1] - H[i];
        } else {
          result = "No";
          break;
        }
      }
    }

    System.out.println(result);

  }

}

Measured memory_bytes: 50636
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int n = nextInt();
		long[][] rank = new long[n][4];

		for(int i=0;i<n;i++) {
			long[] a = Long_ASCII(next());
			rank[i][0] = a[0];
			rank[i][1] = a[1];
			rank[i][2] = nextLong();
			rank[i][3] = i;
		}
		sc.close();

		Arrays.sort(rank,(a1,a2)->Long.compare(a2[2],a1[2]));
		Arrays.sort(rank,(a1,a2)->Long.compare(a1[1],a2[1]));
		Arrays.sort(rank,(a1,a2)->Long.compare(a1[0],a2[0]));
		//for(int i=0;i<n;i++)out.println(rank[i][0]+" "+rank[i][1]+" "+rank[i][2]);

		for(int i=0;i<n;i++) {
			out.println(rank[i][3]+1);
		}
	}

	//ASCIICodesに変換して結合し返す a[0]:asciiCodes[0]~[8]  a[1]:asciiCodes[9]~[17]
	private long[] Long_ASCII(String s) {
		 byte[] asciiCodes = null;
	        String sampleString = s;
	        try {
	            asciiCodes = sampleString.getBytes("US-ASCII");
	        } catch (Exception e) {
	            e.printStackTrace();
	        }
	        long[] a = new long[2];
	        for (int i=0;i<asciiCodes.length&&i<10-1;i++) {
	        	a[0] *= 100;
	        	a[0] += asciiCodes[i]-85;
	        }
	        if(asciiCodes.length>=10) {
	        	for(int i=9;i<asciiCodes.length;i++) {
	        		a[1] *= 100;
	        		a[1] = asciiCodes[asciiCodes.length-1]-85;
	        	}
	        }
	        while(true) {
	        	if(a[0] > 100_000_000_000_000_000L-1)break;
	        	a[0]*=10;
	        }
		return a;
	}

	private static int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	private static long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	private static int nextInt() {
		return Integer.parseInt(next());
	}
	private static long nextLong() {
		return Long.parseLong(next());
	}
	private static String next() {
		return sc.next();
	}

}

Measured memory_bytes: 26708
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	T := nextInt()
	X := nextInt()

	fmt.Println(float64(T)/float64(X))
}

Measured memory_bytes: 640
import java.util.*;
import java.io.*;
import static java.lang.System.in;

public class Main {
    static ArrayList<Integer>[] rec;
    static int[] tar;
    static int A,B,C;
    public static void main(String[] args)throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        A = sc.nextInt(); B = sc.nextInt(); C = sc.nextInt();
        int[] len = new int[n];
        for(int i=0;i<n;i++) len[i]=sc.nextInt();
        Arrays.sort(len);
        tar = new int[]{C,B,A};
        int ans = Integer.MAX_VALUE/2;
        for(int i=0;i<=n-3;i++){
            ans = Math.min(ans,solve(len,i));
        }
        System.out.println(ans);
    }
    static int solve(int[] len, int numOf){
        if(numOf==0){
            ArrayList<Integer> dic = new ArrayList<>();
            for(int w:len){
                if(w>0) dic.add(w);
            }
            int[] res = new int[3];
            Collections.sort(dic);
            Arrays.fill(res,Integer.MAX_VALUE/2);
            for(int pass=0;pass<3;pass++){
                int idx = -1;
                for(int i=0;i<dic.size();i++){
                    if(Math.abs(res[pass]-tar[pass])>Math.abs(dic.get(i)-tar[pass])){
                        res[pass] = dic.get(i);
                        idx = i;
                    }
                }
                dic.remove(idx);
            }
            int ans = 0;
            for(int i=0;i<3;i++) ans += Math.abs(res[i]-tar[i]);
            return ans;
        }
        int[] backup = new int[len.length];
        System.arraycopy(len,0,backup,0,len.length);
        int ans = Integer.MAX_VALUE;
        for(int i=0;i<len.length;i++){
            if(len[i]<0) continue;
            for(int j=i+1;j<len.length;j++){
                if(len[j]<0) continue;
                len[i] += len[j];
                len[j] = -1;
                ans = Math.min(ans,solve(len,numOf-1)+10);
                System.arraycopy(backup,0,len,0,len.length);
            }
        }
        return ans;
    }
}

Measured memory_bytes: 70776
import sys
read = sys.stdin.readline

n = int(read())
V = 1001000

g = [[] for _ in range(V)]
deg = [0] * V
vlist = set()

for i in range(1, n + 1):
    a = list(map(int, read().rstrip().split()))
    for j in range(n - 2):
        v1 = min(i, a[j]) * 1001 + max(i, a[j])
        v2 = min(i, a[j + 1]) * 1001 + max(i, a[j + 1])
        vlist.add(v1)
        vlist.add(v2)
        g[v1].append(v2)
        deg[v2] += 1

d = [0] * V
check_cnt = 0
q = []
for v in vlist:
    if deg[v] == 0:
        q.append(v)

if len(q) == 0:
    print(-1)
    exit()

for v in q:
    check_cnt += 1
    for nv in g[v]:
        d[nv] = max(d[nv], d[v] + 1)
        deg[nv] -= 1
        if deg[nv] == 0:
            q.append(nv)
if check_cnt == n * (n - 1) // 2:
    print(max(d) + 1)
else:
    print(-1)


Measured memory_bytes: 244696
/**/

#include <bits/stdc++.h>

using namespace std;

int N, M, P;
vector<tuple<int, int, long long>> grafo;
long long resp;

void BellmanFord(int inicio)
{
     vector<long long> distancia(N + 1, LONG_LONG_MAX);
     distancia[inicio] = 0;

     //Verifica o looping negativo (não há máximo)
     vector<bool> verifica(N + 1, false);
     verifica[N] = true;

     int primeiro, segundo;
     long long moedas;

     //Verifica o máximo possível, exceto os casos de looping negativo
     for (int i = 1; i < N; i++)
     {
          for (int j = 0; j < M; j++)
          {
               tie(primeiro, segundo, moedas) = grafo[j];

               if (distancia[primeiro] != LONG_LONG_MAX &&
                   distancia[primeiro] + moedas < distancia[segundo])
               {
                    distancia[segundo] = distancia[primeiro] + moedas;
               }

               //Salvando o vértice percorrido
               if(verifica[segundo] == true)
               {
                    verifica[primeiro] = true;
               }
          }
     }

     //Salvando a resposta máxima atual
     resp = max((long long)0, -distancia[N]);

     //Percorrendo o grafo e verificando se há o looping negativo
     for(int i = 0; i < M; i++)
     {
          tie(primeiro, segundo, moedas) = grafo[i];

          if (distancia[primeiro] != LONG_LONG_MAX &&
              distancia[primeiro] + moedas < distancia[segundo] &&
              verifica[segundo] == true)
          {
               //Looping negativo = impossível
               resp = -1;
               break;
          }     
     }
     

}

int main()
{
     cin >> N >> M >> P;

     for (int i = 0; i < M; i++)
     {
          int primeiro, segundo;
          long long moedas;
          cin >> primeiro >> segundo >> moedas;

          grafo.push_back({primeiro, segundo, P - moedas});
     }

     BellmanFord(1);
     cout << resp << endl;

     return 0;
}

Measured memory_bytes: 3632
let () =
    let split s =
        let rec loop i cur flag acc =
            if i = String.length s then (
                if flag then cur :: acc else acc
            ) else (
                match flag, s.[i] with
                | true,  ' ' -> loop (i + 1) 0 false (cur :: acc)
                | false, ' ' -> loop (i + 1) 0 false acc
                | true,  v   -> loop (i + 1) (cur * 10 + int_of_char v - 48) true acc
                | false, v   -> loop (i + 1) (cur * 10 + int_of_char v - 48) true acc
            )
        in
        List.rev (loop 0 0 false [])
    in
    let main () =
        let _ = int_of_string (read_line ()) in
        let w = split (read_line ()) in
        let s = List.fold_left (+) 0 w in
        let rec loop acc m = function
            | [] -> m
            | hd :: tl -> 
                let acc = acc + hd in
                let m = min (abs (s - 2 * acc)) m in
                loop acc m tl
        in
        Printf.printf "%d\n" (loop 0 100000000 w)
    in
    main ()

Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  ll a[100005];
  a[0]=0; a[1]=1;
  rep(i,100003){
    a[i+2]=(a[i+1]+a[i])%modbig;
  }
  ll n,m;
  cin>>n>>m;
  ll cant[m];
  if(m==0){
    cout<<a[n+1];
  }else{
    rep(i,m){
      cin>>cant[i];
    }
    ll ans=(a[n-cant[m-1]]*a[cant[0]])%modbig;
    for(int i=0;i<m-1;i++){
      ans=(ans*a[cant[i+1]-cant[i]-1])%modbig;
    }
    cout<<ans;
  }
}


Measured memory_bytes: 1792
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<ll, ll>
#define pll pair<ll, ll>
#define pli pair<ll, ll> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 1000000007
using namespace std;

int main(){
	FASTIO
	int n;
	cin >> n;
	n >= 30 ? cout << "Yes" : cout << "No";
	
    return 0;
}

Measured memory_bytes: 3648
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] road = new int[n];
        Arrays.fill(road, 0);

        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();

            road[a - 1]++;
            road[b - 1]++;
        }

        for (int i = 0; i < n; i++) {
            System.out.println(road[i]);
        }
    }
}


Measured memory_bytes: 21844
s = input()

a = int(s[:2])
b = int(s[2:])


if 0 < a <= 12:
    if 0 < b <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 0 < b <= 12:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main(void)
{
    char input;

	cin >> input;

	switch(input)
	{
		case 'a':
		case 'i':
		case 'u':
		case 'e':
		case 'o':
		cout << "vowel" << endl;
		break;
	default:
		cout << "consonant" << endl;
		break;
	}

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <complex>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second

typedef complex<double> P;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const double L = 100.0;
const double PI = 3.14159265358979323846;

vector <P> ans;

int N;

void rec(P lp, P rp, int n) {
    if (n == 0) {
        ans.pb(lp);
        return;
    }
    P s, t, u, a;
    s = lp + (rp - lp) / 3.;
    t = lp + (rp - lp) * 2. / 3.;
    a = polar(abs(rp-lp)/3, arg(rp-lp) + PI/3.);
    u = s + a;
    rec(lp, s, n-1);
    rec(s, u, n-1);
    rec(u, t, n-1);
    rec(t, rp, n-1);
}



void solve(void){
    cin >> N;
    P p1(0., 0.);
    P p2(L, 0.);

    rec(p1, p2, N);
    ans.pb(p2);

    for (auto p : ans) {
        printf("%.6lf %.6lf\n", p.real(), p.imag());
    }

}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}



Measured memory_bytes: 3700
#include <stdio.h>

int main(){
    int h, w;
    int i, j;
    while(1){
        scanf("%d %d ", &h, &w);
        if(h==0&&w==0)break;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                if(i==0||i==h-1||j==0||j==w-1){
                    printf("#");
                }else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 2656
import java.util.*;

public class Main {

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

		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			int[] a = new int[n];
			int[] b = new int[n];
			
			for(int i=0;i<n;i++){
				a[i] = sc.nextInt();
				b[i] = 60*sc.nextInt() + sc.nextInt() + 60*sc.nextInt() + sc.nextInt()
						+ 60*sc.nextInt() + sc.nextInt() + 60*sc.nextInt() + sc.nextInt();
			}
			int[] c = b.clone();
			Arrays.sort(c);
			int[] ans = new int[3];

			for(int i=0;i<n;i++){
				if(b[i]==c[0]) ans[0] = a[i];
				else if(b[i]==c[1]) ans[1] = a[i];
				else if(b[i]==c[n-2]) ans[2] = a[i];
			}
			for(int i=0;i<3;i++) System.out.println(ans[i]);
		}
	}
}

Measured memory_bytes: 62776
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  
  vector<char> vec(W);
  
  for (int k = 0; k < W + 2; k++) {
    cout << "#";
    if (k == W + 1)
      cout << endl;
  }
  
  for (int i = 0; i < H; i++) {
    cout << "#" ;
    
    for (int j = 0; j < W; j++) {
      cin >> vec.at(j);
      cout << vec.at(j);
    }
    
    cout << "#" << endl;
  }
  
  for (int l = 0; l < W + 2; l++) {
    cout << "#";
    if (l == W + 1)
      cout << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const ld pi = 3.14159265358;
typedef pair<ll,ll> P;
using graph = vector<vector<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;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    ll ans = 0;
    vector<ll> now(N),to(N);
    rep(i,N)cin >> to[i];
    for(ll i = N;i > 0;i--){
        ll cnt = 0;
        for(ll j = i;j <= N;j += i){
            if(now[j - 1])cnt ^= 1;
        }
        if(cnt != to[i - 1]){
            ans++;
            now[i - 1] ^= 1;
        }
    }
    cout << ans << endl;
    ll cnt = 0;
    rep(i,N){
        if(now[i]){
            cout << i + 1;
            if(cnt != ans - 1){
                cout << " ";
                cnt++;
            }
            else cout << "\n";
        }
    }
    //rep(i,N)cout << now[i] << endl;
}

Measured memory_bytes: 6368
#include "bits/stdc++.h" 
using namespace std;
long long n, m, mon, mmon, mmmon, bmon, bmmon, bmmmon;
bool fi;
vector<int>a(100005), b(100005);
int main() {
	cin >> n;
	vector<int> a(100001);
	vector<int> b(100001);
	for (int i = 0; i < n; i++) {
		cin >> m;
		if (i % 2) a[m]++;
		else b[m]++;
	}

	for (int i = 0; i <= 100000; i++) {
		if (a[i] > mmon) {
			if (a[i] > mon) {
				mmon = mon;
				mon = a[i];
				mmmon = i;
			}
			else {
				mmon = a[i];
			}
		}
		if (b[i] > bmmon) {
			if (b[i] > bmon) {
				bmmon = bmon;
				bmon = b[i];
				bmmmon = i;
			}
			else {
				bmmon = b[i];
			}
		}
	}
	cout << ((mmmon != bmmmon) ? n - mon - bmon : min(n - mon - bmmon, n - mmon - bmon)) << endl;
}

Measured memory_bytes: 1792
#include <string>
#include <iostream>
using namespace std;
unsigned long long power(int a, int b) {
	unsigned long long ret = 1;
	for(int i = 0; i < b; i++) ret *= a;
	return ret;
}
unsigned n, t; string s;
int main() {
	cin >> n >> t >> s;
	if(n == 1000000000 && s != "n^0" && s != "n^1") { cout << "TLE" << endl; return 0; }
	unsigned long long ret = 0;
	for(int i = 0; i < s.size(); i += 4) {
		ret += power(n, s[i + 2] - 48) * t;
	}
	if(ret > 1000000000ULL) cout << "TLE" << endl;
	else cout << ret << endl;
}

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

using namespace std;

priority_queue<long long> pq;
long long ans[100005];

int main()
{
    int n;
    scanf("%d",&n);
    int i;
    for(i=0;i<n;i++)
    {
        long long t1;
        scanf("%lld",&t1);
        pq.push(t1);
    }
    long long before;
    before = 0;
    int c = 0;
    while(!pq.empty())
    {
        long long now = pq.top(); pq.pop();
        if(now == before)
        {
            before = 0;
            ans[c++] = now;
        }
        else before = now;
    }
    long long ans1 = ans[0]*ans[1];
    printf("%lld",ans1);
}


Measured memory_bytes: 1524
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define NUM_OF_TREASURE 21

int main(void){
	int i,j,x,y,pos_x,pos_y,count;
	int N,M,step,length;
	int **jewel;
	char direction, buf[6];

	jewel = (int **)calloc(NUM_OF_TREASURE,sizeof(int *));
	for(i=0;i<NUM_OF_TREASURE;i++){
		jewel[i] = (int *)calloc(NUM_OF_TREASURE,sizeof(int));
	}

	while(scanf("%d",&N)!=EOF){
		if(N==0)break;
		for(i=0;i<NUM_OF_TREASURE;i++){
			for(j=0;j<NUM_OF_TREASURE;j++) jewel[i][j]=0;
		}
		for(i=0;i<N;i++){
			scanf("%d %d",&x,&y);
			jewel[x][y]+=1;
		}
		scanf("%d",&M);
		fgets(buf,sizeof(buf),stdin);

		pos_x=pos_y=10;
		count=0;
		for(i=0;i<M;i++){
			fgets(buf,sizeof(buf),stdin);
			length = strlen(buf);
			buf[length-1]='\0';
			direction=buf[0];

			if(length==4) step=buf[2]-'0';
			else if(length==5) step=(buf[2]-'0')*10 + buf[3]-'0';

			for(j=1;j<=step;j++){
				switch(direction){
				case 'N':
					pos_y++;
					break;
				case 'S':
					pos_y--;
					break;
				case 'E':
					pos_x++;
					break;
				case 'W':
					pos_x--;
					break;
				default:
					break;
				}
				if(jewel[pos_x][pos_y]==1){
					count++;
					jewel[pos_x][pos_y]=0;
				}
			}
		}

		if(count==N) printf("Yes\n");
		else printf("No\n");
	}

	for(i=0;i<NUM_OF_TREASURE;i++){
		free(jewel[i]);
	}
	free(jewel);

	return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
        String str = scan.next();
        int ans = 700;
        for (char c: str.toCharArray()) {
        	if (c == 'o')
        		ans += 100;
        }
        System.out.println(ans);
	}
	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n;cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    ll kxor=0,kplus=0;
    ll l=0,r=0;
    ll ans=0;
    rep(r,n){
        kxor^=a[r];
        kplus+=a[r];
        while(kxor!=kplus){
            kxor^=a[l];
            kplus-=a[l];
            l++;
        }
        ans+=r-l+1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define MAX 100005

int V,E;
vector<int> G[MAX];

int depth[MAX];
int cnt[MAX];
int visited[MAX];

vector<P> ans;

void dfs(int pos,int prev){
  visited[pos]=true;
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    if(to==prev)continue;
    if(!visited[to]){
      depth[to]=depth[pos]+1;
      dfs(to,pos);
      cnt[pos]+=cnt[to];
      if(cnt[to]==0)ans.push_back( P( min(pos,to) , max(pos,to) ) );
    }else if(depth[to]<depth[pos]){
      cnt[pos]++;
      cnt[to]--;
    }
  }
}

int main(){
  scanf("%d %d",&V,&E);
  for(int i=0;i<E;i++){
    int a,b;
    scanf("%d %d",&a,&b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(0,-1);
  sort(ans.begin(),ans.end());
  
  for(int i=0;i<(int)ans.size();i++)
    printf("%d %d\n",ans[i].first,ans[i].second);
  return 0;
}

Measured memory_bytes: 5348
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const ll MAX = 1e+12 + 1;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
ll g(ll x) {
    ll ans = ((x + 1) / 2 ) % 2;
    ans ^= ((x + 1) % 2) * x;
    return ans;
}
/* main */
int main(){
    ll A, B;
    cin >> A >> B;
    cout << (g(B) ^ g(A - 1)) << '\n';
}


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

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)

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

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string S, T;
  cin >> S >> T;
  S = " " + S;
  T = " " + T;
  vvl dp = VVL(S.size(), T.size(), 0);
  FOR(si, 1, S.size()) {
    FOR(ti, 1, T.size())
    if (S[si] == T[ti])
      dp[si][ti] = dp[si - 1][ti - 1] + 1;
    else
      dp[si][ti] = max(dp[si - 1][ti], dp[si][ti - 1]);
  }
  string ans = "";
  ll x = (ll)S.size() - 1;
  ll y = (ll)T.size() - 1;
  while (x > 0 && y > 0) {
    if (dp[x][y] == dp[x - 1][y])
      x--;
    else if (dp[x][y] == dp[x][y - 1])
      y--;
    else {
      ans = S[x] + ans;
      x--;
      y--;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 70784
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	S = IS()
	Q = II()
	c = 0
	head=[]
	tail=[]
	for _  in range(Q):
		query = IS()
		if(len(query)==1):
			c = (c + 1)%2
		else:
			T,F,C = query.split()
			T = int(T)
			F = int(F)
			if F==1:
				if(c==0):
					head.append(C)
				else:
					tail.append(C)
			else:
				if(c==1):
					head.append(C)
				else:
					tail.append(C)
	if c == 0:
		head = ''.join(head[::-1])
		tail = ''.join(tail)
		ans = head+S+tail
	else:
		head = ''.join(head)
		tail = "".join(tail[::-1])
		ns = S[::-1]
		ans = tail+ns+head
	print(ans)




if __name__ == '__main__':
	main()

Measured memory_bytes: 6372
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,a;
	cin>>n;
	
	if(n%2==0) 
	a=n/2;
	if(n%2==1)
	a=(n-1)/2+1;
	
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c[200005],n,d,ans,l,k;
struct node
{
    long long x,y;
} w[200005];
inline bool cmp(node x,node y)
{
    return x.x<y.x;
}
int main()
{
    scanf("%lld%lld%lld",&n,&d,&a);
    d*=2;
    for(int i=1; i<=n; ++i)
    {
        scanf("%lld%lld",&w[i].x,&w[i].y);
        w[i].y=(w[i].y+a-1)/a;
    }
    sort(w+1,w+n+1,cmp);
    l=1;
    for(int i=1; i<=n; ++i)
    {
        while(l<i&&w[i].x-w[l].x>d)
        {
            k-=c[l++];
        }
        c[i]=w[i].y-k;
        if(c[i]<0)c[i]=0;
        ans+=c[i];
        k+=c[i];
    }
    printf("%lld",ans);
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long double ld;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

int c[55][55];
bool v[55][55];

void solve(){

    int w,h;
    vector<int> a;

    while(true){
        cin >> w >> h;
        if(w==0&&h==0) break;
        rep(i,h){
            rep(j,w){
                v[i][j]=false;
            }
        }
        rep(i,h) v[i][w]=true;
        rep(j,w) v[h][j]=true;
        v[h][w]=true;

        rep(i,h){
            rep(j,w){
                cin >> c[i][j]; 
                if(c[i][j]==0) v[i][j]=true;
            }
        }

        int ans=0;
            
            rep(i,h){
                rep(j,w){
                    if(!v[i][j]) {
                        stack<pair<int,int>> st;
                        st.push(make_pair(i,j));
                        while(!st.empty()){
                            int ti = st.top().first;
                            int tj = st.top().second;
                            st.pop();
                            v[ti][tj]=true;
                            
                            if(v[ti+1][tj]==false) st.push(make_pair(ti+1,tj));
                            if(v[ti][tj+1]==false) st.push(make_pair(ti,tj+1));
                            if(ti>0) {if(v[ti-1][tj]==false) st.push(make_pair(ti-1,tj));}
                            if(tj>0) {if(v[ti][tj-1]==false) st.push(make_pair(ti,tj-1));}
                            if(v[ti+1][tj+1]==false) st.push(make_pair(ti+1,tj+1));
                            if(ti>0) {if(v[ti-1][tj+1]==false) st.push(make_pair(ti-1,tj+1));}
                            if(tj>0) {if(v[ti+1][tj-1]==false) st.push(make_pair(ti+1,tj-1));}
                            if(ti>0&&tj>0) {if(v[ti-1][tj-1]==false) st.push(make_pair(ti-1,tj-1));}
                            
                        }
                        ans++;
                    }
                }
            }

        a.emplace_back(ans);
        


    }

    for(auto e:a){
        cout << e << endl;
    }

}

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



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

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

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    int ans = 0;
    for(int i = 0; i < n - 1; i++){
        ans += (s[i] == s[i + 1]);
    }

    cout << min(ans + 2 * k, n - 1) << endl;

    return 0;
}

Measured memory_bytes: 512
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        for(int i = 0 ; i < 3 ;i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        System.out.println(a[0] + a[1]);
    }
}

Measured memory_bytes: 35692
#include <iostream>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <string>
#include <cstdio>
#include <cstring>
#include <assert.h>
#include <functional>
#define  lowbit(x) (x&(-x))
#define  ll long long
#define  ull unsigned long long
#define  max(a,b) (a>b?a:b)
#define  min(a,b) (a>b?b:a)
#define  PI acos(-1.0)
#define  fir first
#define  sec second
#define  SZ(x) (x.size())
#define  inf 0x3f3f3f3f
#define  PB push_back
#define  MP make_pair
#define  all(x) (x).begin(),(x).end()
#define  PII pair<int,int>
#define  E 2.7182818284590452353602874713527
using namespace std;

/**********************************************Head-----Template****************************************/
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

const ll mod = 9901;
ll ksm(ll a,ll b){ll ans=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1) ans=ans*a%mod;a=a*a%mod;}return ans;}
/********************************Head----Template**********************************************/

bool judge(string ss){
    int k1=0,k2=0,k3=0;
    for(int i=0;i<ss.size();i++){
        if(ss[i]=='c') k1=1;
        if(ss[i]=='o') k2=1;
        if(ss[i]=='w') k3=1;
    }
    return k1&&k2&&k3;
}

int main (){
    int a,b,c;cin>>a>>b>>c;
    printf("%d\n",c/a*b);
    return 0;
}



Measured memory_bytes: 256
let last_i = ref 0

let parent i = int_of_float (floor (float_of_int i) /. 2.)

let left i = 2*i

let right i = 2*i + 1

let swap i j t = let tmp = t.(i) in t.(i) <- t.(j); t.(j) <- tmp

let extract (t : int array) =
  let ret = t.(1) in
  t.(1) <- t.(!last_i);
  decr last_i;
  let rec max_heapify i =
    let l = left i in
    let r = right i in
    let m = if l <= !last_i && t.(l) > t.(i) then l else i in
    let m = if r <= !last_i && t.(r) > t.(m) then r else m in
    if i = m then ()
    else begin
      let tmp = t.(i) in t.(i) <- t.(m); t.(m) <- tmp;
      max_heapify m
    end in
  max_heapify 1;
  ret

let insert x (t : int array) =
  incr last_i;
  t.(!last_i) <- x;
  let rec doit i =
    if i <= 1 || t.(parent i) >= t.(i) then ()
    else begin
      let pi = parent i in
      let tmp = t.(i) in t.(i) <- t.(pi); t.(pi) <- tmp;
      doit pi
    end in
  doit !last_i

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let t = Array.make 2000001 0 in
  while true do
    match read_line () |> split_on_char ' ' with
    | ["extract"] -> print_int (extract t); print_newline ()
    | ["insert"; n] -> insert (int_of_string n) t
    | _ -> exit 0
  done

Measured memory_bytes: 20212
n = int(input())
s = list(map(int, input().split()))

divide_num = 0

def all_even(s):
    for i in s:
        # 奇数
        if i % 2 == 1:
            return False
    return True

while all_even(s):
    for i in range(n):
        s[i] /= 2
    divide_num += 1

print(divide_num)


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j

int main() {
  int N, A, B, C, D;
  string S;
  cin >> N >> A >> B >> C >> D;
  A--; B--; C--; D--;
  cin >> S;
  vector<int> vecS(N);
  rep(i, 0, N) {
    char ch = S[i];
    if (ch == '.') {
      vecS[i] = 0;
    } else vecS[i] = 1;
  }

  if (C < D) {
    bool flag = true;
    rep(i, A, D) {
      if (vecS[i] == 1 && vecS[i + 1] == 1) {
        flag = false;
        break;
      }
    }
    if (flag) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
    return 0;
  } else {
    bool flag1 = true;

    rep(i, A, C) {
      if (vecS[i] == 1 && vecS[i + 1] == 1) {
        flag1 = false;
        break;
      }
    }
    if (!flag1) {
      cout << "No" << endl;
      return 0;
    }

    bool flag = false;
    rep(i, B, D + 1) {
      if (vecS[i - 1] == 0 && vecS[i] == 0 && vecS[i + 1] == 0) {
        flag = true;
        break;
      }
    }
    if (flag) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
    return 0;
  }
};


Measured memory_bytes: 1284
using System;
using System.IO;

class Program{
    static void Main(string[] args){
        var arr = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var K = arr[0];
        var N = arr[1];
        var A = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var longest = 0;
        for (int i = 0; i < N - 1; i++){
            if (longest >= A[i + 1] - A[i]) continue;
            longest = A[i + 1] - A[i];}
        if (A[0] + K - A[^1] > longest) longest = A[0] + K - A[^1];
        var answer = K - longest;
        var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 42984
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;

int main(){
    string s,t;
    cin >> s >> t;

    int cnt = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] != t[i]){
            cnt++;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3908
local mfl, mce, mmi = math.floor, math.ceil, math.min
local SegTree = {}
SegTree.updateAll = function(self)
  for i = self.stagenum - 1, 1, -1 do
    for j = 1, self.cnt[i] do
      self.stage[i][j] = self.stage[i + 1][j * 2 - 1] + self.stage[i + 1][j * 2]
    end
  end
end
SegTree.create = function(self, n)
  self.emptyvalue = 0
  local stagenum, mul = 1, 1
  self.cnt, self.stage, self.size = {1}, {{}}, {}
  while mul < n do
    mul, stagenum = mul * 2, stagenum + 1
    self.cnt[stagenum], self.stage[stagenum] = mul, {}
  end
  for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end
  self.stagenum = stagenum
  for i = 1, mul do self.stage[stagenum][i] = 0 end
  self:updateAll()
end
SegTree.getRange = function(self, left, right)
  if left == right then return self.stage[self.stagenum][left] end
  local start_stage = 1
  while right - left + 1 < self.size[start_stage] do
    start_stage = start_stage + 1
  end
  local ret = self.emptyvalue
  local tasks = {{start_stage, left, right}}
  while 0 < #tasks do
    local task = tasks[#tasks]
    table.remove(tasks)
    local stage, l, r = task[1], task[2], task[3]
    if (l - 1) % self.size[stage] ~= 0 then
      local newr = mce((l - 1) / self.size[stage]) * self.size[stage]
      table.insert(tasks, {stage + 1, l, mmi(r, newr)})
      l = newr + 1
    end
    if self.size[stage] <= r + 1 - l then
      local pos = mce(l / self.size[stage])
      ret = ret + self.stage[stage][pos]
      l = l + self.size[stage]
    end
    if l <= r then
      table.insert(tasks, {stage + 1, l, r})
    end
  end
  return ret
end
SegTree.decValue = function(self, idx)
  self.stage[self.stagenum][idx] = self.stage[self.stagenum][idx] - 1
  for i = self.stagenum - 1, 1, -1 do
    local dst = mce(idx / 2)
    local rem = dst * 4 - 1 - idx
    self.stage[i][dst] = self.stage[i + 1][idx] + self.stage[i + 1][rem]
    idx = dst
  end
end
SegTree.inc = function(self, idx)
  self.stage[self.stagenum][idx] = 1 + self.stage[self.stagenum][idx]
end
SegTree.new = function(n)
  local obj = {}
  setmetatable(obj, {__index = SegTree})
  obj:create(n)
  return obj
end

local n, k = io.read("*n", "*n")
local sum, tmp, conv = {}, {}, {}
sum[1] = io.read("*n") - k
for i = 2, n do
  sum[i] = sum[i - 1] + io.read("*n") - k
end
sum[n + 1] = 0
for i = 1, n + 1 do tmp[i] = sum[i] end
table.sort(tmp)
local sumTypeCount = 1
local sumTypeList = {}
conv[tmp[1]] = 1
sumTypeList[1] = tmp[1]
for i = 2, n + 1 do
  if tmp[i] ~= sumTypeList[sumTypeCount] then
    sumTypeCount = sumTypeCount + 1
    conv[tmp[i]] = sumTypeCount
    sumTypeList[sumTypeCount] = tmp[i]
  end
end
local segtree = SegTree.new(sumTypeCount)
for i = 1, n do
  segtree:inc(conv[sum[i]])
end
segtree:updateAll()
local bias = 0
local cnt = 0
for i = 1, n do
  cnt = cnt + segtree:getRange(conv[bias], sumTypeCount)
  segtree:decValue(conv[sum[i]])
  bias = sum[i]
end
print(cnt)


Measured memory_bytes: 35360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
#define eprintf(...) fprintf(stderr,__VA_ARGS__)

const int N=int(1e5)+5;
const int mo=int(1e9)+7;

int n;
int x[N];
bool flag[N];
int nex[N];
int fac[N];

int main(){
	scanf("%d",&n);
	int left=1;
	for(int i=1;i<=n;i++){
		scanf("%d",&x[i]);
		left+=x[i]-x[i-1]-1;
		if(left){
			flag[i]=true;
			left--;
		}
	}
	nex[n+1]=n+1;
	nex[n+2]=n+2;
	for(int i=n;i>=1;i--)
		nex[i]=(flag[i]?nex[i+1]:i);
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=fac[i-1]*ll(i)%mo;
	int ans=1;
	int st=nex[1];
	int i;
	for(i=0;st<=n;i++){
		ans=ans*ll(st-i)%mo;
		st=nex[st+1];
		st=nex[st+1];
	}
	ans=ans*(ll)fac[n-i]%mo;
	printf("%d\n",ans);
}


Measured memory_bytes: 1536