akhauriyash/Code-Regression huggingface dataset:
/*
 * Hit and Blow
 */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while (!(line = br.readLine()).equals("0 0")) {

			int hit = 0, blow = 0;

			int[] pos = new int[10];
			char[] r = line.substring(0, 4).toCharArray();
			char[] a = line.substring(5).toCharArray();

			for (int i = 0; i < r.length; i++) {
				pos[r[i] - '0'] = i + 1;
			}
			for (int i = 0; i < a.length; i++) {
				if (pos[a[i] - '0'] > 0) {
					if (pos[a[i] - '0'] == i + 1) {
						hit++;
					} else {
						blow++;
					}
				}
			}
			System.out.println(hit + " " + blow);
		}

	}
}

Measured memory_bytes: 32652
//created by Whiplash99
import java.io.*;
import java.util.*;
public class Main
{
    private static long evaluate(long a[], int N, long val)
    {
        long sum=0;
        for(int i=0;i<N;i++) sum+=a[i]^val;
        return sum;
    }
    public static void main(String[] args) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        int i,N;

        String s[]=br.readLine().trim().split(" ");
        N=Integer.parseInt(s[0]);
        long K=Long.parseLong(s[1]);

        s=br.readLine().trim().split(" ");
        long[] a=new long[N];
        for(i=0;i<N;i++) a[i]=Long.parseLong(s[i]);

        long cur; long max;
        for(cur=1;cur<=K;cur*=2){}

        cur/=2; long val=0; max=0;
        for(;cur>=1;cur/=2)
        {
            long tmp=evaluate(a,N,cur);
            if(val+cur<=K&&evaluate(a,N,val+cur)>max)
            {
                max=evaluate(a,N,val+cur);
                val+=cur;
            }
            if(tmp>max)
            {
                max=tmp;
                val=cur;
            }
        }

        max=Math.max(max,evaluate(a,N,0));
        max=Math.max(max,evaluate(a,N,K));
        System.out.println(max);
    }
}

Measured memory_bytes: 49484
#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
int main (){
      
    cin.tie(0);
    ios::sync_with_stdio(false);
      
    while( true ){
        int N;
        cin >> N;
        if( N == 0 ){ break; }
        vector<pair<int,int> > vc(N);
        for( auto& x : vc )
        {
            cin >> x.second >> x.first;
        }
        sort( vc.begin(), vc.end() );
        int count{};
        bool flag = true;
        for( auto& x : vc )
        {
            count += x.second;
            if( count > x.first )
            {
                flag = false;
            }
        }
        cout << ( flag ? "Yes" : "No" ) << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define Vsort(v) sort(All(v))
#define VsortR(v) sort(All(v), std::greater<__typeof(v[0])>())

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    ll n;

	cin >> n;

	ll a = n;
	ll sum = 0;

	while (a) {
		sum += a % 10;
		a /= 10;
	}

	if (n % sum == 0) Out("Yes");
	else Out("No");
	
	return 0;
}


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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
#define N 100010
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

ll result(ll a, ll b, ll p){
    ll ans=1;
    if(b==(-1))
        b=p-2;
    while(b){
        if(b&1){
            ans=(ans*a)%p;
        }
        a=(a*a)%p;
        b>>=1;
    }
    return ans;
}

ll T,n,m;

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);
    ll k; cin >> k >>n;
    ll a[n];
    for(int i=0;i<n;i++)
        cin >> a[i];
    ll m = 0;
    for(int i=0;i<n-1;i++){
        ll d= a[i+1] - a[i];
        m=max(d,m);
    }
    ll p = k-a[n-1];
    p+=a[0];
    m=max(m,p);
    cout << k - m;

    return 0;
}


Measured memory_bytes: 1792
def solve():
    N = int(input())
    for _ in range(N):
        balls = list(map(int, input().split()))
        lefts, rights = [0], [0]
        for ball in balls:
            if lefts[-1] < ball:
                lefts.append(ball)
            elif rights[-1] < ball:
                rights.append(ball)
            else:
                print('NO')
                break
        else:
            print('YES')

if __name__ == "__main__":
    solve()



Measured memory_bytes: 5596
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  ll dp[100005] = {0};
  rep(i,n){
    dp[a[i]-1]++;
    dp[a[i]]++;
    dp[a[i]+1]++;
  }
  ll ans = 0;
  rep(i,100005) maxch(ans,dp[i]);
  cout<<ans<<endl;

}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 1792
N = int(input())

x, y = map(int, input().split())

rt = (x, y)
rb = (x, y)
lt = (x, y)
lb = (x, y)

for _ in range(N-1):
    x, y = map(int, input().split())
    if (x + y - rt[0] - rt[1] > 0):
        rt = (x, y)
    if (x + y - lb[0] - lb[1] < 0):
        lb = (x, y)
    if (x - y - rb[0] + rb[1] > 0):
        rb = (x, y)
    if (x - y - lt[0] + lt[1] < 0):
        lt = (x, y)

def dist(p, q):
    return (abs(p[0]-q[0]) + abs(p[1]-q[1]))
print(max(dist(rt, lb), dist(rb, lt)))

Measured memory_bytes: 76628
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    int x;
    cin>>x;
    cout<<(1-x);
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

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

int main(){
	int x[101],y[101];
	int n, i;
	double p = 0, D = 0;

	cin>>n;
	for(i = 0;i < n;i++)
		cin>>x[i];

	for(i = 0;i < n;i++)
		cin>>y[i];

	for(i = 0;i < n;i++)
		p += (double)abs(x[i]-y[i]);

		printf("%7lf\n",p);

		p = 0;

	for(i = 0;i < n;i++)
		p += pow(((double)abs(x[i]-y[i])),2);

		D = sqrt(p);
		printf("%7lf\n",D);

		p = 0;

	for(i = 0;i < n;i++)
		p += pow(((double)abs(x[i]-y[i])),3);

		D = pow(p,1.0/3.0);
		printf("%7lf\n",D);

		p = 0;

	for(i = 0;i < n;i++)
		if(i == 0)
			D = abs(x[0]-y[0]);

		else
			D = max(D,(double)abs(x[i]-y[i]));
		printf("%7lf\n",D);

	return 0;
}

Measured memory_bytes: 1232
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        a: i32,
        b: i32,
        t: i32,
    }
    let c = t/a;
    println!("{}", c*b);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i <= (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    double l;
    cin >> l;
    l = l/3;
    cout << fixed << setprecision(20) << l*l*l << endl;
}

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

int main(){
    int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(ki,k) {
       vector<int> b(n+1);
       rep(i,n) {
           int l = max(0, i-a[i]);
           int r = min(i+a[i]+1, n);
           b[l]++; b[r]--;
       }
       rep(i,n) b[i+1] += b[i];
       b.pop_back();
       if (a == b) break;
       a = b;
    }
    rep(i,n) cout << a[i] << endl;
    return 0;
}

Measured memory_bytes: 4852
#include<iostream>
#include<cmath>
struct vector
{
	double x, y;
	double norm()
	{
		return hypot(x, y);
	}
	vector operator-(vector v)
	{
		vector result;
		result.x = x - v.x;
		result.y = y - v.y;
		return result;
	}
	double operator*(vector v)
	{
		return x * v.x + y * v.y;
	}
};
double area(vector v1, vector v2, vector v3)
{
	vector side1 = v2 - v1, side2 = v3 - v1;
	return sqrt(pow(side1.norm() * side2.norm(), 2) - pow(side1 * side2, 2)) / 2;
}
int main()
{
	while (true)
	{
		vector A, B, C, D;
		char foo;
		std::cin >> A.x >> foo >> A.y >> foo >> B.x >> foo >> B.y >> foo >> C.x >> foo >> C.y >> foo >> D.x >> foo >> D.y;
		if (std::cin.eof())
		{
			break;
		}
		double ABC = area(A, B, C),
			ACD = area(A, C, D),
			BCD = area(B, C, D),
			ABD = area(A, B, D);
		std::cout << (ABC + ACD > ABD && ABC + ACD > BCD && ABD + BCD > ABC && ABD + BCD > ACD ? "YES" : "NO") << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3184
// Author : Hardik Upadhyay
// college: SVNIT 
// slogan : Ab to phod dunga
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i = a ; i >= b; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
const int MAXN = 100005;
ll mod=1000000007;


long double power(double a, double b){
	if(b==0)return 1.0;
	long double res = 1;
	res = pow(a,b/2);
	res*=res;
	if((int)b%2==1){
		res*=a;
	}
	return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,k;
	cin>>n>>k;
	double res = 0;
	double x = (double)1/n;
	bool f = 0;
	for(int i = 1; i <= n ; i++){
		double st = i;
		double tmp = x;
		while(st < k){
			st = st*2;
			tmp  = tmp/2;
		}	
		res+=(tmp);
	}
	printf("%.15f",res);
	return 0;
}


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

int main(){
  ll n,a,b; cin >> n >> a >> b;
  ll ans,tmp;
  if(a==0) cout << 0 << endl;
  else{
      tmp=n/(a+b);
      ans=(tmp*a)+min(n-(tmp*(a+b)),a);
      cout << ans << endl;
  }
return 0;
}


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

struct LowLink {
    struct Edge {
        int to;
        Edge(int to) : to(to) { }
    };
    vector<vector<Edge>> graph;
    int v;
    vector<int> used, order, low_link, articulation_points;
    vector<pair<int, int>> bridges;
    LowLink(int v) : v(v), graph(v),  used(v, 0), order(v, 0), low_link(v, 0) {}
    void add_edge(int start, int to) {
        graph[start].emplace_back(to);
        graph[to].emplace_back(start);
    }
    void build() {
        int current_order = 0;
        for (int i = 0; i < v; ++i) {
            if (!used[i]) current_order = dfs(i, current_order, -1);
        }
    }
    int dfs(int id, int current_order, int parent) {
        used[id] = true;
        order[id] = current_order++;
        low_link[id] = order[id];
        bool is_articulation_points = false;
        int child_count = 0;
        for (Edge& e : graph[id]) {
            if (!used[e.to]) {
                ++child_count;
                current_order = dfs(e.to, current_order, id);
                low_link[id] = min(low_link[id], low_link[e.to]);
                if (parent != -1 && order[id] <= low_link[e.to]) is_articulation_points = true;
                if (order[id] < low_link[e.to]) bridges.emplace_back(id, e.to);
            } else {
                if (e.to != parent) {
                    low_link[id] = min(low_link[id], order[e.to]);
                }
            }
        }
        if (parent == -1 && child_count >= 2) is_articulation_points = true;
        if (is_articulation_points) articulation_points.push_back(id);
        return current_order;
    }
};

/*
    verified http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_B&lang=jp
    verified http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_A&lang=jp
*/
int main() {
    int V, E; cin >> V >> E;
    LowLink low_link(V);
    for (int i = 0; i < E; ++i) {
        int s, t; cin >> s >> t;
        low_link.add_edge(s, t);
    }
    low_link.build();
    for (auto& bridge : low_link.bridges) if (bridge.first > bridge.second) swap(bridge.first, bridge.second);
    sort(low_link.bridges.begin(), low_link.bridges.end());
    for (auto bridge : low_link.bridges) {
        cout << bridge.first << " " << bridge.second << endl;
    }
}



Measured memory_bytes: 4376
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <ios>
#include <iomanip>

using namespace std;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }

  bool unionSet(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(){
    ll N,M;
    cin >> N >> M;
    ll ans[M];
    vector<pair<ll,ll>> bridge(M);
    UnionFind u = UnionFind(N);

    REP(i, M){
        cin >> bridge[i].first >> bridge[i].second;
        ans[i] = 0;
    }

    ans[M-1] = N*(N-1)/2;
    for(int i=M-2 ; i>=0 ; i--){
        if(u.findSet(bridge[i+1].first-1, bridge[i+1].second-1)){
            ans[i] = ans[i+1];
        }else{
            ans[i] = ans[i+1]-u.size(bridge[i+1].first-1)*u.size(bridge[i+1].second-1);
        }
        u.unionSet(bridge[i+1].first-1, bridge[i+1].second-1);
    }

    REP(i, M){
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 4096
INFTY = (1<<32)

def floyd(n, d):
    for k in range(n):
        for i in range(n):
            if d[i][k] == INFTY:
                continue
            for j in range(n):
                if d[k][j] == INFTY:
                    continue
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])


N, M = [int(i) for i in input().split()]

g = [[INFTY] * N for i in range(N)]
for i in range(N):
    g[i][i] = 0

edge_dict = {}
for i in range(M):
    a, b, c = [int(v) for v in input().split()]
    a -= 1
    b -= 1
    edge_dict[(a, b)] = c
    g[a][b] = c
    g[b][a] = c

floyd(N, g)

ans = M
for e, c in edge_dict.items():
    a, b = e
    for s in range(N):
        if g[s][a] + c == g[s][b]:
            ans -= 1
            break

print(ans)


Measured memory_bytes: 3444
#include<stdio.h>
#include<stdlib.h>
int asc(const void* a, const void* b)
{
	return *(int*)a - *(int*)b;
}
int abs(int n)
{
	if (n < 0)
		n *= -1;
	return n;
}
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	int a[100005];
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	qsort(a, n, sizeof(int), asc);
	int ans = a[n - 1] - a[0];
	for (i = 1; i < n - 1; i++)
		ans += abs(a[i]);
	printf("%d\n", ans);
	int x = a[0];
	for (i = n - 2; i > 0; i--)
	{
		if (a[i] < 0)
			break;
		printf("%d %d\n", x, a[i]);
		x -= a[i];
	}
	int y = a[n - 1];
	for (i = 1; i < n - 1; i++)
	{
		if (a[i] >= 0)
			break;
		printf("%d %d\n", y, a[i]);
		y -= a[i];
	}
	printf("%d %d\n", y, x);
	return 0;
}

Measured memory_bytes: 2232
/*{{{*/
#include "bits/stdc++.h"
using namespace std;

#define MT make_tuple
#define all(x) begin(x), end(x)
#define putchar(x) cout << (x)
static int fastio = [](){ ios_base::sync_with_stdio(false); cin.tie(0); cout.precision(17); return 0; }();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename ...T> string format(const string& fmt, T&&... args) {
    size_t sz = snprintf(nullptr, 0, fmt.c_str(), args...) + 1;
    unique_ptr<char[]> buf(new char[sz]);
    snprintf(buf.get(), sz, fmt.c_str(), args...);
    return string(buf.get(), buf.get() + sz - 1);
}

template<class T> struct rge { T b, e; auto begin() const { return b; } auto end() const { return e; } };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
template<class T> auto dud(T* x) -> decltype(cerr << *x, 0);
template<class T> char dud(...);

struct debug {
#ifdef LOCAL
    debug(int line) {
        if(line) cerr << "LINE(" << line << ") -> ";
    }
    template<class T> typename enable_if<sizeof dud<T>(0) != 1, debug&>::type operator<<(T i) {
        cerr << boolalpha << i; return * this;
    }
    template<class T> typename enable_if<sizeof dud<T>(0) == 1, debug&>::type operator<<(T i) {
        return *this << range(begin(i), end(i));
    }
    template<class T, class U> debug& operator<<(pair<T, U> d) {
        return *this << "(" << d.first << ", " << d.second << ")";
    }
    debug& operator<<(tuple<>&) { return *this << "()"; };
    template<class ...T> debug& operator<<(tuple<T...> d) {
        *this << "("; debug_tuple<sizeof...(T), 0>(d);
        return *this << ")";
    }
    template<size_t L, size_t I, class T> void debug_tuple(const T& t) {
        *this << (I == 0 ? "" : ", ") << get<I>(t);
        if(I + 1 < L) debug_tuple<L, (I + 1) % L>(t);
    }
    template<class T> debug & operator <<(rge<T> d) {
        *this << "[";
        for(auto it = d.b; it != d.e; ++it)
            *this << (it != d.b ?  ", " : "") << *it;
        return *this << "]";
    }
    debug& operator<<(ostream&(*pf)(std::ostream&)) {
        cerr << pf; return *this;
    }
#else
    debug(int) {}
    template<class T> debug& operator<<(T&&) { return *this; }
    debug& operator<<(ostream&(*)(std::ostream&)) { return *this; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ << ": " << (__VA_ARGS__) << "] "

#define debug0()  debug(__LINE__)
#define debug1(x) debug(0)
#define GET_MACRO(_0, _1, NAME, ...) NAME
#define debug(...) GET_MACRO(_0, ##__VA_ARGS__, debug1, debug0)(__VA_ARGS__)
/*}}}*/
using LL = long long;

const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const LL LLINF = 0x3f3f3f3f3f3f3f3f;
const int MAX_N = 200005;

void solve(int) {
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for(int i = 0; i < N; ++i) {
        cin >> p[i];
    }
    sort(all(p));

    LL ans = 0;
    for(int i = 0; i < K; ++i) {
        ans += p[i];
    }
    cout << ans << endl;
}

int main() {
    int T = 1;
    //cin >> T;
    for(int i = 1; i <= T; ++i) {
        solve(i);
    }
    return 0;
}


Measured memory_bytes: 3652
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<random>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int q;
  cin >> q;
  while(q--) {
    string s,t;
    cin >> s >> t;
    int dp[s.size()+5][t.size()+5]={};
    for(int i=1; i<=s.size(); i++) {
      for(int j=1; j<=t.size(); j++) {
        if(s[i-1]==t[j-1]) {
          dp[i][j]=dp[i-1][j-1]+1;
        }
        else {
          dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
      }
    }
    cout << dp[s.size()][t.size()] << endl;
  }
 }


Measured memory_bytes: 7172
#include <stdio.h>

int main() {
    int N, M;
    scanf("%d %d", &N, &M);
    int A[N], sum = 0;
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
        sum += A[i];
    }

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (sum <= 4 * M * A[i]) {
            cnt++;
        }
    }

    if (M <= cnt) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
N, K = map(int,input().split())
state = [1 for i in range(N)]
for i in range(K):
  d = int(input())
  #print(1,i,d)
  x = list(map(int, input().split()))
  for k in x:
    state[k-1] = 0
print(sum(state))

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

using namespace std;

using ll = long long;

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

    string s;
    cin >> s;
    for (int i = 0; i < s.size(); ++i)
        if (i % 2 == 0) cout << s[i];
    cout << endl;

    return 0;
}


Measured memory_bytes: 592
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
ll gcd (ll a,ll b){
    return b ? gcd(b,a%b) : a;
}
main(){
    int N;
    cin >> N;
    ll ans = -1;
    rep(i,0,N){
        int a;
        cin >> a;
        if(ans == -1)ans = a;
        ans = gcd(ans, a);
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using vll = vector<ll>;
using vdouble = vector<double>;
using vstr = vector<string>;
const int INF = 100000000;
typedef pair<int,int> P;
int dx[4] = {1, 0, -1, 0},dy[4] = {0, 1, 0, -1};

int gcd(int a, int b) {
    if (b==0) return a;
   	else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

char S[20][21];
ll H,W;
int sx,sy;
int gx,gy;

int d[20][20];

int bfs(int sx, int sy, int gx, int gy){
	queue<P> que;
	REP(i,H){
		REP(j,W){
			d[i][j] = INF;
		}
	}
	
	que.push(P(sx,sy));
	d[sx][sy] = 0;
	
	while (que.size()){
		P p = que.front(); que.pop();
		
		if(p.first == gx && p.second == gy) break;
		
		REP(i,4){
			
			int nx = p.first + dx[i], ny = p.second + dy[i];
			
			if(0 <= nx && nx < H && ny < W && S[nx][ny] != '#' && d[nx][ny] == INF){
				que.push(P(nx,ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[gx][gy];
}

int main(){
	cin>>H>>W;
	REP(i,20){
		REP(j,21){
			S[i][j]='#';
		}
	}
	REP(i,H){
		REP(j,W){
			cin>>S[i][j];
		}
	}
	ll ans=0;
	
	REP(i,H){
		REP(j,H){
			REP(k,W){
				REP(l,W){
				    //cout<<i<<":"<<j<<":"<<k<<":"<<l<<"::";
				    //cout<<S[i][j]<<S[k][l]<<endl;;
					if(S[i][j]!='#'&&S[k][l]!='#'&&((i!=k)||(j!=l))){
					    ll a=bfs(i,j,k,l);
					    //cout<<i<<":"<<j<<":"<<k<<":"<<l<<"::"<<a<<endl;
						ans=max(a,ans);
					}
				}
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import bisect
import copy
import heapq
import sys
import itertools
import queue
input = sys.stdin.readline
sys.setrecursionlimit(100000)
# mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    N = input().strip()
    for s in N:
        if s == "7":
            print("Yes")
            return
    print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9792
#Left = white ".", Right = Black "#"
# ....####
n = int(input())
s = list(input())
ans = 10**9 + 7
black = s.count("#")
white = s.count(".")
tmp = []
#tmp[0] = "#", tmp[1] = "."
if s[0] == "#":
    tmp.append([1,0])
else:
    tmp.append([0,1])

for i in range(1, n):
    if s[i] == "#":
        tmp.append([tmp[i-1][0] + 1, tmp[i-1][1]])
    else:
        tmp.append([tmp[i-1][0], tmp[i-1][1] + 1])

for i in range(n):
    left = tmp[i][0]
    right = white - tmp[i][1]
    ans = min(ans, left + right)

ans = min(ans, black)
ans = min(ans, white)

print(ans)


Measured memory_bytes: 33444
// input! macro is published in the following URLs.
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// https://github.com/tanakh/competitive-rs.git
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        mut v: [i64; 3],
    }
    let mut count = 0;
    while !(v[0] == v[1] && v[1] == v[2]) {
        v.sort();
        if v[0] == v[1] {
            v[0] += 1;
            v[1] += 1;
        } else {
            v[0] += 2;
        }
        count += 1;
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(){
    int n, x, i, j, k, q;
    
    while(1){
        scanf("%d%d", &n, &x);
        if (n==0&&x==0)break;
        q=0;
        for (i=1;i<=n;++i)
            for(j=i+1;j<=n;++j)
                for(k=j+1;k<=n;++k)
                        if (i+j+k==x)++q;

        printf("%d\n", q);
    }
}



Measured memory_bytes: 1992
import java.util.*;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Q = sc.nextInt();
        String S = sc.next();
        int[] l = new int[Q];
        int[] r = new int[Q];
        for(int i = 0; i < Q; i++){
            l[i] = sc.nextInt()-1;
            r[i] = sc.nextInt()-1;
        }
    
        int[] dp = new int[N];
        dp[0] = 0;
        for(int i = 0; i < N-1; i++){
            if(S.charAt(i) == 'A' && S.charAt(i+1) == 'C'){
                dp[i+1] = dp[i] + 1;
            } else {
                dp[i+1] = dp[i];
            }
        }
        for(int i = 0; i < Q; i++){
            System.out.println(dp[r[i]] - dp[l[i]]);
        }
    }
}


Measured memory_bytes: 82460
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long n, m;
    cin >> n >> m;
    long long a[n], b[n], c[m], d[m], l[m], k, r;
    for (long long i = 0; i < n; i++) cin >> a[i] >> b[i];
    for (long long i = 0; i < m; i++) cin >> c[i] >> d[i];
    for (long long i = 0; i < n; i++)
    {
        k = 1e11;
        for (long long j = 0; j < m; j++)
        {
            l[j] = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (k > l[j])
            {
                k = l[j];
                r = j + 1;
            }
        }
        cout << r << endl;
    }
}

Measured memory_bytes: 3576
import java.util.Scanner;

class Main {
	public static void main(String a[]){
		Scanner scanner = new Scanner(System.in);
		int n1;
		int n2;
		while(scanner.hasNext()){

			n1 = scanner.nextInt();
			n2 = scanner.nextInt();

			System.out.println(gcd(n1,n2) + " " + lcm(n1,n2));
		}
		scanner.close();
	}

	public static int gcd(int a, int b ){
		if(b>a){
			int k = a;
			a = b;
			b = k;
		}
		while(a%b != 0){
			int t = a%b;
			a = b;
			b = t;
		}
		return b;
	}
	

	public static long lcm(int a, int  b){
		return a/gcd(a,b) * b;
	}

}



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

int main(){
    int N,K,min = 1;
    int min1 = 1,min2 = 1;
    cin >> N >> K;
    for(int i = 0; i < N;i++){

        min1 = min * 2;//操作A
        min2 = min + K;//操作B
        if(min1 >= min2)
            min = min2;
        else if(min1 < min2)
            min = min1;
    }
    cout << min << endl;
}

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

int main()
{
    int n,mi,ma,a,b;
    long long sum = 0;

    mi = 100000000;
    ma = -100000000;
    cin >> n;

    for (a=0; a < n; a++)
    {
        cin >> b;
        mi = min(mi,b);
        ma = max(ma,b);
        sum += b;
    }

    cout << mi << " " << ma << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3092
#include <cstdio>
#include <algorithm>
using namespace std;
int n, c, k, ans, x, y, a[100005];
int main() {
	int i;
	scanf("%d%d%d", &n, &c, &k);
	for(i=0; i<n; i++) scanf("%d", &a[i]);
	sort(a, a+n);
	for(i=0; i<n; i++, x--)
		if(!x || a[i]-y>k) ans++, x=c, y=a[i];
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<stdio.h>
#include <algorithm>
#include <set>
#include<math.h>
#include<vector>

using namespace std;

int main(){
    int n,k;cin >> n >> k;
    string s;cin >> s;
    s[k-1] += 32;
    cout << s << endl;

}

Measured memory_bytes: 3540
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n + 1);
    REP(i, 0, n) {
        cin >> a[i];
    }
    a[n] = a[n - 1];
    vector<int> runlen;
    {
        int tmp = 1;
        REP(i, 0, n) {
            if (a[i] == a[i + 1]) {
                runlen.emplace_back(tmp);
                tmp = 0;
            }
            tmp++;
        }
    }
    int ans = 0;
    REP(i, 0, runlen.size()) {
        int cnt = runlen[i];
        if (i > 0) {
            cnt += runlen[i - 1];
        }
        if (i + 1 < runlen.size()) {
            cnt += runlen[i + 1];
        }

        ans = max(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}



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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const ll dx[] = {1,0,-1,0};
const ll dy[] = {0,1,0,-1};
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define m_p make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,ans=0;
    cin >> n;
    vector<ll> d(n);
    rep(i,n) cin >> d[i];
    rep(i,n-1){
        REP(j,i+1,n){
            ans += d[i]*d[j];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
int n,m;
cin>>n>>m;
vector<int> v(n);
int sum=0;
rep(i,n){
  cin>>v[i];
  sum+=v[i];
}
rep(i,n)if(v[i]*4*m<sum)v[i]=0;
sort(v.begin(),v.end());

if(v[n-m]!=0){
  cout<<"Yes"<<endl;
}else{cout<<"No"<<endl;}
return 0;

}


Measured memory_bytes: 256
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val H, W, K = in.nextInt
  val grid = Array.fill(H)(in.next)

  def check(h: Int, w: Int): Boolean = {
    (for {
      hi <- 0 until H
      if ((1 << hi) & h) != 0
      wi <- 0 until W
      if ((1 << wi) & w) != 0
    } yield if (grid(hi).charAt(wi) == '#') 1 else 0).sum == K
  }

  println((for {
    h <- 0 until (1 << H)
    w <- 0 until (1 << W)
  } yield check(h, w)).count(_ == true))
}

Measured memory_bytes: 58288
"""A
K = int(input())
even = 0
odd = 0

for i in range(1,K+1):
	if i%2 == 0:
		even += 1
	else:
		odd += 1

print(even*odd)
"""

x1,y1,x2,y2 = map(int,input().split())

x3 = x2 - (y2-y1)
y3 = y2 + (x2-x1)
x4 = x3 - (y3-y2)
y4 = y3 + (x3-x2)

print(x3,y3,x4,y4)

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
  int n;
  cin >> n;
  double a[n];
  for(int i=0; i<n; i++)cin >> a[i];
  sort(a, a+n);
  double ans = a[0];
  for(int i = 1; i<n; i++){
    ans = (ans+a[i])/2;
  }
  cout << setprecision(8) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

//みんなどんだけ頭いいの

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


	int N = 0;
	const int cm = 1 << 18;
	char cn[cm], * ci = cn, c;
	fread(cn, 1, cm, stdin);
	while ((c = *ci++) >= '0') N = N * 10 + c - '0';

	int L = 0;
	ll kotae = 1;
	ll mod = 1e9 + 7;
	rep1(i, N) kotae = kotae * i % mod;
	rep(i, N + N) {
		if (*ci++ == 'B' ^ (i & 1)) {
			L++;
		}
		else {
			kotae = kotae * L % mod;
			L--;
		}
	}

	if (L == 0) printf("%ld", kotae);
	else printf("0");

	Would you please return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#define FOR(i,a,n) for(i=a;i<n;i++)
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define INF 1000000000
typedef struct LIST{
	int to;
	struct LIST *next;
}Edge;
Edge** init(int v){
	Edge **edge=(Edge**)calloc(v,sizeof(Edge*));
	return edge;
}
void add_edge(Edge **edge,int s,int t){
	Edge *tmp=(Edge*)malloc(sizeof(Edge));
	tmp->to=t;
	tmp->next=edge[s];
	edge[s]=tmp;
	return;
}
void delete_edge(Edge **edge,int v){
	int i;
	Edge *e,*tmp;
	FOR(i,0,v){
		e=edge[i];
		while(e!=NULL){
			tmp=e->next;
			free(e);
			e=tmp;
		}
	}
	return;
}
int used[100000];
Edge **edge;
void dfs(int d[],int v,int k){
	Edge *e;
	d[v]=k; used[v]=1;
	for(e=edge[v];e!=NULL;e=e->next){
		if(!used[e->to]) dfs(d,e->to,k+1);
	}
	return;
}
int d1[100000],d2[100000];
int main(void)
{
	int n,a,b,cnt=0,i;
	scanf("%d",&n);
	edge=init(n);
	FOR(i,0,n-1){
		scanf("%d%d",&a,&b);
		add_edge(edge,--a,--b);
		add_edge(edge,b,a);
	}
	dfs(d1,0,0);
	FOR(i,0,n) used[i]=0;
	dfs(d2,n-1,0);
	FOR(i,0,n) if(d1[i]<=d2[i]) cnt++;
	printf("%s",cnt>n/2?"Fennec":"Snuke");
	return 0;
}


Measured memory_bytes: 11520
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
int N; 
cin >> N; 
long long int A[314159]; 
for (int i = 0; i < N; i++){
cin >> A[i * 3] >> A[i * 3 + 1] >> A[i * 3 + 2]; 
}
sort(A, A+N*3, greater<long long int>()); 
long long int ans; 
for (int i = 0; i < N; i++){
ans += A[i * 2 + 1];
}
cout << ans << endl; 
}

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

/*
ll gcds(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    ll r=a%b;
    if(r==0){
        return b;
    }
    while(r>0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
 
 
ll lcms(ll a,ll b){
    ll mmr=gcds(a,b);
    a=a/mmr;
    b=b/mmr;
    return a*b*mmr;
}
*/
/*
struct UnionFind{
    vector<int> par;
    vector<int> rank;
    vector<int> size;

    //こいつがいわゆるコンストラクタ
    //初期化している
    UnionFind(int N) : par(N),rank(N),size(N){
        for(int i=0;i<N;i++){
            par[i]=i;
            size[i]=1;
            rank[i]=0;
        }
    }

    int find(int x){
        if(x == par[x]) return x;
        return par[x] = find(par[x]);
    }


    void unite(int x, int y){
        int rx,ry;
        rx = find(x);
        ry = find(y);
        if(rx == ry){
            return;
        }
        else{
            if(rank[rx]<rank[ry]){
                par[rx]=ry;
                size[ry]+=size[rx];
            }
            else{
                par[ry]=rx;
                size[rx]+=size[ry];
                if(rank[rx]==rank[ry]){
                    rank[rx]++;
                }
            }
        }
    }


    bool same(int x,int y){
        return find(x) == find(y);
    }
};
*/
// ll PPP(ll k,ll m){
//     ll sum = 1;
//     for(ll i=m;i<=k;i++){
//         sum*=i;
//     }
//     return sum;
// }
ll inf = 1000000000+7;

int main(){
    ll N;
    cin>>N;
    ll a=1;
    ll b=2;
    ll c=1;
    for(ll i=0;i<N;i++){
        a*=10;
        a%=inf;
        b*=9;
        b%=inf;
        c*=8;
        c%=inf;
    }
    ll ans=a-b+c;
    if(ans>-1){
        ans%=inf;
    }
    else{
        while(ans<0){
            ans+=inf;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        while(true){
            int x = sc.nextInt();
            int y = sc.nextInt();
            int z = sc.nextInt();
            if(x == -1 && y == -1 && z == -1){
                break;
            }else{
                if(x==-1 || y==-1){
                    System.out.println("F");
                }else if(x+y>=80){
                    System.out.println("A");
                }else if(x+y>=65){
                    System.out.println("B");
                }else if(x+y>=50){
                    System.out.println("C");
                }else if(x+y>=30){
                    if(z>=50){
                        System.out.println("C");
                    }else{
                        System.out.println("D");
                    }
                }else if(x+y<30){
                    System.out.println("F");
                }
            }
        }
        sc.close();
    }
}



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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int reverse_num(int a){
	int b = 0;
	while(a != 0){
		b = b*10 + a%10;
		a /=10;
	}
	return b;
}


int main() {
	int a, b, c, ans=0;
	cin >> a >> b;
	REP(i, a, b+1){
		c = reverse_num(i);
		if(c == i) ++ans;
	}
	cout << ans;

}


Measured memory_bytes: 256
// --------------
// Tejas Pandey  |
// 18 - 08 - 19  |
// ABC #138      |
// --------------

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		int n;
		cin >> n;
		int a[n];
		for(int i = 0;i < n;i++){
			cin >> a[i];
		}
		sort(a,a+n);
		double ans = (a[0] + a[1])/2.0;
		for(int i = 2;i < n;i++){
			ans = (ans + a[i])/2.0;
		}
		cout << fixed << setprecision(5) << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(0);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";


using namespace std;

ll n,r;

int main(){
FLASH;
cin>>n>>r;
if(n<10)cout<<r+(100*(10-n))<<endl;
else cout<<r<<endl;






return 0;
} 


Measured memory_bytes: 3616
#a,b は消費税x%のときの値段
#p,qは税抜きの値段
#c,d は消費税y%のときの値段

while True:
    x,y,s=map(int,input().split())
    if x==y==s==0:
        break
    else:
        m=0
        for p in range(1,s):
            for q in range(1,p+1):
                a=p*(100+x)//100
                b=q*(100+x)//100
                l=a+b
                if l==s:
                    c=p*(100+y)//100
                    d=q*(100+y)//100
                    n=c+d
                    m=max(m,n)
    print(m)


Measured memory_bytes: 5596
# -*- coding: utf-8 -*-
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

n, x = map(int, input().split())
slimes = list(map(int, input().split()))

# 魔法を唱える回数を固定
cost = sum(slimes)
for k in range(n):
    slimes = [slimes[i-1] if slimes[i] > slimes[i-1] else slimes[i]
              for i in range(n)]
    cost = min(cost, sum(slimes)+(k+1)*x)
print(cost)


Measured memory_bytes: 3188