akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<bitset>
#include<iostream>
#include<iomanip>
#include<set>
#include<string>
#include<math.h>

using namespace std;

class zahyo{
	public:
	int x;
	int y;
	zahyo(){
		x=0;
		y=0;
	}
	zahyo(int x_,int y_){
		x=x_;
		y=y_;
	}
	void print(){
		cout<<x<<" "<<y;
	}
	zahyo operator+(zahyo add){
		add.x=this->x+add.x;
		add.y=this->y+add.y;
		return add;
	}
	zahyo operator-(zahyo add){
		add.x=this->x-add.x;
		add.y=this->y-add.y;
		return add;
	}
	bool operator==(const zahyo add) const{
		if(add.x==this->x and add.y==this->y){return true;}
		else{return false;}
	}
	bool operator!=(const zahyo add) const{
		if(add.x==this->x or add.y==this->y){return false;}
		else{return true;}
	}
	bool operator<(const zahyo add) const{
		if(this->x<add.x){return true;}
		else if(this->x==add.x and this->y<add.y){return true;}
		else{return false;}
	}
	bool operator>(const zahyo add) const{
		if(this->x>add.x){return true;}
		else if(this->x==add.x and this->y>add.y){return true;}
		else{return false;}
	}
	void input(){
		cin>>x>>y;
	}
};

double length(zahyo a,zahyo b){
	int nijyo=pow(a.x-b.x,2)+pow(a.y-b.y,2);
	double len=sqrt(nijyo);
	return len;
}

int main(){
	int n;cin>>n;
	zahyo city[8];
	for(int i=0;i<n;i++){
		city[i].input();
	}
	double ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			ans+=length(city[i],city[j]);
		}
	}
	ans=(ans*2)/n;
	cout<<setprecision(10)<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3788
//Night's template
//orzakyrt
#include <bits/stdc++.h>
#define R register
#define LL long long
#ifdef __DEBUG__
	#define Debug (fprintf(stderr,"orzyrt\n"),fflush(stderr))
	#define debug(__a...) (fprintf(stderr,__a),fflush(stderr))
#else
	#define Debug ('orzyrt')
	#define debug(__a...) ('orzyrt')
#endif
inline void Compile(R char *s){
	char com[111];
	sprintf(com,"g++ %s.cpp -lm -o %s",s,s);
	system(com);
}
inline void setfile(R char *s){
	char inname[111],outname[111];
	sprintf(inname,"%s.in",s);
	sprintf(outname,"%s.out",s);
	freopen(inname,"r",stdin);
	freopen(outname,"w",stdout);
}
#ifdef __DEBUG__
	#define setfile(__a) (1)
#endif
template<class TT>inline TT Max(R TT a,R TT b){return a<b?b:a;}
template<class TT>inline TT Min(R TT a,R TT b){return a<b?a:b;}
template<class TT>inline TT Abs(R TT a){return a<0?-a:a;}
template<class TT>inline TT cmin(R TT &a,R TT b){(b<a)&&(a=b);}
template<class TT>inline TT cmax(R TT &a,R TT b){(a<b)&&(a=b);}
using namespace std;
template<class TT>inline void read(R TT &x){
	x=0;R bool f=false;R char c=getchar();
	for(;c<48||c>57;c=getchar())f|=(c=='-');
	for(;c>47&&c<58;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	(f)&&(x=-x);
}
//end template

namespace Night{
	const int maxn = 1e5+10;
	int n;
	int a[maxn];
	int vis1[maxn],vis2[maxn],siz1,siz2;
	struct node{
		int key,val;
		inline bool operator < (R const node &x)const{
			return val>x.val;
		}
	};
	vector<node>mx1,mx2;
	int main(){
		read(n);
		for(R int i=1;i<=n;++i)read(a[i]);
		for(R int i=1;i<=n;i+=2)vis1[a[i]]++,siz1++;
		for(R int i=2;i<=n;i+=2)vis2[a[i]]++,siz2++;
		for(R int i=1;i<maxn;++i){
			mx1.push_back((node){i,vis1[i]});
			mx2.push_back((node){i,vis2[i]});
		}
		sort(mx1.begin(),mx1.end());
		sort(mx2.begin(),mx2.end());
		int ans=0;
		if(mx1.size()==1 && mx2.size()==1){
			if(mx1[0].key == mx2[0].key){
				ans=Min(siz1,siz2);
				debug("1\n");
			}else{
				ans=0;
				debug("2\n");
			}
		}else{
			if(mx1[0].key == mx2[0].key){
				ans=Min(siz1-mx1[1].val+siz2-mx2[0].val,siz2-mx2[1].val+siz1-mx1[0].val);
				debug("3\n");
			}else{
				ans=siz1-mx1[0].val+siz2-mx2[0].val;
				debug("4\n");
				debug("%d %d\n",mx1[0].key,mx1[0].val);
				debug("%d %d\n",mx2[0].key,mx2[0].val);
			}
		}
		cout<<ans;
		return 0;
	}
}
int main(){
	return Night::main();
}

Measured memory_bytes: 3188
def Z_algo(S):
    N = len(S)
    result = 0
    c = 0
    Z = [0]*N
    for i in range(1, N):
        l = i - c
        if (i + Z[l] < c + Z[c]):
            Z[i] = Z[l]
        else:
            j = max(0, c + Z[c] - i)
            if i + j >= N:
                j = min(j, N-i-1)
            while(S[j] == S[i + j]):
                j += 1
                if i + j >= N:
                    break
            Z[i] = j
            c = i
        result = max(result, min(Z[i], i))
    return result

L = int(input())
P = list(input())
ans = 0

for k in range(L):
    ans = max(ans, Z_algo(P[k:]))

print(ans)

Measured memory_bytes: 53084
using System;

class Atcoder103
{
    public static void Main()
    {
        int day = int.Parse(Console.ReadLine());

        if (day == 25)
            Console.WriteLine("Christmas");
        else if (day == 24)
            Console.WriteLine("Christmas Eve");
        else if (day == 23)
            Console.WriteLine("Christmas Eve Eve");
        else if (day == 22)
            Console.WriteLine("Christmas Eve Eve Eve");
    }
}

Measured memory_bytes: 13140
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#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)

void zalgo(string& s,vector<int>& z){
    int c=0,n=s.length();
    z.resize(n,0);
    for(int i=1;i<n;++i){
        int l=i-c;
        if(i+z[l]<c+z[c]) z[i]=z[l];
        else{
            int j=max(0,c+z[c]-i);
            for(;i+j<n&&s[j]==s[i+j];++j);
            z[i]=j;c=i;
        }
    }
    z[0]=n;
}

class EWhoSaysAPun {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n;
        string s,t;
        in>>n>>s;
        int ans=0;
        fr(i,n){
            vector<int> z(n-i);
            t=s.substr(i,n-i);
            zalgo(t,z);
            fr(j,n-i) ans=max(ans,min(j,z[j]));
        }
        out<<ans<<endl;
    }
};

int main() {
    EWhoSaysAPun solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define nFOR(i,a,b) for(int i=a; i>=b; --i)

#define ll long long
#define pb(x) push_back(x)
#define pii pair <int, int>
#define S second
#define F first

const int MAX=2e+5;
using namespace std;

int n, x, a[MAX], F[MAX];

int main(){
	cin>>n;
	FOR(i, 1, n) cin>>a[i];
	int dem=0, m=INT_MAX;
	FOR(i, 1, n){
		if(a[i]<m){
			m=a[i];
			dem++;
		}
	}
	cout<<dem;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <stdlib.h>
using namespace std;
int main()
{
	int i,q;
	long long a,b;
	scanf("%d", &q);
	for(i = 1 ; i <= q ; i++)
	{
		scanf("%lld %lld", &a, &b);
		if(a == b)
		{
			printf("%lld\n",a * 2 - 2);
		}
		else
		{
			int fuzu;
			if(a > b)
			{
				fuzu = a;
				a = b;
				b = fuzu;
			}
			if(a + 1 == b)
			{
				printf("%lld\n",2 * a - 2);
			}
			else
			{
				long long c = sqrt(a * b);
				if(c * c == a * b)
				{
					c = c - 1;
				}
				if(c * (c + 1) >= a *b)
				{
					printf("%lld\n",2 * c - 2);
				}
				else
				{
					printf("%lld\n", 2 * c - 1);
				}
			}
		}

	}
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
#EDPC J

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
dp = [[[0.0]*(n+1) for _ in range(n+1)] for _ in range(n+1)]
x,y,z = 0,0,0
for i in range(n):
    if a[i] == 1:
        x += 1
    elif a[i] == 2:
        y += 1
    else:
        z += 1
s = x + y + z
for k in range(z+1):
    for j in range(y+z+1-k):
        for i in range(s+1-k-j):
            if i == 0 and j == 0 and k == 0:
                continue
            tmp = 1.0*n
            if i > 0:
                tmp += i*dp[i-1][j][k]
            if j > 0:
                tmp += j*dp[i+1][j-1][k]
            if k > 0:
                tmp += k*dp[i][j+1][k-1]
            dp[i][j][k] = tmp/(i+j+k)
#print(x,y,z)
print(dp[x][y][z])

Measured memory_bytes: 253832
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long K = sc.nextLong();
        if (N == K) {
            System.out.println(0);
        } else if (N > K) {
            if (N % K == 0) {
                System.out.println(0);
            } else {
                N -= K * (N / K);
                solve(N, K);
            }
        } else {
            solve(N, K);
        }
    }

    private static void solve(long N, long K) {
        long comp = K - N;
        System.out.println(Math.min(comp, N));
    }
}

// x * 3 <= 16

Measured memory_bytes: 19668
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    
    cout << a[k-1] << endl;
    
}


Measured memory_bytes: 256
n = int(input())
nums = list(map(int,input().split()))
min = nums[0]
max = nums[0]
sum = 0
for x in range(n):
	if nums[x] > max:
		max = nums[x]
	if nums[x] < min:
		min = nums[x]
	sum += nums[x]

print(min, max, sum)

Measured memory_bytes: 8544
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: u64,
        b: u64,
    }
    let mut ans = 0;
    let l = b - a + 1;
    if a % 2 == 0 {
        if l % 2 == 0 {
            let n_pair = l / 2;
            let ones = if n_pair % 2 == 0 { 0 } else { 1 };
            println!("{}", ones);
        } else {
            let n_pair = l / 2;
            let ones = if n_pair % 2 == 0 { 0 } else { 1 };
            println!("{}", b ^ ones);
        }
    } else {
        if l % 2 == 0 {
            let n_pair = l / 2 - 1;
            let ones = if n_pair % 2 == 0 { 0 } else { 1 };
            println!("{}", (a ^ ones) ^ b);
        } else {
            let n_pair = l / 2;
            let ones = if n_pair % 2 == 0 { 0 } else { 1 };
            println!("{}", a ^ ones);
        }
    }
}


Measured memory_bytes: 4352
def main():
    s = input()
    s = s.replace("BC", "D")
    ans = 0
    cnt = 0
    for i in range(len(s)):
        if s[i] == "A":
            cnt += 1
        elif s[i]=="D":
            ans += cnt
        else:
            cnt=0
    print(ans)
main()

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

int main(){
  int price[3];
  int price_j[2];

  for(int i = 0; i < 3; i++){
    cin >> price[i] ;
  }
  for(int i = 0; i < 2; i ++){
    cin >> price_j[i];
  }

  int min,min_j;
  min = min_j = 3000;
  for(int i = 0; i < 3; i++){
    if(min > price[i] ){
      min = price[i];
    }
  }
  for(int i = 0; i < 2; i++){
    if(min_j > price_j[i]){
      min_j = price_j[i];
    }
  }

  cout << min + min_j - 50 << endl;
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
#include<algorithm>
#include<cstring>
#include<stdio.h>
#include<cstdio>
#include<string.h>
#include<cmath>
int lst[200010];
int main() {
	int k;
	int n;
	int ans;
	cin >> k  >> n;
	for (int i = 0; i < n; i++) {
		cin >> lst[i];
	}
	ans = -lst[n - 1] + lst[0] +k;
	for (int i = 0; i < n - 1; i++) {
		if (lst[i + 1] - lst[i] > ans)ans = lst[i + 1] - lst[i];
	}
	cout << k - ans << endl;
	return 0;
}

Measured memory_bytes: 4356
if __name__ == '__main__':

	s = input()
	s_len = len(s) -1
	A = ""
	for i in range(2**s_len):
		A = s[0]
		for j in range(s_len):
			if i & (1 << j):
				A += "+" + s[j+1]
			else:
				A += "-" + s[j+1]
		if eval(A) == 7:
			break

	print(A + "=7")


Measured memory_bytes: 3060
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: u64,
        b: u64
    }
    let f_check: u64 = if format!("{}{}", a % 10_000 / 1_000, (a / 10_000))
        .parse::<u64>()
        .unwrap()
        >= a % 100
    {
        1
    } else {
        0
    };
    let l_check: u64 = if format!("{}{}", b % 10_000 / 1_000, (b / 10_000))
        .parse::<u64>()
        .unwrap()
        <= b % 100
    {
        1
    } else {
        0
    };

    println!("{}", (b / 100) - (a / 100) - 1 + f_check + l_check)
}


Measured memory_bytes: 4352
import Foundation

func readInts() -> [Int]{
    readLine()!.split(separator: " ").map { Int($0)! }
}

func main(){
    let aryS = readLine()!.map { String($0) }
    print(aryS[2] == aryS[3] && aryS[4] == aryS[5] ? "Yes": "No")
}
main()


Measured memory_bytes: 13088
N = int(input())
A = [int(input()) for _ in range(N)]

c = 0
n = 1
checked = [False for _ in range(N)]
checked[0] = True
for _ in range(N+1):
    n = A[n-1]
    c += 1
    if n == 2:
        ok = True
        break
    if checked[n-1]:
        ok = False
        break
    checked[n-1] = True
if ok:
    print(c)
else:
    print(-1)

Measured memory_bytes: 7852
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = 2e9;
const int MAX_N = 1;

int main() {
  double ans = 0;
  int N; cin >> N;
  for (int i = 0; i < N; i++) {
    string s;
    double x;
    cin >> x >> s;
    if (s[0] == 'B') x *= 380000.0;
    ans += x;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int N, T, t[200000];
    int i, x=0;

    scanf("%d %d", &N, &T);

    for(i=0; i<N; i++)
        scanf("%d", &t[i]);
    
    for(i=0; i<N; i++){
        if(i != N-1){
            if(t[i+1] - t[i] < T)
                x += t[i+1] - t[i];
            else   
                x += T;
        }
        else
            x += T;
    }

    printf("%d\n", x);

    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cassert>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

struct segTree {
	vector<pii> dat;
	int n;
	segTree(){};
	segTree(int n_) {
		n = 1;
		while(n < n_) n *= 2;
		dat.resize(2*n);
		for(int i = 0; i < dat.size(); i++) {
			dat[i].fi = 1e9;
			dat[i].se = 1e9;
		}
	}
	void update(int k, int a) {
		k += n-1;
		dat[k].fi = a;
		dat[k].se = k-(n-1);
		while(k > 0) {
			k = (k-1) / 2;
			dat[k] = min(dat[k*2+1], dat[k*2+2]);
		}
	}
	pii query(int a, int b, int k=0, int l=0, int r=-1) {
		assert(a < b);
		if(r < 0) r = n;
		if (r <= a || b <= l) 
			return pii(1e9,-1);
		if(a <= l && r <= b)
			return dat[k];
		pii vl = query(a, b, k*2 + 1, l, (l+r) / 2);
		pii vr = query(a, b, k*2 + 2, (l+r) / 2, r);
		return min(vl, vr);
	}
};

pii l_indx(int a, int b) {
	int c = a % 2;
	assert((b-a) % 2 == 0);
	return pii(a/2, (b+!c)/2);
}

pii r_indx(int a, int b) {
	pii t = l_indx(a,b);
	if(a % 2) {
		t.fi++; t.se++;
	}
	return t;
}

int main() {
	int N; cin >> N;
	vector<int> p(N);
	rep(i,N) cin >> p[i];
	segTree T[2];
	T[0] = segTree(N/2+10);
	T[1] = segTree(N/2+10);
	rep(i,N) {
		T[i%2].update(i/2,p[i]);
	}
	priority_queue<pair<int,pii> > pq;
	pq.push(pair<int,pii>(-T[0].query(0,N/2).fi, pii(0,N)));

	vector<int> res;
	while(pq.size()) {
		pair<int,pii> t = pq.top(); pq.pop();
		pii x, y;
		pii l, r;
		int s = t.se.fi % 2;

		l = l_indx(t.se.fi, t.se.se);

		x = T[s].query(l.fi, l.se);
		x.se = x.se*2 + s;

		r = r_indx(x.se, t.se.se);

		y = T[!s].query(r.fi, r.se);
		y.se = y.se*2 + !s;

		res.push_back(x.se);
		res.push_back(y.se);

		vector<pair<int,pii> > a;
		a.push_back(pair<int,pii>(-1,pii(t.se.fi, x.se)));
		a.push_back(pair<int,pii>(-1,pii(x.se+1,y.se)));
		a.push_back(pair<int,pii>(-1,pii(y.se+1, t.se.se)));
		for(int i = 0; i < a.size(); i++) {
			//cout << a[i].se.fi << "," << a[i].se.se << endl;
			if(a[i].se.fi == a[i].se.se) continue;
			l = l_indx(a[i].se.fi, a[i].se.se);
			a[i].fi = -T[a[i].se.fi % 2].query(l.fi, l.se).fi;
			pq.push(a[i]);
		}
	}
	rep(i,res.size()) {
		if(i) cout << " ";
		cout << p[res[i]];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 7848
s = gets.chomp
k = gets.chomp.to_i

def pp(o)
  STDERR.puts o.inspect
end

groups = []
current_count = 0
for i in 0..s.length-1 do
  current_count += 1
  if (s[i] != s[i+1]) or i==s.length-1 then
    groups.push(current_count)
    current_count = 0
  end
end
pp groups
# 前後でつながらない場合
if s[0] != s[-1] then
  pp 'A'
  sum = groups.map{|v| v/2}.inject(&:+) * k
else
  # 全部つながる場合
  if groups.length == 1 then
    pp 'B'
    sum = groups[0] * k /2
  else
  # 飛び飛びにつながる場合
    if k==1 then
      pp 'C'
      sum = groups.map{|v| v/2}.inject(&:+)
    else
      pp 'D'
      g_s = groups.clone
      g_m = groups.clone
      g_e = groups.clone
      g_s[-1] += groups[0]
      g_m[-1] += groups[0]
      g_m.delete_at(0)
      g_e.delete_at(0)
      sum = 0
      sum += g_s.map{|v| v/2}.inject(&:+)
      pp sum
      sum += (g_m.map{|v| v/2}.inject(&:+)) * (k-2)
      pp sum
      sum += g_e.map{|v| v/2}.inject(&:+)
      pp sum
    end
  end
end
# 前後でつながる場合
  

print "#{sum}\n"

Measured memory_bytes: 1788
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
from itertools import permutations
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

N = I()

def distance(x,y):
    return (x - y)**2

ls = []
for i in range(N):
    ls.append(LI())

l = list(permutations(ls))

ans =0
for js in l:
    for j in range(len(js)-1):
        ans += sqrt(distance(js[j][0],js[j+1][0]) + distance(js[j][1],js[j+1][1]))

print(ans/len(l)) 

Measured memory_bytes: 25796
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int x,y,z;
  cin >> x >> y >> z;
  printf("%d %d %d\n",z,x,y);
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, i, j;
  cin>>N;
  int a[N];
  for (i=0;i<N;i++){
    cin>>a[i];
  }
  sort(a,a+N);
  int mina=a[0];
  int maxa=a[N-1];
  int sum=1000000;
  for (i=mina; i<=maxa; i++){
    int tmp=0;
    for (j=0; j<N; j++){
      tmp+=(a[j]-i)*(a[j]-i);
    }
    if(sum>=tmp){
      sum=tmp;
    }
  }
  cout<<sum;
}


Measured memory_bytes: 256
from collections import deque

n, k = map(int, input().split())
p = list(map(int, input().split()))

minList = deque()
maxList = deque()
ascList = deque()


def add_list(_k, target):
    global p
    global minList
    global maxList
    global ascList
    while len(minList) > 0 and p[minList[-1]] >= p[target]:
        minList.pop()
    minList.append(target)
    if minList[0] == target - _k:
        minList.popleft()
    while len(maxList) > 0 and p[maxList[-1]] <= p[target]:
        maxList.pop()
    maxList.append(target)
    if maxList[0] == target - _k:
        maxList.popleft()
    if target > 0 and p[target] < p[target-1]:
        ascList.append(target-1)
    if len(ascList) > 0 and ascList[0] == target - _k:
        ascList.popleft()


count = 0
ascend = 0
for i in range(k):
    add_list(k, i)

if len(ascList) == 0:
    ascend += 1
else:
    count += 1
for i in range(k, n):
    tail_is_max = False
    if p[i] > p[maxList[0]]:
        tail_is_max = True
    add_list(k, i)
    head_is_min = False
    if p[i-k] < p[minList[0]]:
        head_is_min = True
    if not (tail_is_max and head_is_min):
        if len(ascList) == 0:
            if ascend == 0:
                ascend += 1
        else:
            count += 1

print(count+ascend)



Measured memory_bytes: 91760
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0; i<(int)n; i++)
#define rep2(i,a,n) for(long long i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const ll mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

ll N, M, K, H, W, L, R, X;
string S, T;

int main(){
  cin >> N;
  vll vec(N+1,1);
  for(ll i=2; i<=N; i++){
    for(ll j = i; j<=N; j += i){
      vec[j]++;
    }
  }
  
  ll ans = 0;
  for(ll i = 1; i<=N; i++){
    ans += i* vec[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 81404
#include <bits/stdc++.h>
using namespace std;
#define rint register int
#define gc() getchar()
inline int read(int r=0,int s=0,int c=gc()){for(;c<48||c>57;s=c,c=gc());for(;c>=48&&c<=57;(r*=10)+=c-48,c=gc());return s^'-'?r:-r;}
string s[15], S, R; unordered_set<string> g; int o[15], n, m, c; bool book[15];
inline void Check()
{
	for(rint i, j = 0; j < m; R = S, reverse(R.begin(),R.end()), g.count(R)?g.erase(R),0:(g.insert(S),0), j++) for(S = "", i = 1; i <= n; S += s[o[i++]][j]);
	if(!g.size()||(m&1&&g.size()==1&&(S=R=*g.begin(),reverse(R.begin(),R.end()),R==S))) return puts("YES"),exit(0); g.clear();
}
void DFS(int i, bool mid)
{
	if(c+1 >= -~n>>1){for(int j = 1, t = c; j <= n; !book[j] ? o[++t] = j : 0, j++); Check(); return;} if(book[i]){DFS(i+1,mid); return;} if(mid) DFS(i+1,0); 
	o[++c] = i, book[i] = true; for(int j = i+1; j <= n; !book[j] ? o[n-c+1] = j, book[j] = true, DFS(i+1,mid), book[j] = false : 0, j++); book[i] = false, --c;
}
int main(){n = read(), m = read(); for(rint i = 1; i <= n; cin >> s[i++]); DFS(1,n&1); return puts("NO"),0;}

Measured memory_bytes: 384
//MADE BY Y_is_sunshine;
//#include <bits/stdc++.h>
//#include <memory.h>
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define pb push_back
#define pf push_front
#define INF 0x3f3f3f3f
#define MAXN (int) 1e6 + 7
#define all(a) a.begin(), a.end()

typedef long long ll;

const ll mod = 1e9 + 7;
const double PI = acos(-1);

using namespace std;

int N, M, K, T;

int dp[MAXN];

signed main(void) {

#ifdef Sunshine
	freopen("data.txt", "r", stdin);
#endif

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

	memset(dp, 0x3f, sizeof(dp));

	cin >> N;
  K = 2;

	vector<int>d(N + 1);
	for (int i = 1; i <= N; i++)
		cin >> d[i];

	dp[1] = 0;
	for (int i = 2; i <= N; i++) {
		for (int j = max(1, i - K); j < i; j++) {
			dp[i] = min(dp[i], dp[j] + abs(d[j] - d[i]));
		}
	}

	cout << dp[N] << '\n';











#ifdef Sunshine
	freopen("CON", "r", stdin);
	system("pause");
#endif
	return 0;
}

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

using namespace std;

int main() {
  int n,i;
  // int mt;
  // vector<int> m;
  string s;
  cin  >> n;
  cin>>s;
  // for (int i = 0; i < n; ++i) {
  //   cin >> mt;
  //   m.push_back(mt);
  // }
  // for (auto l : s) {
  //   cout << l << endl;
  // }



  string uni=s;
  sort(uni.begin(),uni.end());
  decltype(uni)::iterator result = unique(uni.begin(), uni.end());
  uni.erase(result, uni.end());

  vector<int> p;
  for (i = 1; i < n; ++i) {
    string x=s.substr(0,i);
    string y=s.substr(i);
    // cout<<(x.find(uni[i])!=string::npos)<<endl;
    // cout<<(y.find(uni[i])!=string::npos)<<endl;
    // cout<<"slash"<<endl;
    vector<bool> former_hukumare(uni.size());
    vector<bool> later_hukumare(uni.size());
    for (int j=0; j<uni.size() ; j++) {
      bool formaer_aru=false;
      if(x.find(uni[j])!=string::npos)
        formaer_aru=true;
      bool later_aru=false;
      if(y.find(uni[j])!=string::npos)
        later_aru=true;
      if(formaer_aru and later_aru){
        former_hukumare[j]=true;
        later_hukumare[j]=true;
        // cout<<"tttt"p<<j<<endl;
      }
        
    }
    int count=0;
    int f;
    for (f = 0; f < uni.size(); ++f) {
      // cout<<former_hukumare[i]<<endl;
      // cout<<later_hukumare[i]<<endl;
      if(former_hukumare[f] and later_hukumare[f])
        count++;
    }
    p.push_back(count);
  }

  
  int max = *max_element(p.begin(), p.end());
  cout << max << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
    int N, K, ans = 0;
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        if (a >= K) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    string s;
    cin >> s;
    int ans = 0;
    rep(i,s.size()-1) {
        if(s[i]==s[i+1] && s[i] == '0') {
            s[i+1] = '1';
            ans++;
        }
        if(s[i]==s[i+1] && s[i] == '1') {
            s[i+1] = '0';
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>

using namespace std;

typedef long long ll;

void solve() {
	bool x;
	cin >> x;
	cout << !x;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		//cout << endl;
	}
}

Measured memory_bytes: 3608
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[] a = new int[n];
		int[] x = new int[n];
		long ans = 0, b = 0, sum = 0;

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			x[i] = a[i] - (i + 1);
			sum += x[i];
		}
		
		Arrays.sort(x);

		if (n % 2 == 0) {
			if (Math.abs(x[(n / 2) - 1] - (sum / 2)) <= Math.abs(x[n / 2] - (sum / 2))) {
				b = x[(n / 2) - 1];
			} else {
				b = x[n / 2];
			}
		} else {
			b = x[(n / 2)];
		}

		for (int i = 0; i < n; i++) {
			ans += Math.abs(a[i] - (b + (i + 1)));
		}
		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 89240
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define pb                     push_back
#define ll                     long long int
#define fi                     first
#define se                     second
#define ii                     pair<long long int, long long int>
#define vi                     vector <long long int>
#define vii                    vector <pair <long long int, long long int > >
#define all(cont)              cont.begin(), cont.end()
#define EPS                    1e-9
#define MOD                    1000000007
#define range
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
 

int main(){
 
    IOS;
    clock_t clk = clock();
   // freopen("input.txt",  "r", stdin);
   // freopen("output.txt", "w", stdout);
    int a,b;
  cin>>a>>b;
  if(2*b<=a)cout<<a-(2*b);
  else cout<<0;
 
    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  char b;
  cin >> b;

  char ans;
  switch (b) {
    case 'A':
      ans = 'T';
      break;
    case 'T':
      ans = 'A';
      break;
    case 'G':
      ans = 'C';
      break;
    case 'C':
      ans = 'G';
      break;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int H, W, N;
int a[10000];
int ans[100][100];

int main() {
	cin >> H >> W >> N;
	REP(i, N) scanf("%d", a + i);
	
	int p = 0;
	REP(i, N) {
		REP(j, a[i]) {
			if (p % (2 * W) < W) {
				ans[p / W][p % W] = i + 1;
			}
			else {
				ans[p / W][W - 1 - (p % W)] = i + 1;
			}
			p++;
		}
	}
	
	REP(i, H) REP(j, W) printf("%d%c", ans[i][j], j == W - 1 ? '\n' : ' ');
	
	return 0;
}

Measured memory_bytes: 384
s = input()
l = []
for i in s:
  l.append(i)
if l[0] != "A":
  print("WA")
else:
  if len(l) == 3:
    if l[1].islower() and l[2] == "C":
      print("AC")
    else:
      print("WA")
  else:
    l.remove("A")
    if "C" not in l[1:len(l)-1]:
      print("WA")
    else:
      l.remove("C")
      s = "".join(l)
      if s.islower():
        print("AC")
      else:
        print("WA")

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

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

int main() {
  int N, W;
  cin >> N >> W;
  long long w, v;
  long long dp[N+1][W+1] = {};
  for (int i = 0; i < N; ++i){
    cin >> w >> v;
    for (long long j = 0; j < W+1; ++j){
      if (w <= j){
        dp[i+1][j] = max(dp[i][j], dp[i][j-w] + v);
      }
      else{
        dp[i+1][j] = dp[i][j];
      }
    }
  }
  cout << dp[N][W] << endl;
  return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6+10 , OO = 0x3f3f3f3f ;
const int mod = 1e9 + 7;
 
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define xloop(i,a,b) for(int i = int(a);i <= int(b);i++)
#define range(vec) for(auto &x : vec) cin >> x;
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

int a[5];

int main()
{
   // startTime = (double)clock();
    #ifndef ONLINE_JUDGE
        //freopen("in.in", "r", stdin);
        //freopen("out.in", "w", stdout);
    #endif
	//ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    int ans = 0;
    for(int i = 0 ; i < 5 ; ++i){
        scanf("%d" , &a[i]);
        if(a[i] == 0)
            ans = i + 1;
    }

    printf("%d\n" , ans);

    return 0;
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);

int main() {
  ll N; cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  vector<ll> M(N);
  ll sumA = 0;
  ll sum = 0;
  for (int i = 0; i < N; i++) sumA += A[i];
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) sum += A[i];
  }
  M[0] = 2*sum - sumA;
  
  for (int i = 1; i < N; i++) M[i] = 2*A[i-1] - M[i-1];
  
  for (int i = 0; i < N; i++) cout << M[i] << " ";
  cout << endl;
}

Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, L; 
  cin >> N >> L;

  vector<string> s(N);
  REP(i, N) cin >> s[i];

  sort(ALL(s));

  REP(i, N) cout << s[i];
  cout << "\n";

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <string.h>
int main()
{
    int i;
    char s[10];
    scanf("%s",s);
    for(i=0;i<3;i++){
        if(s[i]=='R'){
            s[i]='B';

        }
        else if(s[i]=='B'){
            s[i]='R';
        }

    }
    printf("%s\n",s);

    return 0;


}

Measured memory_bytes: 1604
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, x, y;
  cin >> n;
  vector<vector<int> > red;
  vector<vector<int> > blue;
  REP(i,n){
    cin >> x >> y;
    vector<int> v = {y,x};
    red.push_back(v);
  }
  REP(i,n){
    cin >> x >> y;
    vector<int> v = {x,y};
    blue.push_back(v);
  }
  int ans = 0;
  SORT(red);REV(red);
  SORT(blue);
  REP(i,n){
    REP(j,blue.size()){
      if (red[i][1] < blue[j][0] && red[i][0] < blue[j][1]){
        ans++;
        blue.erase(blue.begin() + j);
        break;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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 long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;
    if (M1 != M2) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  char a;
  cin >> a;
  if(a=='A')
    cout << 'T' <<endl;
   if(a=='T')
    cout << 'A' <<endl;
   if(a=='G')
    cout << 'C' <<endl;
   if(a=='C')
    cout << 'G' <<endl;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            return Array().Select(int.Parse).ToArray();
        }
        public long[] LongArray()
        {
            return Array().Select(long.Parse).ToArray();
        }
    }

    class Program
    {
        private int N, A;
        private void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            A = sc.NextInt();
        }

        public void Solve()
        {
            Scan();
            if(A>=499)
            {
                Console.WriteLine("Yes");
                return;
            }
            if(N%500<=A)
            {
                Console.WriteLine("Yes");
                return;
            }
            Console.WriteLine("No");
        }

        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

Measured memory_bytes: 13140
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// -----------------------------------------------------------------------------
// main
// -----------------------------------------------------------------------------
use std::cmp::min;
fn main(){
    input!{
        d: usize,
        g: i64,
        pc: [(i64,i64); d]
    }
    let mut ans = std::i64::MAX;
    for b in (0..1 << d){
        let mut total = 0;
        let mut cnt = 0;
        // bitが1の問題セットは全部解く
        for i in 0..d as i64{
            if b&(1<<i) != 0{
                total += (i+1)*100*pc[i as usize].0 + pc[i as usize].1;
                cnt += pc[i as usize].0;
            }
        }
        // 目標点数に不足しているなら残りの問題セットで一番配点が高いものを問題数-1まで解く
        if total >= g{
            ans = min(ans,cnt);
        }else{
            let mut si = std::i64::MAX;
            for i in 0..d as i64{
                if b&(1<<i) == 0{
                    si = i;
                }
            }
            if si<std::i64::MAX{
                for _ in 0..pc[si as usize].0-1{
                    total += (si+1)*100;
                    cnt += 1;
                    if total >= g{
                        ans = min(ans,cnt);
                        break;
                    }
                }
            }
        }
    }
    println!("{}", ans);
}



Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

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

		solve(sc, out);

		out.flush();
	}
	
	public static void solve(FastScanner sc, PrintWriter out) {
		String o = sc.next();
		String b = sc.next();
		
		int i = 0;
		
		boolean bool = false;
		while(true) {
			if(i < o.length()) {
				out.print(o.charAt(i));
				bool = true;
			}
			if(i < b.length()) {
				out.print(b.charAt(i));
				bool = true;
			}
			if(bool) bool = false; else break;
			i++;
		}
	}
	
	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

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

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

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

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

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

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

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

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

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

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

int main(){
  int n;
  cin>>n;
  vector<int>vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  int count=0,anscount=0;
  for(int i=0;i<n;i++){
    for(int k=0;k<=i;k++){
      if(vec.at(k)<=vec.at(i)){
        count++;
      }
    }
    if(count>=i+1){
      anscount++;
    }
      count=0;
  }
  cout<<anscount<<endl;
}

Measured memory_bytes: 256