akhauriyash/Code-Regression huggingface dataset:
from itertools import permutations

N, M = map(int, input().split())
graph = []
for i in range(M):
    a, b = map(int, input().split())
    graph.append(set((a, b)))

g = permutations(range(1, N + 1))

count = 0
for order in g:
    flag = True
    for i in range(N-1):
        if set((order[i], order[i + 1])) not in graph or order[0] != 1:
            flag = False
            break
    if flag:
        count += 1

print(count)

Measured memory_bytes: 42220
N = int(input())
L = [int(s) for s in input().split()]
L.sort()
count = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            len0 = L[i] + L[j] + L[k]
            max0 = max(L[i],L[j],L[k])
            rest = len0 - max0
            if (max0 < rest) and L[i] != L[j] and L[j]!=L[k]:
                count += 1
print(count)

Measured memory_bytes: 9200
// 2017/09/21 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;

	int N;
	cin >> N;

	int flg = 0;

	for(int i=0; i<N; i++){
		int s, f;
		cin >> s >> f;

		if(f<=a || b<=s){
			continue;
		}
		else{
			flg = 1;
		}
	}

	cout << flg << endl;

	return 0;
}

Measured memory_bytes: 3088
import java.lang.ArithmeticException

fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d:String = " ") = str().split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}.toIntArray()

fun <T> T.print() = this.also(::println)

fun main() {
	abc000X()
}

fun abc000X() {
	var n = long()
	var r = 0L

	for(i in 2L..1000000) {
		var j = i
		while(n%j==0L) {
			++r
			n /= j
			j *= i
		}
		while(n%i==0L)
			n /= i
	}

	if(n>2)
		++r

	println(r)
}


Measured memory_bytes: 34588
#include <stdio.h>

int main(void){
	int a[9];
	int i;
	int sum = 0;
	int b;
	for(i=0;i<9;i++){
		scanf("%d",&a[i]);
		sum += a[i];
	}
	b = a[0]+a[4]+a[8];
	b *=3;
	if(b==sum){
		printf("Yes");
	}else{
		printf("No");
	}
	//printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#include <numeric>

#define ll long long
#define int long long
#define ld long double
#define endl "\n"
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(p) cerr<<#p<<'='<<(p.first)<<" "<<p.second<<endl;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
const ll MOD = 1e9 + 7;
const int N = 1e3+5;
const int demo = 10;
using namespace std;
const ll cfmod=998244353;
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
char button[4]={'L','R','U','D'};

// Ahhiya thi lakhvanu chalu thasse....


signed main() {
    FAST
    int q = 1;
    //cin>>q;
    while (q--) {
        int n;
        cin>>n;
        int k;
        cin>>k;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin>>arr[i];
        }
        sort(arr.begin(),arr.end());
        int ans=0;
        for(int i=0;i<k;i++){
            ans+=arr[i];
        }
        cout<<ans;
    }
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ull unsigned long long int
#define ll long long int
#define LL_MAX 9223372036854775807
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define vl vector<ll>
#define bs(v, x) binary_search(v.begin(), v.end(), x)
#define popf pop_front
#define p() cout << '\n'
#define p0(x) cout << x << " "
#define p1(x) cout << x << '\n'
#define p2(x, y) cout << x << " " << y << '\n'
#define p3(x, y, z) cout << x << " " << y << " " << z << '\n'
#define printv(v)                   \
  for (ll i = 0; i < v.size(); ++i) \
    cout << v[i] << " ";            \
  cout << '\n'
#define pr1(x) cout << fixed << setprecision(15) << x << '\n'
#define mod 1000000007
#define mod1 998244353
#define fio                         \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)
#define get(n) \
  ll n;        \
  cin >> n
#define getvec(v, n)         \
  vector<ll> v(n);           \
  for (ll i = 0; i < n; i++) \
    cin >> v[i];
#define getstr(s) \
  string s;       \
  cin >> s
#define all(x) x.begin(), x.end()
#define countBits(x) __builtin_popcount(x)
using namespace std;

vector<vl> adj;
vector<bool> vis;

void dfs(int node)
{
  if (vis[node])
    return;
  vis[node] = true;
  for (int x : adj[node])
  {
    if (vis[x])
      continue;
    dfs(x);
  }
}

void mainSolve()
{
  get(n);
  get(m);
  adj.resize(n + 1);
  vis.resize(n + 1, false);
  while (m--)
  {
    get(a);
    get(b);
    adj[a].pb(b);
    adj[b].pb(a);
  }
  int c = 0;
  for (int i = 1; i <= n; i++)
  {
    if (vis[i])
      continue;
    ++c;
    dfs(i);
  }
  p1((c - 1));
}

int main()
{
  fio;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  //get(t);
  ll t = 1;
  while (t--)
  {
    mainSolve();
  }
  return 0;
}


Measured memory_bytes: 9796
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9 + 7;

struct Less {
	bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
		return x.second < y.second;
	}
};
//グラフの隣接リスト
//VI g[200010];
//頂点の入次数を管理
int h[100010];

int g[101][101];

bool e[100010];
vector<string> field;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M; cin >> N >> M;

	REP(i, N - 1) e[i] = true;
	vector<pair<int, int> > vp;
	REP(i, M) {
		int a, b; cin >> a >> b;
		a--; b--;
		vp.push_back({ a, b });
	}
	sort(vp.begin(), vp.end(), Less());
	
	int ans = 1;
	int t = vp[0].second;
	for (int i = 0; i < M; ++i) {
		if (vp[i].first >= t) {
			t = vp[i].second;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1528
import Data.List

rewrite :: Int -> String -> Int
rewrite x = sum . drop x . reverse . sort . map length . group . sort . words

main = do
    cs <- getLine
    ds <- getLine
    let t = read . head . words $ cs :: Int
    let s = read . last . words $ cs :: Int
    case (t == s) of
      True  -> print 0
      False -> print $ rewrite s ds

Measured memory_bytes: 97660
import numpy as np
def main():
    
    n = int(input())

    s = str(input())

    ans = 0
    for i in range(n-2):
        if s[i] == 'A':
            if s[i+1] == 'B':
                if s[i+2] == 'C':
                    ans += 1
    
    print(ans)



if __name__ == '__main__':
    main()



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

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

void print0() {}
template <typename Head, typename... Tail>
void print0(Head head, Tail... tail) {
    cout << head;
    print0(tail...);
}

ll dp[3001][3001][4];
ll itemtbl[3001][3001];
int main() {
    ll R, C, K;
    cin >> R >> C >> K;

    // vector<vector<ll>> itemtbl(R, vector<ll>(C));
    for (ll r = 0; r < R; r++) {
        for (ll c = 0; c < C; c++) {
            itemtbl[r][c] = 0;
        }
    }

    for (ll i = 0; i < K; i++) {
        ll r, c, v;
        cin >> r >> c >> v;
        r--;
        c--;
        itemtbl[r][c] = v;
    }

    //vector<vector<vector<ll>>> dp(R, vector<vector<ll>>(C, vector<ll>(4)));
    for (ll r = 0; r < R; r++) {
        for (ll c = 0; c < C; c++) {
            if (r == 0) {
                if (c == 0) {
                    dp[r][c][0] = itemtbl[r][c];
                    dp[r][c][1] = itemtbl[r][c];
                    dp[r][c][2] = itemtbl[r][c];
                    dp[r][c][3] = 0;
                } else {
                    dp[r][c][0] = max(dp[r][c - 1][1] + itemtbl[r][c], dp[r][c - 1][0]);
                    dp[r][c][1] = max(dp[r][c - 1][2] + itemtbl[r][c], dp[r][c - 1][1]);
                    dp[r][c][2] = max(dp[r][c - 1][3] + itemtbl[r][c], dp[r][c - 1][2]);
                    dp[r][c][3] = dp[r][c - 1][3];
                }
            } else {
                if (c == 0) {
                    dp[r][c][0] = itemtbl[r][c] + dp[r - 1][c][0];
                    dp[r][c][1] = itemtbl[r][c] + dp[r - 1][c][0];
                    dp[r][c][2] = itemtbl[r][c] + dp[r - 1][c][0];
                    dp[r][c][3] = dp[r - 1][c][0];
                } else {
                    dp[r][c][0] = max(
                        max(dp[r][c - 1][1] + itemtbl[r][c], dp[r][c - 1][0]),
                        dp[r - 1][c][0] + itemtbl[r][c]);
                    dp[r][c][1] = max(
                        max(dp[r][c - 1][2] + itemtbl[r][c], dp[r][c - 1][1]),
                        dp[r - 1][c][0] + itemtbl[r][c]);
                    dp[r][c][2] = max(
                        max(dp[r][c - 1][3] + itemtbl[r][c], dp[r][c - 1][2]),
                        dp[r - 1][c][0] + itemtbl[r][c]);
                    dp[r][c][3] = max(dp[r][c - 1][3], dp[r - 1][c][0]);
                }
            }
        }
    }
    print(dp[R - 1][C - 1][0]);
}


Measured memory_bytes: 355304
#[macro_use(s)]
#[macro_use(stack)]
extern crate ndarray;

use ndarray::{Array, Array2, Axis};
use proconio::input;
use proconio::marker::Chars;

fn main() {
    abc173_c()
}

fn abc173_c() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        ss: [Chars; h],
    }
    let grid = Array::from_shape_vec(
        (h, w),
        ss.concat()
            .iter()
            .map(|&c| if c == '#' { 1 } else { 0 })
            .collect(),
    )
    .unwrap();
    println!("{}", check_v(&grid, k, 0));

    fn check_v(grid: &Array2<usize>, k: usize, v: usize) -> usize {
        let sum = grid.sum();
        if sum < k {
            return 0;
        }
        let mut total = 0;
        total += check_h(&grid, k, 0);
        for i in v..grid.shape()[1] {
            total += check_v(
                &stack![
                    Axis(1),
                    grid.slice(s![.., ..i]),
                    grid.slice(s![.., (i + 1)..])
                ],
                k,
                i,
            );
        }
        return total;
    }

    fn check_h(grid: &Array2<usize>, k: usize, h: usize) -> usize {
        let sum = grid.sum();
        if sum < k {
            return 0;
        }
        let mut total = if sum == k { 1 } else { 0 };
        for i in h..grid.shape()[0] {
            total += check_h(
                &stack![
                    Axis(0),
                    grid.slice(s![..i, ..]),
                    grid.slice(s![(i + 1).., ..])
                ],
                k,
                i,
            );
        }
        return total;
    }
}


Measured memory_bytes: 2128
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
L = int(input())
k = 1
while a[-1] // (L * pow(2, k)): k += 1
e = [[0] * k for _ in range(N)]
for i in range(N):
  t = L + a[i]
  ok = i
  ng = N
  while ng - ok > 1:
    m = (ok + ng) // 2
    if a[m] <= t: ok = m
    else: ng = m
  e[i][0] = ok
for j in range(len(e[i]) - 1):
  for i in range(N):
    x = e[i][j]
    e[i][j + 1] = e[x][j]
#print(e)

def doubling(u, v):
  if u == v: return 0
  ok = -1
  ng = len(e[u])
  while ng - ok > 1:
    m = (ok + ng) // 2
    if e[u][m] < v: ok = m
    else: ng = m
  if ok < 0: return 1
  return doubling(e[u][ok], v) + pow(2, ok)

Q = int(input())
for _ in range(Q):
  x, y = map(int, input().split())
  x -= 1
  y -= 1
  if x > y: x, y = y, x
  print(doubling(x, y))


Measured memory_bytes: 98584
n = int(input())

memo = [-1]*(n+1)
memo[0] = 2
memo[1] = 1

def dp(x):
    if x == 0:
        return 2
    elif x == 1:
        return 1
    elif memo[x] != -1:
        return memo[x]
    memo[x] = dp(x-1) + dp(x-2)
    return memo[x]

print(dp(n))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using vi = vector<int>;
using vv = vector<vi>;
using vvv= vector<vv>;
using P  = pair<int,int>;

const int INF = 1001001001;

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--; y1--; x2--; y2--;
    
    vector<string> s(h);
    rep(i,h)cin>>s[i];
    
    vvv cost(h, vv(w, vi(4, INF)));
    vvv used(h, vv(w, vi(4,   0)));
    priority_queue<P, vector<P>, greater<P>> q;
    
    rep(i,4){
        cost[x1][y1][i]=0;
        used[x1][y1][i]=0;
        q.push(P(0, (x1*w+y1)*4+i));//始点, 全方位
    }
    
    vector<int> dx={0,1,0,-1};
    vector<int> dy={1,0,-1,0};
    
    while(!q.empty()){
        int c  = q.top().first;
        int p  = q.top().second;//場所,方向
        int go = c%k;//その方向に何マス直進してきたか
        c /= k;//移動コスト
        
        int px = p/(4*w);//x座標
        int py = (p/4)%w;//y座標
        int d  = p%4;//方向
        q.pop();
        
        if(used[px][py][d])continue;
        used[px][py][d] = 1;
        cost[px][py][d] = c*k+go;
        
        //左右に向きを変える遷移
        if(!used[px][py][(d+1)%4])q.push(P(((c*k+go+k-1)/k)*k,(px*w+py)*4+(d+1)%4));
        if(!used[px][py][(d+3)%4])q.push(P(((c*k+go+k-1)/k)*k,(px*w+py)*4+(d+3)%4));
        
        //直進する遷移
        int nx = px+dx[d];
        int ny = py+dy[d];
        if(nx<0 || ny<0 || nx>=h || ny>=w)continue;
        if(s[nx][ny]=='@')continue;
        
        if(!used[nx][ny][d])q.push(P(c*k+go+1, (nx*w+ny)*4+d));
        
    }
    
    int ans = INF;
    rep(i,4)ans = min(ans, cost[x2][y2][i]);
    cout << (ans==INF?-1:(ans+k-1)/k) << endl;
    return 0;
}

Measured memory_bytes: 168176
import java.util.*;
import java.io.*;
import java.math.*;
 
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{ 
 
 
    static long mod=1000000007;
    static int dx[]={1,-1,0,0};
    static int dy[]={0,0,1,-1};
    // static int dx[]={1,-1,0,0,1,1,-1,-1};
    // static int dy[]={0,0,1,-1,1,-1,1,-1};
    // PriorityQueue<Integer> que = new PriorityQueue<Integer>(); 
    //HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
 
    public  static void main(String[] args)   throws Exception, IOException{
     
        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
     
        // int n=sc.nextInt();
        // long n=sc.nextLong();
        // char c[][] = new char[h][w];
        // long a[] = new long [n];
        // for (int i=0; i<n; i++ ) {a[i]=sc.nextInt();}
        char c[] = sc.nextString().toCharArray();
        int l=c.length,ans=1000000,f=0;
        for (int i=0; i+1<l; i++ ) {
            if(c[i]!=c[i+1]){f++;ans=min(ans,max(i+1,l-(i+1)));}
        }
        out.println(f<1?l:ans);
        out.flush();
    }

    static void db(Object... os){
     
        System.err.println(Arrays.deepToString(os));
     
    }
     
    static boolean validpos(int x,int y,int r, int c){
        
        return x<r && 0<=x && y<c && 0<=y;
        
    }
     
    static boolean bit(long x,int k){
        // weather k-th bit (from right) be one or zero
        return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
    }    
}

class XY {
    int x,y,d;
    XY(int x, int y, int d) {
        this.x=x;
        this.y=y;
        this.d=d;
    } 
}
 
class P implements Comparable<P>{
    int x,y;
    P(int x, int y) {
        this.x=x;
        this.y=y;
    } 
      
    public int compareTo(P p){
        return -x + p.x;//des
    } 
}
 
class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  vi x(n),y(n); rep(i,n) cin >> x[i] >> y[i];
  int ans = INF;
  rep(i,n){
    rep(j,n){
      int cnt = 0;
      ll p = x[i]-x[j], q = y[i]-y[j];
      if(p != 0 || q != 0) rep(k,n) rep(l,n) if(x[k]-x[l] == p && y[k]-y[l] == q) cnt++;
      chmin(ans,n-cnt);
    }
  }
  cout << ans;
  cout << "\n";
  return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    cout << (double)((N+1)/2) / N << '\n';

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 256
h,w,d = gets.split(" ").map(&:to_i)

arr = Array.new(h*w+1,nil)

h.times do |i|
  input = gets.split(" ").map(&:to_i)
  input.each_with_index do |ip,j|
    arr[ip] = {i:i+1, j:j+1}
  end
end

q = gets.to_i

task = []
q.times do
  input = gets.split(" ").map(&:to_i)
  task << {L:input[0], R:input[1]}
end

# 1からh*wまでそれぞれ移動した場合のコスト
cost = Array.new(h*w+1,0)
(1+d).upto(h*w) do |i|
  cost[i] = cost[i-d] + (arr[i][:i] - arr[i-d][:i]).abs + (arr[i][:j] - arr[i-d][:j]).abs
end

task.each do |t|
  puts cost[t[:R]] - cost[t[:L]]
end

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

int main(void)
{
    int n;
    int i, t, ans;
    double h, w;
    double diff;
    
    while (1){
        scanf("%d", &n);
        
        if (n == 0){
            break;
        }
        
        diff = ans = 10000000;
        for (i = 0; i < n; i++){
            scanf("%d%lf%lf", &t, &h, &w);
            
            if (fabs(22 - w / ((h / 100) * (h / 100))) <= diff){
                if (fabs(22 - w / ((h / 100) * (h / 100))) == diff && t < ans){
                    ans = t;
                }
                else if (fabs(22 - w / ((h / 100) * (h / 100))) < diff){
                    ans = t;
                }
                diff = fabs(22 - w / ((h / 100) * (h / 100)));
            }
        }
        printf("%d\n", ans);
    }
    
    return (0);
}

Measured memory_bytes: 0
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	i, err := strconv.Atoi(readString())
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func vi(n int, args ...int) []int {
	res := make([]int, n)
	if len(args) == 0 {
		return res
	}
	v := args[0]
	if v == 0 {
		return res
	}
	for i := 0; i < n; i++ {
		res[i] = v
	}
	return res
}

func vvi(n int, args ...int) [][]int {
	res := make([][]int, n)
	m := n
	if len(args) > 0 {
		m = args[0]
	}
	v := 0
	if len(args) > 1 {
		v = args[1]
	}
	for i := 0; i < n; i++ {
		res[i] = vi(m, v)
	}
	return res
}

func main() {
	defer stdout.Flush()

	// readString() string
	// readInt() int
	// readIntSlice(n int) []int
	// readLengthAndSlice() []int

	n := readInt()
	x := make([]int, n)
	s := make([]int, n)
	for i := 0; i < n; i++ {
		a := readInt()
		x[i] = a
		s[i] = a
	}

	sort.Ints(s)
	small := s[len(s)/2-1]
	large := s[len(s)/2]

	for i := 0; i < n; i++ {
		if x[i] <= small {
			println(large)
		} else {
			println(small)
		}
	}
}


Measured memory_bytes: 8832
def main():
    x = int(input())

    A = list(map(int, input().split()))
    A = sorted(A)

    B = {}
    count = 1
    a = -1
    for i in A:
        if a == i:
            count += 1
        elif a >= 0:
            B.update({a:count})
            count = 1

        a = i

    B.update({a:count}) 

    count = 0
    for key in B.keys():
        val = B.get(key)
        diff = val - key

        if diff >= 0:
            count += diff
        else:
            count += val

    print (count)


if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()

Measured memory_bytes: 18548
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
#include <utility>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define cl(a) memset((a),0,sizeof(a))
#define all(n) n.begin(),n.end()
#define lson(x) ((x<<1))
#define rson(x) ((x<<1)|1)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod=1000000007;
const int inf=0x3f3f3f3f;
const double eps=1e-8;
const double pi=acos(-1.0);

int main()
{
    int a,b,c,sum;
    while(scanf("%d%d%d%d",&a,&b,&c,&sum)!=EOF)
    {
        int ans=0;
        rep(i,0,a)
            rep(j,0,b)
                rep(k,0,c)
        {
            if(i*500+j*100+k*50==sum)
                ans++;
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
import math
x=int(input())
# lhs=x/100
# pow2=1.01
# ans=math.log(lhs,pow2)
# print(math.ceil(ans))
amt=100
# x/100= (pow((1 + rate / 100), time)) 
for i in range(1,4000):
    amt=amt*1.01
    amt=math.floor(amt)
    if amt>=x:
        print(i)
        break

Measured memory_bytes: 63540
class Stack:
    MAX = 101

    def __init__(self):
        self.S = [None] * self.__class__.MAX
        self.top = 0

    def is_empty(self):
        return self.top == 0

    def is_full(self):
        return self.top >= self.__class__.MAX - 1

    def push(self, x):
        self.top += 1
        self.S[self.top] = x
        return x

    def pop(self):
        self.top -= 1
        return self.S[self.top + 1]


stack = Stack()
print([stack.push(eval("".join(map(str,[stack.pop(),s,stack.pop()][::-1]))))
       if s in["+","-","*"]else stack.push(int(s))for s in input().split()][-1])



Measured memory_bytes: 5612
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <random>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)

int caseId = 1;

void solve42(int W) {
    cout << "Case " << caseId << ":" << endl;
    int N;
    cin >> N;
    char c;
    int dp[1001] = {0}; // dp[i]: maxvalue under weight i
    REP(i,N) {
        int v, w;
        cin >> v >> c >> w;
        for(int j = W; j >= w; j--) {
            dp[j] = max(dp[j], dp[j-w] + v);
        }
    }
    int value = 0, weight = 0;
    REP(i,W+1) {
        if (value < dp[i]) {
            value = dp[i];
            weight = i;
        }
    }
    cout << value << endl << weight << endl;
}

int main() {
    int W;
    while (cin >> W, W) {
        solve42(W);
        caseId++;
    }
    return 0;
}

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

using namespace std;
 
#define debug(s) cerr << #s << " = " << s << '\n'
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define ff first
#define ss second
typedef long long ll;

int main() {
  int n;
  scanf("%d", &n);
  int ans = ceil(n/1000.)*1000 - n;
  printf("%d\n", ans);
}

Measured memory_bytes: 3752
#include<stdio.h>
int main(void){
    int A;
    int B;
    int C;
    int D;
    scanf("%d %d %d",&A,&B,&C);
    D = A-B;
    if(D <= C){
        printf("%d\n",C-D);
    }else{
        printf("0");
    }
    return 0;
} 



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const int INF = 1e9 + 10;

const int mod = 998244353;
struct mint {
    ll x;
    mint(ll x=0):x( (x%mod + mod) % mod ) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ( (x += a.x) >= mod ) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ( ( x += mod - a.x) >= mod ) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        ( x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

mint dp[400400];
int L[15], R[15];
int N, K;

int main() {
    cin >> N >> K;
    rep(i,K) cin >> L[i] >> R[i];
    dp[0] = 1;
    dp[1] = -1;
    rep(i,N) {
        rep(k,K) {
            dp[i+L[k]] += dp[i];
            dp[i+R[k]+1] -= dp[i];
        }
        dp[i+1] += dp[i];   
    }
    cout << dp[N-1] << endl;
}


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

long long dp[3005][3005];
const long long mod = 998244353;

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	dp[a][b] = 1;
	for(int i = a; i <= c; i++){
		for(int j = b; j <= d; j++){
			if(a < i) dp[i][j] = (dp[i][j] + dp[i - 1][j] * j) % mod;
			if(b < j) dp[i][j] = (dp[i][j] + dp[i][j - 1] * i) % mod;
			if(a < i && b < j){
				dp[i][j] -= dp[i - 1][j - 1] * (i - 1) * (j - 1);
				dp[i][j] = ((dp[i][j] % mod) + mod) % mod;
			}
		}
	}
	cout << dp[c][d] << endl;
	return 0;
}

Measured memory_bytes: 73980
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

string s;

int main(){
	int n;
	cin >> n;
	cin >> s;
	int tot = 0;
	for(int i = 0; i < n; i++)
		if(s[i] == 'R') tot++;
	int total = 0;
	for(int i = 0; i < tot; i++)
		if(s[i] == 'R') total++;
	cout << tot - total;
} 

Measured memory_bytes: 3484
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

ll n, m, ans;
struct node
{
	ll num, val;
	friend bool operator < (node a, node b)
	{
		return a.val < b.val;
	}
}q[100005];

int main()
{
	cin >> n >> m;
	for (ll i = 1; i <= n; i++)
	{
		cin >> q[i].val >> q[i].num;
	}
	sort(q + 1, q + n + 1);
	ll poll = 1;
	while (m > 0)
	{
		ll qua = min(m, q[poll].num);
		m -= qua;
		ans += qua * q[poll].val;
		poll++;
	}
	cout << ans << endl;
	return 0;
 } 

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// input
void input() {}
template <class Head, class... Tail>
void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

// ouls
void outs() {}
template <class Head, class... Tail>
void outs(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  outs(forward<Tail>(tail)...);
}

template <class T>
void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void outs(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// outl
void outl() {}
template <class Head, class... Tail>
void outl(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  outl(forward<Tail>(tail)...);
}

template <class T>
void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// outn
void outn() {}
template <class Head, class... Tail>
void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

// dump
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

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

  var(int, n, m);

  i64 loop = pow(2, m);
  dump(loop);

  i64 tmp = n - m;

  i64 norm = tmp * 100 + 1900 * m;
  norm *= loop;

  outl(norm);

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for(int i=0; i<N; i++){
     cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int A=0, B=0;
  for(int i=0; i<N; i++){
    if(i==0 || i % 2==0){
      A = A + a.at(i);
      //cout << A << endl;
    }
    else{
      B = B + a.at(i);
      //cout << B << endl;
    }
  }
  
  int SA;
  SA = A - B;
  cout << SA << endl;
}

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


int main(int argc, char const *argv[])
{
    int N;
    std::cin >> N;
    double a = (double)N/1.08;
    double b = ((double)N + 0.9999)/1.08;
    
    if ((int)a == a) {
        std::cout << a << std::endl;
        return 0;
    }
    if ( ((int)a) != ((int)b) ) {
        std::cout << (int)b << std::endl;
        return 0;
    }

    std::cout << ":(" << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int i, j, n, k, ans;
	cin >> n; cin >> k;

	ans = 1;
	for (i = 0; i < n; i++) {
		if (ans * 2 < ans + k)
			ans = ans * 2;
		else
			ans += k;
	}

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

Measured memory_bytes: 256
# AOJ 0589: Production
# Python3 2018.6.30 bal4u

dic = {}
n = int(input())
for i in range(n):
	a, p = input().split()
	if a in dic: dic[a] += int(p)
	else: dic[a] = int(p)
s = list(dic.items())
s.sort(key=lambda x:(len(x[0]),x[0]))
for x in s: print(*x)


Measured memory_bytes: 5620
q = int(input())
lr = [list(map(int,input().split()))for _ in range(q)]
maxr = 0
for i in range(q):
    maxr = max(maxr,lr[i][1])
res = 0
cnt = [0]*(maxr+3)
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
x = primes(maxr+1)
for i in range(1,maxr+1):
    if i%2 == 0:
        cnt[i] = res
        continue
    if i in x and (i+1)//2 in x:
        res+=1

    cnt[i] = res
for i in range(q):
    l = lr[i][0]
    r = lr[i][1]
    print(cnt[r]-cnt[l-1])


Measured memory_bytes: 69080
#include<iostream>
#include<iomanip>

using namespace std;
using ll=long long;

#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  ll a,b,k;
  cin>>a>>b>>k;
  a>k ? cout<<a-k<<" "<<b<<endl : k<a+b ? cout<<0<<" "<<b-(k-a)<<endl : cout<<0<<" " << 0<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 8008;
string s;
int X, Y;
vector<int> v[2];
bool f[N][N];
 
bool check(vector<int>& a, int M) {
    // for(auto x: a) cout << x << ' '; cout << endl << M << endl;
    if (M < 0) return false;
    else if (M == 0) return true;
    else if (M % 2) return false;
    M /= 2;
    int n = a.size();
    a.insert(a.begin(), 0);
    for(int i = 1; i <= M; i++)
        for(int j = 1; j <= n; j++) f[i][j] = false;
    for(int j = 0; j <= n; j++) f[0][j] = true;
 
    for(int i = 1; i <= M; i++) {
        for(int j = 1; j <= n; j++) {
            f[i][j] = f[i][j - 1];
            if (a[j] <= i) f[i][j] = f[i][j] || f[i - a[j]][j - 1];
        }
    }
    return f[M][n];
}
 
int main() {
    ios::sync_with_stdio(false); cin.tie(NULL);
    cin >> s >> X >> Y;
 
    int initialX = 0, i = 0;
    for(; i < s.length() && s[i] == 'F'; i++) initialX++;
 
    int cur = 0;
    for(int j = i; j < s.length(); j++) 
        if (s[j] == 'T') cur = 1 - cur, v[cur].push_back(0);
        else v[cur].back() ++;
 
    int sx = 0, sy = 0;
    for(auto x: v[0]) sx += x;
    for(auto y: v[1]) sy += y;
    bool ok1 = check(v[0], initialX + sx - X);
    bool ok2 = check(v[1], sy - Y);
 
    cout << (ok1 && ok2 ? "Yes" : "No");
 
    // for(auto x: v[0]) cout << x << ' '; cout << endl;
    // for(auto x: v[1]) cout << x << ' '; cout << endl;
}

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

int zyuu(int i) {
  int z=0;
  while (i>0) {
    z+=i%10;
    i/=10;
  }
  return z;
}

int main() {
  int N, A, B, S=0;
  cin >> N >> A >> B;
  for (int i=1; i<=N; i++) {
    if (zyuu(i)>=A && zyuu(i)<=B) {
      S+=i;
    }
  }
  cout << S << endl;
}


Measured memory_bytes: 3600
# Your code here!

K = gets.to_i
counter = 0

for i in 1..K
    for j in i..K
        if i % 2 == 0 && j % 2 != 0
            counter += 1
        elsif i % 2 != 0 && j % 2 == 0
            counter += 1
        end
    end
end
puts counter

Measured memory_bytes: 1788
//此程序使用了qt专属名称，请勿模仿。侵权必究！！！
//我真是太菜了啊……
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define ll long long
const ll N=100010;
int n,m,q,t=0,f[N][20];
vector<int> a[N];
bool vis[N];
int v[N],d[N],c[N];
inline int read()
{
	int sum=0,flag=1;
	char c;
	for(;c<'0'||c>'9';c=getchar())if(c=='-') flag=-1;
	for(;c>='0'&&c<='9';c=getchar())sum=(sum<<1)+(sum<<3)+c-'0';
	return sum*flag;
}
inline void dfs(int x,int y,int z)
{
	if(y<0)
	{
		return;
	}
	if(f[x][y])
	{
		return;
	}
	f[x][y]=z;
	for(int i=a[x].size()-1;i>=0;--i)
	{
		dfs(a[x][i],y-1,z);
	}
}
int main()
{
	n=read();
	m=read();
	for(int i=1;i<=m;++i)
	{
		int x=read(),y=read();
		a[x].push_back(y);
		a[y].push_back(x);
	}
	for(int i=1;i<=n;++i)
	{
		a[i].push_back(i);
	}
	q=read();
	for(int i=1;i<=q;++i)
	{
		v[i]=read();
		d[i]=read();
		c[i]=read();
	}
	for(int i=q;i;--i)
	{
		dfs(v[i],d[i],c[i]);
	}
	for(int i=1;i<=n;++i)
	{
		printf("%d\n",f[i][0]);
	}
	return 0;
}

Measured memory_bytes: 15480
#include <iostream>

using namespace std;

int main()
{
    int n,m,b,r=0;
    cin>>n;
    m=n;
    while(m!=0){
        b=m%10;
        r+=b;
        m/=10;
    }
    if(n%r==0)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


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

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

   int N,R; cin>>N>>R;
   int ans;
   if(N>=10){
      ans=R;
   }else{
      ans=R+100*(10-N);
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!



void solve(){
    int n;
    cin>>n;
    
    vector<vi> grid(2,vi (n,0));
    for(int i=0;i<2;i++){
        for(int j=0;j<n;j++){
            cin>>grid[i][j];
        }
    }
    
    for(int i=1;i<n;i++){
        grid[0][i]+=grid[0][i-1];
    }
    
    for(int i=n-1-1;i>=0;i--){
        grid[1][i]+=grid[1][i+1];
    }
    
    int ans=0;
    for(int i=0;i<n;i++){
        ans=max(ans,grid[0][i]+grid[1][i]);
    }
    cout<<ans<<endl;
}

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

Measured memory_bytes: 3672
N, K = map(int, input().split())
P = list(map(int, input().split()))
l = []

for i in range(N):
    l.append((P[i] + 1) / 2)

n = 0
for i in range(N):
    n += l[i]
    l[i] = n

ans = l[K - 1]
for i in range(N - K):
    ans = max(ans, l[i + K] - l[i])

print(ans)
# print(l)


Measured memory_bytes: 25060
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
#define MAX_N 250000
bool seen[MAX_N];
ll cost[MAX_N];

void dfs(int cur, const vector<vector<int>> &G) {
  seen[cur] = true;
  for (int x : G[cur]) {
    if (seen[x]) continue;
    cost[x] += cost[cur];
    dfs(x, G);
  }
  return;
}

int main() {
  int N, Q;
  cin >> N >> Q;
  vector<vector<int>> G(N);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  for (int i = 0; i < Q; i++) {
    int p, x;
    cin >> p >> x;
    cost[p - 1] += x;
  }

  dfs(0, G);
  for (int i = 0; i < N - 1; i++) {
    cout << cost[i] << " ";
  }
  cout << cost[N - 1] << endl;

  return 0;
}

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

const int mnx = 1e6 + 9;
const int mod = 1e9 + 7;

ll n;
ll a[mnx];
ll sum, b[mnx];

int main() {

cin >> n;

for(int i = 1; i <= n; i++){
    cin >> a[i];
    sum += a[i];
}

if(sum % ((n + 1) * n / 2) != 0) {
    cout << "NO" << endl;
    return 0;
}

b[1] = a[n] - a[1];

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

bool f = true;

for(int i = 1; i <= n; i++){
    if((b[i] + sum / ((n + 1) * n / 2)) % n != 0
    || (b[i] + sum / ((n + 1) * n / 2)) / n < 0){
            cout << "NO" << endl; return 0;
    }
}

cout << "YES" << endl;

return 0;
}


Measured memory_bytes: 5120
#include<stdio.h>

int main(){
	char buf[256];
	int X, A, B;
	int diff;
	
  	fgets(buf,256,stdin);
  	sscanf(buf,"%d %d %d",&X, &A, &B);
  	diff = B-A;
  	
  	if( diff <= 0){
		printf("delicious\n");
  	}
  	else if( diff > 0 && diff <= X ){
		printf("safe\n");
  	}
  	else if(diff > 0 && diff > X){
		printf("dangerous\n");
  	}
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){

	int A, B, N;
    cin >> N;
    if(N == 1){
    	cout << "Hello World";
    }
    else if(N == 2){
    	cin >> A >> B;
    	cout << A + B;
    }

  cout << endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;
ll H, N;

int main() {

    
    cin >> H >> N;
    ll ng = -1; ll ok = INF;

    vector<pi > AB;
    for(ll i = 0; i < N; i++){
        ll a, b;
        cin >> a >> b;
        AB.push_back(make_pair(a, b));
    }
    
    vector<ll > dp(19191919, INF);
    dp[0] = 0;

    for(ll i = 0; i <= H; i++){
        for(ll j = 0; j < N; j++){
            if(dp[i] == INF) continue;
            dp[i+AB[j].first] = min(dp[i+AB[j].first], dp[i] + AB[j].second);
        }
    }

    ll ans = INF;
    for(ll i = H; i < 191919; i++){
        ans = min(ans, dp[i]);
    }

    cout << ans << endl;

}

Measured memory_bytes: 150272
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
using llint = long long int ;

#define rep(i,c) for(int i = 0; i < (int)c; ++i)
// c 回繰り返す

const llint mod = 1000000007;
//mod　10^9 + 7


///////////////////////便利？な関数///////////////////////
llint Pow_Mod(llint n,llint p,llint m){
    //n^p mod　の繰り返し二乗法
    if(p==0) return 1%m;
    else if(p%2==0){
        llint kakeru = Pow_Mod(n,p/2,m);
        return kakeru*kakeru%m;
    }
    else return n%m*Pow_Mod(n,p-1,m)%m;
}

llint Conbi(llint x,llint y,llint m){
    //xCy mod を求める
    llint UP,DOWN;
    UP=DOWN=1%m;
    rep(i,y){
        UP=UP*(x-i)%m;
        DOWN=DOWN*(i+1)%m;
    }
    return UP*Pow_Mod(DOWN,m-2,m)%m;
    //mは素数がいい
}




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

    int ALL=Pow_Mod(2,n,mod);
    int AB=Conbi(n,a,mod)+Conbi(n,b,mod);

    cout<<((ALL-AB-1)%mod+mod)%mod<<endl;



    return 0;
}



Measured memory_bytes: 256
def PrimeFactorize(n):
    l = []
    for i in range(2, int(n ** 0.5) + 1):
        if i > n:
            break
        while n % i == 0:
            n //= i
            l.append(str(i))
    if n != 1:
        l.append(str(n))
    return l


n = int(input())
print(str(n) + ": " + " ".join(PrimeFactorize(n)))




Measured memory_bytes: 5632
k,n=map(int, input().split())
a=list(map(int,input().split()))
m=float('inf')
for i in range(n):
    if i==0:
        m=min(a[-1]-a[0],m)
        continue
    m=min(a[-1]-a[i]+k-a[-1]+a[i-1], m)
print(m)

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

using namespace std;
using ll=long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define chmin(mi, val) mi = min(mi, val)
#define INFL (long long)(4e18)

int main(void) {
  int L, R;
  cin >> L >> R;
  if (R - L > 2019) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = INFL;
  rep2(i, L, R) {
    rep2(j, i + 1, R + 1) {
      chmin(ans, (ll)i * j % 2019);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3652
while True:
    try:
        H, W = map(int, input().split())
        
        if H == 0 and W == 0:
            break;
        for i in range(H):
            if i == 0 or i == H-1:
                print('#'*W)
            else:
                print('#' + '.'*(W-2) + '#')
        print()
        
    except:
        break;


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

#define pb push_back
#define fi first
#define SZ(x) (int((x).size()))
#define se second
#define ll long long
#define pq priority_queue
#define MP make_pair
#define pii pair<int,int>
#define mod 1000000007
#define debug(x) cerr<<#x<<"="<<x<<'\n'

const int maxn=1e4+10;
const int maxm=1e6+10;

int n;
int a[maxn];
bool is_not_prim[maxm];
int id[maxm];
vector <int> prim;
int cnt[maxm];
ll power[100010][21];
ll res[maxn];

void init() {
	memset(is_not_prim,false,sizeof(is_not_prim));
	for (int i=2;i<maxm;i++) {
		if (!is_not_prim[i]) prim.pb(i);
		for (int j=0;j<SZ(prim)&&prim[j]*i<maxm;j++) {
			is_not_prim[prim[j]*i]=true;
			if (i%prim[j]==0) break;
		}
	}
	return;
}

ll calc(ll x,int y) {
	ll res=1;
	while (y>0) {
		if (y%2==1) (res*=x)%=mod;
		(x*=x)%=mod;
		y/=2;
	}
	return res;
}

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),res[i]=1ll;
	init();
	for (int i=0;i<SZ(prim);i++) id[prim[i]]=i;
	for (int i=1;i<=n;i++) {
		int cur=a[i];
		for (int j=0;prim[j]<=sqrt(cur)&&cur>1;j++) {
			int tmp=0;
			while (cur%prim[j]==0) cur/=prim[j],tmp++;
			cnt[j]=max(cnt[j],tmp);
		}
		if (cur!=1) cnt[id[cur]]=max(1,cnt[id[cur]]);
	}
	for (int i=0;i<SZ(prim);i++) {
		power[i][0]=1;
		for (int j=1;j<=20;j++) power[i][j]=(power[i][j-1]*(prim[i]))%mod;
	}
	int ans=0;
	for (int j=0;j<SZ(prim);j++) {
		if (cnt[j]==0) continue;
		for (int i=1;i<=n;i++) {
//			debug(cur);
			int tmp=0;
			while (a[i]%prim[j]==0) a[i]/=prim[j],tmp++;
			(res[i]*=power[j][cnt[j]-tmp])%=mod;
//			debug(i),debug(res[i]);
		}
	}
	for (int i=1;i<=n;i++) (ans+=res[i])%=mod;
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 23928
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

    vector<vi> dist(h, vi(w, INF));
    dist[0][0] = 0;

    queue<pint> que;
    que.push(make_pair(0, 0));

    // BFS
    while (!que.empty()) {
        auto pos = que.front();
        que.pop();

        int y = pos.first;
        int x = pos.second;

        rep(i, 4) {
            int next_y = y + dy[i];
            int next_x = x + dx[i];

            if (next_y >= 0 && next_y < h && next_x >= 0 && next_x < w) {
                if (s[next_y][next_x] == '.' && dist[next_y][next_x] == INF) {
                    dist[next_y][next_x] = dist[y][x] + 1;
                    que.push(make_pair(next_y, next_x));
                }
            }
        }
    }

    // ゴール到達不能
    if (dist[h-1][w-1] == INF) {
        cout << "-1" << endl;
        exit(0);
    }

    int res = 0;

    rep(i, h) rep(j, w) {
        if (s[i][j] == '.') res++;
    }

    res -= dist[h-1][w-1] + 1;

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a;
	int b;
	scanf("%d%d", &a, &b);	
	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else if(a==b){
		printf("a == b\n");
	}else{
		printf("An internal error has occured.\n");
	}
	return 0;
}

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

#define ll long long int
#define tinput int t; cin>>t; while(t--)
#define rep(i,n,s) for((i)=(s); (i)<(n); (i)++)

template <typename T>
T mini(T x, T y) { return (x<y)?x:y; }
template <typename T>
T maxi(T x, T y) { return (x>y)?x:y; }
ll M=1e9+7;

int main(){
  //  freopen("input2.txt", "r", stdin);
  //  freopen("output2.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n, i;
    cin>>n;
    ll a[n];
    rep(i,n,0) cin>>a[i];
    ll sum[n];
    sum[n-1]=a[n-1];
    for(i=n-2;i>=0;i--) { sum[i]=sum[i+1]+a[i]; }
    ll ans = 0;
    for(i=0;i<n-1;i++) {
        ll x=sum[i+1]%M;
        ll aux=a[i]*x;
        aux=aux%M;
        ans+=aux;
    }
    ans=ans%M;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 6788