akhauriyash/Code-Regression huggingface dataset:
/// wa ^3^

#pragma GCC optimize("O3")

#include<bits/stdc++.h>
                           
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

void stndrtn() {
#ifdef accepted
    freopen(".in", "r", stdin);
#endif        
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    int n, m;
    cin >> n >> m;
    vector<vector<char>> c(n, vector<char>(m));
    for (vector<char>& v : c)
        for (char& x : v)
            cin >> x;
    vector<vector<int>> dp(n, vector<int>(m));
    for (int i = 0; i < n; ++i) {
        if (i && c[i][0] == c[i-1][0] && c[i][0] == '#')
            dp[i][0] = dp[i-1][0];
        else
            dp[i][0] = (i ? dp[i-1][0] : 0) + (c[i][0] == '#');
    }            
    for (int j = 0; j < m; ++j) {
        if (j && c[0][j] == c[0][j-1] && c[0][j] == '#')
            dp[0][j] = dp[0][j-1];
        else
            dp[0][j] = (j ? dp[0][j-1] : 0) + (c[0][j] == '#');
    }            
    for (int i = 1; i < n; ++i)
        for (int j = 1; j < m; ++j) {
            if (c[i][j] == '#')
                dp[i][j] = min(dp[i-1][j] + (c[i-1][j] == '.'), dp[i][j-1] + (c[i][j-1] == '.'));
            else
                dp[i][j] = min(dp[i-1][j], dp[i][j-1]);
        }
    cout << dp[n-1][m-1];

    return 0;
}



Measured memory_bytes: 384
abcd = [int(i) for i in input()]
a = abcd.pop(0)
op = ''
check = 0
for i in range(1 << len(abcd)):
  check = a
  op = ''
  for j in range(len(abcd)):
    if ((i >> j) & 1) == 1:
      check += abcd[j]
      op += '+'
    else:
      check -= abcd[j]
      op += '-'
  if check == 7:
    print(str(a)+op[0]+str(abcd[0])+op[1]+str(abcd[1])+op[2]+str(abcd[2])+'=7')
    break

Measured memory_bytes: 3064
a1, a2 = gets.chomp.split(' ').map(&:to_i)
a3, a4 = gets.chomp.split(' ').map(&:to_i)
a5, a6 = gets.chomp.split(' ').map(&:to_i)

array = []
array << a1
array << a2
array << a3
array << a4
array << a5
array << a6

array.sort!

ans1 = array.count(1)
ans2 = array.count(2)
ans3 = array.count(3)
ans4 = array.count(4)


if ans1 >= 3 || ans2 >= 3 || ans3 >= 3 || ans4 >= 3
  puts 'NO'
else
  puts 'YES'
end



Measured memory_bytes: 1788
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	std::string S;
	std::cin >> S;
	
	bool chars[26] = {};
	for (auto ch : S) {
		if (chars[ch-'a']) {
			std::cout << "no\n";
			return 0;
		}
		chars[ch-'a'] = true;
	}
	std::cout << "yes\n";
}


Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <iomanip>
#include <deque>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std;
int n;
int ans=0;
const double eps=1e-9;
typedef vector<int> vi;
typedef long long ll;
const bool Black=true;
const bool White=false;
int l,k;
ll dp[105][2];
ll solve(int tall,bool black)
{
  if(dp[tall][black]!=-1) return dp[tall][black];
  ll res=0;
  if(tall>l || (tall==l && !black)) return 0;
  if(tall<=l && black) res+=1;
  if(black)
    {
      res+=solve(tall+1,White);
    }
  else
    {
      res+=solve(tall+k,Black);
      res+=solve(tall+1,Black);
    }
  return dp[tall][black]=res;
}
int main(void)
{
  memset(dp,-1,sizeof(dp));
  cin >> l >> k;
  cout << solve(0,White) << endl;;
  return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100010];
int main()
{
    int i, j, k;
    int n, t, m;
    cin >> n;
    for(i = 1; i <= n; i++) {
        cin >> k;
        if(k % 2 == 0) {
            if(k%3 && k%5) {
                break;
            }
        }
    }
    if(i <= n) {
        puts("DENIED");
    }
    else puts("APPROVED");
    return 0;
}


Measured memory_bytes: 256
Imports System
Public Class A100
    Public Shared Sub Main()
        Dim N As Integer
        N = Console.ReadLine()
        Dim a, b, c, d As Integer
        d = N Mod 10
        c = ((N - d) / 10) Mod 10
        b = ((N - d - 10 * c) / 100) Mod 10
        a = (N - d - 10 * c - 100 * b) / 1000
        If (a = b And b = c) Or (b = c And c = d) Then
            Console.WriteLine("Yes")
        Else
            Console.WriteLine("No")
        End If
    End Sub
End Class


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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};

int h, w;
int a[200][200], c[10][10], b[10];
int memo[10][1<<10+1];
int dp(int now, int use){
	if(now == 1) return 0;
	if(memo[now][use] != inf) return memo[now][use];

	int ret = inf;
	for(int i = 0; i <= 9; i++){
		if(!(use>>i & 1)){
			ret = min(ret, c[now][i] + dp(i, use|1<<i));
		}
	}

	return memo[now][use] = ret;
}

void syori(){
	fn(*memo, 10*(1<<10+1), inf);
	for(int i = 0; i <= 9; i++){
		b[i] = dp(i, 1<<i);
	}
}

int main(){
	cin >> h >> w;
	for(int i = 0; i <= 9; i++){
		for(int j = 0; j <= 9; j++){
			cin >> c[i][j];
		}
	}
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> a[i][j];
		}
	}

	syori();
	int ans = 0;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(a[i][j] != -1){
				ans += b[a[i][j]];
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

#define abs(a) ((a)<0 ? -(a) : (a))

int main(){
	int N, L;
	scanf("%d %d", &N, &L);
	int a[N], i, min=99999, sum=0;
	for(i=0; i<N; i++){
		a[i] = L+i;
		sum += a[i];
		if (abs(a[i]) < min) min = abs(a[i]);
	}
	
        if (sum<0) min = -min;
	printf("%d", sum-min);
	
	return 0;
}

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

L = len(A)
from functools import reduce
from fractions import gcd

def lcm(a,b):
  return (a*b)//gcd(a,b)

g = reduce(gcd, A)
l = reduce(lcm, A)

def _gcd(a,b):
  if a is None and b is None:
    return None
  if a is None:
    return b
  if b is None:
    return a
  else:
    return gcd(a,b)

class SegTree():
  import math
  def __init__(self, func, A, identity=1):
    self._func = func
    self._N = 1
    while self._N < len(A):
      self._N *= 2
       # 長さ 7 なら N=3 (2^3=8)
    self._identity = identity # maxなら-1e9, sumなら0, productなら1

    self._tree = [self._identity] * (2*self._N -1) 
    self._tree[self._N-1:self._N-1+ len(A)] = A #最下段に元の配列を
    for i in range(self._N-2, -1, -1):
      self._update_single_node(i)
    ########
    # N=3: #
    # 0000 #
    # 1122 #
    # 3456 #
    ########
    self._node_range = [(i-self._N+1,i-self._N+2) for i in range(2*self._N-1)] #right_exclusive
    for i in range(self._N-2, -1, -1):
      self._node_range[i] = (self._node_range[2*i+1][0], self._node_range[2*i+2][1])

  def _update_single_node(self,i):
    self._tree[i] = self._func(self._tree[2*i+1], self._tree[2*i+2])

  def point_update(self,i,x):
    # A[i] = x (addではないので注意)
    j = self._N-1+i
    self._tree[j] = x
    while j>0:
      j = (j-1)//2
      self._update_single_node(j)

  def range_query(self, l, r, on=0):
    # reduce(func, A[l:r])
    # onはノード[on]上と重なる部分の，ということ
    onl, onr = self._node_range[on]
    
    # ノード[on]上はすべて覆う
    if l<=onl and onr<=r:
      return self._tree[on]
    
    # 重なりなし
    elif onr<=l or r<=onl:
      return self._identity
    
    else:
      return self._func(self.range_query(l, r, on=2*on+1),
                        self.range_query(l, r, on=2*on+2))

st = SegTree(_gcd, A, identity=None)

answer = 0
for i in range(len(A)):
  st.point_update(i, A[i-1])
  answer = max(answer, st._tree[0])
  st.point_update(i, A[i])

print(answer)

Measured memory_bytes: 111976
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    ll X; cin >> X;
    ll p= 100;
    ll c = 0;
    while(p < X){
        p = floor(p*1.01);
        c++;
    }
    cout << c;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  string X;
  cin >> X;
  int N = X.size();
  for (int i = 1; i < X.size(); i++) {
    if (X[i-1] == 'S' && X[i] == 'T') {
      X.erase(i-1,2);
      i-=2;
    }
  }
  cout << X.size() << endl;
  return 0;
}

Measured memory_bytes: 640
#!/usr/bin/python3

#標準出力からの読み込み
input_1 = input()
last_word = input_1[-1]

#判定ロジック
if last_word in ['2','4','5','7','9']:
    print("hon")
elif last_word in ['0','1','6','8']:
    print("pon")
elif last_word in ['3']:
    print("bon")


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

typedef long long ll;
const int maxn = 1e5+120;
ll dp[maxn],v[120],w[120];

int main() {
	std::ios::sync_with_stdio(false);
    ll N,W,ans = 0;
    cin >> N >> W; 
	for(int i=1; i<maxn; i++) dp[i] = W+1;
	for(int i=1; i<=N; i++) cin >> w[i] >> v[i];
	for(ll i=1; i<=N; i++) {
		//1e3*100
		for(ll j=1e5+100; j>=v[i]; j--) {
			dp[j] = min(dp[j],dp[j-v[i]]+w[i]);
			if(dp[j] <= W) ans = max(ans,j);
		}
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

int main(void)
{
	char vx[] = { 0, 1, 0, -1,  0, 1, 0};
	char vy[] = {-1, 0, 1,  0, -1, 0, 1};
	char cx[4][3] = {{0, 0, 0}, {0, 0, -1}, {0, -1, 0}, {-1, 0, 0}};
	char cy[4][3] = {{-1, 0, 0}, {0, 0, 0}, {0, 0, -1}, {0, -1, 0}};
	char cw[] = {3, 0, 1, 2, 3, 0, 1, 2};
	char op[] = "URDLURDL";
	char w;
	int i, j;
	char map[3][102][102];
	int n;
	int x, y;
	
	n = 1;
	memset(map, 0, sizeof(map));
	while (1){
		for (i = 0; i < 2; i++){
			if (scanf("%s", map[i][n]) == EOF){
				goto A;
			}
			for (j = strlen(map[i][n]); j >= 0; j--){
				map[i][n][j + 1] = map[i][n][j];
			}
			map[i][n][0] = 0;
		}
		n++;
	}
	A:
	
	x = 2;
	y = 1;
	w = 0;
	printf("R");
	while (x != 1 || y != 1){
		for (i = 0; i < 4; i++){
			if (i == 3 || map[!((w + i) % 2)][y + cy[w][i]][x + cx[w][i]] == '1'){
				x += vx[w + i];
				y += vy[w + i];
				printf("%c", op[i + w]);
				w = cw[i + w];
				break;
			}
		}
	}
	
	printf("\n");
	
	return (0);
}

Measured memory_bytes: 552
#include<stdio.h>
#include<string.h>
int main()
{
    long long int N,i,sum=0;
    scanf("%lld",&N);
    for(i=1;i<=N;i++)
    {
       if((i%3)==0||(i%5)==0)
        continue;
       else
        sum+=i;
    }
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 1728
package main

import (
	"fmt"
)

func main() {
	var s string
	var k int
	fmt.Scan(&s, &k)

	for i := 0; i < k; i++ {
		if string(s[i]) != "1" {
			fmt.Println(string(s[i]))
			return
		}
	}
	fmt.Println(1)
}


Measured memory_bytes: 512
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    let mut s = io.chars();
    let n = s.len();

    for i in 1..n {
        let ss = &s[0..n - i];
        let nn = ss.len();
        let mut found = true;
        if i % 2 == 1 {
            continue;
        }
        for j in 0..nn / 2 {
            if ss[j] != ss[nn / 2 + j] {
                found = false;
                break;
            }
        }
        if found {
            io.writeln(nn);
            break;
        }
    }
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 2196
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <random>
#include <array>
#include <chrono>
#include <cmath>
#include <memory>
#include <map>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

using llint=long long;

llint scoring(vector<llint> c,
            vector<vector<llint>> s,
            vector<llint> result,
            llint d=365){
    
    if(c.size()!=s[0].size()||s.size()!=result.size()){
         return -1;
    }else{
        llint score=0;
        REP(i,d){
            score+=s[i][result[i]-1];
            REP(j,26){
                if(j+1!=result[i]){
                    score-=c[j];
                }
            }
        }
        return score;
    }
 }

int main(){
    chrono::system_clock::time_point start, end;
    std::random_device rnd;     // 非決定的な乱数生成器を生成
    std::mt19937 mt(rnd());     //  メルセンヌ・ツイスタの32ビット版、引数は初期シード値
    start = chrono::system_clock::now();
    llint d;
    cin>>d;
    std::uniform_int_distribution<> rand26(1, 26),randd(0,d-1);        // [0, 99] 範囲の一様乱数
    
    llint anum=26;
    vector<llint> c(anum);
    
    REP(i,anum){
        cin>>c[i];
    }
    vector<vector<llint>> s(d,vector<llint>(anum));
    REP(i,d){
        REP(j,anum){
            cin>>s[i][j];
        }
    }
    vector<llint> result(d);

    REP(i,d){
        result[i]=1+i%26;
    }
    double time;
    while(( time = static_cast<double>(chrono::duration_cast<chrono::microseconds>(
        ( end = chrono::system_clock::now()) - start).count()
        ))<1800000){
        auto newresult=result;
        REP(i,20){
            newresult[randd(mt)]=rand26(mt);
        }
        if(scoring(c,s,newresult,d)>scoring(c,s,result,d)){
            result=newresult;
        }
    }
    REP(i,d){
        cout<<result[i]<<endl;
    }
}


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

struct road{
    int goal;
    long cost;
};

vector<vector<road>> roads;
vector<long> K_distance;

void find_distance(int now, long cost_all){
    if(K_distance[now] == -1){
        K_distance[now] = cost_all;
        for(int i = 0; i < roads[now].size(); i++){
            find_distance(roads[now][i].goal, cost_all + roads[now][i].cost);
        }
    }
}

int main(){
    int N;
    cin >> N;
    roads.resize(N);
    for(int i = 0; i < N - 1; i++){
        int start, goal;
        long cost;
        cin >> start >> goal >> cost;
        roads[start - 1].push_back({goal - 1, cost});
        roads[goal - 1].push_back({start - 1, cost});
    }
    int Q, K;
    cin >> Q >> K;
    K_distance.resize(N);
    fill(K_distance.begin(), K_distance.end(), -1);
    find_distance(K - 1, 0);
    for(int i = 0; i < Q; i++){
        int start, goal;
        cin >> start >> goal;
        cout << K_distance[start - 1] + K_distance[goal - 1] << endl;
    }
}


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

#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

int main() {
	int N,K;
	cin>>N>>K;
	int ans=N-K+1;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
using P = pair<int,int>;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)

/* modとる */
inline ll modu(ll a){
    return(a % mod + mod) % mod;
}

/* 逆元(法mod = 1e7) */
ll modinv(ll a){
    ll b = mod, u = 1, v = 0;
    while (b){
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
        }
    return modu(u);
}

/* modつき二分累乗法 */
ll modpow(ll a, ll b) {
    ll res = 1;
    for (a = modu(a); b; a = modu(a * a) , b >>= 1){
        if (b & 1) res = modu(res * a);
    }
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    ll n,a,b;
    cin >> n >> a >> b;
    ll nca = 1,ncb = 1;
    REP(i,a){
        nca = modu(nca*modu((n-i)*modinv(i+1)));
    }
    REP(i,b){
        ncb = modu(ncb*modu((n-i)*modinv(i+1)));
    }
    ll answer = modu(pow(2,n) - ncb - nca - 1);
    cout << answer << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FOR(i,a,b) for(ll i=a; i<= b; ++i)
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define vi vector<int>
#define pb push_back
#define MOD 1000000007
typedef long long ll;

ll solve(ll a,ll b)
{
    return a*b;
}

int main(){
    optimize();
    ll T=1;
    //cin>>T;
    while(T--)
    {
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        ll max = -1e18;

        if(max < solve(a,c))
            max = solve(a,c);

        if(max < solve(a,d))
           max = solve(a,d);

        if(max < solve(b,c))
            max = solve(b,c);

        if(max < solve(b,d))
            max = solve(b,d);

        cout<<max<<endl;
    }
    return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,k;
  cin>>n>>k;
  vll a(n);
  rep(i,n) cin>>a[i];
  vll b(n+1,0);
  rep(i,n){
    b[i+1]+=b[i]+a[i];
  }
  map<ll,ll> p;
  ll ans=0;
  rep(i,n+1){
    if(i>=k){
      ll h=(b[i-k]-i+k)%k;
      if(h<0) h+=k;
      p[h]--;
    }
    ll cu=(b[i]-i)%k;
    if(cu<0) cu+=k;
    ans+=p[cu];
    p[cu]++;
  }
  COUT(ans);
}

Measured memory_bytes: 18852
N = int(input())
lis = []
indexes = []
cou = 1
ans = []
c_p = 0
for _ in range(N):
  lis.append(input())
lis.sort()
if len(lis) != len(set(lis)):
  lis.append("zzzzzzzzzzzzzz")
  for i in range(N):
    if lis[i] == lis[i+1]:
      cou += 1
    else:
      indexes.append(cou)
      cou = 1
  L = len(indexes)
  M = max(indexes)
  for k in range(L):
    if indexes[k] == M:
      ans.append(lis[c_p])
    c_p += indexes[k]
  print(*ans)
else:
  print(*lis)

Measured memory_bytes: 29632
import random

mod=998244353
N,X=input().split()
N=int(N)
A=[]
for i in range(N):
    A.append(int(input(),2))
A.sort()

a=A[-1]
M=max(len(X)-1,a.bit_length()-1)
data=[0]*(M+1)
n=a.bit_length()-1
for i in range(M-n,-1,-1):
    data[i+n]=a<<i

for i in range(0,N-1):
    a=A[i]
    flag=True
    while flag:
        n=a.bit_length()
        for j in range(n-1,-1,-1):
            a=min(a,a^data[j])
        if a!=0:
            data[a.bit_length()-1]=a
            id=a.bit_length()-1
            while data[id+1]==0:
                data[id+1]=min((data[id]<<1)^a,(data[id]<<1))
                if data[id+1]:
                    id+=1
                else:
                    flag=False
            else:
                a=data[id]<<1
        else:
            break

data2=[0]*(M+1)
for i in range(M+1):
    data2[i]=(data[i]!=0)

for i in range(1,M+1):
    data2[i]+=data2[i-1]

data2=[0]+data2

#print(data)
#print(data2)

x=0
ans=0
n=len(X)-1
for i in range(len(X)):
    if X[i]=="1":
        if x>>(n-i)&1==1:
            if data[n-i]:
                ans+=pow(2,data2[n-i],mod)
                ans%=mod
        else:
            ans+=pow(2,data2[n-i],mod)
            ans%=mod
            if data[n-i]:
                x=x^data[n-i]
            else:
                break
    else:
        if x>>(n-i)&1==1:
            if data[n-i]:
                x=x^data[n-i]
            else:
                break
        else:
            continue
else:
    ans+=1
    ans%=mod
print(ans)

Measured memory_bytes: 85416
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, K; cin >> N >> K;
    vector<int> v(N);
    for (int i = 0; i < N; i++) cin >> v[i];
    int maxV = 0;
    for (int l = 0; l <= K; l++) {
        for (int r = 0; r <= K; r++) {
            int outNum = l + r;
            if (outNum > min(N,K)) continue;
            int rest = K - outNum;
            vector<int> hand;
            hand.insert(hand.end(), v.begin(), v.begin() + l);
            hand.insert(hand.end(), v.rbegin(), v.rbegin() + r);
            sort(hand.begin(), hand.end());
            int tmp = 0;
            for (int i = 0; i < outNum; i++) {
                if (i < rest && hand[i] < 0) continue;
                tmp += hand[i];
            }
            maxV = max(tmp, maxV);
        }
    }
    cout << maxV << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<memory.h>
using namespace std;
int arr[10],used[10];
void DFS(int pre,int cur)
{
   if(cur<10&&arr[pre]<arr[cur])
   {
       used[cur]=1;
       DFS(cur,cur+1);
   }
   else if(cur<10&&arr[pre]>=arr[cur])
       DFS(pre,cur+1);
}
int main()
{
   int T,pre;
   bool judge;
   cin>>T;
   while(T--)
   {
     for(int i=0;i<10;i++)
         cin>>arr[i];
     for(int i=0;i<10;i++)
     {
         memset(used,0,sizeof(used));
         used[i]=1;
         DFS(i,i+1);
         judge=false;
         pre=0;
         for(int j=0;j<10;j++)
            if(used[j]==0)
                if(pre>=arr[j])
            {
                judge=true;
                break;
            }else pre=arr[j];
         if(!judge)
         {
             cout<<"YES"<<endl;
             break;
         }
     }
     if(judge)cout<<"NO"<<endl;
   }

}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

ll f(ll n, ll a)
{
  return n / a;
}

int main()
{
  ll n;
  cin >> n;
  bool even = (n % 2 == 0);
  if (!even)
  {
    cout << 0 << endl;
    return 0;
  }
  ll five = 0;
  ll pow5 = 5;
  while (n / pow5 > 0)
  {
    if (even)
    {
      five += f(n, 2 * pow5);
    }
    else
    {
      five += f(n, pow5) - f(n, 2 * pow5);
    }
    pow5 *= 5;
  }

  cout << five << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int mod = 1000000007;
const int modx = 998244353;
#define ll long long
#define readi(x) scanf("%d", &x)
#define reads(x) scanf("%s", x)
#define readl(x) scanf("%I64d", &x)
#define rep(i, n) for (i = 0; i < n; i++)
#define rep1(i, a, b) for (i = a; i < b; i++)
#define rep2(i, a, b) for (i = b; i >= a; i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bpc(x) __builtin_popcount(x)
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pdd pair<double, double>
#define pic pair<int, char>
#define ddouble long double
#define PI 3.1415926535
#define endl "\n"
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define prod(x, y) ((x % mod) * (y % mod)) % mod
#define add(x, y) ((x % mod) + (y % mod)) % mod
#define ub(a, b) upper_bound(all(a), b)
#define lb(a, b) lower_bound(all(a), b)
#define pqs priority_queue<int, vector<int>, greater<int>>
#define pqb priority_queue<int>
#define mii map<int, int>
#define mll map<ll, ll>
using namespace std;
//using namespace __gnu_pbds;
/*ll power(ll x, ll y)
{
    ll r = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            r = (r*x) % mod;

        y = y>>1;
        x = (x*x) % mod;
    }
    return r;
}*/
const int N = 1e5 + 5;
int n, m;
int dp[N] = {}, ans = 0, vis[N] = {};
vi a[N];
void dfs(int s)
{
    vis[s] = 1;
    for (auto it : a[s])
    {
        if (!vis[it])
            dfs(it);
        dp[s] = max(dp[s], 1 + dp[it]);
    }
    ans = max(ans, dp[s]);
    return;
}
void thunder()
{
    int n, m, i;
    cin >> n >> m;
    rep(i, m)
    {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        a[x].pb(y);
    }
    rep(i, n)
    {
        if (!vis[i])
            dfs(i);
    }
    cout << ans << endl;
    return;
}
int main()
{
    /*#ifndef ONLINE_JUDGE
	    freopen("input.txt", "r", stdin);
	    freopen("output.txt", "w", stdout);
	#endif*/
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll q = 1;
    //cin >> t;
    while (q--)
        thunder();
}


Measured memory_bytes: 12544
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}
func absint(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var n int
	fmt.Sscan(getNextLine(scanner), &n)
	aa := getIntList(scanner)
	sum := int64(0)
	bits := 0
	min := absint(aa[0])
	for i := 0; i < n; i++ {
		if aa[i] < 0 {
			bits++
		}
		abs := absint(aa[i])
		sum += int64(absint(aa[i]))
		if min > abs {
			min = abs
		}
	}
	if bits%2 == 1 {
		sum -= int64(2 * min)
	}
	fmt.Println(sum)
}


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


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
 
    int n;
    cin>>n;
    int a;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a%2==0){
            if(a%3 && a%5){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int L;
    string S, s1, s2, s3, s4;
    s1 = "maerd";
    s2 = "remaerd";
    s3 = "esare";
    s4 = "resare";

    cin >> S;

    L = S.length();

    reverse(S.begin(), S.end());

    bool flag = true;
    int i = 0;
    while (i < L){
        if (S.substr(i, 5) == s1 or S.substr(i, 5) == s3){
            i += 5;
        }
        else if (S.substr(i, 7) == s2){
            i += 7;
        }
        else if (S.substr(i, 6) == s4){
            i += 6;
        }

        else{
            flag = false;
            break;
        }
    }

    if (flag == true){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	string s = "", t = "";
	for(int i = 0; i < b; ++i) {
		s += (char)(a + '0');
	}
	for(int i = 0; i < a; ++i) {
		t += (char)(b + '0');
	}
	cout << ((s < t) ? s : t) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long  long
#define ld long double
#define mod 1000000007
#define max_char 128
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define lbd lower_bound
#define ubd upper_bound
#define PI 3.141592653589793238
#define pf push_front
#define all(x) x.begin(),x.end()
#define input(arr,n) for(ll c1=0;c1<n;c1++)cin>>arr[c1];
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define mems(x, y) memset(x, y, sizeof(x))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;


int main()
{
    fastio
	ll m,n,i,sum=0;
	cin>>m>>n;
	ll a[n];
	input(a,n);
	for(i=0;i<n;i++)
	sum+=a[i];
	
	if(sum>m)
	cout<<-1;
	else cout<<m-sum;
	return 0;
}

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int n;
    cin >> n;

    vector<ll> a(n);
    ll rest = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (i > 1) rest ^= a[i];
    }

    ll sum = a[0] + a[1];
    if (sum < rest || (sum - rest) % 2 == 1) {
        //cerr << "odd " << (sum <= rest) << newl;
        cout << -1 << newl;
        return 0;
    }

    ll hoge = (sum - rest) / 2;
    if (hoge > a[0]) {
        //cerr << "small\n";
        cout << -1 << newl;
        return 0;
    }

    for (int i = 0; i < 40; i++) {
        bool f1 = (hoge >> i & 1);
        bool f2 = (rest >> i & 1);
        if (f1 && f2) {
            //cerr << "mismatch\n";
            cout << -1 << newl;
            return 0;
        }
    }

    ll foo = hoge;
    for (int i = 39; i >= 0; i--) {
        if (rest >> i & 1) {
            if (foo + (1LL << i) <= a[0]) {
                foo += (1LL << i);
            }
        }
    }
    cout << (foo == 0 ? -1 : a[0] - foo) << newl;

    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(), a.end()

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

    string s;
    cin >> s;

    if(s == "AAA" || s == "BBB")
        cout << "No";
    else
        cout << "Yes";
    cout << "\n";
    return 0;
}


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

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

	int start = a <= c ? c : a;
	int end = b <= d ? b : d;
	int delta = end - start;
	if (delta < 0)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << end - start << endl;
	}
}


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

string s, r = "yuiophjklnm";

int main(){
	while (cin >> s && s != "#") {
		char fg; 
		int c = 0;
		for (int i = 0; i < s.size(); i++) {
			fg &= 0x01;
			for (int j = 0; j < r.size(); j++) {
				if (s[i] == r[j]) {
					fg |= 0x02;
					break;
				}
			}
			if (i == 0) {
				fg = fg >> 1;
			}
			else {
				if (fg == 0x01 || fg == 0x02) {
					c++;
					fg = fg >> 1;
				}
			}
		}
		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 3156
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    try (PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in)) {
      Task task = new Task();
      task.solve(sc, out);
      out.flush();

    } catch (Exception e) {
      // DO NOT USE
    }
  }

  static class Task {
    public void solve(Scanner sc, PrintWriter out) {
      // TODO
      int n = nint(sc);
      int x = nint(sc);

      int[] xArray = new int[n];

      for (int i = 0; i < n; i++) {
        xArray[i] = Math.abs(x - nint(sc));
      }

      if (n == 1) out.println(xArray[0]);
      else {
        long ans = gcd(xArray[0], xArray[1]);
        for (int i = 2; i < n; i++) {
          ans = gcd(ans, xArray[i]);
        }
        out.println(ans);
      }
    }
  }

  // method
  static int nint(Scanner sc) {
    return Integer.parseInt(sc.next());
  }

  static long nlong(Scanner sc) {
    return Long.parseLong(sc.next());
  }

  static double ndouble(Scanner sc) {
    return Double.parseDouble(sc.next());
  }

  static float nfloat(Scanner sc) {
    return Float.parseFloat(sc.next());
  }

  static String nstr(Scanner sc) {
    return sc.next();
  }

  static long[] longLine(Scanner sc, int size) {
    long[] lLine = new long[size];
    for (int i = 0; i < size; i++) {
      lLine[i] = nlong(sc);
    }
    return lLine;
  }

  static int[] intLine(Scanner sc, int size) {
    int[] iLine = new int[size];
    for (int i = 0; i < size; i++) {
      iLine[i] = nint(sc);
    }
    return iLine;
  }

  static String[] strLine(Scanner sc, int size) {
    String[] strLine = new String[size];
    for (int i = 0; i < size; i++) {
      strLine[i] = nstr(sc);
    }
    return strLine;
  }

  static long maxFromList(List<Long> longList) {
    return longList.stream().max(Comparator.naturalOrder()).get();
  }

  static long minFromList(List<Long> longList) {
    return longList.stream().min(Comparator.naturalOrder()).get();
  }

  static int sumDigits(int n) {
    int sum = 0;
    while (n != 0) {
      sum += n % 10;
      n /= 10;
    }
    return sum;
  }

  static long sumDigits(long n) {
    long sum = 0;
    while (n != 0) {
      sum += n % 10;
      n /= 10;
    }
    return sum;
  }

  static List<Integer> getIntegerList(Scanner sc, int size) {
    List<Integer> list = new ArrayList<>();
    for (int i = 0; i < size; i++) {
      list.add(nint(sc));
    }
    return list;
  }

  static List<Long> getLongList(Scanner sc, int size) {
    List<Long> list = new ArrayList<>();
    for (int i = 0; i < size; i++) {
      list.add(nlong(sc));
    }
    return list;
  }

  static long gcd(long m, long n) {
    if (m < n) return gcd(n, m);
    if (n == 0) return m;
    return gcd(n, m % n);
  }
}


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

int main()
{
    long long n;cin>>n;
    vector<long long>a(n);
    int i;
    for(i=0;i<n;i++)cin>>a.at(i);
    vector<long long> sum(n,0);
    sum.at(0)=a.at(0);
    for(i=1;i<n;i++)
    {
        sum.at(i)=sum.at(i-1)+a.at(i);
    }
    long long ans=12345678901234567;
    for(i=0;i<n-1;i++)
    {
        long long kans=abs(sum.at(n-1)-sum.at(i)-sum.at(i));
        if(kans<ans)ans=kans;
    }
    cout<<ans<<endl;
}


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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-indexか1-indexでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-index昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-index昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-index降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-index降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(15);
    
    ll n; cin >> n;
    ll ans1, ans2, ans3;
    for(ll i = 1; i <=3500; ++i) {
        for(ll j = 1; j <= 3500; ++j) {
            if((4*i*j-n*(i+j))<=0) continue;
            if(i*j*n<=0) continue;
            if(((i*j*n)%(4*i*j-n*(i+j)))==0) {
                ans1 = i; ans2 = j;
                ans3 = (((i*j*n)/(4*i*j-n*(i+j))));
                break;
            } 
        }
    }
    cout << ans1<<' ' << ans2<<' ' << ans3 << '\n';
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    string s,t;
    cin >> s >> t;
    Yes(s == t.substr(0,s.size()));
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define re return
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
int n;
vector<pair<int,int> >v[100010];
bool vis[100010];
bool col[100010];
void dfs(int nw,int even){
	vis[nw]=1;
	for(int i=0;i<v[nw].size();i++){
		int to=v[nw][i].first,cc=v[nw][i].second;
		if(vis[to]==1)continue;
		if((even+cc)%2==1)col[to]=1;
		dfs(to,(even+cc)%2);
	}
}
int main() { 
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	int a,b,c;
	for(int i=0;i<n-1;i++){
		cin>>a>>b>>c;
		a--;
		b--;
		v[a].push_back({b,c});
		v[b].push_back({a,c});
	}
	dfs(0,0);
	for(int i=0;i<n;i++){
		cout<<col[i]<<endl;
	}
    return 0; 
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

int main()
{
  long long int n;
  long long int count = 0;
  cin>>n;
  for(int i=1;i<n;i++){
    count+=(n/i);
    count-=(n%i == 0)?1:0;
  }
  cout<<count;
  return 0;
}


Measured memory_bytes: 3628
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

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



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



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

	if (n % 2 != 0) {
		cout << "No" << endl;
		return 0;
	}

	for (int i = 0; i < n/2; i++) {
		if (s[i] != s[i + n / 2]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}


Measured memory_bytes: 3592
#include <stdio.h>

int main(){
  int h, w, i, j;
  while(scanf("%d%d", &h, &w) && h && w){
    for(i = 0;i < h;i++){
      for(j = 0;j < w;j++){
        if(!i || !j || i == h - 1 || j == w - 1) putchar('#');
        else putchar('.');
      }
      puts("");
    }
    puts("");
  }
  return 0;
}

Measured memory_bytes: 588
#include <algorithm>
#include <array>
#include <cstdio>
#include <iostream>
#include <queue>
using namespace std;
#define FOR(i, n) for (int i = 0; i < (int)(n); i++)
vector<bool> seen;
vector<int> ans(3000, 0);
int d[3000][3000];
vector<vector<int>> G(3000);

void bfs(int s) {
  queue<int> q;
  q.push(s);
  seen[s] = true;

  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (auto next_v : G[v]) {
      if (seen[next_v]) continue;
      seen[next_v] = true;
      q.push(next_v);
      d[s][next_v] = d[s][v] + 1;
      ans[d[s][next_v]]++;
    }
  }
}

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  X--;
  Y--;
  FOR(i, N - 1) {
    G[i].push_back(i + 1);
    G[i + 1].push_back(i);
  }
  G[X].push_back(Y);
  G[Y].push_back(X);
  FOR(i, N) FOR(j, N) d[i][j] = 0;

  FOR(i, N) {
    seen.assign(N, false);
    bfs(i);
  }

  for (int i = 1; i < N;i++) cout << ans[i] / 2 << endl;
  return 0;
}

Measured memory_bytes: 24960
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

////////////////////////////////////////////////////////////////////////////////////////
int main(){
    string s; cin >> s;
    int n = s.size();
    
    // 先頭を0とした時の塗替回数
    int flag = 1, cnt = ( s[0] == '0' ? 0 : 1 );
    rep(i,1,n){
        int d = s[i] - '0';
        if(d != flag){
            cnt++;
        }
        flag = abs(flag - 1);
    }
    int res = cnt;
    // 先頭を1とした時の塗替回数
    flag = 0; cnt = ( s[0] == '1' ? 0 : 1 );
    rep(i,1,n){
        int d = s[i] - '0';
        if(d != flag){
            cnt++;
        }
        flag = abs(flag - 1);
    }
    res = min(res, cnt);
    cout << res << ednl;
}


Measured memory_bytes: 512