akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} // input vector


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

int N, K; cin >> N >> K;
VI H(N); invec(H);
sort(ALL(H), greater<i64>());

if (N > K) cout << accumulate(RANGE(H, K, N), 0LL) << "\n";
else cout << "0\n";

}
// 書いて考える．場合分け．情報整理．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <utility>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W; cin >> H >> W;
  int a[510][510];
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> a[i][j];
    }
  }
  int count = 0; int r = 0;
  vector<array<int,4>> action;
  int x = 0; int y = 0;
  int nx = 0; int ny = 0;
  while (r < H*W-1) {
    r++;
    if (y % 2 == 0) {
      nx = x + (x != W-1); ny = y + (x == W-1);
    }
    else {
      nx = x - (x != 0); ny = y + (x == 0);
    }
    if (a[y][x] % 2 != 0) {
      count++;
      a[y][x]--; a[ny][nx]++;
      action.push_back({y+1, x+1, ny+1, nx+1});
    }
    //cout << y << " " << x << endl;
    x = nx; y = ny;
  }
  cout << count << endl;
  for (int i = 0; i < action.size(); i++) {
    cout << action[i][0] << " " << action[i][1] << " "
         << action[i][2] << " " << action[i][3] << endl;
  }
}


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N;
    cin >> N;
    vector<int> W(N);
    REP(i,N) cin >> W[i];
    vector<int> A(N+1,0);
    REP(i,N) {
        A[i+1] = A[i] + W[i];
    }
    int m = A[N];
    int ans = inf;
    REP(i,N+1) {
        int t = A[i] - (m - A[i]);
        ans = min(ans, abs(t));
    }   
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const string days[] = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
// 						   Jan Feb Match April May June July, Aug Sep Oct No  Dec
const int months[] = { 0, 31, 29, 31,   30,   31, 30,  31, 31, 30, 31, 30, 31 };
int main()
{
//	cut here before submit 
//	freopen ("testcase.What_day_is_today", "r", stdin );
	int month, day;
	while (scanf ("%d %d", &month, &day ) && month ){
		int cnt = 3;	// 2004/01/01 is Thursday
		for (int i = 0; i < month; i++ ){
			cnt += months[i];
		} // end for
		cnt += day;
		cnt--;
		cout << days[cnt % 7] << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 1212
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,a,n) for(int i=a;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef long long ll;

const int INF=1000000;
char fi[101][101];
int d[21][21];
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
double EPS = 1e-10;
int N,M;
int sx,sy;
int gx,gy;
int w,h;
int ans;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int MAX_V=100;
const int MAX_N=100;
char o[3]={'+','-','*'};
#define md 1000003


int dp[353][353]={0};
int bow[353][353]={0};
double add(double a,double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))
	return 0;
	return a+b;
}

struct P{
	double x,y;
	P(){}
		P(double x,double y):x(x),y(y){
		}
		P operator + (P p){
			return P(add(x,p.x),add(y,p.y));
		}
		P operator - (P p){
			return P(add(x,-p.x),add(y,-p.y));
		}
		P operator *(double d){
			return P(x*d,y*d);
		}
		double dot(P p){
			return add(x*p.x,y*p.y);
		}
		double det(P p){
			return add(x*p.y,-y*p.x);
		}
};

bool cmp_x(const P& p,const P& q){
	if(p.x!=q.x) return p.x<q.x;
	return p.y<q.y;
}

vector<P> convex_hull(P* ps, int n){
	sort(ps,ps+n,cmp_x);
	int k=0;
	vector<P> 	qs(n*2);
	
	rep(i,n){
		while(k>1&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)
			k--;
		qs[k++]=ps[i];
	}
	for(int i=n-2,t=k;i>=0;i--){
		while(k>t&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)
		k--;
		qs[k++]=ps[i];
	}
	qs.resize(k-1);
	return qs;
}

int n;
P ps[101];

int main(){
	
	int h,w;
	
	while(cin>>h>>w,h!=0||w!=0){
		
		rep(i,h){rep(j,w)
		cout<<"#";
			cout<<endl;
		}
		
		cout<<endl;
	}
	
	
	
	
	
	
	

	
}

Measured memory_bytes: 1156
#include <iostream>
#include <string>

using namespace std;

int main(){
    string str, str_out;
    int len;

    cin >> str;
    len = str.size();

    str_out = str[0] + to_string(len - 2) + str[len - 1];

    cout << str_out;

    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n;
    cin >> n;
    vi p(n);
    rep(i,n) cin >> p.at(i);
    // 手前から順に変えて行けば良さそう
    ll res = 0;
    rep(i,n-1){
        if(p.at(i)==i+1){
            swap(p.at(i),p.at(i+1));
            res++;
        }
    }
    if(p.at(n-1)==n) res++;
    cout << res << endl;
}

Measured memory_bytes: 1024
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

def min(a,b)
  return a>b ? b : a
end
h,w=get_i
c=array(10,1)

10.times do|i|
  c[i]=get_i
end
a=array(h,1)
h.times do|i|
  a[i]=get_i
end
10.times do|i|
  10.times do|j|
    10.times do|k|
      c[j][k]=min(c[j][k],c[j][i]+c[i][k])
    end
  end
end
ans=0
h.times do|i|
  w.times do|j|
    next if a[i][j]==-1
    ans+=c[a[i][j]][1]
  end
end
puts ans

Measured memory_bytes: 2684
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    println(problem175a(s))
}

fun problem175a(s: String): Int {
    return when (s) {
        "RSS", "SRS", "SSR", "RSR" -> 1
        "RRS", "SRR" -> 2
        "RRR" -> 3
        else -> 0
    }
}

Measured memory_bytes: 36280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long double PI = 3.14159265358979323846;

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

    int n;
    cin >> n;
    set<string> s;
    for (int i = 0; i < n; ++i) {
        string tmp;
        cin >> tmp;
        s.insert(tmp);
    }
    cout << (int)s.size() << '\n';

    return 0;
}


Measured memory_bytes: 19252
import heapq

n = list(map(int,input().split()))
a = list(map(int,input().split()))

#heapqでは最小値しか取り出せないので，*(-1)することで最大値を取り出す
for i in range(len(a)):
    a[i] *= -1

#リストを優先度付きキューにする
heapq.heapify(a)

for i in range(n[1]):
    #最小値(実際には最大値であるはずの値)を取り出す
    tmp = heapq.heappop(a)

    #取り出した値を2で割って切り下げで優先度付きキューに挿入
    heapq.heappush(a, int(tmp/2))

print(-sum(a))

'''
max()はO(N)．heapqはO(logN)
これだと発想はあっているが，O(NM)となるので間に合わない
for i in range(n[1]):
    a[a.index(max(a))] = int(max(a) / 2)

print(sum(a))
'''

Measured memory_bytes: 14180
#include<stdio.h>
int main(void){
    int n,i=0;
    double sum = 0;
    int number[1000];
    scanf ("%d",&n);
    for (i=0;i<n;i++){
    scanf ("%d",&number[i]);
    sum = sum + (double)1/number[i];
    }

    sum = 1/sum ;
    printf("%.5f\n",sum);
    return 0;
}

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

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i64 = int64_t;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= a; i--)
#define RF0(i,b) RFO(i,0,b)
#define F first
//#define S second

constexpr char getl(const char& a, const char& b) {
  assert(a != b);
  switch (a) {
  case 'R':
    switch (b) {
    case 'G':
      return 'B';
    default:
      return 'G';
    }
  case 'G':
    switch (b) {
    case 'R':
      return 'B';
    default:
      return 'R';
    }
  default:  // b
    switch (b) {
    case 'R':
      return 'G';
    default:
      return 'R';
    }
  }
}

#if 1
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  string S;
  cin >> N;
  cin >> S;

  vector<int> rn(N+3), gn(N+3), bn(N+3);
  RF0(i, N) {
    rn[i] = rn[i + 1];
    gn[i] = gn[i + 1];
    bn[i] = bn[i + 1];

    if (S[i] == 'R') {
      rn[i] ++;
    }
    else if (S[i] == 'G') {
      gn[i]++;
    }
    else if (S[i] == 'B') {
      bn[i]++;
    }
    //cout << "i=" << i << " " << rn[i] << " " << gn[i] << " " << bn[i] << "\n";
  }

  i64 result = 0;
  F0R(i, N) {
    FOR(j, i + 1, N) {
      if (S[j] != S[i]) {
        char last = getl(S[i], S[j]);

        int jmi = j - i;
        int k = j + jmi;

        switch (last) {
        case 'R':
          result += rn[j + 1];
          break;
        case 'G':
          result += gn[j + 1];
          break;
        default:
          result += bn[j + 1];
          break;
        }
        if (k < N && S[k] == last) {
          result--;
        }
      }
    }
  }

  cout << result;
}
#endif


Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<tuple>
using namespace std;
#define INF 1LL<<62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());


int main(){
    int N,K;
    cin>>N>>K;
    int A[110000];
    ll B[110000];
    for(int i=0;i<N;i++) cin>>A[i]>>B[i];
    int n=-1;
    for(int i=0;i<=30;i++){
        if(bit(K,i)) n=i;
    }
    ll ans=0;
    for(int i=n;i>=1;i--){
        if(bit(K,i)==0) continue;
        ll temp=0;
        for(int j=0;j<N;j++){
            bool flag=true;
            for(int k=30;k>=i+1;k--){
                if(bit(K,k)==0 && bit(A[j],k)==1) flag=false;
            }
            if(bit(A[j],i)==1) flag=false;
            if(flag) temp+=B[j];
        }
        //cout<<i<<" "<<temp<<endl;
        chmax(ans,temp);
    }
    ll temp=0;
    for(int i=0;i<N;i++){
        bool flag=true;
        for(int j=0;j<=30;j++){
            if(bit(K,j)==0 && bit(A[i],j)==1) flag=false;
        }
        if(flag) temp+=B[i];
    }
    chmax(ans,temp);
    cout<<ans<<endl;
    
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
const ll MAX_N = 3e6 + 10;
const ll MOD = 1e9+7;
ll Inv[MAX_N];
ll fact[MAX_N];
ll factInv[MAX_N];
void Inv_init(){
    Inv[1] = 1;
    for(int i = 2; i < MAX_N; i++) {
        Inv[i] = Inv[MOD%i] * (MOD - MOD/i) % MOD;
    }
}
void fact_init(){
    fact[0] = fact[1] = factInv[0] = factInv[1] = 1;
    for(int i = 2; i < MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        factInv[i] = (factInv[i-1] * Inv[i])%MOD;
    }
}

// a^b % MOD;
ll powmod(ll a,ll b) {ll res=1;a%=MOD; for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
// 逆元 1/a % MOD
ll inversemod(ll a) { return powmod(a,MOD - 2);}

// 1 以上 N 以下の N 個の整数の中から，相異なる K 個の整数を選ぶパターンの数
ll nCr(int n,int r) {
    if(n < r) return 0;
    return (fact[n] * (factInv[r] * factInv[n-r] % MOD)) % MOD;
}
// 1 以上 N 以下の N 個の整数の中から，相異なる K 個の整数を選び，順番に並べるパターンの数
ll nPr(int n,int r){
    if(n < r) return 0;
    return (fact[n]*factInv[n-r])%MOD;
}
// 1 以上 N 以下の N 個の整数の中から，重複を許して K 個の整数を選ぶパターンの数
ll nHr(int n,int r){
    if(n == 0 && r == 0) return 1;
    return nCr(n+r-1,r);
}

void init(){
    Inv_init();
    fact_init();
}

ll solve(){
    init();
    ll res = 0;
    ll n,k; cin >> n >> k;
    res = nCr(n+k-1,k-1);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}



Measured memory_bytes: 73536
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>

using namespace std;



int main(){
  long n,m;
  cin >> n >>m;
  vector<pair<long,long>> pairs(n);
  for (int i=0;i<n;i++) {
    int a,b;
    cin >> a >>b;
    pairs.at(i)=make_pair(a,b);
  }
  sort(pairs.begin(),pairs.end());
  long ans=0;
  for (int i=0;m>0;i++){
    if (m<=pairs.at(i).second) {
      ans+= pairs.at(i).first*m;
      break;
    }
    else {
      ans+= pairs.at(i).first*pairs.at(i).second;
      m=m-pairs.at(i).second;
    }
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    long long N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    
    long long MinTime = min({A, B, C, D, E});
    
    long long ans = (N + MinTime - 1) / MinTime + 4;
    
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
 *  Author: mizo0203
 *  Problem: 2008
 *  Status: Accepted
 *  Submission Date: 2012/04/17 18:28:54
 *
 *  方策：幅優先による全探索+枝刈り
 */
#include <stdio.h>
#include <math.h>

int n;
int hx, hy, dx, dy;
int cx[20], cy[20];
double cdis[20]; // 魔王とクリスタルの距離

// 初期化
void init() {
}

// 入力
bool input() {
  int i;

  scanf("%d %d %d %d %d", &n, &hx, &hy, &dx, &dy);
  if (!n && !hx && !hy && !dx && !dy)
    return false;
  for (i = 0; i < n; i++) {
    scanf("%d %d", &cx[i], &cy[i]);
    cdis[i] = hypot(dx - cx[i], dy - cy[i]); // 魔王とクリスタルの距離を算出
  }
  return true;
}

// 再帰関数
// bit:クリスタルの回収状況 sum:勇者の総移動距離 x,y:勇者の現在地
bool recursive(long bit, double sum, int x, int y) {
  int i;
  double minD = 2000000.0; // 魔王と魔王に最も近いクリスタルの距離
  double maxH = -1.0; // 勇者の総移動距離+勇者と魔王に最も近いクリスタルの距離


  /* 【探索終了】
   * 全てのbitが立つとクリスタルの収集が完了したため
   * 探索を終了する
   */
  for (i = 0; i < n; i++)
    if (~bit & 1 << i) // 未回収のクリスタルがあるならば
      break;
  if (i == n) // クリスタルの回収完了
    return true;

  /* 【枝刈り】
   * 「勇者の総移動距離+勇者と魔王に最も近いクリスタルの距離」が
   * 「魔王と魔王に最も近いクリスタルの距離」以上長いならば
   * 勇者は魔王に最も近いクリスタルが回収不能のため
   * それ以上の探索をしない
   */
  for (i = 0; i < n; i++) { // 魔王に最も近いクリスタルを探索
    if (bit & 1 << i) // 回収済みのクリスタルはスルー
      continue;
    if (minD > cdis[i]) {
      minD = cdis[i];
      maxH = hypot(x - cx[i], y - cy[i]) + sum;
    }
  }
  if (maxH >= minD) // 枝刈り発生
    return false;

  /* 【幅優先探索】
   * 未回収のクリスタルを回収する
   * 全ての順列を試みる
   */
  for (i = 0; i < n; i++) {
    if (bit & 1 << i) // 回収済みのクリスタルはスルー
      continue;
    if (recursive(bit | 1 << i, sum + hypot(x - cx[i], y - cy[i]), cx[i], cy[i]))
      return true; // 回収完了したらならば探索終了
  }

  return false;
}

int main() {

  init(); // 初期化
  while (input()) { // 入力
    if (recursive(0, 0.0, hx, hy)) { // 再帰関数
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }

  return 0;
}

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


def solve(a: int, b: int, c: int, d: int):
    ans = -float("inf")
    if a <= 0 <= b or c <= 0 <= d:
        ans = 0
    for x in [a, b]:
        for y in [c, d]:
            ans = max(ans, x*y)
    return ans

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    c = int(next(tokens))  # type: int
    d = int(next(tokens))  # type: int
    print(solve(a, b, c, d))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


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

#define  ll long long int
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define si(a) a.size()
#define p pair< ll,ll >
#define v vector< ll >
#define vi vector<p>
#define mem(tabl,i) memset(tabl, i, sizeof(tabl))
#define sp(x,y) fixed<<setprecision(y)<<lf(x)
#define debug(c) cout << #c << " = " << c << endl;
#define  f(i,a,b) for(int i=a;i<b;i++)
#define fe(i,a,b) for(int i=a;i<=b;i++)
#define Mod 1000000007

const int N = 1e5 + 5;

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

           string s;
           ll n,k,b,c,x,y,z;
           ll counter=0,counter1=0,counter2=0;
           ll sum=0,result=0,ans=0, flag=0;
           cin>>n;
           fe(i,1,n)
           {
                 if(i%3==0 || i%5==0)
                 {

                 }
                 else
                    sum+=i;
           }
           cout<<sum<<endl;

}


Measured memory_bytes: 3608
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = (0 until n).map {
        readLine()!!.split(' ').map { s -> s.toInt() }
    }

    val dp = Array(n + 1) { Array(3) { 0 } }

    (0 until n).forEach { i ->
        (0 until 3).forEach { j ->
            (0 until 3).forEach { k ->
                if (j != k) {
                    dp[i + 1][k] = Math.max(dp[i + 1][k], dp[i][j] + a[i][k])
                }
            }
        }
    }

    println(dp.last().max())
}

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

int main() {

	int n, k; cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	if (k == n) {
		cout << 1 << endl;
		return 0;
	}
	int ans = 1;
	int tmp = k;
	while (tmp < n) {
		tmp += k - 1;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

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


const int N=1e6 + 5;
ll arr[N];
ll n,m,k,l,r,mid,su;
vector<pair<int,int>> vec;
ll MX=0;



int main(){
    scanf("%d",&n);
    for(int i=0;i<n;++i)
        scanf("%d",arr+i),arr[i]-=(i+1);
    sort(arr,arr+n);
    int x=arr[n/2];
    for(int i=0;i<n;++i)
        su+=abs(arr[i]-x);
    printf("%lld",su);



}




Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int a = Integer.parseInt(br.readLine());
		
		int sum = (int)(a + Math.pow((double)a, 2.0) + Math.pow((double)a, 3.0));
		
		System.out.println(sum);
	}

}

Measured memory_bytes: 32708
#define TST 0
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cctype>

using namespace std;
// for loop
#define F(i, L, R) for(int i = L; i < R; i++)
#define FE(i, L, R) for(int i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(int i = L; i > R; i--)
#define FRE(i, L, R) for(int i = L; i >= R; i--)

// data types
#define Int long
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back
#define InputV(a, n) F(i,0,n){long l; cin >> l; a.pb(l);}

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)
#define printM(a, n, m) F(i, 0, n){ FE(j, 0, m) cout << a[i][j] << (i==m?'\n':' ');}

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#define printMatrix(mat,n,m){ \
    F(i, 0, n){               \
        F(j, 0, m){           \
            cout << mat[i][j] << space;\
        }\
        cout << endl;\
    }\
}

int main() {
#if TST==1
    ifstream in ("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    ll dp[100010][3];
    ll data[100010][3];
    ll abc[3];
    long n;
    cin >> n;
    //cin >> dp[0][0] >> dp[0][1] >> dp[0][2];
    F(i, 0, n){
        F(j, 0, 3){
            cin >> data[i][j];
        }
    }
    dp[0][0] = data[0][0];
    dp[0][1] = data[0][1];
    dp[0][2] = data[0][2];
    F(i, 1, n){
        F(k, 0, 3){
            F(l, 0, 3){
                if(l == k)continue;
                chmax(dp[i][k], dp[i-1][l] + data[i][k]);
            }
        }
    }
    ll ans = dp[n-1][0];
    chmax(ans, dp[n-1][1]);
    chmax(ans, dp[n-1][2]);
#if TST==1
    printMatrix(dp, n, 3);
#endif
    cout << ans << endl;
}


Measured memory_bytes: 4992
#include <cstdio>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;

const int INF = 1000000000;

int n;
vector<int> way[128];

int mini(int s, int d, int v);

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		int r, k;
		
		scanf("%d %d", &r, &k);
		while (k-- > 0){
			int t;
			
			scanf("%d", &t);
			way[r].push_back(t);
		}
	}
	
	int p;
	
	scanf("%d", &p);
	while (p-- > 0){
		int s, d, v;
		
		scanf("%d %d %d", &s, &d, &v);
		int cost = mini(s, d, v);
		if (cost == INF) puts("NA");
		else printf("%d\n", cost);
	}
	
	return 0;
}

int mini(int s, int d, int v)
{
	int diff[128];
	queue<P> q;
	
	fill(diff, diff + n + 1, INF);
	q.push(P(s, 1));
	diff[s] = 1;
	while (!q.empty()){
		P p = q.front(); q.pop();
		
		if (diff[p.first] < p.second) continue;
		for (int i = 0; i < way[p.first].size(); i++){
			int tmp = way[p.first][i];
			
			if (diff[tmp] > diff[p.first] + 1){
				diff[tmp] = diff[p.first] + 1;
				q.push(P(tmp, diff[tmp]));
			}
		}
	}
	
	if (diff[d] == INF || diff[d] > v) return INF;
	else return diff[d];
}

Measured memory_bytes: 1072
import * as fs from 'fs';

//in
// 2 5
// 1 WA
// 1 AC
// 2 WA
// 2 AC
// 2 WA
//out
// 2 2
// 一回もACならなかった問いのWAは0

const inp: string[] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');

const [n,m] = inp[0].split(' ').map(Number);
// const n = parseInt(inp[0].split(' ')[0]);
// const m = parseInt(inp[0].split(' ')[1]);
inp.shift(); // 不要な引数を除く

const acList: any = {};
const waList: any = {};
let acTotal: number = 0;
let waTotal: number = 0;
for (let i: number = 0; i < m; i++) {
    const q: number = parseInt(inp[i].split(' ')[0]);
    if (q > n) continue;

    const status: string = inp[i].split(' ')[1];
    if (status === 'AC') {
        if (!acList[q]) {
            acList[q] = 1;
            acTotal++;

            // waCnt
            if (waList[q]) waTotal += waList[q];

        }
    } else if (status === 'WA') {
        if (acList[q]) continue;


        if (!waList[q]) {
            waList[q] = 1
        } else {
            waList[q]++
        }
    }
}

//
console.log(`${acTotal} ${waTotal}`);


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

int primenumber(int n){
    bool is_prime[50001];

    is_prime[0] = is_prime[1] = false; 
    for(int i=2; i<=50000; i++){
        is_prime[i] = true;
    }
    for(int i=2; i*i<=50000; i++){
        if(is_prime[i]){
            for(int j=i*i; j<=50000; j+=i){ 
                is_prime[j] = false; 
            }
        }
    }
    int ans=0;
    for(int i=2;i<=n/2;i++){
        if(is_prime[i]){
            int num=n-i;
            if(is_prime[num]){
                ans++;
            }
        }
    }
    return ans;
}
    

int main(){
    while(true){
        int n;
        cin >> n;
        if(cin.eof())
        break;
        if(n==0)
        return 0;
        cout<<primenumber(n)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3144
#include <stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==1&&b==0&&c==0){
		printf("Close\n");
	}else if(a==0&&b==1&&c==0){
		printf("Close\n");
	}else if(a==1&&b==1&&c==0){
		printf("Open\n");
	}else if(a==0&&b==0&&c==1){
		printf("Open\n");
	}else if(a==0&&b==0&&c==0){
		printf("Close\n");
	}
	return 0;
}


Measured memory_bytes: 2136
#include <cstdio>
#include <cstring>
int main() {
	int n;
	while(scanf("%d",&n),n) {
		int dice[6]={1,6,4,3,2,5},work[6];
		char query[6];
		int sum=1;
		for(int i=0;i<n;i++) {
			scanf("%s",query);
			if(strcmp(query,"North")==0) {
				work[0]=dice[4];
				work[1]=dice[5];
				work[4]=dice[1];
				work[5]=dice[0];
				work[2]=dice[2];
				work[3]=dice[3];
			}else if(strcmp(query,"South")==0) {
				work[0]=dice[5];
				work[1]=dice[4];
				work[4]=dice[0];
				work[5]=dice[1];
				work[2]=dice[2];
				work[3]=dice[3];
			}else if(strcmp(query,"East")==0) {
				work[0]=dice[2];
				work[1]=dice[3];
				work[2]=dice[1];
				work[3]=dice[0];
				work[4]=dice[4];
				work[5]=dice[5];
			}else if(strcmp(query,"West")==0) {
				work[0]=dice[3];
				work[1]=dice[2];
				work[2]=dice[0];
				work[3]=dice[1];
				work[4]=dice[4];
				work[5]=dice[5];
			}else if(strcmp(query,"Right")==0) {
				work[2]=dice[4];
				work[3]=dice[5];
				work[4]=dice[3];
				work[5]=dice[2];
				work[0]=dice[0];
				work[1]=dice[1];
			}else if(strcmp(query,"Left")==0) {
				work[2]=dice[5];
				work[3]=dice[4];
				work[4]=dice[2];
				work[5]=dice[3];
				work[0]=dice[0];
				work[1]=dice[1];
			}
			for(int i=0;i<6;i++) dice[i]=work[i];
			sum+=dice[0];
		}
		printf("%d\n",sum);
	}
}

Measured memory_bytes: 1032
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	H, W, K := sc.nextInt(), sc.nextInt(), sc.nextInt()
	S := make([]string, H)
	for i := 0; i < H; i++ {
		S[i] = sc.nextStr()
	}
	ans := INF
	for bit := 0; bit < 1<<uint(H-1); bit++ {
		borders := make([]bool, H-1)
		count := 0
		for i := 0; i < H-1; i++ {
			if 1<<uint(i)&bit > 0 {
				borders[i] = true
				count++
			}
		}
		// 横線で区切られたブロックごとの累積和
		Sum := make([][]int, count+1)
		for i := 0; i < count+1; i++ {
			Sum[i] = make([]int, W+1)
		}
		for i := 0; i < W; i++ {
			block := 0
			for j := 0; j < H; j++ {
				if S[j][i] == '1' {
					Sum[block][i+1]++
				}
				if j < H-1 && borders[j] {
					block++
				}
			}
		}
		// 1列でKを超えるブロックが存在しないか
		ok := true
		for i := 0; i < count+1; i++ {
			for j := 0; j < W; j++ {
				if Sum[i][j+1] > K {
					ok = false
				}
			}
		}
		if !ok {
			continue
		}
		for i := 0; i < count+1; i++ {
			for j := 0; j < W; j++ {
				Sum[i][j+1] += Sum[i][j]
			}
		}
		left := 0
		right := 0
		total := count
		for ; right < W; right++ {
			for j := 0; j < count+1; j++ {
				if Sum[j][right+1]-Sum[j][left] > K {
					left = right
					total++
				}
			}
		}
		ans = min(ans, total)
	}

	fmt.Fprintln(wtr, ans)
}


Measured memory_bytes: 6528
W, H, x, y = map(int, input().split())
#if x*y == 0 or (x-W)*(y-H) ==0 or (x == W/2 and y != H/2) or (x != W/2 and y == H/2) :
#  print(str(W*H/2) + ' 0')
#  exit()
#elif y == H / W * x and x != W/2:
#  print(str(W*H/2) + ' 0')
#  exit()
#elif y == H - H / W * x and x != W/2:
#  print(str(W*H/2) + ' 0')
#  exit()
#print(str(W*H/2) + ' 1')

if x == W/2 and y == H/2:
  print(str(W*H/2) + ' 1')
  exit()
print(str(W*H/2) + ' 0')


Measured memory_bytes: 2940
x = int(input())
lst = list(map(int, input().split()))
lst.append(0)
lst.insert(0, 0)
S = 0
for i in range(1, x+2):
    S += abs(lst[i-1] - lst[i])
for i in range(1, x+1):
    print(S + abs(lst[i-1] -lst[i+1]) - (abs(lst[i-1]-lst[i]) + abs(lst[i]-lst[i+1])))

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

using namespace std;

int main()
{
    int k,n;
    vector<int> vc;
    cin >> k >> n;
    int i;
    i = 0;
    while(i < n) {
        int x;
        cin >> x;
        vc.push_back(x);
        i++;
    }
    vector<int> dis;
    auto end_itr = vc.end();
    --end_itr;
    /*
    cout << *end_itr << endl;
    for(auto itr2 = vc.rbegin(); itr2 != vc.rend(); ++itr2) {
        cout << *itr2 << endl;;
    }
    */
    for (int i = 1; i < n; i++)
        dis.push_back(abs(vc[i] - vc[i - 1]));
    dis.push_back(abs(k - *end_itr) + vc[0]);
    vector<int>::iterator itr = max_element(dis.begin(), dis.end());
    size_t index = distance(dis.begin(), itr);
    dis.erase(dis.begin() + index);
    int sum = accumulate(dis.begin(), dis.end(), 0);
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 2548
using System;
using System.Text;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace sandbox
{
    class Program
    {
        static void Main(string[] args)
        {
            var consoleReader = new ConsoleReader(Console.In);
            var N = consoleReader.Int;

            var count = consoleReader.Repeat(N).String
            .Select(x => new string(x.OrderBy(c => c).ToArray()))
            .GroupBy(x => x)
            .Select(g => g.Count())
            .Where(i => i > 1)
            .Select(i => (long)i * (i - 1) / 2)
            .Sum();

            Console.WriteLine(count);
        }
    }

    class ConsoleReader
    {
        private StringBuilder sb = new StringBuilder(4096);
        private TextReader textReader;
        public ConsoleReader(TextReader tr) { textReader = tr; }
        public int Int => int.Parse(String);
        public long Long => long.Parse(String);
        public double Double => double.Parse(String);
        public string String
        {
            get
            {
                sb.Clear();
                int current = textReader.Read();
                while (current > 0 && char.IsWhiteSpace((char)current)) { current = textReader.Read(); }
                while (current > 0 && !char.IsWhiteSpace((char)current)) { sb.Append((char)current); current = textReader.Read(); }
                return sb.ToString();
            }
        }


        public class RepeatReader
        {
            ConsoleReader cr; int count;
            public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; }
            public IEnumerable<T> Select<T>(Func<ConsoleReader, T> func) { for (int i = 0; i < count; i++) yield return func(cr); }
            public IEnumerable<string> String { get { for (int i = 0; i < count; i++) yield return cr.String; } }
            public IEnumerable<int> Int { get { for (int i = 0; i < count; i++) yield return cr.Int; } }
            public IEnumerable<double> Double { get { for (int i = 0; i < count; i++) yield return cr.Double; } }
        }
        public RepeatReader Repeat(int count) => new RepeatReader(this, count);
    }
}


Measured memory_bytes: 33804
/// sultanov

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
     
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type,
less<T>, rb_tree_tag, 
tree_order_statistics_node_update>;

using ll = long long;
using pii = pair<int, int>;                                   

const int N = 2e5 + 1e2;
const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

int d[N];

vector<int> adj[N];

void bfs(int v = 0) {
    queue<int> q;
    q.push(v);
    fill(d, d + N, INF32);
    d[v] = 0;
    while (!q.empty()) {
        int x = q.front();
        q.pop();
        for (int to : adj[x]) {
            if (d[to] > d[x] + 1) {
                d[to] = d[x] + 1;
                q.push(to);
            }
        }
    }
    for (int i = 0; i < N; ++i)
        if (d[i] == INF32)
            d[i] *= -1;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 1; i < n; ++i) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    bfs();
    int v = max_element(d, d + N) - d;
    bfs(v);
    int dia = *max_element(d, d + N);
    if (dia % 3 == 1)
        cout << "Second";
    else
        cout << "First";
    return 0;
}

Measured memory_bytes: 13556
#include <iostream>
using namespace std;
int main(void){
    int H,W;
    while(1){
        cin>>H>>W;
        if(H==0&&W==0)break;
        for(int i=1;i<=H;i++){
            for(int j=1;j<=W;j++){
                if((i+j)%2==0)cout<<"#";
                else cout<<".";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3072
// g++ .cpp && ./a.out
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef pair<int, int> p;
typedef long long ll;

const int mod = 1000000007;
const int inf = 1000000007;

int main() {
  int x, y;
  cin >> x >> y;
  bool ok = false;
  for (int i = 0; i <= x; i++) {
    if (2 * (i) + 4 * (x - i) == y) {
      ok = true;
      break;
    }
  }
  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int ab[4];

int main() {
    memset(ab, 0, sizeof(ab));
    for (int i = 0; i < 3; i++) {
        int a, b;
        cin >> a >> b;
        ab[a-1]++;
        ab[b-1]++;
    }

    bool f = false;
    int odd = 0;
    for (int i = 0; i < 4; i++) {
        if (ab[i] % 2 == 1) {
            odd++;
        }
    }

    if (odd == 0 || odd == 2) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
/*
AizuOnline A0000
Title
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int n;


int primes[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,
	      101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,
	      211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,
	      307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,
	      401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,
	      503,509,521,523,541,547,557,563,569,571,577,587,593,599,
	      601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,
	      701,709,719,727,733,739,743,751,757,761,769,773,787,797,
	      809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,
	      907,911,919,929,937,941,947,953,967,971,977,983,991,997};


//
int isprime(int n)
{
  int i;
  for(i=0;i<sizeof(primes)/sizeof(int);i++)
    if(n == primes[i])
      return(-1);
  else if(n % primes[i] ==0)
      return(0);
  return(-1);
}
main()
{
  int i;
  int cnt;

  while(EOF != scanf("%d",&n) && n)
    {

      cnt=0;
      for(i=2;i<=n-1;i++)
	{
	  //printf("i:%d %d %d %d\n",i,isprime(i),n-i,isprime(n-i));
	cnt += ((isprime(i)&&isprime(n+1-i))?1:0);
	}
      printf("%d\n",cnt);

    }

return(0);
}

Measured memory_bytes: 1024
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    print(3*n**2)
    return

#B
def B():
    n,d = LI()
    f = [1]*(n+2*d+2)
    ans = 0
    for i in range(n):
        if f[i]:
            for j in range(i,i+2*d+1):
                f[j] = 0
            ans += 1
    print(ans)
    return

#C
def C():
    n = I()
    a = IR(n)
    mi = max(a)
    if a.count(mi) > 1:
        for i in range(n):
            print(mi)
    else:
        b = [a[i] for i in range(n)]
        b.sort()
        b = b[::-1]
        for i in range(n):
            if mi != a[i]:
                print(mi)
            else:
                print(b[1])

    return

#D
def D():
    n = I()
    a = LI()
    b = [0]*(n+1)
    for i in range(1,n+1)[::-1]:
        j = 2*i
        k = 0
        while j <= n:
            k ^= b[j]
            j += i
        if a[i-1]^k:
            b[i] = 1
    ans = []
    for i in range(n+1):
        if b[i]:
            ans.append(i)
    print(len(ans))
    if ans:
        print(*ans)
    return

#E
def E():
    n = I()
    a = IR(n)
    mi = []
    ans = 0
    for i in range(n):
        j = bisect.bisect_right(mi,-a[i])
        if j == len(mi):
            mi.append(-a[i])
        else:
            mi[j] = -a[i]
    print(len(mi))
    return

#F 箱根駅伝DP
def F():
    n,K = LI()
    dp = [[[0]*(K+2500) for j in range(n+1)] for i in range(n+1)] #dp[i][j][k] : i段目、j個保留の時にスコアがkとなるパターン数(保留した点の数だけ、スコアは加算されていく,保留点が段をまたいでスコアが増えていくイメージ)
    dp[0][0][0] = 1
    for i in range(n):
        for j in range(i+1):
            for k in range(K+1):
                #パターン1 : i+1段目で両方結ぶ
                nj = j
                dp[i+1][nj][k+2*nj] += dp[i][j][k]
                dp[i+1][nj][k+2*nj] %= mod
                #パターン2 : i+1段目で両方結ばない
                nj = j+1
                dp[i+1][nj][k+2*nj] += dp[i][j][k]
                dp[i+1][nj][k+2*nj] %= mod
                #パターン3 : i+1段目で片側ともう片方の保留点を結ぶ
                nj = j
                x = j*2 #結ぶ相方の選び方((右or左)*(保留点の数))
                dp[i+1][nj][k+2*nj] += dp[i][j][k]*x
                dp[i+1][nj][k+2*nj] %= mod
                #パターン4 : i+1段目で両側ともう片方の保留点を結ぶ
                nj = j-1
                x = j*j #結ぶ相方の選び方(左側の保留点*右側の保留点)
                dp[i+1][nj][k+2*nj] += dp[i][j][k]*x
                dp[i+1][nj][k+2*nj] %= mod
    print(dp[n][0][K])
    return

#Solve
if __name__ == "__main__":
    F()


Measured memory_bytes: 144348
import sys

s = input()

while len(s) != 0:
    if s.endswith('dream') or s.endswith('erase'):
        s = s[:-5]
    elif s.endswith('eraser'):
        s = s[:-6]
    elif s.endswith('dreamer'):
        s = s[:-7]
    else:
        print('NO')
        sys.exit()

print('YES')


Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans=0;
	for(int i=1;i<n;i++){
		int cnt=0;
		for(char c='a';c<='z';c++){
			bool left=0,right=0;
			for(int j=0;j<i;j++)
				if(s[j]==c){
					left=1;
					break;
				}
			for(int j=i;j<n;j++)
				if(s[j]==c){
					right=1;
					break;
				}
			if(left&&right)
				cnt++;
		}
		if(ans<cnt)
			ans=cnt;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
s = input()
K = int(input())

substr_set = set()

for i in range(1, K + 1) : # max length of string
    if i >= len(s) :
        substr_set.add(s)
    else :
        for j in range(len(s) - i + 1) :
            if s != '' :
                substr_set.add(s[j:j+i])
    
sublist = list(substr_set)

sublist.sort()
# sublist.sort(key = len, reverse = False)

print(sublist[K - 1])

Measured memory_bytes: 4464
//OPTIMIZATONS
#pragma GCC optimize("02")
//CODE
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;
bool check(string s,int st,int fin){
	int limit = (st+fin)/2;
	for(int i=st;i<=limit;i++){
		if(s[i]!=s[fin-i]) return false;
	}
	return true;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	float n;
	cin>>n;
	double side = n/3;
	double vol = side*side*side;
	cout<<fixed<<setprecision(12)<<vol<<endl;
	return 0;
}



Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)

using namespace std;

int n, ans, a[200010];

int main()
{
    scanf("%d", &n);
    FOR(i, 1, n) scanf("%d", &a[i]);
    FOR(i, 0, n) ans += abs(a[i + 1] - a[i]);
    FOR(i, 1, n) printf("%d\n", ans - abs(a[i + 1] - a[i]) - abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i - 1]));
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  
  string a, b, c;
  a = s.substr(0, 5);
  b = s.substr(6, 7);
  c = s.substr(14, 5);

  cout << a << " " << b << " " << c << endl;


 

}
             
 

Measured memory_bytes: 3572
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val t = (1..n).map {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        Pair(a, b)
    }.sortedByDescending { it.second }

    var limit = Int.MAX_VALUE
    for (i in t.indices) {
        limit = Math.min(limit, t[i].second) - t[i].first
        if (limit < 0) {
            break
        }
    }
    println(if (limit < 0) "No" else "Yes")
}

Measured memory_bytes: 125504
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
int main() {
  int N,K;
  cin>>N>>K;
  if(K==1){
  cout<<0<<endl;
  }else{
  cout<<N-K<<endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String N = scanner.next();
        //各行の数字の和
        int sum = 0;
 
        for (int i = 0; i < N.length(); i++) {
        	//Nの各行を数値に変換し足す
        	int x = Integer.parseInt(N.substring(i, i+1));
        	sum += x;
        }
 
        int n = Integer.parseInt(N);
        String judge = n % sum == 0 ? "Yes" : "No";
 
        System.out.println(judge);
	}
}

Measured memory_bytes: 23764
#include<iostream>
using namespace std;
int N,P;
int cnt[10101];
int T[2<<17];
string s;
main()
{
	cin>>N>>P>>s;
	long ans=0;
	if(P==2||P==5)
	{
		for(int i=0;i<N;i++)
		{
			if((s[i]-'0')%P==0)ans+=i+1;
		}
	}
	else
	{
		T[N-1]=1;
		for(int i=N-1;i--;)
		{
			T[i]=T[i+1]*10%P;
			///printf("%d ",T[i]);
		}
		int now=0;
		cnt[0]=1;
		for(int i=0;i<N;i++)
		{
			now=(now+(s[i]-'0')*T[i])%P;
			ans+=cnt[now]++;
		}
	}
	///puts("");
	cout<<ans<<endl;
}


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

using namespace std;

int main()
{
	int n, x;
	cin >> n >> x;
	int minm = INT_MAX;
	for (int i = 0; i < n; i++)
	{
		int m;
		cin >> m;
		x -= m;
		minm = min(minm, m);
	}
	cout << n + x / minm  << endl;
	return 0;
}


Measured memory_bytes: 256