akhauriyash/Code-Regression huggingface dataset:
<?php
 
$file_handle = fopen('php://stdin', "r"); //fopen()は同位フォルダにファイルがあればその名前のみでOK
//$file_handle = fopen('aoj0235_in.txt', "r");
 
//dfs（再帰ver）(根から葉の親までの距離総計を$leafに格納していく)
function dfs($cur) {
    //グローバル変数定義
    global $dist;
    global $leaf;
    global $flag;
     
    //終了条件不要
    
    //現在の島を探索済みにする
    $flag[$cur['node']] = 1;
     
    $childnode = childnode($cur['node']);
    if (empty( $childnode )) return;
    foreach ($childnode as $island_num => $distance) {
    	if ( $flag[$island_num] === 1 ) continue;
        $grandchildnode = childnode($island_num);
        if (!empty($grandchildnode)) {
            $new['node'] = $island_num;
            $new['dist'] = $cur['dist'] + $dist[$cur['node']][$new['node']];
            dfs($new);
        } else {
            $leaf[$cur['node']] = $cur['dist'];     //ここが葉の親ならば
            $dist[$cur['node']][$island_num] = 0;   //バグの修正。孫ノードが存在しない橋への距離を０に。
            $dist[$island_num][$cur['node']] = 0;   //バグの修正。孫ノードが存在しない橋への距離を０に。
        }
    }
}
 
//子ノード抽出
function childnode($island){
    global $dist;
    global $flag;
   //未探索のみ子ノードとして取り出す
   $childnode = array();
   if (!empty($dist[$island])){
       foreach ($dist[$island] as $key => $val){
           if ($flag[$key] !== 1) {
               $childnode[$key] = $val;
           }
       }
   }
   return $childnode;
}
 
//最も根から葉の親までの距離が大きいものを取り出す
function max_dist($leaf){
    $max = 0;
    foreach ($leaf as $key => $val){
        if ($max < $leaf[$key]){
            $max = $leaf[$key];
        }
    }
    return $max;
}
 
function calc(){
    global $dist;
    global $leaf;
    global $max_dist;
    //まずは葉の親までの全部の橋のコストを合計して2倍。もともとダブルカウントなので全部足し算すればOK
    $sum = 0;
    foreach($dist as $key => $val){
        foreach($dist[$key] as $d2){
            $sum += $d2;
        }
    }
     
    //$sum から、根から葉の親までの距離が最も大きいものをマイナス
    $sum -= $max_dist;
    return $sum;
}
 
while (1){
    //変数の初期化
    $dist = array();
    $leaf = array();    //$leaf[葉の親のnum] = 根からの距離
    $flag = array();	//探索済みかどうか
 
    //ファイル読み込み
    $stdin = fscanf($file_handle, '%d');    //fscanf()で読み込んだものは配列として格納される
    $n = $stdin[0];
    //終了条件
    if ($n == 0){
        break;
    }
     
    for ($i=0; $i < $n-1; $i++){
        $info = fscanf($file_handle, '%d %d %d');
        $parent = $info[0]; $child = $info[1]; $distance = $info[2];
        $dist[$parent][$child] = $distance;
        $dist[$child][$parent] = $distance;
    }
    
    for ($i=1; $i<=$n; $i++){
    	$flag[$i] = 0;	//すべての島を未探索に。
    }
    
 
    //探索
    $stack['node'] = 1;     //スタートを$stackに入れて開始
    $stack['parent'] = NULL;
    $stack['dist'] = 0;
    dfs($stack);
    $max_dist = max_dist($leaf);
    $sum = calc();
    
    //出力
    echo $sum;
    echo PHP_EOL;
}
 
fclose($file_handle);

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


int main() {
    li n, a, b;
    cin >> n >> a >> b;
    if (n == 1) {
        cout << (a == b ? 1 : 0) << endl;
        return 0;
    }
    if (a > b) {
        puts("0");
        return 0;
    }
    li mi = a * (n - 1) + b;
    li ma = b * (n - 1) + a;
    cout << ma - mi + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	void solve() throws IOException {
		solve(ns().toCharArray(), ni());
	}

	private void solve(char[] a, int n) {
		StringBuffer sb = new StringBuffer();
		int i=0;
		while (i<a.length) {
			sb.append(a[i]);
			i+=n;
		}
		out.println(sb);
	}

	String ns() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine(), " ");
		}
		return tok.nextToken();
	}

	int ni() throws IOException {
		return Integer.parseInt(ns());
	}

	long nl() throws IOException {
		return Long.parseLong(ns());
	}

	double nd() throws IOException {
		return Double.parseDouble(ns());
	}

	String[] nsa(int n) throws IOException {
		String[] res = new String[n];
		for (int i = 0; i < n; i++) {
			res[i] = ns();
		}
		return res;
	}

	int[] nia(int n) throws IOException {
		int[] res = new int[n];
		for (int i = 0; i < n; i++) {
			res[i] = ni();
		}
		return res;
	}

	long[] nla(int n) throws IOException {
		long[] res = new long[n];
		for (int i = 0; i < n; i++) {
			res[i] = nl();
		}
		return res;
	}

	public static void main(String[] args) throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		tok = new StringTokenizer("");
		Main main = new Main();
		main.solve();
		out.close();
	}
}

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


bool isIn9x9[81];
int main()
{
  for (int i = 1; i <= 9; i++)
    for (int j = 1; j <= 9; j++)
      isIn9x9[i * j - 1] = true;
  int n;
  cin >> n;
  if (n < 1 || n > 81)
    cout << "No" << endl;
  else if (isIn9x9[n - 1])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

ll collatz(ll n) {
    if (n % 2 == 0) {
        return n / 2;
    }
    return 3 * n + 1;
}

int main() {
    ll s;
    cin >> s;

    vector<ll> a;
    ll val = s;
    ll ans = 1;
    while (none_of(cbegin(a), cend(a), [val](auto x) { return x == val; })) {
        a.push_back(val);
        val = collatz(val);
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//
//ARC 094
//C
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;

#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 RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    vector<int> v(3);
    cin >> v[0] >> v[1] >> v[2];
    sort(ALL(v));

    int ans=0;
    if ((v[2]-v[0])%2==0){
        if ((v[2]-v[1])%2==0){
            ans += (v[2]-v[0])/2;
            ans += (v[2]-v[1])/2;
        }else{
            ans += 1;
            ans += (v[2]-v[0])/2;
            ans += (v[2]+1-v[1])/2;
        }
    }else{
        if ((v[2]-v[1])%2==0){
            ans += 1;
            ans += (v[2]+1-v[0])/2;
            ans += (v[2]-v[1])/2;
        }else{
            ans += v[2]-v[1];
            ans += (v[0]+(v[2]-v[1]))/2;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main (){
    int n,m,l;
    cin >> n >>m >> l;
    long long int **A = new long long int *[n];
    for(int i = 0; i < n; i++){
        A[i] = new long long int [m];
    }

    long long int **B = new long long int *[m];
    for(int i= 0; i < m; i++){
        B[i] = new long long int [l];
    }
 
    for(int i= 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> A[i][j];
        }
    }

    for (int i = 0; i < m; i++){
        for(int j = 0; j < l; j++){
            cin >> B[i][j];
        }
    }
    
    long long int **C = new long long int * [n];
    for(int i = 0; i < n; i++){
        C[i] = new long long int[l];
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            C[i][j] = 0;
        }
    }
    for(int i = 0; i < n; i ++){
        for(int j = 0; j < l; j++){
            for(int k = 0; k < m; k++){
                C[i][j] += A[i][k]* B[k][j];
            }
        }
    }
    for(int i = 0;i < n; i++){
        for(int j = 0; j < l-1; j++){
            cout << C[i][j] << " ";
        }
        cout << C[i][l-1];
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3308
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

int main() {
  string s; cin>>s;
  int ans = 10000000;
  int num = 0;
  rep(i, s.size() - 2) {
    num = 0;
    num += (s[i] - '0') * 100;
    num += (s[i+1] - '0') * 10;
    num += (s[i+2] - '0');
    //cout << num << endl;
    if (ans > abs(num - 753)) ans = abs(num - 753);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int N, M; cin >> N >> M;
    vector<int> p(N);
    rep(i, N) {
        int t; cin >> t;
        t--;
        p[i] = t;
    }

    vector<vector<int>> e(N);

    rep(i, M) {
        int x, y; cin >> x >> y;
        x--; y--;
        e[x].emplace_back(y);
        e[y].emplace_back(x);
    }

    vector<int> achi(N);

    int ans = 0;
    rep(i, N) {
        if (achi[i]) continue;

        achi[i] = 1;

        vector<int> nb_sets;
        vector<int> sets;
        nb_sets.emplace_back(p[i]);
        sets.emplace_back(i);

        stack<int> st;
        st.push(i);

        while (!st.empty()) {
            int ni = st.top(); st.pop();
            for (auto ne: e[ni]) {
                if (achi[ne]) continue;
                achi[ne] = 1;
                nb_sets.emplace_back(p[ne]);
                sets.emplace_back(ne);
                st.push(ne);
            }
        }

        sort(nb_sets.begin(), nb_sets.end());
        sort(sets.begin(), sets.end());

        int ls = sets.size();
        int a = 0, b = 0;
        while (a < ls && b < ls) {
            if (nb_sets[a] == sets[b]) {
                ans += 1;
                a += 1;
                b += 1;
            } else if (nb_sets[a] < sets[b]) {
                a += 1;
            } else {
                b += 1;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7464
Q,H,S,D = map(int,input().split())
N = int(input())

efficient_num,efficient_cost = 0,8*Q
if(efficient_cost > 4*H): efficient_num,efficient_cost = 1,4*H
if(efficient_cost > 2*S): efficient_num,efficient_cost = 2,2*S
if(efficient_cost > D): efficient_num,efficient_cost = 3,D

#残りが0L or 1Lとなるまでコスパいい商品を買う
min_cost = 0

if(N%2 == 0):
 if(efficient_num == 0): min_cost = int(N/0.25)*Q
 elif(efficient_num == 1): min_cost = int(N/0.50)*H
 elif(efficient_num == 2): min_cost = N*S
 elif(efficient_num == 3): min_cost = (N//2)*D
 #残り0L

else:
 N = 2*(N//2)
 if(efficient_num == 0): min_cost = int(N/0.25)*Q
 elif(efficient_num == 1): min_cost = int(N/0.50)*H
 elif(efficient_num == 2): min_cost = N*S
 elif(efficient_num == 3): min_cost = (N//2)*D
 #残り1L
 #2L以外のコスパいいので残り1Lを買う
 efficient_num,efficient_cost = 0,8*Q
 if(efficient_cost > 4*H): efficient_num,efficient_cost = 1,4*H
 if(efficient_cost > 2*S): efficient_num,efficient_cost = 2,2*S
  
 if(efficient_num == 0): min_cost += int(1/0.25)*Q
 elif(efficient_num == 1): min_cost += int(1/0.50)*H
 elif(efficient_num == 2): min_cost += 1*S
    
print(min_cost)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(long long)(n); i++)
#define REP(i, k, n) for(long long i=(long long)(k); i<(long long)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const ll inf = 1020304050607080910;
const int mod = 1000000007;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x,ll y){if(x>y)swap(x, y);while(x!=0){y%=x;swap(x, y);}return y;}
ll mpow(ll x,ll r){if(r==0)return 1;if(r%2==1){return x*mpow(x,r-1)%mod;}else{ll aa=mpow(x,r/2);return aa*aa%mod;}}

int N, A[100000];

bool solve(void){
	if(N==1) return ((A[0]%2)?false:true);
	int gu = 0, odd;
	rep(i, N){
		if(A[i]%2==0) gu++;
		else odd = i;
	}
	if(gu%2==1 && N>gu) return true;
	if(gu%2==0 && N-gu>1) return false;
	if(A[odd] == 1) return false;
	A[odd]--;
	int g = A[0];
	rep(i, N-1) g = gcd(g, A[i+1]);
	rep(i, N) A[i] /= g;
	return (!solve());
}

int main(){
	cin >> N;
	rep(i, N) cin >> A[i];
	cout << (solve()?"First":"Second") << endl;
	return 0;
}


Measured memory_bytes: 640
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	O, E := sc.nextStr(), sc.nextStr()
	ans := ""
	even, odd := 0, 0
	for i := 1; i <= len(O)+len(E); i++ {
		if i%2 == 0 {
			ans += string(E[even])
			even++
		} else {
			ans += string(O[odd])
			odd++
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 640
N = gets.to_i
D = gets.split.map &:to_i
M = gets.to_i
T = gets.split.map &:to_i
h = {}
D.each{ |d| h[d] = (h[d] || 0) + 1 }
T.each{ |t| h[t] = (h[t] || 0) - 1 }
puts h.values.all?{ |v| v >= 0 } ? "YES" : "NO"


Measured memory_bytes: 43580
#include <stdio.h>
int main()
{
  int train[100],i=1,n;
  while(scanf("%d",&n)!=EOF){
    if(n!=0){
      train[i]=n;
      i++;
    }else {
      printf("%d\n",train[i-1]); 
      i--;
    }
  }
  return 0;
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

set<int>st;
int a, b;
 
int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin);
#endif
	
	st.insert(1);
	st.insert(2);
	st.insert(3);
	cin >> a >> b;
	st.erase(a); st.erase(b);
	cout << *st.begin() << '\n';
		
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc063/tasks/arc075_b

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 1e5;
const int A_MAX = 1e9;
const int H_I_MAX = 1e9;

int N, A, B;
int h[N_MAX];

int D;

bool C(ll k) {
  ll k2 = 0;
  REP(i, N) {
    ll h2 = h[i] - B * k;
    if (h2 <= 0) break;
    k2 += (h2 + D - 1) / D;
  }
  return k2 <= k;
}

void solve() {
  D = A - B;
  sort(h, h + N, greater<int>());
  int hi = H_I_MAX;
  int lo = 0;
  while (hi - lo > 1) {
    int mi = (hi + lo) / 2;
    if (C(mi)) hi = mi;
    else lo = mi;
  }
  printf("%d\n", hi);
}

void input() {
  scanf("%d%d%d", &N, &A, &B);
  REP(i, N) scanf("%d", h + i);
}

int main() {
  input();
  solve();
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  string T = S;
  T = regex_replace(T, regex("WR"), "x");
  if (count(T.begin(), T.end(), 'x') == 0) return cout << 0 << "\n", 0;
  set<int> SE;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'R') SE.insert(i);
  }
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'W') {
      if (!SE.size()) continue;
      int tmp = *rbegin(SE);
      if (tmp <= i + 1) continue;
      swap(S.at(i), S.at(tmp));
      SE.erase(tmp);
      cnt++;
    }
  }
  S = regex_replace(S, regex("WR"), "x");
  cnt += count(S.begin(), S.end(), 'x');
  cout << cnt << "\n";
}

Measured memory_bytes: 12120
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ');
            var n = int.Parse(line[0]);
            var r = int.Parse(line[1]);
 
            if (n >= 10) Console.WriteLine(r);
            else
            {
                var ans = r + (100 * (10 - n));
                Console.WriteLine(ans);
            }
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
const int mod=1e9+7;
#define pb push_back
#define pii pair<ll,ll>
#define pi pair<int ,int> 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i,a,n) for(int i=a;i>=n;i-- )


int main()

{  
    
    string s;
    cin>>s;int count=0;
    for(int i=0;i<3;i++){if(s[i]=='A'){count++;}}
    
    if(s[0]==s[1] && s[2]==s[1]){cout<<"No";}
    else{cout<<"Yes";}
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8

# https://atcoder.jp/contests/abc078/tasks/arc085_b
# 15:53-


def main():
    a, b, c, d = list(map(int, list(input())))

    def p(x, y):
        return x + y
    
    def m(x, y):
        return x - y
    
    conv = {0: "+", 1: "-"}
    
    for i, op1 in enumerate([p, m]):
        for j, op2 in enumerate([p, m]):
            for k, op3 in enumerate([p, m]):
                if op3(op2(op1(a, b), c), d) == 7:
                    return "{}{}{}{}{}{}{}=7".format(a, conv[i], b, conv[j], c, conv[k], d)


print(main())


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int N=4019,mod=1e9+7;
int A,B,ans,c[N][N],s[N][N];
int main()
{
	for(int i=0;i<N;i++)
	{
		c[i][0]=1;
		for(int j=1;j<=i;j++)c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
	}
	for(int i=0;i<N;i++)
	{
		s[i][0]=1;
		for(int j=1;j<N;j++)s[i][j]=(s[i][j-1]+c[i][j])%mod;
	}
	for(int i=0;i<N;i++)
	for(int j=1;j<N;j++)
	s[i][j]=(s[i][j]+s[i][j-1])%mod;
	cin>>A>>B;
	for(int i=0;i<=A;i++)
	for(int j=0;j<B&&i+j<=A;j++)
	if(!j)ans=(ans+1)%mod;
	else ans=(ans+1ll*c[B-1][j]*s[j-1][i])%mod;
	cout<<ans<<endl;
}

Measured memory_bytes: 126592
N,M = map(int,input().split())
num = 1000000007

hole = [False]*(N+1)
a = [int(input()) for _ in range(M)]
for i in a:
  hole[i] = True
  
dp = [0]*(N+1)
dp[0] = 1


for i in range(1,N+1):
  if i == 1:
    if hole[i] == True:
      dp[i] = 0
    else:
      dp[i] = dp[0]
  else:
    if hole[i] == True:
      dp[i] = 0
    else:
      dp[i] = dp[i-1] + dp[i-2]
print(dp[-1]%num)

Measured memory_bytes: 460788
#include <bits/stdc++.h>
using namespace std;
int b[2000009];
int c[2000009];
int k;
int dp(int a){
    if(c[a] != -1){
        return c[a];
    }
    if(a == 1){
        c[a] = 0;
        return 0;
    }
    else{
        int mini = 1e9;
        for(int i = 1; i < min(a,k + 1);i++){
            mini = min(mini, dp(a-i)+abs(b[a]-b[a-i]));
        }
        c[a] = mini;
        return c[a];
    }
}
int main(){
    int x;
    cin >> x>>k;
    for(int i=1;i<x+1;i++){
        cin >> b[i];
        c[i] = -1;
    }
    b[0] = b[1];
    cout << dp(x);
}




Measured memory_bytes: 9472
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stdexcept>
#include<cmath>
#include<fstream>
#include<memory>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define S second
#define pb push_back
#define pf push_front
#define LIM 100000
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;


int main(){

  int N,M;
  while(true){
    cin >> N >> M;
    if(N == 0 && M == 0)break;
    vector<int> h,w;
    map<int,int> http,www;
    rep(i,N){
      int hh;
      cin >> hh;    
      h.push_back(hh);
    }
    rep(i,M){
      int ww;
      cin >> ww;
      w.pb(ww);
    }

    rep(i,N){
      http[h[i]]++;
      int pre = h[i];
      for(int j=i+1;j<N;j++){
	pre += h[j];
	http[pre]++;
      }
    }

    rep(i,M){
      www[w[i]]++;
      int pre = w[i];
      for(int j=i+1;j<M;j++){
	pre += w[j];
	www[pre]++;
      }
    }

    int cnt = 0;
    map<int,int>::iterator it = www.begin();
    while(it != www.end()){    

      cnt += http[(*it).first]*(*it).second;
    
	it++;
    }
    
    cout << cnt << endl;




  }
return 0;
}

Measured memory_bytes: 32224
<?php
$n=fgets(STDIN);

for($i=0;$i<$n;$i++){
  list($a,$b,$c)=explode(' ',fgets(STDIN));
  $a*=$a;
  $b*=$b;
  $c*=$c;
  if($a+$b==$c){echo 'YES',PHP_EOL;continue;}
  if($a+$c==$b){echo 'YES',PHP_EOL;continue;}
  if($b+$c==$a){echo 'YES',PHP_EOL;continue;}
  echo 'NO',PHP_EOL;
}

Measured memory_bytes: 15132
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int k = scan.nextInt();
        long count = 0;

		for(int a=1; a<(k+1); a++){
		for(int b=1; b<(k+1); b++){
		for(int c=1; c<(k+1); c++){
			count+=gcd((gcd(a,b)),c);		
		}}}
		
		System.out.println(count);
	    scan.close();	
    }

	//ユークリッドの互除法
    private 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: 36336
from operator import itemgetter
N = int(input())
AB = []
for _ in range(N):
    A, B = map(int, input().split())
    AB.append([A, B])
AB.sort(key=itemgetter(1))
cnt = 0
for a, b in AB:
    cnt += a
    if cnt > b:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 38080
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

const int maxn = 1e5 + 5;
int sz[maxn], p[maxn];
set <int> X[maxn], Y[maxn];

void mset(int u){
    p[u] = u;
    sz[u] = 1;
}

int fset(int u){
    return (u == p[u] ? u : p[u] = fset(p[u]));
}

void connect(int u, int v, int x1, int y1, int x2, int y2){
    u = fset(u);
    v = fset(v);
    if(u != v){
        if(sz[v] > sz[u])
            swap(u, v);
        sz[u] += sz[v];
        p[v] = u;
      	for(int x : X[v])
      	    X[u].insert(x);
      	for(int y : Y[v])
      	    Y[u].insert(y);
    }
}

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
        mset(i);
    vector <tuple<int, int, int>> v;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        X[i].insert(a);
        Y[i].insert(b);
        v.emplace_back(a, b, i);
    }
    sort(all(v));
    for(int i = 0; i < n - 1; i++){
        int a[2], b[2], c[2];
        tie(a[0], b[0], c[0]) = v[i];
        tie(a[1], b[1], c[1]) = v[i + 1];
        if(a[0] == a[1]){
            connect(c[0], c[1], a[0], b[0], a[1], b[1]);
        }
    }
    sort(all(v), [](tuple<int, int, int> A, tuple<int, int, int> B){
        int a[2], b[2], c[2];
        tie(a[0], b[0], c[0]) = A;
        tie(a[1], b[1], c[1]) = B;
        return b[0] < b[1];
    });
    for(int i = 0; i < n - 1; i++){
        int a[2], b[2], c[2];
        tie(a[0], b[0], c[0]) = v[i];
        tie(a[1], b[1], c[1]) = v[i + 1];
        if(b[0] == b[1]){
            connect(c[0], c[1], a[0], b[0], a[1], b[1]);
        }
    }
    bool used[maxn] = {};
    ll res = 0;
    for(int i = 0; i < n; i++){
        if(used[fset(i)])
            continue;
        res += X[fset(i)].size() * Y[fset(i)].size();
        used[fset(i)] = 1;
    }
    cout << res - n;
}

Measured memory_bytes: 49460
#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; 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 ll long long
#define pb(a) push_back(a)

int main(){
  int n, ans = 0;
  cin >> n;
  long a[n];
  REP(i, n){
    cin >> a[i];
    while(a[i] % 2 == 0){
      a[i] /= 2;
      ans++;
    }
  }
  cout << ans;
}


Measured memory_bytes: 384
import sys
input = sys.stdin.readline
from collections import Counter, defaultdict
def main():
    N = int( input())
    A = list( map( int, input().split()))
    CA = Counter(A)
    d = defaultdict( lambda : False)
    T = [False]*(10**6+1)
    A.sort()
    Z = [False]*(10**6+1)
    ans = 0
    for a in A:
        if CA[a] == 1 and not T[a]:
            ans += 1
        if not Z[a]:
            Z[a] = True
            for i in range(1, 10**6+1):
                if i*a > 10**6:
                    break
                T[i*a] = True
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 47912
// In the name of God

#include <bits/stdc++.h>

using namespace std;

const long long mod = 998244353LL;

long long fast_pow(long long x, long long y) {
	x %= mod;
	long long ret = 1;
	for(;y;y>>=1) {
		if(y & 1) ret = (ret*x)%mod;
		x = (x*x)%mod;
	}
	return ret;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> cnt(n, 0);
	for(int i=0;i<n;i++) {
		int x;
		cin >> x;
		if(i == 0 && x != 0) {
			cout << 0;
			exit(0);
		}
		cnt[x]++;
	}
	if(cnt[0] != 1) {
		cout << 0;
		exit(0);
	}
	for(int i=1;i<n;i++) {
		if(cnt[i] && !cnt[i-1]) {
			cout << 0;
			exit(0);
		}
	}
	long long ret = 1;
	for(int i=1;i<n;i++) {
		if(!cnt[i]) break;
		ret = (ret * fast_pow(cnt[i-1], cnt[i]))%mod;
	}
	cout << ret;
	return 0;
}


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

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  
  if(a-b<0){
  	if(abs(a-b)>x){
      cout << "dangerous";
    }else{
      cout << "safe";
    }
  }else{
  	cout << "delicious";
  }

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()
p = [sc, sc, sr, sr]

def takahashi(p, M):
    if M == 'L':
        p[0] -= 1
    if M == 'R':
        p[1] += 1
    if M == 'U':
        p[2] -= 1
    if M == 'D':
        p[3] += 1
    return p

def aoki(p, M):
    if M == 'L':
        p[1] = max(1, p[1]-1)
    if M == 'R':
        p[0] = min(W, p[0]+1)
    if M == 'U':
        p[3] = max(1, p[3]-1)
    if M == 'D':
        p[2] = min(H, p[2]+1)
    return p

for n in range(N):
    p = takahashi(p, S[n])
    if p[0] == 0 or p[1] == W+1 or p[2] == 0 or p[3] == H+1:
        print('NO')
        exit()
    p = aoki(p, T[n])
print('YES')
    


Measured memory_bytes: 3888
#include <stdio.h>
#include <stdbool.h>

int main(){
   bool flag=false;
   char S[5];
   gets(S);
   if((S[0]==S[1])||(S[1]==S[2])||(S[2]==S[3])) flag=true;
   if(flag){
      printf("Bad\n	");
   }
   else{
      printf("Good\n");
   } 
   return 0;
}

Measured memory_bytes: 128
n,k = map(int, input().split())
l = [0 for i in range(n)]
c = []
for i in range(k):
  d = int(input())
  if d != 1:
    c.append(list(map(int, input().split())))
    for j in c[i]:
      l[j-1] = 1
  else:
    c.append(int(input()))
    l[c[i]-1] = 1
print(l.count(0))

Measured memory_bytes: 9284
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    cin>>n;
    int a[n];
    forn(i,n)   cin>>a[i];
    forn(i,n){
        if(a[i]%2==0){
            if(a[i]%3!=0 && a[i]%5!=0){
                cout<<"DENIED\n";
                return 0;
            }
        }
    }
    cout<<"APPROVED\n";
    return 0;
}



Measured memory_bytes: 256
X,N = (int(i) for i in input().split())
p_list=[int(i) for i in input().split()]
for i in range(0,200):
    if p_list==[]:
        print(str(X))
        break
    if i%2==1:
        X-=i
        if X not in p_list:
            print(str(X))
            break
    elif i%2==0:
        X+=i
        if X not in p_list:
            print(str(X))
            break

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

int main(void){
    std::string a;
    std::cin>>a;
    if(a=="Sunny") {
        std::cout<<"Cloudy";
    }   
    else if(a=="Rainy"){
        std::cout<<"Sunny";
    }

    else if(a=="Cloudy"){
        std::cout<<"Rainy";
    }

    return (0);
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

vector<ll> G[55];
map<pll, ll> mp;

ll mask[25][55] = {};

bool dfs(ll now, ll par, ll dst, ll id){
	if(now == dst){
		return true;
	}
	for(auto next: G[now]){
		if(next == par) continue;
		bool flag = dfs(next, now, dst, id);
		if(flag){
			ll a = now;
			ll b = next;
			if(a>b) swap(a, b);
			mask[id][mp[{a, b}]] = 1;
			return true;
		}
	}
	return false;
}

ll powLL(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res *= a;
            //res %= mod;
        }
        a = a*a;
        //a %= mod;
        n >>= 1;
    }
    return res;
}

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

    ll N;
    cin >> N;
    REP(i, N-1){
    	ll a, b;
    	cin >> a >> b;
    	a--, b--;
    	G[a].push_back(b);
    	G[b].push_back(a);
    	if(a>b) swap(a, b);
    	mp[{a, b}] = i;
    }

    ll M;
    cin >> M;
    vector<ll> u(M), v(M);
    REP(i, M){
    	cin >> u[i] >> v[i];
    	u[i]--;
    	v[i]--;
    }

    REP(i, M){
    	dfs(u[i], -1, v[i], i);
    }

    /*
    REP(i, M){
    	REP(j, N-1){
    		cout << mask[i][j] << " ";
    	}
    	cout << endl;
    }
    */

    ll res = 0;
    REP(ma, (1ll<<(M))){
    	ll kosu = __builtin_popcountll(ma);
    	ll cnt = 0;
    	REP(i, N-1){
    		ll tmp = 0;
    		REP(j, M){
    			if(ma>>j & 1){
    				if(mask[j][i]==1) tmp = 1;
    			}
    		}
    		cnt += tmp;
    	}
    	ll val = powLL(2, N-1-cnt);
    	if(kosu%2==0){
    		res += val;
    	}else{
    		res -= val;
    	}
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    fastcin();

    int n;
    cin >>n;
    cout << (n-1)/2 << endl;
}

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

int main() {
    int n, d;
    cin >> n >> d;
    vector< vector< double > > x(n, vector< double >(d));

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < d; j++) {
            cin >> x[i][j];
        }
    }

    int cnt = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            double dis = 0;
            for(int k = 0; k < d; k++) {
                dis += pow(x[i][k] - x[j][k], 2);
            }
            if(fabs((double)((int)sqrt(dis)) - sqrt(dis)) < 0.001) {
                cnt++;
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define pb push_back
#define ff first
#define ss second
#define BS binary_search
#define all(c) (c).begin(),(c).end()
#define sz(x) (int)(x).size()
#define EPS 0.000000001 //1e-9
using pii=pair<int,int>;
const long long INF=1e18;

template <class A, class B> ostream& operator<<(ostream& os, const pair<A,B> p) {return os << "(" << p.first << "," << p.second << ")";} 

void dprint(string s) {cout << endl;}
template <class T, class... U> void dprint(string s, T t, U... u) 
{int w = s.find(','); cout << "[" << s.substr(0,w) << ": " << t << "] "; dprint(s.substr(w+1, (int)s.size()-w), u...);} 

#define DEBUG 
#ifdef DEBUG
#define dbg(X...) dprint(#X,X)
#else
#define dbg(X...) "KEEP CALM" 
#endif

const int N=2e5+5; // Don't forget to CHANGE this value ACC. TO Q.

int n, k, arr[N];

bool check(int x)
{
	int ans=0;
	for(int i=0;i<n;i++)
	{
		int cut=(arr[i]-1)/x;
		ans+=cut;
	}
	return ans<=k;
}

int BinSearch()
{
	int lo=0, hi=1e9+5;
	while(hi-lo>1)
	{
		int mid=(lo+hi)/2;
		if(check(mid))
			hi=mid;
		else
			lo=mid;
	}
	return hi;
}

int32_t main()
{
	IOS;
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>arr[i];
	cout<<BinSearch();
	return 0;
}

Measured memory_bytes: 5108
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
const double PI = 3.14159265358979323846;
int main()
{
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	while (h >= 12.0)
		h -= 12.0;
	while (m >= 60.0)
		m -= 60;
	double a1 = (h * 60.0 + m) / 2;
	double a2 = 360.0 * (m / 60);
	double a3 = abs(a1 - a2);
	if (a3 > 180.0)
		a3 = 360 - a3;
	a3 = PI * a3 / 180.0;
	double c = sqrt(a * a + b * b - 2 * a * b * cos(a3));
	cout.precision(20);
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 4124
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//-----CODE------//

vector< int > z_algorithm(const string &s) {
  vector< int > prefix(s.size());
  for(int i = 1, j = 0; i < s.size(); i++) {
    if(i + prefix[i - j] < j + prefix[j]) {
      prefix[i] = prefix[i - j];
    } else {
      int k = max(0LL, j + prefix[j] - i);
      while(i + k < s.size() && s[k] == s[i + k]) ++k;
      prefix[i] = k;
      j = i;
    }
  }
  prefix[0] = (int) s.size();
  return prefix;
}

void solve(void)
{
  int N;cin>>N;
  string str;cin>>str;
  int ANS  =0;
  for (int i = 0; i < N-1; i++)
  {
    string s = str.substr(i,str.size()-i);
    auto vec = z_algorithm(s);
    // DEBUG(vec);
    for (int j = 1; j < vec.size(); j++)
    {
      if(vec[j] > j)continue;
      chmax(ANS,vec[j]);
    }
    
  }
  cout<<ANS<<endl;
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

  string s;
  cin >> s;
  
  string c = "CODEFESTIVAL2016";
  int ans = 0;
  rep(i, s.length()){
    if(s[i] != c[i]){
		ans++;
    }
  }
  cout << ans << endl;
  
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    n%=10;
    if(n==3) cout << "bon";
    else if(n==2 || n==4 || n==5  || n==7 || n==9) cout << "hon";
    else cout << "pon";
}

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

void Print(const vector<int> & A)
{
    cout << A[0];
    for (int i = 1; i < A.size(); ++i) {
        cout << ' ' << A[i];
    }
    cout << endl;
}

void InsertionSort(vector<int> & A)
{
    int n = A.size();
    for (int i = 1; i < n; ++i) {
        int key = A[i];
        int j = i-1;
        while (j >= 0 && A[j] > key) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = key;
        Print(A);
    }
}

int main()
{
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    Print(A);
    InsertionSort(A);
    return 0;
}

Measured memory_bytes: 3088
using System;

	class Program
	{
		public static void Main(string[] args)
		{
			int n=int.Parse(Console.ReadLine());
			int[] array= new int[n];
			for(int k=0;k<array.Length;k++)
			{
				array[k]=int.Parse(Console.ReadLine());
			}
			int cnt=0;
			int m=1;//?????£??????????????°???h=3???m?????????/??? h<n???

			for(int gap=2;(int)((Math.Pow(3,gap)-1)/2)<n;gap++)
			{			
				m++;
			}
			
			int []  G=new int[m];//?????£??????????´???????????????£???????????????????????????????????????????????£??????
			for(int i=0;i<G.Length;i++)//??????.Length????????????????????? m=G.Length
			{
				G[m-1-i]=(int)((Math.Pow(3,i+1)-1)/2);
			}
			for(int j=0;j<G.Length;j++)
			{
				cnt+=sort( array, n, G[j]);//?????\?????????????????????
			}
			//?????????????????????m???????????????G[i]????????????????????§???????????????G?????¨????????´??????count?????????
			//????????????????????????????????????
			Console.WriteLine(m);
			for(int o=0;o<G.Length-1;o++)
			{
				Console.Write(G[o]+" ");
			}
			Console.Write(G[G.Length-1]+"\r\n");//???????????§?????????
			Console.WriteLine(cnt);//?????????
			for(int l=0;l<array.Length;l++)
			{
				Console.WriteLine(array[l]);
			
			}
			
			
		}
		public static int sort(int [] A,int n,int g)
		{
			int count=0;//??????????????°
			for (int k=0;k<g;k++)
			{
				
			for(int i=k+g;i<n;i+=g)
			{
				
				int v=A[i];
				int j=i-g;
				while(j>=0&&A[j]>v)
				{
					A[j+g]=A[j];
					j=j-g;
				count ++; //????????????????????§????????????????????§??????????????¢??????
				A[j+g]=v;//????????????A[j]???????????????????§?????????????????????\????????????
				//??????????????????????°?????????????????????´?????????????????£?????????????????????????´??????´???????????????????°?????????????????????????0
				//?????????????????????????????\???
				}
				
			}
			}
			return count;
		}
		
	}
	

Measured memory_bytes: 16668