akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=5050;
ll mod_pow(ll x, ll n, ll mod) {
    if(n == 0) return 1;
    ll res = mod_pow((x * x) % mod, n / 2 , mod);
    if(n & 1) res = (res * x) % mod;
    return res;
}
int main() {
	//%MOD下での階乗
	ll ex[SIZE]={1,0};
	for(int i=1;i<SIZE;i++){
		ex[i]=ex[i-1]*i%MOD;
	}
	//%MOD下での階乗の逆数
	ll inv[SIZE]={1,0};
	for(int i=1;i<SIZE;i++){
		inv[i]=mod_pow(i,MOD-2,MOD);
	}
	for(int i=1;i<SIZE;i++){
		inv[i]=inv[i-1]*inv[i]%MOD;
	}


	ll N,K;
	cin>>N>>K;
	ll ans[SIZE]={};
	for(int i=1;i<=K;i++){

		ll temp=0;
		ll red=N-K;
		if(red<i-1){
			ans[i]=0;
			continue;
		}
		//入れる隙間を決める
		temp=ex[K-1]*inv[i-1]%MOD*inv[K-i]%MOD;
		//最初に1つずつ分配
		red-=i-1;
		//スキマに入れる数を決める
		ll oral=ex[i+red]*inv[red]%MOD*inv[i]%MOD;
		//cout<<"!"<<i<<" "<<temp<<" "<<oral<<endl;
		if(red==0)
			oral=1;
		ans[i]=temp*oral%MOD;
	}
	for(int i=1;i<=K;i++)
		cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  int cnt = 0;
  bool flg = false;
  rep(i,N){
    int a, b;
    cin >> a >> b;

    if(a==b){
      cnt++;
    }else{
      cnt = 0;
    }
    if(cnt == 3){
      flg = true;
    }
  }

  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	vector<long long>e;
	int n;
	while (cin >> n) {
		if (n == 0)break;
		vector<long long>l;
		for (int i = 0; i < n; i++) {
			long long a; cin >> a;
			l.push_back(a);
		}
		sort(l.begin(), l.end());
		long long num = l[1] - l[0];
		for (int i = 1; i < n - 1; i++)
			num = min(num, l[i + 1] - l[i]);
		e.push_back(num);
	}
	for (long long l : e) 
		cout << l << endl;
	return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define dbg(x) cout << #x << ": " << (x) << '\n'
#define ff first
#define ss second
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

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

   int a, b;
   cin >> a >> b;
   cout << a * b << endl;


   return 0;
}

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

int main()
{
	int n;
	cin >> n;
	int w[n];
	int ptot=0;
	for (int i = 0; i < n; ++i)
	{
		int j;
		cin >> j;
		w[i]=j;
		ptot=ptot+j;
	}
    vector<int> sum(n,-1);
    sum[0]=w[0];
    for (int i = 1; i < n; ++i)
    {
    	sum[i]=sum[i-1]+w[i];
    }
    
    int a=ptot/2;
    int j=0;
    while(sum[j]<=a){
    	j++;
    }
    j--;
    int c1= a-sum[j]; int c2=sum[j+1]-a;
    if (a==sum[j])
    {
    	cout << 0 << "\n";
    } else if (c1<=c2)
    {
    	cout << abs(2*sum[j]-ptot) << "\n";
    }else{
    	cout << abs(2*sum[j+1]-ptot) << "\n";
    }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <cstdio>

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

	int input;
	std::map<int, int> count;
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &input);
		++count[input];
	}
	int eliminated = 0;
	for (auto it : count)
	{
		eliminated += it.second - 1;
	}
	if (eliminated & 1)
		++eliminated;
	std::cout << n - eliminated << std::endl;

	return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>

int main(void)
{
int W, H, x, y, r;
scanf("%d %d %d %d %d\n", &W, &H, &x, &y, &r);
if(x >= r && x <= W-r && y >= r && y <= H-r){
printf("Yes\n");
} else {
printf("No\n");
}

return 0;
}

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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}

int main()
{
    int N, K; cin >> N >> K;
    string S; cin >> S;

    vector<pair<char, int>> v;
    char ch = S[0];
    int cnt = 1;
    rep1(i, N) {
        if (ch == S[i]) {
            cnt++;
        } else {
            v.push_back(make_pair(ch, cnt));
            ch = S[i];
            cnt = 1;
        }
    }
    v.push_back(make_pair(ch, cnt));

    vector<int> s(v.size());
    s[0] = v[0].second;
    rep1(i, v.size()) s[i] = s[i-1] + v[i].second;

    int ans = 0;
    int l = 0, r;
    while (1) {
        r = min((int)v.size()-1, l + (v[l].first=='0'? 2*K-1:2*K));
        int sum = s[r] - (l > 0 ? s[l-1] : 0);
        chmax(ans, sum);
        if (r == v.size()-1) break;
        l++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 1652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,h;cin >> n >> h;
	vector<int> a(n);
	vector<int> b(n);
	rep(i,n) cin >> a.at(i) >> b.at(i);
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	reverse(b.begin(),b.end());
	int ans=0;
	rep(i,n){
		if(b.at(i)<=a.at(n-1)) break;
		h-=b.at(i);
		ans++;
		if(h<=0){
			cout << ans << endl;
			return 0;
		}
	}
	ans+=(h+a.at(n-1)-1)/a.at(n-1);
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

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

void Main() {
    f64 a, b, x;
    cin >> a >> b >> x;
    f64 max_v = a * a * b;
    f64 rad;
    if (a * a * b / 2.0 >= x) {
        rad = atan(a * b * b / (2.0 * x));
    } else {
        rad = atan(2.0 * (max_v - x) / (a * a * a));
    }
    cout << rad / PI * 180.0<< endl;

}


Measured memory_bytes: 4056
n, k = map(int, input().split())
a = [int(x) for x in input().split()]

for i in range(min(k, 450)):
    tmp = [0] * (n + 1)
    for j in range(n):
        tmp[max(0, j - a[j])] += 1
        tmp[min(n, j + a[j] + 1)] -= 1
    
    cnt = 0
    for j in range(n):
        cnt += tmp[j]
        a[j] = cnt

for i in range(n):
    print(a[i], end=' ')

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll ans = 0, N; cin >> N;
    rep2(i, 1, N + 1){
        if (to_string(i).size() % 2 == 1){ans++;}
    }
    cout << ans << endl;
}

int main() {

    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cstring>
#include <cctype>
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <complex>
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
const double PI = 3.141592653589793238462643383279502884L;
const int LARGE_PRIME = 1000000007;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define repfn(i,a,cont,next) \
  for(auto i = (a); [=](){return(cont);}(); i = [=](){return(next);}())
#define repby(i,a,b,s) repfn(i,a,i<b,i+s)
#define repab(i,a,b) repby(i,a,b,1)
#define rep(i,b) repab(i,0,b)
#define pb push_back
#define sz(c) int((c).size())

int main(int argc, char **argv)
{
  for (;;) {
    int n;
    vi v;

    cin >> n;
    if (!n)
      break;

    while (n--) {
      int tmp;
      cin >> tmp;
      v.pb(tmp);
    }

    vi w(v);
    w.pb(0);
    int prev = 0;
    int accm = -LARGE_PRIME;
    for (int j = 0; j < sz(v); j++) {
      for (int i = 0; i < sz(v); i++) {
        w[i] = max(w[i], v[i] + w[i+1]);
        accm = max(accm, w[i]);
      }
    }
    cout << accm << endl;
  }
  return 0;
}

Measured memory_bytes: 1260
a, b, c, x, y = map(int, input().split())
z = 0
p = 0
if a+b < c*2:
    p = a*x + b*y
else:
    if x > y:
        x -= y
        z = y*2
        y = 0
        if a > c*2:
            z += x*2
            x = 0
    else:
        y -= x
        z = x*2
        x = 0
        if b > c*2:
            z += y*2
            y = 0
            
print(x*a + y*b + z*c)
    

Measured memory_bytes: 3060
#include <cstdio>
constexpr int MOD = 1e9 + 7;
int x[605], y[605], pre[605];
long long dp[605][605], fact[605], ans;
int main()
{
	// freopen("AGC028-D.in", "r", stdin);
	int n, k;
	scanf("%d%d", &n, &k);
	n <<= 1;
	fact[0] = 1;
	for (int i = 2; i <= n; i++)
		fact[i] = fact[i - 2] * (i - 1) % MOD;
	for (int i = 0; i < k; i++)
	{
		scanf("%d%d", x + i, y + i);
		pre[--x[i]] = pre[--y[i]] = 1;
	}
	for (int i = 0; i < n; i++)
		pre[i] = !pre[i] + (i ? pre[i - 1] : 0);
	for (int l = 0; l < n; l++)
	{
		for (int r = l + 2; r <= n; r += 2)
		{
			auto in = [&] (int t) { return l <= t && t < r; };
			int cnt = pre[r - 1] - (l ? pre[l - 1] : 0);
			bool flg = true;
			for (int i = 0; i < k && flg; i++)
				flg &= in(x[i]) == in(y[i]);
			if (!flg || cnt & 1)
				continue;
			dp[l][r] = fact[cnt];
			for (int i = l + 2; i < r; i += 2)
				(dp[l][r] -= dp[l][i] * fact[pre[r - 1] - pre[i - 1]]) %= MOD;
			(ans += dp[l][r] * fact[n - cnt - (k << 1)]) %= MOD;
		}
	}
	printf("%lld\n", (ans + MOD) % MOD);
	return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const ll MOD=1e9+7;
const int MAX=1e5+10;
const ll INF=1e18;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int n,k;
    cin >> n >> k;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    int ans=0;
    rep(i,n) ans+=min(2*x[i],2*(k-x[i]));
    
    cout << ans << endl;

    return 0;   
}

Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <cassert>
#include <ctime>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define all(x) (x).begin(), (x).end()

#ifdef LOCAL
#define dbg(x) cerr << #x " = " << x << endl;
#define idbg(x) #x " = " << x
#include "pretty_print.h"
#else
#define dbg(x)
#define idbg(x) ""
#endif

#ifdef _WIN32
#  define LLD "%I64d"
#else
#  define LLD "%lld"
#endif

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

template <typename T> T sqr(T x) { return x * x; }
template <typename T> T abs(T x) { return x < 0? -x : x; }
template <typename T> T gcd(T a, T b) { return b? gcd(b, a % b) : a; }
template <typename T> bool chmin(T &x, const T& y) { if (x > y) { x = y; return true; } return false; }
template <typename T> bool chmax(T &x, const T& y) { if (x < y) { x = y; return true; } return false; }


int main(int /* argc */, char** /* argv */)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef LOCAL
    assert(freopen("inp", "r", stdin));
    assert(freopen("out", "w", stdout));
    #endif

    string s;
    vector<string> days = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    while (cin >> s) {
        int d = find(all(days), s) - days.begin();
        cout << 7 - d << endl;
    }


    cerr << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#define int long long
using namespace std;

#define fin(i,n) for (int i = 0; i < n; i++)
#define fin2(i,a,b) for (int i = a; i < b; i++)
#define ford(i,n) for (int i = n-1; i >= 0; i--)
#define ford2(i,a,b) for (int i = a-1; i >= b; i--)
 
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define mod 1000000007
#define PI 3.1415926535897932384626
#define EXP1 2.718281828459045
#define BIG 1000000000000000000

#define sl(n) scanf("%lld", &n)
#define sll(n,m) scanf("%lld %lld", &n, &m)
#define slll(n,m,k) scanf("%lld %lld %lld", &n, &m, &k)
#define sllll(n,m,k,o) scanf("%lld %lld %lld %lld", &n, &m, &k, &o)
#define sd(n) scanf("%lf", &n)
#define sdd(n,m) scanf("%lf %lf", &n, &m)
#define sddd(n,m,k) scanf("%lf %lf %lf", &n, &m, &k)
#define sc(c) scanf(" %c", &c)
#define ss(s) scanf("%s", s)
#define sal(t,n) fin(iz,n) { scanf("%lld", &t[iz]); }
#define sad(t,n) fin(iz,n) { scanf("%lf", &t[iz]); }
#define gl(t) scanf(" %[^\n]", t);

#define pc(n) printf("%c\n", n)
#define ps(s) printf("%s\n", s)
#define pss(s) printf("%s\n", s.c_str())
#define pl(n) printf("%lld\n", n)
#define pll(n,m) printf("%lld %lld\n", n, m)
#define plll(n,m,k) printf("%lld %lld %lld\n", n, m, k)
#define pd(n) printf("%lf\n", n)
#define pdd(n,m) printf("%lf %lf\n", n, m)
#define pal(t,n) fin(rz,n) { printf("%lld ", t[rz]); } printf("\n")
#define pad(t,n) fin(rz,n) { printf("%lf ", t[rz]); } printf("\n")

#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
 
#define OK ps("OK")
#define OK1 ps("OK1")
#define OK2 ps("OK2")

#define ll int
#define vl vector<ll>
#define vvl vector<vl>
#define vvvl vector<vvl>

#define dll pair<ll, ll>
#define vdll vector<dll>
#define vvdll vector<vdll>

#define vb vector<bool>
#define vvb vector<vb>
#define vd vector<double>
#define vvd vector<vd>
#define vc vector<char>
#define vvc vector<vc>

#define all(v) v.begin(), v.end()
#define vlen(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second

int a[105];
int dp[105][(int)(1e5) + 5];
int ss[105][(int)(1e5) + 5];
int n, k;

signed main()
{
    sll(n,k);
    sal(a, n);
    dp[n][0] = ss[n][0] = 1;
    ford(i, n) {
        fin(c, k+1) {
            dp[i][c] += (((ss[i+1][max(0LL, c - a[i])] - ss[i+1][c+1])%mod)+mod)%mod;
            dp[i][c] %= mod;
        }
        ford(c, k+1) ss[i][c] = (dp[i][c]+ss[i][c+1])%mod;
    }
    pl(dp[0][k]);
}

Measured memory_bytes: 160000
import Data.Maybe
import qualified Data.ByteString.Char8 as B
main = mapM_ (print . solve) . analyze . map (map readInt . B.words) . B.lines =<< B.getContents
readInt = fst . fromJust . B.readInt
analyze [] = []
analyze ([n]:cs) = as:analyze bs where (as,bs) = splitAt n cs
solve = foldr (\[a,b] c -> ((b-((a+c)`mod`b))`mod`b)+c) 0

Measured memory_bytes: 24060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int i = 1;
		while (true) {
			int x = i;
			if (x % 3 == 0) {
				System.out.print(" "+i);
			} else {
				while (true) {
					if (x % 10 == 3) {
						System.out.print(" "+i);
						break;
					} else {
						x /= 10;
						if (x == 0)
							break;
					}
				}
			}
			if (++i > n) {
				System.out.print("\n");
				break;
			}
		}
	}

}

Measured memory_bytes: 28788
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch ABCSwap | diff ABCSwap.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address ABCSwap.cpp && ./a.out

/*
 
 4/4/2020
 
 5:00-
 
 */

int x,y,z;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>x>>y>>z;
  println("%d %d %d", z,x,y);
  
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, m);

    vvi dp(m+1, vi((1LL << n), INF));
    dp[0][0] = 0;
    rep(i, m) {
        int2(a, b);
        int mask = 0;
        rep(j, b) {
            Int(tmp); tmp--;
            mask += 1LL << tmp;
        }
        //cout << i << " : " << mask << endl;
        rep(j, (1LL << n)) {
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            dp[i+1][j | mask] = min(dp[i+1][j | mask], dp[i][j] + a);
        }
    }
/*
    rep(i, dp.size()) {
        rep(j, dp[i].size()) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    */
    cout << (dp[m][(1LL << n)-1] == INF ? -1 : 
            dp[m][(1LL << n)-1]) << endl;

    return 0;
}



Measured memory_bytes: 32384
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define For(i, a, b) for (i = a; i <= b; i++)
#define Rof(i, a, b) for (i = a; i >= b; i--)
using namespace std;
inline int read() {
	int res = 0; bool bo = 0; char c;
	while (((c = getchar()) < '0' || c > '9') && c != '-');
	if (c == '-') bo = 1; else res = c - 48;
	while ((c = getchar()) >= '0' && c <= '9')
		res = (res << 3) + (res << 1) + (c - 48);
	return bo ? ~res + 1 : res;
}
typedef long long ll; const int N = 5005;
int n, K, a[N]; bool f[N]; ll sum;
int main() {
	int i, j; n = read(); K = read(); For (i, 1, n) sum += (a[i] = read());
	f[0] = 1; sort(a + 1, a + n + 1); Rof (i, n, 1) {
		int l = max(-sum + K, 0ll), r = K - 1; bool orz = 0;
		For (j, l, r) if (f[j]) {orz = 1; break;}
		if (!orz) return printf("%d\n", i), 0;
		sum -= a[i]; Rof (j, K, a[i]) f[j] |= f[j - a[i]];
	}
	puts("0"); return 0;
}

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


def solve(N: int, M: int):
    print(((N-M)*100+M*1900)*(2**M))
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
from collections import deque

S = input()
Q = int(input())
d = deque()
for i in S:
    d.append(i)
flag = True
for _ in range(Q):
    q = [i for i in input().split()]
    if int(q[0]) == 1:
        flag = not flag
    else:
        if (int(q[1]) == 1 and flag) or (int(q[1]) == 2 and not flag):
            d.appendleft(q[2])
        else:
            d.append(q[2])
S = ""
while(len(d)>0):
    if flag:
        S += d.popleft()
    else:
        S += d.pop()
print(S)

Measured memory_bytes: 6412
#include <stdio.h>
#include <algorithm>

using namespace std;

int main() {
	int n, a[200010], b[200010];
	bool ada = false;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		b[i] = a[i];
	}
	sort(a, a + n);
	if (a[n - 1] == a[n - 2])
		ada = true;
	for (int i = 0; i < n; i++) {
		if ((b[i] == a[n - 1]) && (!ada))
			printf("%d\n", a[n - 2]);
		else
			printf("%d\n", a[n - 1]);
	}
	return 0;
}

Measured memory_bytes: 3072
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

int main() {
    SS(string,s)
    Yes(s[2]==s[3]&&s[4]==s[5]);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> P;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<string,int>> vpsi;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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 int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



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

int n,k;
cin >> n >> k;
int p;
int temp=0;
vi sum(n+1,0);
rrep(i,n){
    cin >> p;
    p++;
    sum[i] = sum[i-1] + p;
}
for(int i=k;i<=n;++i){
    chmax(temp,sum[i]-sum[i-k]);
}
printf("%.10lf",(double)temp/2.0);

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 1024
/*
Hanit Banga
*/

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <map>
#include <set>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false)

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

const int N = 2e5 + 5, mod = 1e9 + 7;

pll a[N];
ll fact[N], factInv[N];
vector <int> g[N];
bool seen[N] = {0};

void add_edges(int i, int n, ll y);
void add_edge(int i, int j);
ll bfs(int cur, ll ans);
ll fastModExp(ll x, ll e);

int main()
{
	int n; ll x, y;
	cin >> n >> x >> y;
	for (int i = 1; i <= n; ++i)
		cin >> a[i].first >> a[i].second;

	sort(a + 1, a + 1 + n);
	int cur = 1, m1 = 1, m2 = 1;
	for (int i = 2; i <= n; ++i)
	{
		if (a[i].first == a[cur].first)
		{
			if (a[i].second + a[cur].second <= x)
				add_edge(i, cur);
		}

		else
		{
			cur = i;
			if (a[i].second < a[m1].second)
			{
				m2 = m1;
				m1 = i;
			}

			else if (a[i].second < a[m2].second or m1 == m2)
			{
				m2 = i;
			}
		}
	}

	add_edges(m1, n, y);
	add_edges(m2, n, y);
	fact[0] = factInv[0] = 1;
	for (int i = 1; i < N; ++i)
	{
		fact[i] = (i * fact[i - 1]) % mod;
		factInv[i] = fastModExp(fact[i], mod - 2);
	}

	ll ans = 1;
	for (int i = 1; i <= n; ++i)
		if (!seen[i])
			ans = bfs(i, ans);

	cout << ans << endl;
}

void add_edges(int i, int n, ll y)
{
	for (int j = 1; j <= n; ++j)
		if ((a[i].first != a[j].first) and (a[i].second + a[j].second <= y))
			add_edge(i, j);
}

void add_edge(int i, int j)
{
	g[i].pb(j);
	g[j].pb(i);
}

ll bfs(int cur, ll ans)
{
	map <int, int> m;
	seen[cur] = true;
	queue <int> q;
	q.push(cur);
	int ctr = 0;
	while (!q.empty())
	{
		int x = q.front();
		q.pop();
		++m[a[x].first];
		++ctr;
		for (auto &i : g[x])
		{
			if (!seen[i])
			{
				q.push(i);
				seen[i] = true;
			}
		}
	}

	ans = (ans * fact[ctr]) % mod;
	for (auto &i : m)
		ans = (ans * factInv[i.second]) % mod;
	
	return ans;
}

ll fastModExp(ll x, ll e)
{
	ll res = 1;
	while (e)
	{
		if (e % 2)
			res = (res * x) % mod;

		e /= 2;
		x = (x * x) % mod;
	}

	return res;
}

Measured memory_bytes: 24240
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor

import heapq
import itertools
import operator


def get_int():
    return int(input())


def get_str():
    return input().strip()


def get_int_list():
    return [int(i) for i in input().split()]


def get_char_list():
    return list(input().strip())


def f(n):
    if n % 2 == 0:
        return n // 2
    return 3 * n + 1


def main():
    s = get_int()
    a_set = {s}
    a = f(s)
    for i in itertools.count(2):
        if a in a_set:
            print(i)
            return
        a_set.add(a)
        a = f(a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38512
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    [n, k] <- map strToInt . words <$> getLine
    l <- getLine
    let likes = ['0'..'9'] \\ l
    -- 出力
    putStrLn $ solve likes n

solve :: String -> Int -> String
solve likes n = if and (map (`elem` likes) strn) then strn else solve likes (n+1)
    where strn = show n


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

int main() {
    int n;
    cin >> n;
    vector<int> arr(n);

    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }

    arr[0]--;
    for (int i = 1; i < n; i++) {
        if (arr[i] < arr[i - 1]) {
            cout << "No" << endl;
            return 0;
        }
        arr[i] = max(arr[i - 1], arr[i] - 1);
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
  int a, b, c;
  int zero;
  int cnt = 0;
  int i;

  scanf("%d %d %d", &a, &b, &c);

  for(i = a;i <= b;i++){
    zero = c % i;
    if(zero == 0){
      cnt++;
    }
  }

  printf("%d\n", cnt);

  return 0;
}

Measured memory_bytes: 596
li = []

while True:
    i,j = map(int,input().split())
    if i == 0 and j == 0:
        break
    li.append((i,j))

for l,m in li:
    point = 0
    for i in range(1,l-1):
        for j in range(i+1,l):
            for k in range(j+1,l+1):
                if i+j+k == m:
                    point += 1
    print(point)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i) 
#endif

#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());

using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int EPS = 1e-9;
const int MOD = 1e9+7;

struct Point{
public:
  int x;
  int y;
  Point(){}
  Point(int _x,int _y){
    x = _x;
    y = _y;
  }
  bool operator<( const Point& p ) const {
        return x < p.x;
  }
};
  
struct RPoint{
public:
  int x;
  int y;
  RPoint(){}
  RPoint(int _x,int _y){
    x = _x; //赤⇛奇数　青⇛偶数
    y = _y;
  }
  bool operator<( const RPoint& p ) const {
    return y > p.y;//降順に並んで欲しい
  }
};

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<Point> P;
  vector<RPoint> R;
  REP(i,n){
    int a,b;
    cin >> a >> b;
    P.push_back(Point(a*2+1,b));
  }
  REP(i,n){
    int c,d;
    cin >> c >> d;
    P.push_back(Point(c*2,d));
  }

  sort(ALL(P));
  int ans = 0;
  REP(i,n*2){
    if(P[i].x % 2 == 1){//赤
      R.push_back(RPoint(P[i].x,P[i].y));
      sort(ALL(R));
    }else{//青
      REP(j,SZ(R)){
	if(R[j].y < P[i].y){
	  ans++;
	  R.erase(R.begin() + j);
	  break;
	}
      }
    }
  }
  cout << ans << endl;
  return 0;
}



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

int main() {
	int A, B;
	cin >> A >> B;
	int G;
	G = A + B;
	if (A % 3 == 0 || B % 3 == 0 || G % 3 == 0)
	{
		cout << "Possible" << endl;
	}
	else
	{
		cout << "Impossible" << endl;
	}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N,W;cin>>N>>W;
    vector<int> w(N),v(N);
    REP(i,N) cin>>w[i]>>v[i];
    int w1=w[0];
    REP(i,N) w[i]-=w1;
    vector<vector<vector<int>>> dp(N+1,vector<vector<int>>(N+1,vector<int>(3*N+1)));
    REP(i,N) REP(j,N) REP(k,3*N+1){
        dp[i+1][j+1][k]=dp[i][j+1][k];
        if(k>=w[i]) dp[i+1][j+1][k]=max(dp[i+1][j+1][k],dp[i][j][k-w[i]]+v[i]);
    }
    int ans=0;
    REP(i,N+1) REP(j,3*N+1){
        if((ll)w1*i+j<=W) ans=max(ans,dp[N][i][j]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 12800
//#pragma GCC optimize ("-O3","unroll-loops")
// #pragma GCC target("avx")
#include<bits/stdc++.h>
 
using namespace std;
 
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
 
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9+7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;

void solve() {
	string S;cin>>S;
	int N=S.size();
	int cnt =0;
	REP(i,N){
		if(S[i]!=S[N-1-i]){
			S[i]=S[N-1-i];
			cnt++;
		}
	}
	print(cnt);
}
 
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;
    VEC(int) P(N), Q(N);
    READVEC(P);
    READVEC(Q);

    VEC(int) Perm(N);
    FOR(i, 0, N)
        Perm[i] = i + 1;

    int a = 0, b = 0, i = 0;
    do {
        if (Perm == P)
            a = i;
        if (Perm == Q)
            b = i;
        i++;
    } while (next_permutation(ALL(Perm)));

    cout << abs(a - b) << endl;
    return 0;
};

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

int N,A,B,C;
vector<int> l(8);
int ans = 1e9;

void dfs(int a, int b, int c, int d, int i){
  if(i == N){
    if(a && b && c){
      int m = i-d-3;
      int res = abs(a-A) + abs(b-B) + abs(c-C) + 10*m;
      ans = min(ans,res);
    }
    return;
  }
  dfs(a+l[i],b,c,d,i+1);
  dfs(a,b+l[i],c,d,i+1);
  dfs(a,b,c+l[i],d,i+1);
  dfs(a,b,c,d+1,i+1);
}

int main(){
  cin>>N>>A>>B>>C;
  for(int i=0;i<N;i++) cin>>l[i];
  dfs(0,0,0,0,0);
  cout<<ans<<endl;
  return 0;
}


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

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

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

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

int main()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

    LL n, k;
    cin >> n >> k;

    LL ans = 0;
    for(LL i = 1; i <= n; i++){
        LL x;
        cin >> x;

        ans += 2 * min(x, k - x);
    }

    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr ll INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld PI = acos(-1);
constexpr ld EPS = 1e-11;

int main(void){
	ll h, w;
	cin >> h >> w;

	if(h == 1 || w == 1){
		co(1);
		return 0;
	}

	ll ans = h * w / 2;
	if(h % 2 && w % 2) ans++;
	co(ans);

	return 0;
}


Measured memory_bytes: 256
n,k=gets.split.map(&:to_i)
h=Array.new(n,0)
n.times do |i|
    h[i]=gets.to_i
end

h.sort!
ans=h.max-h.min
0.upto(n-k) do |i|
    ans=[ans,h[i+k-1]-h[i]].min
end
puts ans


Measured memory_bytes: 15928
import java.util.*;

public class Main{
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      
      int n = Integer.parseInt(sc.next());
      int m = Integer.parseInt(sc.next());
      
      PriorityQueue<Long> q = new PriorityQueue<>(Collections.reverseOrder());
      for(int i=0; i<n; i++){
      	q.add(Long.parseLong(sc.next()));
      }
      
      for(int i=0; i<m; i++){
        long tmp = q.poll();
        q.add(tmp/2);
      }
      
      long ans = 0;
      while(!q.isEmpty()){
        ans += q.poll();
      }
      
      System.out.println(ans);
    }
}

Measured memory_bytes: 47696
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    ll l, r;
    cin >> l >> r;
    ll ans = INF;
    for(ll i = l; i <= r; i++){
        for(ll j = i + 1; j <= r; j++){
            if((i * j) % 2019 == 0){
                cout << 0 << endl;
                return 0;
            }
            ans = min(ans, (i * j) % 2019);
        }
    }
    cout << ans << endl;
}   

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

using namespace std;

using ll = long long;

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

    int n, k;
    cin >> n >> k;

    vector<int> h(n);
    for (auto &&x : h) cin >> x;

    vector<int> dp(n, INT_MAX);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 1; j <= k && i + j < n; ++j)
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
    }

    cout << dp[n - 1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<map>

using namespace std;

int main(){
	map<string,int> day;
	string S;
	cin >> S;
	day["SUN"]=0;
	day["MON"]=1;
	day["TUE"]=2;
	day["WED"]=3;
	day["THU"]=4;
	day["FRI"]=5;
	day["SAT"]=6;

	cout << 7-day.at(S) << endl;

}


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

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n, a, b = map(int, input().split())
x = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
    ans += min(b, a * (x[i + 1] - x[i]))
print(ans)


Measured memory_bytes: 19828
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << x << endl;
#define printv(x) for(int i = 0; i < x.size(); i++){ cout << (x[i]) << " "; } cout << endl; 
#define printa(x) for(int i = 0; i < (sizeof(x)/sizeof(x[0])); i++){ cout << (x[i]) << " ";} cout << endl;

typedef long long ll;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,C;
    cin >> N >> C;
    int D[31][31] = {0};
    rep(i,0,C){
        rep(j,0,C){
            int tmp;
            cin >> tmp;
            D[i][j] = tmp;
        }
    }
    int c[501][501] = {0};
    rep(i,0,N){
        rep(j,0,N){
            int tmp;
            cin >> tmp;
            c[i][j] = tmp;
        }
    }

    int col[3][31] = {0};
    rep(i,0,N){
        rep(j,0,N){
            col[(i+j)%3][c[i][j]] += 1;
        }
    }
    ll ans = 1<<30;
    rep(i,1,C+1){
        rep(j,1,C+1){
            rep(k,1,C+1){
                if(i != j && j != k && k != i){
                    ll tt = 0;
                    rep(l,1,C+1){
                        tt += col[0][l] * D[l-1][i-1];
                        tt += col[1][l] * D[l-1][j-1];
                        tt += col[2][l] * D[l-1][k-1];
                    }
                    ans = min(ans, tt);
                }
            }
        }
    }
    print(ans);






}


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

int main(){
  string S;
  cin >> S;
  int s=S.size();
  int a=0,b=0,c=0;
  for(int i=0;i<s;i++){
    if(S[i]=='a')a++;
    if(S[i]=='b')b++;
    if(S[i]=='c')c++;
  }
  string ans="NO";
  if(s%3==0){
    if(a==b && b==c){ans="YES";}
  }
  else if(s%3==1){
    int m=min({a,b,c});
    if(a+b+c-3*m==1){ans="YES";}
  }
  else{
    int M=max({a,b,c});
    if(3*M-a-b-c==1){ans="YES";}
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;

int main()
{
	ios::sync_with_stdio(false);

	int n, x;
	cin >> n >> x;
	if (x == 1 || x == 2 * n - 1)
	{
		cout << "No\n";
		return 0;
	}
	cout << "Yes\n";
	if (n == 2)
	{
		cout << "1\n2\n3\n";
		return 0;
	}
	if (x == 2 * n - 2)
	{	
		for (int i=0; i<n-3; i++)
			cout << i + 3 << "\n";
		cout << 1 << "\n" << 2 * n - 1 << "\n" << x << "\n" << 2 << "\n";
		for (int i=0; i<n-2; i++)
			cout << i + n << "\n";
	}
	else
	{
		vector<int> v;
		for (int i=2; i<2*n-2; i++)
			if (x != i)
				v.push_back(i);
		for (int i=0; i<n-3; i++)
			cout << v[i] << "\n";
		cout << 2 * n - 1 << "\n" << x << "\n" << 1 << "\n" << 2 * n - 2 << "\n";
		for (int i=0; i<n-2; i++)
			cout << v[i+n-3] << "\n";
	}
	  

	return 0;
}

Measured memory_bytes: 2420
n, x, m = map(int, input().split())
arr = [x]
mod = x
memo = [-1 for _ in range(m+1)]

ans = 0
for i in range(1, n):
    mod = mod ** 2 % m
    idx = memo[mod]

    if idx != -1:
        a = i - idx
        q, _mod = divmod((n - idx), a)

        ans = sum(arr[0:idx]) + q * sum(arr[idx:idx+a]) + sum(arr[idx:idx+_mod])
        break
    arr.append(mod)
    memo[mod] = i

if ans == 0:
    ans = sum(arr)

print(ans)

Measured memory_bytes: 13600