akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007;
int N;
ll K;
vector<int> T[100005];
bool Used[100005];

ll dfs(int n, int f){
  ll c;
  if (f == -1) c=K-1;
  else c = K-2;
  if (K < T[n].size()) return 0;
  ll cn = 1;
  for (auto e: T[n]){
    if (e == f) continue;
    cn *= c;
    c--;
    cn%=MOD;
  }
  for (auto e: T[n]){
    if (e == f) continue;
    cn *= dfs(e, n);
    cn %= MOD;
  }
  return cn;
}

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

  cin >> N >> K;
  int a, b;
  rep(i, N-1){
    cin >> a >> b;
    a--, b--;
    T[a].push_back(b);
    T[b].push_back(a);
  }
  ll ans = K*dfs(0, -1);
  ans %= MOD;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 10368
import java.util.Scanner;


public class Main {


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ


		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		
		int count = 0;
		int res = 0;
		
		for(int i =0;i<S.length();i++) {
			char c = S.charAt(i);
			if(c=='A'||c=='G'||c=='C'||c=='T') {
				count++;
			}else {
				res = Math.max(res, count);
				count=0;
			}
		}
		
		res = Math.max(res, count);
		System.out.println(res);


		}


}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void print(ll x,ll k,ll d){
	if(k&1){
		cout<<min(abs(x-d),abs(x+d));
		}
	else cout<<abs(x);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll x,k,d;
	cin>>x>>k>>d;
	if(abs(x)<=d){
		if(k&1){
			cout<<min(abs(x-d),abs(x+d));
		}
		else cout<<abs(x);
	}
	else{
		ll n=abs(x)%d;
		if(k<abs(x)/d){
			if(x<0) cout<<abs(x+(k*d));
			else cout<<x-(k*d); 
		}
		else{
			print(n*((x<0)?-1:1),k-(abs(x)/d),d);
		}
	}
	cout<<"\n";
}

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

int main(){
  int n;
  double power=1.0;
  cin >> n;
  for(int i=1;i<=n;i++){
   power = fmod(power*i, pow(10,9)+7.0);
  }
  cout << (int)power << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
#include<string>
#include<algorithm>
#include<set>
#include<map>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORS(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)
#define SORT(v,n) sort(v,v+n)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FORR(i,n,0)
#define si(n) scanf("%d",&n)
#define sc(s) scanf("%s",s)
#define EPS (1e-7)
#define INF (1e9)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

const int MOD = 1000000007;
struct mint { int n; mint(int n_ = 0) : n(n_) {} };
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};
void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}

template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

vector<ll> G[100000];
int N, K;

int color[100000];

int main(void){
    cin >> N >> K;
    rep(i,N-1){
        int s,t;
        scanf("%d %d",&s,&t);
        G[s-1].push_back(t-1);
        G[t-1].push_back(s-1);
    }

    queue<PL> q;
    mint count = 1;

    q.push(PL(0,0));
    PL tmp = q.front();
    color[0] = 1;
    count*=K;
    for(int i=0;i<G[tmp.first].size();i++){
        if(color[G[tmp.first][i]] == 0){
            q.push(PL(G[tmp.first][i],i));
            count*=K-(i+1);
            color[G[tmp.first][i]]=1;
        }
    }
    q.pop();

    while(q.size()){
        tmp=q.front();
        ll num = 0;
        for(int i=0;i<G[tmp.first].size();i++){
            if(color[G[tmp.first][i]] == 0){
                q.push(PL(G[tmp.first][i],i));
                count*=K-(i+2-num);
                color[G[tmp.first][i]]=1;
            }else num++;
        }
        q.pop();
    }

    cout << count << endl;

    return 0;
}



Measured memory_bytes: 8564
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)    for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define rrep(i, n)   for(int i=(n-1); i>=0; --i)
#define all(v)       v.begin(), v.end()
#define rall(v)      v.rbegin(), v.rend()
#define int          long long
template<typename T>
using vv  = vector<vector<T>>;
using vi  = vector<int>;
using vvi = vector<vector<int>>;
using P   = pair<int, int>;
using ll  = long long;
constexpr ll INF = 1LL << 60;

signed main(){

    int a;
    double b;
    cin >> a >> b;

    int ans = a * llround(b * 100) / 100;

    cout << ans << endl; 

    return 0;
}



Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <algorithm>

int main()
{
	int S, W;
	std::cin >> S >> W;
	std::cout << ((W >= S) ? "unsafe" : "safe") << std::endl;
	return 0;
}

Measured memory_bytes: 3592
N, M = gets.split.map(&:to_i)
h = []
h = gets.split.map(&:to_i)
a = []
b = []
"想定解"
# ma = []
# ma = ma.fill(0,0..N-1)
# M.times do |i|
#   a[i], b[i] = gets.split.map(&:to_i)
#   ma[a[i]-1] = [ h[b[i]-1], ma[a[i]-1] ].max
#   ma[b[i]-1] = [ h[a[i]-1], ma[b[i]-1] ].max
# end
# ans = 0
# N.times do |i|
#   if ma[i] < h[i]
#     ans += 1
#   end
# end
# puts ans

"隣接リストを用いる"
Adj = Struct.new(:id, :l)
adj = []
N.times do |i|
  adj[i] = Adj.new(i, [])
end
  
M.times do |i|
  a[i], b[i] = gets.split.map(&:to_i)
  adj[a[i]-1].l.push(b[i]-1)
  adj[b[i]-1].l.push(a[i]-1)
end

# puts "#{adj}"

ans = 0
adj.each do |n|
  if n.l.empty?
    ans += 1
  else
    x = 0
    x = n.l.map {|v| v = h[v]}.max
    # puts "n #{n.id}"
    # puts "x #{x}"
    if x < h[n.id]
      ans += 1
    end
  end
end
puts "#{ans}"

Measured memory_bytes: 34848
#include "bits/stdc++.h"
#define ed cout<<"\n";
//#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//#define ll longlongint
using namespace std;
int main(){
     //SPEED;
     int N,Y;
     cin>>N>>Y;
     int res10000 = -1, res5000 = -1, res1000 = -1;
     for (int a = 0; a <= N; ++a) { 
         for (int b = 0; b  < N-a+1; ++b) {
             int c=N-a-b;
             int total=10000*a+5000*b+1000*c;
             if(total==Y){
                 res10000=a;
                 res5000=b;
                 res1000=c;
             }
         }
     }
     cout << res10000 << " " << res5000 << " " << res1000 << endl;
}


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

void solve(int N, vector<int64_t> A)
{
    for (int i = 0; i < N; i++)
    {
        if (A.at(i) == 0)
        {
            cout << 0 << endl;
            return;
        }
    }

    int64_t res = 1;
    for (int i = 0; i < N; i++)
    {
        if (res > INT64_MAX / A.at(i))
        {
            cout << -1 << endl;
            return;
        }
        res *= A.at(i);
        if (res > (int64_t)1e18)
        {
            cout << -1 << endl;
            return;
        }
    }
    cout << res << endl;
}

int main()
{
    int N;
    cin >> N;
    vector<int64_t> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }
    solve(N, move(A));
    return 0;
}


Measured memory_bytes: 4052
n = int(input())
a = input().split()
b = a[:]
flag = 1
while flag:
    flag = 0
    for i in range(n-1):
        if a[i][1] > a[i+1][1]:
            a[i], a[i+1] = a[i+1], a[i]
            flag = 1
print(*a)
print("Stable")

for i in range(n-1):
    min_j = i
    for j in range(i,n):
        if b[j][1] < b[min_j][1]:
            min_j = j
    b[i], b[min_j] = b[min_j], b[i]
print(*b)
if a == b:
    print("Stable")
else:
    print("Not stable")

Measured memory_bytes: 7756
n,k = map(int,input().split())
num_lis = list(input().split())
max = 0
c = 0
for i in range(n):
    num_lis[i] = int(num_lis[i])
for i in range(n-k+1):
    if i == 0:
        for j in range(k):
            c = c + num_lis[i+j]/2 + 1/2
        max = c
    else:
        c = c - num_lis[i-1]/2 + num_lis[i+k-1]/2
        if c > max:
            max = c
print(max)

Measured memory_bytes: 18852
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 10000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
typedef pair<P, int> PI;
typedef pair<int, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

int c[10];

bool seq3(int p) {
  if(p==4) return true;
  repl(i, 1, 7) {
    if(c[i] && c[i+1] && c[i+2]) {
      --c[i]; --c[i+1]; --c[i+2];
      bool r = seq3(p+1);
      ++c[i]; ++c[i+1]; ++c[i+2];
      if(r) return true;
    }
  }
  return false;
}

bool same3(int p) {
  if(p==4) return true;
  if(seq3(p)) return true;
  repl(i, 1, 9) {
    if(c[i]>=3) {
      c[i] -= 3;
      bool r = same3(p+1);
      c[i] += 3;
      if(r) return true;
    }
  }
  return false;
}

bool same2() {
  repl(i, 1, 9) {
    if(c[i]>=2) {
      c[i] -= 2;
      bool r = same3(0);
      c[i] += 2;
      if(r) return true;
    }
  }
  return false;
}

int main() {
  string s;
  while(cin >> s) {
    rep(i, 10) c[i] = 0;
    rep(i, 13) ++c[s[i]-'0'];
    vector<int> ans;
    repl(i, 1, 9) {
      if(c[i]<4) {
        ++c[i];
        if(same2()) {
          ans.push_back(i);
        }
        --c[i];
      }
    }
    if(ans.size()) {
      rep(i, ans.size()) cout << (i?" ":"") << ans[i]; cout << endl;
    }else {
      cout << "0" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1208
function main(input) {
  const lines = input.trim().split("\n");
  const X = BigInt(lines[0]);

  let d = BigInt(100);
  let res = 0;
  while (d < X) {
    d += d / BigInt(100);
    res++;
  }

  console.log(res);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30512
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll n=s.length();
    ll dp[n][13];
    for(int i=0;i<n;i++){
        for(int j=0;j<13;j++){
            dp[i][j]=0;
        }
    }
    if(s[0]=='?'){
        for(int i=0;i<10;i++){
            dp[0][i]=1;
        }
    }else{
        dp[0][s[0]-'0']=1;
    }
    for(int i=1;i<n;i++){
        if(s[i]=='?'){
            for(int j=0;j<13;j++){
                for(int k=0;k<10;k++){
                    dp[i][(10*j+k)%13]+=dp[i-1][j];
                }
            }
        }
        else{
            for(int j=0;j<13;j++){
                dp[i][(10*j+(s[i]-'0'))%13]+=dp[i-1][j];
            }
        }
        for(int j=0;j<13;j++){
            dp[i][j]%=mod;
        }
    }
    cout << dp[n-1][5]%mod<<endl;
    return 0;
}



Measured memory_bytes: 10704
import java.lang.*;
import java.math.*;
import java.io.*;
import java.util.Scanner;

/* Name of the class has to be "Main" only if the class is public. */
public class Main {
    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int h[] = new int[n];
        for (int i = 0; i < n; i++)
        {
            h[i]=sc.nextInt();
        }
        int a[]=new int[n];
        a[0]=0;
        a[1]=Math.abs(h[1]-h[0]);
        for(int i=2;i<n;i++)
        {
            a[i]=Math.min(a[i-2]+Math.abs(h[i-2]-h[i]),a[i-1]+Math.abs(h[i-1]-h[i]));
        }
        System.out.println(a[n-1]);
    }
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 2e5+23;
int a[N], f[N], ind[N];
long long b[N];
long long n, k;

bool check(long long target) {
  long long kk = k;
  for (int i = 0; i < n; ++i) {
    long long cur = 1LL*a[i]*f[i];
    if (cur <= target) continue;
    int sub = (cur-target+f[i]-1)/f[i];
    if (kk < sub) return false;
    kk -= sub;
  }
  return true;
}

void solve() {
  scanf("%lld%lld", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", f+i);
    ind[i] = i;
  }
  for (int i = n; i < N; ++i) ind[i] = n;
  sort(f, f+n, greater<int>());
  sort(a, a+n);
  long long lo = -1, hi = 1e12+1;
  while (lo+1<hi) {
    long long mid = (lo+hi)/2;
    if (check(mid)) hi = mid;
    else lo = mid;
  }
  printf("%lld", hi);
}

int main() {
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 6128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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;
}

int main(){
  int i,j;
  ll a,b;
  cin>>a>>b;
  for(i=1;i<20000;i++){
    if(a==i*8/100&&b==i*10/100) {
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;

}

Measured memory_bytes: 256
import itertools, math
N = int(input())
lst1 = []
for _ in range(N):
    x, y = map(int, input().split())
    lst1.append((x, y))

lst2 = list(itertools.combinations(lst1, 2))
p = math.factorial(N) * (N - 1)
c = len(list(itertools.combinations(lst1, 2)))
total = 0

for i in lst2:
    d = ((i[1][0] - i[0][0]) ** 2 + (i[1][1] - i[0][1]) ** 2) ** 0.5
    total += d
    
num = int(p/c)
fct = math.factorial(N)

print(total * num / fct)

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

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;

ll N, K;
vector<ll> a, dp, pp;

ll fix(ll x) {
    x %= MOD;
    if (x < 0)
        x += MOD;
    return x;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> K;
    a.resize(N);
    for (int i = 0; i < N; i++)
        cin >> a[i];
    dp.resize(K + 1);
    pp.assign(K + 2, 1);
    dp[0] = 1;
    pp[0] = 0;
    for (int i = 0; i < N; i++) {
        for (int k = 0; k <= K; k++)
            dp[k] = fix(pp[k + 1] - pp[max(k - a[i], 0LL)]);
        for (int k = 1; k <= K + 1; k++)
            pp[k] = fix(pp[k - 1] + dp[k - 1]);
    }
    cout << dp[K] << endl;
}


Measured memory_bytes: 1792
from decimal import *
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N = I()
    s = S()
    N = len(s)
    white = [0 if s[i] == '.' else 1 for i in range(N)]
    count = sum(white)
    lst = set()
    lst.add(count)

    for i in range(N-1, -1, -1):
        if white[i]:
            count -= 1
        else:
            count += 1
        lst.add(count)
    print(min(lst))


if __name__ == '__main__':
    main()


Measured memory_bytes: 79736
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}

int dx8[8]={-1,-1,-1,0,0,1,1,1};
int dy8[8]={-1,0,1,-1,1,-1,0,1};

int a[64][64],fl[64][64];
int h,w;

void rep(int p,int q){
  if(p<0 || h<=p){return;}
  if(q<0 || w<=q){return;}
  if(a[p][q]==0){return;}
  if(fl[p][q]==1){return;}
  fl[p][q]=1;
  int i;
  for(i=0;i<8;i++){
    rep(p+dx8[i],q+dy8[i]);
  }
}

int main(){
  int i,j,r;
  while(scanf("%d%d",&w,&h),h!=0){
    r=0;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        scanf("%d",&a[i][j]);
        fl[i][j]=0;
      }
    }
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        if(fl[i][j]==1 || a[i][j]==0){continue;}
        rep(i,j);
        r++;
      }
    }
    printf("%d\n",r);
  }
  return 0;
}



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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { cout << p.first << ' ' << p.second; return os; }

void solve() {
  int N, Z, W; cin >> N >> Z >> W;
  vi32 a(N); cin >> a;

  function<int(int, int)> dp0, dp1;
  vector<unordered_map<int, int>> memo0(N), memo1(N);

  dp0 = [&](int l, int x) {
    if (memo0[l].count(x) > 0) {
      return memo0[l][x];
    }
    int ret = abs(x - a[N - 1]);
    repi(i, l, N - 1) {
      amax(ret, dp1(i + 1, a[i]));
    }
    return memo0[l][x] = ret;
  };

  dp1 = [&](int l, int x) {
    if (memo1[l].count(x) > 0) {
      return memo1[l][x];
    }
    int ret = abs(x - a[N - 1]);
    repi(i, l, N - 1) {
      amin(ret, dp0(i + 1, a[i]));
    }
    return memo1[l][x] = ret;
  };

  cout << dp0(0, W) << '\n';
}


Measured memory_bytes: 896
def select_sort(A, N):
    cnt = 0
    for i in range(N):
        mini_ix = i
        for j in range(i, N):
            if A[mini_ix] > A[j]:
                mini_ix = j

        if mini_ix != i:  # ここでswap
            A[i], A[mini_ix] = A[mini_ix], A[i]
            cnt += 1

    print(*A, sep=' ')
    print(cnt)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    select_sort(A, N)


if __name__ == "__main__":
    main()


Measured memory_bytes: 5612
#include<cstdio>
int main(){
int n;
scanf("%d",&n);
int a=n/1000;
int b=(n/100)%10;
int c=(n/10)%10;
int d=n%10;
if(b==c&&(a==b||c==d))printf("Yes\n");
else printf("No\n");
return 0;
}

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

using namespace std;

const int maxN = 1000009;
int N;
char sir[maxN];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%s", sir + 1), N = strlen (sir + 1);
long long ans = 0;
int cntA = 0;
for (int i=1; i<=N; i++)
    if (sir[i] == 'A') cntA ++;
    else
    if (sir[i] == 'B' && sir[i + 1] == 'C')
        ans += cntA, i ++;
    else
        cntA = 0;
printf ("%lld\n", ans);
return 0;
}


Measured memory_bytes: 4032
import sys
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]
for i in range(3):
    # for j in range(3):
    if A[i][0] in B and A[i][1] in B and A[i][2] in B:
        print("Yes")
        sys.exit()
    elif A[0][i] in B and A[1][i] in B and A[2][i] in B:
        print("Yes")
        sys.exit()
    elif A[0][0] in B and A[1][1] in B and A[2][2] in B:
        print("Yes")
        sys.exit()
    elif A[0][2] in B and A[1][1] in B and A[2][0] in B:
        print("Yes")
        sys.exit()
print("No")

Measured memory_bytes: 3188
number = []
result = "No"

for i in range(3):
	for n in input().split():
		n = int(n)
		number.append(n)

bingo = [None for _ in range(9)]

N  = int(input())
for i in range(N):
	b = int(input())
	for j in range(9):
		if b == number[j]:
			bingo[j] = True


for i in range(3):
	if bingo[3*i] == bingo[3*i+1] and bingo[3*i+1] == bingo[3*i+2] and bingo[3*i] == True:
		result = "Yes"

for i in range(3):
	if bingo[i] == bingo[3+i] and bingo[3+i] == bingo[6+i] and bingo[i] == True:
		result = "Yes"

if bingo[0] == bingo[4] and bingo[4] == bingo[8] and bingo[0] == True:
	result = "Yes"

if bingo[2] == bingo[4] and bingo[4] == bingo[6] and bingo[2] == True:
	result = "Yes"

print(result)


Measured memory_bytes: 3192
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var nkq = lines[0].split(' ');
 var n = Number(nkq[0]);
 var k = Number(nkq[1]);
 var q = Number(nkq[2]);
 var points = [];
 for(i=0; i<n; i++){
   points.push(k-q);
 }

 for(i=1; i<=q; i++){
   var num = Number(lines[i]);
   points[num-1]++;
 }

 for(i=0; i<n; i++){
   if(points[i] > 0){
     console.log('Yes');
   }else{
     console.log('No');
   }
 }
});

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

using namespace std;
using ll = long long;

const ll md = 1e9 + 7;
const ll nax = 2345;

ll a[nax], b[nax];

ll mul (ll a, ll b)
{
  ll ans = a;
  ans = ans * b % md;
  return ans;
}

void add (ll &a, ll b)
{
  a += b;
  if (a > md) {
    a -= md;
  }
}

ll bexp (ll a, ll b)
{
  ll ans = 1LL;
  while (b > 0) {
    if (b & 1) {
      ans = ans * a % md;
    }
    a = a * a % md;
    b >>= 1;
  }
  return ans;
}

ll fn (ll a)
{
  return bexp (a, md - 2);
}

int main()
{
  ios_base::sync_with_stdio (0);
  cin.tie (0);
  ll n, k;
  cin >> n >> k;
  set<ll>s;
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    s.insert (a[i]);
  }
  vector<ll>inv (n);
  for (ll i = 0; i < n; i++) {
    ll now = 0;
    for (ll j = 0; j < i; j++) {
      if (a[j] > a[i]) {
        now++;
      }
    }
    inv[i] = now;
  }
  ll ans = 0;
  vector<ll>pro (n);
  for (ll i = 0; i < n; i++) {
    ll cur = 0;
    for (ll j = 0; j < n; j++) {
      if (a[j] > a[i]) {
        cur++;
      }
    }
    pro[i] = cur;
  }
  for (ll i = 0; i < n; i++) {
    ll pre = 1;
    pre = mul (pre, k);
    pre = mul (pre, k - 1);
    pre = mul (pre, fn (2) );
    pre = mul (pre, pro[i]);
    ll tot = 1;
    tot = mul (tot, inv[i]);
    tot = mul (tot, k);
    add (ans, pre);
    add (ans, tot);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

template <typename T>
bool MinPlace(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename Container>
int SZ(const Container& S) { return S.size(); }

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

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg_var(x) clog << #x  << ": " << x << endl;
    #define dbg_array(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg_var(x)
    #define dbg_array(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

LL binom(LL k) {
    return (k*(k-1))/2;
}


LL cc[26];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!

    string s;
    cin >> s;
    for (char c : s) cc[c-'a']++;
    LL res = 1 + binom(s.size());
    for (int i = 0; i < 26; i++) res -= binom(cc[i]);
    cout << res << "\n";
}



Measured memory_bytes: 720
#include <stdio.h>
#include <string.h>

int main()
{
	char S[3];
	scanf("%s",S);
	if(strlen(S) == 2){
		printf("%s",S);
	}else{
		
		char tmp = S[0];
		S[0] = S[2];
		S[2] = tmp;
		printf("%s",S);
	}
	return 0;	
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int main (void) {
  int a, b, x;
  cin >> a >> b >> x;
  int rest = x - a;
  if (0 <= rest && rest <= b)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define repd(i,a,b) for(int i = (a); i >= (b); i--)
using namespace std;
typedef long long int ll;
typedef complex<double> com;
typedef pair<int, int> P;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;



int main() {
	int n, t; cin >> n >> t;
	vector<int> a(n);
	ll ans = 0;
	rep(i, 0, n) cin >> a[i];
	rep(i, 0, n - 1) {
		ans += min(t, a[i + 1] - a[i]);
	}
	printf("%lld", ans+t);
	return 0;
}


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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    int ans = 0;
    for(int i = 0; i < N; ++i){
        cin >> A[i];
    }
    for(int i = 0; i < N; ++i){
        cin >> B[i];
    }  
    for(int i = 0; i < N-1; ++i){
        cin >> C[i];
    }

    ans += B[A[0]-1];
    for(int i = 1; i < N; ++i){
        if(A[i]-1 == A[i-1]){
            ans += B[A[i]-1];
            ans += C[A[i]-2];
            // cout << C[A[i]-2] << endl;
        }else{
            ans += B[A[i]-1];
        }
        // cout << "i = " << i << " : " << B[A[i]-1] << endl;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int N;
    scanf("%d",&N);
    int a[N];
    for(int i=0;i<N;i++)scanf("%d",&a[i]);
    int ans=0;
    for(int i=0;i<N-1;i++){
        if(a[i]==i+1&&a[i+1]==i+2){a[i]=0;a[i+1]=0;ans++;}
    }
    for(int i=0;i<N;i++)if(a[i]==i+1)ans++;
    printf("%d",ans);
    return 0;
}


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

const int MOD = 1000000007;

int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	auto sum = [](int l, int r){
				   return (long)(r - l + 1) * (l + r) / 2;
			   };
	long ans = 0;
	for(int i = k; i <= n + 1; i++)
		ans += sum(n-i+1, n) - sum(0, i-1) + 1;
	printf("%ld\n", ans % MOD);
}

Measured memory_bytes: 3828
//
//AtCoder Regular Contest 099
//C - Minimization
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    cout << ceil((double)(n-1)/(k-1)) << endl;
    return 0;
}


Measured memory_bytes: 3748
#include<stdio.h>
#include<string.h>
typedef long long int lli;
int main() {
  int n;
  int ac=0,wa=0,tle=0,re=0;
  scanf("%d", &n);
  while(n--){
      char s[3];
      scanf("%s", &s);
      if(strcmp(s,"AC")==0){
          ac++;
      }
      else if(strcmp(s,"WA")==0)
        wa++;
      else if(strcmp(s,"TLE")==0)
        tle++;
      else if(strcmp(s,"RE")==0)
        re++;
  }

  printf("%s x %d\n", "AC",ac);
  printf("%s x %d\n", "WA", wa);
  printf("%s x %d\n", "TLE", tle);
  printf("%s x %d\n", "RE", re);
  return 0;
}



Measured memory_bytes: 1712
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <iterator>
#include <cmath>
#include <deque>
#include <stack>
using namespace std;

const long long mod = 1000 * 1000 * 1000 + 7;

int main()
{
    {
        if (fopen("input.txt", "r")) {
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        }
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
    }

    long long n;
    cin >> n;
    vector<long long> vec(60);
    for (long long i = 0; i != n; ++i) {
        long long a;
        cin >> a;
        for (long long j = 0; j != 60; ++j)
            if (a & (1LL << j))
                ++vec[j];
    }
    long long ans = 0, p = 1;
    for (int i = 0; i != 60; ++i) {
        ans += (p * ((vec[i] * (n - vec[i])) % mod)) % mod;
        ans %= mod;
        p *= 2LL;
        p %= mod;
    }
    ans %= mod;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
//package code;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.StringTokenizer;

/**
 *
 * @author Milo
 */
public class Main {
    
    static FastReader in = new FastReader();
    public static void main(String[] args) {
        int t = 1; //in.nextInt();
        while (t-- > 0)
            solve();
    }
 
    public static void solve() {
        int n = in.nextInt();
        BigInteger b = BigInteger.ONE;
        BigInteger lim = BigInteger.valueOf((long)1e18);
        for(int i = 0; i < n; ++i){
            long t = in.nextLong();
            if(t == 0){
                System.out.println("0");
                return;
            }
            if(b.compareTo(lim) == 1){
                continue;
            }
            b = b.multiply(BigInteger.valueOf(t));
        }
        if(b.compareTo(lim) == 1){
            System.out.println("-1");
            return;
        }
        System.out.println(b);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
 
    public static int max(int a, int b) {
        return a > b ? a : b;
    }
 
    public static int min(int a, int b) {
        return a < b ? a : b;
    }
 
    public static int gcd(int a, int b) {
        return b == 0 ? a : gcd(b, (a % b));
    }
}


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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 a, b, c, k;
    cin >> a >> b >> c >> k;

    i64 ans = 0;
    i64 d = min(a, k);
    ans += d;
    k -= d;
    d = min(b, k);
    k -= d;
    d = min(c, k);
    ans -= d;
    cout << ans << endl;
}

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


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

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long

int main()
{
    double q,x;
    while(1)
    {
	scanf("%lf",&q);
	if (q==-1)break;
	x=q/2.0;
	while(abs(x*x*x-q)>=0.00001*q)
	{
	    x=x-(x*x*x-q)/(3.0*x*x);
	}
	printf("%f\n",x);
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <algorithm>
#include <utility>
using namespace std;
int main(){
	int N, M; 
  	cin >> N >> M; 
	char A[60][60] = {}, B[60][60] = {}; 
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			cin >> A[i][j]; 
        }
	}
	for(int i = 0; i < M; i++){
		for(int j = 0; j < M; j++){
			cin >> B[i][j]; 
        }
	}
	string ans = "No"; 
	for(int s = 0; s <= N-M; s++){
		for(int t = 0; t <= N-M; t++){
			bool possible = true; 
			for(int i = 0; i < M; i++){
				for(int j = 0; j < M; j++){
					if(A[i+s][j+t] != B[i][j]){
						possible = false; 
					}
				}
			}
          if(possible) ans = "Yes"; 
		}
	}
	cout << ans << endl; 
}

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

int main(){
  int A,B;
  cin >> A >> B;
  if(A > 9 || B > 9){
    cout << "-1" << endl;
  }
  	else cout << A*B <<endl;
}

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

using namespace std;
using ll = long long;

int main()
{
    ll a, b, c, d, e, n;
    cin >> n >> a >> b >> c >> d >> e;
    ll mi = min(a, min(b, min(c, min(d, e))));
    ll ans = 4;
    if(n % mi == 0) ans += n/mi;
    else ans += n/mi + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
 int N,M;cin>>N>>M;vi a(M),b(M);vvi c(N+1);
  rep(i,M){
    cin>>a[i]>>b[i];
    c[b[i]].push_back(a[i]);
    c[a[i]].push_back(b[i]);
  }
  f(i,1,N+1){
    cout<<c[i].size()<<endl;
  }
}





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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

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

    ll ans = 0;
    ans += min(n, m / 2);
    m -= 2 * ans;
    ans += m / 4;

    cout << ans << endl;

    return 0;
}

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

#define _CRT_SECURE_NO_WARNINGS

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

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

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k, t;
	cin >> k >> t;

	vi cake(t);

	int sum = 0;
	for (int i = 0; i < t; i++) {
		cin >> cake[i];
		sum += cake[i];
	}
	DESCSORT(cake);

	cout << max(0, cake[0] * 2 - sum - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
using namespace std;





int main() {
	int n, a, b;
	cin >> n >> a >> b;
	int ans1 = min(a, b);
	int ans2 = n - a - b;
	if (ans2 > 0) {
		ans2 =0 ;
	}
	else {
		ans2 = -ans2;
	}
	cout << ans1 << " " << ans2 << endl;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 500005;

int n;
set<string> zb;

void go(string& s) {
	if (s.size() == n) {
		zb.insert(s);
		return;
	}
	set<char> ss;
	for (int i=0;i<s.size();i++) ss.insert(s[i]);
	for (auto& w : ss) {
		string s2 = s + w;
		go(s2);
	}
	char next;
	if (ss.size() == 0) next = 'a'; else {
		set<char>::iterator it = ss.end();
		it--;
		next = *it + 1;
	}
	string s2 = s + next;
	go(s2);
}

int main() {
scanf("%d", &n);
string s = "";
go(s);
for (auto& w : zb) printf("%s\n", w.c_str());
return 0;
}

Measured memory_bytes: 14208
/*
 * Problem Description: Recursion / Divide and Conquer - Koch Curve
 * Category:
 * Author: Khan
 * Date: 15th October, 2017
 */

#include <stdio.h>
#include <math.h>

typedef struct Point
{
    double x, y;
}Point;

void koch(int n, Point a, Point b)
{
    if(n == 0)
        return;
    Point s, t, u;
    double th = M_PI * 60.0 / 180.0;

    s.x =(2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y =(2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x =(1.0 * a.x + 2.0 * b.x) / 3.0;;
    t.y =(1.0 * a.y + 2.0 * b.y) / 3.0;;
    u.x =(t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y =(t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n - 1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n - 1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n - 1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n - 1, t, b);
}

int main(int argc, char const *argv[])
{
    //freopen("sample.txt", "r", stdin);
    Point a, b;
    int n;

    scanf("%d", &n);
    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    printf("%.8f %.8f\n", a.x, a.y);
    koch(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);

    return 0;
}

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

using namespace std;

typedef long long ll;
#define mems(p) memset(p,-1,sizeof(p))
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define nl "\n"

const int mxN = 1e5;
const ll MOD = 1e9 + 7;

void fast()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

ll gcd(ll a, ll b) {
	return b ? gcd(b, a%b) : a;
}

int main() {
	fast();
	int n;
	cin >> n;
	cout << n + n*n + n*n*n << nl;
}

Measured memory_bytes: 3608
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Tue Dec 25 03:29:25 2018
//
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	arr := make([]int, N)
	for i := range arr {
		fmt.Scan(&arr[i])
	}

	ans := 0
	now := 0
	from, to := 0, 0
	for i := range arr {
		if now&arr[i] == 0 {
			now |= arr[i]
			to = i
			ans += to - from + 1
		} else {
			for now&arr[i] != 0 && from <= i {
				now &= ^arr[from]
				from++
			}
			now |= arr[i]
			to = i
			ans += to - from + 1
		}
		//fmt.Printf("%010b %d %d %d\n", now, from, to, ans)
	}

	fmt.Println(ans)
}


Measured memory_bytes: 7552
using System;

namespace Project
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			string s1 = Console.ReadLine();
			string[] sar1 = s1.Split(' ');
			int n = int.Parse(sar1[0]);
			int m = int.Parse(sar1[1]);
			int[,] a = new int[n, m];
			int[] b = new int[m];
			for (int i = 0; i < n; i++)
			{
				string s2 = Console.ReadLine();
				string[] sar2 = s2.Split(' ');
				for (int j = 0; j < m; j++)
				{
					a[i, j] = int.Parse(sar2[j]);
				}
			}
			for (int i = 0; i < m; i++)
			{
				b[i] = int.Parse(Console.ReadLine());
			}
			int[] c = new int[n];
			for (int i = 0; i < n; i++)
			{
				for (int j = 0; j < m; j++)
				{
					c[i] += a[i, j] * b[j];
				}
				Console.WriteLine(c[i]);
			}
		}
	}
}

Measured memory_bytes: 9248