akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public struct Pair
{
	public long Cost;
	public int Type;

	public Pair(long c, int t)
	{
		Cost = c;
		Type = t;
	}
}


public class C
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		long W = GetLong();
		long H = GetLong();
		long[] p = GetLongs((int)W);
		long[] q = GetLongs((int)H);

		var pairs = new List<Pair>((int)(H + W));
		for(int i = 0; i < W; i++)
			pairs.Add(new Pair(p[i], 0));

		for(int i = 0; i < H; i++)
			pairs.Add(new Pair(q[i], 1));

		pairs.Sort((x, y) => x.Cost.CompareTo(y.Cost));

		long ans = 0;
		long restW = W;
		long restH = H;
		for(int i = 0; ; i++)
		{
			if((restW == 0) && (restH == 0))
				break;

			if(pairs[i].Type == 0)
			{
				if(restW == 0)
					continue;

				ans += (restH + 1) * pairs[i].Cost;
				restW--;
			}
			else
			{
				if(restH == 0)
					continue;

				ans += (restW + 1) * pairs[i].Cost;
				restH--;
			}
		}

		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


Measured memory_bytes: 24008
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>

void Aoj_Learning();

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

void Aoj_Learning()
{
	std::string sInput;
	int intInputNum = 0;
	std::istringstream ss;	// 汎用文字列ストリーム

	// 入力個数の取得
	std::cin >> sInput;
	ss = std::istringstream(sInput);
	ss >> intInputNum;
	if(intInputNum > 36 || 1 > intInputNum)
	{
		exit(0);
	}

	// 数列の取得
	std::string sInputNum[36];
	std::string sOutputBubble[36];
	std::string sOutputSelect[36];
	for(int i = 0; i < intInputNum; i++)
	{
		std::cin >> sInputNum[i];
		sOutputBubble[i] = sInputNum[i];
		sOutputSelect[i] = sInputNum[i];
	}

	// 数列を2種類のソートで整列する
	std::string sTemp;
	int temp1,temp2;

	// バブルソート
	for(int i = 0; i < intInputNum; i++)
	{
		for(int j = intInputNum-1; j > 0; j--)
		{
			sTemp = sOutputBubble[j].substr(1,1);
			ss = std::istringstream(sTemp);
			ss >> temp1;
			sTemp = sOutputBubble[j-1].substr(1,1);
			ss = std::istringstream(sTemp);
			ss >> temp2;

			if(temp1 < temp2)
			{
				sTemp = sOutputBubble[j];
				sOutputBubble[j] = sOutputBubble[j-1];
				sOutputBubble[j-1] = sTemp;
			}
		}
	}

	// バブルソートの出力
	for(int i = 0; i < intInputNum; i++)
	{
		std::cout << sOutputBubble[i];
		if(i == intInputNum-1)
		{
			std::cout << std::endl;
			// バブルソートは安定なソートとする
			std::cout << "Stable" << std::endl;
		}
		else
		{
			std::cout << " ";
		}
	}

	// 選択ソート
	int flag;
	int changeNum;
	for(int i = 0; i < intInputNum; i++)
	{
		//未整理領域から最小値を探す
		flag = 0;
		sTemp = sOutputSelect[i].substr(1,1);
		ss = std::istringstream(sTemp);
		ss >> temp1;
		for(int j = i; j < intInputNum; j++)
		{
			sTemp = sOutputSelect[j].substr(1,1);
			ss = std::istringstream(sTemp);
			ss >> temp2;
			if(temp1 > temp2)
			{
				temp1 = temp2;
				changeNum = j;
				flag = 1;	// 交換が発生する場合フラグを立てる
			}
		}

		// 最小値を未整理領域の先頭と交換
		if(flag == 1)
		{
			sTemp = sOutputSelect[i];
			sOutputSelect[i] = sOutputSelect[changeNum];
			sOutputSelect[changeNum] = sTemp;
		}
	}

	// 選択ソートの出力
	for(int i = 0; i < intInputNum; i++)
	{
		std::cout << sOutputSelect[i];
		if(i == intInputNum-1)
		{
			std::cout << std::endl;
		}
		else
		{
			std::cout << " ";
		}
	}
	// ソートの安定性チェック
	int iStableFlag = 0;
	// バブルソートの内容と比較するように変更
	for(int i = 0; i < intInputNum; i++)
	{
		if(0 != sOutputSelect[i].compare(sOutputBubble[i]))
		{
			iStableFlag = 1;
			break;
		}
	}

	if(iStableFlag == 1)
	{
		std::cout << "Not stable" << std::endl;
	}
	else
	{
		std::cout << "Stable" << std::endl;
	}
}




Measured memory_bytes: 3172
#include<stdio.h>

int main(){
  char c, s[11], flag = 0;
  
  scanf("%s", s);
  c = getchar();
  
  int i = 0;
  do{
    c = getchar();
    if(c != s[i] && s[i] != '\0'){
      flag = 1;
      break;
    }
    i++;
  }while(c != '\0' && s[i] != '\0');
  
  if(flag == 0){
    printf("Yes");
  }
  else{
    printf("No");
  }
  
  return 0;
}

Measured memory_bytes: 1724
#include <iostream>
#include <string>
using namespace std;
int main(){
  int n;
  cin >> n;
  string a;
  cin >> a;
  int yes = 0;
  for(int i = 0;i <= n / 2 - 1;i++){
    if(a[i] != a[i + n / 2]){
      yes = 1;
    } 
  }
  if(n == 1 || n % 2 == 1){
    yes = 1;
  }
  if(yes == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "4", "hoge", "english", "hoge", "enigma" ].parse.expand.solve == "No" );
	assert( [ "9", "basic", "c", "cpp", "php", "python", "nadesico", "ocaml", "lua", "assembly" ].parse.expand.solve == "Yes" );
	assert( [ "8", "a", "aa", "aaa", "aaaa", "aaaaa", "aaaaaa", "aaa", "aaaaaaa" ].parse.expand.solve == "No" );
	assert( [ "3", "abc", "arc", "agc" ].parse.expand.solve == "No" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	auto ws = new string[ n ];
	foreach( ref w; ws )
	{
		input.popFront;
		w = input.front.strip;
	}
	return tuple( ws );
}

auto solve( string[] ws )
{
	if( ws.dup.sort().uniq.walkLength != ws.length ) return "No";
	
	auto p = "0" ~ ws[ 0 ][ 0 ];
	
	foreach( w; ws )
	{
		if( p[ $ - 1 ] != w[ 0 ] ) return "No";
		p = w;
	}
	
	return "Yes";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,k;
    cin>>n>>k;
    string num,tmp;
    for(int i=0;i<k;i++){
        cin>>tmp;
        num+=tmp;
    }
    //cout<<num<<endl;
    int count=0;
    for(int i=n;;i++){
        string check=to_string(i);
        for(auto e:num){
            if(find(check.begin(),check.end(),e)==check.end()){
                count++;
            }
        }
        if(count==k){
            cout<<check<<endl;
            return 0;
        }
        count=0;
    }
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
//#include<boost/multi_array.hpp>
//#include<boost/optional.hpp>
//#include<boost/range/irange.hpp>
//#include<boost/range/algorithm.hpp>
//#include<boost/range/adaptors.hpp>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

void Main() {
	int d, t, s;
	cin >> d >> t >> s;
	if (t * s >= d) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

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

Measured memory_bytes: 3608
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> P;
const int mw=10001,mn=101;
int n,W;
int dp[mn][mw],v[mn],w[mn];

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

  
}



Measured memory_bytes: 7020
import math
a,b,c=map(int,input().split())
d=b-c/(a**2)
d=d*2
if d==0:
  print(0)
elif d>b:
  e=(c*2)/(a*b)
  print(math.degrees(math.atan(b/e)))
else:
  print(math.degrees(math.atan(d/a)))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
#define M 1000000007
#define deb(x) cout<<#x<<'='<<x<<endl
using namespace std;
signed main()
{
	int h,w;
	cin>>h>>w;
	string s[h];
	for(int i=0; i<h; i++)
	{
		cin>>s[i];
	}
	int dp[h][w];
	for(int i=0; i<h; i++)
	{
		for(int j=0; j<w; j++)
		{
			if (s[i][j]=='#')
				dp[i][j]=0;
			else if (i==0 && j==0)
				dp[i][j]=1;
			else if (i==0)
				dp[i][j]=dp[i][j-1];
			else if (j==0)
				dp[i][j]=dp[i-1][j];
			else
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%M;
		}
	}
	cout<<dp[h-1][w-1];
}

Measured memory_bytes: 9088
s = list(input())

base = ['A', 'T', 'C', 'G']

a = -1
b = -1

L = 0
R = -1
mode = 1
for i in range(len(s)):
    if mode == 0:
        if s[i] in base:
            b += 1
        else:
            mode = 1
            if b - a > R - L:
                L = a
                R = b
    elif mode == 1:
        if s[i] in base:
            a = i
            b = i
            mode = 0

if mode == 0 and b - a > R - L:
    L = a
    R = b

print(R - L + 1)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
using namespace std;
#define INF 0x3f3f3f3f
typedef long long ll;
int main () {
    int n, k;
    while (cin >>n >>k) {
        int ans = 0;
        while (n) {
            ans++;
            n /= k;
        }
        cout << ans << "\n";
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <utility>

using namespace std;

template<typename T> 
void show(T a){
  for(auto i : a){ cout << i << " "; }
  cout << endl;
}


int main(int argc, char *argv[]){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int a, b, n;
  cin >> n >> a >> b;
  cout << min(a, b) << endl;
  int res = a+b-n;
  cout << (res > 0 ? res : 0) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <numeric>

using namespace std;

typedef long long int ll;
typedef long int li;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
    ll ans=0;
    ll n,q;
    cin >> n >> q;
    int a[n];
    int b[n];
    for(ll i=0;i<n;i++){
        b[i]=0;
    }
    for(ll i=0;i<n;i++){
        char s;
        cin >> s;
        if(s=='A')a[i]=0;
        if(s=='T')a[i]=1;
        if(s=='G')a[i]=2;
        if(s=='C')a[i]=3;
    }
  b[0]=0;
    for(ll i=0;i<n-1;i++){
        if(a[i]==0&&a[i+1]==3)b[i+1]=b[i]+1;
        else{b[i+1]=b[i];}
    }
    
    for(ll i=0;i<q;i++){
        ll l,r;
        cin >> l >> r;
        cout << b[r-1]-b[l-1] << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 1664
import numpy as np
#n = int(input())
#n, m = map(int, input().split())
#for i in range(n):

h1, m1, h2, m2, k = map(int, input().split())

time1 = h1*60+m1
time2 = h2*60+m2

t = time2-k
print(t-time1)

Measured memory_bytes: 27132
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        sc.close();
        if (k == 1) {
            System.out.println(0);
            return;
        }
        int ans = n - k;
        if (ans <= 0) {
            ans = 0;
        } else {
        }
        System.out.println(ans);

        sc.close();
    }
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct ii {
    int a, b;
    bool operator < (ii o) const {
        return tie(a, b) < tie(o.a, o.b);
    }
};
struct iii {
    int a, b, c;
    bool operator < (iii o) const {
        return tie(a, b, c) < tie(o.a, o.b, o.c);
    }
};

const int MOD = 1000000007;
const int INF = 1000000000;
const int MAXN = 1000005;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    int N;
    cin >> N;
    if (N >= 30) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 3664
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define true 1
#define false 0
#define MAX 100000
#define mod 1000000007
//#define mod 10000000+7
typedef long long ll;
typedef unsigned char Uchar; 

int main(void){
 int n;
  scanf("%d",&n);
  ll a[n];
  ll b[n];
  scanf("%lld",&a[0]);
  b[0] = a[0];
  int i,j;
  for(i=1;i<n;i++){
    
    scanf("%lld",&a[i]);
    b[i] = (a[i] + b[i-1]) % mod;
  }
  ll res = 0;
   for(i = 1;i < n;i++) {
    res += a[i] * b[i-1];
    res %= mod;
  }
  printf("%lld\n", res);
  
  return 0;
}

Measured memory_bytes: 4812
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()

int main(){
    int n,k,c;
    cin>>n>>k;
    long double ans=0,p;
    REP(i,n){
        p=1;
        c=i+1;
        while(c<k){
            c*=2;
            p/=2;
        }
        ans+=p;
    }
    cout<<fixed << setprecision(10)<<ans/n<<endl;
}

Measured memory_bytes: 256
N, X = map(int, input().split())
x_list = [abs(int(i) - X) for i in input().split()]
# N, X = map(int, '3 81'.split())
# x_list = [abs(int(i) - X) for i in '33 105 57'.split()]
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
res = [x_list[0]]
for i in range(1, N):
    res.append(gcd(res[i-1], x_list[i]))
print(min(res))

Measured memory_bytes: 14252
n = int(input())
s = input()
t = input()
tmp = 0
for i in range(n):
    # print(s[-i:], t[:len(t) if (i == 0) else i])
    if s[-i:] == t[:n if (i == 0) else i]:
        if i == 0:
            i += n
        tmp = max(tmp, i)
print(len(s) + len(t) - tmp)


Measured memory_bytes: 2940
n = int(input())
ans = 0
a = 0
b = 0
ba = 0
for _ in range(n):
    s = input()
    if s[0] == 'B' and s[-1] == 'A':
        ba += 1
    else:
        if s[0] == 'B':
            b += 1
        if s[-1] == 'A':
            a += 1
    ans += s.count('AB')
t = ans
ans += ba - 1
if a >= 1:
    ans += 1
    a -= 1
if b >= 1:
    ans += 1
    b -= 1
ans += min(a, b)
print(max(ans, t))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define re register
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n,m,ans;
signed main(){
	ans=read();
	n=read();m=read();
	for(re int i=n;i<=m;++i){
		if(i%ans==0){
			puts("OK");
			return 0;
		}
	}
	return puts("NG"),0;
}

Measured memory_bytes: 3636
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#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>
#endif

// 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 <atomic>
#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>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int main(){
  ll N, T; cin >> N >> T;
  vector<ll> t(N); rep(i, N) cin >> t[i];
  ll ans = 0;
  rep(i, N-1){
    if(t[i] + T >= t[i+1]){
      ans += t[i+1] - t[i];
    }else{
      ans += T;
    }
  }
  ans += T;
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int N, C[505], S[505], F[505];

long long int  ans(int i, long long int t) {

	if (i == N) { return t; }

	if (t <= S[i]) { return ans(i + 1, S[i] + C[i]); }
	else {   
		long long int h = t / F[i];
		if (t != h*F[i]) { h++; }
		return ans(i + 1, h*F[i] + C[i]);
	}
	return -1;
}

int main(void) {

	cin >> N;

	for (int i = 1; i <= N - 1; i++) {
		cin >> C[i]; cin >> S[i]; cin >> F[i];
	}


	for (int i = 1; i <= N; i++) {
		cout << ans(i, 0) << endl;
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int ans = 0;
        int nowIndex = 1;

        for (int i = 1; i <= n; i++) {
            if (sc.nextInt() == nowIndex) {
                nowIndex++;
            } else {
                ans++;
            }
        }
        if (ans == n) {
            ans = -1;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 64864
#include <bits/stdc++.h>
using namespace std;
const long long int MAXN = 1111, MOD = 1000000007;
char v[MAXN][MAXN];
int n, m;
long long int resp, dp[MAXN][MAXN];
int main(){
    scanf("%d%d",&n,&m);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            scanf(" %c",&v[i][j]);
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(v[i][j] == '.'){
                if(i == 0 && j == 0)    dp[i][j] = 1;
                else if(i == 0) dp[i][j] = dp[i][j - 1] % MOD; 
                else if(j == 0) dp[i][j] = dp[i - 1][j] % MOD;
                else    dp[i][j] = dp[i - 1][j] + dp[i][j - 1] % MOD;
                
            }  
            else    dp[i][j] = 0;
        }
    }
    resp = dp[n - 1][m - 1];
    resp = resp % MOD;
    printf("%lld",resp);
}


Measured memory_bytes: 11008
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
     ll n;cin >> n;
     if(n&1) cout << 0;
     else {
            ll sum = 0;
        for(ll i = 5;n/i/2>0;i*=5)
            sum += n/i/2;
     cout << sum;
     }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

int main(void) {
  cout.precision(12);

  long N, M;
  cin >> N >> M;
  unordered_set<long> a;
  rep (i, M) {
    long tmp;
    cin >> tmp;
    a.insert(tmp);
  }

  vector<long> result(N + 1);
  rep(i, N + 1) result[i] = 0;
  result[0] = 1;

  for (long i = 1; i <= N; i++) {
    if (a.count(i) > 0) continue;
    result[i] += result[i-1];
    if (i - 2 >= 0) result[i] += result[i-2];
    result[i] %= MOD;
  }

  cout << result[N] << endl;

  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i = 0; i < n; i++) cin >> h.at(i);
  
  int ans = 0;
  int sum = 0;
  for(int i = 0; i < n - 1; i++){
    if(h.at(i) >= h.at(i + 1)){
      sum++;
      ans = max(ans, sum);
    }
    else sum = 0;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
double pi=3.14159265358979;
int m;
vector<int> r;
double ans;
bool check(double mid){
	double p[8]={},cop[8]={},sum=0;
	p[0]=mid;
	cop[0]=cos(p[0]);
	sum=p[0];
	rep1(i,m-1){
		cop[i]=cop[i-1]/r[(i+1)%m]*r[i-1];
		if(abs(cop[i])>1) return false;
		p[i]=acos(cop[i]);
		sum+=p[i];
	}
	if(sum>2*pi) return false;
	return true;
}
void update(double mid){
	double p[8]={},cop[8]={},sum=0;
	p[0]=mid;
	cop[0]=cos(p[0]);
	sum=p[0];
	rep1(i,m-1){
		cop[i]=cop[i-1]/r[(i+1)%m]*r[i-1];
		if(abs(cop[i])>1) return;
		p[i]=acos(cop[i]);
		sum+=p[i];
	}
	if(sum>2*pi) return;
	double tmp=0;
	rep(i,m){
		tmp+=r[i]*r[(i+1)%m]*sin(p[i])/2;
	}
	ans=max(ans,tmp);
}
int main(){
	int N;
	cin>>N;
	rep(i,N){
		int ri;
		cin>>ri;
		r.pb(ri);
	}
	while(r.size()>=3){
		sort(all(r));
		m=r.size();
		do{
			double ub=pi,lb=0;
			int cnt=0;
			while(cnt<100){
				double mid=(ub+lb)/2;
				if(check(mid)) lb=mid;
				else ub=mid;
				cnt++;
			}
			update(lb);
		}while(next_permutation(r.begin(),r.end()));
		sort(all(r),greater<int>());
		r.erase(r.end()-1);
	}
	printf("%.12f\n",ans);
}

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

namespace geometry {
	using Real = double;
	using Point = complex<Real>;
	constexpr Real EPS = 1e-9;
	struct Circle {
		Point p;
		Real r;
	};
	// 内積
	inline Real dot(const Point& lhs, const Point& rhs) {
		return (conj(lhs) * rhs).real();
	}
	// 外積
	inline Real cross(const Point& lhs, const Point& rhs) {
		return (conj(lhs) * rhs).imag();
	}
	// 円の交点
	vector<Point> intersect(const Circle& c1, const Circle& c2) {
		const Real dist = abs(c1.p - c2.p);
		vector<Point> ret;
		if(dist > c1.r + c2.r) return ret;
		if(dist < abs(c1.r - c2.r)) return ret;
		const Real rc = (dist * dist + c1.r * c1.r - c2.r * c2.r) / (2 * dist);
		const Real rs = sqrt(c1.r * c1.r - rc * rc);
		const Point vec = (c2.p - c1.p) / dist;
		ret.emplace_back(c1.p + vec * Point(rc, rs));
		ret.emplace_back(c1.p + vec * Point(rc, -rs));
		return ret;
	}
	// a の b に対する正射影ベクトル
	inline Point projection(const Point& a, const Point& b) {
		return b * dot(a, b) / norm(b);
	}
	// 直線の交点
	// Point intersect(const Line& l1, const Line& l2) {
	// 	const Point v1 = l1.p2 - l1.p1;
	// 	const Point v2 = l2.p2 - l2.p1;

	// }

	inline istream& operator>>(istream& is, Point& p) {
		Real x, y;
		is >> x >> y;
		p = Point(x, y);
		return is;
	}
	inline ostream& operator<<(ostream& os, const Point &p) {
		return os << fixed << setprecision(15) << p.real() << " " << p.imag();
	}
}

using namespace geometry;
int main() {
	Point p1, p2; cin >> p1 >> p2;
	int q; cin >> q;
	while(q--) {
		Point p; cin >> p;
		cout << projection(p - p1, p2 - p1) + p1 << '\n';
	}
	return 0;
}


Measured memory_bytes: 3360
import sys
import numpy as np
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    n, a, b = map(int, input().rstrip().split())
    x = list(map(int, input().rstrip().split()))
    ans = 0
    for diff in np.diff(x):
        if diff * a < b:
            ans += diff * a
        else:
            ans += b
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38096
import sys


N, Y = map(int, input().split())

k_max = Y//10000

for k in range(k_max+1):
    for j in range(N-k+1):
        if 0 <= N-j-k == (Y - 5000*j - 10000*k)/1000:
            print(k, j, N-j-k)
            sys.exit()

print(-1, -1, -1)

"""
1000*i + 5000*j + 10000*k = Y
i = (Y - 5000*j - 10000*k) / 1000
i = N - j - k
"""


Measured memory_bytes: 3060
N = int(input())
A = [input().split() for i in range(2)]
candy = 0
max = 0

for i in range(N):
  candy = 0
  for j in range(i+1):
    candy += int(A[0][j])
  for k in range(i,N):
  	candy += int(A[1][k])
  if candy > max: max = candy

print(max)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

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

    int64_t n, p;
    cin >> n >> p;
    int64_t res = 1;

    std::vector<int64_t> prime;
    bool list[100010] = {};
    for (int i = 2; i <= 100000; i++) {
        list[i] = true;
    }
    int64_t top = 2;
    while (top <= sqrt(100000)) {
        prime.push_back(top);
        for (int i = top; i <= 100000; i += top) {
            list[i] = false;
        }
        while (1) {
            top++;
            if (list[top])
                break;
        }
    }
    for (int i = sqrt(100000); i <= 100000; i++) {
        if (list[i])
            prime.push_back(i);
    }

    // for (auto x : prime) {
    //     cout << x << endl;
    // }

    if (n == 1) {
        cout << p << endl;
        return 0;
    } else if (p == 1) {
        cout << 1 << endl;
        return 0;
    }

    for (int64_t a = std::pow(p, double(1 / (double)n)) + 1; a >= 2; a--) {
        if (p % (int64_t)std::pow(a, n) == 0) {
            res *= a;
            p /= (int64_t)std::pow(a, n);
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int N;
cin >> N;
vector<int> l(N),r(N);
int ans = 0;
for (int i = 0;i < N;i++) {
  cin >> l.at(i) >> r.at(i);
  ans += r.at(i) - l.at(i) + 1;
}
cout << ans << endl;


return 0;
}

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

int main(){
  string s,t;
  cin >>s >>t;
  
  bool abc=false;
  for(int i=s.size()-t.size();i>=0;i--){
    
    bool abcd=true;
    
    for(int j=t.size()-1;j>=0;j--){
      if(s[i+j] != '?'){
        
        if(s[i+j]!=t[j])abcd = false;
      }
    }
    if(abcd){
      
      for(int j=0;j<t.size();j++) s[i+j]=t[j];
      
      for(int j=0;j<s.size();j++)
        
        if(s[j]=='?')s[j]='a';
      
      abc = true;
      break;
    }
  }
  if (abc) {
    cout << s <<endl;
  }
  else {
    cout <<  "UNRESTORABLE"  <<endl;
}

}

Measured memory_bytes: 256
// ABC042B - 文字列大好きいろはちゃんイージー

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

int main() {
	int N, L;
	cin >> N >> L;

	vector<string> S(N);
	for (int i = 0; i < N; i++) {
		cin >> S.at(i);
	}

	sort(S.begin(), S.end());

	string ans = "";
	for (int i = 0; i < N; i++) {
		ans += S.at(i);
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000 //2e9
#define LLINF 2000000000000000000ll // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define dmp(x) cerr << #x << ": " << x << endl;

template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}

template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T,vector<T>,greater<T>>;
template<class T> vector<T> vect(int len,T elem){ return vector<T>(len,elem); }

template<class T,class U>
ostream& operator << (ostream& os,const pair<T,U>& p){
  os << p.fi << ',' << p.sec; return os;
}
template<class T,class U>
istream& operator >> (istream& is,pair<T,U>& p){
  is >> p.fi >> p.sec; return is;
}
template<class T>
ostream& operator << (ostream &os,const vector<T> &vec){
  for(int i=0;i<vec.size();i++){
    os << vec[i];
    if(i+1<vec.size())os << ' ';
  }
  return os;
}
template<class T>
istream& operator >> (istream &is,vector<T>& vec){
  for(int i=0;i<vec.size();i++)is >> vec[i];
  return is;
}
void fastio(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(20);
}
namespace Util{
  template<class T>
  vector<pair<T,int>> runLength(vector<T> v){
    vector<pair<T,int>> res;
    for(int i=0;i<v.size();i++){
      if(res.empty()||res.back().first!=v[i])res.push_back(make_pair(v[i],1));
      else res.back().second++;
    }
    return res;
  }
  template<class T>
  void compress(vector<T> &v){
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
  }
}

void solve(){
  int k,q;
  cin >> k >> q;
  vector<ll> d(k);
  cin >> d;
  for(int i=0;i<q;i++){
    ll n,x,m;
    cin >> n >> x >> m;
    n--;
    x %= m;
    vector<ll> v = d;
    for(int j=0;j<k;j++){
      v[j]%=m;
      if(v[j]==0)v[j] = m;
    }
    ll Sv = accumulate(all(v),0ll);
    ll s = x + Sv * (n/k) + accumulate(v.begin(),v.begin()+(n%k),0ll);
    cout << n-s/m << endl;
  }
  return ;
}
 
signed main(){
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 384
/*
  選択ソート
*/
#include <stdio.h>

void swap(int *, int *);

int main()
{
  int i, j, minj,  count = 0, n, ary[100];

  scanf("%d", &n);
  for( i = 0; i<n; i++ )
    scanf("%d", &ary[i]);

  /*選択ソートを用いて昇順にソート*/
  for( i = 0; i<n; i++ )
    {
      minj = i;

      for( j = i+1; j<n; j++ )
	{
	  if( ary[j] < ary[minj] )
	    {
	      minj = j;
	    }
	}
      if( minj != i )
	{
	  swap(&ary[i], &ary[minj]);
	  count++;
	}
    }

  for( i = 0; i<n; i++ )
   {
     printf("%d", ary[i]);

     if( i != n-1 )
       printf(" ");
   }
  printf("\n%d\n", count);

  return 0;
}

/*引数として与えられた整数 a,b を交換する関数*/
void swap(int *a, int *b)
{
  int tmp;

  tmp = *a;
  *a = *b;
  *b = tmp;
}



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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


int main()
{
    int N,K;
    cin >> N >> K;
    vector<int> h(N);
    rep(i,N) cin >> h[i];

    vector<ll> dp(N,INF_LL);
    dp[0] = 0;

    rep(i,N)
    {
        REP(j, 1, K+1)
        {
            if( i+j < N ) chmin(dp[i+j], dp[i]+abs(h[i+j]-h[i]) );
        }
    }
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    char c[a][b];
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++){
            cin>>c[i][j];
        }
    }
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++){
            if(c[i][j]=='#'&&!(c[min(a-1,i+1)][j]=='#'||c[max(0,i-1)][j]=='#'||c[i][min(b-1,j+1)]=='#'||c[i][max(0,j-1)]=='#')){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
}
    

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

using namespace std;

int main(){
	int N,ans(0),M(0);
  	cin >> N;
  	vector<int> h(N);
  	for(int i = 0 ; i < N ; i ++){
      	cin >> h[i];
      	if(h[i] >= M){
        	M = h[i];
          	ans ++;
        }
    }
  	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>
#include <stack>
#include <tuple>
#include <map>
#include <cassert>
#include <numeric>

using namespace std;
typedef long long ll;

struct mint{
    static const long long MOD = 1000000007;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator-=(mint a){
        v -= a.v;
        if(v < 0){ v += MOD; }
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

    mint operator*(mint a) const{
        return mint(v) *= a;
    }

    mint operator+(mint a) const {
        return mint(v) += a;
    }

    mint operator-(mint a) const {
        return mint(v) -= a;
    }

    mint pow(long long k) const {
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }

    static mint factorial(long long n){
        mint res(1);
        for(int i = n; i > 1; --i){
            res *= mint(i);
        }
        return res;
    }

    bool operator<(const mint &a) const {
        return v < a.v;
    };
};

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

    vector<ll> ds;
    for(ll i = 1; i * i <= n; ++i){
        ds.push_back(i);
        ds.push_back(n / i);
    }
    sort(ds.begin(), ds.end());
    ds.erase(unique(ds.begin(), ds.end()), ds.end());
    vector<mint> num;
    for(ll i = 0; i < ds.size() - 1; ++i){
        num.push_back(
            n / ds.at(i) - n / ds.at(i + 1)
        );
    }
    num.push_back(1);
    reverse(num.begin(), num.end());

    vector<vector<mint>> dp(k, vector<mint>(num.size()));
    for(ll i = 0; i < num.size(); ++i){
        dp.at(0).at(i) = num.at(i);
    }
    for(ll i = 1; i < k; ++i){
        vector<mint> cs(num.size(), 0);
        cs.at(0) = dp.at(i - 1).at(0);
        for(ll j = 1; j < num.size(); ++j){
            cs.at(j) = cs.at(j - 1) + dp.at(i - 1).at(j);
        }

        for(ll j = 0; j < num.size(); ++j){
            dp.at(i).at(j) = cs.at(cs.size() - j - 1) * num.at(j);
        }
    }

    mint ans = accumulate(dp.back().begin(), dp.back().end(), mint(0));
    cout << ans.v << endl;
    return 0;
}


Measured memory_bytes: 51448
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;



int main()
{
	string s;
	int k;
	cin >> s >> k;
	vector<string> sub;

	for (int i = 0; i <s.size(); i++) {
		string temp = "";
		for (int j = i; j < s.size() && j < i + 5; j++) {
			temp += s[j];
			sub.push_back(temp);
		}
		
	}

	sort(sub.begin(), sub.end());
	unique(sub.begin(), sub.end());
	
	cout << sub[k - 1] << endl;
	return 0;
}

Measured memory_bytes: 1660
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {

    private static Scanner sc;

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            int N = sc.nextInt();
            long sum = 0;

            for(int i=1; i<=N; i++) {
                if(i%3!=0&&i%5!=0) sum+=i;
            }

            System.out.println(sum);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 32604
//#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>

//Some constants don't work
#ifndef INT_MAX
#define INT_MAX 2147483647
#endif
#ifndef INT_MIN
#define INT_MIN -2147483648
#endif
//short hand tricks
typedef long long ll;

using namespace std;

int main(int argc, char * argv[]) {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int r = 8-(n-400)/200;
    cout << r << "\n";
    return 0;
}


Measured memory_bytes: 3684
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n=int(input());a=sorted(int(x)-i for i,x in enumerate(input().split()));print(sum(abs(i-a[n//2])for i in a))\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 27056
#include<bits/stdc++.h>
#define read() Read<int>()
namespace pb_ds{   
    namespace io{
        const int MaxBuff=1<<15;
        const int Output=1<<23;
        char B[MaxBuff],*S=B,*T=B;
		#define getc() ((S==T)&&(T=(S=B)+fread(B,1,MaxBuff,stdin),S==T)?0:*S++)
        char Out[Output],*iter=Out;
        inline void flush(){
            fwrite(Out,1,iter-Out,stdout);
            iter=Out;
        }
    }
    template<class Type> inline Type Read(){
        using namespace io;
        register char ch;
        register Type ans=0; 
        register bool neg=0;
        while(ch=getc(),(ch<'0' || ch>'9') && ch!='-');
        ch=='-'?neg=1:ans=ch-'0';
        while(ch=getc(),'0'<= ch && ch<='9') ans=ans*10+ch-'0';
        return neg?-ans:ans;
    }
    template<class Type> inline void Print(register Type x,register char ch='\n'){
        using namespace io;
        if(!x) *iter++='0';
        else{
            if(x<0) *iter++='-',x=-x;
            static int s[100]; 
            register int t=0;
            while(x) s[++t]=x%10,x/=10;
            while(t) *iter++='0'+s[t--];
        }
        *iter++=ch;
    }
}
using namespace pb_ds;
using namespace std;
typedef long long ll;
const int N=1005;
const int Mod=1e9+7;
inline void ad(int &x,int y){
	x+=y;
	if (x>=Mod) x-=Mod;
}
inline int Pow(int x,int y){
	int res=1;
	while (y){
		if (y&1) res=1ll*res*x%Mod;
		x=1ll*x*x%Mod;
		y>>=1;
	}
	return res;
}
int n,m,ans;
int p[N],cnt[N][N];
int mn[N][N],mx[N][N];
int dp[N][N],f[N];
int fac[N],inv[N];
inline void math_init(int nn){
	fac[0]=1;
	for (int i=1;i<=nn;++i)
		fac[i]=1ll*fac[i-1]*i%Mod;
	inv[nn]=Pow(fac[nn],Mod-2);
	for (int i=nn;i;--i)
		inv[i-1]=1ll*inv[i]*i%Mod;
}
inline void init(){
	f[0]=1;
	for (int i=2;i<=n;i+=2){
		/*f[i]=1ll*fac[i]*inv[i>>1]%Mod;
		f[i]=1ll*f[i]*Pow(Pow(2,i>>1),Mod-2)%Mod;*/
		f[i]=1ll*f[i-2]*(i-1)%Mod;
	}
}
inline int solve(int l,int r){
	if (~dp[l][r]) return dp[l][r];
	if (mx[l][r]>r || mn[l][r]<l) return dp[l][r]=0;
	if (cnt[l][r]&1) return dp[l][r]=0;
	int res=f[cnt[l][r]];
	for (int i=l;i<r;++i)
		ad(res,Mod-(1ll*solve(l,i)*f[cnt[i+1][r]]%Mod));
	return dp[l][r]=res;
}
int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	n=read()*2,m=read();
	for (int i=1;i<=m;++i){
		int u=read(),v=read();
		p[u]=v,p[v]=u;
	}
	for (int i=1;i<=n;++i){
		mx[i][i-1]=0,mn[i][i-1]=n+1;
		for (int j=i;j<=n;++j){
			mx[i][j]=mx[i][j-1];
			mn[i][j]=mn[i][j-1];
			cnt[i][j]=cnt[i][j-1];
			if (p[j]){
				mx[i][j]=max(mx[i][j],p[j]);
				mn[i][j]=min(mn[i][j],p[j]);
			}else ++cnt[i][j];
		}
	}
	memset(dp,-1,sizeof(dp));
	math_init(n),init();
	for (int i=1;i<=n;++i){
		for (int j=i;j<=n;++j){
			solve(i,j);
		//	printf("%d %d %d\n",i,j,dp[i][j]);
			ad(ans,1ll*dp[i][j]*f[cnt[1][i-1]+cnt[j+1][n]]%Mod);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 16640
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int sx = scanner.nextInt();
        final int sy = scanner.nextInt();
        final int tx = scanner.nextInt();
        final int ty = scanner.nextInt();

        final int xDistance = tx - sx;
        for (int i = 0; i < xDistance; i++) {
            System.out.print("R");
        }

        final int yDistance = ty - sy;
        for (int i = 0; i < yDistance; i++) {
            System.out.print("U");
        }

        for (int i = 0; i < xDistance; i++) {
            System.out.print("L");
        }

        for (int i = 0; i < yDistance; i++) {
            System.out.print("D");
        }

        System.out.print("D");

        for (int i = 0; i < xDistance + 1; i++) {
            System.out.print("R");
        }

        for (int i = 0; i < yDistance + 1; i++) {
            System.out.print("U");
        }

        System.out.print("L");

        System.out.print("U");

        for (int i = 0; i < xDistance + 1; i++) {
            System.out.print("L");
        }

        for (int i = 0; i < yDistance + 1; i++) {
            System.out.print("D");
        }

        System.out.println("R");
    }
}


Measured memory_bytes: 23252
#include <cstdio>
using namespace std;
int n,a,sum[1000005];
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;++i){
		scanf("%d",&a);
		sum[a]++;
	}
	for(int i=1;i<=n;++i){
		printf("%d\n",sum[i]);
	}
	return 0;
}


Measured memory_bytes: 2452
#include<stdio.h>
 
int main()
{
  int k;
  int l=1;
  int i;
  int a[2000001];
  int ans=1;
  int t=1;
  scanf("%d",&k);
  if(k%7==0) k/=7;
  for(i=0;i<2000001;i++){
    a[i]=0;
  }
  while(l<k){
    l*=10;
    l+=1;
    t++;
  }
  ans+=t-1;
  a[l]=1;
  while(1){
    l%=k;
    if(l==0){
      printf("%d",ans);
      return 0;
    }
    else if(l!=0){
      if(a[l]==0){
        a[l]=1;
        l*=10;
        l+=1;
      }
      else if(a[l]!=0){
        ans=-1;
        printf("%d",ans);
        return 0;
      }
    }
    ans++;
  }
}


Measured memory_bytes: 9536
#include <bits/stdc++.h>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    string s;
    cin >> s;
    ll a=0,bc=0;
    ll cnt=0;
    bool renzoku=false;
    ll i=0;
    while(i<s.size()){
        ll nowa=0;
        while(s[i]=='A'){
            i++;
            nowa++;
        }
        while(s[i]=='B' && s[i+1]=='C'){
            i+=2;
            bc++;
        }
        a+=nowa;
        cnt+=a*bc;
        if(bc==0){
            a=0;
            i++;
        }
        bc=0;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

const int maxn=200000+5;
const int INF=1000000;

vector <int> mp[maxn];
int dist[maxn];

int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		mp[a].push_back(b);
		mp[b].push_back(a);
	}
	queue <int> que;
	que.push(1);
	dist[1]=0;
	while(!que.empty()){
		int u=que.front();
		que.pop();
		for(int i=0;i<mp[u].size();i++){
			if(!dist[mp[u][i]]){
				dist[mp[u][i]]=dist[u]+1;
				que.push(mp[u][i]);
			}
		}
	}
	if(dist[n]==2) cout<<"POSSIBLE"; else cout<<"IMPOSSIBLE";
	return 0;
}


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

int N;
const int MAX_N = 2.0e5 + 100;
int a[MAX_N];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> a[i];

    if (N % 2 == 0) {
        stack<int> front;
        queue<int> back;
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                back.push(a[i]);
            }
            else {
                front.push(a[i]);
            }
        }
        
        while (!front.empty()) {
            cout << front.top() << " ";
            front.pop();
        }
        while (!back.empty()) {
            cout << back.front() << " ";
            back.pop();
        }
        cout << endl;

    }
    else {
        stack<int> front;
        queue<int> back;
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                front.push(a[i]);
            }
            else {
                back.push(a[i]);                
            }
        }
        
        while (!front.empty()) {
            cout << front.top() << " ";
            front.pop();
        }
        while (!back.empty()) {
            cout << back.front() << " ";
            back.pop();
        }
        cout << endl;

    }

    return 0;
}


Measured memory_bytes: 3840