akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) cin >> a[i];
	
	long long dp[n][n];
	for (int i = n - 1; i >= 0; i--) {
		for (int j = i; j < n; j++) {
			if (j == i) dp[i][j] = 0;
			else {
				dp[i][j] = 1e18;
				long long cost{};
				for (int k = i ; k <= j; k++) cost += a[k];
				for (int k = i; k < j; k++) dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + cost);
			}
//			cout << i << " " << j << " " << dp[i][j] << endl;
		}
	}
	cout << dp[0][n - 1];
}

Measured memory_bytes: 4888
#include<iostream>
#include<functional>
#include<vector>
#include<string>
#include<cassert>

using namespace std;

template<typename type>
class heap {
	
	vector<type> arr;
	int ele;
	function<bool(type,type)> comparison;
	
	void heapify(int now){
		type temp;
		int left = now*2, right = now*2 + 1;
		
		if(left <= ele && !comparison(arr[now], arr[left])){
			temp = left;
		} else {
			temp = now;
		}
		
		if(right <= ele && !comparison(arr[temp], arr[right])){
			temp = right;
		}
		
		if(temp != now){
			swap(arr[temp], arr[now]);
			heapify(temp);
		}
	}
	
public :

	heap(){
		init();
	}
	
	heap(function<bool(type,type)> f){
		init(f);
	}
	
	heap(function<bool(type,type)> f, int n){
		init(f);
		resize(n);
	}
	
	void init(function<bool(type,type)> f){
		arr.resize(1);
		ele = 0;
		comparison = f;
	}
	
	void init(){
		arr.resize(1);
		ele = 0;
		comparison = [](type high, type low){ return high >= low;};
	}
	
	void resize(int n){
		arr.resize(n+1);
	}
	
	void insert(type key){
		int num = ++ele;
		
		if(num + 1 >= arr.size()) arr.resize(num + 1);
		arr[num] = key;
		
		for( ; num > 1 && !comparison(arr[num/2], arr[num]); num /= 2){
			swap(arr[num/2], arr[num]);
		}
	}
	
	type top(){
		return arr[1];
	}
	
	type extract(){
		
		assert(arr.size() >= 2);
		type res = arr[1];
		arr[1] = arr[ele--];
		heapify(1);
		
		return res;
	}
	
	type size(){
		return ele;
	}
};

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	char com[10];
	int key;
	heap<int> priority_queue([](int high, int low){ return high >= low;},2100000);
	// heap<int> priority_queue;
	
	while(true){
		cin>>com;
		
		if(com[2] == 'd') break;
		else if(com[0] == 'i'){
			cin>>key;
			priority_queue.insert(key);
		} else cout<<priority_queue.extract()<<endl;
	}
	return 0;
}


Measured memory_bytes: 10964
import Foundation

let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ")//ブランクで区切られている場合 

let a = Int(split[0])!
//String->Intの型変換はnilが返る可能性があるので、ラップされたOptional<Int>型が返るので強制アンラップ
let b = Int(split[1])!

if (a * b % 2 == 0){
    print("Even")
}else{
    print("Odd")
}

Measured memory_bytes: 14064
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 2e5+5;

int main(int argc, char ** argv) {
	int N, x, ma = 0;
 	ll ans = 0;
	scanf("%d", &N);
	rep(i, 0, N) {
		scanf("%d", &x);
		ans += max(0, ma-x);
		ma = max(ma, x);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3792
n,m = map(int,input().split())
a = list(int(input()) for i in range(m))
a.append(0)
dp = [0] * (n+1)
b = 0
for i in range(1,n+1):
    if a[b] == i:
        b += 1
    else:
        if i != 1 and i != 2:
            dp[i] = dp[i-1] + dp[i-2]
        else:
            if i == 1:
                dp[1] = 1
            elif i == 2 and a[0] == 1:
                dp[2] = 1
            else:
                dp[1] = 1
                dp[2] = 2
print(dp[-1] % (10 ** 9 + 7))

Measured memory_bytes: 465712
import math
from bisect import bisect_right
from bisect import bisect_left

n = int(input())
L = list(map(int,input().split()))
L.sort()
c = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        lg = L[i] + L[j]
        st = L[j] - L[i]
        if lg > L[j+1] and st < L[n-1]:
            if lg > L[n-1]:
                m1 = n - (j+1)
            else:
                m1 = bisect_left(L[j+1:],lg)
            c += max(0,m1)
print (c)

Measured memory_bytes: 51036
#include <iostream>
#include <vector>
#include <utility>
using namespace std;


int main()
{
    int N, M, Q;
    int L[200000], R[200000];
    int p[100000], q[100000];
    cin >> N >> M >> Q;
    for( int i = 0; i < M; i++ ) cin >> L[i] >> R[i];
    for( int i = 0; i < Q; i++ ) cin >> p[i] >> q[i];


    // 都市のの数を二次元座標 ( L[i], R[i] ) に記憶しておけば、
    // 求めるのは ( p[i]-1, p[i]-1 ), ( q[i], q[i] ) 
    // で囲まれた領域の和
    // -> 2次元累積和を使う
    int coord[501][501] = {};
    for( int i = 0; i < M; ++i ) coord[L[i]][R[i]]++;

    // 2次元累積和を求める
    // 列の和
    for( int i = 0; i < 501; ++i ){
        for( int j = 1; j < 501; ++j ){
            coord[i][j] += coord[i][j-1];
        } 
    }
    // 行の和
    for( int j = 0; j < 501; ++j ){
        for( int i = 1; i < 501; ++i ){
            coord[i][j] += coord[i-1][j];
        } 
    }

    for( int i = 0; i < Q; i++ ){
        cout << coord[q[i]][q[i]] 
              - coord[q[i]][p[i]-1] - coord[p[i]-1][q[i]]
              + coord[p[i]-1][p[i]-1] << endl;
    }

    return 0;
}

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

const int INF = 1000000;

int main() {
	int N, X, Y;
	cin >> N >> X >> Y;
	X--; Y--;
	vector<int> ans(N);
	rep(i, N) {
		vector<int> d(N,INF);
		queue<int> q;
		auto push = [&](int a, int dis){
			if (d[a] != INF) return;
			d[a] = dis;
			q.push(a);
		};
		push(i, 0);
		while (!q.empty()) {
			int a = q.front(); q.pop();
			int dis = d[a];
			if (a > 0) push(a - 1, dis + 1);
			if (a < N) push(a + 1, dis + 1);
			if (a == X) push(Y, dis + 1);
			if (a == Y) push(X, dis + 1);
		}
		rep(i, N) ans[d[i]] ++;
	}
	rep(i, N) ans[i] /= 2;
	for (int i = 1; i < N; i++) cout << ans[i] <<  endl;
}



// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();


// bool cmp(pair<int,int>p,pair<int,int>q) {
//     return p.first>q.first;//descending by first
//     return p.first<q.first;//ascending by first
//     return p.second>q.second;//descending by second
//     return p.second<q.second;//ascending by second
// }

bool cmp(int p,int q) {
    return p>q;//descending
    // return p<q;//ascending
}

int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }
    return 0;
}
int clue() {

    int k,a,b;
    cin>>k>>a>>b;
    int det=0;
    for(int i=a;i<=b;++i) {
        if(i%k==0)++det;
    }
    (det)?cout<<"OK"<<endl:cout<<"NG"<<endl;
    
    return 0;
}

Measured memory_bytes: 3632
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int T;
	cin>>T;
	rep(_,T){
		int n,D;
		cin>>n>>D;
		priority_queue<int> pq;
		pq.push(-D);
		rep(i,n-1){
			int t = -pq.top();
			pq.pop();
			int a = 127;
			int b = a^t;
			pq.push(-a);
			pq.push(-b);
		}
		ll ans = 0;
		while(pq.size()){
			ans += -pq.top();
			pq.pop();
		}
		cout<<ans<<endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
import copy

N = int(input())
p = [int(i) for i in input().split(' ')]

has_changed = False
for i in range(N):
    expect = i + 1
    #print(p)
    #print(p[i], expect)
    if p[i] != expect:
        if has_changed:
            print('NO')
            exit()
        index = p[i] - 1
        if p[index] == expect:
            has_changed = True
            tmp = copy.deepcopy(p[i])
            p[i] = expect
            p[index] = tmp
            # print('change', p[i], p[index])
        else:
            print('NO')
            exit()

print('YES')


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

int main() {
  int N,num=0;
  cin >> N;
  string s;
  for(int i =0;i<N;i++) {
    cin >> s;
    if(s=="Y") {
      num =1;
      cout << "Four" << endl;
      break;
    }
  }
  if(num == 0) cout << "Three" << endl;
  
    
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii  = pair<int,int>;
const int INF=1001001001;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define MOD 1000000007
#define EPS 10e-8
int gcd(int a,int b){return b?gcd(b,a%b):a;}    //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数
int main() {
    string s;
    cin >> s;
    int a, b, c, d;
    a = s[0] - '0';
    b= s[1] - '0';
    c= s[2] - '0';
    d= s[3] - '0';

    if (a + b + c + d == 7)
    {
        cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
    }
    else if(a + b + c - d==7){
        cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
    }
    else if(a+b-c+d==7){
        cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
    }
    else if(a+b-c-d==7){
        cout << a << "+" << b << "-"<< c << "-" << d << "=7" << endl;
    }
    else if(a-b+c+d==7){
        cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
    }
    else if(a-b+c-d==7){
        cout << a << "-" << b << "+"<< c << "-" << d << "=7" << endl;
    }
    else if(a-b-c+d==7){
        cout << a << "-" << b << "-"<< c << "+" << d << "=7" << endl;
    }
    else if(a-b-c-d==7){
        cout << a << "-" << b << "-"<< c << "-" << d << "=7" << endl;
    }
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <map>
using namespace std;


#define prec(i) cout << fixed << setprecision(i)

const long long int MOD = 1000000007;

long long int fact(long long int k) {
	long long int sum = 1;
	for (long long int i = 2; i <= k; i++)
		sum *= i;

	return sum;
}

int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}

long long int pow_mod(int a, int b) {
	long long int  ans = 1;
	for (int i = 0; i < b; i++)
		ans = (ans * a) % MOD;

	return ans;
}

vector<int> a;


int main()
{
	long long int cnt = 0;
	string s;

	cin >> s;

	for (int i = 0; i < s.length() / 2; i++) {
		if (s[i] != s[s.length() - 1 - i])
			cnt++;
	}

	cout << cnt << endl;

	return 0;
}

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

int main(){
  char boin[5] = {'a', 'i', 'u', 'e', 'o'};
  char c;
  cin >> c;
  rep(i, 5){
    if(c == boin[i]){
      cout << "vowel" << endl;
      return 0;
    }
  }
  cout << "consonant" << endl;
}

Measured memory_bytes: 256
program ABC155B
    implicit none
    integer(8)::N,i
    integer(8)::flg=0!承認
    integer(8),allocatable,dimension(:)::A
    read(5,*)N
    allocate(A(N))
    read(5,*)(A(i),i=1,N)

    do i=1,N
        if(mod(A(i),2)==0)then
            if(mod(A(i),3)/=0.and.mod(A(i),5)/=0)then
                flg=1
                exit
            end if
        end if
    end do

    if(flg==0)then
        print'(A)',"APPROVED"
    else
        print'(A)',"DENIED"
    end if
end program ABC155B

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

Measured memory_bytes: 596
import java.util.Scanner; 
class Main { 
public static void main(String args[]) { 
int one=0;
int two=0;
int three=0;
Scanner sc = new Scanner(System.in); 
for(int i=0;i<=9;i++){
int n=sc.nextInt();
if(n>one){
three=two;
two=one;
one=n;
}else if (n>two){
three = two;
two = n;
}
else if(n>three){
three = n;
}
}
System.out.println(one);
System.out.println(two);
System.out.println(three);
 } }


Measured memory_bytes: 26216
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

using Facts = map<ll, int>; 
void factrize(ll n, Facts& mp) {
    if(n < 2) return;
    ll m = sqrt(n);
    REP(i, 2, m+1) {
        int cnt = 0;
        while(n%i == 0) {
            n /= i;
            ++cnt;
        }
        mp[i] += cnt;
    }
    if(n != 1) mp[n]++;
}

int main(){
  ll n;
  cin >> n;
  Facts f;
  factrize(n, f);
  cout << n << ":";
  for(auto& p : f) {
    rep(i, p.se) cout << " " << p.fi;
  }
  cout << endl;
}



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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s,t; cin>>s>>t;
  sort(all(s));
  sort(all(t));
  reverse(all(t));
  if(s<t) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int n,k,x,y;
  cin>>n>>k>>x>>y;

  if(n<=k) cout<<x*n<<endl;
  else cout<<x*k+y*(n-k)<<endl;
  
	return 0;
}

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

typedef long long ll;

#define PB push_back
#define MP make_pair

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    ll l, r; cin >> l >> r;
    r = min(r, l + 2019);
    ll ans = 2018;
    for (ll i = l; i <= r; ++i) {
        for (ll j = i + 1; j <= r; ++j) {
            ans = min(ans, (1LL * i * j) % 2019);
        }
    }
    cout << ans << "\n";
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* print new lines
*/

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7
ALPHABET = [chr(i) for i in range(ord('A'), ord('Z') + 1)]


def resolve():
    H, W = map(int, input().split())
    S = [list(input().split()) for _ in range(H)]

    for w in range(W):
        for h in range(H):
            if S[h][w] == "snuke":
                break
        else:
            continue
        break

    print(chr(65 + w) + str(h + 1))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define F(i,a,b) for(int i=a;i<b;i++)
#define RF(i,a,b) for(int i=a;i>b;i--)
#define mp(a,b) make_pair(int a,int b)
#define ll long long
const int mxn=1e5+10,mxm=4e5+10;
const ll modl=998244353;
int nm,n,m,p,t,k;
int ans,sum;
int a[mxn],b[mxn],h[mxn];
int l,r;
int main(){
    ios_base::sync_with_stdio(false);
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    cin>>nm;
//    string s,s1,s2;char c;
    while(cin>>n>>m){
//        priority_queue<dp,vector<dp>,cmp>q;
        F(i,0,n){
            cin>>a[i];
            p+=a[i];
        }
        sort(a,a+n,greater<int>());
        F(i,0,m){
            if(a[i]*4*m<p) {cout<<"No"; return 0;   }
        }
        cout<<"Yes";
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner stdin = new Scanner(System.in);

        int N = stdin.nextInt();
        double sum=0;
        for(int i=1;i<=N;i++) {
        	if(i%2!=0) {
        		sum+=1;
        	}
        }
        System.out.println(sum/N);
    }
}


Measured memory_bytes: 23764
#include <iostream>

using namespace std;

int n,m,q,a[20];

bool query(int s,int d) {
	if(d == n) {
		if(s == 0) return true;
		else return false;
	}
	return query(s-a[d],d+1) || query(s,d+1);
}

int main() {
	cin >> n;
	for(int i = 0;i < n;i++) {
		cin >> a[i];
	}
	cin >> q;
	for(int i = 0;i < q;i++) {
		cin >> m;
		if(query(m,0)) cout << "yes" << endl;
		else cout <<"no" << endl;
	}
}



Measured memory_bytes: 3096
import java.util.*;
import java.util.Map.Entry;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<Long,Long> w = new HashMap<>(n);
        for( int i=0; i<n; i++) {
            Long a = sc.nextLong();
            Long b = sc.nextLong();
            if( w.containsKey(b) ) {
                a += w.get(b);
            }
            w.put(b,a);
        }
        n = w.size();
        //
        List<Entry<Long,Long>> en = new ArrayList<>(w.entrySet());
        Collections.sort(en, new Comparator<Entry<Long, Long>>() {
            @Override
            public int compare(Entry<Long, Long> e1, Entry<Long, Long> e2) {
                return (e1.getKey()).compareTo(e2.getKey());
            }
        });
        //
        String ans = "Yes";
        long check = 0;
        for( Entry<Long,Long> e : en ) {
            check += e.getValue();
            if( check > e.getKey() ) {
                ans = "No";
                break;
            }
        }
        System.out.println(ans);
    }

}

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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e5; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll n,ans=0;
	string s;
	cin>>n>>s;
	forn(i,n-2){
		if(s[i]=='A'&& s[i+1]=='B'&&s[i+2]=='C')ans++;
	}
	cout<<ans<<"\n";
	return 0;
}


// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""



Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){


    int n; cin >> n;
    string s, r; cin >> s >> r;
    for( int i = 0 ; i < n ; i++ ){

        if(  s.substr(i,r.size()) == r.substr(0,r.size()-i)  ){
            cout << r.size() + i << '\n';
            return 0;
        }

    }

    cout << n+n << '\n';

}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}
func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func main() {
	N := nextInt()
	var top, sec int
	l := make([]int, N)
	for i := 0; i < N; i++ {
		n := nextInt()
		l[i] = n
		if top < n {
			sec = top
		} else {
			sec = max(sec, n)
		}
		top = max(top, n)
	}
	for i := 0; i < N; i++ {
		if l[i] == top {
			fmt.Println(sec)
		} else {
			fmt.Println(top)
		}
	}
}

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}


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

#define debug(x) cout << #x" = " << x;

#define st first
#define nd second

using namespace std;
using namespace placeholders;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

const int MAXN = 5E5 + 10, SIGMA = 26, D = 18;

char s[MAXN];
int nex[MAXN][SIGMA + 1];
int p[D][MAXN];

int main(){
	scanf("%s", s);
	int n = strlen(s);
	fill_n(nex[n], SIGMA, n + 1);
	p[0][n] = n + 1;
	fill_n(nex[n + 1], SIGMA, n + 1);
	p[0][n + 1] = n + 1;
	for (int i = n - 1; i >= 0; --i){
		int m = s[i] - 'a';
		nex[i][m] = i + 1;
		for (int j = m + 1; j <= SIGMA; ++j)
			nex[i][j] = nex[nex[i][j - 1]][j - 1];
		for (int j = 0; j < m; ++j)
			nex[i][j] = nex[nex[i][SIGMA]][j];
		p[0][i] = nex[i][SIGMA];
	}
	for (int i = 1; i < D; ++i)
		for (int j = 0; j <= n + 1; ++j)
			p[i][j] = p[i - 1][p[i - 1][j]];

	int q;
	scanf("%d", &q);
	for (int l, r, qi = 0; qi < q; ++qi){
		scanf("%d%d", &l, &r);
		--l;
		for (int i = D - 1; i >= 0; --i)
			if (p[i][l] <= r)
				l = p[i][l];
		puts(l == r ? "Yes" : "No");
	}
	return 0;
}


Measured memory_bytes: 89088
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    int H,A;
    cin >> H >> A;
    int ans=0;
    while(H>0) H-=A,ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;

long long dp[51][51][2501];

int main() {
    int N, A;
    cin >> N >> A;
    vector<int> X(N);
    for (int i = 0; i < N; i++)
        cin >> X[i];

    dp[0][0][0] = 1;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= N; j++) {
            for (int k = 0; k <= 2500; k++) {
                dp[i + 1][j][k] += dp[i][j][k];
                if (j > 0 && X[i] <= k) {
                    dp[i + 1][j][k] += dp[i][j - 1][k - X[i]];
                }
            }
        }
    }

    long long res = 0;
    for (int i = 1; i <= N; i++) {
        res += dp[N][i][i * A];
    }
    cout << res << endl;
    return 0;
}

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

//////////////////
// Union-Find木 //
//////////////////

class UnionFind {
private:
	std::vector<int> parent_, size_;
public:
	UnionFind(const int size)
		:parent_(size), size_(size, 1)
	{
		for (int i{}; i < size; i++) parent_[i] = i;
	}
	int calcRoot(const int index)
	{
		if (parent_[index] == index) return index;
		const int p{calcRoot(parent_[index])};
		parent_[index] = p;
		return p;
	}
	bool areConnected(const int index1, const int index2)
	{
		return calcRoot(index1) == calcRoot(index2);
	}
	void unite(const int index1, const int index2)
	{
		const int root1{calcRoot(index1)}, root2{calcRoot(index2)};
		if (root1 == root2) return;
		if (size_[root1] <= size_[root2])
		{
			size_[root2] += size_[root1];
			parent_[root1] = root2;
		}
		else
		{
			size_[root1] += size_[root2];
			parent_[root2] = root1;
		}
		return;
	}
	int calcSize(const int index)
	{
		return size_[calcRoot(index)];
	}
};

int main()
{
	int N, M;
	scanf("%d%d", &N, &M);
	std::vector<bool> has_colored(N);
	for (int i{}; i < M; i++)
	{
		int a, L;
		scanf("%d%d", &a, &L);
		for (int i{a}; i < a + L; i++)
			has_colored[i % N] = true;
	}
	
	UnionFind uf(N);
	for (int i{}; i < N; i++)
		if (has_colored[i] && has_colored[(i + 1) % N])
			uf.unite(i, (i + 1) % N);
	
	std::vector<bool> is_root(N);
	for (int i{}; i < N; i++)
		if (has_colored[i])
			is_root[uf.calcRoot(i)] = true;

	std::map<int, int> length;
	for (int i{}; i < N; i++)
		if (is_root[i])
			length[uf.calcSize(i)]++;
	
	for (auto it{length.rbegin()}; it != length.rend(); it++)
		printf("%d %d\n", it->first, it->second);

	return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long N, K;
  cin >> N >> K;
  vector<long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  long ok = -1e18-1, ng = 1e18+1;
  while (ng - ok > 1) {
    long mid = (ok + ng) / 2, sum = 0;
    for (int i = 0; i < N; i++) {
      long double tmp = (long double) mid / A.at(i);
      if (A.at(i) > 0) sum += lower_bound(A.begin(), A.end(), tmp) - A.begin();
      if (A.at(i) < 0) sum += N - (upper_bound(A.begin(), A.end(), tmp) - A.begin());
      if (A.at(i) == 0) sum += (mid > 0) ? N : 0;
      if (A.at(i) * A.at(i) < mid) sum--;
    }
    (sum / 2 < K) ? ok = mid : ng = mid;
  }
  cout << ok << "\n";
}


Measured memory_bytes: 4736
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	int A,B,C;
	cin >> A >> B >> C;
	int ans = 0;
	//偶奇を合わせる
	if(A%2 == B%2 && A%2 == C%2){
	
	}
	else{
		if(A%2 == B%2){
			A++; B++;
		}
		else if(A%2 == C%2){
			A++; C++;
		}
		else{
			B++; C++;
		}
		ans++;
	}
	int m = max({A,B,C});
	ans += (m-A)/2 + (m-B)/2 + (m-C)/2;
	cout << ans << endl;


	return 0;
}



Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
c=0
d={}
f=[0]*(max(l)+1)
for i in l:
	if i in d:
		d[i]+=1
	else:
		d[i]=1
x=sorted(list(set(l)))
for i in x:
	if d[i]==1 and f[i]==0:
		c+=1
	for j in range(2*i,len(f),i):
		f[j]=1 

print(c)

Measured memory_bytes: 157032
n = int(input())
alist = list(map(int, input().split()))

preva = None
mode = 0  # 0: 不定 1: 単調増加 2: 単調減少
c = 0
for a in alist:
  if preva is None:
    preva = a
  elif mode == 0:
    if preva == a:
      continue
    if preva > a:
      mode = 2
    else:
      mode = 1
    preva = a
  elif mode == 1 and preva > a:
    c += 1
    preva = a
    mode = 0
  elif mode == 2 and preva < a:
    c += 1
    preva = a
    mode = 0
  else:
    preva = a
print(c + 1)


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string N;
	cin >> N;
	int64 sum = 0;
	REP(i, N.size()) sum += N[i] - '0';
	cout << (sum % 9 == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3736
import java.util.Scanner;
 
class Main {
	int n;
	int[] h;
	int[] cost;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
	}
	Main(Scanner sc){
		n = sc.nextInt();
		h = new int[n];
		cost = new int[n];
		for(int i = 0; i < n;i++){
			h[i] = sc.nextInt();
			cost[i] = Integer.MAX_VALUE;
		}
		cost[0] = 0;
	}
	int cntString(String str,char target){
		int cnt = 0;
		for(char s : str.toCharArray()){
			if(s == target){
				cnt++;
			}
		}
		return cnt;
	}
	boolean[] checked;
	void solve(){
		checked = new boolean[n];
		for(int i=1;i<n;i++) checked[i] = false;
		checked[0] = true;
		System.out.println(reSolve(n-1));
	}
	int reSolve(int num){
		if(checked[num]) return cost[num];
		cost[num] = Math.min(cost[num], reSolve(num-1)+Math.abs(h[num]-h[num-1]));
		if (num>1) cost[num] = Math.min(cost[num], reSolve(num-2)+Math.abs(h[num]-h[num-2]));
		checked[num] = true;
		return cost[num];
	}
}


Measured memory_bytes: 75056
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>
#include <set>
#include <map>
#include <string.h>
#include <iomanip>

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
#define clr(n) memset(n,0,sizeof(n))
#define ll long long

using namespace std;
#define double long double

double dp[101][101];

int main()
{
	int n, t, l, b;
	while (cin >> n >> t >> l >> b && n) {
		vector<int> fl(n+1, 0), fb(n+1, 0);
		rep(i, l) {
			int t;
			cin >> t;
			fl[t] = 1;
		}
		rep(i, b) {
			int t;
			cin >> t;
			fb[t] = 1;
		}
		clr(dp);
		dp[0][0] = 1.0;
		rep(i, t) {
			rep(j, n) {
				for (int k = 1; k <= 6; k++) {
					int now = j + k;
					if (now > n) {
						now -= (now - n) * 2;
					}
					if (fl[now]) {
						dp[i + 2][now] += dp[i][j] / 6.0;
						continue;
					}
					if (fb[now]) {
						dp[i + 1][0]   += dp[i][j] / 6.0;
						continue;
					}

					dp[i + 1][now] += dp[i][j] / 6.0;
				}
			}
		}
		double ans = 0;
		rep(i, t+1) {
			ans += dp[i][n];
		}
		cout << fixed << setprecision(30) << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1436
#include <stdio.h>

int main() {
  int a,e,t,k;
  scanf("%d\n",&a);
   scanf("%d\n",&t);
   scanf("%d\n",&t);
   scanf("%d\n",&t);
   scanf("%d\n",&e);
   scanf("%d\n",&k);
  if(e-a>k) printf(":(");
  else printf("Yay!");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define endl '\n'
 
int t=1;
 
// void print2d(vector<vector<int>> &v){
//     for(int i=0;i<v.size();i++){
//         for(int x:v[i]){
//             cout << x <<' ';
//         }
//         cout <<endl;
//     }
// }
 
// void print(vector<int> &a){
//     for(int x : a){
//         cout << x <<' ';
//     }
//     cout << endl;
//     return;
// }

void solve(){
    int n,l;
    cin >> n >> l;
    for(int i=0;i<=n;i++){
        if((l+2*i)==4*n){cout << "Yes" <<endl;return;}
    }
    cout << "No" <<endl;
}
 
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
 
    // cin >> t;
    for(int i=1;i<=t;i++){
        solve();
    }
    // solve();
 
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
int dxx[8] = { 1, 1, 1, 0, 0, -1, -1, -1 }, dyy[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };

int main() {
    int n, m;
    cin >> n >> m;
    int a[m], b[m];
    Graph g (n);
    rep (i, m) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        g[a[i]].push_back (b[i]);
        g[b[i]].push_back (a[i]);
    }
    //bfsで確かめる
    int cnt = 0;
    rep (i, m) {
        auto itra = find (g[a[i]].begin(), g[a[i]].end(), b[i]);
        auto itrb = find (g[b[i]].begin(), g[b[i]].end(), a[i]);
        g[a[i]].erase (itra);
        g[b[i]].erase (itrb);
        queue<int> q;
        q.push (0);
        bool seen[n] = {};
        seen[0] = 1;
        while (!q.empty()) {
            int now = q.front();
            q.pop();
            for (auto next : g[now]) {
                if (seen[next]) continue;
                seen[next] = 1;
                q.push (next);
            }
        }
        rep (i, n) {
            if (!seen[i]) {
                cnt++;
                break;
            }
        }
        g[a[i]].push_back (b[i]);
        g[b[i]].push_back (a[i]);
    }
    cout << cnt << "\n";
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> ii;

#define repa(i, a, b) for (auto i = (a); i <= (b); i++)
#define repd(i, a, b) for (auto i = (a); i >= (b); i--)
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define zero(a)  memset((a), 0, sizeof (a))
#define sz(x) (int)(x).size()
#define debug(x) cout << (x) << "\n";
#define mp make_pair
#define pb push_back

ll n, k;

void solve() {
	auto thr = n / k;
	auto n1 = n - thr * k;
	auto n2 = k - n1;
	assert(n2 >= 0);
	cout << min(n1, n2);
	cout << "\n";
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	solve();
	return 0;
}


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

using namespace std;

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

map<string,bool> used;

bool ok = false;

bool dfs(string s){
	if(used[s]) return false;
	used[s] = true;
	if(s.size()==1) return true;
	vector<int> p;
	string t;
	int pos = 0;
	vector<int> cnt(3);
	while(pos<s.size()){
		if(s.substr(pos,3)=="ABC"){
			p.push_back(t.size());
			t+='C';
			pos += 3;
		}
		else{
			cnt[s[pos]-'A']++;
			t += s[pos];
			pos++;
		}
	}
	if(cnt[2]==0&&dfs(t)) return true;
	rep(i,2){
		for(int x: p){
			t[x] = char('A'+i);
		}
		if(cnt[i]==0&&dfs(t)) return true;
	}
	return false;
}

int main(){
	string s;
	cin>>s;
	if(s.size()<3) cout<<"No"<<endl;
	else cout<<(dfs(s)?"Yes":"No")<<endl;
}

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

using namespace std;

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

	int a;
	string s;

	cin >> a;
	cin >> s;

	if (a < 3200)
	{
		cout << "red" << endl;
	}
	else
	{
		cout << s << endl;
	}

	return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
int N,A,B;
int main() {
    cin>>N>>A>>B;

    if((N*A)>=B)cout<<B<<endl;
    else cout<<N*A<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
using namespace std;

int main(){
    string S;
    cin >> S;
    if(S.len % 2 == 0) {
        S.ppb;
        S.ppb;
    }
    else S.ppb;
    bool d=1;
    while(d){
        bool t = 1;
        rep(i, S.len / 2){
            if(S.at(i) != S.at(i + S.len / 2)){
                S.ppb;
                S.ppb;
                t = 0;
                break;
            }
        }
        if(S.at(S.len/2 - 1) == S.at(S.len - 1) && t){
            cout << S.len << endl;
            d = 0;
            break;
        }
        
    }

    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
s = gets.rstrip

l = 0
r = n - 1
c = 0

while l < r
  while s[l] == 'R' && l < r
    l += 1
  end

  if l >= r
    break
  end

  while s[r] == 'W' && l < r
    r -= 1
  end

  if l >= r
    break
  end

  l += 1
  r -= 1
  c += 1
end

p c


Measured memory_bytes: 14736
import math
import itertools

# 与えられた数値の桁数と桁値の総和を計算する.
def calc_digit_sum(num):
    digits = sums = 0
    while num > 0:
        digits += 1
        sums += num % 10
        num //= 10
    return digits, sums


n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

pidx, qidx = 0, 0
candidates = list(itertools.permutations(range(1, n+1), n))
for index, candidate in enumerate(candidates):
    candidate = list(candidate)

    if candidate == p:
        pidx = index
    if candidate == q:
        qidx = index

print(abs(pidx - qidx))


Measured memory_bytes: 80132
/* 
 * File:   main.c
 * Author: s1252007
 *
 * Created on June 15, 2018, 12:38 PM
 */

#include <stdio.h>
#include <stdlib.h>

/*
 * 
 */

int checkPrime(int b);

int main(int argc, char** argv) {
    int size, counter = 0;
    int *A;
    
    scanf("%d", &size);
    A = (int *)malloc(sizeof(int) * size);
    
    for (int i = 0; i < size; ++i)
    {
        scanf("%d", &A[i]);
        if (checkPrime(A[i])) counter++;
    }
    
    printf("%d\n", counter);
    
    return (EXIT_SUCCESS);
}

int checkPrime ( int b )
{
    int a = 0;
    int i = 1;
    while( i <= b / i )
    {
        if( b % i == 0 ) 
        {
            a = a + i + (b/i);
        }
        i++;
    }
    if ( a == b+1 ) return 1; //Is Prime
    return 0; //Not Prime
}



Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <functional>
using namespace std;

int main() {
	vector<int> v;
	for (int i = 0; i < 5; ++i) {
		int a; cin >> a;
		v.push_back(a);
	}
	sort(v.begin(), v.end(), greater<int>());
	
	for (int i = 0; i < 5; ++i) {
		if (i == 4) {
			cout << v[i];
			cout << endl;
			break;
		}
		cout << v[i] << " ";
	}
	return 0;
}


Measured memory_bytes: 3148
import math
n=int(input())
t=int(math.sqrt(n))
ans=[0 for i in range(100001)]
for j in range(1,t):
  for k in range(1,t):
    for l in range(1,t):
      s=j**2+k**2+l**2+j*k+k*l+j*l
      if s<10001:
        ans[s]+=1
          
for m in range(1,n+1):
  print(ans[m])

Measured memory_bytes: 9716
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
class tt
{
public:
    long long a;
    int b;
};
tt t[500001];
int n,m;
int cmp(const tt &t1,const tt &t2)
{
    return t1.a<t2.a;
}
//int book[100001];
int min1=999999;
int main()
{
    while(scanf("%d %d",&n,&m)!=EOF)
    {

        for(int i=0; i<m; i++)
        {
            cin>>t[i].a>>t[i].b;
            if(min1>t[i].b)
                min1=t[i].b;
        }

        sort(t,t+m,cmp);
        //for(int i=0; i<m; i++)
            //cout<<t[i].a<<" "<<t[i].b<<endl;
        //memset(book,0,sizeof(book));
        int sum=0;
        int i=0;
        while(i!=m)
        {
            for(i;i<m;i++)
            {
                if(t[i].a>=min1)
                    break;
            }
            sum++;
            min1=999999;
            for(int j=i;j<m;j++)
                {
                    if(t[j].b<min1)
                        min1=t[j].b;
                }
        }
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#define MALLOC(type, n) (type *)malloc((n)*sizeof(type))
#define HASH(A, W, B) (((W%166667)*(A%166667)+B%166667)%166667)
#define TYPELIST unsigned long 

struct list{
	TYPELIST item;
	struct list *next;
};

typedef struct list List;

void KillList(List *list){
	if(list!=NULL){
		KillList(list->next);
		free(list);
	}
}

List* AddList(List *head, TYPELIST item){
	List *newlist;
	newlist=MALLOC(List, 1);
	newlist->item=item;
	newlist->next=head;
	return newlist;

}

int main(){
	unsigned long H, W, N, i, *a, *b, sl[2][2], h, w, k, ax, bx;
	unsigned long long ans[10];
	List *table[166667], *lp;
	int j, finded;
	for(i=0; i<166667; i++) table[i]=NULL;
	for(j=0; j<10; j++) ans[j]=0;
	
	scanf("%lu %lu %lu", &H, &W, &N);
	a = MALLOC(unsigned long, N);
	b = MALLOC(unsigned long, N);
	for(i=0; i<N; i++){
		scanf("%lu %lu", a+i, b+i);
		table[HASH(a[i], W, b[i])]=AddList(table[HASH(a[i], W, b[i])], i);
	}
	
	for(i=0; i<N; i++){
		sl[0][0]=(a[i]<3? 1: a[i]-2);
		sl[0][1]=(b[i]<3? 1: b[i]-2);
		sl[1][0]=(H-a[i]<2? H-2: a[i]);
		sl[1][1]=(W-b[i]<2? W-2: b[i]);
		for(h=sl[0][0]; h<=sl[1][0]; h++){
			for(w=sl[0][1]; w<=sl[1][1]; w++){
				j=0;
				for(k=0; k<9; k++){
					ax=h+k/3;
					bx=w+k%3;
					lp=table[HASH(ax, W, bx)];
					while(lp!=NULL && !(ax==a[lp->item] && bx==b[lp->item])) lp=lp->next;
					if(lp!=NULL) finded=1;
					else finded=0;
					if(finded==1 && lp->item<i){
						j=0;
						break;
					}
					else if(finded==1) j++;
					
				}
				ans[j]++;
			}
		}
	}
	ans[0]=(unsigned long long)(H-2)*(unsigned long long)(W-2);
	for(j=1; j<10; j++) ans[0] -= ans[j];
	
	for(j=0; j<10; j++) printf("%llu\n", ans[j]);
	
	free(a);
	free(b);
	for(i=0; i<166667; i++) KillList(table[i]);
	return 0;
}


Measured memory_bytes: 6144
#include <iostream>
#include <cstdio>
#define N 30
using namespace std;
int main(){
  int w,n,tmp;
  int lod[N]; int lis[N][3];
  while(cin >> n >> w){
  for(int i = 0;i<n;i++){
    lod[i] = i+1;
  }
 
  for(int i=0;i<w;i++){
    scanf("%d,%d",&lis[i][0],&lis[i][2]);
  }
  for(int i=0;i<w;i++){
    tmp = lod[lis[i][0]-1];
    lod[lis[i][0]-1] = lod[lis[i][2]-1];
    lod[lis[i][2]-1] = tmp;
  }
  for(int i=0;i<n;i++){
    cout << lod[i] << endl;
  }
  }
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
int getting_digits_sum(int number){
    int sum =0;
    while(number > 0){
       sum += number%10;
       number /= 10;
    }
    return sum;
}

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    int sum = 0;
    for(int i=1; i<=n; i++){
        if(getting_digits_sum(i) >= a && getting_digits_sum(i) <= b) sum += i;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (ll i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    ll N;
    cin >> N;
    int cnt = 0;
    int ni = 0;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    rep(i, N){
        a[i]%=4;
        if(!a[i]) cnt++;
        else if(a[i]==2) ni++;
    }
    cnt+=ni/2;
    if(N%3==0) cout << (N/3<=cnt? "Yes": "No") << endl;
    else cout << (N/2<=cnt? "Yes": "No") << endl;
    return 0;
}


Measured memory_bytes: 4036