akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn move_count(grid: &Vec<Vec<char>>, h: usize, w: usize, start: (usize, usize)) -> usize {
    let di = vec![-1, 0, 1, 0];
    let dj = vec![0, 1, 0, -1];
    let mut visited = HashSet::new();
    let mut que = VecDeque::new();
    visited.insert(start);
    que.push_back((start, 0));
    let mut res = 0;
    while let Some(((i, j), cost)) = que.pop_front() {
        for d in 0..4 {
            let new_i = (i as isize) + di[d];
            let new_j = (j as isize) + dj[d];
            if new_i < 0 || new_i >= (h as isize) || new_j < 0 || new_j >= (w as isize) {
                continue;
            }
            let new_i = new_i as usize;
            let new_j = new_j as usize;
            if grid[new_i][new_j] == '#' {
                continue;
            }
            let new_pos = (new_i, new_j);
            if visited.contains(&new_pos) {
                continue;
            }
            visited.insert(new_pos);
            let new_cost = cost + 1;
            que.push_back((new_pos, new_cost));
            res = res.max(new_cost);
        }
    }
    res
}

fn solve() {
    input! {
        h: usize, w: usize,
        grid: [Chars; h]
    };

    let mut res = 0;
    for i in 0..h {
        for j in 0..w {
            if grid[i][j] != '#' {
                res = res.max(move_count(&grid, h, w, (i, j)));
            }
        }
    }
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2244
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    cout <<  (10000 - n) % 1000 << endl;
    return 0;
}

Measured memory_bytes: 3476
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll> > mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;
const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};

int N, C, K;
int T[101010];

signed main() {
  cin >> N >> C >> K;
  REP(i,N) cin >> T[i];
  sort(T, T + N);

  int ans = 0;
  int cur = 0;
  int num = C;
  
  int pos = T[0] + K;
  ans++;
  cur++;
  num--;

  while (cur < N) {
    while (0 < num && cur < N && T[cur] <= pos) {
      num--;
      cur++;
    }
    pos = T[cur] + K;
    //cout << "# " << cur << endl;
    if (cur < N) {
      ans++;
    }
    cur++;
    num = C - 1;
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
import Data.Char
import Data.IORef
import Control.Monad
import Data.List

count :: (a -> Bool) -> [a] -> Int
count p = foldr (\a acc -> if p a then acc + 1 else acc) 0

-- '0' -> 0, '1' -> 1, ..., '9' -> 9
charToInt :: Char -> Int
charToInt a = ord a - ord '0'

-- 各桁の和
sumOfDigits :: Int -> Int
sumOfDigits = sum . map charToInt . show

interleave :: [a] -> [a] -> [a]
interleave (x:xs) (y:ys) = x : y : interleave xs ys

uninterleave :: [a] -> ([a], [a])
uninterleave = foldr (\x (xs, ys) -> (x:ys, xs)) ([], [])

flipOrder :: Ordering -> Ordering
flipOrder GT = LT
flipOrder LT = GT
flipOrder EQ = EQ

sortRev :: Ord a => [a] -> [a]
sortRev = sortBy (\a b -> flipOrder $ compare a b)

intList :: [Int] -> [Int]
intList = id

int :: Int -> Int
int = id

gridDistance :: Num a => (a, a) -> (a, a) -> a
gridDistance (x1, y1) (x2, y2) = abs (x2 - x1) + abs (y2 - y1)

main = do
  n <- int . read <$> getLine
  print (n * 800 - (n `div` 15 * 200))


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

int main(){
    int N, ok=1;

    cin >> N;

    int H[N];

    for(int lp; lp<N; lp++) cin >> H[lp];

    int premax = H[0];
    for(int lp=0; lp<N-1; lp++){
        if(premax <= H[lp+1]){
            ok++;
            premax = premax > H[lp+1] ? premax : H[lp+1];
        }
    }
    
    cout << ok << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

#define MOD 1e9+7
#define INF 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_V 100
#define MAX_E 100

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

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

void dfs(int x, int y);

int w, h, cnt;

int c[50][50];

int main() {

  while(true) {
    cin >> w >> h;

    if(w==0&&h==0) break;

    cnt = 0;

    rep(i, h) {
      rep(j, w) cin >> c[i][j];
    }

    rep(i, h) {
      rep(j, w) {
        if(c[i][j]==1) {
          dfs(i, j);
          ++cnt;
        }
      }
    }

    cout << cnt << endl;
  }

  return 0;
}

void dfs(int x, int y) {

  if(x<0||x>=h||y<0||y>=w||c[x][y]==0) {
    return;
  }

  c[x][y] = 0;

  rep(i, 8) {
    dfs(x+ddx[i], y+ddy[i]);
  }
}



Measured memory_bytes: 3092
文字列1 = list(input())
文字列2 = list(input())

テーブル = [[0]*(len(文字列2)+1) for _ in range(len(文字列1)+1)]#外側から内側のイメージ

for 添字1 in range(len(文字列1)):
    for 添字2 in range(len(文字列2)):
        if 文字列1[添字1] == 文字列2[添字2]:
            テーブル[添字1+1][添字2+1] = テーブル[添字1][添字2] + 1
        else:
            テーブル[添字1+1][添字2+1] = max(テーブル[添字1+1][添字2], テーブル[添字1][添字2+1])

答え = []
添字1 = len(文字列1)
添字2 = len(文字列2)
while True:
    if テーブル[添字1][添字2] == テーブル[添字1][添字2-1]:
        添字2 -= 1
    elif テーブル[添字1][添字2] == テーブル[添字1-1][添字2]:
        添字1 -= 1
    else:
        答え.append(文字列1[添字1-1])
        添字1 -= 1
        添字2 -= 1

    if 添字1 == 0 or 添字2 == 0:
        break

答え.reverse()
print(''.join(答え))

Measured memory_bytes: 112732
#include <stdio.h>
#include <stdlib.h>

int main()
{
	long long N, M;
	scanf("%lld %lld", &N, &M);
	
	long long i, dog = 1, monkey = 1;
	for (i = 2; i <= N; i++) dog = dog * i % 1000000007;
	for (i = 2; i <= M; i++) monkey = monkey * i % 1000000007;
	
	if (llabs(N - M) >= 2) printf("0\n");
	else if (llabs(N - M) == 1) printf("%lld\n", dog * monkey % 1000000007);
	else printf("%lld\n", dog * monkey * 2 % 1000000007);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n ;
    cin >> n ;
    string s ;
    cin >> s ;
    vector<vector<int> > p(26) ;
    for(int i = 0; i < n; i++){
        p[s[i] - 'a'].emplace_back(i) ;
    }
    int ans = 0 ;
    for(int cut = 0; cut < n; cut++){
        int cnt = 0 ;
        for(int i = 0; i < 26; i++){
            vector<int> &v = p[i];
            if ( (int)v.size() >= 2 ){
                if ( v[0] <= cut && v.back() > cut ) cnt++ ;
            }
        }
        ans = max(ans, cnt) ;
    }
    cout << ans << endl;
    return 0; 
}

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

int main(void) {
	int A, B, C, K;
	scanf("%d %d %d %d", &A, &B, &C, &K);
	for (int i = 0; i < K; i++) {
		if (A >= B) {
			B *= 2;
		} else if (B >= C) {
			C *= 2;
		}
	}
	printf(A < B && B < C ? "Yes\n" : "No\n");

	return 0;
}


Measured memory_bytes: 3824
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n, q;
	LL k;
	while(cin >> n >> k >> q) {
		vector<LL> a(q);
		REP(i, q){
			cin >> a[i];
			a[i]--;
		}
		vector<LL> b(n);
		LL diff = 0;
		REP(i, q) {
			b[a[i]]++;
			diff--;
		}
		REP(i, n) {
			if(b[i] + diff + k <= 0) {
				cout << "No" << endl;
			} else{
				cout << "Yes" << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>

using namespace std;

int BIT_calc(vector<int> &v, int x){
  int ret = 0;
  for(int i = x; i > 0; i -= i & -i){
    ret += v[i];
  }
  return ret;
}

void BIT_add(vector<int> &v, int w, int s, int n){
  for(int i = s; i <= n; i += i & -i){
    v[i] += w;
  }
}


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

  vector<int> l(n), r(n);
  vector< vector<int> > x(m+1);
  vector<int> station(m+10, 0);

  for(int i = 0; i < n; i++){
    cin >> l[i] >> r[i];
    int d = r[i] - l[i];

    x[d].push_back(i);
  }

  int len = n;
  int y = 0;

  for(int d = 1; d <= m; d++){
    for(; y < d-1; y++){
      for(int j = 0; j < x[y].size(); j++){
        int z = x[y][j];
        BIT_add(station, 1, l[z], m);
        BIT_add(station, -1, r[z]+1, m);
        //cout << "j : " << j << " " << z << " " << r[z] + 1 << endl;
        len--;
      }
    }

    int result = len;
      //for(int i = 1; i <= m; i++) cout << BIT_calc(station, i);
    for(int i = d; i <= m; i += d){
      result += BIT_calc(station, i);
    }

    cout << result << endl;

  }

  return 0;
}


Measured memory_bytes: 9216
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long

bool is_prime[200200];

void solve() {
	int x; cin >> x;
    rep(i, 200200) {
        is_prime[i] = true;
    }
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i < 200200; ++i) {
        if(is_prime[i]) {
            for(int j = 2 * i; j < 200200; j += i) {
                is_prime[j] = false;
            }
        }
    }
    for(int k = x; k < 200200; ++k) {
        if(is_prime[k]) {
            cout << k << endl;
            return;
        }
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100010
#define INF 10000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
    int x,a;
    cin>>x>>a;
    int ans=0;
    if(x>=a)ans=10;
    OUT(ans);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007

int N;
int W[105];
signed main(){
    scanf("%lld",&N);
    int wa=0;
    rep(i,N){
        scanf("%lld",&W[i]);
        wa+=W[i];
    }
    int ans=LLINF;
    int leftwa=0;
    rep(i,N){
        leftwa+=W[i];
        ans=min(ans,abs(wa-2*leftwa));
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var sx, sy, tx, ty int
	fmt.Scan(&sx, &sy, &tx, &ty)

	// 基本的に、1回目の行きは上右、帰りは下左
	// 2回目の行きも上右、帰りは下左で行けば良い
	// 2回目はひとマスずらしてちょっと遠回りする

	ans := ""

	dx := tx - sx
	dy := ty - sy

	// 1回目の行き
	for i := 0; i < dy; i++ {
		ans += "U"
	}
	for i := 0; i < dx; i++ {
		ans += "R"
	}

	// 1回目の帰り
	for i := 0; i < dy; i++ {
		ans += "D"
	}
	for i := 0; i < dx; i++ {
		ans += "L"
	}

	// 原点から-x方向に移動しておく
	ans += "L"
	// 2回目の行き
	for i := 0; i <= dy; i++ {
		ans += "U"
	}
	for i := 0; i <= dx; i++ {
		ans += "R"
	}
	ans += "D"

	ans += "R"
	// 2回目の帰り
	for i := 0; i <= dy; i++ {
		ans += "D"
	}
	for i := 0; i <= dx; i++ {
		ans += "L"
	}
	ans += "U"

	fmt.Println(ans)
}


Measured memory_bytes: 5504
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
x,y = readInts()
cnt = 0
while x <= y:
    cnt += 1
    x += x
print(cnt)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N,M;
    cin >> N >> M;
    vector<ll> K(N);
    vector<vector<ll>> L(N),G(M+N);
    rep(i,N){
        cin >> K[i];
        rep(j,K[i]){
            ll l;
            cin >> l;
            l--;
            L[i].push_back(l);
            G[l].push_back(M+i);
            G[M+i].push_back(l);
        }
    }
    queue<ll> que;
    que.push(M);
    vector<ll> memo(M+N,1e18);
    memo[M] = 0;
    while(!que.empty()){
        ll v = que.front();
        que.pop();
        for(auto& u:G[v]){
            if(memo[u] != 1e18) continue;
            memo[u] = memo[v] + 1;
            que.push(u);
        }
    }
    rep(i,N){
        //cout << "aa:" << memo[M+i] << " "<< i+1 << endl;
        if(memo[M+i] == 1e18){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 20400
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class A
{
	public static void Main()
	{
		int X = GetInt();
		int A = GetInt();
		int B = GetInt();
		if(-A + B <= 0)
		{
			Console.WriteLine("delicious");
		}
		else if(-A + B <= X)
		{
			Console.WriteLine("safe");
		}
		else
		{
			Console.WriteLine("dangerous");
		}
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 13140
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int sum = 0;
		for(int i=1; i<=n; i++){
			sum += i;
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 35644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
static const long double pi = 3.141592653589793;

ll N, M, R;
vector<ll> r(9);
vector<vector<ll>> Way(202, vector<ll>(202, INF));
vector<ll> A(20000), B(20000), C(20000);
vector<bool> used(9);
ll res=INF;
void dfs(int c,int las,int dist) {
    if(c==R) {
		if(res>dist)res=dist; 
      	return;
	}
	for(int i=0;i<R;i++){
      if(!used[i]) {
              used[i]=true;
      	if(las==-1){
              dfs(c+1,i,0);
      	}else{
        		dfs(c+1,i,dist+Way[r[las]][r[i]]);
      	}
      	used[i]=false;
      	}
     }
  }
 

int main(){
    cin>>N>>M>>R;
    rep(i, R){
        cin>>r[i];
        r[i]--;
    }
    vector<ll> A(M), B(M), C(M);
    rep(i, M){
        cin>>A[i]>>B[i]>>C[i];
        A[i]--; B[i]--;
        Way[A[i]][B[i]]=min(Way[A[i]][B[i]],C[i]);
        Way[B[i]][A[i]]=min(Way[B[i]][A[i]],C[i]);
    }
  	rep(i, N){
      	Way[i][i]=0;
    }
    rep(k, N){
        rep(i, N){
            rep(j, N){
                Way[i][j]=min(Way[i][j], Way[i][k]+Way[k][j]);
            }
        }
    }
  	/*rep(i, N){
		rep(j, N){
          cout<<Way[i][j]<<" ";
        }
      	cout<<endl;
    }*/
   dfs(0,-1,0);
  	cout<<res<<endl;
}
     

Measured memory_bytes: 1536
class Dice:
    def __init__(self,t,f,r,l,b,u):
        self.a=[t,f,r,l,b,u]
        self.direct={'S':(4,0,2,3,5,1),'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3)}
    def roll(self,d):
        self.a=[self.a[i] for i in self.direct[d]]
        self.t = self.a[0]
        self.f = self.a[1]
        self.r = self.a[2]
        self.l = self.a[3]
        self.b = self.a[4]
        self.u = self.a[5]
t,f,r,l,b,u=map(int,input().split())
dice=Dice(t,f,r,l,b,u)
for d in input():
    dice.roll(d)
print(dice.t)



Measured memory_bytes: 5604
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Integer[] lines = getStdinInt();
        int sum  = 0;
        for(int i = 0; i < lines[0]; i++){
            sum = sum + (i + 1);
        }
        System.out.println(sum);

    }
    private static Integer[] getStdinInt() {
        Scanner scanner = new Scanner(System.in);
        ArrayList<Integer> lines = new ArrayList<>();
        while (scanner.hasNext()) {
            lines.add(scanner.nextInt());
        }
        return lines.toArray(new Integer[lines.size()]);
    }
}


Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<long long, long long> pll;

using namespace std;

const long long mod = 1000000007;

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

	string s;
	cin >> s;

	rep(i, s.length()) {
		if (i & 1) {
			if (s[i] == 'R') {
				cout << "No\n";
				return 0;
			}
		}
		else {
			if (s[i] == 'L') {
				cout << "No\n";
				return 0;
			}
		}
	}

	cout << "Yes" << "\n";

	return 0;
}

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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    int n;
    int d[100001];
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> d[i];

    sort(d, d + n);

    int mn = d[n / 2 - 1];
    int mx = d[n / 2];

    cout << mx - mn << endl;
}

Measured memory_bytes: 1024
N,K,Q = list(map(int,input().split()))

point = [K-Q for _ in range(N)]

for i in range(Q):
    p = int(input())-1
    point[p] += 1
for i in range(N):
    if point[i] <= 0:
        print('No')
    else:
        print('Yes')


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  string s; cin >> s;
  bool ans = s[2] == s[3] && s[4] == s[5];
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pii pair<long long,long long>
#define endl '\n'
#define N 100001
#define ll long long
int mod=1000000007;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
vector<int> parent(N),sz(N);
int modexp(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        
        return modexp((x*x)%M,n/2,M);
    else                             
        return (x*modexp((x*x)%M,(n-1)/2,M))%M;
}
void make_set(int s)
{
    parent[s]=s;
    sz[s]=1;
}
int find_parent(int p)
{
    if(p==parent[p])
    return p;
    return parent[p]=find_parent(parent[p]);
}
void union_set(int a,int b)
{
    a=find_parent(a);b=find_parent(b);
    if(a!=b)
    {
        if(a<b)
        swap(a,b);
        parent[b]=parent[a];
        sz[a]+=sz[b];
    }
}

vector<vector<int>> dp;
int func(string &a , string &b, int i , int j)
{
    if(i==a.size()||j==b.size())
    return 0;
    if(dp[i][j]!=-1)
    return dp[i][j];
    if(a[i]==b[j])
    return dp[i][j]=1+func(a,b,i+1,j+1);
    else
    return dp[i][j]=max(func(a,b,i+1,j),func(a,b,i,j+1));
}
void print(string &a, string &b,int n, int m)
{
    int i=0,j=0;
    while(i<n && j<m)
    {
        if(a[i]==b[j])
        cout<<a[i],i++,j++;
        else if(dp[i][j+1]>=dp[i+1][j])
        j++;
        else
        i++;
    }
}
void solve()
{
    int n,m; cin>>n>>m;
    char a[n][m];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        cin>>a[i][j];
    }
    dp.assign(n+1,vector<int> (m+1,0));
    dp[0][0]=1;
    for(int i=1;i<m;i++)
    {
        if(a[0][i]=='.')
        dp[0][i]=dp[0][i-1];
    }
    for(int i=1;i<n;i++)
    {
        if(a[i][0]=='.')
        dp[i][0]=dp[i-1][0];
    }
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<m;j++)
        {
            if(a[i][j]=='.')
            {
                dp[i][j]=dp[i-1][j]+dp[i][j-1];
                if(dp[i][j]>=mod)
                dp[i][j]-=mod;
            }
        }
    }
    cout<<dp[n-1][m-1];
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test; test=1;
    while(test--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 10624
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 105;

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

int h, w;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> h >> w;
    int n;
    cin >> n;
    vector< int > v;
    int mp[SIZE][SIZE];

    for( int i = 0; i < n; ++i ) {
        int a;
        cin >> a;
        v.pb( a );

    }

    int flg = true;
    int y = 0, x = 0;
    int cnt = 0;
    int pos = 0;
    while( cnt != h * w ) {
        mp[y][x] = pos + 1;
        --v[pos];
        if( v[pos] == 0 ) ++pos;
        if( ( flg && x == w - 1 ) || ( !flg && x == 0 ) ) {
            flg = !flg;
            ++y;

        } else {
            if( flg ) ++x;
            else --x;
        }
        ++cnt;

    }

    for( int i = 0; i < h; ++i ) {
        for( int j = 0; j < w; ++j ) cout << mp[i][j] << " ";
        cout << endl;

    }

    return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
#define fi first
#define sc second
#define pii pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define msi map<string,int>
#define si set<int>
#define all(v) v.begin(),v.end()
#define sz(v)  int((v).size())
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define dep(i,a,b)    for(int i=a;i>=b;i--)
#define isinarr(i,n) ((i>=0)?((i<n)?1:0):0)
#define fastio  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ppb pop_back
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mp make_pair
#define inparr(a,n) rep(i,0,n)cin>>a[i];
#define give(x,y) cout<<x<<" "<<y<<endl;
#define setp(n) cout<<fixed<<setprecision(n);
#define    endl '\n'

using namespace std;
void solve()
{
    int n,i,j,k,l;
    cin>>n;
    int cnt=n/500;
    int rem=n%500;
    int cnt2=rem/5;
    cout<<(cnt*1000)+(cnt2*5);
} 



signed main()
{
    fastio
    int t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]

A.sort()

L = [a for a in A if a <= 0]
R = [a for a in A if a > 0]

ans = []

if L != [] and R != []:
    low = L[0]
    for r in R[:-1]:
        ans.append([low, r])
        low -= r

    up = R[-1]
    for l in L[1:]:
        ans.append([up, l])
        up -= l

    ans.append([up, low])
    ans.append([up - low])

elif L == []:
    low, up = R[0], R[-1]
    for r in R[1:-1]:
        ans.append([low, r])
        low -= r
    ans.append([up, low])
    ans.append([up - low])

elif R == []:
    low, up = L[0], L[-1]
    for l in L[1:-1]:
        ans.append([up, l])
        up -= l
    ans.append([up, low])
    ans.append([up - low])

print(*ans[-1])
for a in ans[:-1]:
    print(*a)


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

int main(){
  int N;
  int T;
  int sum = 0;
  cin >> N;
  T = N;
  while(T>0){
    sum += T%10;
    T /= 10;
  }
  if(N%sum == 0){
    cout << "Yes" << endl;}
  else{
    cout << "No" << endl;}  
}   

Measured memory_bytes: 256
//       Author: Mostafa Mounir Shehab
 
#include <bits/stdc++.h>
using namespace std;
 
#define PI  acos(-1)
#define EPS (1e-10)
#define endl "\n"
#define SZ(v) (int)(v.size())
#define IO ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL), cerr.tie(NULL);
typedef long long ll;
typedef long double ld;
 
 
 
ll MOD=1e9 + 7;
ll OO=1e9 + 1;
const int N=1e6 + 10,M=20;
int arr[N];
int LOG[N];

int n,m,k,T;
int a,b,c;
int l,r,mid;
string str;


int main(){
	IO
	//freopen("in.txt","r",stdin);
	cin>>n;
	for(int i=0;i<n;++i)
		cin>>arr[i];
	ll ans = 0;
	for(int i=0;i<n-1;++i){
		if(arr[i+1] < arr[i]){
			ans += (arr[i] - arr[i+1]);
			arr[i+1] = arr[i];
		}
	}
	
	cout<<ans<<endl;
}

 

Measured memory_bytes: 4328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>

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

int main()
{
	int n, a, b;

	std::cin >> n >> a >> b;


	long long sum = 0;
	for (size_t i = 1; i <= n; i++)
	{
		long long dsum = digit_sum(i);
		if (dsum >= a && dsum <= b) {
			sum += i;
		}
	}

	std::cout << sum << std::endl;

	return 0;
}


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


int main(){

    ll N,A,B;
    cin >> N >> A >> B;

    ll sub = B - A;
    ll mini;
    if(sub%2 == 0){
        cout << sub / 2;
    }else{
        mini = N-A > B-1 ?A-1+1:N-B+1;
        mini = mini + sub/2;
        cout << mini;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

using Tup = array<int, 3>;

int N;
Tup rates[2];
LL dp[25000001];

LL Get(LL N, Tup A, Tup B) {
  Tup C, D;
  vector<int> is = {0, 1, 2};
  sort(all(is), [&](int a, int b) {
    if (B[a]*A[b] != B[b]*A[a]) return B[a]*A[b] > B[b]*A[a];
    else return A[a] > A[b];
  });

  int lim = 3;
  rep(i, 3) {
    C[i] = A[is[i]];
    D[i] = B[is[i]];
    if (D[i] <= C[i]) lim = i;
  }
  if (lim == 0) return N;

  if (lim == 1) {
    return N/C[1]*D[1] + N%C[1];
  }

  if (lim == 2) {
    LL ret = N;
    LL p = 0;
    while (1) {
      if (C[0] * p > N) break;
      LL cand = p*D[0];
      LL rem = N - C[0] * p;
      MX(ret, cand+rem);
      cand += (rem/C[1]) * D[1];
      rem %= C[1];
      MX(ret, cand+rem);
      ++p;
    }
    return ret;
  }
  assert(lim == 3);

  assert(N <= 25000000);
  fill(dp, dp+N+1, -1);
  int mc = min(C[1], C[2]);
  rep(i, mc) dp[i] = i;
  reps(i, mc, N+1) {
    dp[i] = i;
    if (i >= C[1]) MX(dp[i], dp[i-C[1]] + D[1]);
    if (i >= C[2]) MX(dp[i], dp[i-C[2]] + D[2]);
  }
  
  LL ret = N;
  LL p = 0;
  while (1) {
    if (C[0] * p > N) break;
    LL cand = p*D[0];
    LL rem = N - C[0] * p;
    MX(ret, cand+dp[rem]);
    ++p;
  }
  assert(ret >= N);
  return ret;
}

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);

  cin >> N;
  rep(i, 2) {
    rep(j, 3) {
      cin >> rates[i][j];
    }
  }

  LL ans = Get(Get(N, rates[0], rates[1]), rates[1], rates[0]);
  cout << ans << endl;
}


Measured memory_bytes: 256
const input = require("fs").readFileSync("/dev/stdin", "utf8")

function pow (x ,n) {
    let res = 1
    while (n > 0) {
        if (n & 1) res = mul(res, x)
        x = mul(x, x)
        n >>= 1
    }
    return res
}

function inv (x) {
    if (x == 1) return 1;
    return pow(x, mod - 2);
}

function mul (a, b) {
    return ((a >> 16) * b % mod * 65536 + (a & 65535) * b) % mod
}

const mod = 998244353

;(input => {
    const lines = input.split('\n')
    let [N, M, K] = lines[0].split(' ').map(Number)

    let ans = 0
    let fa = 1
    let fa2 = 1
    for (let k = 0; k <= K; k++) {
        fa = mul(fa, (k || 1))
        fa2 = mul(fa2, (k ? (N - k) : 1))
        let left = mul(fa2, inv(fa)) % mod
        ans += mul(left, pow((M - 1), (N - (k + 1)))) * M % mod
    }

    console.log(ans % mod)
 
})(input)


Measured memory_bytes: 34412
#include <iostream>
#include <string>    
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, h;

int main() {
	cin >> n >> h;
	ll a, b;
	ll max = 0;
	ll bb[n];
	for(ll i = 0; i < n; i++){
		cin >> a >> b;
		max = (a > max)? a : max;
		bb[i] = b;
	}
	sort(bb, bb+n);
	ll count = 0;
	while(h > 0){
		if(count == n || bb[n-1-count] < max){
			count += h/max;
			h -= (h/max)*max;
			if(h > 0){
				count++;
				h -= max;
			}
		}
		else{
			h -= bb[n-1-count];
			count++;
		}
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 1024
N,M,K = map(int,input().split())
if N==1 or M==1:
    flag = 1
else:
    flag = 0
    for i in range(N+1):
        for j in range(M+1):
            if M*i+N*j-2*i*j==K:
                flag = 1
                break
        if flag==1:break
if flag==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 64412
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>

using namespace std;

int N,W,value[1000],weight[1000];
int dp[110][10010];

int main(){
	cin>>N>>W;
	for(int i=0;i<N;i++){
		cin>>value[i]>>weight[i];
	}
	for(int w=0;w<W;w++){
		dp[0][w]=0;
	}
	for(int i=0;i<N;i++){
		for(int w=0;w<=W;w++){
			if(w>=weight[i]){
				dp[i+1][w]=max(dp[i][w-weight[i]]+value[i],dp[i][w]);
			}else{
				dp[i+1][w]=dp[i][w];
			}
		}
	}
	cout<<dp[N][W]<<endl;
}


Measured memory_bytes: 7052
# PyPy なら通る
# DP(貰うDP)
N = int(input())
S = input()

dp = [[0] * (N + 1) for _ in range(N + 1)]
result = 0
for i in range(N - 1, -1, -1):
    for j in range(N - 1, -1, -1):
        if S[i] == S[j]:
            t = dp[i + 1][j + 1] + 1
            dp[i][j] = t
            if t > j - i:
                t = j - i
            if t > result:
                result = t
print(result)


Measured memory_bytes: 229896
package main

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

func min(arr []int) (v int) {
	for i, n := range arr {
		if i == 0 || v > n {
			v = n
		}
	}
	return
}

func max(arr []int) (v int) {
	for i, n := range arr {
		if i == 0 || v < n {
			v = n
		}
	}
	return
}

func sum(arr []int) (s int) {
	for _, n := range arr {
		s += n
	}
	return
}

func main() {
	rd := bufio.NewReader(os.Stdin)
	for {
		s, err := rd.ReadString('\n')
		if err == io.EOF {
			return
		}
		arr := strings.Split(strings.TrimSpace(s), " ")
		a, _ := strconv.Atoi(arr[0])
		b, _ := strconv.Atoi(arr[1])
		for i := 0; i < a; i++ {
			for j := 0; j < b; j++ {
				fmt.Print("#")
			}
			fmt.Println()
		}
		if a == 0 && b == 0 {
			return
		}
		fmt.Println()
	}
}



Measured memory_bytes: 1108
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

main()
{
  int N;
  int a[300001];

  cin >> N;
  Rep(i, 3*N) {
    cin >> a[i];
  }

  sort( a, a+3*N );
  int sum = 0;
  for(int i=N; i<3*N; i+=2) {
    sum += a[i];
  }

  cout << sum << endl;  
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
    map<int,int>mp;
    int n,k;
    cin>>n>>k;
    while(k--){
        int d;
        cin>>d;
        for(int i=0;i<d;i++)
        {
            int a;
            cin>>a;
            mp[a]=d;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
        if(mp[i]==0)
        {
            ans+=1;
        }
    cout<<ans<<endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
using Graph = vector<vector<pair<int, int> > >;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


int N;

vector<P> red;
vector<P> blue;

bool com(P a, P b) {
	if (a.first > b.first)return true;
	else if (a.first == b.first)return a.second > b.second;
	else return false;
}

int main() {
	cin >> N;
	red.assign(N, P(0, 0));
	blue.assign(N, P(0, 0));
	for (int i = 0; i < N; i++) {
		cin >> red[i].first >> red[i].second;
	}
	for (int i = 0; i < N; i++) {
		cin >> blue[i].first >> blue[i].second;
	}
	sort(red.begin(), red.end(), com);
	sort(blue.begin(), blue.end());
	int ans = 0;
	for (int i = 0; i < red.size(); i++) {
		P p = red[i];
		P* cand = nullptr;
		for (int k = 0; k < blue.size(); k++) {
			if (p.first < blue[k].first && p.second < blue[k].second) {
				if (cand == nullptr)cand = &(blue[k]);
				else if(cand->second > blue[k].second){
					cand = &(blue[k]);
				}
			}
		}
		if (cand == nullptr)continue;
		ans++;
		cand->first = 0; cand->second = 0;
	}

	cout << ans << endl;

	return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

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

const int maxN = 1e5 + 5;
int h[maxN];
int dp[maxN];

signed main() {
  int n, k;
  std::cin >> n >> k;
  REP(i, n) {
    int hi = read();
    hi--;
    h[i] = hi;
  }
  dp[1] = abs(h[0] - h[1]);
  FOR(i, 2, n) {
    int cost = inf;
    FOR(j, 1, k + 1) {
      if (i - j < 0)
        break;
      chmin(cost, dp[i - j] + abs(h[i - j] - h[i]));
    }
    dp[i] = cost;
  }
  print(dp[n - 1]);
}


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

int main(){

    while(true){
        int m, f, r;
        cin >>m >>f >>r;

        if(m==-1&&f==-1&&r==-1) break;
        else if(m==-1||f==-1) cout << 'F';
        else if(m+f>=80) cout << 'A';
        else if(m+f<80&&m+f>=65) cout << 'B';
        else if(m+f<65&&m+f>=50) cout << 'C';
        else if(m+f<50&&m+f>=30){
            if(r>=50) cout << 'C';
            else cout << 'D';
        }
        else if (m+f<30) cout << 'F';

        cout << endl;

    }
    return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define LL long long 
const int N=1e5+10;
using namespace std;
int edgenum,to[N*2],nxt[N*2],head[N],n,q,k;
LL w[N*2],dis[N];
void addedge(int from,int too,LL jvli)
{
	++edgenum;nxt[edgenum]=head[from];to[edgenum]=too;w[edgenum]=jvli;head[from]=edgenum;
	++edgenum;nxt[edgenum]=head[too];to[edgenum]=from;w[edgenum]=jvli;head[too]=edgenum;
}
void buildtree(int now,int fa)
{
	 for(int i=head[now];i;i=nxt[i])
	  {
	  	 int too=to[i];
	  	 if(too!=fa)
	  	  {
	  	  	dis[too]=dis[now]+w[i];
	  	  	buildtree(too,now);
	  	  }
	  }
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;++i)
	 {
	  int x,y;
	  LL z;
	  scanf("%d%d%lld",&x,&y,&z);
	  addedge(x,y,z);
	 }
	 scanf("%d%d",&q,&k);
	 buildtree(k,0);
	 for(int i=1;i<=q;++i)
	  {
	  	 int x,y;
	  	 scanf("%d%d",&x,&y);
	  	 printf("%lld\n",dis[x]+dis[y]);
	  }
	return 0;
}

Measured memory_bytes: 10752
#include<bits/stdc++.h>
using namespace std;
int n;
double x[1005], y[1005], X, Y, d, e;
double dist(double a, double b) {
	return a*a + b*b;
}
int main() {
	cin>>n;
	for (int i = 0; i < n; i++) {
		cin>>x[i]>>y[i];
		X += x[i]; Y += y[i];
	}
	X /= n; Y /= n;
	double P = 0.1;
	for (int i = 0; i < 30000; i++) {
		int f = 0;
		d = dist(X - x[0], Y - y[0]);
		for (int j = 1; j < n; j++) {
			e = dist(X - x[j], Y - y[j]);
			if (d < e) { d = e; f = j; }
		}
		X += (x[f] - X)*P;
		Y += (y[f] - Y)*P;
		P *= 0.999;
	}
	cout<<setprecision(15)<<sqrt(d)<<"\n";
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())

cnt = 0
if a != b:
    for i in range(a, b + 1):
        if c % i == 0:
            cnt += 1
elif a == b and a <= c:
    if c % a == 0:
        cnt += 1
else:
    None

print(cnt)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int Maxn=100010;
const int inf=2147483647;
int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    return x*f;
}
int n,a[Maxn],b[Maxn],s[Maxn];
int c[Maxn<<1];
void add(int x,int v){for(;x<=n*2+1;x+=(x&-x))c[x]+=v;}
int query(int x){int re=0;for(;x;x-=(x&-x))re+=c[x];return re;}
LL g(int v)
{
	for(int i=1;i<=n;i++)
	if(a[i]<=v)b[i]=-1;
	else b[i]=1;
	s[0]=0;
	for(int i=1;i<=n;i++)s[i]=s[i-1]+b[i];
	for(int i=1;i<=2*n+1;i++)c[i]=0;
	add(n+1,1);
	LL re=0;
	for(int i=1;i<=n;i++)
	{
		re+=((LL)i-query(n+1+s[i]));
		add(n+1+s[i],1);
	}
	return re;
}
int main()
{
	int l=1,r=0;
	n=read();
	for(int i=1;i<=n;i++)r=max(a[i]=read(),r);
	while(l<=r)
	{
		int mid=l+r>>1;
		if(g(mid)>=(LL)n*(n+1)/4LL+1)r=mid-1;
		else l=mid+1;
	}
	printf("%d",r+1);
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define ABS(a,b) max(a,b) - min(a,b)

int main() {
	string s;
	int a = 0;
	cin >> s;
	REP(i, s.size()) {
		a += s[i] - '0';
	}
	cout << (atoi(s.c_str()) % a == 0 ? "Yes" : "No") << endl;
}
	


Measured memory_bytes: 256