akhauriyash/Code-Regression huggingface dataset:
import java.util.HashMap;
import java.util.Scanner;
import java.util.Stack;

public class Main
{
	//Ford-Fulkerson algorithm implementation practice
	static int v, e;
	
	static class Node
	{
		int id;
//		ArrayList<Edge> edges = new ArrayList<>();
		
		HashMap<Integer, Integer> resflow = new HashMap<>();
		
		void incflow(int i, int flow)
		{
			if(resflow.containsKey(i))
				resflow.put(i, resflow.get(i)+flow);
			else
				resflow.put(i, flow);
		}
		
		public Node(int i)
		{
			id = i;
		}
	}
	
	static class Edge
	{
		Node node;
		int flow = 0;
		int resflow = 0;
		
		public Edge(int fl)
		{
			flow = fl;
			resflow = fl;
		}
	}
	
	static Node[] node;

	public static void main(String[] args) 
	{
//		System.out.println("Aygreets!");
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		int y = sc.nextInt();
		e = sc.nextInt();
		
		v = x + y + 2;
		node = new Node[v];
		
		for(int i = 0; i < v; i++)
			node[i] = new Node(i);
		
		for(int i = 0; i < e; i++)
		{ //read edges
			int a = sc.nextInt()+1; //node in x
			int b = sc.nextInt()+1+x; //node in y
			int flow = 1; //flow that can still flow through this edge.
			
			node[a].incflow(b, flow);
			node[b].incflow(a, 0);
		}
		
		for(int i = 1; i < x+1; i++)
		{ //add flow from source to x
			node[0].incflow(i, 1);
		}
		
		for(int i = x+1; i < v-1; i++)
		{ //add flow from y to sink
			node[i].incflow(v-1, 1);
		}
		
		//This part is the same as standard Ford-Fulkerson
		int[] par = new int[v];
		
		//Traverse.
		boolean keepgoing = true;
		int sunk = 0;
		
		while(keepgoing)
		{ //keep finding augmenting paths until it's determined that there isn't one.
			keepgoing = false;
			int pos = -1;
			
			boolean[] visited = new boolean[v];
			int[] flowing = new int[v];
			
			Stack<Integer> stack = new Stack<>();
			stack.add(0);
			flowing[0] = 999999999;
			//DFS
			while(!stack.isEmpty())
			{
				pos = stack.pop();
				Node nd = node[pos];
				
				if(!visited[pos])
				{
					visited[pos] = true;
					
					if(pos == v-1)
					{ //reached sink
						keepgoing = true;
						int backpos = pos;
						int flow = flowing[pos];
						sunk += flow;
						
						while(backpos != 0)
						{ //backtrack; update residual capacities.
							node[backpos].incflow(par[backpos], flow);
							node[par[backpos]].incflow(backpos, -flow);
							backpos = par[backpos];
						}
						
						break;
					}
					
					for(int ed : nd.resflow.keySet())
					{ //find unvisited nodes that can have flow flow from this node
						int res = nd.resflow.get(ed);
						if(res > 0 && !visited[ed])
						{ //can flow here
							stack.add(ed);
							flowing[ed] = Math.min(flowing[pos], res);
							par[ed] = pos;
						}
					}
				}
			}
		}
		
		System.out.println(sunk);
	}

}



Measured memory_bytes: 68484
#include<stdio.h>

int main(){
  int h, n, tmp, sum = 0;
  scanf("%d %d", &h, &n);
  
  for(int i = 0;i < n;i++){
    scanf("%d", &tmp);
    sum += tmp;
  }
  
  if(sum >= h){
  	puts("Yes");
  }
  else{
    puts("No");
  }
  
  return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))
num_minus = sum([1 if v < 0 else 0 for v in A])
sum_abs = sum([abs(v) for v in A])
min_abs = min([abs(v) for v in A])
print(sum_abs if num_minus % 2 == 0 else sum_abs - min_abs * 2)

Measured memory_bytes: 19964
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int k = Integer.parseInt(sc.next());
    int s = Integer.parseInt(sc.next());
    int[] a = new int[n];
    int p = 0;

    if(n==k){
      for(int i=0; i<n; i++){
        System.out.print(s);
        System.out.print(" ");
      }
      System.out.print("\n");
      return;
    } else {
      if(s==1){
        for(int i=0; i<n; i++){
          if(i<k){
            System.out.print(1);
            System.out.print(" ");
          } else {
            System.out.print(9);
            System.out.print(" ");
          }
        }
      } else {
        for(int i=0; i<n; i++){
          if(i<=k){
            if(i%2 == 1){
              System.out.print(1);
              System.out.print(" ");
            } else {
              System.out.print(s-1);
              System.out.print(" ");
            }
          } else {
            System.out.print(888888888);
            System.out.print(" ");
          }
        }
      }
      System.out.print("\n");
      return;
    }

  }
}


Measured memory_bytes: 42564
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define mip map<int, pair<int,int> >
#define inf INT_MAX
#define inf1 LONGLONG_MAX
#define sz(v) v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define deb(x) cout<<#x<<"is "<<x<<endl;
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
vector<int>adj [T];
			/*brownsands IIITA*/
 
void solve()
{	string s,s1;
 	int n,i;
	cin>>n;
  	cin>>s>>s1;
  for(i=0;i<n;i++)
   cout<<s[i]<<s1[i];
}
signed main()
{
   boost
        int test=0,t;
		//cin>>t;
		t=1;
		while(test++ <t){
            //cout<<"Case "<<test<<": ";
            solve();
            //cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
               }		
}

Measured memory_bytes: 23808
#include<iostream>
#include<algorithm>
#include<vector>
#include <numeric>
using namespace std;
int main(int argc, char const *argv[]) {
    int N,tmp;
    int ans=0;
    std::vector<int> h;

    std::cin >> N;
    for (size_t i = 0; i < N; i++) {
        std::cin >> tmp;
        h.push_back(tmp);
    }
    h.push_back(0);
    int base=0;
    int before=0;
    int adder=0;
    for (size_t i = 0; i < h.size(); i++) {

        if(before<h[i]){
        }else if(before==h[i]){
        }else if(before>h[i]){
            ans+=before-base;
            base=h[i];
        }
        before=h[i];
    }
    std::cout << ans ;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<climits>
#include<algorithm>
using namespace std;
int AskMCM(int *p,int n){
    int cost[n+1][n+1];
    for(int i = 1;i <= n;++i) cost[i][i] =0;
    for(int l = 2;l <= n; l++){
        for(int i = 1;i <= n - l + 1;i++){
            int j = i+l -1;
            int min_cost = INT_MAX;
            for(int k = i;k < j;++k) min_cost = min(min_cost,cost[i][k] + cost[k+1][j] + p[i-1] * p[k] * p[j]);
            cost[i][j] = min_cost;
        }
    }
    return cost[1][n];
}

int main(){
    int n,r,tmp;
    scanf("%d",&n);
    int p[n+1];
    for(int i = 1;i <= n;++i) scanf("%d %d",&p[i-1],&p[i]);
    printf("%d\n",AskMCM(p,n));
}


Measured memory_bytes: 2760
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    n = int(input())
    V = list(map(int, input().split()))

    d1, d2 = defaultdict(int), defaultdict(int)
    for i in range(n):
        if i % 2 == 0:
            d1[V[i]] += 1
        else:
            d2[V[i]] += 1

    if len(set(V)) == 1:
        print(n // 2)
        return

    num = n // 2
    ans = INF
    for k1, v1 in sorted(d1.items(), key=lambda x:x[1], reverse=True)[:2]:
        for k2, v2 in sorted(d2.items(), key=lambda x:x[1], reverse=True)[:2]:
            if k1 != k2:
                t = (num - v1) + (num - v2)
                ans = min(ans, t)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 23132
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int i=0;
  for(;i < s.size();i++){
    if(i%2==0 && s.at(i)=='L') break;
    else if(i%2==1 && s.at(i)=='R') break;
  }
  if(i == s.size()) cout << "Yes" << endl;
  else cout << "No";
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n,d;cin>>n>>d;
  vector<int> p(n);
  int i;
  rep(i,n)cin>>p[i];
  rep(i,n)p[i]-=d;
  int ans=0;
  rep(i,n)
  {
    if(p[i]>0)ans+=p[i];
  }
  if(ans<=0)cout<<"kusoge"<<endl;
  else cout<<ans<<endl;
}



Measured memory_bytes: 3104
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-9
#define M_PI 3.141592653589793
#define bsize 300

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 1100031;

int m,k;
vector<int> v,v2;
vector<int> V;

int used[N];

vector<int> ev(vector<int> &V){
	vector<int> ret;
	for (int i=0;i<V.size();i++){
		used[i]=0;
	}
	for (int i=0;i<V.size();i++){
		if (used[i])
			continue;
		int X=V[i];
		used[i]=1;
		for (int j=i+1;j<V.size();j++){
			X^=V[j];
			if (V[j]==V[i]){
				used[j]=1;
				break;
			}
		}
		ret.push_back(X);
	}
	sort(ret.begin(),ret.end());
	vector<int> ret2;
	for (int i=0;i<ret.size();i++){
		if (i==0||ret[i]!=ret[i-1])
			ret2.push_back(ret[i]);
	}
	return ret2;
}

bool valid(vector<int> V,int t){
	return (ev(V).size()==1&&ev(V)[0]==t);
}

int main(){
//    freopen("apache.in","r",stdin);
//    freopen("apache.out","w",stdout);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    //cin.tie(0);

   /* for (int i=0;i<4;i++){
    	V.push_back(i);
    	V.push_back(i);
    }

    do{
    	if (valid(V)){
    		cout<<ev(V)[0]<<endl;
    		for (int i=0;i<V.size();i++){
    			cout<<V[i]<<" ";
    		}
    		cout<<endl;
    	}
    }
    while (next_permutation(V.begin(),V.end()));
*/
    cin>>m>>k;
    if (k>=(1<<m)){
    	cout<<-1<<endl;
    }
    else
    {
    	if (m<3){
    		for (int i=0;i<(1<<m);i++){
				V.push_back(i);
				V.push_back(i);
			}

    		int found=0;
			do{
				if (valid(V,k)){
					for (int i=0;i<V.size();i++){
						if (i)
							cout<<" ";
						cout<<V[i];
					}
					found=1;
					cout<<endl;
					break;
				}
			}
			while (next_permutation(V.begin(),V.end()));
			if (!found){
				cout<<-1<<endl;
			}
			return 0;
    	}
    	for (int i=0;i<(1<<m);i++){
    		if (i!=k)
    			v.push_back(i);

    	}
    	v.push_back(k);
    	for (int i=(1<<m)-1;i>=0;--i){
    		if (i!=k)v.push_back(i);
    	}
    	v.push_back(k);

    	for (int i=0;i<v.size();i++){
    		if (i)
    			cout<<" ";
    		cout<<v[i];
    	}
    	cout<<endl;
    }
//    cin.get(); cin.get();
    return 0;
}


Measured memory_bytes: 3060
import numpy as np

N,A,B,C,D = list(map(int, input().split()))
S = input()
s = S
ans = "No"
if "##" in S[B : min([C, D])]:
    ans = "No"
else:
    if C < D:
        ans = "No"
        if not "##" in S[B:D]:
            if not "##" in S[A:C]:
                ans = "Yes"
    else:
        S = S[:C]
        s = S
        
        if not "##" in S[B:D]:
            S = S[:D-1] + "#" + S[D:]
            if not "##" in S[A:]:
                ans = "Yes"
            else:
                ans = "No"
        else:
            ans = "No"

        S = s
        if ans is "No":
            if "..." in S[B-2:D]:
                if not "##" in S[A:]:
                    S = S[:D]
                    if not "##" in S[B:]:
                        ans = "Yes"
                    else:
                        ans = "No"
                else:
                    ans = "No"        

print(ans)

Measured memory_bytes: 21500
K,N=map(int, input().split())
A=list(map(int, input().split()))
max_diff = 0
ck = 0
for i in range(0,N):
    if i == N -1:
        ck = abs(A[(i+1)%N] + K  - A[i])
    else:
        ck = abs(A[(i+1)%N] - A[i])
    if max_diff < ck:
        max_diff = ck
print(K - max_diff)


Measured memory_bytes: 25452
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();

		int ans = 0;
		for(int i = 1;i <= N;i = i + 2){
			int cnt = 0;
			for(int j = 1;j <= i;j++){
				int tmp = i % j;
				if(tmp == 0){
					cnt ++;
				}
			}
			if(cnt == 8){
				ans ++;
			}
		}
		
		System.out.println(ans);
		
   		sc.close();
        return ;

    }
    
}



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

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

        public static void Solve()
        {
            var s = Console.ReadLine();
            var answer = 0;
            for (var i = 0; i < s.Length; i++)
            {
                if (s[i] == '+') answer++;
                if (s[i] == '-') answer--;
            }
            Console.WriteLine(answer);
        }
    }
}


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

int main() {
    long long int n,h[100010],dp[100010],i,j;
    cin>>n;
    for(i=0;i<n;i++) cin>>h[i];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;

using namespace std;

int main(){
    int  n;
    cin >> n;
    int i=0;
    int tmp=0;
    while(tmp<=n){
        i+=1;
        tmp = i*i;
    }
    cout << (i-1)*(i-1) << endl;
    }

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
using namespace std;
int N,M;
string S;
int A[11];
vector<int> D;
int calc(char num){
  int n = (int)(num-'0');
  n*=2;
  return n/10+n%10;
}
int calc(int num){
  int n = num;
  n*=2;
  return n/10+n%10;
}
int solve(int no,int sum){
  if(no==(int)D.size()){
    //    printf("%d\n",sum);
    if(!(sum%10)) return 1;
    return 0;
  }
  int ret=0;
  for(int i=0;i<M;i++){
    ret+= solve(no+1,sum+( ((D[no])%2)?A[i]:calc(A[i])) );
  }
  return ret;
}
int main(){
  cin >> N;
  cin >> S;
  cin >> M;
  for(int i=0;i<M;i++)
    cin >> A[i];
  for(int i=0;i<N;i++)
    if(S[i]=='*') D.push_back(N-i);
  int sum=0;
  for(int i=N-1,j=1;i>-1;i--,j++){
    if(S[i]=='*') continue;
    if(!(j%2)) sum+=calc(S[i]);
    else sum+=(int)(S[i]-'0');
  }
  //  printf("%d\n",sum);
  printf("%d\n",solve(0,sum));
}

Measured memory_bytes: 1352
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 07/25/20 20:57:10
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int x; cin>>x;
  int th = 1800;
  int ans = 1;
  while (th >= 400) {
    if (th <= x and x < th+200)
      break;
    th -= 200;
    ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3644
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << -1; return;}

void solve() {
    int n, k;
    string s;
    cin >> n >> k >> s;
    s[k - 1] = char(tolower(s[k - 1]));
    cout << s;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 3656
#include <math.h>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <functional>
#include <typeinfo>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define mp(a, b) make_pair(a, b)
#define all(vec) (vec).begin(), (vec).end()
#define yn(formula) (formula) ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(formula) (formula) ? (cout << "YES" << endl) : (cout << "NO" << endl)
#define MIN(a, b) ((a) < (b)) ? (a) : (b)
#define LLONG_MAX     9223372036854775807i64

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
typedef vector<vll> vvl;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vp> vvp;
typedef vector<vpl> vvpl;

constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 29;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };

struct edge { ll to; ll cost; };

/*<ここから>***********************************************************/


int main()
{
	int X;
	cin >> X;

	ll ans = 1;
	repr(b, 2, X) {
		repr(p, 2, X) {

			ll n = pow(b, p);
			if (n > X) continue;
			if (ans < n) ans = n;
		}
	}

	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
	char suit;
	int value;
};

struct Card L[MAX/2+2],R[MAX/2+2];


void merge(struct Card A[] , int n , int left , int mid , int right)
{
	int n1 = mid - left;
	int n2 = right -mid;
	for( int i = 0; i < n1; i++) L[i] = A[left+i];
	for( int i = 0; i < n2; i++) R[i] = A[mid+i];
	L[n1].value = R[n2].value = SENTINEL;
	int i = 0 , j = 0;
	for( int k = left; k < right; k++)
	{
		if(L[i].value <= R[j].value)
		{
			A[k] = L[i++];
		}
		else{
			A[k] = R[j++];
		}
	}
}

void mergeSort(struct Card A[] , int n , int left , int right)
{
	if(left + 1 < right)
	{
		int mid = (left+right)/2;
		mergeSort(A,n,left,mid);
		mergeSort(A,n,mid,right);
		merge(A,n,left,mid,right);
	}
}


int partition(struct Card A[] , int n , int p , int r)
{
	struct Card x = A[r];
	struct Card t;
	int i = p-1;
	int j;
	for( j = p; j < r; j++)
	{
		if(A[j].value <= x.value)
		{
			i++;
			t = A[i];
			A[i] = A[j];
			A[j] = t;
		}
	}
	t = A[i+1];
	A[i+1] = A[r];
	A[r] = t;
	return i+1;
}

void quickSort(struct Card A[], int n , int p , int r)
{
	int q;
	if(p < r){
		q = partition(A,n,p,r);
		quickSort(A,n,p,q-1);
		quickSort(A,n,q+1,r);
	}
}

int main(void)
{
	int n , i , v;
	struct Card A[MAX] , B[MAX];
	char S[10];
	int stable = 1;
	scanf("%d",&n);
	for( i = 0; i < n; i++)
	{
		scanf("%s %d",S,&v);
		A[i].suit = B[i].suit = S[0];
		A[i].value = B[i].value = v;
	}
	
	mergeSort(A,n,0,n);
	quickSort(B,n,0,n-1);
	
	for( i = 0; i < n; i++)
	{
		if(A[i].suit != B[i].suit) stable = 0;
	}
	
	if(stable == 1) printf("Stable\n");
	else printf("Not stable\n");
	for( i = 0; i < n; i++)
	{
		printf("%c %d\n",B[i].suit,B[i].value);
	}
	return 0;
}


Measured memory_bytes: 4036
import math
n = int(input())
h = list(map(int,input().split(' ')))
'''
n-=1
inf = int(1e9+5)

dp = {}
def frog1(i):
    if i==n:
        return 0
    if i in dp:
        return dp[i]
    
    a = 0
    b = 0
    if i+1>n:
        a = inf
    else:
        a = frog1(i+1)+abs(h[i]-h[i+1])

    if i+2>n:
        b = inf
    else:
        b = frog1(i+2)+abs(h[i]-h[i+2])
    dp[i] = min(a,b)
    return dp[i]
'''
def solve(n,h):
    dp = [0]*n
    for i in reversed(range(0,n-1)):
        if i==n-1:
            dp[i] = 0
        else:
            if i==n-2:
                dp[i] = abs(h[n-1]-h[n-2])
                continue
            a = 0
            b = 0
            if i+1<=n-1:
                a = dp[i+1]+abs(h[i]-h[i+1])
            if i+2<=n-1:
                b = dp[i+2]+abs(h[i]-h[i+2])  
            dp[i] = min(a,b)
    return dp[0]
print(solve(n,h))


Measured memory_bytes: 14480
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        n--;
        List<Character> ansList = new ArrayList<>();
        while (n>=0) {
            long nAns = n % 26 + 97;
            ansList.add((char) nAns);
            n = n / 26 - 1;
        }

        for (int i=ansList.size()-1;i>=0;i--) {
            System.out.print(ansList.get(i));
        }
        System.out.println();
    }
}


Measured memory_bytes: 35820
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

W, H, x, y = wi()
ans = (H * W) / 2
if x == W / 2 and y == H / 2:
    print(ans, 1)
else:
    print(ans, 0)


Measured memory_bytes: 5464
#include<stdio.h>
void cal(){
int mark[10],h[10],i,r,high;
	for(i=0;i<10;i++){
		scanf("%d",h+i);
		mark[i]=0;
	}
	for(r=1;r<=3;r++){
		high=0;
		while(mark[high])high++;
		for(i=1;i<10;i++)if(h[i]>h[high]&&!mark[i])high=i;
		printf("%d\n",h[high]);
		mark[high]=1;
		}
}
int main(){
	cal();
	return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>

using namespace std;
using ll = long long int; 

void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;

    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}


ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

ll keta(ll a){
  ll ans = 1;
  while(1){
    if(a/10 > 0){
      ans++;
      a = a/10;
    }
    if(a<10) break;
  }
  return ans;
}

const int MAX = 50;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void){

    int n;
    string s,t;
    cin>>n;
    cin>>s>>t;
 
    for(int i=0;i<n;i++){
        cout<<s[i]<<t[i];
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
using LL = long long;
const int INF = 0x3f3f3f3f;
const int N = 400005;
LL a[N];
LL sum[N];
int main()
{
	LL k, n;
	scanf("%lld%lld", &k, &n);

	LL res = INF;
	for (int i = 1; i <= n; ++i)
	{
		scanf("%lld", &a[i]);
		a[n + i] = a[i] + k;
	}

	//for (int i = 1; i <= 2 * n; ++i) sum[i] = sum[i - 1] + a[i];

	for (int i = 1; i + n - 1 <= 2 * n; ++i)
	{
		res = min(res, a[i + n - 1] - a[i]);
	}

	printf("%lld\n", res);


	return 0;
}

Measured memory_bytes: 4480
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
struct Struct;

//#[proconio::fastout]
fn main() {
    input! {
        n: usize,
        a:[i64;n],
    }

    let mut v = Vec::new();
    for i in 0..n {
        v.push((i, a[i]));
    }

    v.sort_unstable_by_key(|p| -p.1);

    // 大きい方から貪欲だと、左右どちらも同じ距離の場合に困る??

    let mut dp = vec![vec![0i64; n + 1]; n + 1]; // dp[l][r]: Aが大きい方からl+r個を、左にl個、右にr個動かした場合のスコア
    fn diffabs(x: usize, y: usize) -> i64 {
        (x as i64 - y as i64).abs()
    }

    for i in 0..n {
        for l in 0..=i {
            let r = i - l;
            dp[l + 1][r] = max(dp[l + 1][r], dp[l][r] + v[i].1 * diffabs(v[i].0, l));
            dp[l][r + 1] = max(dp[l][r + 1], dp[l][r] + v[i].1 * diffabs(n - r - 1, v[i].0));
        }
    }

    let mut ans = 0;
    for l in 0..=n {
        let r = n - l;
        ans = max(ans, dp[l][r]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 33444
#include <bits/stdc++.h>
using namespace std;
#define M_PI 3.14159265358979323846
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> ipair;
typedef pair<ll, ll> llpair;

ll n, a[200001];

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin>>n;
    for(int i=0; i<n; i++) cin>>a[i];
    ll ans = 0, max_yet = a[0];
    for(int i=1; i<n; i++){
        if(a[i]<max_yet) ans += (max_yet-a[i]);
        max_yet = max(max_yet, a[i]);
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 5196
#include <bits/stdc++.h>
#define N 100050
using namespace std;


int n, tr[N], a[N], b[N], c[N], mark[N], F[N];
int x[2], y[2];

inline int lowbit(int x) {return (x)&(-x);}

inline int rd() {int r;scanf("%d",&r);return r;	}

void add(int x) {
	for (int i=x;i<=n;i+=lowbit(i)) tr[i]+=1;	
}

int ask(int x) {
	int ret = 0;
	for (int i=x;i>=1;i-=lowbit(i)) ret+=tr[i];
	return ret;	
}

void no() {
	puts("No");
	exit(0);	
}

int main() {
	n = rd();
	for (int i=1;i<=n;i++) a[i] = rd();
	for (int i=1;i<=n;i++) b[i] = rd();
	for (int i=1;i<=n;i++) c[i] = rd();
	
	for (int i=1;i<=n;i++) {
        if(a[i]%3==1)
        {
            if(b[i]!=a[i]+1||c[i]!=a[i]+2)no();
            F[i]=(c[i])/3;
        }
        else if(a[i]%3==0)
        {
            if(b[i]!=c[i]+1||a[i]!=c[i]+2)no();
            y[i&1]++;
            y[i&1]%=2;
            F[i]=a[i]/3;
        }
        else no();
        if(F[i]%2!=i%2)no();
	}
	for (int i=1;i<=n;i++) tr[i] = 0;

	for (int i=n;i>=1;i-=2) {
		y[1^(i&1)] += ask( F[i] );
		y[1^(i&1)] %= 2;
		add(F[i]);	
	}
	
	for (int i=1;i<=n;i++) tr[i] = 0;
	
	for (int i=n-1;i>=1;i-=2) {
		y[1^(i&1)] += ask( F[i] );
		y[1^(i&1)] %= 2;
		add(F[i]);	
	}
	
	if (y[0]||y[1]) no();
	puts("Yes");
	return 0;	
}

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

int n,a[200010];
signed main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	if(a[0]){
		cout<<-1<<endl;
		return 0;
	}
	int now=a[0];
	int ans=0;
	for(int i=1;i<n;i++){
		if(now+2<=a[i]){
			cout<<-1<<endl;
			return 0;
		}
		if(now>=a[i])ans+=now;
		now=a[i];
	}
	ans+=now;
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<int> v(n+1);//iでの行き先がv[i]
    vector<int> visited(n+1, -1);
    for (int i = 1; i < n + 1; i++)
    {
        cin >> v[i];
    }
    int cycle = 1;
    int now = 1;
    vector<int> s;


    while (visited[now]==-1)
    {
        visited[now] = s.size();
        s.push_back(now);
        now = v[now];
    }
    cycle = s.size() - visited[now];
    int tail = visited[now];

    if(k<tail)
    {
        cout << s[k] << endl;
    }
    else
    {
        k -= tail;
        k %= cycle;
        cout << s[tail + k] << endl;
    }


    return 0;
}

Measured memory_bytes: 5828
#include <stdio.h>
#include<string.h>
int main(void){
    int n,i,j,t=0,h=0;
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        char a[101],b[101];
        scanf("%s%s",a,b);
        if(strcmp(a,b)==0){
        t++;
        h++;
        }else{
            int y,z=0;
            y=strlen(a)<strlen(b)?strlen(a):strlen(b);
        for(j=0;j<y;j++){
            if(a[j]==b[j])
            continue;
            else if(a[j]<b[j]){
             break;
            }else{
                z=1;
                break;
            }
        }
            if(j==y){
                if(strlen(a)<strlen(b))
                h+=3;
                else
                t+=3;
                
            }
            else{
            if(z)
            t+=3;
            else
            h+=3;
                
            }
            
        
        }
    }
    printf("%d %d\n",t,h);
    return 0;
}

Measured memory_bytes: 2668
#include <bits/stdc++.h>
#include <boost/dynamic_bitset.hpp>

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 998244353
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 200005;

int N, Q;
string S;
char T[MAX_N], D[MAX_N];

bool used[MAX_N];

signed main()
{
  cin >> N >> Q;
  cin >> S;
  REP(q,Q) {
    cin >> T[q] >> D[q];
  }

  int L = 0, R = N-1;

  int l = -1, r = N;
  while(r-l>1) {
    int mid = (l+r)/2;
    int pos = mid;
    REP(q,Q) {
      if(S[pos] == T[q]) {
        if(D[q] == 'L') {
          pos--;
        } else {
          pos++;
        }
      }
      if(pos < 0 || pos >= N) {
        break;
      }
    }
    if(pos < 0) {
      l = mid;
    } else {
      r = mid;
    }
  }

  L = l+1;

  l = -1, r = N;
  while(r-l>1) {
    int mid = (l+r)/2;
    int pos = mid;
    REP(q,Q) {
      if(S[pos] == T[q]) {
        if(D[q] == 'L') {
          pos--;
        } else {
          pos++;
        }
      }
      if(pos >= N) {
        break;
      }
    }
    if(pos >= N) {
      r = mid;
    } else {
      l = mid;
    }
  }

  R = r-1;

  cout << (R-L)+1 << endl;

  return 0;
}

Measured memory_bytes: 900
# -*- coding: utf-8 -*-
N = int(input())
A = map(int, input().split())
h = []

max_h = 0
for a in A:
    if max_h <= a:
        max_h = a
        h.append(0)
    else:
        h.append(max_h - a)

print(sum(h))


Measured memory_bytes: 32012
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;
static const int N = 100;

#define INT_MIN     (-2147483647 - 1) /* minimum (signed) int value */
#define INT_MAX       2147483647    /* maximum (signed) int value */

void solve(vector<int> &data)
{
	vector<vector<int> > dp(N + 1, vector<int>(N + 1, 0));

	int nums = data.size() - 1;
	for (int len = 2; len <= nums; ++len)
	{
		for (int l = 1; l <= nums - len + 1; ++l)
		{
			int r = l + len - 1;
			dp[l][r] = INT_MAX;
			for (int m = l; m <= r - 1; ++m)
			{
				dp[l][r] = min(dp[l][r], dp[l][m] + dp[m+1][r] + data[l - 1] * data[m] * data[r]);
			}
		}
	}

	cout << dp[1][nums] << endl;
}

int main()
{
	int num; cin >> num;
	vector<int> data(num + 1);
	for (int i = 1; i <= num; ++i)
		cin >> data[i-1] >> data[i];

	solve(data);
}

Measured memory_bytes: 3188
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		if (t.substring(0, t.length() - 1).equals(s)) {
		    System.out.println("Yes");
		} else {
		    System.out.println("No");
		}
	}
}


Measured memory_bytes: 35700
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
      int K = in.nextInt();  
      String S = in.next();
      
      if (S.length()<=K){
          System.out.println(S);
         }
         else {
           System.out.println(S.substring(0,K)+ "...");
                }
        }
}

Measured memory_bytes: 38664
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define print(x) cout << #x << " = " << x << endl;

using namespace std;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;


int main() {
	int A, B;
	cin >> A >> B;

	int ans = 0;
	for (int i = A; i <= B; ++i) {
		string str = to_string(i);
		bool bCheck = true;
		for (int j = 0; j < str.size() / 2; j++) {
			if (str[j] != str[str.size() - j - 1]) bCheck = false;
		}
		if (bCheck) ans++;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>
#include <random>


using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int d;
    cin >> d;

    vector c(27, 0);
    for (int i=1; i<27; i++) cin >> c[i];
    int csum = accumulate(c.begin(), c.end(), 0);


    vector<vector<int>> s(d, vector<int>(27, 0));
    for (int i=0; i<d; i++) {
        for (int j=1; j<27; j++)
            cin >> s[i][j];
    }

    vector last(27, 0);
    for (int i=1; i<=d; i++) {
        vector<int> tmp;
        for (int j=1; j<27; j++) {
            tmp.push_back(s[i-1][j] - c[j] * abs(i - last[j]));
        }
        auto it = max_element(tmp.begin(), tmp.end());
        int index = it - tmp.begin() + 1;
        cout << index << endl;
        last[index-1] = i;
    }
}

Measured memory_bytes: 3248
#include <iostream>

using namespace std;

typedef long long int ll;


int main () {
    int n;
    string s;

    cin >> n;
    cin >> s;

    int i = 0;
    int j = 0;

    char c = s[0];
    int ans = 1;

    for (int i = 0; i < n; i++) {
        if (c != s[i]) {
            c = s[i];
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

fn keta(n: u64) -> usize {
    if n < 10 {
        1
    } else {
        1 + keta(n / 10)
    }
}

fn main() {
    let mut sc = Scanner::new();
    let n: u64 = sc.cin();
    let mut ans = 30;
    for p in 1..n+1 {
        if p * p > n { break }
        if n % p > 0 { continue }
        let q = n / p;
        ans = min!(ans, max!(keta(p), keta(q)));
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
<?php
// Your code here!
    $input = trim(fgets(STDIN));
    $value = explode(" ", $input);
    $L = $value[0];
    $R = $value[1];
    $d = $value[2];
    $count = 0;
    for (; $L <= $R; $L++) {
        
        if ($L % $d === 0) {
            $count++;
        };
    };
    echo $count;
?>


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

#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

struct node{
	int x,y,id;
	node(int xx=0,int yy=0,int ii=0):x(xx),y(yy),id(ii){}
	bool operator<(const node c){return x==c.x&&y==c.y?id<c.id:x==c.x?y<c.y:x<c.x;}
}p[1005];

int n,m,cys,ans;
int l[505],r[505],now[505];
ll d[505][505];

ll mod(ll x){return x>=cys?x-cys:x;}

int main(){
	n=readint(); cys=readint();
	for(int i=0;i<=n-1;i++) l[i]=sqrt(n*n-i*i-1)+1;  //a
	for(int i=0;i<=2*n-1;i++) r[i]=sqrt(4*n*n-i*i)+1;  //c  b
	r[0]--;
	for(int i=0;i<=n-1;i++) p[++m]=node(l[i],r[i],n-i);
	for(int i=n;i<=2*n-1;i++) p[++m]=node(r[i],-1,i);
	sort(p+1,p+m+1);
	for(int i=1;i<=m;i++) now[i]=now[i-1]+(p[i].y>=0);
	for(int i=0;i<=n;i++){
		memset(d,0,sizeof(d));
		d[0][0]=1;
		for(int j=1;j<=2*n;j++){
			if(p[j].y>=0) for(int k=0;k<=min(j,i);k++) d[j][k]=mod(d[j-1][k]*max(p[j].y-2*n+1-p[j].id+n-i+k,0)%cys+(k>0?d[j-1][k-1]*max(p[j].x-j+now[j]-k+1,0)%cys:0));
			else for(int k=0;k<=min(j,i);k++) d[j][k]=d[j-1][k]*max(p[j].x-j+1+now[j]-k,0)%cys;
		}
		ans=mod(ans+(i&1?cys-1:1)*d[2*n][i]%cys);
	}
	cout<<ans<<endl;
	return 0;
}

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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int a = input(), b = input(), c = input(), d = input();
    
    int cntt = (c + b - 1) / b;
    int cnta = (a + d - 1) / d;

    cout << (cntt <= cnta ? "Yes" : "No") << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define SORT(c) sort(ALL((c)))
#define debug(x)                 \
    do {                         \
        std::cout << #x << ": "; \
        view(x);                 \
    } while (0)

template <typename T>
void view(T e) {
    std::cout << e << std::endl;
}
template <typename T>
void view(const std::vector<T>& v) {
    for (const auto& e : v) {
        std::cout << e << ", ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>>& vv) {
    for (const auto& v : vv) {
        view(v);
    }
}

int main() {
    ll K;
    cin >> K;
    queue<ll> q;
    rep(i, 9) { q.push(i + 1); }

    ll ans = 0;
    rep(i, K) {
        ll tmp = q.front();
        q.pop();
        if (tmp % 10 != 0) {
            q.push(tmp * 10 + tmp % 10 - 1);
        }
        q.push(tmp * 10 + tmp % 10);
        if (tmp % 10 != 9) {
            q.push(tmp * 10 + tmp % 10 + 1);
        }
        ans = tmp;
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
  long long w,a,b;
  cin>>w>>a>>b;
  if(a<=b&&b<=a+w){
    cout<<0<<endl;
  }
  else if(a>b&&a<=b+w){
    cout<<0<<endl;
  }
  else if(a<b&&b>a+w){
    cout<<b-a-w<<endl;
  }
  else if(a>b&&a>b+w){
    cout<<a-b-w<<endl;
  }
}
 


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}


int nextInt() { int x; scanf("%d", &x); return x;}

ll C(int n, int r) {
  ll res = 1;
  for (int i = 1; i <= r; i++) {
    res *= n + 1 - i;
    res /= i;
  }
  return res;
}

int main2() {
  int N = nextInt();
  int P = nextInt();
  int even = 0, odd = 0;
  REP(i, N) {
    int a = nextInt() % 2;
    if (a == 0) even++; else odd++;
  }
  ll ans = 0;
  for (int i = P; i <= odd; i += 2) {
    ans += C(odd, i);
  }
  ans *= (1LL << even);
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



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

int main(){
  double N;
  cin >> N;
  vector<double> a(N);
  for(int i=0;i<N;i++)  cin >> a.at(i);

  double ave=0;
  for(int i=0;i<N;i++)  ave+=a.at(i);
  ave/=N;
  double mi=1e9;
  for(int i=0;i<N;i++)  mi=min(mi,abs(ave-a.at(i)));
  for(int i=0;i<N;i++){
    if(abs(ave-a.at(i))==mi){
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define tam 100010
#define ull long long
 
using namespace std;
 
typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <ll, ll> dl;
typedef pair <int, int> ii;
typedef vector <ii> vii;
typedef vector <vi> graph;
 
bool comp(int a, int b) {
	return a > b;
}
 
int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
 
	ull a;
	double b;
	cin >> a >> b;
	ull c = round(b * 100);
	ull ans = a * c;
	cout << (ans / 100) << "\n";
	return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
ll a,b,c,d;
ll f(ll x)
{
    return x-(x/c+x/d-x/(c*d/__gcd(c,d)));
}
int main()
{
    cin>>a>>b>>c>>d;
    //printf("%lld %lld\n",f(b),f(a-1));
    printf("%lld\n",f(b)-f(a-1));
    return 0;
}


Measured memory_bytes: 256