akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
long long max(long long x, long long y){return x<y?y:x;}
int main(void){
	int n,i,flag=0;
	scanf("%d",&n);
	long long Cx,Cy,x[n],y[n],h[n],H,hkari,hhh;
	for(i=0;i<n;i++)scanf("%lld%lld%lld",&x[i],&y[i],&h[i]);
	for(Cx=0;Cx<=100;Cx++){
		for(Cy=0;Cy<=100;Cy++){
			for(i=0;i<n;i++){
				if(h[i]!=0){
					hhh = abs(x[i]-Cx)+abs(y[i]-Cy)+h[i];
					break;
				}
			}
			for(i=0;i<n;i++){
				if(h[i] != max(0,hhh-abs(x[i]-Cx)-abs(y[i]-Cy)))break;
			}
			if(i==n)flag=1;
			if(flag==1)break;
		}
		if(flag==1)break;
	}
	
	printf("%lld %lld %lld",Cx,Cy,hhh);
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

signed main() {
	IOS;
	string s;	cin >> s;
	for(int i = 0; i < s.length(); i++){
		if(s[i] == '?'){
			s[i] = 'D';
		}
	}	
	cout << s;
	return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll h, w;
  cin >> h >> w;
  ll ans = min(h, w);
  if(h % 3 == 0 || w % 3 == 0) ans = 0;
  rep(k, 2) {
    ll r = w % 3;
    rep(i, r + 1) {
      vl a(3);
      a[0] = h * (w / 3 + i);
      a[1] = (h / 2 + h % 2) * (w / 3 * 2 + r - i);
      a[2] = (h / 2) * (w / 3 * 2 + r - i);
      sort(all(a));
      ans = min(ans, a[2] - a[0]);
    }
    swap(h, w);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		int ans = Integer.MAX_VALUE;

		for (int i = 0; i <= n; i++) {
			int c = 0;

			int t = i;
			while (t > 0) {
				c += t % 6;
				t /= 6;
			}

			t = (int) (n - i);
			while (t > 0) {
				c += t % 9;
				t /= 9;
			}

			ans = Math.min(ans, c);
		}

		System.out.println(ans);
	}
}

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

void main_()
{
    ll N;
    cin >> N;
    vector<ll> ps;
    ps.reserve(N);
    copy_n(istream_iterator<ll>(cin), N, back_inserter(ps));

    ll ans = 0;
    for (ll i = 0; i < N; ++i) {
        if (ps[i] == i + 1) {
            ans++;
            i++; // ループと合わせて2つ進む
        }
    }
    cout << ans << "\n";
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <iterator>
#include <cmath>
#include <deque>
#include <stack>
#include <functional>
using namespace std;
#define int long long

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}

signed main()
{
    {
        if (fopen("input.txt", "r")) {
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        }
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
    }

    int a, b;
    cin >> a >> b;
    cout << a * (b / gcd(a, b));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
    int N;
    ll K;
    cin >> N >> K;
    int P[N];
    ll C[N];
    for (int i = 0; i < N; i++) {
        cin >> P[i];
        P[i]--;
    }
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }

    ll ans = -100000000000000;

    for (int i = 0; i < N; i++) {
        vector<ll> v;
        int p = P[i];
        ll c_sum = C[p];
        v.push_back(C[p]);
        ll cnt = 1;
        ans = max(ans, c_sum);
        while (true) {
            p = P[p];
            if (P[i] == p) break;
            cnt++;
            if (cnt > K) break;
            c_sum += C[p];
            v.push_back(C[p]);
            ans = max(ans, c_sum);
        }
        //cout << c_sum << "\n";
        ll sum = 0;
        p = P[i];
        if (cnt > K) continue;
        ans = max(ans, c_sum * (K / cnt));
        for (int i = 0; i < cnt; i++) {
            sum += C[p];
            p = P[p];
            ans = max(ans, sum + c_sum * ((K - i - 1)/ cnt));
        }

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

    return 0;
}

Measured memory_bytes: 3688
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))
x = [False]*N
n,i = (0, 0)
while x[n] == False:
    x[n] = True
    n = a[n]-1
    i+=1
    if n==1:
        print(i)
        break
else:
    print(-1)


Measured memory_bytes: 7852
#include<iostream>
#include<algorithm>
#include <stdlib.h> 
using namespace std;

int main(){
  int N;
  cin >> N;
  int A[110];
  for (int n=0; n <N ; n++)cin >> A[n];
  sort(A,A+N);
  int pAlice=0, pBob=0;
  for (int i = 0; i<N; i++) {
    if(i%2!=0) {
      pAlice+=A[i];
    }
    else{
      pBob+=A[i];
    }
  }
  cout<< abs(pAlice-pBob) << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];

  ll sum = 0;
  rep2(i, 1, n) {
    if (v[i - 1] > v[i]) {
      sum += v[i - 1] - v[i];
      v[i] = v[i - 1];
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  char s[N];
  bool flag = false;
  
  for ( int i = 0; i < N; i++){
    cin >> s[i];
    if ( s[i] == 'Y'){
      flag = true;
      break;
    }
  }
  if (flag){
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}

 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>	// require sort next_permutation count etc.

//#include <fstream>	// require freopen

using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.milkshop", "r", stdin );
	int n;

	while (cin >> n && n ){
		vector <int> order (n);
		for (int i = 0; i < n; ++i ){
			cin >> order[i];
		} // end for

		sort (order.begin(), order.end() );
		long long res = 0LL;

		for (int i = 1; i < n; ++i ){
			for (int j = 0; j < i; ++j ){
				res += (long long )order[j]; 
			} // end for
		} // end for
		cout << res << endl;
	} // end while

		
	return 0;
}

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

int main(){
int n,k,h[100000],cost[100000];
cin >> n >> k;
for (int i=0;i<n;i++){
  cin >> h[i];
}
cost[0]=0;
//cost[1]=abs(h[1]-h[0]);
for (int i=1;i<n;i++){
  int minv=1000000000,tmp;
  for (int j=1;j<=k;j++){
    if (i<j)
      break;
    tmp=abs(h[i]-h[i-j])+cost[i-j];
    if (tmp<minv)
      minv=tmp;
  }
  cost[i]=minv;
}

cout << cost[n-1] << endl;
return 0;
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N;
    vector<ll> s, t;
    ll sum;
    cin >> N;
    s.resize(N);
    for(ll i = 0;i < N;i++) cin >> s[i];
    copy_if(s.begin(), s.end(), back_inserter(t), [](ll a) { return a % 10 != 0; });
    sort(t.begin(), t.end(), greater<>());
    sum = accumulate(s.begin(), s.end(), 0);
    while(sum > 0 && sum % 10 == 0) {
        if(t.size()) {
            sum -= t.back();
            t.pop_back();
        } else {
            sum = 0;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int N, cnt, ans = 0;
  string s;
  cin >> N >> s;
  rep(i, N-1){ // i番目とi+1番目の間できる
    vector<int> a(26, 0);
    vector<int> b(26, 0);
    rep(j, i+1){
      a[s[j]-'a']++;
    }
    for(int j=i+1; j < N; j++){
      b[s[j]-'a']++;
    }
    cnt = 0;
    rep(j, 26){
      if(a[j] > 0 && b[j] > 0) cnt++;
    }
    ans = max(ans, cnt);
  }
  print(ans);

}


Measured memory_bytes: 256
package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	c := map[string]int{}
	var n int
	var s string
	for Fscan(in, &n); n > 0; n-- {
		Fscan(in, &s)
		c[s]++
	}
	for _, s := range []string{"AC", "WA", "TLE", "RE"} {
		Fprintln(out, s, "x", c[s])
	}
}

func main() { run(os.Stdin, os.Stdout) }


Measured memory_bytes: 2200
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static int n, w;
    static int[] value, weight;
    static int[][] memo;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        w = sc.nextInt();

        value = new int[n];
        weight = new int[n];
        memo = new int[n][w + 1];
        for (int i = 0; i < n; i++) {
            value[i] = sc.nextInt();
            weight[i] = sc.nextInt();
        }
        for (int[] mv : memo) {
            Arrays.fill(mv, -1);
        }
        System.out.println(dp(n - 1, w));
    }

    public static int dp(int k, int w) {
        if (w < 0) { return Integer.MIN_VALUE; }
        if (k == -1) { return 0; }
        if (memo[k][w] != -1) { return memo[k][w]; }
        memo[k][w] = Math.max(
                dp(k - 1, w - weight[k]) + value[k],
                dp(k - 1, w));
        return memo[k][w];
    }
}

Measured memory_bytes: 31420
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<int> x(N);
    vector<int> y(N);
    vector<int> index(N);

    for(int i{0}; i<N; ++i){
        index.at(i) = i;
        cin >> x.at(i);
        cin >> y.at(i);
    }

    vector<vector<double>> d(N, vector<double>(N,0));

    for(int i{0}; i<N-1; ++i){
        for(int j{i+1}; j<N; ++j){
            d.at(i).at(j) = sqrt(pow(x.at(i)-x.at(j), 2)+pow(y.at(i)-y.at(j), 2));
            d.at(j).at(i) = d.at(i).at(j);
        }
    }

    double result{0};

    do{
        for(int i{0}; i<N-1; ++i){
            result += d.at(index[i]).at(index[i+1]);
        }

    } while (next_permutation(index.begin(), index.end()));

    for(int n{N}; n>0; --n){
        result  /= double(n);
    }


    cout << fixed << setprecision(10);
    cout << result << endl;
}


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

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

fn main() {
    let x = read_as_vec::<i32>()[0];
    if x == 0 {
        println!("1");
    } else {
        println!("0");
    }
}


Measured memory_bytes: 2076
# 解説放送のコード

def main():
    from collections import namedtuple
    from math import hypot

    pt = namedtuple('pt', 'x y')

    def f(x: float, y: float) -> float:
        """(x,y)から最遠点までの距離"""

        def dist(a: pt, b: pt) -> float:
            """二点a,b間の距離"""
            return hypot(a.x - b.x, a.y - b.y)

        return max(dist(pt(x=x, y=y), p_) for p_ in ps)

    def g(x: float) -> float:
        """xを固定し、yを自由に選んだときのfの最小値"""

        # -+-+-+-ternary search-+-+-+-
        l, r = 0, 1000
        for i in range(80):
            # 回数決め打ちで三分探索
            # epsで条件判定は無限ループが怖い
            # 回数固定が計算量も判断しやすい
            # 70-80程度で十分だが、必要なら2/3のべき乗で収束するか計算する
            c1 = (l * 2 + r) / 3  # lr間を3等分した内分点
            c2 = (l + r * 2) / 3  # lr間を3等分した内分点
            if f(x, c1) > f(x, c2):
                l = c1  # 最小値を求めたいので、大きい方を(中央に)近づけていく
            else:
                r = c2
        return f(x, l)  # xを固定し、yを自由に選んだときのfの最小値
        # -+-+-+-+-+-+-+-+-+-+--+-+-+-

    n = int(input())
    *ps, = (pt(*map(int, input().split())) for _ in range(n))

    # -+-+-+-ternary search-+-+-+-
    l, r = 0, 1000
    for i in range(80):
        # 回数決め打ちで三分探索
        # epsで条件判定は無限ループが怖い
        # 回数固定が計算量も判断しやすい
        # 70-80程度で十分だが、必要なら2/3のべき乗で収束するか計算する
        c1 = (l * 2 + r) / 3  # lr間を3等分した内分点
        c2 = (l + r * 2) / 3  # lr間を3等分した内分点
        if g(c1) > g(c2):
            l = c1  # 最小値を求めたいので、大きい方を(中央に)近づけていく
        else:
            r = c2
    ret = g(l)  # xを自由に選んだときのgの最小値
    # -+-+-+-+-+-+-+-+-+-+--+-+-+-

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */



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

    int k, x; cin >> k >> x;
    if (500*k >= x) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
N, X = map(int, input().split())
donut_list = []
for i in range(N):
  donut_list.append(int(input()))

donut_sum = sum(donut_list)
X_remaining = X - donut_sum
donut_num = N
donut_num += int(X_remaining / min(donut_list))

print(donut_num)

Measured memory_bytes: 9044
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<pair<long long, long long>> p(n);
    for(auto&& i : p){
        cin >> i.first >> i.second;
    }
    map<pair<long long, long long>, int> cnt;
    int ans = n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i == j) continue;
            cnt[make_pair(p[i].first - p[j].first, p[i].second - p[j].second)]++;
        }
    }
    for(auto&& i : cnt){
        ans = min(ans, n - i.second);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 384
/*
author : seryu
title : ABC170D_"Not Divisible"
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }

void solve()
{
	int n;
	cin >> n;
	bool can_make[1000005] = {false};
	map<int, int> mp;
	vector<int> a(n);
	rep(i, n) 
	{
		cin >> a[i];
		mp[a[i]]++;
	}
	sort(all(a));
	int ans = 0;
	rep(i, n)
	{
		if(can_make[a[i]])continue;
		if(mp[a[i]] == 1)ans++;
		int j = 1;
		while (j*a[i] <= 1000000)
		{
			can_make[j*a[i]] = true;
			j++;
		}		
	}
	cout << ans << endl;
	return;	
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


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

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        n: u32,
        hvals: [u32; n],
    }
    let mut ans = 0;
    for (end_pos, h) in hvals.clone().into_iter().clone().enumerate() {
        let mut flag = true;
        for i in 0..end_pos {
            if hvals[i] > h {
                flag = false;
                break;
            }
        }
        if flag {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };

int main() {
	int n;
	cin>>n;
	while (n--){
		vector<pair<double, double>> pos(4);
		REP(i, 4){
			cin >> pos[i].first >> pos[i].second;
		}

		if (abs((pos[1].first - pos[0].first)*(pos[3].second - pos[2].second) - (pos[1].second - pos[0].second)*(pos[3].first - pos[2].first))<=1e-10)
			cout << "YES"<<endl;
		else
			cout << "NO"<<endl;
		
	}
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
string grid[1005];
long long  md = 1000000007;
long long  dp[1005][1005];
long long  n, m;
long long  rec(long long  x, long long  y){
	if(x == n-1 && y == m-1)return 1;
	if(x == n || y == m)return 0;
	if(grid[x][y] == '#')return 0;
	if(dp[x][y] != -1)return dp[x][y];
	return dp[x][y] = (rec(x+1, y) + rec(x, y+1) )%md;
}
int main(){
	for(long long  i = 0; i <= 1000; i++)
		for(long long  j = 0; j <= 1000; j++)
			dp[i][j] = -1;
	cin >> n >> m;
	for(long long  i = 0; i < n; i++)cin >> grid[i];
	cout <<rec(0,0);
}

Measured memory_bytes: 9216
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		no4();
	}

	static void no4() {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			long h = sc.nextLong();

			long[] a = new long[n];
			long[] b = new long[n];

			long maxhit = 0;
			for (int i = 0; i < n; i++) {
				a[i] = sc.nextLong();
				b[i] = sc.nextLong();

				if (a[i] > maxhit) {
					maxhit = a[i];
				}
			}

			List<Long> th = new ArrayList<Long>();
			for (int i = 0; i < n; i++) {
				if (b[i] > maxhit) {
					th.add(b[i]);
				}
			}
			Collections.sort(th);
			Collections.reverse(th);

			int i = 0;
			for (long t : th) {
				i++;
				h -= t;
				if (h <= 0) {
					System.out.println(i);
					return;
				}
			}
			long j = h / maxhit;
			i += j;
			if (h % maxhit != 0) {
				i++;
			}
			System.out.println(i);
		}
	}

	static void no3() {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			long y = sc.nextLong();
			long t = 0;
			for (int i = 0; i <= n; i++) {
				for (int j = 0; j <= n - i; j++) {
					t = 10000 * i + 5000 * j + 1000 * (n - i - j);
					if (t == y) {
						System.out.println(i + " " + j + " " + (n - i - j));
						return;
					}
				}
			}
			System.out.println("-1 -1 -1");
		}
	}

	static void no2() {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = 0;
			}

			int ans = 0;
			for (int i = 0; i < n; i++) {
				int flg = 0;
				int t = sc.nextInt();
				for (int j = 0; j < n; j++) {
					if (a[j] == t) {
						flg = 1;
						break;
					}
				}
				if (flg == 0) {
					ans++;
				}
				a[i] = t;
			}
			System.out.println(ans);
		}
	}

	static void no1() {
		try (Scanner sc = new Scanner(System.in)) {
			String str = sc.nextLine();
			System.out.println("2018/01/" + str.substring(8));
		}
	}
}


Measured memory_bytes: 92784
import { count } from 'console';

process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
let gInput = '';
process.stdin.on('data', (chunk) => (gInput += chunk));
process.stdin.on('end', () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {
  const n = Number(inputs[0].split(' ')[0]);
  const k = Number(inputs[0].split(' ')[1]);
  const pom = Math.pow(10, 9) + 7;

  let min = calc(k - 1, 0);
  let max = calc(n, n - (k - 1));
  let ans = max - min + 1;

  for (let i = k; i < n + 1; i++) {
    min += i;
    max += n - i;

    ans += max - min + 1;
  }

  console.log(ans % pom);
}

function calc(num: number, min: number): number {
  let sum = 0;
  while (num >= min) {
    sum += num;
    num--;
  }

  return sum;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		String s = fs.next();
		System.out.println(dfs(0,0,0,s));
	}
	
	long dfs(long leftNum, long sum, int depth, String s) {
		int nowCharNum = s.charAt(depth) - '0';
		if(depth == s.length() - 1) {
			return sum + leftNum*10 + nowCharNum;
		}
		// +を置かない
		return dfs(leftNum*10+nowCharNum,sum, depth+1, s) + dfs(0, sum + leftNum*10+nowCharNum, depth+1, s);
		
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 22868
N, M = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)
for g in G:
    print(len(g))

Measured memory_bytes: 9124
import java.util.Scanner;

public class Main {

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] L = new int[M];
        int[] R = new int[M];
        for (int i=0; i<M; i++) {
            L[i] = sc.nextInt();
            R[i] = sc.nextInt();
        }

        System.out.println(solve(N, M, L, R));
    }

    public static int solve(int N, int M, int[] L, int[] R) {
        int ansL = 1, ansR = N;

        for (int i=0; i<M; i++) {
            if (ansL < L[i]) {
                ansL = L[i];
            }
            if (ansR > R[i]) {
                ansR = R[i];
            }
        }


        if (ansR < ansL) return 0;

        return ansR-ansL+1;
    }
}

Measured memory_bytes: 83772
def gcd(x,y):
    if x < y:
        tmp = y
        y = x
        x = tmp

    while x % y != 0:
        r = x % y
        x = y
        y = r
    return y

n = int(input())
x = []
for i in range(n):
    a,b,c,d = map(int,input().split())
    x.append((a,b,c,d))

def f(a,b,c,d):
    if a < b:
        print("No")
    elif b > d:
        print("No")
    elif c >= b:
        print("Yes")
    else:
        g = gcd(b,d)
        if b-g+(a%g) > c:
            print("No")
        else:
            print("Yes")

for i in range(n):
    a,b,c,d = x[i][0],x[i][1],x[i][2],x[i][3]
    f(a,b,c,d)


Measured memory_bytes: 3064
n,k = map(int, input().split())
list_d = list(map(str, input().split()))

ans = n
ans_list = list(str(ans))
while True:
    ans_list = list(str(ans))
    for number in ans_list:
        if number in list_d:
            ans += 1
            break
    else:
        print(ans)
        break


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

typedef long long ll;
#define mod 1000000007

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

void solve() {
    float d, t, s;
    cin>>d>>t>>s;
    if(t < (d/s)){
        cout<<"No\n";
        return;
    }
    cout<<"Yes\n";

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    // pre();
    while (t--)
        solve();

    return 0;
}

Measured memory_bytes: 3740
N = int(input())
H = list(map(int, input().split()))
for i in range(N-1):
  if H[i] > H[i+1] + 1:
    print("No")
    exit()
  elif H[i] <= H[i+1]:
    if i > 0:
      if H[i-1] <= H[i]-1:
        H[i] -= 1        
  elif H[i] == H[i+1] + 1:
    H[i] -= 1
    if i > 0:
      if H[i-1] > H[i]:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#include<chrono>
#define ll long long
#define ld long double
#define eb emplace_back
#define pb push_back
#define mt make_tuple
#define tc  ll t; cin>>t; while(t--)
#define io ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define F first
#define S second
#define vi vector<ll>
#define pii pair<ll,ll>
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define vii vector<pair<ll,ll>>
ll gcd(ll n,ll m)
{
    if(n==0)
            return m;
    return gcd(m%n,n);
}
bool ifprime(ll n)
{
if(n==1)
return false;
    ll i;
for(i=2;i*i<=n;i++)
{
if(n%i==0)
return false;
 
}
return true;
}
void disp(vi v)
{
    for(auto u:v)
    cout<<u<<" ";
    cout<<"\n";
}
void remleadzero(vector<int> &v)
{
    vector<int> u;
    int i=0;
    while(v[i]==0)
        i++;
    while(i<v.size())
    {
        u.push_back(v[i]);
        i++;
    }
    v=u;
}
#define mod 1000000007LL
/*
void myscanf(long long *n)
{
    register long long c=getchar_unlocked();
    *n=0;
    for(;(c<48 ||c>57);c=getchar_unlocked())
        ;
    for(;(c>47 && c<58);c=getchar_unlocked())
    {
        *n=(*n<<1)+(*n<<3)+(c&15);
    }
 
}
void fastscan(long long &number)
{
    bool negative = false;
    register long long c;
 
    number = 0;
 
    c = getchar_unlocked();
    if (c=='-')
    {
 
        negative = true;
 
        c = getchar_unlocked();
    }
 
 
    for (; (c>47 && c<58); c=getchar_unlocked())
        number = number *10 + c - 48;
 
 
    if (negative)
        number *= -1;
}
*/
ll fast_expo(ll n,ll m, ll md)
{
    ll a=1;
    while(m>0)
    {
        if(m&1) a=(a*n)%md;
        n=(n*n)%md;
        m/=2;
    }
    return a%md;
}
long long sqroot(long long n){
    long double N = n;
    N = sqrtl(N);
    long long sq = N-2;
    sq = max(sq,0LL);
    while(sq*sq<n){
        sq++;
    } 
    if((sq*sq)==n)
        return sq;
    return -1;
}

int main()
{
	io;
    int n;
    cin>>n;
    vector<int> p(n),q(n);
    for(auto &u:p) cin>>u;
    for(auto &u:q) cin>>u;
    vector<int> v;
    for(int i=1;i<=n;i++)
        v.push_back(i);
    int a,b,i=0;

    do{
        if(v==p){
            a=i;
        }
        if(v==q) b=i;
        i++;
    }while(next_permutation(v.begin(),v.end()));
    cout<<abs(a-b);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	ll m = 1000000000;
	int x;
	rep(i, n) {
		cin >> a[i];
		if (abs(a[i]) < m) {
			m = abs(a[i]);
			x = i;
		}
	}
	int cnt = 0;
	bool frag;
	rep(i, n) {
		if (a[i] < 0) cnt++;
	}
	if (cnt % 2 == 0) frag = true;
	else frag = false;
	ll ans = 0;
	rep(i, n) ans += abs(a[i]);
	if (frag) {
		cout << ans << endl;
		return 0;
	}
	else {
		cout << ans - 2 * abs(a[x]) << endl;
		return 0;
	}
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
int dh[4] = {-1, 0, 0, 1};
int dw[4] = {0, -1, 1, 0}; 
using P = pair<int, int>;
const double pi = acos(-1.0);

using Graph = vector<vector<ll>>;

int main(){
  string s,t;
  cin>>s>>t;
  vector<int>mat(s.size());
  rep(i,s.size()-t.size()+1){
    rep(j,t.size()){
      if(s[i+j]==t[j])mat[i]++;
    }
  }
  sort(all(mat));
  reverse(all(mat));
  cout<<t.size()-mat[0]<<endl;
    
    
  return 0;
}


Measured memory_bytes: 3636
n,m = map(int, input().split())
 
"""
考え方
端から端まで、で一致するパターンがないか全探索
"""
 
## 1.INPUTの取得
a = list(input() for i in range(n))
b = list(input() for i in range(m))
 
## 2.全探索
ans = 'No'
for i in range(n-m+1): ## aの行
  for j in range(n-m+1): ## aの列 
    ## 2-1.m,nの一番上の行を比較
    if b[0] == a[i][j:j+m]:
      ## 下の行も比較
      for x in range(1,m):
        if b[x] != a[i+x][j:j+m]:
          break
      else:
        ans = 'Yes'
  
 
print(ans)

Measured memory_bytes: 3064
import math
a, b = list(map(int, input().split()))
for i in range(1, 1250):
    p8 = math.floor(i * 0.08)
    p10 = math.floor(i * 0.10)
    if p8 == a and p10 == b:
        print(i)
        exit()
print(-1)

Measured memory_bytes: 63884
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

const int max_n = 100000+19;

int N,q;
typedef struct M {
    int to;
    int color;
    int dist;
}Node;

vector<Node> G[max_n];
vector<Node> Q[max_n];
int par[max_n][20];
int ans[max_n];
int height[max_n];
int dist[max_n];
int num[max_n];
int sum[max_n];

void get(int p) {
    height[p] = height[par[p][0]]+1;
    for(auto u: G[p]) {
        if(u.to != par[p][0]) {
            par[u.to][0] = p;
            dist[u.to] = dist[p]+u.dist;
            get(u.to);
        }
    }

    return;
}

int lca(int x,int y) {
    if(height[x] > height[y])
        swap(x,y);
    int t = height[y] - height[x];
    for(int i = 0;i < 18;i++) {
        if(t&(1<<i))
            y = par[y][i];
    }
    if(x == y)
        return x;
    for(int i = 17;i >= 0;i--) {
        if(par[x][i] != par[y][i]) {
            x = par[x][i];
            y = par[y][i];
        }
    }

    return par[x][0];
}

void dfs(int p) {
    for(auto u: Q[p]) {
        if(u.to > 0) { //each node
            ans[u.to] += dist[p]+num[u.color]*u.dist-sum[u.color];
        } else { //ancestor
            ans[-u.to] -= 2*(dist[p]+num[u.color]*u.dist-sum[u.color]);
        }
    }

    for(auto u: G[p]) {
        if(u.to == par[p][0])
            continue;
        num[u.color]++;
        sum[u.color] += u.dist;
        dfs(u.to);
        num[u.color]--;
        sum[u.color] -= u.dist;
    }

    return;
}

int main(void) {
    cin>>N>>q;
    for(int i = 1;i < N;i++) {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        G[a].push_back({b,c,d});
        G[b].push_back({a,c,d});
    }

    get(1);
    for(int i = 1;i <= 18;i++) {
        for(int v = 1;v <= N;v++) {
            par[v][i] = par[par[v][i-1]][i-1];
        }
    }

    for(int i = 1;i <= q;i++) {
        int x,y,u,v;
        cin>>x>>y>>u>>v;
        Q[u].push_back({i,x, y});
        Q[v].push_back({i, x, y});
        Q[lca(u,v)].push_back({-i, x, y});
    }

    dfs(1);
    for(int i = 1;i <= q;i++) {
        cout<<ans[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 28600
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
bool vis[BITLE(19)];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(BITLE(n));
  for(auto &a:A)cin>>a;
  sort(ALL(A),greater<ll>());
  priority_queue<ll> slime[2];
  slime[0].push(A[0]);
  bool ans=true;
  vis[0]=true;
  for(int i=0;i<n;i++){
    ll num=BITLE(i);
    ll cnt=0;
    ll now=slime[i%2].top();
    for(int j=0;j<BITLE(n);j++){
      if(vis[j]||now<=A[j])continue;
      slime[i%2].pop();
      slime[(i+1)%2].push(A[j]);
      slime[(i+1)%2].push(now);
      vis[j]=true;
      if(!slime[i%2].empty())
	now=slime[i%2].top();
      else break;
    }
    if(!slime[i%2].empty()){cout<<"No"<<endl;return 0;}
  }
  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

int  main(){
  int n;
  while(1){
  int count=0;
  cin >> n;
  if(n==0)break;
  int total = 1000-n;
  if(total >= 500){
  count+=total/500;
  total%=500;
  }

  if(total >= 100){
  count+=total/100;
  total%=100;
  }
  
  if(total >= 50){
  count+=total/50;
  total%=50;
  }

  if(total >= 10){
  count+=total/10;
  total%=10;
  }

  if(total >=  5){
  count+=total/5;
  total%=5;
  }

  if(total >=  1)
  count+=total/1;

  cout << count << endl;

  }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<map>
#include<string>

int n, k;
std::string a[10];
std::map<std::string, int> m;

void rec(int i, int S, std::string str){//i個選んで今strという文字列ができている(Sは選んだ集合)
	if(i == k){
		m[str]++;
		return;
	}

	for(int j=0;j<n;j++){
		if(!(S >> j & 1)){//使っていない
			rec(i + 1, S | (1 << j), str + a[j]);
		}
	}
}

int main(){
	while(std::cin >> n >> k, n){
		m.clear();

		for(int i=0;i<n;i++){
			int j;
			std::cin >> j;
			a[i] = std::to_string(j);
		}

		rec(0, 0, "");

		std::cout << m.size() << std::endl;
	}
}

Measured memory_bytes: 1532
#include <stdio.h>
#include <string.h>
#define INF 0x1fffffff
#define MAX_STATION 500
#define START 0
#define ON_2D 1
#define GOAL 2


int stat_cnt = 0;
char reg_name[MAX_STATION][21];

// 駅の登録情報の初期化関数
void init(){
	stat_cnt = 0;
}


// 登録されている駅の番号を返す関数、なければ、-1を返す。
int srch_stat(char *name){
	int i;
	for(i = 0;i < stat_cnt;i++){
		if(!strcmp(reg_name[i],name)){
			return i;
		}
	}
	return -1;
}


// 駅名と駅番号を登録する関数
int reg_stat(char *name){
	strcpy(reg_name[stat_cnt],name);
	return stat_cnt++;
}


int main(void){
	int n, m, d, t, i, j, k, dist[MAX_STATION][MAX_STATION];
	char s[21], p[21], g[21], a[21], b[21];

	while(1){
		scanf("%d%d",&n,&m);
		if(n == 0 && m == 0){
			break;
		}
		init();
		scanf("%s%s%s",&s,&p,&g);
		reg_stat(s);
		reg_stat(p);
		reg_stat(g);
		


		// コストの初期化
		for(i = 0;i < n;i++){
			for(j = 0;j < n;j++){
				dist[i][j] = INF;
			}
			dist[i][i]=0;
		}





		for(i = 0;i < m;i++){
			int stat_num;
			int stat_a_num, stat_b_num;
			scanf("%s%s",&a,&b);
			// 駅名の検索
			if((stat_num = srch_stat(a)) == -1){
				stat_a_num = reg_stat(a);
			}else{
				stat_a_num = stat_num;
			}
			// 駅名の検索
			if((stat_num = srch_stat(b)) == -1){
				stat_b_num = reg_stat(b);
			}else{
				stat_b_num = stat_num;
			}
			scanf("%d%d",&d,&t);
			dist[stat_a_num][stat_b_num] = d / 40 + t;
			dist[stat_b_num][stat_a_num] = d / 40 + t;
		}



		for(k = 0;k < n;k++){
			for(i = 0;i < n;i++){
				for(j = 0;j < n;j++){
					if(dist[i][j] > dist[i][k] + dist[k][j]){
						dist[i][j] = dist[i][k] + dist[k][j];
					}
				}
			}
		}
		printf("%d\n",dist[START][ON_2D] + dist[ON_2D][GOAL]);


	}

	return 0;
}

Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	ll n, k;
	cin >> n >> k;
	/*if (k == 0) {
		ll ans = n * n;
		cout << ans << endl;
	}
	*/
	ll ans = 0;
	for (ll i = k + 1; i <= n; i++) {
		ll cycle = n / i;
		ans += cycle * max((ll)0, i - k);
		ll rem = max((ll)0, n % i - k + 1);
		ans += rem;
		if (k == 0) ans--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    ll H, W;
    cin >> H >> W;
    bool bo[H][W], bored[H][W], boblue[H][W];
    for (int i = 0; i < H; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < W; j++) {
            if (s[j] == '#') {
                bo[i][j] = true;
            } else {
                bo[i][j] = false;
            }
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (i == 0) {
                bored[i][j] = true;
                boblue[i][j] = false;
            } else if (i == H - 1) {
                bored[i][j] = false;
                boblue[i][j] = true;
            } else if (j == 0) {
                bored[i][j] = true;
                boblue[i][j] = false;
            } else if (j == W - 1) {
                bored[i][j] = false;
                boblue[i][j] = true;
            } else if (i % 2 == 0) {
                bored[i][j] = true;
                boblue[i][j] = false;
            } else {
                bored[i][j] = false;
                boblue[i][j] = true;
            }
        }
    }
    for (int i = 1; i < H - 1; i++) {
        for (int j = 1; j < W - 1; j++) {
            if (bo[i][j]) {
                if (i % 2 == 0) {
                    boblue[i][j] = true;
                } else {
                    bored[i][j] = true;
                }
            }
        }
    }
    for (int i = 0; i < H; i++) {
        string s = "";
        for (int j = 0; j < W; j++) {
            if (bored[i][j]) {
                s.push_back('#');
            } else {
                s.push_back('.');
            }
        }
        cout << s << endl;
    }
    cout << endl;
    for (int i = 0; i < H; i++) {
        string s = "";
        for (int j = 0; j < W; j++) {
            if (boblue[i][j]) {
                s.push_back('#');
            } else {
                s.push_back('.');
            }
        }
        cout << s << endl;
    }
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int N, M, X, A[100], cnt = 0;
    cin >> N >> M >> X;
    for (int i = 0 ; i < M; i++) {
        cin >> A[i];
        if (A[i] < X) cnt++;
    }
    cout << min(cnt, M - cnt) << endl;
}

Measured memory_bytes: 256