akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    lint n, k;
    cin >> n >> k;
    vector<lint> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    // dp[i][j]:(i:未満フラグ),(j:決めた桁数)
    vector<vector<lint>> dp(2, vector<lint>(51, -1));
    dp[0][0] = 0;
    for (int i = 0; i < 50; i++) {
        lint mask = 1LL << (50 - 1 - i);
        // 50-1-iビット目が何本立ってるか調べる
        lint num_bit = 0;
        for (int j = 0; j < n; j++) {
            if (a[j] & mask) num_bit++;
        }
        // 0->0
        if (k & mask) {
            dp[0][i + 1] = dp[0][i] + (n - num_bit) * mask;
        } else {
            dp[0][i + 1] = dp[0][i] + num_bit * mask;
        }
        // 0->1
        if (k & mask) {
            dp[1][i + 1] = max(dp[1][i + 1], dp[0][i] + num_bit * mask);
        }
        // 1->1
        if (dp[1][i] != -1) {
            dp[1][i + 1] =
                max(dp[1][i + 1], dp[1][i] + max(num_bit, n - num_bit) * mask);
        }
    }
    cout << max(dp[0][50], dp[1][50]) << endl;
}

Measured memory_bytes: 1024
// Problem : A - αlphabet
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    char a;
    cin>>a;
    if(isupper(a)) cout<<"A"<<endl;
    else cout<<"a"<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main()
{
	int w, h, x, y, r;
	
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	
	if((x+r <= w && x - r >= 0) && (y + r <= h && y - r >= 0))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
	return 0; 
}


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

#define all(x) (x).begin(), (x).end()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

int main() {
  _upgrade;
  int x;
  cin >> x;
  if (x == 0) {
    cout << 1 << "\n";
  } else {
    cout << 0 << "\n";
  }
  return 0;
}

Measured memory_bytes: 3628
n=int(input())
d= list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))

if n<m:
    print('NO')
    exit(0)

pro={}
for i in d:
    if i in pro:
        pro[i]+=1
    else:
        pro[i]=1

for j in t:
    if j in pro:
        if pro[j]>0:
            pro[j]-=1
        else:
            print('NO')
            exit(0)
    else:
        print('NO')
        exit(0)

print('YES')

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

template <typename T>
using lim = numeric_limits<T>;

const int MAX = 1e4;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n, m; cin >> n >> m;
	int total = 0;
	for (int i = 0; i < m; i++) {
		int a; cin >> a;
		total += a;
	}

	int ans = n-total;
	if (ans < 0) cout << -1 << "\n";
	else cout << ans << "\n";
}

Measured memory_bytes: 3644
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long M = sc.nextLong();
        long ans;
        if(2*N>=M) ans = M/2;
        else{
            ans = N;
            long left = M-2*N;
            ans += left/4;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21588
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
#define findge lower_bound
#define findgt upper_bound
const i64 MOD = 1000000007;
const f64 EPS = 1e-10;

i64 n, m, q;
i32 s[2001][2001];
i32 v[2001][2001];
i32 eh[2001][2001], ev[2001][2001];

i32 main()
{
	cin >> n >> m >> q;
	upto(1, n, i) {
		upto(1, m, j) {
			char c; cin >> c;
			s[i][j] = c - '0';
		}
	}
	upto(1, n, i) {
		upto(1, m, j) {
			v[i][j] = v[i][j - 1] + v[i - 1][j] - v[i - 1][j - 1] + s[i][j];
			i32 e1 = (s[i][j] > 0 && s[i][j - 1] == s[i][j]) ? 1 : 0;
			i32 e2 = (s[i][j] > 0 && s[i - 1][j] == s[i][j]) ? 1 : 0;
			eh[i][j] = eh[i][j - 1] + eh[i - 1][j] - eh[i - 1][j - 1] + e1;
			ev[i][j] = ev[i][j - 1] + ev[i - 1][j] - ev[i - 1][j - 1] + e2;
		}
	}
	times(q, k) {
		i32 a, b, c, d; cin >> a >> b >> c >> d;
		i64 cnt = v[c][d] - v[a-1][d] - v[c][b-1] + v[a-1][b-1];
		i64 ehcnt = eh[c][d] - eh[a-1][d] - eh[c][b] + eh[a-1][b];
		i64 evcnt = ev[c][d] - ev[a][d] - ev[c][b-1] + ev[a][b-1];
		cout << (cnt - ehcnt -evcnt) << endl;
	}
	return 0;
}


Measured memory_bytes: 64384
#include <iostream>
#include <climits>

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

using namespace std;

int main(){
	long long a,b,c,d;
	cin >> a >> b >> c >> d;
	
	long long num1 = a*c;
	long long num2 = a*d;
	long long num3 = b*c;
	long long num4 = b*d;
	
	long long max = LONG_MIN;
	if(max < num1) max = num1;
	if(max < num2) max = num2;
	if(max < num3) max = num3;
	if(max < num4) max = num4;
	
	cout << max << endl;
	
	
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
#define         ull             unsigned long long
#define         ll              long long
#define         inf             INT_MAX
#define         pi              acos(-1.0)
#define         vi              vector<int>
#define         vl              vector<long long>
#define         pii             pair<int,int>
#define         pll             pair<long long,long long>
#define         mp              make_pair
#define         mii             map<int,int>
#define         mll             map<int,int>
#define         mli             multimap<int,int>
#define         mlll            multimap<long long,long long>
#define         msi             multiset<int>
#define         msl             multiset<long long>
#define         si              set<int>
#define         sl              set<long long>
#define         FOR(I,A,B)      for(int I = (A); I < (B); I++)
#define         rev(I,A,B)      for(int I = A ; I >= B ; I--)
#define         mem(a, v)       memset(a, v, sizeof (a))
#define         mod             1000000007
#define         all(a)          a.begin(),a.end()
#define         rall(a)         a.rbegin(),a.rend()
#define         ff              first
#define         ss              second
#define         arsort(ar,n)    sort(ar,ar+n);
#define         vsort(v)        sort(v.begin(),v.end())
#define         vrev(v)         reverse(v.begin(),v.end())
#define         arrev(ar,n)     reverse(ar,ar+n)
#define         pb              push_back
#define         popb            pop_back
#define         booster()       ios_base::sync_with_stdio(0); cin.tie(0);
#define         read(f)         freopen(f, "r", stdin)
 
 
#define         min3(a,b,c)     min(a,min(b,c))
#define         max3(a,b,c)     max(a,max(b,c))
#define         min4(a,b,c,d)   min(min(a,b),min(c,d))
#define         max4(a,b,c,d)   max(max(a,b),max(c,d))
#define         max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define         min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
 
 
#define         bitCheck(a,k)     ((bool)(a&(1<<(k))))
#define         bitOff(a,k)       (a&(~(1<<(k))))
#define         bitOn(a,k)        (a|(1<<(k)))
#define         bitFlip(a,k)      (a^(1<<(k)))
 
 
int fx[] = {-1,+0,+1,+0,+1,+1,-1,-1,+0};
int fy[] = {+0,-1,+0,+1,+1,-1,+1,-1,+0};
int day[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
 
using namespace std;
 
bool comp(int x, int y) { return x > y; }
 
/*********************** let the play begin() ***********************************/
 
int main()
{
    booster()
    int n;
    cin>>n;
    int p=1;
    while(p<=n)
    {
        p*=2;
    }
    cout<<p/2;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll>PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll MOD = 1e4+7;
int main() {
    int n;
    cin >> n;
    ll l0 = 2;
    ll l1 = 1;
    if ( n == 1 ) {
        cout << l1 << endl;
        return 0;
    }
    ll l_next = 0;
    for ( int i = 2; i <= n; ++i ) {
        l_next = l0 + l1;
        l0 = l1;
        l1 = l_next;
//        cout << l_next << endl;
    }
    cout << l_next << endl;
    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

#include<unordered_set>

using namespace std;

#define dprint(Exp,...) if(Exp){fprintf(stderr, __VA_ARGS__);}
#define printe(...) fprintf(stderr, __VA_ARGS__);
#define PrtExp(_Exp)  cerr<< #_Exp <<" = "<< (_Exp)
#define PrtExpN(_Exp)  cerr<< #_Exp <<" = "<< (_Exp) <<"\n"

#define SINT(n) scanf("%d",&n)
#define SINT2(n,m) scanf("%d %d",&n,&m)
#define SINT3(n,m,o) scanf("%d %d %d",&n,&m,&o)
#define SINT4(n,m,o,p) scanf("%d %d %d %d",&n,&m,&o,&p)
#define SINT5(n,m,o,p,q) scanf("%d %d %d %d %d",&n,&m,&o,&p,&q)
#define SLL(n) scanf("%lld",&n)
#define SLL2(n,m) scanf("%lld %lld",&n,&m)
#define SLL3(n,m,o) scanf("%lld %lld %lld",&n,&m,&o)
#define SST(s) scanf("%s",s)
#define SCH(c) scanf("%c",&c)

#define GC() getchar()

#define PINT(n) printf("%d",(int)(n))
#define PINT2(n,m) printf("%d %d",(int)(n),(int)(m))
#define PINT3(n,m,l) printf("%d %d %d",(int)(n),(int)(m),(int)(l))
#define PLL(n) printf("%lld",(long long)(n))
#define PST(s) printf("%s",(s))
#define PCH(s) printf("%c",(s))

#define PINTN(n) printf("%d\n",(int)(n))
#define PINT2N(n,m) printf("%d %d\n",(int)(n),(int)(m))
#define PINT3N(n,m,l) printf("%d %d %d\n",(int)(n),(int)(m),(int)(l))
#define PLLN(n) printf("%lld\n",(long long)(n))
#define PSTN(s) printf("%s\n",(s))
#define PCHN(s) printf("%c\n",(s))

#define PSP() printf(" ")
#define PN() printf("\n")

#define PC(c) putchar(c)
#define CSP (' ')
#define SN ("\n")

#define rep(i,a) for(int i=0;i<a;i++)
#define reP(i,a) for(int i=0;i<=a;i++)
#define Rep(i,a) for(int i=a-1;i>=0;i--)
#define ReP(i,a) for(int i=a;i>=0;i--)

#define rEp(i,a) for(i=0;i<a;i++)
#define rEP(i,a) for(i=0;i<=a;i++)
#define REp(i,a) for(i=a-1;i>=0;i--)
#define REP(i,a) for(i=a;i>=0;i--)

#define repft(i,a,b) for(int i=a;i<b;i++)
#define repfT(i,a,b) for(int i=a;i<=b;i++)
#define Repft(i,a,b) for(int i=a-1;i>=b;i--)
#define RepfT(i,a,b) for(int i=a;i>=b;i--)

#define foreach(a,it) for(auto it = a.begin(); it != a.end(); ++it)

#define FILL(a,v) fill(begin(a),end(a), v)
#define FILL0(a) memset(a,0,sizeof(a))
#define FILL1(a) memset(a,-1,sizeof(a))

typedef long long ll;

typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll>   Pll;


const int INF = 1000000009;
const ll INFLL = 0x1f1f1f1f1f1f1f1fLL;//2,242,545,357,980,376,863

template <class A, class B> inline ostream& operator<<(ostream& st, const pair<A, B>& P) { return st << "(" << P.first << "," << P.second << ")"; };
template <class A, class B> inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first + Q.first, P.second + Q.second); };
template <class A, class B> inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first - Q.first, P.second - Q.second); };

#define fs  first	
#define sc  second


int main() {
	int a, b, c, d, e, f, g, h;
	int i, j, k, l, m, n, o, p, q, r;
	string s, t, u;
	int v, w, x, y, z;

	cin >> n;
	r = 0;
	rep(i, n) {
		cin >> a;
		while (a % 2 == 0) {
			++r;
			a /= 2;
		}
	}
	cout << r << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ff first
#define ss second
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  string s;
  cin >> s;
  rep(i, 0, s.size()) {
    if ((i + 1) % 2 != 0) {
      cout << s[i];
    }
  }
}

int main() {
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  Main();
}

Measured memory_bytes: 592
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
const int MaxN = 1e5 + 4;
typedef long long LL;
char s[MaxN];
int main(){
	cin>>s;
	int n;
	cin>>n;
	int t = strlen(s);
	for(int i = 0; i < t; i += n){
		cout<<s[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const S = (arg[0].split(" ")[0]);
    const T = (arg[0].split(" ")[1]);
    let A = parseInt(arg[1].split(" ")[0]);
    let B = parseInt(arg[1].split(" ")[1]);
    const U = (arg[2].split(" ")[0]);
    
    if(U === S) {
        A--;
    } else {
        B--;
    }
    
    console.log(A + " " + B);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 22076
/**
    __author__ : srv_twry
**/

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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}

bool ge(const ll& a, const ll& b) { return a >= b; }
bool le(const ll& a, const ll& b) { return a <= b; }
bool eq(const ll& a, const ll& b) { return a == b; }
bool gt(const ll& a, const ll& b) { return a > b; }
bool lt(const ll& a, const ll& b) { return a < b; }
int sgn(const ll& x) { return le(x, 0) ? eq(x, 0) ? 0 : -1 : 1; }
/*----------------------------------------------------------------------*/

const int N = 1e5+5;
int scores[N];

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
	int n,k,q,a; cin>>n>>k>>q;
	memset(scores, 0, sizeof(scores));
	FOR(i, 0, q) {
		cin>>a; a--;
		scores[a]++;
	}
	FOR(i, 0, n) {
		if(k - q + scores[i] > 0) {
			cout<<"Yes\n";
		} else {
			cout<<"No\n";
		}
	}
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,t;
  cin>>n>>m>>t;
  int x,y;
  x=0;
  int ans=0;
  for(int i=0;i<n;i++){
    cin>>y;
    if(i==0){
      ans+=y-m;
    }
    else if(y-x<2*m) 1;
    else ans+=y-x-2*m;
    x=y;
  }
  if(t-x>m) ans+=t-x-m;
  cout<<ans<<endl;
	
  return 0;
}



Measured memory_bytes: 3108
//Bismillahir Rahmanir-Rahim
/**@MSR**/
#include<bits/stdc++.h>
using namespace std;

#define mod 1e9+7
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vll vector<long long>
#define ll long long
#define lli long long int
#define el '\n'
#define inf 2000000000
#define mem(a,b) memset(a, b, sizeof(a) )

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define F1(i,n)  for(lli i=1;i<=n;i++)
#define F0(i,n)  for(lli i=0;i<n;i++)
#define FRev(i,n)  for(lli i=n-1;i>=0;i--)
#define ever (;;)

ll gcd(ll a,ll b){  return (b==0)?a:gcd(b,a%b);}
ll lcm(ll a,ll b) { ll x=(a/gcd(a,b))*b; return x; }

const int mx=1e5+123;
int dp[mx];
int n;
int h[mx];

int magic(int i)
{
    if(i==n)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    int ret2 = inf;
    int ret1 = abs ( h[i] - h[i+1] ) + magic ( i+1 );
    if ( i+2 <= n ) ret2 = abs ( h[i] - h[i+2] ) + magic ( i+2 );

  return dp[i] = min ( ret1, ret2 );
}

int main()
{
  optimize();
  ll t,x,y,k,z,m,a,b;
  /**/
  cin>>n;
  for(int i=1;i<=n;i++)
    cin>>h[i];

  mem(dp,-1);

  cout<<magic(1)<<el;

return 0;
}
/**/



Measured memory_bytes: 9004
s = input()
t = input()

ls = len(s)
lt = len(t)

dp = [[0]*(lt+1) for i in range(ls+1)]

for i in range(1,ls+1):
    for j in range(1,lt+1):
        if s[i-1] == t[j-1]:
            dp[i][j] = dp[i-1][j-1] + 1
        else:
            dp[i][j] = max(dp[i][j-1], dp[i-1][j])

max_len = dp[-1][-1]
ans = ""

i = ls
j = lt

while i > 0 and j > 0:
    if dp[i][j] == dp[i - 1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j - 1]:
        j -= 1
    else:
        ans += s[i - 1]
        i -= 1
        j -= 1

print(ans[::-1])

Measured memory_bytes: 113116
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	cout << max(0, A - 2 * B) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int date[9][5]={
	{2,1,3,0,0},
	{3,0,2,4,1},
	{2,1,5,2,2},
	{3,0,4,6,3},
	{4,1,3,5,7},
	{3,2,4,8,5},
	{2,3,7,6,6},
	{3,4,6,8,7},
	{2,5,7,8,8}
};
int main(){
	int n;
	while(cin>>n,n){
		long double dp[16][9]={0.0};
		int s,t,b;
		char S,T,B;
		cin>>S>>T>>B;
		s=S-'A';
		t=T-'A';
		b=B-'A';
		dp[0][s]=1.0;
		
		
		for(int i=0;i<15;i++){
			for(int j=0;j<9;j++){
				for(int k=1;k<=4;k++){
					if(date[j][k]!=b){
						dp[i+1][date[j][k]]+=dp[i][j]*0.25;
					}
					else{
						dp[i+1][j]+=dp[i][j]*0.25;
					}
				}
			}
		}
		//cout<<dp[n][t]<<endl;
		printf("%.8Lf\n",dp[n][t]);
	}
	return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  long long w;
  cin >> n >> w;
  vector<vector<long long>> dp(2, vector<long long>(1e5 + 1));
  for (int val = 0; val <= 1e5; val++) {
    dp[0][val] = 1e17;
  }
  dp[0][0] = 0;
  int crr = 0;
  int nxt = 1;
  for (int i = 0; i < n; i++) {
    long long a;
    int b;
    cin >> a >> b;
    dp[nxt] = dp[crr];
    for (int val = b; val <= 1e5; val++) {
      dp[nxt][val] = min(dp[crr][val], dp[crr][val - b] + a);
    }
    swap(crr, nxt);
  }
  long long maxv = 0;
  for (int val = 0; val <= 1e5; val++) {
    if (dp[crr][val] <= w) {
      maxv = val;
    }
  }
  cout << maxv << '\n';
  return 0;
}


Measured memory_bytes: 2560
s=str(input())
t=str(input())
flag=0
if(s==t):
    flag=1
    print('Yes')
else:
    a=s
    for i in range(len(s)-1,-1,-1):
        a=s[i]+a
        a=a[:-1]
        if(a==t):
            flag=1
            break
    if(flag==1):
        print('Yes')
    else:
        print('No')

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

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

  vector<ll> a(n), b(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];

  ll ans = 0;

  for (ll bit = 0; bit < 30; bit++) {
    ll cnt = 0;
    ll t = 1LL << bit;

    vector<ll> tmpa(n), tmpb(n);
    for (int i = 0; i < n; i++) {
      tmpa[i] = a[i] % (2 * t);
      tmpb[i] = b[i] % (2 * t);
    }

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

    for (int j = 0; j < n; j++) {
      cnt += lower_bound(tmpb.begin(), tmpb.end(), 4 * t - tmpa[j]) -
             lower_bound(tmpb.begin(), tmpb.end(), 3 * t - tmpa[j]);
      cnt += lower_bound(tmpb.begin(), tmpb.end(), 2 * t - tmpa[j]) -
             lower_bound(tmpb.begin(), tmpb.end(), t - tmpa[j]);
    }
    if (cnt % 2 == 1) ans += t;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9524
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  	ll n;
  	vector<ll> v, vcp;
  	cin >> n;
  	ll tmp;
  	for (int i = 0; i < n; i++){
      	cin >> tmp;
      	v.push_back(tmp);
      	vcp.push_back(tmp);
    }
  	sort(vcp.begin(), vcp.end(), greater<ll>());
  	ll mx = vcp[0];
  	ll mx_n = vcp[1];
  		
  	for (int i = 0; i < n; i++){
      	if (v[i] == mx){
          	cout << mx_n << endl;
        } else {
          	cout << mx << endl;
        }
    }
  
  	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

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

    ll N; cin >>N;
    string x;
    string u;
    double ans = 0;
    rep(i, N) {
        cin >> x >> u;
        if (u == "JPY") {
            ans += stoi(x);
        } else {
            ans += stod(x) * 380000.0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define D(...) fprintf(stderr,__VA_ARGS__)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
const int N=105;
int n,m,a[N][N],b[N],num[N],pre[N];
bool vis[N][N],pd[N],go[N][N];
int id(int x){return (x-1)/m+1;}
bool dfs(int k1){
	if(pd[k1])return 0;
	pd[k1]=1;
	rep(i,1,n)if(go[k1][i]){
		if(!pre[i]||dfs(pre[i])){
			pre[i]=k1;
			return 1;
		}
	}
	return 0;
}
int main(){
	scanf("%d%d",&n,&m);
#ifdef xay5421
	static int p[N*N];
	rep(i,1,n*m)p[i]=i;
	mt19937 ran;
	shuffle(p+1,p+1+n*m,ran);
	rep(i,1,n)rep(j,1,m)a[i][j]=p[(i-1)*m+j];
	rep(i,1,n)rep(j,1,m){
		printf("%d%c",a[i][j],j==m?'\n':' ');
	}
#else
	rep(i,1,n)rep(j,1,m)scanf("%d",&a[i][j]);
#endif
	rep(j,1,m){
		memset(go,0,sizeof(go));
		rep(i,1,n)rep(k,j,m)go[id(a[i][k])][i]=1;
		memset(pre,0,sizeof(pre));
		rep(i,1,n){
			memset(pd,0,sizeof(pd));
			assert(dfs(i));
		}
		rep(i,1,n){
			int cur=pre[i];
			bool flg=0;
			rep(k,j,m){
				if(id(a[i][k])==cur){
					swap(a[i][k],a[i][j]);
					flg=1;
					break;
				}
			}
			assert(flg);
		}
	}
	rep(i,1,n)rep(j,1,m)printf("%d%c",a[i][j],j==m?'\n':' ');
	rep(j,1,m){
		rep(i,1,n)b[i]=a[i][j];
		sort(b+1,b+1+n);
		rep(i,1,n)a[i][j]=b[i];
	}
	rep(i,1,n)rep(j,1,m)printf("%d%c",a[i][j],j==m?'\n':' ');
	return 0;
}
/*
5 5
4 10 22 25 2
6 20 19 13 17
5 18 14 24 12
7 3 15 1 9
16 11 21 8 23

5 4
3 10 1 15
5 19 8 12
4 9 17 13
14 18 6 7
11 20 16 2
*/

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

double g( int a, int b, int c, int d ) {
  return (a-c)*(a-c)+(b-d)*(b-d);
}

double f( int a, int b, int c, int d ) {
  return sqrt(g(a,b,c,d));
}
void ok() { puts("YES"); }
void ng() { puts("NO");  exit(0); }

int main() {
  int n;
  cin >> n; 
  long long a=1,b=1;
  for ( int i=0; i<n; i++ ) {
    long long x,y;
    cin >> x >> y;
    long long d=max(a/x,b/y);
    for ( ; x*d<a || y*d<b; d++ );
    a=x*d; b=y*d;
  }
  cout << a+b << '\n';
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0]))
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << "(" << pair_var.first << ", " << pair_var.second << ")";return os;}
// head

int x,n,k,c,q,res;
int a[101000] = {};
queue<int> que;
queue<int> que2;
string s;
vector<vector<int>> vec;
signed main() {
	std::cin >>n>>c>>k;
	rep(i,0,n){
		std::cin >> a[i];
	}
	sort(a,a+n);
	res = 0;
	que.push(a[0]);
	que2.push(a[0]+k);
	rep(i,1,n){
		if (que2.front() >= a[i]){
		que.push(a[i]);
		que2.push(a[i]+k);
	}
	else{
		while(que2.front() <= a[i]){
			rep(j,0,c){
				if(que.empty()){break;}
				else{
					que.pop();
					que2.pop();
				}
			}
			res += 1;
			if(que.empty()){break;}
		}
		que.push(a[i]);
		que2.push(a[i]+k);
	}
	}
	res += que.size()/c + (que.size()%c != 0);
	std::cout << res << '\n';
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

ll dp[101][100001];

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, w;
    cin >> n >> w;

    vector<ll> weight(n), value(n);

    rep(i, n){
        cin >> weight[i] >> value[i];
    }

    for(int i = 0; i <= w; ++i){
        dp[0][i] = 0;
    }

    for(int i = 0; i < n; ++i){
        for(int j = 0; j <= w; ++j){
            if(j >= weight[i])
                dp[i+1][j] = max(dp[i][j-weight[i]]+value[i], dp[i][j]);
            else
                dp[i+1][j] = dp[i][j];
        }
    }

    ppp(dp[n][w]);
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

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

int main(){
	int n;cin>>n;
	vi a(n);
	rep(i,n){
		cin>>a[i];
	}
	sort(all(a));
	int cnt=1,trg=a[0],ans=0;
	for(int i=1;i<n;++i){
		if(a[i]==trg){
			cnt++;
		}
		else{
			if(trg<=cnt){
				ans+=cnt-trg;
			}
			else{
				ans+=cnt;
			}
			trg=a[i];
			cnt=1;
		}
	}
    if(trg<=cnt){
		ans+=cnt-trg;
    }
	else{
		ans+=cnt;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = ~~arg[0];
    const K = ~~arg[1];
    const X = arg[2].split(" ");
    
    let answer = 0;
    
    for(let i in X) {
        let temp = Math.min(X[i], K - X[i]);
        answer += temp;
    }

    console.log(answer * 2);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7628
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007


inline int floormod(int a, int mod) {
  if (a > 0) return (a % mod);
  else if (a % mod == 0 ) return 0;
  else return (a % mod) + mod;
}

inline int modpow(int a, int n, int mod) {
  if (a == 0) return 0;
  int res = 1;
  while (n > 0) {
    if (n & 1) res = floormod(res * a , mod);
    a = floormod(a * a , mod);
    n >>= 1;
  }
  return res;
}

int modinv(int a, int mod) {
  return modpow(a, mod - 2, mod);
}

const int MAX = 3100;
int fac[MAX], finv[MAX], inv[MAX];
inline void COMinit(int mod) {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % mod;
    inv[i] = mod - inv[mod % i] * (mod / i) % mod;
    finv[i] = finv[i - 1] * inv[i] % mod;
  }
}
inline int COM(int n, int k, int mod) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}


int main() {
  int p;
  cin >> p;
  COMinit(p);
  vi a(3005, 0);
  rep(i, p) cin >> a[i];

  vi b(3005, 0);
  b[0] = a[0];
  b[p - 1] = (p - 1) * a[0];

  for (int i = 1; i < p; i++) {
    if (a[i] == 0) continue;
    for (int j = 1; j < p; j++) {
      int c = floormod(COM(p - 1, j, p) * modpow(-i, p - 1 - j, p), p);
      b[j] = floormod(b[j] - c, p);
    }
  }

  rep(i, p) cout << b[i] << " ";
  cout << endl;


}





Measured memory_bytes: 384
import heapq
def main():
    X, Y, A, B, C = (int(_) for _ in input().split())
    p = sorted([int(_) for _ in input().split()])[::-1]
    q = sorted([int(_) for _ in input().split()])[::-1]
    r = sorted([int(_) for _ in input().split()])[::-1]
    output = 0
    apple = list()
    heapq.heapify(apple)
    for i in range(X):
        heapq.heappush(apple, p[i])
        output += p[i]
    for i in range(Y):
        heapq.heappush(apple, q[i])
        output += q[i]
    i = 0
    while i < C:
        x = heapq.heappop(apple)
        if x < r[i]:
            heapq.heappush(apple, r[i])
            output = output - x + r[i]
            i += 1
        else: break

    print(output)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 22592
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

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

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

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

	ll N; cin >> N;
	vector<ll> A(N), B(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
	}

	const ll INF = 1000000001LL;
	if (N % 2 == 1) {
		ll L = 0, R = INF;
		while (R - L > 1) {
			ll c = (L + R) / 2;
			int count = 0;
			for (int i = 0; i < N; i++) {
				if (B[i] >= c) { count++; }
			}
			if (count >= (N / 2 + 1)) {
				L = c;
			}
			else {
				R = c;
			}
		}
		ll ans1 = L;
		L = 0, R = INF;
		while (R - L > 1) {
			ll c = (L + R) / 2;
			int count = 0;
			for (int i = 0; i < N; i++) {
				if (A[i] <= c) { count++; }
			}
			if (count >= (N / 2 + 1)) {
				R = c;
			}
			else {
				L = c;
			}
		}
		ll ans0 = R;
		cout << ans1 - ans0 + 1 << endl;
	}
	else {
		ll L = 0, R = INF;
		while (R - L > 1) {
			ll c = (L + R) / 2;
			int count = 0;
			for (int i = 0; i < N; i++) {
				if (B[i] >= c) { count++; }
			}
			if (count >= N / 2) {
				L = c;
			}
			else {
				R = c;
			}
		}
		ll ans11 = L;
		L = 0, R = INF;
		while (R - L > 1) {
			ll c = (L + R) / 2;
			int count = 0;
			for (int i = 0; i < N; i++) {
				if (B[i] >= c) { count++; }
			}
			if (count >= N / 2 + 1) {
				L = c;
			}
			else {
				R = c;
			}
		}
		ll ans10 = L;

		L = 0, R = INF;
		while (R - L > 1) {
			ll c = (L + R) / 2;
			int count = 0;
			for (int i = 0; i < N; i++) {
				if (A[i] <= c) { count++; }
			}
			if (count >= N / 2) {
				R = c;
			}
			else {
				L = c;
			}
		}
		ll ans00 = R;
		L = 0, R = INF;
		while (R - L > 1) {
			ll c = (L + R) / 2;
			int count = 0;
			for (int i = 0; i < N; i++) {
				if (A[i] <= c) { count++; }
			}
			if (count >= N / 2 + 1) {
				R = c;
			}
			else {
				L = c;
			}
		}
		ll ans01 = R;

		cout << ans10 + ans11 - ans00 - ans01 + 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 5884
N, x = map(int, input().split())
if x == 1 or x == 2 * N - 1:
  print("No")
else:
  print("Yes")
  if N == 2:
    li = [1,2,3]
  else:
    s = set([i for i in range(1, 2 * N)])
    li = [0] * (2 * N - 1)
    if x == 2:
      li[N - 2] = x + 1
      li[N - 1] = x 
      li[N] = x - 1
      li[N + 1] = x + 2
      s -= set([x-1, x, x+1, x+2])
    else:
      li[N - 2] = x - 1
      li[N - 1] = x 
      li[N] = x + 1
      li[N + 1] = x - 2
      s -= set([x-2, x-1, x, x+1])
    for i in range(2 * N - 1):
      if li[i] == 0:
        li[i] = s.pop()
  for i in li:
    print(i)

Measured memory_bytes: 23336
#include <bits/stdc++.h>
using namespace std;
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v){
  const char* dlm = "";
  for(const auto& x:v) cout << exchange(dlm, ",") << x;
  return os;
}
struct UnionFind{
  using val_t=size_t;
  vector<val_t> par;
  UnionFind(val_t n): par(n){
    for(val_t i=0; i<n; ++i) par[i]=i;
  }
  val_t root(val_t x){
    if(par[x]==x) return x;
    par[x]=root(par[x]);
    return par[x];
  }
  void unite(val_t x, val_t y){
    val_t rx=root(x), ry=root(y);
    if(rx!=ry) par[rx]=ry;
  }
  bool same(val_t x, val_t y){
    return root(x)==root(y);
  }
};
int32_t main(){
  size_t n,m; cin>>n>>m;
  vector<size_t> p(n+1);
  for(size_t i=1; i<n+1; ++i) cin>>p[i];
  UnionFind tree(n+1);
  for(size_t i=0; i<m; ++i){
    size_t x,y; cin>>x>>y;
    tree.unite(p[x],p[y]);
  }
  size_t ans=0;
  for(size_t i=1; i<n+1; ++i){
    if(tree.same(i,p[i])) ++ans;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
	int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n;
	scanf("%d",&n);
	printf("%d",a[n-1]);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;


// https://atcoder.jp/contests/abc150/tasks/abc150_a

int main() {
    int K, X;
    cin >> K >> X;
    if (K * 500 < X) {
        cout << "No";
    }
    else {
        cout << "Yes";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int n, ans, f[N];
int main() {
    scanf("%d", &n);
    for(int i = 0, mod = 0;; ++i) {
        mod = (mod * 10 + 7) % n;
        if(!mod) {
            cout << i + 1 << endl;
            return 0;
        }
        if(f[mod]) {
            cout << "-1\n";
            return 0;
        }
        f[mod] = 1;
    }
}

Measured memory_bytes: 7508
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

n = lines[0][0]
a = lines[1]

def binom(n)
  return n * (n-1) / 2
end

num = []
for i in 1..n do
  num[i-1] = 0
end
for i in 1..n do
  num[a[i-1]-1] += 1
end
num_binom = []
naive_answer = 0
for i in 1..n do
  num_binom[i-1] = binom(num[i-1])
  naive_answer += num_binom[i-1]
end

for k in 1..n do
  num_new = num[a[k-1]-1] - 1
  new_binom = binom(num_new)
  puts naive_answer - num_binom[a[k-1]-1] + new_binom
end

Measured memory_bytes: 26196
# -*- coding: utf-8 -*-
from decimal import Decimal, ROUND_HALF_UP
n = int(input())
l_x = list(map(int, input().split()))
mtg_p = Decimal(str(sum(l_x) / n)).quantize(Decimal('0'), rounding=ROUND_HALF_UP)

print(sum([(x-mtg_p)**2 for x in l_x]))


Measured memory_bytes: 9908
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

int main(){
    int n; cin>>n;
    vector<P> v(n);
    for(int i=0; i<n; i++){
        ll a, b; cin>>a>>b;
        v[i] = P(b, a);
    }

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

    ll sum = 0;
    bool valid = true;
    for(int i=0; i<n; i++){
        //cout << v[i].fs << " " << v[i].sc << endl;
        sum += v[i].sc;
        if(sum <= v[i].fs);
        else valid = false;
    }

    if(!valid){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3328
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);
		//出力
        if(a+b <= b+c){
            if(a+b <= a+c){
                Console.WriteLine(a+b);
            }else{
                Console.WriteLine(a+c);
            }
        }else if(b+c <= a+c){
            Console.WriteLine(b+c);
        }else{
            Console.WriteLine(a+c);
        }
	}
}

Measured memory_bytes: 11092
n=int(input())
s=input()
r=g=b=0
for i in range(n):
    if s[i]=="R":
        r+=1
    elif s[i]=="G":
        g+=1
    else:
        b+=1
ans=r*g*b
sub=0
for i in range(n-2):
    for j in range(i+1,n-1):
        k=j+(j-i)
        if s[i]==s[j]:
            continue
        if k>=n or s[i]==s[k] or s[j]==s[k]:
            continue
        sub+=1
print(ans-sub)

Measured memory_bytes: 67980
#include <bits/stdc++.h>
using namespace std;
#define push_back pb
#define make_pair mp
using ll =  long long;
const int INF = 0x3f3f3f3f;
const int MAX_N = 200;
int N, K;
int V[MAX_N];

// least I have, left, right

void solve()
{
	int ans = 0;
	for(int left=0;left<=N;++left)for(int right=0;right<=N;++right)if(left+right<=K && left+right<=N){
		multiset<int> v;
		for(int i=0;i<left;++i) v.emplace(V[i]);
		for(int i=0;i<right;++i) v.emplace(V[N-1-i]);
		int op = (K-left-right);
		while(op){
		    if(v.empty() || *v.begin()>=0) break;
			v.erase(v.begin());
			op--;
		}
		int sc = 0;
		for(int x : v) sc += x;
		ans = max(ans, sc);
	}
	cout << ans << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N >> K;
	for(int i=0;i<N;++i)cin >> V[i];
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
	int i;
	int dx,dy,x,y,mx,my;
	int n;
	
	scanf("%d ",&n);

	for(i=0;i<n;i++)
		{
			x=0;
			y=0;
			mx = 0;
			my = 0;

			while(1)
				{
					scanf("%d %d ",&dx,&dy);

					if(dx == 0 && dy ==0)break;

					x += dx;
					y += dy;

					if(mx*mx+my*my < x*x+y*y)
						{
							mx = x;
							my = y;
						}
					else if(mx*mx+my*my == x*x+y*y)
						{
							if(mx < x)
								{
									mx = x;
									my = y;
								}
						}	
				}
			printf("%d %d\n",mx,my);
		}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 1000000000000000005
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int main(){
	int n;
	while(~getI(n)) printf("%s\n",n<=999?"ABC":"ABD");
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
string s;
int n;
int main()
{
    cin >> s;
    n = s.size();
    if (s[n - 1] != '0'){
        cout << -1;
        return 0;
    }
    for (int i = 0; n - i - 2 >= 0; i++)
    {
        if (s[i] != s[n - i - 2])
        {
            cout << -1;
            return 0;
        }
    }
    if (s[0] == '0')
    {
        cout << -1;
        return 0;
    }
    int counter = 2;
    int beta = n;
    cout << 1 << " " << 2 << "\n";
    for (int i = 1; beta > counter; i++)
    {
        if (s[i] == '0') {cout << counter << " " << beta << "\n"; beta--;}
        else {cout << counter << " " << counter + 1 << "\n"; counter++;}
    }
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}


int n,k,a[1005],ma,b[1005]={};
int c[1005];
int ans=0;
string s[3]={"Sunny","Cloudy","Rainy"};
string str;
vector<P> v[1005][1005];
int main() {
	cin>>str;
	if(str=="Sunny")cout<<"Cloudy"<<endl;
	if(str=="Cloudy")cout<<"Rainy"<<endl;
	if(str=="Rainy")cout<<"Sunny"<<endl;
	return 0;
}


Measured memory_bytes: 23936
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, y;
    cin >> n >> y;
    REP(i,n+1) {
        if (i*10000 > y) break;
        REP(j,n-i+1) {
            if (i*10000 + j*5000>y) break;
            int k = n-i-j;
            if (i*10000 + j*5000 + k*1000 == y) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }

    OUT("-1 -1 -1")

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if(A == B){
    cout << C << endl;
  }
  else if(A == C){
    cout << B << endl;
  }
  else{
    cout << A << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#define MAX 1000000
using namespace std;
const int infty = 1<<25;
int main()
{
  int allnum = 0;
  static int KAll[MAX];
  static int Answer1[MAX];
  static int Answer2[MAX];

  Answer1[0]=0;
  Answer2[0]=0;

  int n = 1;
  while( true ){
    int t = n*(n+1)*(n+2) / 6;
    if( t >= MAX ) break;
    KAll[allnum++]=t;
    ++n;
  }
  
  for(int i = 1; i < MAX; ++i){
    Answer2[i] = Answer1[i] = infty;
    for(int j = 0; j < allnum && i - KAll[j] >= 0; ++j){
      Answer1[i] = min(Answer1[i], 1+Answer1[i-KAll[j]]);
      if( KAll[j] % 2 == 1 ){
	Answer2[i] = min(Answer2[i], 1+Answer2[i-KAll[j]]);
      }
    }
  }
  
  while(true){
    int N;
    scanf("%d", &N);
    if( N == 0 ) break;
    printf("%d %d\n", Answer1[N], Answer2[N]);
  }
  return 0;
}

Measured memory_bytes: 8524
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let h: usize = s.next().unwrap().parse().unwrap();
	let w: usize = s.next().unwrap().parse().unwrap();

	let mut mp: std::collections::BTreeSet<_> = (1..=w).map(|i| (i, i)).collect();
	let mut mins = std::collections::BTreeMap::new();
	mins.insert(0, w);

	use std::io::Write;
	let out = std::io::stdout();
	let mut out = out.lock();
	for h in 0..h {
		let l: usize = s.next().unwrap().parse().unwrap();
		let r: usize = s.next().unwrap().parse().unwrap();
		let mut max = None;
		while let Some(p) = mp.range((l, 0)..=(r, std::usize::MAX)).next().cloned() {
			if Some(p.1) > max {
				max = Some(p.1);
			}
			let step = p.0 - p.1;
			if let Some(v) = mins.get_mut(&step) {
				*v -= 1;
			}
			mp.remove(&p);
		}
		match max {
			Some(max) if r + 1 <= w => {
				mp.insert((r + 1, max));
				*mins.entry(r + 1 - max).or_insert(0) += 1;
			}
			_ => (),
		}
		let min = loop {
			if let Some((&k, &v)) = mins.iter().next() {
				if v == 0 {
					mins.remove(&k);
				} else {
					break k as i64;
				}
			} else {
				break -1;
			}
		};
		writeln!(out, "{}", if min < 0 { -1 } else { min + (h + 1) as i64 }).unwrap();
	}
}


Measured memory_bytes: 11700