akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

int main() {
  	int N, M, x;
    cin >> N >> M;
    vector<int> A(N);
    for (int i=0; i<2*M; i++){
    	cin >> x;
    	A[x-1]++;
    }
    for (int i=0; i<N; i++){
    	cout << A[i] << endl;
    }
}

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

int main(){
    int N, K;
    int count = 0;
    cin >> N >> K;
    for(int i = 1;i <= N;i += 2){
        count++;
    }
    /*count = N / 2;
  cout << count << endl;
    if(N % 2 == 1){
        count++;
    }
    */
 // cout << count << endl;
    if(count >= K){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n;
	int v[100000];
	int v1[100000] = {0};
	int pv1 = 0;
	int pv2 = 0;
	int pv2_2 = 0;
	int pv1_2 = 0;
	int v2[100000] = {0};
	
	scanf("%d", &n);
	
	for (int i=0; i<n; i++) {
		scanf("%d", &v[i]);
		if (i % 2 == 0) {
			v2[v[i]]++;
			if (v2[pv2] < v2[v[i]]) {
				pv2_2 = pv2;
				pv2 = v[i];
			} else {
				if (v2[pv2_2] < v2[v[i]] && v[i] != pv2)
					pv2_2 = v[i];
			}
		} else {
			v1[v[i]]++;
			if (v1[pv1] < v1[v[i]]) {
				pv1_2 = pv1;
				pv1 = v[i];
			} else {
				if (v1[pv1_2] < v1[v[i]] && v[i] != pv1)
					pv1_2 = v[i];
			}
		}
	}
	
	if (pv1 == pv2) {
		if (v1[pv1_2] > v2[pv2_2])
			pv1 = pv1_2;
		else
			pv2 = pv2_2;
	}
	
	int cnt = 0;
	for (int i=0; i<n; i++) {
		if (i % 2 == 0) {
			if (v[i] != pv2)cnt++;
		} else {
			if (v[i] != pv1)cnt++;
		}
	}
	
	printf("%d", cnt);
	
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    V<int> x(n);
    V<int> ans(n * n, -1);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        ans[--x[i]] = i + 1;
    }

    V<int> ord(n); iota(ALL(ord), 0);
    sort(ALL(ord), [&](int i, int j) {
        return x[i] < x[j];
    });

    int tmpi = 0;
    for (int i: ord) {
        for (int j = 0; j < i; j++) {
            while (ans[tmpi] > -1) tmpi++;
            if (tmpi > x[i]) {
                cout << "No\n";
                return 0;
            }
            ans[tmpi] = i + 1;
        }
    }

    tmpi = n * n - 1;
    reverse(ALL(ord));
    for (int i: ord) {
        for (int j = 0; j < n - i - 1; j++) {
            while (ans[tmpi] > -1) tmpi--;
            if (tmpi < x[i]) {
                cout << "No\n";
                return 0;
            }
            ans[tmpi] = i + 1;
        }
    }

    cout << "Yes\n";
    for (int i = 0; i < n * n; i++) cout << ans[i] << (i == n * n - 1 ? '\n' : ' ');
    return 0;
}


Measured memory_bytes: 2176
#pragma GCC optimize("Ofast")
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>

using namespace std;

#define ll long long
#define ull unsigned long long
const ll MOD = 1000000007;
#define rep(i,n) for (int i = 0; i < (n); ++i)

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

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

	map<ll, ll> m;
	bool ok = true;
	for (int ii = 0; ii < N; ++ii){
		ll A;
		cin >> A;
		if (m[A]){
			ok = false;
			break;
		}
		m[A] = 1;
	}

	if (ok){
	cout << "YES" << "\n";
	} else {
			cout << "NO" << "\n";
	}


	return 0;
}


Measured memory_bytes: 16124
// #include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

#define rep(i,n) for (int i = 0; i < n; ++i)
#define repr(i,n) for (int i = n; i > 0; --i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MAX = 100;
const int INF = (1<<12);

int main() {
  int a, b, M;
  cin >> a >> b >> M;
  vector<int> A(a), B(b), cA(a), cB(b);
  rep(i,a) cin >> A[i];
  rep(i,b) cin >> B[i]; 
  cA = A;
  cB = B;

  sort(cA.begin(), cA.end());
  sort(cB.begin(), cB.end());
  int cost = cA[0] + cB[0];

  rep(i,M){
    int x,y,c;
    cin >> x >> y >> c;
    cost = min(cost, A[x-1] + B[y-1] - c);
  }
  cout << cost << endl;
  return 0;
}

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

using namespace std;

using LL = long long;
const LL INFLL = 999999999999999LL;
 

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

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

	Vll a(n);
	LL total=0;
	for(int i=0; i<n; i++){
		cin>>a[i];
		total+=a[i];
	}

	LL half = total/2;
	LL b1=0;
	LL b2=total;
	LL ans=INFLL;
	for(int i=0; i<n; i++){
		b1 += a[i];
		b2 -= a[i];
		ans = min(ans,abs(half-b1)+abs(half-b2));
	}

	cout<<ans<<endl;	
	return 0;
}

Measured memory_bytes: 1792
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n, m = LI()
G = [[] for _ in range(n)]
for _ in range(m):
    l, r, d = LI()
    G[l - 1] += [(r - 1, d)]
    G[r - 1] += [(l - 1, -d)]

A = [0] * n
visited = [0] * n
for i in range(n):
    if visited[i]:
        continue
    visited[i] = 1
    A[i] = 0
    q = [i]
    while q:
        u = q.pop()
        for v, di in G[u]:
            if visited[v]:
                if A[v] != A[u] + di:
                    print("No")
                    exit()
            else:
                A[v] = A[u] + di
                visited[v] = 1
                q += [v]

print("Yes")


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

// macros
#define REP(I, N) for (std::decay_t<decltype(N)> I = 0, I##_LEN = (N); I < I##_LEN; ++I)
#define RANGE(I, INIT, N) for (auto I = INIT, I##_LEN = (N); I < I##_LEN; ++I)

// utilities
using llong = long long;
template<class T> bool chmax(T& a, T b) { return a < b ? a = b, true : false; }
template<class T> bool chmin(T& a, T b) { return a > b ? a = b, true : false; }

llong dp[60][60][2600] {};

void solve() {
    int N, A;
    cin >> N >> A;

    int x[51] {};
    REP (i, N) {
        cin >> x[i];
    }

    int y = A; // 全てのカードとAの最大値
    REP (i, N) {
        chmax(y, x[i]);
    }

    // i番目までのカードをj枚使って合計をkにする
    dp[0][0][0] = 1;

    REP (i, N) {
        REP (j, N+1) {
            REP (k, N*y+1) {
                if (x[i] > k) {
                    dp[i+1][j][k] = dp[i][j][k];    // ひとつ前の数値を引き継ぐだけ
                } else if (j >= 1) {
                    dp[i+1][j][k] = dp[i][j][k] + dp[i][j-1][k-x[i]];   // k - x[i] >= 0
                }
            }
        }
    }

    llong ans = 0;
    RANGE (i, 1, N+1) {
        ans += dp[N][i][i*A];
    }
    cout << ans << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // COMinit();
    solve();
}



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

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

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

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll a[100010];
    rep(i, n) cin >> a[i];
    int q;
    sort(a, a + n);
    rep(i, n) if (a[i] >= 0) {
        q = i;
        break;
    }


    vector<pll> ans;
    if (a[0] >= 0) {

        REP(i, 1, n - 1) {
            ans.push_back(MP(a[0], a[i]));
            a[0] -= a[i];
        }
        ans.push_back(MP(a[n - 1], a[0]));
        a[n - 1] -= a[0];
        cout << a[n - 1] << endl;
    } else if (a[n - 1] < 0) {

        rep(i, n - 1) {
            ans.push_back(MP(a[n - 1], a[i]));
            a[n - 1] -= a[i];
        }
        cout << a[n - 1] << endl;

    } else {

        REP(i, q, n - 1) {
            ans.push_back(MP(a[0], a[i]));
            a[0] -= a[i];
        }

        rep(i, q) {
            ans.push_back(MP(a[n - 1], a[i]));
            a[n - 1] -= a[i];
        }

        cout << a[n - 1] << endl;
    }


    for (auto p : ans) {
        cout << p.first << " " << p.second << endl;
    }

    return 0;
}



Measured memory_bytes: 4336
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
	int m, n, a[100000], ans = 0, tans = 0;
	cin >> m >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	if (m == 2) {
		for (int x = 0; x < n; x++) {
			if (x % 2 == 0) {
				if (a[x] == 1) {
					ans++;
				}
			}
			else {
				if (a[x] == 2) {
					ans++;
				}
			}
		}
		for (int y = 0; y < n; y++) {
			if (y % 2 == 0) {
				if (a[y] == 2) {
					tans++;
				}
			}
			else {
				if (a[y] == 1) {
					tans++;
				}
			}
		}
		if (ans > tans) {
			cout << tans << endl;
			return 0;
		}
		else {
			cout << ans << endl;
			return 0;
		}
	}
	for (int j = 1; j < n; j++) {
		if (a[j] == a[j - 1]) {
			ans++;
			a[j]=0;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3476
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ff first
#define ss second
#define endl '\n'
#define MAX INT_MAX
#define MIN INT_MIN
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define pb push_back
#define sz(a) (int)((a).size())
#define all(a) a.begin(),a.end()
#define loopf(i,a,b) for(int i = a;i < b;i++)
#define loopb(i,a,b) for(int i = a;i >= b;i--)
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;



int32_t main()
{
    fast

   int test=1;
   // cin>>test;
  
  while(test--)
  {
    int k;
    string s;
    cin>>k>>s;

    if(s.size()<=k)cout<<s;
    else
    {
        for(int i=0;i<k;i++)cout<<s[i];
            cout<<"...";
    }


    // while loop ending
   }
  

return 0;
}

Measured memory_bytes: 3652
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 100005
int n;
struct node
{
	int x,t;
}a[N];
bool cmp(node a,node b)
{
	return a.x<b.x;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i].x),a[i].t=i;
	sort(a+1,a+n+1,cmp);
	printf("%d",a[1].t);
	for(int i=2;i<=n;i++)
		printf(" %d",a[i].t);
}

Measured memory_bytes: 1536
a, b = [int(x) for x in input().split()]
 
if (b < a):
    temp = b
    b = a
    a = temp
 
 
x = 1
while True:
    if (int(x*0.08) == a and int(x*0.1) == b):
        print(x)
        break
    else:
        if (x > 1500):
            print(-1)
            break
        else:
            x += 1

Measured memory_bytes: 3188
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

D = [1] * (N + 1)
for i in range(1, N):
  D[i] = D[i - 1] * i

def nasu(L):
  ans = 1
  K = [0] * (N + 1)
  for i in range(N):
    t = i + 1
    k = 0
    for j in range(1, N + 1):
      if L[i] == j: break
      if K[j] == 0:
        k += 1
    K[L[i]] = 1
    ans += k * D[N - t]
  return ans

print(abs(nasu(P) - nasu(Q)))


Measured memory_bytes: 3064
S = input()
ans = 'Yes'
if len(S)%2:
    ans = 'No'
else:
    for i, c in enumerate(S):
        if i%2 and c!='i':
            ans = 'No'
            break
        elif i%2 == 0 and c!='h':
            ans = 'No'
            break
print(ans)


Measured memory_bytes: 2940
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

#define pb push_back
#define fi first
#define se second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int inf = 1e9;

template <class T>
istream& operator>>(istream& ss, vector<T>& v) {
	for (int i = 0; i < v.size(); i++) ss >> v[i];
	return ss;
}

template <class T> 
ostream& operator<<(ostream& ss, const vector<T>& v) {
	for (int i = 0; i < v.size(); i++) ss << v[i] << ' ';
	return ss;
}

void solve(){
	ll x;
	cin >> x;
	ll n = 100;
	int cnt = 0;
	while (n < x) {
		n += n / 100;
		cnt++;
	}
	cout << cnt;
}

int main(){
	int t = 1;
	//cin >> t;
	for(int i = 1; i <= t; i++){
		solve();
	}
}

Measured memory_bytes: 3604
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        input_inner!{$s, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($exp_input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                let start = std::time::Instant::now();
                let input = solve($exp_input);
                let end = start.elapsed();
                assert_eq!(input, $output, "{}.{:03}", end.as_secs(), end.subsec_millis());
                assert!(end.as_secs() <= 2, "expected_sec: {}sec, actual_sec: {}sec", 2, end.as_secs());
                assert!(end.as_secs() <= 1, "expected_sec: {}sec, actual_sec: {}sec", 1, end.as_secs());
                assert!(end.subsec_millis() <= 10, "expected_ms: {}ms, actual_ms: {}ms", 10, end.subsec_millis());
                assert!(end.subsec_millis() <= 2, "expected_ms: {}ms, actual_ms: {}ms", 2, end.subsec_millis());
            )*
        }
    };
}

test! {

r#"2
1 4"# => r#"5"#,

r#"7
14 14 2 13 56 2 37"# => r#"2354"#,
}

const INF:isize = 1 << 60;

fn solve(src: &str) -> String {
    let mut src_iter = src.split_whitespace();
    input! {
        source = src_iter,
        n: usize,
        x: [isize; n],
    }
    let mut ans = INF;

    for i in 1..101 {
        let mut sum:isize = 0;
        for j in 0..n {
            let t = x[j] - i;
            sum = sum + t * t;
        }
        ans = std::cmp::min(ans, sum);
    }

    ans.to_string()
}

Measured memory_bytes: 4352
n,x,y = list(map(int, input().split()))
ans = [0 for i in range(n)]
for i in range(1,n):
    for j in range(i+1,n+1):
        t = min(j-i, abs(x-i)+abs(y-j)+1)
        ans[t]+=1

for k in range(1,n):
    print(ans[k])

Measured memory_bytes: 46556
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n;ll k;cin>>n>>k;
	vector<P> p = {};
	rep(i, n){
		int a, b;
		cin>>a>>b;
		p.push_back(P(a, b));
	}
	sort(all(p));
	rep(i, n){
		if(k-p[i].second<=0){
			cout << p[i].first<<endl;
			return 0;
		}
		k -= p[i].second;
	}
	return 0;
}


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

int main()
{
    string s;
    cin >> s;
    string ans = "Yes";
    for(int i=0; i<int(s.length()); i++){
        if(i%2==0){
            if(s[i]=='L'){
                ans = "No";
            }
        }else{
            if(s[i]=='R'){
                ans = "No";
            }
        }
    }
    cout << ans << endl;
}

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

#define reint register int
#define coint const int

using namespace std;

typedef long long ll;

int main(void) {
    ll l, r;
    scanf("%lld%lld", &l, &r);
    if (r - l <= 3000) {
        ll ans = 2019;
        for (reint i = l; i <= r; ++i)
            for (reint j = i + 1; j <= r; ++j)
                ans = min(ans, (ll)i * j % 2019);
        printf("%lld\n", ans);
    } else printf("0\n");
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <set>
#include <string>
#include <math.h>
#include <map>
#include <climits>
#include <iomanip>


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

#define ll long long

using namespace std;

void A();
void B();
void C();
void D();
void E();
void F();

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

	A();


}

void A() {
	string s;
	cin >> s;

	cout << (s == "ABC" ? "ARC" : "ABC") << '\n';

}

void B() {
	int T;
	cin >> T;
	for (int t = 1; t <= T; t++) {

		int N;
		cin >> N;


		int result = 0;

		cout << "Case #" << t << ": ";

		cout << result << endl;

	}
}

void C() {
	int T;
	cin >> T;
	for (int t = 1; t <= T; t++) {

		int N;
		cin >> N;


		int result = 0;

		cout << "Case #" << t << ": ";

		cout << result << endl;

	}
}

void D() {
	int T;
	cin >> T;
	for (int t = 1; t <= T; t++) {

		int N;
		cin >> N;


		int result = 0;

		cout << "Case #" << t << ": ";

		cout << result << endl;

	}
}

void E() {
	int T;
	cin >> T;
	for (int t = 1; t <= T; t++) {

		int N;
		cin >> N;


		int result = 0;

		cout << "Case #" << t << ": ";

		cout << result << endl;

	}
}

void F() {
	int T;
	cin >> T;
	for (int t = 1; t <= T; t++) {

		int N;
		cin >> N;


		int result = 0;

		cout << "Case #" << t << ": ";

		cout << result << endl;

	}
}



Measured memory_bytes: 3688
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();    
        int N, K;
        {int[] a = r.ii(); N = a[0]; K = a[1];}
        int[] l = r.ii();
        Arrays.sort(l);
        int ans = 0;
        for(int i = N-1; i > N-1-K; i--)
            ans += l[i];
        println(ans);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 23124
#[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" ) } ; }
#[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 ! 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 ) * } } ; }

fn main() {
    input! {
        x: i32,
    }
    let a = x / 100;
    let mut b = (x % 100) / 5;
    if (x % 100) % 5 != 0 {
        b += 1;
    }
    if a >= b {
        println!("1");
    } else {
        println!("0");
    }
}


Measured memory_bytes: 2096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int INF = 1e9+10;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    vector<ll> cont(n-k+1);
    ll sum = 0;
    for(int i = 0; i < k; i++) sum += a[i];
    cont[0] = sum;
    for(int i = 1; i < n-k+1; i++)
    {
        sum -= a[i-1];
        sum += a[i+k-1];
        cont[i] = sum;
    }
    ll arb = 0;
    for(int i = k; i < n; i++)
    {
        if(a[i] > 0) arb += a[i];
    }
    ll ans = 0;
    for(int i = 0; i < n-k+1; i++)
    {
        ll cand = arb;
        if(cont[i] > 0) cand += cont[i];
        ans = max(ans, cand);
        if(a[i] > 0) arb += a[i];
        if(a[i+k] > 0) arb -= a[i+k];
    }
    cout << ans << endl;
}


Measured memory_bytes: 4808
from collections import deque
h, w = map(int, input().split())
A = [input() for _ in range(h)]
dist = [[-1]*w for _ in range(h)]
di = [1, 0, -1, 0]
dj = [0, 1, 0, -1]
que = deque()
for i in range(h):
  for j in range(w):
    if A[i][j] == "#":
      que.append((i, j))
      dist[i][j] = 0
ans = 0
while que:
  y, x = que.popleft()
  for dy, dx in zip(di, dj):
    ny, nx = y+dy, x+dx
    if ny < 0 or ny >= h or nx < 0 or nx >= w:
      continue
    if dist[ny][nx] != -1:
      continue
    dist[ny][nx] = dist[y][x] + 1
    ans = max(ans, dist[ny][nx])
    que.append((ny, nx))
print(ans)


Measured memory_bytes: 87644
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 2010

typedef long double Real;

Real P[SIZE][SIZE];

vector<Real> calc(int N, int M, int k, int *p) {
  Real first = 1, second = 0, third = 0, last = 1;

  for (int i=1; i<N; i++) {
    ll q = ((ll)p[0] * k + p[i] - 1) / p[i];
    double r = M >= q ? P[M][q] : 0;

    debug(M);
    debug(q);
    debug(r);

    Real nFir = first * (1 - r);
    Real nSec = first * r + second * (1 - r);
    Real nThi = second * r + third * (1 - r);
    Real nLast = last * r;

    first = nFir;
    second = nSec;
    third = nThi;
    last = nLast;
  }

  return vector<Real>({first + second + third, last});
}

int main(){
  int N, M, a[3][SIZE];

  cin >> N >> M;

  P[0][0] = 1;
  for (int i=0; i<=M; i++) {
    for (int j=0; j<=i; j++) {
      P[i+1][j] = P[i][j] * (i+1) * 2 / 3 / (i+1-j);
      if (i > j) P[i][j+1] = P[i][j] * (i - j) / 2 / (j+1);
    }

    for (int j=i; j>0; j--)
      P[i][j-1] += P[i][j];
  }

  for (int i=0; i<N; i++) {
    for (int j=0; j<3; j++) {
      cin >> a[j][i];
    }
  }

  vector<Real> res[3][SIZE];

  for (int i=0; i<=M; i++) {
    res[0][i] = calc(N, M, i, a[0]);
    res[1][i] = calc(N, M, i, a[1]);
    res[2][i] = calc(N, M, i, a[2]);
  }

  double ans = -1e9;

  for (int i=0; i<=M; i++) {
    for (int j=0; i+j<=M; j++) {
      Real sum = 0;
      int k = M - i - j;
      sum += res[0][i][0] * 5 + res[0][i][1] * -1;
      sum += res[1][j][0] * 3 + res[1][j][1] * -1;
      sum += res[2][k][0] * 2 + res[2][k][1] * -1;

      ans = max(ans, (double)sum);
    }
  }

  printf("%.10lf\n", ans);

  return 0;
}



Measured memory_bytes: 42436
a,b,c,d = map(int, input().split(' '))

t,tmod = divmod(a, d)
a,amod = divmod(c , b)

if tmod >0:
  t = t+1
if amod >0:
  a = a+1

if a > t:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 8988
#include <iostream>
using namespace std;
int main(){
	int a,b;
	cin >> a >> b;
	if(a<b){
		cout<<"a"<<" < "<<"b"<<endl;
	}else if(a>b){
		cout<<"a"<<" > "<<"b"<<endl;
	}
	else{
		cout<<"a"<<" == "<<"b"<<endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;

#define pb push_back
#define ff first
#define ss second
#define SIZE 1000001
#define INF int(2e9 + 9)
#define BIG_INF ll(4e18 + 9)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define _sz(v) int((v).size())
#define sqr(x) (x) * (x)
#define cube(x) (x) * (x) * (x)

//#pragma GCC optimize("Ofast")

ll binpow(ll a, ll b, ll mod = BIG_INF)
{
    ll res = 1;
    while(b)
    {
        if(b & 1)
            res *= a;
        a *= a;
        b >>= 1;
        a %= mod;
        res %= mod;
    }
    res %= mod;
    return res;
}




int T = 1, n, k, a[SIZE], x;
string s;

bool used[SIZE];




void solve()
{
    cin >> n >> x;
    if(x >= n)
    {
        cout << "unsafe";
    }else cout << "safe";

}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

//    cin >> T;

    while(T--)
    {
        solve();
    }




    return 0;
}


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

int main(){
  int N; cin >> N;
  int length=0;
  for(int i=0; i<N; i++){
    int tmp; cin >> tmp;
    if(length+1==tmp) length++;
  }
  cout << (length==0?-1:N-length) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=998244353;
const int inf=0x3f3f3f3f;
ll a[200005];
int main()
{
    ios::sync_with_stdio(false);
    ll n,x;cin>>n>>x;
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(i>0)
        {
            if(a[i]+a[i-1]>x) sum+=(a[i]+a[i-1]-x),a[i]-=(a[i]+a[i-1]-x);
            if(a[i]<0) a[i]=0;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1024
#https://wakabame.hatenablog.com/entry/2020/05/24/031143

#from collections import defaultdict
#from pprint import pprint
#from collections import deque
#from collections import Counter
#from copy import deepcopy
#from itertools
#import sys 
#sys.setrecursionlimit(N) #N回まで再起を許可する。
#import numpy as np
#import math
# = map(int,input().split())

# = list(map(int,input().split()))

# = [list(map(int,input().split())) for _ in range(XXXX)]

def func(i):
    if i == 0:
        return 0
    elif i == 1:
        return d
    elif i in memo:
        return memo[i]
    else:
        min_val = int(min(
            d*i,
            d*abs(i-i//2*2) + a + func(i//2),
            d*abs(i-(i+1)//2*2) + a + func((i+1)//2),
            d*abs(i-i//3*3) + b + func(i//3),
            d*abs(i-(i+2)//3*3) + b + func((i+2)//3),
            d*abs(i-i//5*5) + c + func(i//5),
            d*abs(i-(i+4)//5*5) + c + func((i+4)//5)
        ))

    memo[i] = min_val
    return min_val



t = int(input())

nabcd = [list(map(int,input().split())) for _ in range(t)]


for i in range(t):
    n = nabcd[i][0]
    a = nabcd[i][1]
    b = nabcd[i][2]
    c = nabcd[i][3]
    d = nabcd[i][4]

    memo = {}


    print(func(n))
    #print(memo)


Measured memory_bytes: 11020
#include <stdio.h>

int main(void)
{
    int a, b, i, flag;
    char s[12];
    scanf("%d%d", &a, &b);
    scanf("%s", s);
    flag = 0;
    for (i=0; i<a; i++)
    {
        if (s[i] == '-') {
            flag = 1;
            break;
        }
    }
    for (i=a+1; i<a+b+1; i++)
    {
        if (s[i] == '-') {
            flag = 1;
            break;
        }
    }
    if (s[a] != '-') {
        flag = 1;
    }
    if (flag) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }
    return 0;
}


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

# from numba import njit

# input = stdin.readline

# @njit
def solve(n,l):
  return (n - 1)//min(l) + 5



def main():
  N = int(input())
  l = [int(input()) for _ in range(5)]
  print(solve(N,l))
  return

if __name__ == '__main__':
  main()


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

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; }
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using pint = pair<int, int>; 
using pll  = pair<ll, ll>;
using vint = vector<int>; 
using vll  = vector<ll>;
using vstr = vector<string>;

//　定数, 変数 *********************************************
const ll MOD=1e9+7;
const ll INF=1ll<<60;

int X, N;

// *********************************************************
int main(){

    cin >> X >> N;


    int pi;
    vint vi;
    rep(i,N){
        cin >> pi;
        vi.emplace_back(pi);
    }

    if(N==0){
        cout << X;
        return 0;
    }

    for(int i=0; ;++i){
        auto itr = find(vi.begin(), vi.end(), X-i);
        if(itr != vi.end()){
            auto itr2 = find(vi.begin(), vi.end(), X+i);
            if(itr2 != vi.end()){

            }else{
                cout << X+i;
                return 0;
            }
        } else{
            cout << X-i;
            return 0;
        }
    }
    
    

    return 0;
}

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

int main(){
    std::string s;
    std::cin >> s;
    
    std::string ans="Yes";
    
    for(int i=0;i<s.size();++i){
        if(i%2==0){
            if(s[i]!='R'&&s[i]!='U'&&s[i]!='D'){
                 ans="No";
                 break;
             }
        } else if (i%2==1) {
            if(s[i]!='L'&&s[i]!='U'&&s[i]!='D'){
                ans="No";
                break;
            }
        }
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct ab
{
    int v,i;
} mp1[500005],mp2[500005];
int cmp(ab x,ab y)
{
    return x.v>y.v;
}
int main()
{
    int n,x;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        if(i&1) mp1[x].v++;
        else mp2[x].v++;
    }
    for(int i=1;i<=100000;i++)
    {
        mp1[i].i=mp2[i].i=i;
    }
    sort(mp1+1,mp1+100001,cmp);
    sort(mp2+1,mp2+100001,cmp);
    if(mp1[1].i!=mp2[1].i) printf("%d\n",n-mp1[1].v-mp2[1].v);
    else printf("%d\n",min(n-mp1[1].v-mp2[2].v,n-mp1[2].v-mp2[1].v));
    return 0;
}

Measured memory_bytes: 5120
N = int(input())
A = list(map(int, input().split()))
n = len(list(filter(lambda x: x<0, A)))
A.sort(reverse=True, key=lambda x: abs(x))
if n&1 == 0:
    print(sum(map(abs, A)))
else:
    print(sum(map(abs, A[:(N-1)]))-abs(A[-1]))

Measured memory_bytes: 68308
#include<iostream>
#include<cmath>

using namespace std;

int main(void)
{
	long long num;

	while(cin>>num)
	{
		long long steps;

		for (int i = floor(sqrt(num)); i >= 1; --i) // 若是i*i < num,则每次for都需计算一次，容易RT；
		{
			if( num % i == 0 )
			{
				long long j = num/i;
				steps=j+i-2;
				break;
			}
		}

		cout<<steps<<endl;
	}
	return 0;
}

//该题本质是求两差值最小的因数，for循环中对sqrt（num）的处理不仅可以缩短运行时间，
//同时也可以注意到差值最小的两因数离sqrt（num）也最近

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

#define int long long

bool f;
int R, C, N, r[100000], c[100000], a[100000], H[100000], W[100000], vish[100000], visw[100000];
vector<int>h[100000], w[100000];
vector<int>v;

void dfsw(int x);

void dfsh(int x) {
	vish[x] = 1;
	for (int i : h[x]) {
		v.push_back(i);
		if (visw[c[i]]) {
			if (H[x] + W[c[i]] != a[i]) {
				f = false;
			}
		}
		else {
			W[c[i]] =a[i] - H[x];
			dfsw(c[i]);
		}
	}
}

void dfsw(int x) {
	visw[x] = 1;
	for (int i : w[x]) {
		if (vish[r[i]]) {
			if (W[x] + H[r[i]] != a[i]) {
				f = false;
			}
		}
		else {
			H[r[i]] = a[i] - W[x];
			dfsh(r[i]);
		}
	}
}

signed main() {
	cin >> R >> C >> N;
	f = true;
	for (int i = 0; i < N; ++i) {
		cin >> r[i] >> c[i] >> a[i];
		--r[i];
		--c[i];
		h[r[i]].push_back(i);
		w[c[i]].push_back(i);
	}
	for (int i = 0; i < N; ++i) {
		if (!vish[r[i]]) {
			v.clear();
			dfsh(r[i]);
			int minh, minw;
			minh = minw = intmax;
			for (int j : v) {
				minh = min(minh, H[r[j]]);
				minw = min(minw, W[c[j]]);
			}
			for (int j : v) {
				if (vish[r[j]] == 1) {
					H[r[j]] -= minh;
					++vish[r[j]];
				}
				if (visw[c[j]] == 1) {
					W[c[j]] -= minw;
					++visw[c[j]];
				}
				if (H[r[j]] + W[c[j]] > a[j])f = false;
			}
		}
	}
	puts(f ? "Yes" : "No");
}

Measured memory_bytes: 18292
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x,2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
using vd = vector<long double>;
#define co(x) cout << x << endl;
#define cins(n,v) rep(i,n){cin >> v.at(i);}
#define couts(v) rep(i,v.size()){cout << v.at(i) << endl;}
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  int n,x,y,INF=1e9+2,add,sub,nw=INF,ne=-INF,se=-INF,sw=INF;
  cin >> n;
  rep(i,n){
    cin >> x>>y;
    add=x+y; sub=x-y;
    if(add>ne) ne=add;
    if(add<sw) sw=add;
    if(sub<nw) nw=sub;
    if(sub>se) se=sub;
  }
  cout << max(ne-sw,se-nw) << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <queue>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<22

using namespace std;

typedef pair<int,int> P;

struct edge
{
	int to;
	int cost;
};

vector<edge> G[21];

vector<string> split(string &str,char delim)
{
	vector<string> res;
	size_t current = 0,found;
	while((found = str.find_first_of(delim,current)) != string::npos)
	{
		res.push_back(string(str,current,found  - current));
		current = found + 1;
	}
	res.push_back(string(str,current,str.size() - current));
	return res;
}

int dijkstra(int s,int g,int n)
{
	int d[20];
	priority_queue<P,vector<P>,greater<P> > que;
	fill(d,d+n,INF);
	d[s] = 0;
	que.push(P(0,s));
	while(!que.empty())
	{
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		rep(i,G[v].size())
		{
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost)
			{
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
	return d[g];
}

int main()
{
	int n,m,cost[21][21];
	rep(i,21)
	{
		rep(j,21)
		{
			cost[i][j] = INF;
		}
	}

	cin >> n >> m;
	rep(i,m)
	{
		string s;
		cin >> s;
		vector<string> _s = split(s,',');
		int a = atoi(_s[0].c_str());
		int b = atoi(_s[1].c_str());
		int c = atoi(_s[2].c_str());
		int d = atoi(_s[3].c_str());

		edge t,t2;
		t.to = a-1;
		t.cost = d;
		t2.to = b-1;
		t2.cost = c;
		G[b-1].push_back(t);
		G[a-1].push_back(t2);
	}

	string s;
	cin >> s;
	vector<string> _s = split(s,',');
	int x1 = atoi(_s[0].c_str());
	int x2 = atoi(_s[1].c_str());
	int y1 = atoi(_s[2].c_str());
	int y2 = atoi(_s[3].c_str());
	int ans = y1 - y2;
	ans -= dijkstra(x1-1,x2-1,n) + dijkstra(x2-1,x1-1,n);
	cout << ans << endl;

}

int main_Volume0117_a()
{
	int n,m,cost[21][21];
	rep(i,21)
	{
		rep(j,21)
		{
			cost[i][j] = 1000000;
		}
	}

	cin >> n >> m;

	rep(i,m)
	{
		string s;
		cin >> s;
		vector<string> _s = split(s,',');
		int a = atoi(_s[0].c_str());
		int b = atoi(_s[1].c_str());
		int c = atoi(_s[2].c_str());
		int d = atoi(_s[3].c_str());

		cost[a][b] = c;
		cost[b][a] = d;
	}


	REP(k,1,n+1)
	{
		REP(i,1,n+1)
		{
			REP(j,1,n+1)
			{
				cost[i][j] = min(cost[i][j],cost[i][k]+cost[k][j]);
			}
		}
	}

	string s;
	cin >> s;
	vector<string> _s = split(s,',');
	int x1 = atoi(_s[0].c_str());
	int x2 = atoi(_s[1].c_str());
	int y1 = atoi(_s[2].c_str());
	int y2 = atoi(_s[3].c_str());

	int ans = y1 - y2;
	ans -= cost[x1][x2] + cost[x2][x1];

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1248
import numpy as np

def main():
    x, n = map(int, input().split())
    p = list(map(int, input().split()))

    p.sort()
    q = p
    ans = list(map(lambda _: abs(_ - x), q))
    
    cnt = 0
    while cnt <= 101:
        if ans.count(cnt) == 2 and cnt != 0:
            pass
        elif ans.count(cnt) == 1 and cnt == 0:
            pass
        else:
            if (x - cnt) in p:
                return x + cnt
            else:
                return x - cnt

        cnt += 1   


if __name__ == "__main__":
    print(main())

Measured memory_bytes: 27160
import  math
N,M = map(int,input().split())

def f(M):
    l = []
    for i in range(1,int(math.sqrt(M))+1):
        if M%i==0:
            l.append(i)
    n = len(l)
    for i in range(n):
        j = l[n-1-i]
        if M/j!=j:
            l.append(M//j)
    return l

l = f(M)

for i in range(len(l)):
    n = l[-1-i]
    if M/n >= N:
        ans = n
        break
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define GET(a) cin >> (a)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	
	if(a == b && b == c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
    return 0;
}

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

#define Gene template< class
#define Rics printer& operator,
Gene c> struct rge{c b, e;};
Gene c> rge<c> range(c i, c j){ return {i, j};}
struct printer{
    ~printer(){cerr<<endl;}
    Gene c >Rics(c x){ cerr<<boolalpha<<x; return *this;}
    Rics(string x){cerr<<x;return *this;}
    Gene c, class d >Rics(pair<c, d> x){ return *this,"(",x.first,", ",x.second,")";}
    Gene ... d, Gene ...> class c >Rics(c<d...> x){ return *this, range(begin(x), end(x));}
    Gene c >Rics(rge<c> x){
        *this,"["; for(auto it = x.b; it != x.e; ++it)
            *this,(it==x.b?"":", "),*it; return *this,"]";}
};
#define debug() cerr<<"LINE "<<__LINE__<<" >> ", printer()
#define dbg(x) "[",#x,": ",(x),"] "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int my_rand(int l, int r) {
    return uniform_int_distribution<int>(l, r) (rng);
}

const int mod = 1e9+7;
const int N = 4005;
int dp[N][N/2][2];
int cum[N];

int main() {
//    freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, m, K;
    cin >> m >> n >> K;

    dp[0][0][0] = 1;
    int ans = 0;
    for(int i = 1; i <= n+m; i++) {
        for(int x = 0; x <= n; x++) {
            cum[x] = dp[i-1][x][0] + dp[i-1][x][1];
            cum[x] %= mod;
            if(x) cum[x] += cum[x-1];
            cum[x] %= mod;
        }
        for(int sum = 0; sum <= n; sum++) {
            dp[i][sum][0] = (dp[i-1][sum][0]+dp[i-1][sum][1])%mod;
            int L = sum-min(sum, K-1), R = sum-1;
            int add = cum[R] - (L > 0 ? cum[L-1] : 0);
            add %= mod;
            if(add < 0) add += mod;
            dp[i][sum][1] += add;
            dp[i][sum][1] %= mod;
//
//            for(int x = 1; x <= min(sum, K-1); x++) {
//                dp[i][sum][1] += (dp[i-1][sum-x][0]+dp[i-1][sum-x][1])%mod;
//                dp[i][sum][1] %= mod;
//            }
            int other = (K-1)*i - sum;
            if(other >= 0 && other <= m-1 && (n-sum)%(K-1) == 0 && (m-1-other)%(K-1) == 0) {
//                debug(), dbg(i), dbg(sum), dbg(dp[i][sum][1]);
                ans += dp[i][sum][1];
                ans %= mod;
            }
        }
    }
    cout << ans << endl;
}





Measured memory_bytes: 66232
#include<stdio.h>
int main()
{
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x-r>=0 && y-r>=0 && x+r<=W && y+r<=H)
    {
    printf("Yes\n");
    }
    else
    {
    printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 584