akhauriyash/Code-Regression huggingface dataset:
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll

void solve() {
	int n;
	cin >> n;
	if (n <= 1) {
		cout << n + 1 << endl;
	}
	else if(n == 2){
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3168
require 'pp'
# 23, 0, 243
n, a, b, c = gets.split.map &:to_i
l = []
while gg = gets
  l << gg.to_i
end
res = []
[:a,:b,:c,:x].repeated_permutation(n) do |arr|
  aa = bb = cc = 0 # 長さ
  cost = -30
  n.times do |i|
    case arr[i] # 1つ目の竹をどうするか
    when :a # Aの材料
      aa += l[i]
      cost += 10
    when :b # Bの材料
      bb += l[i]
      cost += 10
    when :c # Cの材料
      cc += l[i]
      cost += 10
    when :x # 使わない
    end
  end

  next if [aa,bb,cc].any?{|x|x==0}

  if aa > a # 12, 10
    cost += aa-a
  elsif aa < a
    cost += a-aa
  end

  if bb > b # 12, 10
    cost += bb-b
  elsif bb < b
    cost += b-bb
  end

  if cc > c # 12, 10
    cost += cc-c
  elsif cc < c
    cost += c-cc
  end
  res << [aa,bb,cc,cost]
end
p res.sort_by{|x|-x[3]}[-1][3]
# p [a,b,c]


Measured memory_bytes: 11000
#include <iostream>
#include <vector>
using namespace std;
int cnt;

void insertionSort(int a[], int n, int g) {
  for (int i = g; i < n; i++) {
    int v = a[i];
    int j = i - g;
    while (j >= 0 && a[j] > v) {
      a[j+g] = a[j];
      j = j - g;
      cnt++;
    }
    a[j + g] = v;
  }
  return;
}

void shellSort(int a[], int n, vector<int> G) {
  for (int i = (int)G.size() - 1; i >= 0; i--) {
    insertionSort(a, n, G.at(i));
  }
  return;
}

int main(int argc, char *argv[])
{
  int n;
  cin >> n;
  int calc = 1;
  vector<int> G;
  while (calc <= n) {
    G.push_back(calc);
    calc = calc * 3 + 1;
  }
  int a[n];
  for(int i=0;i<n;++i){
    cin >> a[i];
  }
  shellSort(a, n, G);
  cout << G.size() << endl;
  for (int i = (int)G.size() - 1; i >= 0; i--) {
    cout << G[i];
    if(i == 0) cout << "\n";
    else cout << " ";
  }
  cout << cnt << endl;
  for(int i = 0; i < n; i++){
    cout << a[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 7028
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int gogo[500][500] = {};
int dp[2][(1 << 23)] = {};
int main() {
	while (true) {
		int n, m;
		cin >> n >> m;
		if (n == 0) return 0;
		REP(i, n) {
			string s;
			cin >> s;
			REP(q, m) {
				if (s[q] == '0') {
					gogo[i][q] = 0;
				}
				else {
					gogo[i][q] = 1;
				}
			}
		}
		if (m < 23) {
			//bitdp
			for (int i = 0; i < (1 << m); ++i) {
				dp[0][i] = -10000;
				dp[1][i] = -10000;
			}
			dp[0][0] = 0;
			for (int i = 0; i < n; ++i) {
				int geko = 0;
				int nya = 1;
				for (int j = m - 1; j >= 0; --j) {
					geko += gogo[i][j] * nya;
					nya *= 2;
				}
				for (int q = 0; q < (1 << m); ++q) {
					dp[(i + 1) % 2][q] = max(dp[(i + 1) % 2][q], dp[i%2][q]);
					dp[(i + 1) % 2][(q ^ geko)] = max(dp[(i + 1) % 2][(q ^ geko)], dp[i%2][q] + 1);
				}
			}
			cout << dp[n % 2][0] << endl;
		}
		else {
			//全探索
			int ans = 0;
			for (int i = 0; i < (1 << n); ++i) {
				int cnt = 0;
				int now = i;
				int neko[500] = {};
				for (int q = 0; now != 0; ++q) {
					if (now % 2 == 1) {
						for (int j = 0; j < m; ++j) {
							neko[j] += gogo[q][j];
						}
						cnt++;
					}
					now /= 2;
				}
				int ok = 1;
				for (int q = 0; q < m; ++q) {
					if (neko[q] % 2 == 1) ok = 0;
				}
				ans = max(ans, cnt * ok);
			}
			cout << ans << endl;
		}
	}
}



Measured memory_bytes: 36864
n = int(input())
from math import sqrt,ceil

def is_prime(n):
    if n == 1: return False
    if n == 2: return True
    for i in range(2, ceil(sqrt(n))+1):
        if n % i == 0: return False
    return True

def prime_factorization(n):
    if is_prime(n):return [n]
    factor = []
    for i in range(2, ceil(sqrt(n))+1):
        if not is_prime(i): continue
        q,r = divmod(n, i)
        if r == 0:
            n = q
            factor.append(i)
            q,r = divmod(n, i)    
            while r == 0:
                n = q
                factor.append(i)
                q,r = divmod(n, i)
    if n != 1:
        factor.append(n)
    return factor

factor = sorted(prime_factorization(n))
print("%d:"%n, *factor)


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

    int Q;
    cin>>Q;
    while(Q--){
        int c,a,n;
        cin>>c>>a>>n;
        int ans = 0;
        int x = min(c,min(a,n));
        ans += x;
        c-=x,a-=x,n-=x;
        x = min(c/2,a);
        ans += x;
        c-=x*2,a-=x;
        ans += c/3;
        cout<<ans<<endl;
    }

    return 0;
}

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

const int MAXN = 1e5 + 10;

long long n, a, b, val;
long long v[MAXN];

long long check (int md) {
	long long ret = 0;
	for (int i = 1; i <= n; i++) {
		if (v[i] - md * b > 0) {
			ret += (v[i] - md * b + a - 1) / a;
		}
	}
	return ret;
}

int main (void) {
	scanf("%lld%ld%lld", &n, &a, &b);
	a = a - b;
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &v[i]);
	}
	int st = 1, en = 1e9, md;
	while (st != en) {
		md = (st + en) >> 1;
		if (check(md) <= md) en = md;
		else st = md + 1;
	}
	printf("%d\n", st);
}


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

#define rep(i,n) for (int i=0; i<(n); i++)
const int INF =1001001001;
const ll BIG = 1000000007;

int main(){
    int l;
    cin >> l;
    l = (double)l;
    double ans = pow(l, 3)/27;
    cout << fixed << setprecision(15) << ans << endl;
    return 0;
}

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

// #define REP(i, x) REPI(i, 0, x)
// #define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
// #define ALL(x) (x).begin(), (x).end()

// typedef long long ll;
// using namespace std;

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

//   ll X;
//   cin >> X;
//   ll const max = 1000000;
//   for (ll i = 1; i <= max; ++i) {
//     if (100 * i <= X && X <= 105 * i) {
//       cout << 1 << endl;
//       return 0;
//     }
//   }

//   cout << 0 << endl;

//   return 0;
// }

#include <bits/stdc++.h>

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  ll X;
  cin >> X;
  vector<bool> dp(101010, false);
  dp.at(0) = true;
  REP(i, 100000) {
    if (dp.at(i)) {
      REP(j, 6) { dp.at(i + 100 + j) = true; }
    }
  }
  if (dp.at(X)) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}


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

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

int main() {
	int n;
	cin >> n;
	set<int> s;
	rep(i, n) {
		int w;
		cin >> w;
		s.insert(w);
	}
	cout << s.size() << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var x, y int
	fmt.Scan(&x, &y)

	ss := []string{"A", "C", "A", "B", "A", "B", "A", "A", "B", "A", "B", "A"}

	if ss[x-1] == ss[y-1] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
using System;
using System.Linq;

class Program {
    static void Main() {
        int n = int.Parse(Console.ReadLine());
        int[] b = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        for (int i = 0; i < n; i++) {
            int a = b[i];
            if (a > i + 1) { Console.WriteLine(-1); return; }
            for (int j = 0; j < a - 1; j++) {
                int w = b[i - j];
                b[i - j] = b[i - j - 1];
                b[i - j - 1] = w;
            }
        }
        Array.Reverse(b);
        Console.WriteLine(string.Join("\n", b));
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    ll r, d, x;
    cin >> r >> d >> x;
    rep(i, 10) {
        x = r*x - d;
        cout << x << endl;
    }
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main(void){
  ll n;
  cin >>  n;
  vector<ll> a(n);
  ll ans=0;
  ll m=1000000007;
  for(ll i = 0;i<n;i++){
    cin >>  a[i];
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  for(int i = 1;i<(n/2);i++){
    ans+=2*a[i];
  }
  if(n%2==1){
    ans+=a[n/2];
  }
  
  cout<<ans+a[0]<<endl;
    return 0;
}


Measured memory_bytes: 4804
#include<iostream>

int main(){
    int A, B, C;
    std::cin >> A >> B >> C;
    if(A == B){
        std::cout << C << std::endl;
    }else if(A == C){
        std::cout << B << std::endl;
    }else{
        std::cout << A << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Arrays;

public class Main{
    public static void main(String[] args){
        FastScanner sc = new FastScanner();

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int count = 0;
        for(int i=a;i<=b;i++){
            if(c%i==0)count++;
        }
        System.out.println(count);

    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}



Measured memory_bytes: 24488
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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)*}
    };
}

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:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: i64,
    }
    let mut mi = i64::max_value();
    for i in 1..1_000_001_i64 {
        if n % i == 0 {
            mi = min(mi, n / i + i);
        }
    }
    puts!("{}\n", mi - 2);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include<bits/stdc++.h>
#define N 100005
#define M 1000000007
using namespace std;
bool broken[N];
int n,m;
int dp[N];
int run(int which)
{
    if(which==n) return 1;
    if(dp[which]!=-1) return dp[which];
    int ans=0;
    if(!broken[which+1]) ans+=run(which+1),ans%=M;
    if(which<=n-2&&!broken[which+2]) ans+=run(which+2),ans%=M;
    return dp[which]=ans;
}
main()
{
    memset(dp,-1,sizeof dp);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int p;
        cin>>p;
        broken[p]=true;
    }
    cout<<run(0);
}

Measured memory_bytes: 3840
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, M, L): (usize, usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let (A, B, C): (Vec<usize>, Vec<usize>, Vec<usize>) = {
        let (mut A, mut B, mut C) = (vec![], vec![], vec![]);
        for _ in 0..M {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            A.push(iter.next().unwrap().parse().unwrap());
            B.push(iter.next().unwrap().parse().unwrap());
            C.push(iter.next().unwrap().parse().unwrap());
        }
        (A, B, C)
    };
    let Q: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let (s, t): (Vec<usize>, Vec<usize>) = {
        let (mut s, mut t) = (vec![], vec![]);
        for _ in 0..Q {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            s.push(iter.next().unwrap().parse().unwrap());
            t.push(iter.next().unwrap().parse().unwrap());
        }
        (s, t)
    };

    let G = {
        let mut G = vec![std::collections::HashMap::new(); N + 1];
        for i in 0..M {
            G[A[i]].insert(B[i], C[i]);
            G[B[i]].insert(A[i], C[i]);
        }
        G
    };

    const INF: i64 = 1_000_000_000_000_000;
    let mut dp = vec![vec![(INF, 0); N + 1]; N + 1];
    for i in 1..(N + 1) {
        let mut q = std::collections::BinaryHeap::new();
        q.push(((0, L), i));
        while let Some(((k, r), j)) = q.pop() {
            if dp[i][j] == (INF, 0) {
                dp[i][j] = (-k, r);
                for (&t, &c) in &G[j] {
                    if dp[i][t] == (INF, 0) {
                        if r >= c { q.push(((k, r - c), t)); }
                        else if L >= c { q.push(((k - 1, L - c), t)); }
                    }
                }
            }
        }
    }
    // println!("{:?}", dp);
    let ans = (0..Q)
        .map(|i| if dp[s[i]][t[i]] == (INF, 0) { (-1).to_string() } else { dp[s[i]][t[i]].0.to_string() } )
        .collect::<Vec<_>>()
        .join("\n");

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

Measured memory_bytes: 16536
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<math.h>
using namespace std;
typedef long long ll;
typedef pair<int,ll> P;
#define N (1000000000+7)
#define INF (ll)1e16
typedef long long ll;


vector<int>graph[200010];
ll sum[200010]={0};
bool used[200010];

void bfs(int vertex){
    queue<pair<int,ll>>que;
    que.push(P(vertex,sum[vertex]));
    while(!que.empty()){
        P p=que.front();
        que.pop();
        for(int i=0;i<(int)graph[p.first].size();i++){
            int now=graph[p.first][i];
            if(!used[now]){
                sum[now]=sum[now]+sum[p.first];
                que.push(P(now,sum[now]));
            }
        }
        used[p.first]=true;
    }
}

int main(void){
    int n,q,a,b,p,x;
    cin>>n>>q;
    for(int i=1;i<=n-1;i++){
        cin>>a>>b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    for(int i=0;i<q;i++){
        cin>>p>>x;
        sum[p]+=x;
    }
    bfs(1);
    for(int i=1;i<=n;i++){
        if(i==n)cout<<sum[n]<<endl;
        else cout<<sum[i]<<" ";
    }
    return 0;
}

Measured memory_bytes: 17012
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
struct Maze {
  int id;
  int parent;
  int cost;
};
int N;

vec< vec< int > > g;
vec< int > c;
queue< Maze > q;
vec< int > parent;

int bfs() {
  Maze s = {N - 1, N - 1, 0};
  parent[N - 1] = N - 1;
  q.push(s);
  while (!q.empty()) {
    Maze now = q.front();
    q.pop();
    if (now.id == 0) {

      return now.cost;
    }
    FORA(e, g[now.id]) {
      Maze next = {e, now.id, now.cost + 1};
      if (parent[e] == -1) { //  注意
        parent[e] = now.id;
        q.push(next);
      }
    }
  }
  return -1;
}
void dfs(int id, int color) {
  c[id] = color;
  FORA(e, g[id]) {
    if (c[e] == -1) {
      dfs(e, color);
    }
  }
}
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  cin >> N;
  g.resize(N, vec< int >());
  REP(i, N - 1) {
    int p, q;
    cin >> p >> q;
    p--, q--;
    g[p].pb(q);
    g[q].pb(p);
  }
  c.assign(N, -1);
  parent.assign(N, -1);
  bfs();

  // find path
  int now = 0;
  vec< int > path;
  while (now != N - 1) {
    path.pb(now);
    now = parent[now];
  }
  path.pb(N - 1);
  int pathsize = path.size();
  // PRINTALL(path);

  // REP(i, ((pathsize + 1) / 2)) { c[path[i]] = 1; }
  // FOR(i, ((pathsize + 1) / 2), pathsize) { c[path[i]] = 0; }
  c[path[(pathsize + 1) / 2]] = 0;
  int col = 1;
  dfs(0, col);
  //  REP(i, (int)path.size() / 2) { c[path[i]] = 1; }
  int ans = 0;
  REP(i, N) {
    if (c[i] == col) {
      ans++;
      //     DEBUG(i);
    }
  }
  // DEBUG(ans);
  //  DEBUG(N);
  if (ans > N / 2) {
    print("Fennec");
  } else {
    print("Snuke");
  }
}

Measured memory_bytes: 9716
N = int(input())
s = input()
t = input()
ans = 0
another_t = t

if s == t:
    print(len(s))
else:
    while len(another_t) != 0:
        string = s + another_t
        if string[0:N] == s and string[len(string)-N:len(string)] == t:
            ans = len(string)
        another_t = another_t[1:len(another_t)]
    print(ans)


Measured memory_bytes: 3064
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 ln         PIC X(30).
01 N          PIC 9(10).
01 A          PIC 9(10).
01 B          PIC 9(10).
01 ans        PIC 9(10).
01 zs         PIC Z(9)9.

PROCEDURE DIVISION.
  ACCEPT ln.
  UNSTRING ln DELIMITED BY SPACE INTO N A B.
  COMPUTE ans = FUNCTION MIN(A * N, B).
  MOVE ans TO zs.
  DISPLAY FUNCTION TRIM(zs).
  STOP RUN.


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

int main()
{
	string S, T;
	cin >> S >> T;

	vector<char> chrs(S.size());
	vector<char> chrt(T.size());

	for(int i=0; i<S.size(); i++){
		chrs.at(i) = S.at(i);
	}
	for(int i=0; i<T.size(); i++){
		chrt.at(i) = T.at(i);
	}

	//	for(auto str : chrs){
	//		cout << str;
	//	}
	//	cout << endl;
	//	for(auto str : chrt){
	//		cout << str;
	//	}


	for(int i=0;i<S.size();i++){
		if(chrt.at(i) != chrs.at(i)){
			cout << "No" << endl;
			return 0;
		}
	}
	if(chrt.size() == chrs.size() + 1){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

}


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

using namespace std;

namespace {

#define VEVE(i, a, b) for (ll i = a, __##i = b; i < __##i; ++i)
#define DYDY(i, a, b) for (ll i = a, __##i = b; i > __##i; --i)
#define RARA(x, seq) for (auto &x : seq)
#define SIZE(x) ((ll)(x.size()))
#define ALL(x) x.begin(), x.end()

typedef int ll;
typedef double dd;
const ll MAX = 2048;
// cost[c][i][j] = # of balls of opposite color of c that have
// num <= j and appear after where ball (i,c) is originally positioned
ll pos[2][MAX], cost[2][MAX][MAX];
ll dp[MAX][MAX];

void Solve(ll) {
  ll n;
  if (not(cin >> n))
    return;
  vector<ll> seq[2];
  VEVE(i, 0, 2 * n) {
    char col;
    ll num;
    cin >> skipws >> col >> num;
    seq[col == 'B'].push_back(num);
    pos[col == 'B'][num] = i;
  }
  memset(cost, 0, sizeof(cost));
  VEVE(c, 0, 2) {
    VEVE(i, 1, n + 1) {
      VEVE(j, 1, n + 1) {
        cost[c][i][j] = cost[c][i][j - 1] + (pos[c ^ 1][j] > pos[c][i]);
      }
    }
  }
  memset(dp, 0x3F, sizeof(dp));
  dp[0][0] = 0;
  VEVE(i, 0, n + 1) {
    VEVE(j, 0, n + 1) {
      if (i > 0) {
        // white ball is last
        dp[i][j] = min(dp[i][j], dp[i - 1][j] + cost[0][i][j]);
      }
      if (j > 0) {
        // black ball is last
        dp[i][j] = min(dp[i][j], dp[i][j - 1] + cost[1][j][i]);
      }
    }
  }
  ll res = dp[n][n];
//  DEBUG(res);
  VEVE(c, 0, 2) VEVE(i, 0, n) VEVE(j, i + 1, n) res += seq[c][i] > seq[c][j];
  cout << res << endl;
}

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

int32_t main() {
#ifdef AZN
  freopen("input.txt", "r", stdin);
#endif
  Init();
  ll tests = 11;
  VEVE(test, 1, tests + 1) Solve(test);
  return 0;
}


Measured memory_bytes: 49408
/*通学経路*/
#include <stdio.h> 
void func(int,int); 
int cnt,a,b,c;
int kou[17][17];
int main(void)  
{ 
	while(1){
		int i,j,x,y;
		scanf("%d %d",&a,&b); 
		if(a==0 && b==0) break;
		scanf("%d",&c);
		for(i=1;i<=b;i++){
			for(j=1;j<=a;j++){
				kou[i][j]=0;
			}
		}
		for(i=0;i<c;i++){
			scanf("%d %d",&x,&y);
			kou[y][x]=1;
		}	
		cnt=0;
		func(1,1);
		printf("%d\n",cnt);
	}
    return 0; 
}   
void func(int yy,int xx) 
{ 
	if(xx==a&&yy==b){
		cnt++;
	}
	else {
		if(xx+1<=a&&kou[yy][xx+1]==0){
			func(yy,xx+1);
		}
		if(yy+1<=b&&kou[yy+1][xx]==0){
			func(yy+1,xx);
		}
	} 
}


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

int main()
{
	int N;
	cin >> N;
	int res = 0;
	for (int i = 1; i <= N; i++) {
		res += to_string(i).size() & 1;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    string s, t;
    cin >> s >> t;
    string res = t + s;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

int main() {
	int n;
	string s;
	cin >> n;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		s[i] = (s[i] - 'A' + n) % 26 + 'A';
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3176
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n; cin >> n;
    vl h(n);
    rep(i,n) cin >> h[i];
    vl dp(n, 0);
    dp[0] = 0;
    for(int i=1; i<n; i++){
        dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
        if(i > 1) dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout << dp[n-1] << endl;
}

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

int main()
{
	unsigned long long n, a, b;
	cin >> n >> a >> b;
	unsigned long long prev;
	cin >> prev;
	unsigned long long ret = 0;
	for (unsigned long long i = 1; i < n; ++i) {
		unsigned long long cur;
		cin >> cur;
		ret += min((cur - prev) * a, b);
		prev = cur;
	}

	cout << ret << endl;

	return 0;
}

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

const ll mod = 1e9 + 7;
int n;
vector<int> a;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> a(n), ans(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n - 1; i++) {
        ans[n - 1] ^= a[i];
    }
    for (int i = 0; i < n - 1; i++) {
        if (i == 0) {
            ans[0] = a[n - 1] ^ a[0] ^ ans[n - 1]; 
        } else {
            ans[i] = a[i - 1] ^ a[i] ^ ans[i - 1];
        }
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 4744
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        s: String,
    }

    let vc: Vec<char> = s.chars().collect();
    let mut c_cnt = vec![0; 3];
    for c in &vc {
        c_cnt[(*c as u8 - b'a') as usize] += 1;
    }
    c_cnt.sort();
    if c_cnt[2] - c_cnt[0] < 2 {
        println!("YES");
    } else {
        println!("NO");
    }
}


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

int main() {
  ll N;
  cin >> N;
  ll a[N], b[N];
  vector<P> ba;
  for (ll i = 0; i < N; i++) {
    cin >> a[i] >> b[i];
    ba.push_back(P(b[i], a[i]));
  }
  
  sort(ba.begin(), ba.end());
  
  ll sum[N];
  sum[0] = ba[0].second;
  for (ll i = 0; i < N-1; i++) {
    sum[i+1] = sum[i] + ba[i+1].second;
  }
  
  bool ok = true;
  
  for (ll i = 0; i < N; i++) {
    if (sum[i] > ba[i].first) {ok = false;}
  }
  
  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}


Measured memory_bytes: 9068
#include<stdio.h>
#include<math.h>
int main () {
    int N, L, A[200], h = 100, b, sum = 0;
    scanf("%d %d", &N, &L);
    for(int i = 0; i < N; ++i) {
        A[i] = L + i;
        b = fabs(A[i]);
        if(fabs(h) > b) h = A[i];
        sum += A[i];
        // printf("%d : %d sum : %d\n ", i + 1, A[i], sum);
    }
    // printf("h : %d", h);
    sum -= h;
    printf("%d\n", sum);

    return 0;
}

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

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

const int N=100000+10;

int n,sz[N],dep[N];
pair<ll,int> d[N];
vector<int> E[N];
vector<pair<int,int> > ans;

void dfs(int u,int f) {
	dep[u]=dep[f]+1;
	for (int v:E[u]) if (v!=f) dfs(v,u);
}

int main() {
	n=read();
	for (int i=1;i<=n;++i) d[i]=make_pair(read(),i);
	sort(d+1,d+n+1);
	for (int i=1;i<=n;++i) sz[i]=1;
	for (int i=n;i>1;--i) {
		ll dlt=2*sz[d[i].second]-n+d[i].first;
		int p=lower_bound(d+1,d+n+1,make_pair(dlt,0))-d;
		if (d[p].first!=dlt) { puts("-1"); return 0; }
		int u=d[i].second,v=d[p].second;
		ans.emplace_back(make_pair(u,v));
		E[u].emplace_back(v),E[v].emplace_back(u),sz[v]+=sz[u];
	}
	dep[0]=-1,dfs(d[1].second,0); ll s=0;
	for (int i=1;i<=n;++i) s+=dep[i];
	if (s!=d[1].first) { puts("-1"); return 0; }
	for (auto i:ans) printf("%d %d\n",i.first,i.second);
	return 0;
}

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

using namespace std;

int main()
{
    int a,b,k,c=1,t;
    cin>>a>>b>>k;
    t=b-a+1;
    for(int i=a;i<=b;i++)
    {
        if(c<=k || c>=t-k+1)  cout<<i<<endl;
        c++;
    }
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>/*
#include <unordered_map>
#include <functional> //greater
#include <algorithm> //sort
#include <iostream>
#include <iterator>
#include <utility> //pair
#include <sstream>
#include <cstring> //memset
#include <complex>
#include <cassert>
#include <random>
#include <cstdio>
#include <string>
#include <vector>
#include <cctype> //isaplha, tolower
#include <deque>
#include <queue>
#include <stack>
#include <array>
#include <cmath> //sqrt, sin
#include <ctime>
#include <map>
#include <set>
//*/

#define int long long
#define uns unsigned
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define endl '\n'
using namespace std;

template<class T> ostream &operator<<(ostream &os, const pair<T,T> &p){
	return os<<"("<<p.fi<<","<<p.se<<")";}
template<class T> ostream &operator<<(ostream &os, const pair<const T,T> &p){
	return os<<"("<<p.fi<<","<<p.se<<")";}
template<class T> ostream &operator<<(ostream &os, const array<T,3> &p){
	return os<<"("<<p[0]<<","<<p[1]<<","<<p[2]<<")";}
template<class T> ostream &operator<<(ostream &os, const vector<T> &p){
	for(auto x: p) os<<x<<' '; return os;}
#define dbug(x) cerr<<">>>> "<<#x<<" = "<<x<<endl
#define _ <<", "<<
#define FOR(X,L,R) for(int X=L;X<R;X++)
#define FI(I,X) for(auto I=(X).begin();I!=(X).end();I++)
#define print(X) {cerr<<"{ ";FI(I,X)cerr<<*I<<' ';cerr<<"}"<<endl;}
#define mset(V,X) memset(V,X,sizeof(V))
#define all(X) (X).begin(),(X).end()
#define upperb(V,X) (int)(upper_bound(all(V),(X))-V.begin())
#define lowerb(V,X) (int)(lower_bound(all(V),(X))-V.begin())

const double EPS = 1e-9, PI = acos(-1);
const ll LINF = 0x3f3f3f3f3f3f3f3f, mod = 1e9+7;
const int INF = 0x3f3f3f3f, SZ = 2e4+20;

double dp[3010];
double p[3010];

int32_t main(){
	//ios::sync_with_stdio(false);cin.tie(0);
	
	int n; cin>>n;
	FOR(i,0,n) cin>>p[i];
	FOR(i,0,n) for(int x=i+1; x>=0; x--){
		if(i==0)
			dp[x] = x ? p[i] : 1-p[i];
		else if(x==0)
			dp[x] = dp[x]*(1-p[i]);
		else
			dp[x] = dp[x]*(1-p[i]) + dp[x-1]*p[i];
	}
	double res = 0;
	FOR(x,0,n+1) if(x+x>n) res += dp[x];
	printf("%.10f\n",res);
	
	return 0;
}

Measured memory_bytes: 256
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, usize1) => {
        read_value!($next, usize) - 1
    };

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        v: [usize; 3]
    }
    println!("{}", if v.iter().cloned().sum::<usize>() >= 22 {"bust"} else {"win"});
}


Measured memory_bytes: 4352
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;

public class Main
{
    public static void main(String[] args)
    {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        long d=in.nextLong();
        long[] x=new long[n];
        long[] y=new long[n];
        for(int i=0;i<n;i++)
        {
            x[i]=in.nextLong();
            y[i]=in.nextLong();
        }
        int c=0;
        for(int i=0;i<n;i++)
        {
            if((long)x[i]*x[i]+(long)y[i]*y[i]<=(long)d*d)
                c++;
        }
        System.out.println(c);
    }
}

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

void writeSharp(int num) {
	int i;
	for(i = 0; i < num; i++) {
		printf("#");
	}
	printf("\n");
}

int main () {
	int width , height;
	int i , s;
	while(1) {
		
		scanf("%d %d" , &height , &width);
		if (height == 0 && width == 0) break;
		
		writeSharp(width);
		for(i = 0; i < height - 2; i++) {
			printf("#");
			for(s = 0; s < width - 2; s++) {
				printf(".");
			}
			printf("#\n");
		}
		writeSharp(width);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 588
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        int A = scanner.nextInt();
        int B = scanner.nextInt();

        int rem = (X - A) % B;
        System.out.println(rem);
    }

}

Measured memory_bytes: 21332
#include<stdio.h>
int main(){
  int n,i,num;
  scanf("%d",&n);
  int a[14];
  for(i=0;i<14;i++)
    a[i]=0;
  for(i=0;i<n;i++){
    scanf("%d",&num);
    a[num/400]++;
  }
  int min=0,max;
  for(i=0;i<8;i++){
    if(a[i]!=0)
      min++;
  }
  max=min;
  for(i=8;i<14;i++)
    max+=a[i];
  printf("%d %d\n",min==0?1:min,max);
  return 0;
}


Measured memory_bytes: 1728
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

class Main{
	public static void main(String[] $){
		Scanner sc =new Scanner(System.in);
		int n = sc.nextInt();
		Integer a[] = new Integer[n];
		Integer b[] = new Integer[n];

		int p[] = new int[n];
		int q[] = new int[n];

		for (int i = 1; i <= n; i++) {
			a[i - 1] = i;
			b[i - 1] = a[i- 1];
		}

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

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

		Arrays.sort(a);
		// 降順にソートした配列bを用意しておき、aとbが等しくなるまでループする
		Arrays.sort(b, Collections.reverseOrder());

		int count = 0;
		int x = 0;
		int y = 0;
		while (!(Arrays.toString(a).equals(Arrays.toString(b)))) {
			int maxIndex = 0;
			for (int i = 1; i < n; i++) {
				if (a[i - 1] < a[i]) maxIndex = i - 1;
			}

			int lastIndex = 0;
			for (int i = n - 1; 0 <= i; i--) {
				if (a[maxIndex] < a[i]) {
					lastIndex = i;
					break;
				}
			}

			int tmp = a[lastIndex];
			a[lastIndex] = a[maxIndex];
			a[maxIndex] = tmp;
			Arrays.sort(a, maxIndex + 1, a.length);
			count++;
			if (Arrays.toString(a).equals(Arrays.toString(p))) {
				x = count;
			}
			if (Arrays.toString(a).equals(Arrays.toString(q))) {
				y = count;
			}
		}

		System.out.println(Math.abs(x - y));

		sc.close();
	}
}

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

const int N = 1e5 + 69;

long long n, m, v, p;
long long ar[N], pre[N];

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

	cin >> n >> m >> v >> p;
	for(int i = 1; i <= n; i++) {
		cin >> ar[i];
	}
	sort(ar + 1, ar + n + 1, greater<long long>());
	for(int i = 1; i <= n; i++) {
		pre[i] = pre[i - 1] + ar[i];
	}
	int ans = p;
	for(int i = p + 1; i <= n; i++) {
		if(ar[i] + m < ar[p])
			continue;
		long long sumVote = v * m;
		sumVote -= m;
		sumVote -= (p - 1) * m;
		sumVote -= (n - i) * m;
		if(sumVote <= 0) {
			ans++;
			continue;
		}
		sumVote -= ((i - p) * (ar[i] + m) - pre[i - 1] + pre[p - 1]);
		if(sumVote <= 0) {
			ans++;
			continue;
		}
	}

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;


int main(){
    string S;
    cin >> S;
    
    int len = S.length() - 7;
    int flag = 0;
    
    if (len==0) {
        if (S=="keyence") {
            cout << "YES" << endl;
        }
    }
    else {
        for (int i=0;i<=7;i++) {
            string temp1 = S.substr(0,i);
            string temp2 = S.substr(len+i);
            string result = temp1 + temp2;
            if (result == "keyence") flag = 1;
        }
        
        if (flag==1) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <climits>
using namespace std;

int main() {
	int n;
	string s;
	cin>>n;
	cin>>s;
	vector<bool> v(s.length());
	for (int i=0; i<s.length(); ++i)
		if (s[i]=='E') v[i]=0;
		else v[i]=1;
	int mc, lc=0, rc=0;
	for (int i=1; i<v.size(); ++i)
		if (!v[i])
			++rc;
	mc=rc;
	for (int i=1; i<v.size(); ++i) {
		if (v[i-1])
			++lc;
		if (!v[i] && rc>0)
			--rc;
		mc=min(mc, lc+rc);
	}
	cout<<mc<<endl;
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<vector<int>>keiro(2,vector<int>(n));

    for(int i=0;i<n;i++){
        cin>>keiro.at(0).at(i);
    }
    for(int i=0;i<n;i++){
        cin>>keiro.at(1).at(i);
    }
    long int maxk=0;
    for(int k=0;k<n;k++){
        long int total=0;
        long int count=-1;
    
        for(int i=0;i<=k;i++){
            
            total+=keiro.at(0).at(i);
            count+=1;
        }
        for(int j=count;j<n;j++){
            total+=keiro.at(1).at(j);
        }
        maxk=max(maxk,total);
        
    }
    

    cout<<maxk<<endl;



}

Measured memory_bytes: 256
#if defined(__GNUC__)
#include <bits/stdc++.h>
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#if defined(__GNUC__)
#define __int32 __int32_t
#endif // __GNUC__

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); (i)++)
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); (i)++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) std::sort(ALL(x))
#define RSORT(x, T) std::sort(ALL(x), greater<T>())
#define REVERCE(x) std::reverce(ALL(x))

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)

itn main() {
	std::ios::sync_with_stdio(false);

	int x, y;

	cin >> x >> y;

	long double a = (long double)y / x;

	int br = log2l(a);

	cout << br + 1;

	return 0;
}


Measured memory_bytes: 256
import sys;print"\n".join("%d %d"%(lambda l:(l[0],l[2]/l[0]*l[1]))((lambda f,l:(f(f,l),l[0],l[1]))(lambda f,l:l[1]==0 and l[0] or f(f,[l[1],l[0]%l[1]]),map(int,s.split())))for s in sys.stdin)

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

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

using namespace std;

int main(){
  int n;cin>>n;
  int d,x;cin>>d>>x;
  int result=0;
  rep(i, n){
    int a;cin>>a;
    rep(i,d){
      if(1+(i)*a <= d)result+=1;
    }
  }

  cout<<result+x;

  return 0;
}

Measured memory_bytes: 256
// chain_disappears_puzzle.cpp
// 2017/11/03


//#include "stdafx.h"
#include <iostream>

using namespace std;

//?¶???????????????°???????????????????????¢??° stone_erase
int stone_erase(int i, int *target) {
	if (i == 0) {
		if (target[i + 2] == target[i + 3] && target[i + 3] == target[i + 4]) { //1????????????5?????????????????????
			return 5; //?¶?????????????5?????§??????
		}
	}
	if (i == 0 || i == 1) {
		if (target[i + 2] == target[i + 3]) {
			return 4; //?¶?????????????4?????§??????
		}
	}
	return 3; //?????????????????£?????????????????´???????¶?????????????3?????§??????
}

int main()
{

	//??\???????????????H?????????
	int H; //??????
	cin >> H;

	int board[10][5]; //?????¢
	int point = 0;
	int erase_address[10][3]; //?¶??????´?????¨?¶???????????????°????¨???¶
	bool erase_flag = false;

	while (H != 0) { //H???0?????\??????????????´????????????

		//??\??????????????¢board?????\??????erase_address???????????????2????????\???)
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < 5; j++) {
				cin >> board[i][j];
				if (j < 3) {
					erase_address[i][j] = 0;
				}
			}
		}
		
		//?????¢???????¶?????????¨?????§????????????????´¢????????¢??¢?´¢???
		do {
			erase_flag = false; //2???????????¢?´¢??§?????????
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < 3; j++) {
					if (board[i][j] == -1) continue;
					if (board[i][j] == board[i][j + 1] && board[i][j + 1] == board[i][j + 2]) { //???????????????????¶???????3???????????§????????´???
						erase_flag = true;
						erase_address[i][j] = stone_erase(j, board[i]); //erase_address????¶???????????????°???????´????ex:3????¶??????????erase_address[i][j] = 3???
						point += (board[i][j] * erase_address[i][j]);
						break; //?¬???????????§????
					}
				}
			}
			
			//??????????????????
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < 3; j++) {
					if (erase_address[i][j] != 0) {
						for (int k = i; k > 0; k--) {
							for (int l = j; l < j + erase_address[i][j]; l++) {
								board[k][l] = board[k - 1][l]; // 1?????????????????????????????£????????????????????????
							}
						}
						for (int k = j; k < j + erase_address[i][j]; k++) {
							board[0][k] = -1;
						}
					}
				}
			}

			/*
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < 5; j++) {
					if (board[i][j] == -1) cout << board[i][j] << " ";
					else cout << board[i][j] << "  ";
				}
				cout << endl;
			}
			cout << endl;
			*/

			//erase_address???????????????
			for (int i = 0; i < 10; i++) { 
				for (int j = 0; j < 3; j++) {
					erase_address[i][j] = 0;
				}
			}

		} while (erase_flag != false); //erase_flag???false??????????????´???????¶??????????????????????????????´???????????¢?´¢???????????????do-while?????????????????????

		cout << point << endl; //??????????????????
		point = 0; //?????????????????????

		cin >> H; // ?¬?????????¢??????????????\???
	}
    return 0;
}

Measured memory_bytes: 2980