akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>

using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define pi pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912

const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}
int main(){
    string s; cin >> s;
    int n = s.size();
    bool ans = true;
    bool C = false;

    if(s[0] != 'A') ans = false;
    //if(ans) cout << "BBB";
    int c;
    for(int i = 2; i < n-1; i++){
        if(s[i] == 'C' && !C){
            C = true;
            c = i;
        }
        else if(s[i] == 'C' && C) ans = false; 
    }
    if(!C) ans = false;
    //if(ans) cout << "AAA";
    for(int i = 1; i < n; i++){
        if(i == c) continue;
        bool check = false;
        for(char j = 'a'; j <= 'z'; j++){
            if(j == s[i]) check = true;
        }
        if(!check) ans = false;
    }
    if(ans) cout << "AC" << endl;
    else cout << "WA" << endl;
}



Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int K = sc.nextInt();
		boolean[] D = new boolean[10];
		for (int i = 0; i < K; i++) {
			D[sc.nextInt()] = true;
		}

		for (int i = N;; i++) {
			if (check(D, i)) {
				System.out.println(i);
				break;
			}
		}
	}

	private static boolean check(boolean[] D, int N) {
		while (N > 0) {
			if (D[N % 10]) {
				return false;
			}
			N /= 10;
		}
		return true;
	}

}

class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

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

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 7892
#include<bits/stdc++.h>
#define ll long long int
#define size(x)   x.size()
#define rep(i,a,b) for(ll i=a;i<b;i++)
using namespace std;
signed main(){
ll n;
  cin>>n;
  ll k;
  cin>>k;
  string s;
  cin>>s;
  ll dif=0,ans=0;
  rep(i,0,n-1)
  {
   if(s[i] == s[i+1])
     ans++;
    else dif++;
  }
  ans+=min(dif,2*k);
  cout<<ans;
}
  


Measured memory_bytes: 512
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>

using Real = long double;
using std::complex;
using std::vector;
using Complex = complex<Real>;

struct Fout {
    int precision;
    Fout(int precision) : precision(precision) {}
};
std::ostream& operator<<(std::ostream& os, const Fout& fio) {
    os << std::fixed << std::setprecision(fio.precision);
    return os;
}

const Real PI = acos(-1);

int fact(int n) {
    return n == 0 ? 1 : n * fact(n - 1);
}

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

    vector<Complex> xs(n);
    for (auto& x : xs) {
        Real a, b;
        std::cin >> a >> b;
        x = Complex(a, b);
    }
    xs.emplace(xs.begin(), 0);
    xs.emplace_back(0);

    Real ans = 1e100;
    for (int q = 0; q < fact(n); ++q) {
        Real theta = 0, sum = 0;
        for (int i = 0; i <= n; ++i) {
            Real phi = std::arg(xs[i + 1] - xs[i]);
            Real delta = std::abs(theta - phi);
            sum += std::min(delta, 2 * PI - delta) * 180 / PI;
            theta = phi;
        }
        ans = std::min(ans, sum);
        std::next_permutation(xs.begin() + 1, xs.end() - 1,
                              [](Complex a, Complex b) { return a.real() < b.real(); });
    }

    std::cout << Fout(10) << ans << std::endl;
    return 0;
}



Measured memory_bytes: 3360
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int l[201];

int main() {

	int n;
	cin>>n;
	rep(i,n*2)cin>>l[i];

	sort(l,l+n*2);
	int total=0,s=0;
	while(s<=n*2){
		total+=l[s];
		s+=2;
	}
	cout<<total<<endl;
	return 0;

}


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

using namespace std;

#define int long long

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
constexpr ll TEN(int n){return n==0?1:10*TEN(n-1);}

constexpr ll inf = TEN(9)+5;
constexpr ll linf = 3*TEN(18);

signed main()
{
    const int mod = TEN(9)+7;
    int N; cin >> N;
    vector<ll> A(N + 1), rui(N + 1);
    rep1(i, N) cin >> A[i];
    rep1(i, N) rui[i] = (A[i] + rui[i - 1]) % mod;

    ll ans = 0;

    for (int i = N; i >= 1; --i) {
        ans += A[i] * rui[i - 1];
        ans %= mod;
    }

    cout << ans << endl;
}


Measured memory_bytes: 6428
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define endl "\n"
#define fi first
#define se second
#define For(i,a,b) for(ll i=a;i<b;i++)
#define sz size()
#define PQ priority_queue
#define len length()
#define mll map<ll,ll>
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
#define mp(x,y)  make_pair(x,y)
#define pb push_back
#define pf push_front
#define ALL(v) v.begin(),v.end()
#define LAPAK ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

const ll MOD = 1000000007;
const ll MAX = 100005;

int main() {
	ll n,w;
	cin>>n>>w;
	ll dp[MAX],maxi=0;
	For(i,0,MAX)dp[i]=0;
	For(i,0,n){
	    ll weight,value;
	    cin>>weight>>value;
	    
	    for(ll j=MAX-1;j>=0;j--){
	        if(dp[j]!=0){
	            ll total_value = value+ j;
	            ll total_weight = weight + dp[j];
	            if(total_weight<=w){
	                if(dp[total_value]==0)dp[total_value] = total_weight;
	                else
	                    dp[total_value] = min(dp[total_value], total_weight);
	            }
	            
	        }
	    }
	    if(dp[value]==0)
	    dp[value] = weight;
	    else dp[value] = min(weight,dp[value]);
	}
	for(ll i=MAX-1;i>=0;i--){
	    if(dp[i]>0){
	        maxi=i;
	        break;
	    }
	}
	cout<<maxi;
	return 0;
}

/*            *          *******        *       *    *
             * *            *          * *       *  *
coded by    *****           *         *****        *
           *     *      *   *        *     *       *
          *       *      * *        *       *      *
*/


Measured memory_bytes: 1024
#<ABC.C>
#<135>
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
for i in range(N):
    A[i] -= B[i]
    if A[i] <= 0:
        ans += A[i] + B[i]
        B[i] = - A[i]
        A[i] = 0
        A[i + 1] -= B[i]
        if A[i + 1] <= 0:
            ans += A[i + 1] + B[i]
            #B[i] =  -A[i + 1]
            A[i + 1] = 0
            #B[i] = 0
        else:
            ans += B[i]
            B[i] = 0
    else:
        ans += B[i]
        B[i] = 0
    #print(A)
    #print(B)
print(ans)
             


Measured memory_bytes: 97824
import java.util.*;

public class  Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n =sc.nextLong();
		long k =sc.nextLong();
		long min=n%k;

		System.out.println(Math.min(min, k-min));
		sc.close();
	}
}


Measured memory_bytes: 35552
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using ll = long long;
using namespace std;
#define modmod 1000000007

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

/*
int N;
ll W;
const int MAX_N = 100;
const ll MAX_W = 1000000000;
ll w[MAX_N],v[MAX_N];

///////////// 深さ優先探索 (TLEした) //////////////////
// i番目以降の品物から重さの輪がj以下になるように選んだ時の
// 取りうる価値の総和の最大値を返す関数
ll rec(ll i, ll j){
    ll res;
    if(i == N){
        // 品物がもう残っていないときは、価値の和の最大値は0で確定
        res = 0;
    }else if(j < w[i]){
        // 残りの容量が足りず品物iを入れられないので、入れないパターンだけ処理
        // i+1 以降の品物のみを使った時の最大値をそのままこの場合の最大値にする。
        res = rec(i+1,j);
    }else{
        // 品物iを入れるか入れないか選べるので、両方試して価値の和が大きいほうを選ぶ
        res=max(rec(i+1, j), rec(i+1, j-w[i])+v[i]);
    }
    return res;
}
*/
///////////// メモ化再帰 ///////////////////

// メモ化テーブル
// dp[i][j]はi番目以降の品物から重さの和がj以下になるように選んだ時の価値の和の最大値を表す。
// -1なら未決定
// で、やろうとしたけど、Wが大きすぎるのでメモリが足りない。size of array is too largeになってしまう。
// と思ったら、v自体はintでいけるのかなこれ。→ダメだった。

/*
ll dp[MAX_N + 1][MAX_W + 1];

ll rec_dp(int i, ll j){

}*/

/////////// 漸化式 /////////////

// DPテーブル
// dp[i][j]はi番目以降の品物から重さの和がj以下になるように選んだ時の価値の和の最大値を表す。


int main(){
    string S;
    cin >> S;

    int result = 700;

    for(int i = 0; i < S.length(); i++){
        if(S[i] == 'o'){
            result+=100;
        }
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vector<int> vals(N);
    double sum = 0;
    for(int i = 0; i < N; i++){
        int t;
        cin >> t;
        sum+=t;
        vals[i] = t;
    }
    int tar = round(sum/N);
    int ans = 0;
    for(int i = 0; i < N; i++){
        ans += pow(abs(vals[i]-tar), 2);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n;
ll a[200005];
ll k;
ll ans;
const ll z=0;
int main(void){
    cin>>n;
    cin>>a[0];
    for(int i=1;i<n;i++){
        cin>>a[i];
        k=max(z,a[i-1]-a[i]);
        ans+=k;
        a[i]+=k;
    }
    cout<<ans<<endl;


}



Measured memory_bytes: 5200
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = System.Console.ReadLine();
            string _s = System.Console.ReadLine();
            if (s[0] == _s[2] && s[1] == _s[1] && s[2] == _s[0]) System.Console.WriteLine("YES");
                    else System.Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 11092
//Link : https://atcoder.jp/contests/arc055/tasks/arc055_c
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define N 1000001

bool isNotPrime[N];
void solve() {
  int n;scanf("%d ", &n);
  int cubic = 0,ret = 0;
  const ll maxi = 1e10;

  vector<int> prime;
  set<ll> cubicList;
  cubicList.insert(1);
  for(int i=2;i<N;++i) {
    ll x = i;
    x *=i;
    x *=i;
    if(x<=maxi) {
      cubicList.insert(x);
    }
    if(!isNotPrime[i]) {


      if(i<=3000) {
        prime.push_back(i);
      }
      for(int j=i+i;j<N;j+=i) {
        isNotPrime[j] = true;
      }
    }
  }
  map<ll,ll> op;
  map<ll,ll> pcount;
  for(int i=0;i<n;++i) {
    ll in;scanf("%lld ", &in);
    if(cubicList.count(in)) {
      cubic = 1;
      continue;
    } else {
      ll mn=1,mp=1;
      ll cur = in;
      for(int j = 0;j<prime.size();++j) {
        if(cur%prime[j]==0) {
          int cc = 0;
          while(cur%prime[j]==0) {
            ++cc;
            cur/= prime[j];
          }
          cc = cc%3;
          if(cc==1) {
            mn *= prime[j];
            mp *= prime[j];
            mp *= prime[j];
          } else if(cc==2) {
            mn *= prime[j];
            mn *= prime[j];
            mp *= prime[j];
          }
        }
      }
      if(cur!=1) {
        mn *= cur;
        ll s = sqrt(cur);
        if(s*s==cur) {
          mp *= s;
        } else {
          mp *= cur*cur;
        }
      }
      op[mn] = mp;
      ++pcount[mn];
    }
  }

  for(map<ll,ll>::iterator it = op.begin();it!=op.end();++it) {
    ll x = it->first, y= it->second;
    ret += max(pcount[x],pcount[y]);
    pcount[x] = pcount[y] = 0;
  }
  assert(ret+cubic<=n);
  printf("%d\n", ret+cubic);
}
int main() {
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}


Measured memory_bytes: 20096
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1LL << 60;


int cost(int i, int s, const vector<int> &A){
    if(s == 0 || s == 4) return A[i];
    else if(s == 1 || s == 3){
        if(A[i] % 2 == 0 && A[i] > 0) return 0;
        else if(A[i] > 0) return 1;
        else return 2;
    }else{
        if(A[i] % 2 == 0) return 1;
        else return 0;
    }
}

signed main(){

    int L; cin >> L;
    vector<int> A(L);
    for(int i = 0; i < L; i++) cin >> A[i];

    vector<vector<int> > dp(L + 1, vector<int> (5, INF));
    dp[0][0] = 0;
    for(int i = 0; i < L; i++){
        for(int j = 0; j < 5; j++){
            for(int k = j; k < 5; k++){
                dp[i + 1][k] = min(dp[i + 1][k], dp[i][j] + cost(i, k, A));
            }
        }
    }

    int ans = INF;
    for(int j = 0; j < 5; j++) ans = min(ans, dp[L][j]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <list>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <iomanip>

using namespace std;

int main()
{
	int A;
	cin >> A;
	int B;
	cin >> B;

	if (A >= 13) {
		cout << B;
	}
	else if (A >= 6) {
		cout << B / 2;
	}
	else {
		cout << 0;
	}
}

Measured memory_bytes: 256
'use strict'

function main(input) {
  input = input
    .trim()
    .split('')
    .sort()

  const ans =
    input[0] === input[1] && input[2] === input[3] && input[1] !== input[2]
      ? 'Yes'
      : 'No'
  //Yes // No
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
H, W, K = [int(x) for x in input().split()]
S = [input() for _ in range(H)]
ans = 0
for i in range(2**H):
    tmp1 = S[:]
    for j in range(H):
        if (i >> j) & 1:
            # j+1桁目が1のときここに入る
            tmp1[j] = '.' * W
    for j in range(2**W):
        tmp2 = tmp1[:]
        for k in range(W):
            if (j >> k) & 1:
                tmp2 = [l[:k] + '.' + l[k+1:] for l in tmp2]
        cnt = sum([l.count('#')  for l in tmp2])
        ans += cnt == K
print(ans)


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

ll half(ll x, ll y){
    if(x%2==0||y%2==0)return x*y/2;
    return min(x,y)*(max(x,y)/2);
}

int main(){
    ll h,w;cin>>h>>w;
    
    ll ans = 100000;
    for(ll x=0; x<=w; x++){
        ll p1 = (w-x)*h;
        ll p2 = half(x,h);
        ll p3 = x*h-p2;
        ll d = max(p1,max(p2,p3))-min(p1,min(p2,p3));
        ans = min(ans,d);
    }
    for(ll y=0; y<=h; y++){
        ll p1 = (h-y)*w;
        ll p2 = half(y,w);
        ll p3 = y*w-p2;
        ll d = max(p1,max(p2,p3))-min(p1,min(p2,p3));
        ans = min(ans,d);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  static int N;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    N = sc.nextInt();
    int Q = sc.nextInt();
    for(int i = 0; i < Q; i++) { 
      int v = sc.nextInt();
      int w = sc.nextInt();
      System.out.println(dfs(v, w));
    }
  }

  public static int dfs(int s, int t) {
    int s1 = (s - 1) / N;
    int t1 = (t - 1) / N;
    if((s - 1) % N != 0) s1 += 1;
    if((t - 1) % N != 0) t1 += 1;
    if(s == t) return s;
    if(s >= t) {
      if(N == 1) return t;
      return dfs(s1, t);
    } else {
      if(N == 1) return s;
      return dfs(s, t1);
    }
  }
}

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

#define M_MAX n+1

int main() {
	
	int n,m,x;
	cin >> n >> m >> x;
	int i,j,a[M_MAX],s=x;
	
    for(i=0;i<m;++i){
        cin>>a[i];
    }
	int costS=0,costE=0;
	
	for(i=0;i<n;++i){
	    s++;
	    for(j=0;j<m;++j){
	        if(s==a[j])costE++;
	    }
	    if(s==n)break;
	}
	
	
	
	for(i=0;i<n;++i){
	    x--;
	    for(j=0;j<m;++j){
	        if(x==a[j])costS++;
	    }
	    if(x==0)break;
	}
	
	
	int ans=min(costS,costE);
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
// Problem : E - Handshake
// Contest : AtCoder - AtCoder Beginner Contest 149
// URL : https://atcoder.jp/contests/abc149/tasks/abc149_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

//Macros

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

//Solution

void solve(){
    int n,m;
    cin>>n>>m;
    vi a(n);
    for(int &i : a) cin>>i;
    sort(all(a));
    vi pre(n+1);
    for(int i=0;i<n;i++) pre[i+1] = pre[i]+a[i];
    int ans = 0, cnt = 0;
    int lo = 0, hi = 1e12, cur;
    while(lo <= hi){
        int mid = (lo+hi)/2;
        ans = 0; cnt = 0;
        for(int x : a){
            auto it = lower_bound(all(a),mid-x);
            int i = it-a.begin();
            cnt += a.end()-it;
            ans += pre[n]-pre[i]+(a.end()-it)*x;
        }
        if(cnt >= m) lo = mid+1, cur = mid;
        else hi = mid-1;
    }
    cout<<ans-(cnt-m)*cur<<endl;
}

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

Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
 
int main() {
  int N, M;
  cin >> N >> M;
  vector<ll> A(N), C(M);
  vector<int> B(M);
  rep(i, N) cin >> A[i];
  rep(i, M) cin >> B[i] >> C[i];
  priority_queue<pair<ll, int>,
                 vector<pair<ll, int> >,
                 less<pair<ll, int> >
                 > BC;
  rep(i, M)
    BC.push(make_pair(C[i], B[i]));
  int cnt = 0;
  vector<ll> D;
  while(!BC.empty() && cnt < N) {
    auto p = BC.top();
    for(int i=0; i<p.second&&cnt<N; i++) {
      D.push_back(p.first);
      cnt++;
    }
    BC.pop();
  }
  sort(A.begin(), A.end());
  sort(D.begin(), D.end(), greater<ll>());
  rep(i, D.size()) {
    if(A[i] < D[i])
      A[i] = D[i];
    else
      break;
  }
  cout << accumulate(A.begin(), A.end(), 0LL) << endl;
  return 0;
}

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

int main()
{
    ll N,Y;
    cin >> N >> Y;

    for(ll i = 0; i <= N; i++)
    {
        for(ll j = 0; j <= N-i; j++)
        {
            if(10000*i+5000*j+1000*(N-i-j) == Y)
            {
                cout << i << ' ' << j << ' ' << N-i-j << endl;
                return 0;
            }
        }
    }

    cout << -1 << ' ' << -1 << ' ' << -1 << endl;
    return 0;
}

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

int main() {
    int n,w;
	scanf("%d%d",&n,&w);
	pair<int,int> arr[n];
	int v=0;
	for(int i=0;i<n;i++){
		scanf("%d%d",&arr[i].first,&arr[i].second);
		v+=arr[i].second;
	}
	long long dp[v+1];
	dp[0]=0;
	for(int i=1;i<=v;i++)dp[i]=1000000000000000010;
	for(int i=0;i<n;i++){
		for(int j=v;j>=arr[i].second;j--){
			dp[j]=min(dp[j],dp[j-arr[i].second]+arr[i].first);
		}
	}
	for(int i=v;i>=0;i--){
		if(dp[i]<=w){
			printf("%d",i);
			break;
		}
	}
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,x,n) for(int i=(x);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=(n);i++)
using namespace std;
int main(){
	long long int n,a[100010],t=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(long long int i=n-1;0<=i;i--){
		if(a[i]==a[i-1]){
			a[i]=0;
			a[i-1]=0;
			i--;
		}
		else{
			a[i]=1;
		}
	}
	for(long long int i=0;i<n;i++){
		t+=a[i];
	}
	cout<<t<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

int main(){
    string s;
    cin>>s;
    s[5]=' ';
    s[13]=' ';
    cout<<s<<endl;
    return 0;
}

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

#define vt          vector
#define sz(x)       int((x).size())
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

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

void solve() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < sz(s) / 2; i++) {
        if (s[i] != s[sz(s) - i - 1]) ans++;
    }

    cout << ans;
}

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

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) {
        // cout << "Case " << tc << ": ";
        solve();
    }
}


Measured memory_bytes: 3596
from functools import lru_cache


@lru_cache(maxsize=None)
def search(n, l, m):
    if n == 0:
        return [[]]
    ret = []
    for i in range(l, m+1):
        for v in search(n-1, i, m):
            ret.append([i] + v)
    return ret


def main():
    n, m, q = [int(v) for v in input().split()]
    val = [[int(v) for v in input().split()] for _ in range(q)]
    ans = 0
    for arr in search(n, 1, m):
        score = 0
        for i in range(q):
            a, b, c, d = val[i]
            if arr[b-1] - arr[a-1] == c:
                score += d
        ans = max(ans, score)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 49284
# 初期入力
import sys
input = sys.stdin.readline
N = int(input())
h_aft = list(map(int, input().split()))
h_bef =[0]*N

#
count =0
while sum(h_bef) < sum(h_aft):
    flag =[0]*(N+1)
    for i in range(N):
        if h_bef[i] <h_aft[i]:
            h_bef[i] +=1
            flag[i] =1
    for i in range(N+1):
        if flag[i] ==1 and flag[i+1] ==0:
            count +=1

print(count)

Measured memory_bytes: 9180
import java.util.Arrays;
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k =  sc.nextInt();
    int n =  sc.nextInt();
    int a[] = new int[n];
    int dis[] = new int[n];

    for(int i=0;i<n;i++) {
    	a[i] = sc.nextInt();
    }

    for(int j=0;j<n-1;j++) {
    	dis[j] = a[j+1]-a[j];
    }
    dis[n-1] = k+a[0] - a[n-1];
    Arrays.sort(dis);
    System.out.println(k-dis[n-1]);
  }
}

Measured memory_bytes: 85788
fn main() {
    let input: Vec<i32> = read_vec();
    let a_price = input[0];
    let b_price = input[1];
    let ab_price = input[2];
    let a_num = input[3];
    let b_num = input[4];

    let mut min_price = 0;

    let n = std::cmp::max(a_num, b_num) + 1;
    for ab_count in 0..n {
        // ABは2倍の価格でAとB1枚ずつになる
        let mut price = ab_count * 2 * ab_price;
        if ab_count < a_num {
            // Aを買い足す
            price += (a_num - ab_count) * a_price;
        }
        if ab_count < b_num {
            // Bを買い足す
            price += (b_num - ab_count) * b_price;
        }

        if min_price == 0 {
            min_price = price;
        } else {
            min_price = std::cmp::min(min_price, price);
        }
    }

    println!("{}", min_price);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2064
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans = a*x + b*y;
    if(x < y){
    	chmin(ans, c*2*x + b*(y-x));
    	chmin(ans, c*2*y);
    }
    else{
    	chmin(ans, a*(x-y) + c*2*y);
    	chmin(ans, c*2*x);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int H,W;
  cin >> H >> W;
  
  char A;
  for(int i=0;i<H+2;i++){
    for(int j=0;j<W+2;j++){
       if(i>0&&i<=H&&j>0&&j<=W){
    	  cin >> A;
          cout << A;
  		}
        else cout << "#";
    }
    cout << endl;
  }

}



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

int main() {
	int x,y;
	cin >> x >> y;
	if (x == 2 || y == 2) {
		cout << "No" << endl;
	} else if (x == 4 || x == 6 ||x == 9 ||x == 11 ) {
		if (y == 4 || y == 6 ||y == 9 ||y == 11) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	} else if (x == 1 || x == 3 ||x == 5 ||x == 7 || x == 8 ||x == 10 ||x == 12) {
		if (y == 1 ||y == 3 ||y == 5 ||y == 7 || y == 8 ||y == 10 ||y == 12) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
}


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

#define rep(i,a,n) for(int i=a;i<n;i++)
#define all(x) (x).begin(),x.end()
#define watch(x) cout<<#x<<" = "<<x<<endl;
#define V(x) vector<x>
#define P(x,y) pair<x,y>
#define UMP(x,y) unordered_map<x,y>
#define MP(x,y) map<x,y>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef double db;
const ll mod = 1000000007;

using namespace std;

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

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

	int t;
	cin>>t;
	ll sum=0;
	
	rep(l,1,t+1){
		rep(i,1,t+1)
			rep(j,1,t+1){
				if(i==1 || j==1 || l==1)
					sum++;
				else{
					sum+=gcd(gcd(i,j),l);
				}
			}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3648
while True:
    q = int(input())
    if q == -1:
        break
    n = 1
    while True:
        if n == 1:
            x = q / 2
            n = n + 1
        if n >= 2:
            y = x
            x = y - (y**3 - q) / (3 * (y**2))
            n = n + 1
        if abs(x**3 - q) < 0.00001 * q:
            break
    print(x)


Measured memory_bytes: 5660
N = int(input())
A = list(map(int, input().split()))

kabu = 0
yen = 1000

for i in range(N-1):
  if A[i] < A[i+1]:
    buy = yen//A[i]
    kabu += buy
    yen -= buy * A[i]
  elif A[i] > A[i+1]:
    yen += kabu * A[i]
    kabu = 0

if kabu > 0:
  yen += A[-1] * kabu
  kabu = 0

print(yen)

Measured memory_bytes: 9176
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    String s = next();
    String[] ss = splitString(s);
    for(int i=0;i<ss.length;i++){
      System.out.print("x");
    }



    System.out.println();

  }
  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

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

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

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

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 23124
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DEBUG_OUTPUT_ENABLED 1
	#define DBG(X) dout << #X << "=" << (X) << '\n';
	#define SAY(X) dout << (X) << '\n';
#else
	#define DEBUG_OUTPUT_ENABLED 0
	#define DBG(X) 42;
	#define SAY(X) 42;
#endif

#define dout   ___debug::instance

using namespace std;
using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const multiset<T>& v) { for(auto el: v) cout << el << " "; return os; }
namespace ___debug {
	struct DebugStream {
		private:
			bool is_first;
		public:
			DebugStream(bool _is_first): is_first(_is_first) {}
			template<typename T> DebugStream operator<<(const T& value) const {
				assert(DEBUG_OUTPUT_ENABLED);
				if(is_first) cout << "[DBG] ";
				cout << value;
				return DebugStream(false);
			};

			template<typename T> DebugStream printArray(T* l, T* r) {
				assert(DEBUG_OUTPUT_ENABLED);
				if(is_first) cout << "[DBG] ";
				while(l != r) {
					cout << (*l);
					++l;
					if(l == r) {
						cout << '\n';
					} else {
						cout << ' ';
					}
				}
				return DebugStream(false);
			}
	};
	DebugStream instance(true);
};

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

void solve() {
	int n = fetch<int>();
	vector<int> chld(n, 0);
	for(int i = 1; i < n; ++i) {
		int v = fetch<int>() - 1;
		++chld[v];
	}
	for(auto& x: chld) cout << x << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 3988
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val ab = (1..n).map { readLine()!!.split(" ").map(String::toLong) }.sortedByDescending { it[0] + it[1] }
    print((0 until n step 2).map { ab[it][0] }.sum() - (1 until n step 2).map { ab[it][1] }.sum())
}

Measured memory_bytes: 68900
#include <stdio.h>

int main(void)
{
	double a;
	double ave = 0;
	int i;
	
	for (i = 0; i < 5; i++){
		scanf("%lf", &a);
		if (a <= 40){
			ave += 40;
		}
		else {
			ave += a;
		}
	}
	//printf("%.0f\n", ave);
	
	ave /= 5.0;
	
	printf("%.0f\n", ave);
	
	return (0);
}

Measured memory_bytes: 644
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const int MOD = 998244353;

int add(int x, int y) {
	return (x + y >= MOD ? x + y - MOD : x + y);
}

int mult(int x, int y) {
	return (x * 1LL * y) % MOD;
}

void solve() {
	int n = fetch<int>();
	auto D = fetch_vec<int>(n);
	int answ = 1;

	if(D[0] != 0) {
		cout << "0\n";
		return;
	}

	for(int i = 1; i < n; ++i) {
		if(D[i] == 0 || D[i] >= n) {
			cout << "0\n";
			return;
		}
	}

	vector<int> cnt(n, 0);

	for(auto& elem: D) {
		++cnt[elem];
	}

	for(int i = 1; i < n; ++i) {
		answ = mult(answ, cnt[D[i] - 1]);
	}

	cout << answ << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

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

int N;
int A[SIZE];

string s;

int main()
{
	cin >> s;
	rep(i,0,3){
		if(s[i]=='1')cout << '9';
		else cout << '1';
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 1e5+5;
int n, x, maks=-1;
unordered_map<int, int>arr;

int main(){
	IOS
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> x;
		arr[x+1]++;
		arr[x]++;
		arr[x-1]++;
		maks=max(maks, x+1);
	}
	int ans=-1;
	for(int i=0;i<=maks;i++){
		ans=max(ans, arr[i]);
	}	
	cout << ans << '\n';
}


Measured memory_bytes: 7348
class Dice:
    def __init__(self,t,f,r,l,b,u):
        self.t = t
        self.f = f
        self.r = r
        self.l = l
        self.b = b
        self.u = u
        self.a=[t,f,r,l,b,u]
        self.direction={'S':(4,0,2,3,5,1),'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3),'Y':(0,3,1,4,2,5)}
    def roll(self,d):
        self.a=[self.a[i] for i in self.direction[d]]
        self.t = self.a[0]
        self.f = self.a[1]
        self.r = self.a[2]
        self.l = self.a[3]
        self.b = self.a[4]
        self.u = self.a[5]
t,f,r,l,b,u=map(int,input().split())
dice1=Dice(t,f,r,l,b,u)
t,f,r,l,b,u=map(int,input().split())
dice2=Dice(t,f,r,l,b,u)
s='SSSWEEE'
w='YYYY'
ans='No'
for j in s:
    for r in w:
        if dice1.a==dice2.a:
            ans='Yes'
            break
        dice2.roll(r)
    else:
        dice2.roll(j)
        continue
    break
print(ans)



Measured memory_bytes: 5612
#include <iostream>                                                                     
                                                                                        
using namespace std;                                                                    
                                                                                        
int main (void) {                                                                       
  int m, f, r;                                                                          
  while (true) {                                                                        
    cin >> m >> f >> r;                                                                 
    int x = m+f;                                                                        
    char ans;                                                                           
    if (m+f+r==-3) {                                                                    
      break;                                                                            
    } else if(m==-1 || f==-1) {                                                         
      ans = 'F';                                                                        
    } else if (x>=80) {                                                                 
      ans = 'A';                                                                        
    } else if (x>=65) {                                                                 
      ans = 'B';                                                                        
    } else if (x>=50) {                                                                 
      ans = 'C';                                                                        
    } else if (x>=30) {                                                                 
      if (r>=50) {                                                                      
        ans = 'C';                                                                      
      } else {                                                                          
        ans = 'D';                                                                      
      }                                                                                 
    } else {                                                                            
      ans = 'F';                                                                        
    }                                                                                   
    cout << ans << endl;                                                                
  }                                                                                     
}                                                                                   

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
// types
typedef long long ll; 
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
// IO
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, n) for (int i = 1; i <= n; i++)
#define sc(n) scanf("%d", &n) 
#define sca(a, n) fo(i, n) sc(a[i])
#define pd(a) printf("%d ", a)
#define pld(a) printf("%d\n", a)
#define pda(a, n) fo(i, n) pd(a[i])
#define pl printf("\n")
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b) 
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
// math
const ll mod = 1e9+7;
template<typename T> T gcf(T a, T b) {return (b == 0) ? a : gcf(b, a%b);} 
template<typename T> T lcm(T a, T b) {return (a*b)/gcf(a, b);}
template<typename T> T sumTo(T x) {return x * (x+1) / 2;}
template<typename T> T sumSquaresTo(T x) {return x * (x+1) * (2*x+1) / 6;}
template<typename T> T ceilDiv(T n, T d) {return (n+d-1)/d;}

void solve() {
    int n, r; cin >> n >> r;
    if (n >= 10) cout << r;
    else {
        r += 100*(10-n);
        cout << r;
    }
}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
int main(){
	while(1){
		int n,q;
		cin>>n>>q;
		if(n==0&&q==0) break;
		int a[200];
		lp(i,200) a[i]=0;
		lp(i,n){
			int m;
			cin>>m;
			lp(j,m){
				int b;
				cin>>b;
				a[b]++;
			}
		}
		int max=-1,memo=0;
		lp(i,101){
			if(a[i]>max){
				max=a[i];
				memo=i;
			}
		}
		if(max<q) cout<<"0"<<endl;
		else cout<<memo<<endl;
	}

	return 0;
}


Measured memory_bytes: 2988
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int H, W, h, w;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> H >> W >> h >> w;
  cout << ((H - h) * (W - w)) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,res=0,sum=0;
string s;
vector<pair<int,int> >v;
bool cmp(pair<int,int>p1,pair<int,int>p2) {return min(p1.second,p1.first+p2.second)>min(p2.second,p2.first+p1.second);}
main()
{
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        int cnt=0,mn=0;
        for(char c:s) c=='('?cnt++:cnt--,mn=min(mn,cnt);
        v.emplace_back(cnt,mn);
        sum+=cnt;
    }
    if(sum!=0) {puts("No");exit(0);}
    sort(v.begin(),v.end(),cmp);
    for(pair<int,int>p:v){
        if(res<-p.second){
            puts("No");exit(0);
        }
        res+=p.first;
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 11576
n, m = list(map(int, input().split()))
a = set(list(int(input()) for _ in range(m)))
mod = 1000000007
 
memo = [0]*(n+1)
memo[0] = 1

for i in range(1, n+1):
    memo[i] = memo[i-1] + memo[i-2]
    if i in a:
        memo[i] = 0
print(memo[-1]%mod)

Measured memory_bytes: 504508
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        long X = long.Parse(str[0]);
        long Y = long.Parse(str[1]);
        if(X == Y || X == Y-1 || X == Y+1){
            sb.Append("Brown\n");
        }
        else{
            sb.Append("Alice\n");
        }
    }
}

Measured memory_bytes: 13140
#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 FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

int main(){
  int x, y;
  while(1){
    cin >> x >> y;
    if(x == 0 && y == 0) return 0;
    else if(x > y) cout << y << " " << x << endl;
    else cout << x << " " << y << endl;
  }
}



Measured memory_bytes: 3092