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

using namespace std;
using boost::multiprecision::cpp_int;
using lli = unsigned long int;

lli gcd(cpp_int a, lli b) {
    lli c;
    c = (lli)(a % b);
  
    while(c){
      swap(c,b);
      c = c % b;
    }
	return b;
}
lli mod197 = 1000000007LL;

int N;

int main() {
	cin >> N;
	cpp_int ans = 0;
    cpp_int lcm = 1;
	for (int i = 0; i < N; i++) {
        lli A;
        cin >> A;
        lli t = (gcd(lcm, A));
        cpp_int s = (lcm / t);
        ans *= (A / t) % mod197;
        ans += s;
        ans %= mod197;
		lcm = (A * s);
	}
    cout << ans << endl;
}


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

int main ()
{
	char *S = malloc(((2 * 100000) + 1) * sizeof(char));
	char *T = malloc(((2 * 100000) + 1) * sizeof(char));
	int len;
	int ans;

	scanf("%s", S);
	scanf("%s", T);
	len = strlen(S);
	ans = 0;
	for (int i = 0; i < len; i++)
	{
		if(S[i] != T[i])
			ans++;
	}

	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2124
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] t = new int[n];
        int[] x = new int[n];
        int[] y = new int[n];
        for (int i = 0; i < n; i++) {
            t[i] = sc.nextInt();
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }
        int currentX = 0;
        int currentY = 0;
        int currentTime = 0;
        for (int i = 0; i < n; i++) {
            int restOfTime = (t[i]-currentTime);
            int restOfX = Math.abs(x[i]-currentX);
            int restOfY = Math.abs(y[i]-currentY);
            int subtract = restOfTime - (restOfX + restOfY);
            if(subtract < 0 || subtract % 2 != 0) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 90972
#include <bits/stdc++.h>
#define MOD (long long)(1E9+7)
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	long long n,t=0;
	cin >>n;
	long long i=1;
  	for(; i <= n; i<<=1) {
    	; 
    }
	cout << i-1 << endl;
	
}


Measured memory_bytes: 256
// Aizu Vol-2 0233: Book Arrangement
// 2017.8.8

#include <stdio.h>
#include <string.h>
#include <ctype.h>

char *gets(char *);
char buf[100], *p, *e;

int main()
{
	int minus, c, k;
	
	while (1) {
		p = buf + 5;
		gets(p); while (isspace(*p)) p++;
		if (*p == '0') break;
		minus = 0;
		if (*p == '-') minus = 1, p++;
		e = p + strlen(p) - 1;
		for (c = k = 0; p <= e; e--, k = !k) {
			if (k != minus) {
				if (*e > '0' || c) *e = (10 - (c + *e - '0')) + '0', c = 1;
			} else if (c) {
				if (*e < '9') *e = (c + (*e - '0')) + '0', c = 0;
				else *e = '0';
			}
		}
		if (c) {
			if (k != minus) *e-- = '9';
			*e-- = '1';
		}
		puts(++e);
	}
	return 0;
}

Measured memory_bytes: 520
#include <bits/stdc++.h>
using namespace std;
const int MAX = 3E2+2;

int h, w, k;
vector<vector<int> > a(MAX*MAX, vector<int>(2));
int ans[MAX][MAX];

void solve(vector<int> t, vector<int> b, int l, int r, int id){
//	cerr << t[0] << " " << t[1] << " " << b[0] << " " << b[1] << " "<< l << " " << r << " " << id << "\n";
	if(r==l){
		for(int i=t[0]; i<= b[0]; ++i)
			for(int j=t[1]; j<= b[1]; ++j)
				ans[i][j] = l;
		return;
	}
	int curp=1, cur=l;
	for(int i=l; i< r; ++i){
		if(a[i][id] < a[i+1][id]){
			vector<int> tt = t; tt[id] = curp;
			vector<int> bb = b; bb[id] = a[i][id];
			solve(tt, bb, cur, i, id+1);
			curp = a[i][id]+1;
			cur = i+1;
		}
	}
	vector<int> tt = t; tt[id] = curp;
	vector<int> bb = b; bb[id] = (id == 0? h : w);
	solve(tt, bb, cur, r, id+1);
}

signed main(){
	cin >> h >> w >> k;
	int cur=1;
	for(int i=1; i<= h; ++i)
		for(int j = 1; j<= w; ++j){
			char c; cin >> c;
			if(c == '#'){
				a[cur][0] = i; a[cur][1] = j;
				++cur;
			}
		}
	solve({1, 1}, {h, w}, 1, k, 0);
	for(int i=1; i<= h; ++i){
		for(int j=1; j<= w; ++j){
			cout << ans[i][j] << " ";
		}
		cout << "\n";
	}
}

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

using namespace std;

int main(void)
{
	string s;
	cin >> s;
	int n = s.length();
	for (int i = 0; i < n / 2; i++) {
		if (s[i] != s[n - 1 - i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int i = 0; i < n / 4; i++) {
		if (s[i] != s[n / 2 - 1 - i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)

{


int W, H, x, y, r;


scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);


if (x - r >= 0 && y - r >= 0 && x + r <= W && y + r <= H)


{


printf("Yes\n");


} 


else


{


printf("No\n");


}


return 0;


}

Measured memory_bytes: 584
#include <iostream>
using namespace std;
int main()
{
    int n;
    string s, t;
    cin >> n;
    cin >> s >> t;
    char *z= new char[n*2+1];
    for (int i = 0; i < n; i++) {
            z[2*i] = s[i];
            z[2*i+1] = t[i];
    }
    z[n*2] = '\0';
    cout << z <<"\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int n,out=0, max=0;
	char cha[101];
	scanf("%d", &n);
	scanf("%s", cha);
	for(int i = 0; i < n; i++){
		if(cha[i]=='I'){
			out++;
		}else{
			out--;
		}
		if(max<out){
			max=out;
		}
	}
	printf("%d", max);
	
	return 0;
}

Measured memory_bytes: 1708
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0].split(" ")[0]);
  var m = parseInt(input[0].split(" ")[1]);
  var ans = (1900*m+100*(n-m))*Math.pow(2,m);
  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import sys
import heapq
range = xrange
input = raw_input

n,m = [int(x) for x in input().split()]

A = [(int(x),1) for x in input().split()]

# Keep track of number of elements in A and the sum of all the elements
Acount = n
Asum = sum(a[0]*a[1] for a in A)

heapq.heapify(A)
for _ in range(m):
    new_count,new_val = [int(x) for x in input().split()]
    new_pair = (new_val,new_count)
    
    # Try to add this new pair to A
    heapq.heappush(A, new_pair)
    Acount += new_count
    Asum += new_count * new_val

    # While there are too many elements in A
    while Acount>n:
        # Remove the ones with the smallest values
        old_pair = heapq.heappop(A)
        
        old_count = old_pair[1]
        old_val = old_pair[0]
        Acount -= old_count
        Asum -= old_count * old_val

        # If there are too few elements left in A, then add back
        # some of the elements in the last pair
        if Acount<n:
            count = min(n - Acount, old_count)
            
            heapq.heappush(A, (old_val, count))
            Acount += count
            Asum += count * old_val

    # print Asum
print Asum


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

int main()
{
    int A, B, C, X;
    std::cin >> A >> B >> C >> X;
    int answer = 0;
    for (int i = 0; i <= A; ++i)
    {
        for (int j = 0; j <= B; ++j)
        {
            for (int k = 0; k <= C; ++k)
            {
                if (500 * i + 100 * j + 50 * k == X) { answer++; }
            }
        }
    }
    std::cout << answer << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	ll a;
	cin >> a;
	if (a % 1000 == 0)
	{

		cout << 0 << endl;
		return 0;
	}
	cout << 1000 - a % 1000 << endl;
	return 0;
}

Measured memory_bytes: 3636
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

fn main() {
     //pairwise coprime ならば pairwise coprime、
     //setwise coprime ならば setwise coprime、
     //そのどちらでもなければ not coprime と出力せよ
    input! {
        n: usize,
        a: [usize; n],
    }

    let mut g = a[0];
    for i in 1..n {
        g = gcd(g as u64, a[i] as u64) as usize;
    }
    if g != 1 {
        println!("not coprime");
        return;
    }

    let factors = factor_table(1_000_001);
    let mut fset = HashSet::new();
    for i in 0..n {
        let mut num = a[i];
        while num != 1 {
            let p = factors[num];
            if !fset.contains(&p) {
                fset.insert(p);
                while num % p == 0 {
                    num /= p;
                }
            } else {
                println!("setwise coprime");
                return;
            }
        }
    }
    println!("pairwise coprime");
}
#[allow(dead_code)]
pub fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
#[allow(dead_code)]
pub fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}
#[allow(dead_code)]
/// (gcd, x, y)
pub fn extgcd(a: i64, b: i64) -> (i64, i64, i64) {
    if b == 0 {
        (a, 1, 0)
    } else {
        let (gcd, x, y) = extgcd(b, a % b);
        (gcd, y, x - (a / b) * y)
    }
}

#[allow(dead_code)]
pub fn factor_table(max_n: usize) -> Vec<usize> {
    let mut res = vec![0; max_n + 1];
    for i in 2..max_n + 1 {
        if res[i] == 0 {
            let mut j = i;
            while j <= max_n {
                res[j] = i;
                j += i;
            }
        }
    }
    res
}

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

	public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int num[] = new int[5];
int mins,mine;
for(int i=0;i<5;i++)
{
num[i]=sc.nextInt();
}
mins=60*num[0]+num[1];
mine=60*num[2]+num[3]-num[4];

System.out.println(mine-mins);
	}

}


Measured memory_bytes: 35772
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

const Mod = int(1e9 + 7)

func main() {
	N, K := ReadInt(), ReadInt()
	A := ReadInts(N)
	var plusNums, minusNums []int
	for i := 0; i < N; i++ {
		if A[i] < 0 {
			minusNums = append(minusNums, A[i])
		} else {
			plusNums = append(plusNums, A[i])
		}
	}

	canMakePlus := false
	if N == K {
		canMakePlus = len(minusNums)%2 == 0
	} else {
		if len(plusNums) > 0 {
			canMakePlus = true
		} else {
			canMakePlus = K%2 == 0
		}
	}

	if !canMakePlus {
		sort.Slice(A, func(i, j int) bool { return Abs(A[i]) < Abs(A[j]) })
		ans := 1
		for i := 0; i < K; i++ {
			ans = ModMul(ans, A[i])
		}
		fmt.Println(ans)
		return
	}

	sort.Sort(sort.Reverse(sort.IntSlice(plusNums)))
	sort.Ints(minusNums)
	ans := 1
	if K%2 == 1 {
		ans *= plusNums[0]
		plusNums = plusNums[1:]
		K--
	}
	pairedNums := []int{}
	for len(plusNums) >= 2 {
		pairedNums = append(pairedNums, plusNums[0]*plusNums[1])
		plusNums = plusNums[2:]
	}
	for len(minusNums) >= 2 {
		pairedNums = append(pairedNums, minusNums[0]*minusNums[1])
		minusNums = minusNums[2:]
	}
	sort.Sort(sort.Reverse(sort.IntSlice(pairedNums)))
	for i := 0; i < K/2; i++ {
		ans = ModMul(ans, pairedNums[i])
	}
	fmt.Println(ans)
}

func ModMul(a, b int) int { return (Mod + a%Mod) * (Mod + b%Mod) % Mod }

func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 10148
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=100000+10;

int n,a[N];

int main() {
	n=read();
	for (int i=1;i<=n;++i) a[i]=read();
	ll ans1=0,ans2=0,sum=0;
	for (int i=1;i<=n;++i) {
		if (i&1) {
			if (sum+a[i]>0) sum+=a[i];
			else ans1+=1-(sum+a[i]),sum=1;
		} else {
			if (sum+a[i]<0) sum+=a[i];
			else ans1+=(sum+a[i])+1,sum=-1;
		}
	}
	sum=0;
	for (int i=1;i<=n;++i) {
		if (i&1) {
			if (sum+a[i]<0) sum+=a[i];
			else ans2+=(sum+a[i])+1,sum=-1;
		} else {
			if (sum+a[i]>0) sum+=a[i];
			else ans2+=1-(sum+a[i]),sum=1;
		}
	}
	printf("%lld\n",min(ans1,ans2));
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll; ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);
ll fac(ll x){if(x==0) return 1;  return x*fac(x-1);}

int main(){
  ll h,n,ans=0;
  cin>>h>>n;
  vector<ll>v(n);
  rep(i,n){
    cin>>v[i];
  ans+=v[i];
  }
  if(ans<h)
  cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;

} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i=0; i < (int)(N); i++)
 
int main() {
  int A;
  int B;
  cin >> A >> B;
  
  int start = A / 100;
  int end = B / 100;
  
  int ans = 0;
  
  for (int i=start; i< end+1; i++){
    string temp = to_string(i);
    string s = temp;
    for (int i=temp.size()/2; i > -1; i--){
      s += temp.at(i);
    }
    int num = stoi(s);
    
    if ((num >= A) && (num <= B)){
      ans += 1;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  ll H;

  cin >> H;

  ll ans = 0;
  ll now = 1;

  while (H) {
    ans += now;
    now *= 2;
    H /= 2;
  }

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef tuple<int,int,int> TP;
constexpr int INF = 2e9;
struct UnionFind{
  vector<int> data;
  int __size;
  UnionFind(int sz) {
  data.assign(sz, -1);
  __size = sz;
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);//親は負でサイズを保存
    __size--;
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  bool same(int x, int y){
    return find(x) == find(y);
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }

  int union_count() {
    return (__size);
  }
};
int main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i,m) {
    int x, y, z;
    cin >> x >> y >> z;
    x--; y--;
    uf.unite(x, y);
  }
  cout << uf.union_count() << endl;
  return 0;
} 

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
long long read()
{
	char ch=getchar();long long x=0,ff=1;
	while(ch<'0'||ch>'9') {if(ch=='-') ff=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*ff;
}
void write(long long aa)
{
	if(aa<0) putchar('-'),aa=-aa;
	if(aa>9) write(aa/10);
	putchar(aa%10+'0');
	return;
}
long long n,m,K;
long long a[100005],b[100005],tmp[100005];
void ksm(long long aa)
{
	while(aa)
	{
		if(aa&1) 
		{
			for(long long i=1;i<=n;++i) tmp[i]=a[b[i]];
			for(long long i=1;i<=n;++i) a[i]=tmp[i];
		}
		aa>>=1;
		for(long long i=1;i<=n;++i) tmp[i]=b[b[i]];
		for(long long i=1;i<=n;++i) b[i]=tmp[i];
	}
	return;
}
int main()
{
	n=read();
	for(long long i=1;i<=n;++i) a[i]=read(),b[i]=i;
	for(long long i=n;i>=1;--i) a[i]-=a[i-1];
	m=read(),K=read();
	for(long long i=1;i<=m;++i) 
	{
		long long x=read();
		swap(b[x],b[x+1]);
	}
	ksm(K);
	long long sum=0;
	for(long long i=1;i<=n;++i)
	{
		sum+=a[i];
		write(sum);
		puts("");
	}
	return 0;
}


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

typedef pair<int, int> P;

int partition(vector<P> &a, int p, int r) {
  P x = a[r];
  int i = p-1;
  for ( int j = p; j < r; j++ ) {
    if ( a[j].first <= x.first ) {
      i++;
      swap(a[i], a[j]);
    }    
  }

  swap(a[i+1], a[r]);
  return i+1;
}

void quickSort(vector<P> &a, int p, int r) {
  if ( p < r ) {
    int q = partition(a, p, r);
    quickSort(a, p, q-1);
    quickSort(a, q+1, r);
  }
}

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

  vector<P> a(n);
  vector<char> pat(n);
  vector<int> num(n);
  for ( int i = 0; i < n; i++ ) {
    cin >> pat[i] >> num[i];
    a[i] = P(num[i], i);
  }

  vector<P> b = a;

  quickSort(b, 0, n-1);

  sort(a.begin(), a.end());

  if ( a != b ) cout << "Not stable" << endl;
  else cout << "Stable" << endl;

  for ( int i = 0; i < n; i++ ) {
    int id = b[i].second;
    cout << pat[id] << " " << num[id] << endl;
  }

  return 0;
}



Measured memory_bytes: 4860
#include<iostream>
#include<string>
using namespace std;
int o=0;
void rec(string str){
  //cout << str << endl;
  string next,buf;
  if('0'<=str[0]&&str[0]<='2'){
    //cout << str << endl;
    if(str[0]=='2') o++;
    return;
  }
  for(int i=1;i<str.size();i++){
    if('0'<=str[i]&&str[i]<='2') {
      if(str[i-1]=='-') {
	if(str[i]=='0')  str[i]='2';
	else if(str[i]=='2')  str[i]='0';
	str[i-1]=' ';
      }else if(str[i-1]=='*') {
	if(str[i-3]=='('){
	if(str[i]=='0'||str[i-2]=='0') {
	  str[i-3]=' ';
	  str[i-2]=' ';
	  str[i-1]=' ';
	  str[i]='0';
	  str[i+1]=' ';
	}else if(str[i]=='2'&&str[i-2]=='2') {
	  str[i-3]=' ';
	  str[i-2]=' ';
	  str[i-1]=' ';
	  str[i]='2';
	  str[i+1]=' ';
	}else if('0'<=str[i-2]&&str[i-2]<='2'){
	  str[i-3]=' ';
	  str[i-2]=' ';
	  str[i-1]=' ';
	  str[i]='1';
	  str[i+1]=' ';
	}
	}
      }else if(str[i-1]=='+') {
	if(str[i-3]=='('){
	if(str[i]=='2'||str[i-2]=='2') {
	  str[i-3]=' ';
	  str[i-2]=' ';
	  str[i-1]=' ';
	  str[i]='2';
	  str[i+1]=' ';
	}else if(str[i]=='0'&&str[i-2]=='0') {
	  str[i-3]=' ';
	  str[i-2]=' ';
	  str[i-1]=' ';
	  str[i]='0';
	  str[i+1]=' ';
	}else if('0'<=str[i-2]&&str[i-2]<='2'){
	  str[i-3]=' ';
	  str[i-2]=' ';
	  str[i-1]=' ';
	  str[i]='1';
	  str[i+1]=' ';
	}
	}
      }
    }
  }
  for(int i=0;i<str.size();i++){
    if(str[i]!=' ') next+=str[i];
  }
  rec(next);
}
int main(){
  string str,buf;
  cin >> str;
  while(str!="."){
    int p[]={0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2};
    int q[]={0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2};
    int r[]={0,0,0,1,1,1,2,2,2,0,0,0,1,1,1,2,2,2,0,0,0,1,1,1,2,2,2};
    o=0;
    for(int i=0;i<27;i++){
      buf=str;
      for(int j=0;j<str.size();j++){
	if(buf[j]=='P') buf[j]=p[i]+'0';
	if(buf[j]=='Q') buf[j]=q[i]+'0';
	if(buf[j]=='R') buf[j]=r[i]+'0';
      }
      rec(buf);
    }
    cout << o << endl;
    cin >> str;
  }
  
}

Measured memory_bytes: 1200
process.stdin.resume();
process.stdin.setEncoding('utf-8');
 
let inputString = '';
let currentLine = 0;
 
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
 
process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    
    main();    
});
 
function readLine() {
    return inputString[currentLine++];
}

function main() {
    const [n, d] = readLine().split(/\s/).map(Number)
    const d2 = Math.pow(d, 2)
    result = 0
    for (let i = 0; i < n; i++) {
      const [x, y] = readLine().split(/\s/).map(Number)
      const _d2 = Math.pow(x, 2) + Math.pow(y, 2)
      if (_d2 <= d2) {
        result += 1
      }
    }
  console.log(result)
}

Measured memory_bytes: 84140
use proconio::input;
use std::collections::HashSet;

#[proconio::fastout]
fn main() {
    input! {
    X:i64,
    p:[i64],
    }
    let s: HashSet<i64> = p.into_iter().collect();
    let mut ans = -1;
    for diff in 0..100 {
        if !s.contains(&(&X - diff)) {
            ans = &X - diff;
            break;
        }
        if !s.contains(&(&X + diff)) {
            ans = &X + diff;
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2156
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int s=0,n,l;cin>>n>>l;
	for(int i=1;i<=n;i++)s+=l+i-1;
	cout<<s-(l+min(n,max(1,1-l))-1)<<endl;
	return 0;
}

Measured memory_bytes: 256
// g++ -I ~/Documents/programming/cppLib -std=gnu++14 -o test ~/Documents/programming/cppLib/test.cpp && ./test && rm test
#include <bits/stdc++.h>
using namespace std;
template <typename T> using vector2 = vector <vector  <T>>;
template <typename T> using vector3 = vector <vector2 <T>>;
template <typename T> using vector4 = vector <vector3 <T>>;
using lint = long long;
#define FOR( i, a, b ) for( lint i=(a) ; i <= (b) ; ++i )
#define REP( i, n )    for( lint i= 0  ; i <  (n) ; ++i )
#define ALL( v )       (v).begin(), (v).end()

int main() {
    int P, Q, R;
    cin >> P >> Q >> R;

    if( P >= Q && P >= R ) {
        cout << Q + R << endl;
    } else if ( Q >= P && Q >= R ){
        cout << P + R << endl;
    } else {
        cout << P + Q << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
ll n;
string s;
bool decideAnimal(ll i,vector<bool> animals);
void Main(){    
    cin>>n>>s;
    bool flag=false,flag1,flag2;
    vector<bool> animals(n);//True=Sheep,False=Wolf
    For(i,0,4){
        animals.at(0)=i%2;
        animals.at(1)=i/2;
        flag1=false;flag2=false;
        For(j,2,n){
            animals.at(j)=decideAnimal(j,animals);
        }
        /*For(j,0,n){
            if(animals.at(j)) cout<<'S';
            else cout<<'W';
        }
        cout<<endl;*/
        if(animals.at(n-1)){
            if(s.at(n-1)=='o'){
                if(animals.at(n-2)==animals.at(0)){
                    flag1=true;
                }
            }
            else{
                if(animals.at(n-2)!=animals.at(0)){
                    flag1=true;
                }             
            }
        }
        else{
            if(s.at(n-1)=='o'){
                if(animals.at(n-2)!=animals.at(0)){
                    flag1=true;
                }
            }
            else{
                if(animals.at(n-2)==animals.at(0)){
                    flag1=true;
                }           
            }
        }
        if(animals.at(0)){
            if(s.at(0)=='o'){
                if(animals.at(n-1)==animals.at(1)){
                    flag2=true;
                }
            }
            else{
                if(animals.at(n-1)!=animals.at(1)){
                    flag2=true;
                }             
            }
        }
        else{
            if(s.at(0)=='o'){
                if(animals.at(n-1)!=animals.at(1)){
                    flag2=true;
                }
            }
            else{
                if(animals.at(n-1)==animals.at(1)){
                    flag2=true;
                }           
            }
        }
        if(flag1&&flag2){
            flag=true;
            break;
        }
    }
    if(!flag){
        cout<<-1<<endl;
        return;
    }
    else{
        For(i,0,n){
            if(animals.at(i)) cout<<'S';
            else cout<<'W';
        }
        cout<<endl;
        return;
    }
}
bool decideAnimal(ll i,vector<bool> animals){
    if(animals.at(i-1)){
        if(s.at(i-1)=='o'){
            return animals.at(i-2);
        }
        else{
            return !animals.at(i-2);
        }
    }
    else{
        if(s.at(i-1)=='o'){
            return !animals.at(i-2);
        }
        else{
            return animals.at(i-2);
        }
    }
}
int main(){
    Main();
    return 0;
}

Measured memory_bytes: 512
/*
AOJ - ITP1_5_B
Date: 20180914
Author: Mikoron
 */

#include<stdio.h>

int main(void) {

        int H, W;
        int i, j;

        while(1) {
                scanf("%d %d", &H, &W);
                if(H == 0 && W == 0) break;
                for(i = 1; i <= H; i++) {
                        for(j = 1; j <= W; j++) {
                                if(i%2!=0) {
                                        if(j%2!=0) printf("#");
                                        else printf(".");
                                }else {
                                        if(j%2!=0) printf(".");
                                        else printf("#");
                                }
                        }
                        printf("\n");
                }
                printf("\n");
        }

}



Measured memory_bytes: 2112
#include <iostream>
#include <vector>
using namespace	std;
int main(){

  int n,so[40000]={0},moto;

  cin>>n;
  moto=n;
  vector <int> sonaka;
  for(int i=2;i<40000;i++) if(so[i]==0){
      sonaka.push_back(i);
      for(int j=i*2;j<40000;j+=i) so[j]=1;
    }
  vector <int> result;
  for(int i=0;sonaka[i]<=n&&i<sonaka.size();i++) while(n%sonaka[i]==0){
      n/=sonaka[i];
      result.push_back(sonaka[i]);
  }
  if(n!=1) result.push_back(n);
  cout<<moto<<":";
  for(int i=0;i<result.size();i++) cout<<" "<<result[i];
  cout<<endl;

  return 0;

}

Measured memory_bytes: 3372
#include<iostream>
#include<vector>
#include<algorithm>

int main(){
    int N;
    std::cin >> N;
    std::vector<int> a(N);
    for(int i = 0; i < N; i++){
        std::cin >> a[i];
    }
    
    std::sort(a.begin(), a.end());

    int sum = 1000000;
    for(int i = 0; i < N; i++){
        int tmpSum = 0;
        int left = a[i] - a[0];
        int right = a[N - 1] - a[i];
        if(left < right) tmpSum = left * 2 + right;
        else if(left >= right) tmpSum = right * 2 + left;
        sum = std::min(tmpSum, sum);
    }

    std::cout << sum << std::endl;
    
    return 0;
}


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

#define pb push_back
#define mp make_pair
#define ft first
#define sc second
#define ull unsigned long long int
#define lli long long int
#define li long int

#define si(n) scanf("%d",&n)
#define sl(n) scanf("%ld",&n)
#define sll(n) scanf("%lld",&n)

#define pi(n) printf("%d",n)
#define pl(n) printf("%ld",n)
#define pll(n) printf("%lld",n)

using namespace std;

const int MAX=1e2+5;

lli A[MAX];
int main() {
    // freopen("a.in","r",stdin);
    // freopen("a.out","w",stdout);
    int N;
    cin >> N;
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }
    sort(A,A+N);

    cout << A[N-1]-A[0] << "\n";


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;

int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n; cin >> n;
	vector<int> L(n); for (int i = 0; i < n; i++) cin >> L[i];
	sort(L.begin(), L.end());
	ll res = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int sm = L[i] + L[j];
			res += lower_bound(L.begin() + j + 1, L.end(), sm) - (L.begin() + j + 1);
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<math.h>
#include<stdio.h>
#define pi 3.1415926
using namespace std;
struct point{
    double x,y;
};
void koch(int n,point p1,point p2){
    if(n==0)
        return ;
    point s,u,t;
    s.x=(2*p1.x+p2.x)/3;
    s.y=(2*p1.y+p2.y)/3;
    t.x=(p1.x+2*p2.x)/3;
    t.y=(p1.y+2*p2.y)/3;
    u.x=(t.x-s.x)*cos(60*pi/180)-(t.y-s.y)*sin(60*pi/180)+s.x;
    u.y=(t.x-s.x)*sin(60*pi/180)+(t.y-s.y)*cos(60*pi/180)+s.y;
    //printf("%.8f %.8f\n",p1.x,p1.y);
    koch(n-1,p1,s);
    printf("%.8f %.8f\n",s.x,s.y);
    koch(n-1,s,u);
    printf("%.8f %.8f\n",u.x,u.y);
    koch(n-1,u,t);
    printf("%.8f %.8f\n",t.x,t.y);
    koch(n-1,t,p2);
   // printf("%.8f %.8f\n",p2.x,p2.y);
}
int main(){
    int n;
    cin>>n;
    point p1,p2;
    p1.x=0;p1.y=0;
    p2.x=100;p2.y=0;
    if(n==0){
        printf("%.8f %.8f\n",p1.x,p1.y);
        printf("%.8f %.8f\n",p2.x,p2.y);
        return 0;
    }
    else{
        printf("%.8f %.8f\n",p1.x,p1.y);
        koch(n,p1,p2);
        printf("%.8f %.8f\n",p2.x,p2.y);
    }
    return 0;
}



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

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

ll n,m,x,k,d,i,j,index,flag=0,count=0,result,odd,even,sum=0,temp,mini;
cin>>n>>m;
//string str;
//cin>>str;
//ll a[200005];
//ll b[200005];
/*for(i=0;i<n;i++)
{
    cin>>a[i];
}
*/
if(n==m)  cout<<"Yes";
else cout<<"No";

    return 0;
}


Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int l,r,d,ans{};
    cin>>l>>r>>d;
    for(int i=l;i<=r;++i) if(i%d==0) ++ans;
    cout<<ans<<'\n';
}

Measured memory_bytes: 3576
class Heap
  attr_reader :size

  def initialize
    @heap = []
    @data = {}
    @size = 0
  end

  def add(n, data)
    i = @size
    while i > 0 do
      parent_index = (i - 1) / 2
      break if n >= @heap[parent_index]

      @heap[i] = @heap[parent_index]
      i = parent_index
    end

    @heap[i] = n
    @data[n] = data.merge(key: n)
    @size += 1
  end

  def pop
    min_n = @heap[0]
    @size -= 1
    n = @heap[@size]
    i = 0
    while i * 2 + 1 < @size do
      child_index1 = i * 2 + 1
      child_index2 = i * 2 + 2
      if child_index2 < @size && @heap[child_index2] < @heap[child_index1]
        child_index1 = child_index2
      end
      break if @heap[child_index1] >= n

      @heap[i] = @heap[child_index1]
      i = child_index1
    end
    @heap[i] = n
    @data.delete(min_n)
  end

  def min; @heap[0] end
  def values; @heap.first(@size) end
  def inspect; "Heap: #{values}" end
end

N, M = gets.split.map(&:to_i)
heaps = {}
cities = []
M.times do |i|
  pref, year = gets.split.map(&:to_i)
  heaps[pref] ||= Heap.new
  heaps[pref].add(year, {n: i})
  cities[i] = {p: pref}
end

# p heaps
heaps.each do |pref, heap|
  o = 1
  while c = heap.pop
    cities[c[:n]][:o] = o
    o += 1
  end
end

cities.each do |city|
  puts "%06d%06d" % [city[:p], city[:o]]
end

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    string a;
    cin >> a;
    if (a.length() <= n)
    {
        cout << a;
    }
    else
    {
        for(int i = 0; i < n; i++)
        {
            cout << a[i];
        }
        cout << "...";
    }
}


Measured memory_bytes: 3628
N = int(input())
A = list(map(int, input().split()))

count = 0
flag = 1
i = 0
while flag:
    flag = 0
    for j in range(N-1, i, -1):
        if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j] #交換
            flag = 1
            count += 1
    i += 1
        
for k in range(N):
        if k > 0:
            print(' ', end='')
        print(A[k], end='')

print('')
print(count)


Measured memory_bytes: 5624
#include<bits/stdc++.h>
//#include <iostream>
//#include <iomanip>
//#include <vector>
//#include <cmath>
//#include <algorithm>
using namespace std;


#define F first
#define PB push_back
#define MP make_pair

typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s, t;
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = 0;
    ans += min(d, a);
    d = max(d- a, 0);
    d = max(d - b, 0);

    ans -= d;
    cout << ans << endl;
}


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

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt();
        String[] s=new String[n];
        int[] t=new int[n];
        for(int i=0;i<n;i++){
            s[i]=fsc.next();
            t[i]=fsc.nextInt();
        }
        String x=fsc.next();
        fsc.close();
        boolean sleep=false; 
        int ans=0;
        for(int i=0;i<n;i++){
            if(sleep){
                ans+=t[i];
            }
            if(s[i].equals(x)){
                sleep=true;
            }
        }
        System.out.println(ans);
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


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

using namespace std;

#define db(x) cout << (x) << '\n';
#define all(x) x.begin(),x.end()
#define UNIQUE(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define LB(v,x) lower_bound(all(v),x)
#define UB(v,x) upper_bound(all(v),x)
#define endl "\n"
#define F first
#define S second
#define PB push_back
#define PF push_front
#define int long long
#define double long double
#define trick int m = (l+r)>>1,lc=n<<1,rc=lc|1

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;

int dy[]={0,1,1,1,0,-1,-1,-1};
int dx[]={-1,-1,0,1,1,1,0,-1};
const int maxn = 1e5;
const int OO = 1e18;
const int mod = 1e9 + 7;
const double PI = acos(-1);

void maxself(int &a,int b)
{a=max(a,b);}
void minself(int &a,int b)
{a=min(a,b);}

vector<vi> g(maxn);


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

//	freopen("name.in","r",stdin);
//	freopen("name.out","w",stdout);

	int n;
	cin >> n;
	vi v(n);
	for(int i=0;i<n;i++)
	cin >> v[i];
	sort(all(v));
	int ans = v[n-1];
	int j=n-2;
	int cont=0;
	for(int i=n-3;i>=0;i--)
	{
		ans += v[j];
		cont++;
		if(cont==2)
		cont=0,j--;
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 7148
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(n) for (int i = 0; i < n; i++)
#define fo(i, x, n) for (int i = x; i < n; i++)
#define fb(i, x, n) for (int i = n - 1; i >= x; i--)
#define w(t)  \
    int t;    \
    cin >> t; \
    while (t--)

typedef unsigned long long ull;
typedef vector<long long> vi;
#define msi map<string, long long>
#define mii map<long long, long long>
const int MX = 2e5 + 5;
const int INF = 1e18;
#define pb push_back
//#define endl "\n"
#define yes cout << "Yes\n"
#define no cout << "No\n"
#define all(x) x.begin(), x.end()
#define ff first
#define ss second

void print(int a[], int n)
{
    for (int i = 0; i < n; i++)
    {
        cout << a[i] << " ";
    }
    cout << endl;
}

void print(vi &v)
{
    f(v.size())
    {
        cout << v[i] << " ";
    }
    cout << endl;
}

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

    int cnt=0;
    int ans=0;
    w(t)
    {

        int a,b;
        cin>>a>>b;
        if(a==b)
        {
            cnt++;
            ans=max(ans,cnt);
        }
        else
        {
            cnt=0;
        }
    }
    if(ans>=3)
    {

        yes;
    }
    else
        no;


    cerr<< "Time Killed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
    return 0;
}


Measured memory_bytes: 3804
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let n: u64 = read_as_vec()[0];
    let mut whole: u64 = 1;
    let mm = 1_000_000_007;
    for _ in 0..n {
        whole *= 10;
        whole %= mm;
    }

    let mut not_09 = 1;
    for _ in 0..n {
        not_09 *= 8;
        not_09 %= mm;
    }
    let mut not_a: u64 = 1;
    for _ in 0..n {
        not_a *= 9;
        not_a %= mm;
    }
    if whole < not_a {
        whole += mm;
    }
    let a = whole - not_a;

    let mut b_only9_not0: i64 = whole as i64 - not_09 as i64 - a as i64;
    while b_only9_not0 < 0 {
        b_only9_not0 += mm as i64;
    }
    let b_only9_not0: u64 = b_only9_not0 as u64;

    let a_only0_not9 = b_only9_not0;
    let mut ans: i64 = whole as i64 - not_09 as i64 - a_only0_not9 as i64 - b_only9_not0 as i64;
    while ans < 0 {
        ans += mm as i64;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

template<typename T>
inline void remax(T& x, T y) { x = max(x, y); }

template<typename T>
inline void remin(T& x, T y) { x = min(x, y); }

// End of template code!
int main() 
{
    buff();
    int n, k;
    cin >> n >> k;
    vi v(n);
    for(int& x : v) cin >> x;
    deque<int> window;
    for(int i = 0; i < n; ++i)
    {
        if(sz(window) == k) {
            int fst = window.front();
            window.pop_front();
            int novo = v[i];
            if(novo > fst) cout << "Yes\n";
            else cout << "No\n";
        }
        window.push_back(v[i]);
    }
    

    return 0;
}





Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()
 
int main(){
    ll D;cin>>D;
    vector<int> c(26);rep(i,26)cin>>c[i];
    vector<vector<int>> s(D,vector<int>(26));
    rep(i,D)rep(j,26) cin>>s[i][j];
    rep(i,D) cout<<(i+2)%26+1<<endl;
}

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

int main() {
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	auto b = a;
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++) {
		if (b[i] == a[n - 1]) {
			cout << a[n - 2] << '\n';
		} else {
			cout << a[n - 1] << '\n';
		}
	}
}

Measured memory_bytes: 4840
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        int acnum = 0, wanum = 0, tlenum = 0, renum = 0;
        String judge = "";
        for(long i = 0; i < n + 1; i++){
            judge = sc.nextLine();
            switch(judge){
                case "AC":
                    acnum++;
                    break;
                case "WA":
                    wanum++;
                    break;
                case "TLE":
                    tlenum++;
                    break;
                case "RE":
                    renum++;
                    break;
                default:
                    break;
            }
        }
        sc.close();

        System.out.println("AC x " + acnum);
        System.out.println("WA x " + wanum);
        System.out.println("TLE x " + tlenum);
        System.out.println("RE x " + renum);
    }
}


Measured memory_bytes: 59720
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
typedef long long ll;
const ll mod = 1e9 + 7;

int main(){
    int n; ll k;
    cin >> n >> k;
    int a[n];
    rep(i,n) cin >> a[i];
    vector<ll> num(n,0);
    rep(i,n){
        rep(j,n){
            if(i != j && a[i] > a[j]) num[i]++;
        }
    }
    vector<ll> d(n,0);
    rep(i,n){
        for(int j = i+1; j < n; j++){
            if(a[i] > a[j]) d[i]++;
        }
    }
    ll ans = 0;
    ll b = k*(k-1)/2 % mod;
    rep(i,n){
        ans = (ans + num[i]*b + d[i]*k) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

    vector<vector<int>> lamp(h, vector<int>(w));
    rep(i, h) {
        vector<bool> checked(w);
        rep(j, w) {
            if (s[i][j] == '#') continue;
            if (checked[j] == true) continue;
            int c = 0;
            while(j+c < w) {
                if (s[i][j+c] == '#') break;
                ++c;
            }
            rep(k, c) {
                lamp[i][j+k] += c;
                checked[k+j] = true;
            }
        }
    }

    rep(j, w) {
        vector<bool> checked(h);
        rep(i, h) {
            if (checked[i] == true) continue;
            if (s[i][j] == '#') continue;
            int c = 0;
            while(i+c < h) {
                if (s[i+c][j] == '#') break;
                ++c;
            }
            rep(k, c) {
                lamp[i+k][j] += c;
                checked[i+k] = true;
            }
        }
    }

    int ans = 0;
    rep(i, h) {
        rep(j, w) {
            ans = max(ans, lamp[i][j]);
        }
    }
    cout << ans - 1 << endl;
}

Measured memory_bytes: 20096
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::HashSet;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
      x: i32,
      n: usize,
      p:[i32;n],
    }

    let mut ans = 0;
    if n == 0 {
     println!("{}", x);
     return;
    }

    for i in 0..300 {
      if !p.contains( &(x - i)) {
        ans = x - i;
        break;
      }

      if !p.contains( &(x + i)){
        ans = x+ i;
        break;
      }

    }
     println!("{}", ans);
}


Measured memory_bytes: 2152
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,min = 1000,c = 0;
  cin >> N;
  vector<int> d(N);
  for(int i = 0; i < N; i++){
    cin >> d.at(i);
  }
  std::sort(d.begin(),d.end(),std::greater<int>());
  
  for(int i = 0; i < N; i++){
    if(d.at(i) < min){
      min = d.at(i);
      c++;
    }
  }
  cout << c << endl;
 
}



Measured memory_bytes: 256