akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N, M;
	int ans = 0;
	
	cin>>N>>M;
	
	ans = N * (N - 1) / 2;
	
	ans += M * (M - 1) / 2;
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
 
int main(){
 
 ll n,c;
 
 cin >> n >> c;
 
 ll x[100010],v[100010];
 v[0] = 0; 
 x[0] = 0;
 
 
 for(ll i = 1; i <= n; i++) {
 cin >> x[i] >> v[i];
 }
 
ll s[100010];  // 累積和、正方向でi番目までの寿司を食べたときの累積カロリー
s[0] = 0;
ll ans = 0;
 for(ll i = 0; i < n; i++){
 s[i+1] = s[i] + v[i+1];
ans = max(ans, s[i+1]-x[i+1]);
  }
 
ll pmax[100010],nmax[100010]; // 
 pmax[0] = 0; nmax[0] = 0;
 for(ll i = 0; i < n; i++){
 if(s[pmax[i]] - x[pmax[i]] < s[i+1] - x[i+1]) pmax[i+1] = i+1;
 else                                                         pmax[i+1] = pmax[i];
 if(s[nmax[i]] - x[nmax[i]]*2 < s[i+1] - x[i+1]*2) nmax[i+1] = i+1;
 else                                                         nmax[i+1] = nmax[i];
  }
 
 
 for(ll i = n; i > 0; i--){
ans = max(ans, s[pmax[i-1]] + (s[n] - s[i-1]) - (x[pmax[i-1]] + (c-x[i])*2));
ans = max(ans, s[nmax[i-1]] + (s[n] - s[i-1]) - (x[nmax[i-1]]*2 + (c-x[i])));
 }
 
 cout << ans << endl;
 
 return 0;
}

Measured memory_bytes: 4096
#include <stdio.h>

int main(void) {
  int i,j,a[3][3];
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      scanf("%d",&a[i][j]);
    }
  }
  int n,k,b[10],bingo=0;
  scanf("%d",&n);
  for(k=0;k<n;k++){
    scanf("%d",&b[k]);
    for(i=0;i<3;i++){
      for(j=0;j<3;j++){
        if(a[i][j]==b[k]){
          a[i][j]=0;
        }
      }
    } 
  }
  if(a[0][0]==0&&a[0][1]==0&&a[0][2]==0){
    bingo=1;
  }
  if(a[1][0]==0&&a[1][1]==0&&a[1][2]==0){
    bingo=1;
  }
  if(a[2][0]==0&&a[2][1]==0&&a[2][2]==0){
    bingo=1;
  }
  if(a[0][0]==0&&a[1][0]==0&&a[2][0]==0){
    bingo=1;
  }
  if(a[0][1]==0&&a[1][1]==0&&a[2][1]==0){
    bingo=1;
  }
  if(a[0][2]==0&&a[1][2]==0&&a[2][2]==0){
    bingo=1;
  }
  if(a[0][0]==0&&a[1][1]==0&&a[2][2]==0){
    bingo=1;
  }
  if(a[2][0]==0&&a[1][1]==0&&a[0][2]==0){
    bingo=1;
  }
  if(bingo==1){
    printf("Yes");
  }
  else printf("No");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int allE = count(s.begin(), s.end(), 'E');
    vector<int> a(n+1, 0);
    for(int i = 0; i < n; i++) {
        a[i+1] = a[i] + (s[i]=='E');
    }
    int ans = INF;
    for(int i = 0; i <= n; i++) {
        int now = (i - a[i]) + (allE - a[i]);
        chmin(ans, now);
    }
    cout << ans << endl;

}

Measured memory_bytes: 1796
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    string s1,s2;
    cin >> s1 >>s2;
    char a1[s1.size()],a2[s2.size()];
    ll i;
    for(i=0;i<s1.size();i++)a1[i]=s1[i];
    for(i=0;i<s2.size();i++)a2[i]=s2[i];
    sort(a1,a1+s1.size());
    sort(a2,a2+s2.size());
    for(i=0;i<s1.size();i++)s1[i]=a1[i];
    for(i=0;i<s2.size();i++)s2[s2.size()-i-1]=a2[i];
    if(s1<s2)cout << "Yes";else cout << "No";
    return 0;
}


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

//https://atcoder.jp/contests/abc068/tasks/arc079_b

const int n = 50;
long long k, a[n];

int main() {
	cin >> k;
	long long m = (k + 49) / 50;
	fill(a, a + n, m + 49);
	m = m * 50 - k;
	for (int i = 0; i < m; i++)
		for (int j = 0; j < n; j++)
			a[j] += (j == i ? -n : 1);
	cout << n << endl;
	for (int i = 0; i < n; i++)
		cout << a[i] << (i < n - 1 ? " " : "\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

bool check(string &s)
{
	int bal = 0;
	for (char c : s)
	{
		if (c == '(')
			bal++;
		else
			bal--;
		if (bal < 0)
			return false;
	}
	return (bal == 0);
}

void solve()
{
	int n;
	cin >> n;
	vector<pair<int, string>> arr1, arr2;
	for (int i = 0; i < n; i++)
	{
		string temp;
		cin >> temp;
		int tmp1 = 0, tmp2 = 0;
		int bal = 0;
		for (char c : temp)
		{
			if (c == ')')
				bal++;
			else
				bal--;
			tmp1 = max(tmp1, bal);
		}
		int m = temp.length();
		bal = 0;
		for (int i = m - 1; i >= 0; i--)
		{
			char c = temp[i];
			if (c == '(')
				bal++;
			else
				bal--;
			tmp2 = max(tmp2, bal);
		}
		if (tmp1 <= tmp2)
			arr1.push_back({tmp1, temp});
		else
			arr2.push_back({tmp2, temp});
	}
	sort(arr1.begin(), arr1.end());
	sort(arr2.rbegin(), arr2.rend());
	string res = "";
	for (auto s : arr1)
		res += s.se;
	for (auto s : arr2)
		res += s.se;
	cout << (check(res) ? "Yes" : "No") << ln;
	return;
}

int main()
{
#ifndef LOCAL
	FASTIO;
#endif
	int t = 1;
#ifdef LOCAL
	clock_t start, stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for (int tc = 1; tc < t + 1; tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve();
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 45112
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin>>s;
  sort(s.begin(),s.end());
  if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3]) {
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
namespace IO
{
	template <typename T> inline void read(T &x)
	{
		int f = 1; x = 0; char c = getchar();
		for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
		for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
		x *= f;
	}

	template <typename T> inline void chkmax(T &x, T y) { x = x > y ? x : y; }
	template <typename T> inline void chkmin(T &x, T y) { x = x < y ? x : y; }

	template <typename T> inline void write(T x)
	{
		if (x < 0) putchar('-'), x = -x;
		if (x > 9) write(x / 10);
		putchar(x % 10 + '0');
	}
	template <typename T> inline void writesp(T x) { write(x); putchar(' '); }
	template <typename T> inline void writeln(T x) { write(x); putchar('\n'); }
}
using namespace IO;
const int N = 7;
int n, m, k;
int a[N][N];
int ans;
bool row[N], col[N];
inline bool check()
{
	int sum = 0;
	for (int i = 1; i <= n; i++)
	for (int j = 1; j <= m; j++)
	if (a[i][j] && !row[i] && !col[j]) sum++;
	return (sum == k);
}
inline void dfs(int dep, int op)
{
	if (op == 1)
	{
		if (dep > n) {
			dfs(1, 2);
			return;
		}
		dfs(dep + 1, op);
		row[dep] = 1;
		dfs(dep + 1, op);
		row[dep] = 0;
	}
	else
	{
		if (dep > m) {
			if (check()) ans++;
			return;
		}
		dfs(dep + 1, op);
		col[dep] = 1;
		dfs(dep + 1, op);
		col[dep] = 0;
	} 
}
int main(){
	read(n); read(m); read(k);
	char opt;
	for (int i = 1; i <= n; i++)
	for (int j = 1; j <= m; j++)
	{
		do { opt = getchar(); } while (isspace(opt));
		if (opt == '.') a[i][j] = 0;
		else a[i][j] = 1;
	}
	dfs(1, 1);
	writeln(ans);
  return 0;
}

Measured memory_bytes: 3628
using System;
using System.Linq;

namespace _3_D
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = x[0];
            int b = x[1];
            int c = x[2];
            int answer=0;
            for (int X=a;X<=b;X++)
            {
                if(c%X==0)
                {
                    answer++;
                }
            }
            Console.WriteLine(answer.ToString());
        }
    }
}

Measured memory_bytes: 9604
#include  <bits/stdc++.h>
using namespace std;
static int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();

int main(){ 
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a==0){
    cout<<1<<"\n";  
  }
  if(b==0){
    cout<<2<<"\n";  
  }
  if(c==0){
    cout<<3<<"\n";  
  }
  if(d==0){
    cout<<4<<"\n";  
  }
  if(e==0){
    cout<<5<<"\n";  
  }     
  return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long LL;
const int maxn=2e5+10;
const int modn=1e9+7;
ll num[maxn];
LL pow(LL a, LL n, LL p)   
{
    LL ans = 1;
    while(n)
    {
        if(n & 1) ans = ans * a % p;          
        a = a * a % p;
        n >>= 1;
    }
    return ans;
}
int main()
{
	num[0]=1;
	int n,a,b,c;
	scanf("%d%d%d%d",&n,&a,&b,&c);
	for(int i=1;i<=2*n;i++)num[i]=num[i-1]*i%modn;
	ll ans=0;
	for(int i=n;i<2*n;i++){
		ll sum=num[i-1]*pow(num[i-n],modn-2,modn)%modn*pow(num[n-1],modn-2,modn)%modn;
		ll sum1=pow(a,n,modn)*pow(b,i-n,modn)%modn;
		ll sum2=pow(a,i-n,modn)*pow(b,n,modn)%modn;
		ll sum3=pow(a+b,i,modn);
		sum3=pow(sum3,modn-2,modn);
		sum=(sum1+sum2)%modn*sum%modn;
		sum=sum*sum3%modn;
		//ll sum4=pow(100,i+1,modn);
		sum=sum*i%modn*100ll%modn*pow(a+b,modn-2,modn)%modn;
		ans=(ans+sum)%modn;
	} 
	printf("%lld\n",ans);
}

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

using ll = long long;

int main() {
    int n;
    string s;
    cin >> n >> s;
    string t = "ABC";
    int cnt = 0;
    for (int i = 0; i < n - 2; i++) {
        string str;
        for (int j = 0; j < 3; j++) {
            str += s.at(i + j);
        }

        if (str == t) cnt++;
    }
    cout << cnt << endl;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	stack<char> st;
	int n = s.size();
	for(int i=0; i <n; ++i){
		if( s[i] == 'B' ){ if(!st.empty()){ st.pop(); } }
		else{ st.push(s[i]); }
	}
	string ans = "";
	while(!st.empty()){ ans += st.top(); st.pop(); }
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
N=input("")
N=N.split(" ")
Sunuke_num=int(N[0])
Treat_num=int(N[1])

ans_list=[]
for i in range(Sunuke_num):
    ans_list.append(False)

for i in range(Treat_num):
    s=input("")
    q=input("")
    q=q.split(" ")
    for r in range(int(s)):
        ans_list[int(q[r])-1]=True

print(ans_list.count(False))


Measured memory_bytes: 9192
#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;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    int ans = 0;
    FOR(i,1,n){
        if(i > n - i) break;
        if(i != n - i) ans ++;
    }
    cout << ans << endl;


}

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

#include <boost/multiprecision/cpp_bin_float.hpp>
using namespace boost::multiprecision;

using mydouble = cpp_bin_float_100;

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  mydouble err = 1e-80;
  mydouble a, b, c; cin >> a >> b >> c;
  cout << (sqrt(a) + sqrt(b) + err < sqrt(c) ? "Yes" : "No") << endl;

  return 0;
}



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

using namespace std;

int main() {
  int N, M, C;
  vector<int> B;
  cin >> N >> M >> C;
  for(int i = 0; i < M; i++) {
    int b;
    cin >> b;
    B.push_back(b);
  }
  int ans{};
  for(int i = 0; i < N; i++) {
    vector<int> A;
    for(int j = 0; j < M; j++) {
      int a;
      cin >> a;
      A.push_back(a);
    }
    int sum{};
    for(int j = 0; j < M; j++) {
      sum += A[j] * B[j];
    }
    if(sum + C > 0){
      ans++;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

int main() {
    ios::sync_with_stdio(false);
    int n, m;
    multiset<int, greater<int>> S;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        S.insert(a);
    }

    for (int i = 0; i < m; i++) {
        if (!S.empty()) {
            int a = *S.begin();
            S.erase(S.begin());
            S.insert(a/2);
        }
    }
    long long ans = 0;
    for (auto a: S)
        ans += a;
    cout << ans << endl;
    return 0;
}



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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const int INF = 100001;

int a,b,c;


int main()
{
    cin >> a >> b >> c;
    int ans = 100*a + 10*b+c;
    if(ans%4){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }

}

Measured memory_bytes: 256
s=input()
t=input()
lens=len(s)
lent=len(t)

alp="abcdefghijklmnopqrstuvwxyz"

D={c : {i:-1 for i in range(lens*2)} for c in alp}

tab={c:0 for c in alp}

for i in range(lens*2):
    nowc=s[i%lens]
    for q in range(tab[nowc],i+1):
        D[nowc][q]=i
    tab[nowc]=i+1

ans=0
pos=0
for i in range(lent):
    nowc=t[i]
    if D[nowc][pos]==-1:
        print(-1)
        break
    ans+=D[nowc][pos]-pos+1
    #print(ans)
    pos=D[nowc][pos]+1
    pos%=lens
else:
    print(ans)

Measured memory_bytes: 499264
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		ArrayList<Integer> x = new ArrayList<Integer>();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int i = 0;
		while(true) {
			x.add(Integer.parseInt(br.readLine()));
			if(x.get(i) == 0) {
				break;
			}
			i++;
		}
		for(int j = 0; j < i; j++) {
			System.out.println("Case " + (j+1) + ": " + x.get(j));
		}
	}
}

Measured memory_bytes: 33256
#include <iostream>
#include <algorithm>
using namespace std;

const int MAX_DEPTH = 10;

double T[100001][MAX_DEPTH];
double sum[100001];

void make() {
  fill(T[0], T[100001], 0);
  T[1][1] = 1.0;
  sum[1] = 1;
  for(int i = 2; i <= 100000; ++i) {
    double a = 1;
    sum[i] = sum[i-1];
    T[i][0] = 1;
    for(int j = 1; j < MAX_DEPTH; ++j) {
      double tmp = T[i-1][j-1] * a;
      a *= 0.5;
      T[i][j] = tmp;
      T[i][0] -= tmp;
      sum[i] += tmp;
    }
  }
}

int main() {
  make();
  int n;
  while((cin >> n) && n) printf("%.8f\n", sum[n]);
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const int N = 1e2+5;
int A[N], n, rt;
int main(){
    scanf("%d", &n);
    for(int i=0;i<(n<<1);i++) scanf("%d", &A[i]);
    sort(A, A+(n<<1));
    for(int i=0;i<n;i++) rt+=A[i<<1];
    printf("%d", rt);
}

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

using namespace std;

int main()
{
  int N, H, W;
  cin >> N >> H >> W;
  vector<int> A(N, 0);
  vector<int> B(N, 0);

  int out = 0;
  for( int i=0;i<N;i++ )
    {
      cin >> A[i] >> B[i] ;
      if( A[i]>=H && B[i] >= W)
	out ++;
    }
  cout << out << endl;
}


Measured memory_bytes: 256
from itertools import combinations_with_replacement, permutations, zip_longest
S = input()
cmb = list(combinations_with_replacement(["", "+"], (len(S)-1)))
prm = set()
for c in cmb:
    for p in permutations(c):
        prm.add(p)

formulas = []
for p in prm:
    formulas.append("".join(x+y for x, y in zip_longest(S, p, fillvalue="")))

ans = 0
for f in formulas:
    ans += eval(f)
print(ans)




Measured memory_bytes: 3316
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
b = inl()
a = [0]*n
a[0] = b[0]
a[n-1] = b[n-2]
for i in range(1,n-1):
    a[i] = min(b[i-1],b[i])
print(sum(a))


Measured memory_bytes: 3064
inpl = lambda: list(map(int,input().split()))
N = int(input())
c = input()
ans = 0
i = 0
j = N-1
while True:
    while i < N and c[i] == 'R':
        i += 1
    while j >= 0 and c[j] == 'W':
        j -= 1
    if i > j:
        break
    else:
        ans += 1
        i += 1
        j -= 1
print(ans)


Measured memory_bytes: 67924
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    long N;
    private void solve() {
        N = nextLong()-1;

        StringBuilder sb = new StringBuilder();
        while(N > 0) {
            long n = N % 26;
            char c = (char)('a'+ (int)n);
            sb.append(c);
            N /= 26;
            N -= 1;
        }

        if (N == 0) {
            sb.append('a');
        }

        out.println(sb.reverse());
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] x = new int[n];
        for(int i = 0;i < n;i++) {
            x[i] = nextInt();
        }
        return x;
    }

    public long[] nextLongArray(int n) {
        long[] x = new long[n];
        for(int i = 0;i < n;i++) {
            x[i] = nextLong();
        }
        return x;
    }

    public double[] nextDoubleArray(int n) {
        double[] x = new double[n];
        for(int i = 0;i < n;i++) {
            x[i] = nextDouble();
        }
        return x;
    }
}

Measured memory_bytes: 32624
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

#ifdef WIN32
	#define LL "%I64d"
#else
	#define LL "%lld"
#endif

#ifdef CT
	#define debug(...) printf(__VA_ARGS__)
	#define setfile() 
#else
	#define debug(...)
	#define filename ""
	#define setfile() freopen(filename".in", "r", stdin); freopen(filename".out", "w", stdout)
#endif

#define R register
#define getc() (S == T && (T = (S = B) + fread(B, 1, 1 << 15, stdin), S == T) ? EOF : *S++)
#define dmax(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#define dmin(_a, _b) ((_a) < (_b) ? (_a) : (_b))
#define cmax(_a, _b) (_a < (_b) ? _a = (_b) : 0)
#define cmin(_a, _b) (_a > (_b) ? _a = (_b) : 0)
#define cabs(_x) ((_x) < 0 ? (- (_x)) : (_x))
char B[1 << 15], *S = B, *T = B;
inline int F()
{
	R char ch; R int cnt = 0; R bool minus = 0;
	while (ch = getc(), (ch < '0' || ch > '9') && ch != '-') ;
	ch == '-' ? minus = 1 : cnt = ch - '0';
	while (ch = getc(), ch >= '0' && ch <= '9') cnt = cnt * 10 + ch - '0';
	return minus ? -cnt : cnt;
}

int main()
{
//	setfile();
	int n, x;
	scanf("%d%d", &n, &x);
	if (x == 1 || x == n * 2 - 1)
	{
		puts("No");
		return 0;
	}
	puts("Yes");
	R int pos = x - n, m = 2 * n - 1;
	for (R int i = 0; i < m; ++i)
		printf("%d\n", (i + pos + m) % m + 1);
	return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <cassert>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

constexpr int NUMBER_OF_FACES = 6;
enum FACE { TOP, BOTTOM, NORTH, SOUTH, WEST, EAST };

class dice {
private:
	int num[NUMBER_OF_FACES];

public:
	inline void roll(FACE a, FACE b, FACE c, FACE d) {
		swap(num[a], num[b]);
		swap(num[b], num[c]);
		swap(num[c], num[d]);
	}

	dice() {
		num[TOP] = 1;
		num[BOTTOM] = 6;
		num[NORTH] = 5;
		num[SOUTH] = 2;
		num[EAST] = 3;
		num[WEST] = 4;
	}

	dice(const dice& d) {
		num[TOP] = d[TOP];
		num[BOTTOM] = d[BOTTOM];
		num[NORTH] = d[NORTH];
		num[SOUTH] = d[SOUTH];
		num[EAST] = d[EAST];
		num[WEST] = d[WEST];
	}

	inline int encode() const {
		return (num[TOP] - 1) * NUMBER_OF_FACES * NUMBER_OF_FACES + (num[NORTH] - 1) * NUMBER_OF_FACES + (num[EAST] - 1);
	}

	const int& operator[] (FACE f) const { return num[f]; }
};

void north(dice& d) { d.roll(TOP, SOUTH, BOTTOM, NORTH); }
void east(dice& d) { d.roll(TOP, WEST, BOTTOM, EAST); }
void west(dice& d) { d.roll(TOP, EAST, BOTTOM, WEST); }
void south(dice& d) { d.roll(TOP, NORTH, BOTTOM, SOUTH); }


const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
void (*rotate_dice[4])(dice& d) = {east, south, west, north};

constexpr int MAX_SIZE = 10;
constexpr int INF = 0xfffffff;

int h, w;
int gx, gy;
int field[MAX_SIZE][MAX_SIZE];

typedef int weight;
struct state {
	int x, y;
	dice d;
	weight dist;
	state(int x, int y, const dice& d, weight dist):x(x), y(y), d(d), dist(dist){}

	bool operator>(const state& s) const {
		return dist > s.dist;
	}
};

inline bool out(int x, int y) {
	return x < 0 || x >= w || y < 0 || y >= h;
}

weight dijkstra(int sx, int sy, dice d) {
	priority_queue<state, vector<state>, greater<state> > que;
	vector<vector<vector<weight>>> dist(h, vector<vector<weight>>(w, vector<weight>(NUMBER_OF_FACES*NUMBER_OF_FACES*NUMBER_OF_FACES, INF)));
	dist[sy][sx][d.encode()] = 0;
	que.push(state(sx, sy, d, 0));

	while(!que.empty()) {
		const state s = que.top();
		que.pop();

		if(dist[s.y][s.x][s.d.encode()] < s.dist)
			continue;

		if(s.x == gx && s.y == gy)
			return s.dist;

		for(int i = 0; i < 4; ++i) {
			const int nx = s.x + dx[i];
			const int ny = s.y + dy[i];
			if(out(nx, ny)) continue;
			dice next_d(s.d);
			rotate_dice[i](next_d);

			const int next_dist = s.dist + next_d[BOTTOM] * field[ny][nx];
			const int value = next_d.encode();
			if(dist[ny][nx][value] > next_dist) {
				dist[ny][nx][value] = next_dist;
				que.push(state(nx, ny, next_d, next_dist));
			}
		}
	}

	assert(false);
}

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

	while(cin >> h >> w && h) {
		for(int i = 0; i < h; ++i) {
			for(int j = 0; j < w; ++j) {
				cin >> field[i][j];
			}
		}

		int sx, sy;
		cin >> sy >> sx >> gy >> gx;

		cout << dijkstra(sx, sy, dice()) << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1356
#include <iostream>

int main(void)
{
    int seconds;

    std::cin >> seconds;

    int s = seconds % 60;
    seconds -= s;

    int minutes = seconds / 60;
    int m = minutes % 60;
    minutes -= m;

    int h = minutes / 60;

    std::cout << h << ":" << m << ":" << s << std::endl;

    return 0;
}

Measured memory_bytes: 3088
n,k=map(int,input().split())
s=input()

S=list(s)


if S[k-1]=='A':
    S[k-1]='a'
elif S[k-1]=='B':
    S[k-1]='b'
elif S[k-1]=='C':
    S[k-1]='c'


h=''
for i in S:
    h+=i

print(h)


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

const int ALPHABET = 26;

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

  int len = s.size();

  for (int i = 0; i < len; i++) {
    int x = s[i] - 'A';
    x += n;
    x %= ALPHABET;
    s[i] = (x + 'A');
  }

  cout << s << endl;

}

Measured memory_bytes: 3604
from math import gcd

k = int(input())

ans = 0

for a in range(1, k + 1, 1):
    for b in range(1, k + 1, 1):
        g = gcd(a, b)
        for c in range(1, k + 1, 1):
            ans += gcd(g, c)

print(ans)


Measured memory_bytes: 68068
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main()
{
  string s1, s2;
  cin >> s1 >> s2;
  
  int count = 0;
  
  for(int i = 0; i < s1.size(); i++){
    if(s1.at(i) != s2.at(i))
      count++;
  }
  
  cout << count << endl;
}


Measured memory_bytes: 3920
# https://atcoder.jp/contests/arc061/tasks/arc061_a

s = input()
k = len(s)

# def dfs(i, f) :
#     """
#     argument i : どこから始めるか
#     f :　最初の数
#     returen : falese or ture(作れるならtrue)
#     """
#     if i == k-1:
#         return sum(list(map(int, f.split('+'))))

#     return dfs(i+1, f + s[ i +1 ]) + \
#            dfs(i+1, f + '+' +  s[ i +1 ]) 

# print(dfs(0, s[0]))

#bit木を書いていきます

ans = 0

for bit in range(1 << (k-1)):
    f = s[0]
    
    for i in range(k-1):
        # if bit & (1 << i)で、bitにiが含まれているか（フラグが立っているか）を判定してくれるらしい
        if bit & (1 << i):
            f += '+'
        f += s[i + 1]
    ans += sum(list(map(int, f.split('+'))))

print(ans)

Measured memory_bytes: 3064
import sys

input = sys.stdin.readline

def main():
    n = int(input()[:-1])
    l = list(map(int, input()[:-1].split(" ")))

    c = 1
    s = 0
    tmp = 0
    while l:
        if tmp >= n:
            break
        if l[tmp] != c :
            s += 1
        else:
            c += 1
        tmp += 1

    res = s
    if s == n:
        res = -1

    print(res)

main()



Measured memory_bytes: 69004
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#include <bits/stdc++.h>
#define pb(X) push_back(X)
#define x first
#define y second
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
using namespace std;

typedef pair<int, int> pii;

int n, a, b, c, d, q, ans;

int main() {
	INIT
	char a;
	cin >> a;
	if (a == 'A') {
		cout << 'T';
	} else if (a == 'T') {
		cout << 'A';
	} else if (a == 'C') {
		cout << 'G';
	} else if (a == 'G') {
		cout << 'C';
	}

	return 0;
}

Measured memory_bytes: 256
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
# https://atcoder.jp/contests/abc107/tasks/arc101_a
# C - Candles
"""
need to consider the case that ticket is not enough to lower everything
"""

N = gi()
K = gi()
xs = [0] * N

for i in range(N):
    xs[i] = gi()

ans = abs(xs[0]) + abs(xs[0] - xs[N - 1])

for i in range(N):
    if i + K - 1 >= N:
        break

    l = xs[i]
    r = xs[i + K - 1]
    ans = min(ans, abs(r - l) + abs(r))
    ans = min(ans, abs(r - l) + abs(l))

print(ans)


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

using ll = long long;

template <typename T>
class node {
public:
	node<T> *l, *r;
	T val;
	node() {}
	node(T val_, node<T>* l_ = nullptr, node<T>* r_ = nullptr) : l(l_), r(r_), val(val_) {}
	void init(T val_, node<T>* l_ = nullptr, node<T>* r_ = nullptr) {
		val = val_;
		l = l_;
		r = r_;
	}
};

template <typename T>
class DynamicSegmentTree {
	using func_t = function<T(T, T)>;
	const ll n;
	const T id;
	func_t merge;
	node<T> *root;
	vector<node<T>> pool;
	int it;
	ll size(ll n) {
		ll res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	node<T> *new_node() {
		pool[it].init(id);
		return &pool[it++];
	}
	T sub(ll l, ll r, node<T>* n, ll lb, ll ub) {
		if (ub <= l || r <= lb) return id;
		if (l <= lb && ub <= r) return n->val;
		return merge(n->l != nullptr ? sub(l, r, n->l, lb, (lb + ub) / 2) : id, n->r != nullptr ? sub(l, r, n->r, (lb + ub) / 2, ub) : id);
	}
	void suc(ll v, node<T>* n, ll lb, ll ub, T val) {
		if (ub - lb <= 1) {
			n->val = val;
			return;
		}
		ll c = (lb + ub) / 2;
		if (v < c) {
			if (n->l == nullptr) n->l = new_node();
			suc(v, n->l, lb, c, val);
		}
		else {
			if (n->r == nullptr) n->r = new_node();
			suc(v, n->r, c, ub, val);
		}
		n->val = merge(n->l != nullptr ? n->l->val : id, n->r != nullptr ? n->r->val : id);
	}
public:
	DynamicSegmentTree(ll n_, T id_, func_t merge_, int max_ = 10000000) :
		n(size(n_)), id(id_), merge(merge_), pool(max_)
	{
		it = 0;
		root = new_node();
	}
	void Update(ll p, T val) {
		suc(p, root, 0, n, val);
	}
	T Find(ll l, ll r) {
		return sub(l, r + 1, root, 0, n);
	}
};

int main()
{
	random_device rd;
	int R, C, N;
	cin >> R >> C >> N;
	int cnt = 0;
	bool res = true;
	DynamicSegmentTree<ll> dst(R * 2 + C * 2, 0, [](ll l, ll r) { return l + r; });
	for (int i = 0, x1, x2, y1, y2; i < N; i++) {
		cin >> x1 >> y1 >> x2 >> y2;
		int val1 = 0, val2 = 0;
		if (x1 == 0) {
			val1 = C - y1;
		}
		else if (x1 == R) {
			val1 = R + C + y1;
		}
		else if (y1 == 0) {
			val1 = C + x1;
		}
		else if (y1 == C) {
			val1 = R * 2 + C * 2 - x1;
		}
		else {
			continue;
		}
		if (x2 == 0) {
			val2 = C - y2;
		}
		else if (x2 == R) {
			val2 = R + C + y2;
		}
		else if (y2 == 0) {
			val2 = C + x2;
		}
		else if (y2 == C) {
			val2 = R * 2 + C * 2 - x2;
		}
		else {
			continue;
		}
		cnt++;
		if (dst.Find(0, val1) != dst.Find(0, val2)) {
			res = false;
		}
		else {
			ll val = rd() % 100007;
			dst.Update(min(val1, val2), (ll)val);
			dst.Update(max(val1, val2), -((ll)val));
		}
	}
	cout << (res ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 53760
module Main where

import Data.List
import Data.Char (digitToInt)
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import qualified Data.Map.Strict as M


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las

solve :: [Int] -> Int
solve xs = snd $ head $ sortOn snd $ fmap addV [1..100] where
    addV n = (n, sum $ fmap (\x -> (x - n) ^ 2 ) xs)


main = do
    n <- readInt
    xs <- readInts
    print $ solve xs



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

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll a,b,c,k;cin>>a>>b>>c>>k;
    ll ans=0;
    if(a>=k) 
    {
        cout<<k<<endl;return 0;
    }
    else
    {
        ans+=a;k-=a;
    }
    if(b>=k)
    {
        cout<<ans<<endl;return 0;
    }
    else
    {
        k-=b;
    }
    if(c>=k)
    {
        ans-=k;cout<<ans<<endl;return 0;
    }
    else
    {
        ans-=c;cout<<ans<<endl;return 0;
    }
    
    return 0;
 } 

Measured memory_bytes: 3648
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int main(){
  ll x;
  cin >> x;
  ll t = x / 11 * 2;
  x %= 11;
  if (x > 6) t += 2;
  else if (x > 0) t++;
  cout << t << endl;
}


Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]  # 親
        self.rank = [1] * n  # 木の高さ
        self.size = [1] * n  # size[i] は i を根とするグループのサイズ
 
    def find(self, x):  # x の根を返す
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])  # 経路圧縮
            return self.parent[x]
 
    def unite(self, x, y):  # x, y の属する集合を併合する
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1
 
    def is_same(self, x, y):  # x, y が同じ集合に属するか判定する
        return self.find(x) == self.find(y)
 
    def group_size(self, x):  # x が属する集合の大きさを返す
        return self.size[self.find(x)]




def bridge(edges,v,e):#与えられるグラフが連結の場合
    hashi=[]#橋
    for i in range(e):
        uf=UnionFind(v)
        for j in range(e):
            if i==j:
                continue
            a,b=edges[j]
            uf.unite(a,b)
        if uf.group_size(0)!=v:#非連結でないなら頂点数と一致する
            hashi.append(edges[i])
    return hashi

n,m=map(int,input().split())
edges=[]
for i in range(m):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    edges.append((a,b))

print(len(bridge(edges,n,m)))

Measured memory_bytes: 9304
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i,n)   for (int i = 0; i < (n); ++i)
#define SORT(a)    sort((a).begin(), (a).end());
#define UNIQ(a)    SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define FIND(a,x)  find((a).begin(), (a).end(), (x)) != (a).end()
#define REVERSE(a) reverse((a).begin(), (a).end());

using namespace std;
using ll = long long;
// using P = pair<int,int>;

const int MOD = 1000000007; // 10^9 + 7

struct P {
	int x, y;
};

struct Puzzle {
	int peace[2][4], t;
	P zero_p;
};

int toHash(int arr[][4]) {
	int res = 0;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 4; j++) {
			res = (res << 3) + arr[i][j];
		}
	}
	return res;
}

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

int main() {
	map<int, int> ps;
	queue<Puzzle> pq;

	Puzzle f_puzzle;
	REP(i, 8) f_puzzle.peace[i / 4][i % 4] = i;
	f_puzzle.t = 1;
	f_puzzle.zero_p = {0, 0};

	pq.push(f_puzzle);

	while (!pq.empty()) {
		Puzzle p = pq.front();pq.pop();
		int h_value = toHash(p.peace);

		if (ps[h_value] != 0) continue;

		P zero_p = p.zero_p;
		REP(i, 4) {
			int mx = zero_p.x + dx[i];
			int my = zero_p.y + dy[i];

			if (0 <= mx && mx < 4 && 0 <= my && my < 2) {
				Puzzle temp_p = p;
				temp_p.peace[zero_p.y][zero_p.x] = temp_p.peace[my][mx];
				temp_p.peace[my][mx] = 0;
				temp_p.zero_p = {mx, my};
				temp_p.t++;
				pq.push(temp_p);
			}
		}

		ps[h_value] = p.t;
	}

	int arr[2][4];
	while (true) {
		cin >> arr[0][0];

		if (cin.eof()) return 0;

		for (int i = 1; i < 8; i++)
			cin >> arr[i / 4][i % 4];

		cout << ps[toHash(arr)] - 1 << endl;
	}
}


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

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

  vector<int> xs;
  vector<int> xss;

  int x;
  for(int i = 0; i < N; ++i) {
    cin >> x;
    xs.push_back(x);
    xss.push_back(x);
  }
  sort(xss.begin(), xss.end());
  int midl = xss[N / 2 - 1];
  int midh = xss[N / 2];
  for(auto x : xs) {
    if(x <= midl) {
      cout << midh << endl;
    } else {
      cout << midl << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3948
<?php
list ($x1, $y1, $x2, $y2) = array_map("intval", explode(" ", fgets(STDIN)));
printf("%d %d %d %d\n", $x2+$y1-$y2, $y2+$x2-$x1, $x1+$y1-$y2, $y1+$x2-$x1);
?>


Measured memory_bytes: 5112
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <cmath>
#include <set>
#include <list>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
constexpr ll mod = 1000000007;

int main() {
    ll n;
    cin >> n;
    cout << n * (n - 1) / 2 << endl;
}

Measured memory_bytes: 256
/*
* @Author: _dp95
* @Date:   2020-04-03 09:14:49
*/
#include "bits/stdc++.h"
using namespace std ;

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

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

const int MAX = 2*1000*1000 + 10 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;   

ll ar[MAX], has[MAX] ;

signed main( ){
  timesaver ;
  ll n ;
  cin >> n ;
  for( int i = 0 ; i < n ; i++ ){
    cin >> ar[i] ;
    has[ar[i]]++ ;
  }
  ll ans = 0 ;
  for( int i = 0 ; i < MAX ; i++ ){
    ll x = has[i];
    ans += (x*(x-1)>>1) ;
  }
  for( int i = 0 ; i < n ; i++ ){
    ll x = has[ar[i]]-1 ;
    ll y = has[ar[i]] ;
    cout << ans - (y*(y-1)>>1) + (x*(x-1)>>1) << nl ;
  }
  cout << nl ;
}

Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
using namespace std;

long long com[51][51];
int main() {
    com[0][0] = 1;
    for (int i = 1; i < 51; ++i) {
        for (int j = 0; j <= i; ++j) {
            com[i][j] += com[i-1][j];
            if (j > 0) com[i][j] += com[i-1][j-1];        
        }
    }

    int N, A, B; cin >> N >> A >> B;
    vector<long long> v(N);
    for (int i = 0; i < N; ++i) cin >> v[i];
    sort(v.begin(), v.end(), greater<long long>());

    // 最大値
    long long sum = 0;
    for (int i = 0; i < A; ++i) sum += v[i];
    double ave = (double)(sum) / A;

    // 小さいやつの個数
    long long res = 0;
    int num = 0;
    for (int i = 0; i < N; ++i) if (v[i] == v[A-1]) ++num;
    if (v[0] == v[A-1]) {
        for (int j = A; j <= B; ++j) {
            res += com[num][j];
        }
    }
    else {
        int a = 0;
        for (int i = 0; i < A; ++i) if (v[i] == v[A-1]) ++a;
        res = com[num][a];
    }
    cout << fixed << setprecision(10) << ave << endl;
    cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    string s;
    ll n;
    cin>>n;

    ll ac=0,te=0,re=0,wr=0;
    for(ll i=0; i<n; i++){
        cin>>s;
        if(s=="AC")ac++;
        else if(s=="TLE")te++;
        else if(s=="RE")re++;
        else if(s=="WA")wr++;

    }
    cout<<"AC x "<<ac<<endl<<"WA x "<<wr<<endl<<"TLE x "<<te<<endl<<"RE x "<<re<<endl;

}


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

int main(){
  int a,b;
  
  cin >> a >> b;
  
  if(a <= b){
    for(int i = 0; i < b; i++) cout << a;
  }else{
    for(int i = 0; i < a; i++) cout << b;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#define ll long long
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    int arr[100][100];
    int a,b,c,i,n;
    cin>>n;
    int ae[10000];
    for(i = 1;i <= n;i++){
        cin>>ae[i];
    }
    int j,k=0,s=1;
    
    
    
    for(i = 0;i < h;i++){
        if(k==0){
            for(k;k<w;k++){//k=0; 
                if(ae[s]>0){
                    arr[i][k] = s;
                    ae[s]--;
                }else{
                    s++;
                    arr[i][k] = s;
                    ae[s]--;
                }
            }
        }else{
            k = k-1;
            for(k;k>=0;k--){
                if(ae[s]>0){
                    arr[i][k] = s;
                    ae[s]--;
                }else{
                    s++;
                    arr[i][k] = s;
                    ae[s]--;
                }
            }
            k++;
        }
    }
    
    
    
    
    
    
    
    
    
    
    for(i = 0;i < h;i++){//下面为输出的主体 
        for(j = 0;j < w;j++){
            cout<<arr[i][j]<<' ';
        }
        cout<<endl;
    }
}

Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
    char s[7];
    scanf("%s",&s);
    int l = strlen(s);
    if(l == 2)
        cout << s << endl;
    else
    {
        for(int i = 2; i >= 0; i --)cout << s[i] ;
        cout <<endl;
    }
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> v(n), x(n-1);
    for(int i = 0; i < n; i++)  cin >> v[i];
    for(int i = 0; i < n-1; i++)    x[i] = v[i+1]-v[i];
    int a = 0, b = 0, c = 0, d = 0, e = 0;
    for(int i = 1; i < n-1; i++){
        if(x[i-1] < 0 && x[i] > 0)  e++;
        if(x[i-1] > 0 && x[i] < 0)  d++;
    }
    int cur = 0;
    while(cur < n-1 && x[cur] == 0)  cur++;

    while(cur < n-1){
        if(x[cur] != 0){
            cur++;
            continue;
        }
        int next = cur;
        while(next < n-1 && x[next] == 0)  next++;
        if(next == n-1) break;
        if(x[cur-1] < 0 && x[next] > 0)         b++;
        else if(x[cur-1] > 0 && x[next] < 0)    a++;
        else                                    c++;
        cur = next;
    }
    printf("%d %d %d %d %d\n", a, b, c, d, e);
    return 0;
}


Measured memory_bytes: 3556
#include <iostream>
#include<iostream>
using namespace std;
int main()
{
    int d;
    scanf("%d",&d);
    if(d==25)
    printf("Christmas");
    else if(d==24)
    printf("Christmas Eve");
    else if(d==23)
    printf("Christmas Eve Eve");
    else
        printf("Christmas Eve Eve Eve");

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;



ll N,ans;
ll H[200];


int main() {


	cin >> N;
	int cur = 0;
	FOR(i, 0, N) {
		cin >> H[i];
		if (H[i] >= cur) { ans++; cur = H[i]; }
	}

	ct(ans);

	return 0;
}

Measured memory_bytes: 256
// AOJ 2699: Koto Municipal Subway
// 2017.11.6 bal4u@uu

#include <stdio.h>
#include <math.h>
#define TM 0
#if TM
#include <time.h>
#endif



int main()
{
	int d, e, x, y;
	double t, ans;
#if TM
	clock_t start, end;
	start = clock();
#endif
	while (scanf("%d%d", &d, &e) && e > 0) {
		ans = 1e8;
		for (x = 0; x <= d; x++) {
			y = d-x;
			if ((t = fabs(hypot(x, y) - e)) < ans) ans = t;
		}
		printf("%.10lf\n", ans);
	}
#if TM
	end = clock();
	printf("time %lf\n", (double)(end-start)/CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 1844