akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var S = ReadLine();
            var N = S.Length;
            var left = new long[N];
            var right = new long[N];
            // RRRLを確認(Rにいるやつだけ)
            var cnt = 1L;
            for (var i = 1; i < N; ++i)
            {
                if ('R' == S[i]) ++cnt;
                if ('R' == S[i - 1] && 'L' == S[i])
                {
                    left[i] = cnt / 2;
                    left[i - 1] = (cnt + 1) / 2;
                    cnt = 0;
                    continue;
                }
            }
            // RLLLLを確認(Lにいるやつだけ)
            cnt = 1L;
            for (var i = N - 2; 0 <= i; --i)
            {
                if ('L' == S[i]) ++cnt;
                if ('R' == S[i] && 'L' == S[i + 1])
                {
                    right[i] = cnt / 2;
                    right[i + 1] = (cnt + 1) / 2;
                    cnt = 0;
                    continue;
                }
            }
            for (var i = 0; i < N; ++i)
                Write($"{right[i] + left[i]} ");
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 17416
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using pci = pair<char, int>;
using vpci = vector<pci>;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(int i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define Yes out("Yes")
#define No out("No")
#define NO out("NO")
#define YES out("YES")
#define INF 1e10;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define IfOut(condition,text) if((condition)){out(text);return 0;}
#define IfeOut(condition,itext,etext) if(condition){out(itext);return 0;}else{out(etext);return 0;}
#define beginend(vec) (vec).begin(),(vec).end()
#define pb(item) push_back(item)
#define removeAll(vec,deleg) auto itr=remove_if(beginend(vec),deleg);vec.erase(itr,vec.end());
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
ll manhattanDistance(ll x1, ll y1, ll x2, ll y2) { return (abs(x2 - x1) + abs(y2 - y1)); }
vector<ll> sieveOfEratosthenes(int max) {ll prime;double sqrtmax = sqrt(max);vector<ll> primeVec, searchVec;FOR(i, 2, max + 1) searchVec.push_back(i);do{prime = searchVec[0];primeVec.push_back(prime);auto itr = remove_if(beginend(searchVec), [=](ll x)->bool {return x%prime == 0; });searchVec.erase(itr, searchVec.end());} while (prime < sqrtmax);primeVec.reserve(primeVec.size() + searchVec.size());primeVec.insert(primeVec.end(), beginend(searchVec));return primeVec;}
bool isPrime(ll x) {if (x == 2) return true;if (x < 2 || x % 2 == 0) return false;ll i = 3;while (i <= sqrt(x)) {if (x%i == 0) return false;i += 2;}return true;}

vector<ll> getudoPrimes(ll max) {
	ll prime;
	double sqmax = sqrt(max);
	vector<ll> prvec, svec;
	svec.pb(6);
	for (ll i = 7; i < max+1; i+=7)
	{
		svec.pb(i + 1);
		svec.pb(i + 6);
	}
	do
	{
		prime = svec[0];
		prvec.pb(prime);
		removeAll(svec, [=](ll x)->bool {return x%prime==0; });

	} while (prime<sqmax);
	prvec.reserve(prvec.size() + svec.size());
	prvec.insert(prvec.end(), beginend(svec));
	return prvec;
}


int main() {
	vl query;
	int n;
	while (cin>>n,n!=1)
	{
		query.pb(n);
	}
	auto mm = max_element(beginend(query));
	auto prims = getudoPrimes(*mm);
	Foreach(i, query) {
		auto pri = prims;
		removeAll(pri, [=](ll x) {return i%x != 0; });
		cout << i << ":";
		Foreach(x, pri) cout << " " << x;
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3860
#include<bits/stdc++.h>
using namespace std;
int main() {
	int s; cin >> s;
	if (s == 4 || s == 2 || s == 1)cout << "4\n";
	else {
		for (int i = 2; ; i++) {
			if (s % 2)s = s*3+1;
			else s /= 2;
			if (s == 4 || s == 2 || s == 1) {
				cout << i + 3 << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const int INF = (1<<29);
int dist[10], c[10][10];

void bfs(int v){
    for(int i=0; i<=9; i++) dist[i] = INF;
    dist[v] = 0;

    queue<int> q;
    q.push(v);

    while(!q.empty()){
        int u = q.front(); q.pop();
        for(int i=0; i<=9; i++){
            if(dist[i] > dist[u]+c[u][i]){
                dist[i] = dist[u]+c[u][i];
                q.push(i);
            }
        }
    }
}

int main(){
    int H,W; cin >> H >> W;
    int a[H+1][W+1];
    vector<int> minv(10, 0);

    for(int i=0; i<10; i++) for(int j=0; j<10; j++) cin >> c[i][j];
    for(int i=1; i<=H; i++) for(int j=1; j<=W; j++) cin >> a[i][j];

    for(int i=0; i<=9; i++){
        bfs(i);
        minv[i] = dist[1];
    }

    int ans = 0;
    for(int i=1; i<=H; i++) for(int j=1; j<=W; j++) if(a[i][j] != -1) ans += minv[a[i][j]];

    cout << ans << endl;

}

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

int main() {
  int H,W;
  cin>>H>>W;
  vector<char> side(W+2,'#');
  for(int i=0;i<W+2;i++){
    cout<<side.at(i);
  }
  cout<<endl;
  for(int i=0;i<H;i++){
    vector<char> line(W+2,'#');
    for(int j=1;j<W+1;j++){
      cin>>line.at(j);
    }
    for(int j=0;j<W+2;j++){
      cout<<line.at(j);
    }
    cout<<endl;
  }
  for(int i=0;i<W+2;i++){
    cout<<side.at(i);
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  if(N<=999){
    printf("ABC");
  }else if(N==1000){
    cout << "ABD";
  }else if(N>=1001){
    printf("ABD");
  }

  return 0;
}


Measured memory_bytes: 256
# coding=utf-8

if __name__ == '__main__':
    l = list()

    for s in raw_input().split():
        if int(s) == 1:
            l.append(14)
        else:
            l.append(int(s))

    if l[0] < l[1]:
        print('Bob')
    elif l[1] < l[0]:
        print('Alice')
    else:
        print('Draw')


Measured memory_bytes: 2572
# -*- coding: utf-8 -*-
"""
C - Pyramid
https://atcoder.jp/contests/abc112/tasks/abc112_c

"""
import sys


def solve(N, positions):
    if N == 1:
        return positions[0]
    for cy in range(101):
        for cx in range(101):
            is_valid = True
            x, y, h = positions[0]
            ph = h + abs(cy-y) + abs(cx-x)
            for x, y, h in positions[1:]:
                hh = max(ph - abs(cy-y) - abs(cx-x), 0)
                if hh != h:
                    is_valid = False
                    break
            if is_valid:
                return (cx, cy, ph)
    for cy in range(101):
        for cx in range(101):
            is_valid = True
            x, y, h = positions[-1]
            ph = h + abs(cy-y) + abs(cx-x)
            for x, y, h in positions[:-1]:
                hh = max(ph - abs(cy-y) - abs(cx-x), 0)
                if hh != h:
                    is_valid = False
                    break
            if is_valid:
                return (cx, cy, ph)


def main(args):
    N = int(input())
    positions = [[int(i) for i in input().split()] for _ in range(N)]
    ans = solve(N, positions)
    print(*ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
#include <iostream>
#define REP(i, n) for(int i = 0; i < (n); i++)

using namespace std;
typedef long long ll;

ll pow(ll a, ll n)
{
  ll ret = 1;
  REP(i, n) ret *= a;
  return ret;
}

ll comb[51][51];
void initComb()
{
  REP(i, 51) {
    REP(j, 51) {
      if (i == 0 || j == 0 || i == j) comb[i][j] = 1;
      else comb[i][j] = comb[i-1][j] + comb[i-1][j-1];
    }
  }
}

int main()
{
  initComb();

  int N, P;
  cin >> N >> P;
  ll e = 0, o = 0;
  REP(i, N) {
    int A;
    cin >> A;
    if (A % 2 == 1) o++;
    else e++;
  }

  ll tmp = 0;
  if (P == 0)
    for (int i = 0; i <= o; i += 2) tmp += comb[o][i];
  else
    for (int i = 1; i <= o; i += 2) tmp += comb[o][i];
  cout << pow(2, e) * tmp << endl;

  return 0;
}

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

int main(){
  int N;
  cin >> N;
  string s;
  cin >> s;
  vector<int> W(N, 0);
  vector<int> E(N, 0);
  vector<int> count(N, 0);
  if(s[0] == 'W') W[0] = 1;
  else E[0] = 1;
  for(int i = 1; i < N; i++){
    if(s[i] == 'W'){
      W[i] = W[i - 1] + 1;
      E[i] = E[i - 1];
    }
    else{
      E[i] = E[i - 1] + 1;
      W[i] = W[i - 1];
    }
  }
  count[0] = E[N - 1] - E[0];
  count[N - 1] = W[N - 2];
  for(int i = 1; i < N - 1; i++){
    count[i] += W[i - 1] + E[N - 1] - E[i];
  }
  cout << *min_element(count.begin(), count.end()) << endl;
}


Measured memory_bytes: 4228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	ll n,a,b;
	cin>>n>>a>>b;
	if((a-b)%2){
		cout<<min(a-1,n-b)+(b-a)/2+1<<endl;
	}else{
		cout<<(b-a)/2<<endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll n;
  cin >> n;
  vec l(n);
  for(ll i=0;i<n;i++)cin >> l[i];

  // sort(l.begin(),l.end());
  // l.erase(unique(l.begin(),l.end()),l.end());

  // n=l.size();

  ll s=0;
  for(ll i=0;i<n;i++){
    for(ll j=i+1;j<n;j++){
      for(ll k=j+1;k<n;k++){
        if(l[i]+l[j]>l[k] && l[i]+l[k]>l[j] && l[j]+l[k]>l[i] && l[i]!=l[j] && l[i]!=l[k] && l[j]!=l[k])s++;
      }
    }
  }
  cout << s << endl;

}

Measured memory_bytes: 3628
N=int(input())
a=list(map(int,input().split()))
color=[0]*9
for i in range(N):
    if a[i]//400>=8:
        color[8]+=1
    else:
        color[a[i]//400]+=1
cnt=0
for i in range(8):
    if color[i]>0:
        cnt+=1
mx=cnt+color[8]
if cnt>0:
    mn=cnt
else:
    mn=1
print(mn,mx)

Measured memory_bytes: 38256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (N, M) = read!(usize, usize);
    let A = read![[usize]];

    let total_votes = A.iter().sum::<usize>();
    let popular_count = (0..N).filter(|&i| A[i] * 4 * M >= total_votes).count();
    let ok = popular_count >= M;

    println!("{}", if ok { "Yes" } else { "No" })
}


Measured memory_bytes: 4352
#!/usr/bin/env python3
import itertools
import sys


def solve(N: int, P: "List[int]", Q: "List[int]"):
    perm = list(itertools.permutations(range(1, N+1)))
    pi = perm.index(tuple(P))
    qi = perm.index(tuple(Q))
    ans = abs(pi - qi)
    print(ans)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    Q = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P, Q)

if __name__ == '__main__':
    main()


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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

void chmin(int &a, int b) { a = min(a, b); }

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

    int n, m; cin >> n >> m;
    vector<int> c(m);
    for (int i = 0; i < m; i++) cin >> c[i];

    vector<int> dp(n + 1, inf);
    dp[0] = 0;
    for (int i = 0; i < m; i++) {
        for (int j = c[i]; j <= n; j++) {
            chmin(dp[j], dp[j - c[i]] + 1);
        } 
    }
    cout << dp[n] << endl;
    return 0;
}


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

using namespace std;

int in(){ int a; cin >> a; return a; }
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main(){
  ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0); cerr.tie(0);
  string s, t;
  cin >> s >> t;
  cout << t + s << endl;
  return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define vll vector<ll>
#define G vector<vll >
#define gg vector<int>
#define F first
#define S second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define RFOR(i,a,b) for(int i=a;i>=b;i--)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define endl '\n'
#define clr(a) memset(a,0,sizeof(a))
#define all(x) x.begin(),x.end()
#define rll read_ll();
#define gc getchar
#define pc putchar
typedef long long ll;
template<class T> inline T lcm(T a,T b){
        return a/gcd(a,b)*b;
}
template<typename T>
void debug(T first) {
    cout << first << "\n";
}
template<typename T, typename... Args>
void debug(T first, Args... args) {
    cout << first << " ";
    debug(args...);
}


ll read_ll(){char c=gc();while((c<'0'||c>'9')&&c!='-')c=gc();ll ret=0;int neg=0;if(c=='-')neg=1,c=gc();while(c>='0'&&c<='9'){ret=10*ret+c-48;c=gc();}return neg?-ret:ret;}


int main()
{
int n;
    cin>>n;
    double logn = log10(n);
if(n==1) return !printf("1");
    // cout<<logn<<endl;
if(floor(log10(n)) == ceil(log10(n)))
{
    return !printf("10");
}
    int sum = 0;
while(n>0)
{
auto temp = n%10;
sum += temp;
n/=10;
}
printf("%d",sum);
return 0;
}

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

int main() {
  string s; cin >> s;
  sort(s.begin(), s.end());
  if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
long long int n,i;
long long int f[100001],a[100001];
int main()
{
    cin >>n;
    for (i=1;i<=n;i++) cin >>a[i];
    f[1]=0;
    f[2]=abs(a[1]-a[2]);
    for (i=3;i<=n;i++)
    {
        f[i]=min(f[i-1]+abs(a[i]-a[i-1]),f[i-2]+abs(a[i]-a[i-2]));
    }
    cout <<f[n];
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;

const int MOD = 1e9 + 7;

int main(){
	int n, m; cin >> n >> m; std::vector<long> a(n), b(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> b[i];
	
	std::vector<std::vector<long>> s(m + 1, std::vector<long>(400 + 1, 0));
	for(int i = 1; i <= 400; i++) s[0][i] = 1;
	for(int i = 1; i <= m; i++){
		for(int j = 1; j <= 400; j++){
			s[i][j] = s[i - 1][j] * j % MOD;
		}
	}
	
	for(int i = 0; i <= m; i++)
		for(int j = 0; j < 400; j++)
			(s[i][j + 1] += s[i][j]) %= MOD;
			
	
	std::vector<std::vector<long>> dp(m + 1, std::vector<long>(n + 1, 0)); dp[0][0] = 1;
	for(int i = 0; i <= m; i++){
		for(int j = 0; j < n; j++){
			for(int k = 0; k <= i; k++){
				long X = (s[k][b[j]] - s[k][a[j] - 1] + MOD) % MOD;
				
				dp[i][j + 1] += dp[i - k][j] * X % MOD;
				dp[i][j + 1] %= MOD;
			}
		}
	}
	
	cout << dp[m][n] << endl;
	return 0;
}


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

#define endl '\n'
#define ll long long
#define rint register int

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

int32_t main() {
	ios::sync_with_stdio(0); 		cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t, i, x, j, y, 	z, k, n;
	char c;
	cin >> n >> k;
	ll a[n];
	scan(a, n);
	sort(a, a + n);
	z = accumulate(a, a + min(n, k), 0);
	ce(z)
}

Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <queue>
#include <sstream>
using namespace std;
#define mp make_pair
#define pb push_back
#define re return
#define fi first
#define se second
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef vector<vi> vvi;
int n,m;
int a[100010];
vector<int>len;
int main() {
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a[i];
	}
	if(n>=m){
		cout<<'0'<<endl;
		return 0;
	}
	sort(a,a+m);
	for(int i=0;i<m-1;i++){
		len.push_back(a[i+1]-a[i]);
	}
	sort(len.begin(),len.end());
	int ans=0;
	for(int i=0;i<len.size()-n+1;i++){
		ans+=len[i];
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;

int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
    int p=0;
	// ユークリッドの方法
	while( m > n )
	{
        m = m/2;
        p+=1;
	}
	return p;
}//gcd

int main()
{
    long long a,b,tmp,r,x;
    cin >> a >> b;

    x=a*b;
     if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

    cout << x/b;

    
}

Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
using namespace std;
template<typename T> //整数或浮点数皆可使用,若要使用类(class)或结构体(struct)时必须重载大于(>)运算符
void bubble_sort(T arr[],int len)
{
    int i,j;
    for(i=0;i<len-1;i++)
    {
        for(j=0;j<len-1-i;j++)
            if(arr[j]>arr[j+1])
            swap(arr[j], arr[j + 1]);//所以加了句 using...and  template是干嘛的，，
    }
}
int main()
{
    int array[3];
    for(int i=0;i<3;i++)
    {
        scanf("%d",&array[i]);
    }
    int len=(int)sizeof(array)/sizeof(*array);
     bubble_sort(array,len);
     printf("%d %d %d\n",array[0],array[1],array[2]);
}



Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int a[200010];
int main(){
	int n;
	cin>>n;
	bool flag;
	int pos=1;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]==pos)pos++;
	}
	if(pos==1)cout<<-1<<endl;
	else if(pos!=1)cout<<n-(pos-1)<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll mod=1e9+7,INF=mod*mod*3;//M_PI
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define si(x) x.size()

ll N,M,Q;
vector<ll> V[505];

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N>>M>>Q;
rep(i,M){
	ll L,R;
	cin>>L>>R;
	V[L].pb(R);
}
rep1(i,N+1){
	if(si(V[i])) sort(all(V[i]));
}
rep(i,Q){
	ll ans=0;
	ll p,q;
	cin>>p>>q;
	for(ll j=p;j<=q;j++){
		ll k=upper_bound(all(V[j]),q)-V[j].begin();
		ans+=k;
	}
	cout<<ans<<endl;
}



}
	

Measured memory_bytes: 5972
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    s = str(readline().rstrip().decode('utf-8'))
    if len(s) == 2 and s[0] == s[1]:
        print(1, 2)
    else:
        for i in range(2, len(s)):
            ts = collections.Counter(s[i-2:i+1]).most_common()[0]
            if ts[1] == 2:
                print(i-1, i+1)
                exit()
        print(-1, -1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 44008
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BComparison solver = new BComparison();
        solver.solve(1, in, out);
        out.close();
    }

    static class BComparison {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            BigInteger a = in.bigints(), b = in.bigints();
            if (a.compareTo(b) > 0) {
                out.println("GREATER");
            } else if (a.equals(b)) {
                out.println("EQUAL");
            } else {
                out.println("LESS");
            }
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public BigInteger bigints() {
            return new BigInteger(string());
        }

    }
}



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

int main() {
  int N;
  cin >> N;
  if(N%2 == 1) {
  	cout << "No" << endl;
  }
  else{
  	string S;
    cin >> S;
    int count = 0;
    for(int i = 0; i < N/2; i++){
    	if(S[i] != S[N/2 + i]){
        	count ++;
        }
    }
    if(count == 0){
    	cout << "Yes" << endl;
    }
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef pair<int, int> pii;

int main() {
  int M1, D1, M2, D2;
  cin >> M1 >> D1 >> M2 >> D2;
  if (M1 == M2) {
    cout << "0" <<endl;
  } else {
    cout << "1" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a, b, c;
    int count = 0;
    int i;
    
    scanf("%d%d%d", &a, &b, &c);
    
    for(i=a; i<=b; i++){
        if(c%i==0){
            count++;
        }
    }
    
    printf("%d\n", count);
    
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;

int main(void) {
	int n, k;
	string s;
	cin >> n >> k >> s;

	s.at(k-1) += 'a' - 'A';

	cout << s << endl;

	return 0;
}



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

int main() {
	int n; cin >> n;
	vector<int>a1(n), a2(n);
	for (int i = 0; i < n; i++)cin >> a1[i];
	for (int i = 0; i < n; i++)cin >> a2[i];

	for (int i = 0; i < n - 1; i++)a1[i + 1] += a1[i];
	for (int i = 0; i < n - 1; i++)a2[i + 1] += a2[i];

	int ans = a1[0] + a2[n - 1];
	for (int i = 1; i < n; i++) {
		int tmp = a1[i] + a2[n - 1] - a2[i - 1];
		ans = max(ans, tmp);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
tmp = input().split()
a = int(tmp[0])
b = int(tmp[1])

n1 = a + b
n2 = a-b
n3 = a*b
if n1 > n2 and n1 > n3:
  print(n1)
elif n2 > n3:
  print(n2)
else:
  print(n3)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	long long a[n];
	for(long long i=0;i<n;++i)
	{
		scanf("%lld",&a[i]);
	}
	long long zero=0;
	for(long long i=0;i<n;++i)
	{
		if(a[i]==0) zero++;
	}
	if(zero>0) {
		printf("0\n");
		return 0;
	}
	long long prod=1;
	for(long long i=0;i<n;++i)
	{
		if(a[i]<=1000000000000000000/prod)
		{
			prod*=a[i];
		}
		else
		{
			printf("-1\n");
			return 0;
		}
	}
	printf("%lld",prod);
	return 0;

}

Measured memory_bytes: 4620
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){ 
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c == 17) cout << "YES"<< endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> hist(N);
    rep(i, N - 1) {
        cin >> A[i];
        hist[A[i] - 1]++;
    }
    rep(i, N) { cout << hist[i] << endl; }
    return 0;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K,x, sum=0;
  cin >> N>>K;
  for(int i=0;i<N;i++){
    cin >> x;
    if(K > 2*x){
      sum += 2*x;
    }else{
      sum += 2*(K-x);
    }
       
  }
  cout << sum << endl;
}



Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

static MOD: u64 = 1_000_000_007;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn binary_power(x: u64, n: u64) -> u64 {
    if n == 0 {
      return 1;
    }
    if n % 2 == 0 {
      return (binary_power(x, n / 2) % MOD).pow(2) % MOD;
    } else {
      return binary_power(x, n - 1) % MOD * x % MOD;
    }
}
  
fn inverse_mod(n: u64) -> u64 {
    binary_power(n, MOD-2)
}  

fn combination(n: u64, mut m: u64) -> u64 {
    // println!("{}, {}", n, m);
    if n < m {
        return 0;
    }
    
    if m > n - m {
        m = n - m
    }

    let mut ret = 1u64;
    for i in 0..m {
        ret %= MOD;
        ret *= n - i;        
    }
    ret %= MOD;

    let mut div = 1u64;
    for i in 1..(m+1) {
        div %= MOD;
        div *= i;
    }
    div %= MOD;
    ret * inverse_mod(div) % MOD
}

fn main() {
    let (n, k) = input_tuple();
    for i in 1..(k + 1) {
        println!("{}", combination(k - 1, i - 1) * combination(n - k + 1, i) % MOD);
    }
}


Measured memory_bytes: 4352
#pragma GCC optimize("Ofast")
#include <cstring>
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
    ll N, K, c, m1;
    int i = 1;

    cin >> N >> K;

    c = N % K;
    
    if(c==0) {
        cout << 0;
    } else {
        if(N>=K) {
            cout << K-c;
        } else {
            m1 = abs(N-K);
            if(N>m1) {
                cout << m1;
            } else {
                cout << N;
            }
        }
    }

}

Measured memory_bytes: 256
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N, M = map(int, input().split())
a = [0] + list(map(int, input().split()))
e = dd(list)
for _ in range(M):
  u, v = map(int, input().split())
  e[u].append(v)
  e[v].append(u)

res = 0
for x in range(1, N + 1):
  for y in e[x]:
    if a[x] <= a[y]: break
  else: res += 1
print(res)

Measured memory_bytes: 97320
#include <bits/stdc++.h>
using namespace std;
#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++)

int main() {
int N;
  cin >> N;
  cout << N*N*N<<endl;
}


Measured memory_bytes: 256
#define ll long long
#define MOD 1000000007
#define MOD2 998244353
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set2d(array, val, m, n) memset(array, val, sizeof(array[0][0]) * m * n);
#include <bits/stdc++.h>
using namespace std;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x %= p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll po(ll base, ll powerRaised)
{
    if (powerRaised != 0)
        return (base * po(base, powerRaised - 1));
    else
        return 1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    ll sum = 0;
    for (ll i = 1; i <= n; i++)
    {
        if (i % 3 != 0 && i % 5 != 0)
            sum += i;
    }
    cout << sum;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin>>n;
  int a=n/500;
  n=n%500;
  //cout<<n<<endl;
  int b=n/5;
  int t=0;
   t=(a*1000)+(b*5);
  cout<<t<<endl;
  
  
    return 0;
}

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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define all(x) begin(x),end(x)

#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

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

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

template<class T>
bool chmax(T &a, const 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 true;
    }
    return false;
}

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    for (;;) {
        int N, L; cin >> N >> L;
        if (N == 0) break;

        const int MAX = 86400;

        vi s(N+2), t(N+2), u(N+2);
        REP(i, N) {
            cin >> s[i+1] >> t[i+1] >> u[i+1];
        }
        t[0] = 0, s[N+1] = MAX;

        auto check = [&](double rate) {
            double tank = L;
            double record[2];
            REP(k, 2) {
                REP(i, N) {
                    tank = min(tank + (s[i + 1] - t[i]) * rate, (double) L);
                    tank = min(tank + (t[i + 1] - s[i + 1]) * (rate - u[i+1]), (double) L);
                    if (tank < -eps) {
                        return false;
                    }
                }
                tank = min(tank + (s[N + 1] - t[N]) * rate, (double) L);
                record[k] = tank;
            }

            if (record[0] > record[1] + eps) {
                return false;
            }
            return true;
        };

        double l = 0, r = 1e6;
        while ((r - l) > eps) {
            double m = (l + r) / 2;
            if (check(m)) {
                r = m;
            } else {
                l = m;
            }
        }
        cout << r << endl;
    }

    return 0;
}



Measured memory_bytes: 4044
#https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_d
#2019-02-10

#DP

L = int(input())
A = [int(input()) for i in range(L)]

DP = [[float("inf") for i in range(5)] for j in range(L+1)]
for i in range(5):
    DP[0][i] = 0

def cost(s, i, A):
    if s == 0 or s == 4:
        return A[i]
    elif s == 1 or s == 3:
        if A[i] > 0:
            if A[i]%2 == 0:
                return 0
            else:
                return 1
        else:
            return 2
    else:
        if A[i]%2 == 1:
            return 0
        else:
            return 1

for i in range(L):
    DP[i+1][0] = DP[i][0] + cost(0, i, A)
    DP[i+1][1] = min(DP[i][:2]) + cost(1, i, A)
    DP[i+1][2] = min(DP[i][:3]) + cost(2, i, A)
    DP[i+1][3] = min(DP[i][:4]) + cost(3, i, A)
    DP[i+1][4] = min(DP[i][:5]) + cost(4, i, A)



print(min(DP[L]))

Measured memory_bytes: 74092
X, N = map(int, input().split())
p = set(map(int, input().split()))
def main():
    if X not in p:
        print(X)
        return
    for i in range((N-1)//2+2):
        if X-i not in p:
            print(X-i)
            break
        elif X+i not in p:
            print(X+i)
            break

main()

Measured memory_bytes: 9180
import java.util.Scanner;

public class Main {

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

		int ans = Integer.MAX_VALUE;
		for(int i = 0; i < S.length() - 2; i++) {
			int tmp = Integer.parseInt(S.substring(i, i + 3));
			ans = Math.min(ans, Math.abs(tmp - 753));
		}
		System.out.println(ans);

	}
}

Measured memory_bytes: 23124
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int A[3][3], B[3][3];

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A[i][j];
    }
  }
  int N;
  cin >> N;
  for (int t = 0; t < N; t++) {
    int x;
    cin >> x;
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (A[i][j] == x) B[i][j] = 1;
      }
    }
  }
  bool res = false;
  for (int i = 0; i < 3; i++) {
    bool ok = true;
    for (int j = 0; j < 3; j++) ok &= B[i][j];
    res |= ok;
  }
  for (int j = 0; j < 3; j++) {
    bool ok = true;
    for (int i = 0; i < 3; i++) ok &= B[i][j];
    res |= ok;
  }
  {
    bool ok = true;
    for (int i = 0; i < 3; i++) ok &= B[i][i];
    res |= ok;
  }
  {
    bool ok = true;
    for (int i = 0; i < 3; i++) ok &= B[i][2 - i];
    res |= ok;
  }
  cout << (res ? "Yes" : "No") << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

ll N;
ll A,B,C,D;
const ll mod = 1e9+7;
ll fac[1005];
ll dp[1005][1005];

ll getpow(ll a, ll x) {
  ll res = 1;

  while(x > 0) {
    if(x & 1) res = res * a % mod;
    a = a * a % mod;
    x >>= 1;
  }
  return res;
}

ll get_rev(ll x) {
  return getpow(x,mod-2);
}

ll getP(ll n, ll r) {
  return fac[n] * get_rev(fac[n-r]) % mod;
}

int main() {
  cin >> N >> A >> B >> C >> D;
  fac[0] = 1;
  for(ll i = 1; i <= N; i++) {
    fac[i] = fac[i-1] * i % mod;
  }
  
  
  dp[A-1][0] = 1;

  for(ll i = A; i <= B; i++) {
    for(ll j = 0; j <= N; j++) dp[i][j] = dp[i-1][j];
    for(ll j = C; j <= D; j++) {
      for(ll k = i * j; k <= N; k++) {
	dp[i][k] = (dp[i][k] + (dp[i-1][k-i*j] * getP(k,i*j) % mod) * get_rev(getpow(fac[i],j) * fac[j] % mod) % mod) % mod;
      }
    }
  }

  cout << dp[B][N] << endl;
}
 
  


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
	int a,b; cin>>a>>b;
	for(int i=0;i<10000;i++){
		int A=i*8/100,B=i/10;
		if(A==a&&B==b){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 100000
#define X 1000000007
using namespace std;
int n,a[N+5],s[N+5];
I int QP(RI x,RI y) {RI t=1;W(y) y&1&&(t=1LL*t*x%X),x=1LL*x*x%X,y>>=1;return t;}
int main()
{
	RI i;for(scanf("%d",&n),i=1;i<=n;++i) scanf("%d",a+i);
	for(i=1;i<=n;++i) s[i]=(s[i-1]+QP(i,X-2))%X;
	RI ans=0;for(i=1;i<=n;++i) ans=(1LL*a[i]*(s[i]+s[n-i+1]-1)+ans)%X;
	for(i=1;i<=n;++i) ans=1LL*ans*i%X;return printf("%d\n",ans),0;
}

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

template <typename InputIterator>
typename InputIterator::value_type
summation(InputIterator first, InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int n;
  std::cin >> n;
  std::string s;
  std::cin >> s;
  int i = 0, j = 0;
  for (const auto k : s) {
    if (k == 'I') {
      i++;
    } else {
      i--;
    }
    j = std::max(j, i);
  }
  std::cout << j << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

const int N = 2e5 + 5;
int arr[N];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    ll res = 0;
    priority_queue<ld> pq;
    for (int i = 0; i < n; i++) {
        ld in;
        cin >> in;
        pq.push(in);
    }
    for (int i = 0; i < m; i++) {
        ld curr = pq.top();
        pq.pop();
        pq.push(curr / 2);
    }
    for (int i = 0; i < n; i++) {
        res += pq.top();
        pq.pop();
    }
    cout << res;
    return 0;
}


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

int main(){
    string n;
    cin >> n;
    int ans = 0;
    int tmp_ans = 0;
    rep(i, n.length()) {
        tmp_ans += n[i] - '0';
    }

    cout << max(tmp_ans, ((int)n.length()-1) * 9 + ( n[0] - '0' - 1 ) ) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main () {
    
    int H,W;
    
    while(1) {
        
        cin >> H >> W;
        
        if (H == 0 && W == 0) break;
        
        for (int i = 0 ; i < H ; i ++) {
            
            if (i == 0 || i == H-1) {
                
                for (int j = 0 ; j < W ; j ++) {
                    
                    cout << '#';
                    
                }
                
                // cout << endl;
                
                
            } else {
                
                for (int j = 0 ; j < W ; j ++) {
                    
                    if (j == 0 || j == W-1) {
                        
                        cout << '#';
                        
                    } else {
                        
                        cout << '.';
                        
                    }
                    
                    // cout << endl;
                    
                }
                
                // cout << endl;
                
            }
            
            cout << endl;
            
        }
        
        cout << endl;
        
        
        
    }
    
    return 0;
    
}





Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18

priority_queue<llint,vector<llint>,greater<llint>> que;
priority_queue<llint> q;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

llint n;
llint color[8];

void solve(){
	cin >> n;
	llint a[n];
	for(int i=0;i<n;i++) cin >> a[i];
	for(int i=0;i<8;i++) color[i]=0;

	llint cnt=0;
	llint y=0;
	for(llint x:a){
		if(x>=3200)y++;
		else if(x>=2800)color[0]++;
		else if(x>=2400)color[1]++;
		else if(x>=2000)color[2]++;
		else if(x>=1600)color[3]++;
		else if(x>=1200)color[4]++;
		else if(x>=800)color[5]++;
		else if(x>=400)color[6]++;
		else color[7]++;
	}
	for(llint c:color){
		if(c>0)cnt++;
	}

	llint mn=cnt;
	if(mn==0)mn++;
	llint mx=cnt+y;
	printf("%lld %lld\n",mn,mx);
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 256
while True:
    num = input()
    if num == 0: break

    mrx = []
    row = [0] * (num + 1)
    for i in range(num):
        mrx.append(map(int, raw_input().split()))
        mrx[i].append(sum(mrx[i]))
        for j in range(num + 1): row[j] += mrx[i][j]
    mrx.append(row)
    for i in mrx: print "".join([str(s).rjust(5) for s in i])

Measured memory_bytes: 4228
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nm = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var ai = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var sum = ai.Sum();
            var canSelect = false;
            var count = 0;
            for (var i = 0; i < ai.Length; i++)
            {
                if (ai[i] * 4 * nm[1] >= sum)
                {
                    count++;
                }
            }
            if (count >= nm[1]) canSelect = true;
            Console.WriteLine(canSelect ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13396
<?php
fscanf(STDIN, "%d %d", $k, $x);

$k--;

$start = ($x-$k < -1000000)? -1000000 : $x-$k;
$end = ($x+$k > 1000000)? 1000000 : $x+$k;

echo implode(' ', range($start, $end)), "\n";

Measured memory_bytes: 4728