akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
public class Main{
	static int X,Y,N;
	static int field[][];
	static boolean done[][];
	static final int[] dx = {1,0,-1,0};
	static final int[] dy = {0,1,0,-1};
	static int ans;
	static ArrayList<xy> S = new ArrayList<xy>();
	
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		

		String input[] = br.readLine().split(" +");
		Y = new Integer(input[0]);
		X = new Integer(input[1]);
		N = new Integer(input[2]);
		
		field = new int[X][Y];
		done = new boolean[X][Y];
		
		for(int y = 0; y < Y; y++){
			String str = br.readLine();
			for(int x = 0; x < X; x++){
				String a = str.substring(x, x+1);
				if(a.equals("S")){
					S.add(new xy(0,x,y,0));
				}else if(a.equals("X")){
					field[x][y] = -1;
				}else if(!a.equals(".")){
					S.add(new xy(new Integer(a),x,y,0));
				}
			}				
		}
		Collections.sort(S);
		
		ans = 0;
		for(int i = 0; i < S.size()-1; i++)
			ans += bfs(i);
		
		System.out.println(ans);
	}

	private static int bfs(int no) {
		ArrayDeque<xy> ad = new ArrayDeque<xy>();
		ad.add(S.get(no));
		xy end = S.get(no+1);
		
		for(int y = 0; y < Y; y++)
			for(int x = 0; x < X; x++)
				done[x][y] = false;
		
		while(!ad.isEmpty()){
			xy p = ad.poll();
			if(p.x == end.x & p.y == end.y)	
				return p.step;
			
			for(int i = 0; i < 4; i++){
				if(p.x+dx[i]<0 | p.x+dx[i]>=X) continue;
				if(p.y+dy[i]<0 | p.y+dy[i]>=Y) continue;
				if(done[p.x+dx[i]][p.y+dy[i]]) continue;
				if(field[p.x+dx[i]][p.y+dy[i]] < 0) continue;
				done[p.x+dx[i]][p.y+dy[i]] = true;
				ad.add(new xy(0, p.x+dx[i], p.y+dy[i], p.step+1));
			}
		}
		return -9999;
	}
}

class xy implements Comparable<xy>{
	int x,y,no;
	int step;
	xy(int no, int x, int y, int step){
		this.no = no;
		this.x = x;
		this.y = y;
		this.step = step;
	}
	public int compareTo(xy o) {
		return this.no - o.no;
	}
}

Measured memory_bytes: 79664
from collections import Counter
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, *l = map(int, read().split())

c = Counter(l)
sides = sorted([[x, y] for x, y in c.items() if y >= 2])
ans = 0

if len(sides) == 1:
    if sides[-1][1] >= 4:
        ans = sides[-1][0] ** 2
elif len(sides) >= 2:
    if sides[-1][1] >= 4:
        ans = sides[-1][0] ** 2
    else:
        ans = sides[-1][0]*sides[-2][0]
print(ans)

Measured memory_bytes: 22636
s = input()
n = len(s)
l = []
num = 1
for i in range(n-1):
  if s[i] != s[i+1]:
    l.append([s[i],num])
    num = 1
  else:
    num += 1
l.append([s[n-1],num])
now = 0
cnt = 0
ans = [0]*n
for lst in l:
  if lst[0] == "R":
    ans[now+lst[1]] += lst[1]//2
    ans[now+lst[1]-1] += lst[1] - lst[1]//2
  else:
    ans[now-1] += lst[1]//2
    ans[now] += lst[1] - lst[1]//2
  now += lst[1]
print(*ans)

Measured memory_bytes: 16624
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P; typedef unsigned long long int ull;
const ll mod = 1000000007;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecb vector<bool>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr) {
	if (firstItr < 0 || secondItr>int(str.size() - 1))return str;
	while (firstItr < secondItr) {
		swap(str[firstItr], str[secondItr]);
		firstItr++; secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str) {
	int itr = 0; std::string res;
	while (itr < int(str.size())) {
		char tmp = str[itr++];
		int length = 1;
		while (itr <int(str.size()) && str[itr] == tmp) { ++itr; ++length; }
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
std::string split(std::string str, size_t first_itr, bool isFront) {
	if (first_itr < 0 || first_itr > str.size()) {
		return str;
	}
	else {
		if (isFront) {
			std::string tmp;
			for (size_t i = 0; i < first_itr; i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
		else {
			std::string tmp;
			for (size_t i = first_itr; i < str.size(); i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
	}
}


bool dfs(int depth, str s) {
	/*if (depth == n) {
		ans.push_back(s);
		return false;
	}
	for (int i = 0; i < n; i++) {
		if (dfs(depth + 1, s + dic.at(i))) {
			return true;
		}
	}*/
	return false;
}


int main() {
	int n, m; cin >> n >> m;
	int ans = 0;
	ans += n * max(n - 1, 0) / 2;
	ans += m * max(m - 1, 0) / 2;
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

x, y, z = na()

print((x-z)//(y+z))

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k, x;
  cin >> k >> x;
  for (int i = (x - k + 1); i < (x + k); i++) {
    printf("%d ", i);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
if N == 2:
  ans = abs(A[0]-A[1])
else:
  import numpy
  s = numpy.cumsum(A)
  sA = s[-1]
  ar = numpy.abs(sA-s-s)
  ans = min(ar[1:N-1])
print(ans)

Measured memory_bytes: 24156
/**
*	created: 22.08.2020 01:09:31
**/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const int MAX = 100100;
const int INF = 1ll<<60;

int dp[110][MAX];

signed main() {
    int n, wei; cin >> n >> wei;
    vector<int> w(n), v(n);
    rep(i,n) cin >> w[i] >> v[i];
    rep(i,110) rep(j,MAX) dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i,n) rep(j,MAX) {
        if (j - v[i] >= 0) chmin(dp[i+1][j], dp[i][j - v[i]] + w[i]);
        chmin(dp[i+1][j], dp[i][j]);
    }
    int res = 0;
    rep(i,MAX) if (dp[n][i] <= wei) res = i;
    cout << res << endl;
}

Measured memory_bytes: 89680
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

#define MAX 100010
bool b[MAX] = {};

signed main() {
	for (int n, k; cin >> n >> k&&n;) {
		fill_n(b, n, false);
		rep(i, 0, k) {
			int a; cin >> a;
			b[a] = true;
		}
		vector<int> v;
		int tmp = 0;
		rep(i, 1, n + 1) {
			if (b[i])tmp++;
			else {
				v.push_back(tmp); tmp = 0;
			}
		}
		v.push_back(tmp);
		//dumpc(b);
		//dumpc(v);
		if (b[0]) {
			int ans = 0;
			rep(i, 1, v.size()) {
				ans = max(v[i - 1] + v[i] + 1, ans);
			}
			cout << ans << endl;
		}
		else {
			cout << *max_element(all(v)) << endl;
		}
	}
	return 0;
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;
using Real = double;
using Point = complex< Real >;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
//constexpr ll INF = 1001001001001001001LL;
constexpr double INF = 1e10;
constexpr Real EPS = 1e-10;
const Real PI = acos(-1);
using number = double;


int main() {
    int n, m; cin >> n >> m;
    vi l(m), r(m);
    vll c(m);
    vvi hsl(n), hsr(n);
    rep(k, m) {
        cin >> l[k] >> r[k] >> c[k];
        l[k]--; r[k]--;
        hsl[l[k]].pb(k);
        hsr[r[k]].pb(k);
    }

    vll dist(n);
    multiset<ll> st;

    rep(i, n) {

        //distの決定
        if (i != 0) {
            if (st.empty()) {
                cout << -1 << endl;
                return 0;
            }

            dist[i] = *st.begin();
            
        }

        //stへの追加削除
        for (auto k : hsl[i]) {
            st.insert(dist[l[k]] + c[k]);
        }
        for (auto k : hsr[i]) {
            auto itr = st.lower_bound(dist[l[k]] + c[k]);
            if(itr == st.end()){
                cout << -1 << endl;
                return 0;
            }
            else{
                st.erase(itr);
            }
        }

        //cout << st.size() << endl;

    }

    //for (auto x : dist) cout << x << endl;

    cout << dist[n-1] << endl;
    return 0;

}

Measured memory_bytes: 13312
import copy
N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]

patterns = [[0,0,0]]

def check(index, a, b, c, mp):
    # 取らない場合
    if index == N:
        # 終端
        if a > 0 and b > 0 and c > 0:
            cost = abs(A - a) + abs(B - b) + abs(C - c) + mp
        else:
            cost = 1000 * 1000 * 10
        return cost

    cost1 = check(index + 1, a , b, c, mp)
    if a == 0:
        cost2 = check(index + 1, a + L[index] , b, c, mp)
    else:
        cost2 = check(index + 1, a + L[index] , b, c, mp + 10)

    if b == 0:
        cost3 = check(index + 1, a, b + L[index], c, mp)
    else:
        cost3 = check(index + 1, a, b + L[index], c, mp+ 10)

    if c == 0:
        cost4 = check(index + 1, a , b, c + L[index], mp)
    else:
        cost4 = check(index + 1, a , b, c + L[index], mp+10)

    return min([cost1, cost2, cost3, cost4])

print(check(0, 0, 0, 0, 0))


Measured memory_bytes: 43228
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: usize = 1_000_000_007;
const INF: i64 = std::i64::MAX/2;

pub trait SetMinMax {
	fn setmin(&mut self, v: Self) -> bool;
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMinMax for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

fn solve() {
	let n = read!(usize);
	let a = read!([usize]);
	let mut num = vec![0 as i64;200001];
	for i in 0..n {
		num[a[i]] += 1;
	}
	let mut sum = 0;
	for &i in &num {
		sum += i*(i-1)/2;
	}
	for i in 0..n {
		let mut tmp = sum;
		tmp -= max(0,num[a[i]]-1);
		println!("{}", tmp);
	}
}

fn run() {
    solve();
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

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

  ll ans = 0;
  ll tmp = min(b, c);
  ans += 2 * tmp;
  c -= tmp;
  b -= tmp;

  if (b > 0)
    ans += b;
  else {
    tmp = min(c, a);
    ans += tmp;
    c -= tmp;
    if (c > 0) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $a, $b);
if($a != $b && $a == 1) {
    echo "Alice\n";
} elseif($a != $b && $b == 1) {
    echo "Bob\n";
} elseif($a > $b) {
    echo "Alice\n";
} elseif($b > $a) {
    echo "Bob\n";
} else {
    echo "Draw\n";
}

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  double ans=0.0,a;
  cin>>N;
  for(int i=1;i<=N;i++){
    cin>>a;
    ans+=1/a;
  }
  ans=1/ans;
  cout<<setprecision(16)<<ans<<endl;
}


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

using namespace std;


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, m, suma = 0;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int a;
        cin >> a;
        suma += a;
    }
    if (suma > n) cout << -1;
    else cout << n - suma;
    return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    if(n <= k) {
        cout << '0' << endl;
        return 0;
    }
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    sort(h.begin(), h.end());
    ll ans = 0;
    rep(i, n-k) ans += h[i];
    cout << ans << endl;
    return 0;
}

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

int main(){
 string a;
  char c;
cin>>a;
  int b=a.size(),ans=0;
  c=a[0];
  for(int i=1;i<b;i++){
    if(a[i]!=c){
      c=a[i];
      ans++;
    }
  }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#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-1; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
using namespace std;
typedef long long ll;
int main(){
    int h,n;
    cin>>h;
    cin>>n;
    vector<int>a(n);
    REP(i,n)cin>>a[i];
    REP(i,n)h-=a[i];
    if(h<=0)cout<<"Yes";
    else{
        cout<<"No";
    }
 cout<<endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
int Asc(const void* a,const void* b){return *((int*)a)<*((int*)b)?-1:1;}
int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
int main(void)
{
  int N=IN(),K=IN(),P[1000]={0},sum=0;
  for(int i=0;i<N;i++){P[i]=IN();}
  qsort(P,(size_t)N,sizeof(int),Asc);
  for(int i=0;i<K;i++){sum+=P[i];}
  return printf("%d\n",sum),0;
}

Measured memory_bytes: 1596
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int n;
    string s;
    cin >> n >> s;
    map<pair<string,string>,ll>mp;
    rep(i,1<<n){
        string a,b;
        rep(j,n){
            if(i&(1<<j)){
                a+=s[j];
            }else{
                b+=s[j];
            }
        }
        reverse(b.begin(),b.end());
        mp[make_pair(a,b)]++;
    }
    ll ans = 0;
    rep(i,1<<n){
        string a,b;
        rep(j,n){
            if(i&(1<<j)){
                a+=s[j+n];
            }else{
                b+=s[j+n];
            }
        }
        reverse(b.begin(),b.end());
        ans += mp[make_pair(b,a)];
    }
    cout << ans << endl;
}


Measured memory_bytes: 87040
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner cro=new Scanner(System.in);
int a[][]=new int[3][3];
int i,j;
for(i=0;i<3;i++) for(j=0;j<3;j++) a[i][j]=cro.nextInt();
if(a[0][0]-a[0][1]==a[1][0]-a[1][1]&&a[0][0]-a[0][1]==a[2][0]-a[2][1]&&a[0][2]-a[0][1]==a[1][2]-a[1][1]&&a[0][2]-a[0][1]==a[2][2]-a[2][1]&&a[0][0]-a[1][0]==a[0][1]-a[1][1]&&a[0][0]-a[1][0]==a[0][2]-a[1][2]&&a[2][0]-a[1][0]==a[2][1]-a[1][1]&&a[2][0]-a[1][0]==a[2][2]-a[1][2])
    System.out.println("Yes");
else System.out.println("No");
}   
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string a;
    cin>> a;
    if(a[0]==a[1] && a[2]==a[1] ||a[3]==a[1] && a[2]==a[1]){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdio.h>      /* printf */
#include <math.h> 
#include<iostream>
using namespace std;

int main () {
	int t,h,a;
	//scanf("%d", &t);
	scanf("%d %d", &h,&a);


	if(h % a == 0){
		cout<<h/a;
	}
	else{
		cout<<h/a +1;
	}
	
			
	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);
  int count=0;
  for(int j=1;j<=N;j++){
    if(j%2==1 && A.at(j-1)%2==1) count++;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 3640
# -*- coding: utf-8 -*-
H, W = map(int, input().split())
N = int(input())
an = list(map(int, input().split()))

out = [[0 for _ in range(W)] for _ in range(H)]
cnt = 0
for i,a in enumerate(an):
    for j in range(a):
        if (cnt//W)%2  == 0:
            out[cnt//W][cnt%W] = i + 1
        else:
            out[cnt//W][W - cnt%W - 1] = i + 1
        
        cnt += 1

for h in range(H):
    print(" ".join( map(str, out[h]) ))


Measured memory_bytes: 3564
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int s;
	cin>>s;
	switch(s){
		case 22:ce("Christmas Eve Eve Eve")break;
		case 23:ce("Christmas Eve Eve")break;
		case 24:ce("Christmas Eve")break;
		case 25:ce("Christmas")break;
		
	}
	
}

Measured memory_bytes: 256
import itertools

n = int(input())
w = list(map(int,input().split()))
acu = list(itertools.accumulate(w))
acu = [0] + acu
#print(acu)
ans = float("inf")
for i in range(1,n+1):
    ans = min(ans, abs(acu[i]-(acu[n]-acu[i])))
    #print(acu[i],acu[n]-acu[i])
print(ans)

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

struct sta{
  int now;
  int from;
  int c;
  float d;
};

int main(){
  int n;
  float r,th;
  cin >> n >> r >> th;
  vector<float> x(n),y(n);
  rep(i,n) cin >> x[i] >> y[i];
  vector<vector<float>> d(n,vector<float>(n));
  rep(i,n){
    rep(j,n){
      d[i][j]=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
    }
  }
  th=th*3.1415926535/180;
  vector<vector<vector<int>>> e(n,vector<vector<int>>(n));
  rep(i,n){
    rep(j,n){
      rep(k,n){
        if(i!=j&&i!=k){
          float a = d[j][k];
          float b = d[i][j];
          float c = d[i][k];
          if(acos((a*a-b*b-c*c)/2/b/c)<th) e[i][j].push_back(k);
        }
      }
    }
  }
  vector<vector<vector<float>>> dist(n,vector<vector<float>>(n,vector<float>(floor(r)+2,IINF)));
  priority_queue<sta,vector<sta>,function<bool(sta,sta)>>
    heap([](const sta &a, const sta &b){return a.d>b.d;});
  repp(i,1,n){
    heap.push({i,0,1,d[i][0]});
  }
  int ans=0;
  while(!heap.empty()){
    sta now = heap.top();
    heap.pop();
    if(dist[now.now][now.from][now.c]!=IINF) continue;
    if(now.d>r) continue;
    dist[now.now][now.from][now.c]=now.d;
    ans=max(ans,now.c);
    for(int &nx:e[now.now][now.from]){
      if(now.d+d[now.now][nx]>r) continue;
      if(dist[nx][now.now][now.c+1]!=IINF) continue;
      heap.push({nx,now.now,now.c+1,now.d+d[now.now][nx]});
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 20060
from collections import defaultdict
MOD = 2019
def main():
    S = input()
    dp = [0] * (len(S)+1)
    ex = 1
    for i in range(len(S)):
        dp[i+1] = (int(S[-1-i])*ex + dp[i]) % MOD
        ex *= 10
        ex %= MOD
    d = defaultdict(int)
    for i in range(len(S)+1):
        d[dp[i]] += 1
    output = 0
    for i in d.keys():
        output += (d[i] * (d[i]-1) // 2)
    print(output)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 16724
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
const int N = 3e3 + 5;
const long long INF = 1e18;
const int mod = 1e9 + 7;//1e9 + 7;//786433;//998244353;
const double Pi = acos(-1);
const int p = 510200;
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n, k;
long long l[100005], r[100005];
vector <int> Adj[100005];

signed main()
{
	Fastio();
	cin >> n;
	for(int i = 1; i <= n - 1; i++)
	{
		int u, v;
		cin >> u >> v;
		Adj[u].eb(v);
		Adj[v].eb(u);
	}
	for(int i = 1; i <= n; i++)
	{
		l[i] = -1e18;
		r[i] = 1e18;
	}
	queue <int> BFS;
	cin >> k;
	for(int i = 1; i <= k; i++)
	{
		int v;
		long long p;
		cin >> v >> p;
		l[v] = r[v] = p;
		BFS.push(v);
	}
	while(BFS.empty() == false)
	{
		int node = BFS.front();
		BFS.pop();
		for(auto x : Adj[node])
		{
			long long temp1 = max(l[x], l[node] - 1), temp2 = min(r[x], r[node] + 1);
			if(temp1 != l[x] or temp2 != r[x])
			{
				l[x] = temp1;
				r[x] = temp2;
				BFS.push(x);
			}	
		}	
	}
	for(int i = 1; i <= n; i++)
	{
		if(r[i] < l[i])
		{
			cout << "No";
			return 0;
		}
		for(auto x : Adj[i])
		{
			if(abs(l[x] - l[i]) != 1)
			{
				cout << "No";
				return 0;
			}
		}
	}
	cout << "Yes\n";
	for(int i = 1; i <= n; i++)
	{
		cout << l[i] << '\n';
	}
}

Measured memory_bytes: 10972
#include <iostream>
using namespace std;
int main(){
  int n, k, h[100000] = {0}, count = 0;
  cin >> n >> k;
  for(int i = 0; i < n; i++){
    cin >> h[i];
  }
  for(int i = 0; i < n; i++){
    if(h[i] >= k){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	if(a/3*3==a||b/3*3==b||(a+b)/3*3==a+b)cout<<"Possible"s;
	else cout<<"Impossible"s;
	cout<<"\n"s;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INT_MAX 2000000000
#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)

using namespace std;

int i, j, k;

int main() {
	int h[6], w[6];
	rep(i, 0, 6)
		cin >> h[i] >> w[i];
	int a[6];
	int flag = 0;
	rep(i, 0, 6)
		a[i] = 10000 * min(h[i], w[i]) + max(h[i], w[i]);
	sort(a,a+6);
	if ((a[0] == a[1]) && (a[2] == a[3]) && (a[4] == a[5])) {
		if ((a[0] / 10000 == a[2] / 10000) && (a[0] % 10000 == a[4] / 10000) && (a[2] % 10000 == a[4] % 10000)) {
			cout << "yes" << endl;
			flag = 1;
		}
	}
	if (flag == 0) {
		cout << "no" << endl;
	}
	return 0;
}

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



int main() 
{
  ll n; cin>>n;
  vector<ll> A(n);
  rep(i,n)
  {
    cin>>A.at(i);
  }
  vector<ll> b(0);
  if(n%2==0)
  {
    rep(i,n/2)
    {
      b.push_back(A.at(n-2*i-1));
    }
    rep(i,n/2)
    {
      b.push_back(A.at(2*i));
    }
    rep(i,n) {cout<<b.at(i)<<" ";} 
    cout<<endl;
    return 0;
  }
  rep(i,(n+1)/2)
  {
    b.push_back(A.at(n-2*i-1));
  }
  rep(i,(n-1)/2) {b.push_back(A.at(2*i+1));}
  rep(i,n) {cout<<b.at(i)<<" ";}
  cout<<endl;
  return 0;
}

Measured memory_bytes: 5488
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const s = input[0][0];

  return s.replace(/,/g, " ");
};

console.log(main(read()));


Measured memory_bytes: 29628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=50001,INF=1<<30;

int main(){

    int N;cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    
    vector<int> dp(N+1,INF);
    
    for(int i=0;i<N;i++){
        auto it=lower_bound(all(dp),A[i]);
        *it=min(*it,A[i]);
    }
    
    for(int i=0;i<N+1;i++){
        if(dp[i]==INF){
            cout<<i<<endl;
            break;
        }
    }
}




Measured memory_bytes: 3544
#include<stdio.h>

int main(void) {
    
    int n;
    int i, j;
    int a, b;
    
    scanf("%d", &n);
    
    for(i = 1; i <= n; i++) {
        if(i % 3 == 0) {
            printf(" %d", i);
        }
        else if(i % 3 != 0) {
            a = i;
            for(j = 1; j <= 3; j++) {
                if(a % 10 == 3) {
                    printf(" %d", i);
                    break;
                }
                else {
                    b = a / 10;
                    if(b == 3) {
                        printf(" %d", i);
                        break;
                    }
                    else {
                        a = b;
                    }
                }
            }
        }
    }
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
vector<int> num;
vector<int> change;
int qnum;
int main(){
	int n, rd, mx = 0, last;
	scanf("%d", &n);
	for(int i = 0; i < n; ++i){
		scanf("%d", &rd);
		num.push_back(rd);
	}
	sort(num.begin(), num.end());
	change.push_back(0);
	last = num[0];
	int sz = num.size();
	for(int i = 0; i < sz; ++i){
		if(num[i] != last){
			last = num[i];
			change.push_back(i);
		}
	}
	num.push_back(INT_MAX);
	for(int i = 0; i < 4; ++i) change.push_back(sz);
	sz = change.size();
	qnum = num[0];
	for(int i = 0; i < sz - 2; ++i){
		int st = change[i], ed = change[i+1];
		qnum = num[change[i]];
		if (num[change[i+1]] - qnum <= 2)
			ed = change[i+2];
		if (num[change[i + 2]] - qnum <= 2)
			ed = change[i + 3];
		mx = max(mx, ed - st);
	}
	printf("%d\n", mx);
}

Measured memory_bytes: 1144
object Main extends App {
  val ss = io.StdIn.readLine.split('/')

  val year = ss(0).toInt
  val month = ss(1).toInt
  val day = ss(2).toInt

  val out = (year,month,day) match {
    case (2019,m,_) if m <= 4 => "Heisei"
    case (2019,m,_) => "TBD"
    case (y,_,_) if y > 2019 => "TBD"
    case _ => "Heisei"
  }

  println(out)
}


Measured memory_bytes: 25284
#include <stdio.h>

int gcd(int a, int b) {
  int t;
  while(b) {
    t = a % b;
    a = b;
    b = t;
  }
  return a;
}

int main(void) {
  int i, j, k, n, m, ans = 0;
  scanf("%d%d", &n, &m);
  int a[2 * n];
  for(i = 0; i < n; ++i) scanf("%d", &a[i]);
  for(i = 0; i < n; ++i) a[i + n] = a[i];
  for(i = 0; i < n; i += gcd(n, m)) {
    int max = 0, min = 100;
    for(j = 0; j < m; ++j) {
      if(max < a[i + j]) max = a[i + j];
      if(min > a[i + j]) min = a[i + j];
    }
    ans += max - min;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2752
n,k=map(int,input().split())
p = list(map(int,input().split()))

s = 0
a = sum(p[:k])
for i in range(n-k+1):
    if i != 0:
        a = a-p[i-1]+p[i+k-1]
    if a > s:
        s = a
        
print((s+k)/2)

Measured memory_bytes: 24548
#include <iostream>
#include <string>
#include <list>
using namespace  std;

struct StDtl
{
  int m_iHeight;
  int m_iArea;

  StDtl(int a_iHeight) :
    m_iHeight(a_iHeight), m_iArea(0)
  { }

  ~StDtl() { }
};

struct StSum
{
  bool m_bSumOK;
  int m_iHeight;
  int m_iArea;

  StSum(bool a_bSumOK, int a_iHeight, int a_iArea) :
    m_bSumOK(a_bSumOK), m_iHeight(a_iHeight), m_iArea(a_iArea)
  { }

  ~StSum() { }

};

void fnCrossSectAreaSet(list<StDtl> &a_rltStDtl, list<StSum> &a_rltStSum)
{
  string sCrossSect;
  int iHeight = 0;
 
  cin >> sCrossSect;

  for (int i = 0; i < sCrossSect.size(); i++)
  {
    for (auto itltStDtl = a_rltStDtl.begin(); itltStDtl != a_rltStDtl.end(); ++itltStDtl)
    {
      itltStDtl->m_iArea++;
    }

    if (sCrossSect.at(i) == '\\')
    {
      StDtl oDtl(iHeight);
      a_rltStDtl.push_back(oDtl);
      iHeight--;
    }
    else if (sCrossSect.at(i) == '/')
    {
      iHeight++;
      bool bSumOK;
      int iSum = 0;

      if (a_rltStDtl.size() > 0)
      {
        iSum = a_rltStDtl.back().m_iArea;
        a_rltStDtl.pop_back();

        if (a_rltStDtl.size() == 0)
          bSumOK = false;
        else
          bSumOK = true;

        for (auto itltStSum = a_rltStSum.begin(); itltStSum != a_rltStSum.end();    )
        {
          if (itltStSum->m_bSumOK  == true   &&
              itltStSum->m_iHeight < iHeight)
          {
            iSum += itltStSum->m_iArea;
            itltStSum = a_rltStSum.erase(itltStSum);
            continue;
          }
          itltStSum++;
        }

        StSum oSum(bSumOK, iHeight, iSum);
        a_rltStSum.push_back(oSum); 
      }
      else
        for (auto itltStSum = a_rltStSum.begin(); itltStSum != a_rltStSum.end(); ++itltStSum)
          itltStSum->m_bSumOK = false;
    }
  }
}

void  fnCrossSectAreaGet(const list<StSum> &a_cnrltStSum)
{
  int iArea = 0;
  for (auto itltStSum = a_cnrltStSum.begin(); itltStSum != a_cnrltStSum.end(); ++itltStSum)
    iArea += itltStSum->m_iArea;

  cout << iArea << endl;
  cout << a_cnrltStSum.size();
  if (a_cnrltStSum.size() > 0)
  {
    cout << " ";
    for (auto itltStSum = a_cnrltStSum.begin(); itltStSum != a_cnrltStSum.end(); ++itltStSum)
    {
      if (itltStSum != a_cnrltStSum.begin()) cout << " ";
      cout << itltStSum->m_iArea;
    }
  }
  cout << endl;
}

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

  list<StDtl> ltStDtl;
  list<StSum> ltStSum;

  fnCrossSectAreaSet(ltStDtl, ltStSum);
  fnCrossSectAreaGet(ltStSum);

  return 0;
}

Measured memory_bytes: 1840
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
        int b = int.Parse(input[2]);
//        string temp = ReadLine();
//        int a = int.Parse(ReadLine());
        if(Abs(n-m)<Abs(n-b)){
            WriteLine("A");
        }else{
            WriteLine("B");
        }
    }
}

Measured memory_bytes: 11220
n = gets.to_i
cnt = 0
n.times do
  d1, d2 = gets.split(' ').map(&:to_i)
  if d1 == d2
    cnt += 1
  else
    cnt = 0
  end
  if cnt == 3
    puts 'Yes'
    exit
  end
end

puts 'No'


Measured memory_bytes: 14332
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード

//ループ
#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++) //最初の数値を指定したループ

//型名省略
typedef long long ll;
double tmp;

using namespace std;

int main(){
    string tmp_money;
    char c;
    ll money, thousand, five, tmp, happy;

    cin >> tmp_money;
    REP(i, tmp_money.length()){
        c = tmp_money[i];
        if(isdigit(c)==0){
            //cout << "not digit:" << c << isdigit(c);
            cout << 0;
            return 0;
        }
    }

    money = stoll(tmp_money);
    
    if(money<0 || money>1000000000){
        //cout << "X error:" << money;
        cout << 0;
        return 0;
    }

    if(money==0){
        happy = 0;
        cout << happy; 
    }else{
        thousand = money/500;
        tmp = money - thousand*500;

        if(tmp==0){
            happy = 1000*thousand;
            cout << happy;
        }else{
            five = tmp/5;
            happy = 1000*thousand+5*five;

            //cout << "500:" << thousand << "tmp:" << tmp <<"5:" << five << "happy:" << happy;

            cout << happy;
        }
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
wcnt = [0] * (n + 2)
ecnt = [0] * (n + 2)
for i in range(n):
  if s[i] == 'W':
    wcnt[i + 1] = wcnt[i] + 1
  else:
    wcnt[i + 1] = wcnt[i]
for i in range(n):
  if s[-(i + 1)] == 'E':
    ecnt[-(i + 2)] = ecnt[-(i + 1)] + 1
  else:
    ecnt[-(i + 2)] = ecnt[-(i + 1)]
#print(wcnt)
#print(ecnt)
lst = [wcnt[i - 1] + ecnt[i + 1] for i in range(1, n + 1)]
#print(lst)
print(min(lst))

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

int main(){
	int n,m;
	cin >> n >> m;
	int* broken = new int[n+1];
	long* step = new long[n+1];
	for(int i=0; i<n;i++){
		broken[i] = 0;
		step[i] = 0;
	}
	int tmp;
	for(int i=0; i<m; i++){
		cin >> tmp;
		broken[tmp] = 1;
	}
	step[0] = 1;
	if(broken[1] == 1) step[1] = 0;
	else step[1] = 1;
	for(int i=2; i<=n; i++){
		if(broken[i] == 1) step[i] = 0;
		else step[i] = step[i-1] + step[i-2];
		if(step[i] > 1000000007) step[i] %= 1000000007;
	}
//	for (int i = 0;i<=n ;i++){
//		cout << step[i] << endl;
//	}
	cout << step[n] << endl;
	return 0;
}
	


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

const int N = 1e6 + 5;
const int Mod = 1e9 + 7;

int n;
ll ans, f[N], g[N];

int main() {
	cin >> n;
	if (n == 1) {
		cout << "1";
		return 0;
	}
	f[0] = 1;
	g[1] = 1;
	g[2] = -1;
	g[3] = 1;
	g[n]++;
	for (int i = 1; i <= n; i++) {
		g[i] += g[i - 1];
		g[i] %= Mod;
		f[i] = g[i];
		g[i + 1] += f[i];
		g[i + 1] %= Mod;
		g[i + 2] -= f[i];
		g[i + 2] %= Mod;
		g[i + 3] += f[i];
		g[i + 3] %= Mod;
		if (i <= n - 2) g[n] += f[i] * (i + 1) % Mod; 
		g[n] %= Mod; 
	}
	ans = f[n];
	ans += f[n - 1] * (n - 1);
	ans %= Mod; 
	for (int i = 0; i < n - 1; i++) {
		ans += f[i] * (n - 1) % Mod * (n - 1) % Mod;
		ans %= Mod; 
	}
	//ans++;
	ans %= Mod;
	ans += Mod;
	ans %= Mod; 
	//for (int i = 1; i <= 5; i++) cout << g[i] << "/"; cout << endl;
	//for (int i = 1; i <= n; i++) cout << f[i] << "/";
	cout << ans;
}



Measured memory_bytes: 15872
s = input()

for bit in range(1 << 3):
    ans = int(s[0])
    f = s[0]
    
    for i in range(3):
        if bit & (1 << i):
            ans += int(s[i + 1])
            f += "+"
        else:
            ans -= int(s[i + 1])
            f += "-"
        f += s[i + 1]

    if ans == 7:
        print(f + "=7")
        exit()

Measured memory_bytes: 3060
open System

[<EntryPoint>]
let main argv =
    
    let inputArray = stdin.ReadLine().Split(' ') |> Array.toList

    let x = int inputArray.[0]
    let y = int inputArray.[1]
    let z = int inputArray.[2]

    printfn "%d %d %d" z x y

    0 // return an integer exit code


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

using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s,t;//testcases
    cin>>s>>t;
    for(int i=0;i<(int)s.length();++i){
		if(s[i]!=t[i]){
			cout << "No";
			return 0;
		}
	}
	if((int)t.length()!=(int)s.length()+1){
		cout << "No";
		return 0;
	}
	cout <<"Yes";
	return 0;
}



Measured memory_bytes: 3612
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	int N, W;
	cin>>N>>W;
	vector<int> v(N);
	vector<int> w(N);
	REP(i, N) {
		cin>>v[i]>>w[i];
	}
	vector<vector<int> > dp(N + 1, vector<int>(W + 1));
	REP(i, N + 1) {
		REP(j, W + 1) {
			if(i == 0 || j == 0) dp[i][j] = 0;
			else if(j < w[i - 1]) dp[i][j] = dp[i - 1][j];
			else {
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
			}
		}
	}
	cout<<dp[N][W]<<endl;
}

Measured memory_bytes: 6824
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////




int main() {

	ll N;
	string S;

	cin >>S;

	N = S.size();

	ll r = 0;
	ll b = 0;

	rep(i, N) {
		if (S[i] == '0') { r++; }
		else { b++; }
	}


	cout << N - abs(r - b);

	system("PAUSE");
}

Measured memory_bytes: 760
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

int gcd(int a, int b) {return b != 0 ? gcd(b, a % b) : a;}//最大公約数

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    vector<int> a(n);
        rep(i,n) cin>>a.at(i);
    queue<int> que;
    que.emplace(0);
    int gc=a[0];
    REP(i,1,n){
        int x=gcd(gc,a[i]);
        if(gc==x) continue;
        gc=x;
        que.emplace(i);
    }
    int ans=1;
    while(!que.empty()){
        int x=que.front();
        que.pop();
        bool f=1;
        rep(i,n){
            if(i==x) continue;
            if(f){
                gc=a[i];
                f=0;
            }
            else{
                gc=gcd(gc,a[i]);
            }
        }
        ans=max(ans,gc);
    }
    cout<<ans<<endl;
}
//./problem.exe

Measured memory_bytes: 640
#include <iostream>
using namespace std;
bool isPrime[10000000];

int main(){
    int n,m;
    while(cin>>m>>n,n){
        fill(isPrime,isPrime+10000000,true);
        for(int i=0;i<m;i++) isPrime[i]=false;
        for(int i=m;i<10000000;i++){
            if(isPrime[i]){
                for(int k=2;i*k<10000000;k++){
                    isPrime[i*k]=false;
                }
            }
        }
        for(int i=0;i<10000000;i++){
            if(isPrime[i]){
                if(!n){
                    cout<<i<<endl;
                    break;
                }else{
                    n--;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 12852
using System;

namespace question4
{
    class Program
    {
        static void Main(string[] args)
        {

            int flag = 1;

            int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');
            string[] ans = str;
            int half = (n / 2) + 1;

            /*
            for (int i = (n-1); i >=half; i--)
            {
                ans[i] = str[i];
            }
            for (int i = n - 1; i >= 0; i--)
            {
                if (i > (n / 2 - 1))
                {
                    ans[i] = str[i];
                }
                else
                {
                    ans[i] = (int.Parse(str[i]) ^ int.Parse(str[(i + 1) * 2 - 1])).ToString();

                }

            }
            
            */
            for (int i = n; i > 0; i--)
            {
                int delta = (n / i);
                int count = 0;
                for (int j = 2; j < (delta + 1); j++)
                {
                    count += int.Parse(ans[i * j - 1]);

                }
                ans[i - 1] = (count%2 ^ int.Parse(str[i - 1])).ToString();

            }
            int m = 0;
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            for (int i = 0; i < n; i++)
            {
                if (ans[i] == "1")
                {
                    m += 1;
                    sb.Append((i + 1).ToString() + " ");
                }
            }
            /*
            for (int i = 1; i < (n/2+1); i++)
            {
                int delta = (n / i);
                int count = 0;
                for (int j=1;j< (delta+1); j++)
                {
                    count += int.Parse(ans[i * j-1]);

                }
                if (count%2 != int.Parse(str[i-1])) flag = 0;                
            }
            */
            if (flag == 1)
            {
                Console.WriteLine(m);
                if (m!=0) Console.WriteLine(sb.ToString());

            }
            else Console.WriteLine("-1");
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 33876
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll ans=7;
	rep(i,0,3){
		char c;
		c=getchar();
		if(c=='o')ans++;
	}
	printf("%lld",ans*100);
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    int H, W;
    cin >> H >> W;
    string abc = "ABCDEFGHIJKLMNOPQRSTUVWZXYZ";
    for (int i=0; i<H; i++){
        for (int j=0; j<W; j++){
            string s;
            cin >> s;
            if (s == "snuke"){
                cout <<abc[j] << i+1 << endl;
                exit(0);
            }
        }
    }
}

Measured memory_bytes: 256