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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────


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

	vl l(n);
	for (int i = 0; i < n; ++i) cin >> l[i];
	sort(ASC(l));

	ll res = 0;

	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			int k = lower_bound(l.begin(), l.end(), l[i] + l[j]) - l.begin();
			res += max(k - (j + 1), 0);
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int f[22][(1<<22)-1],a[22][22];
int lowbit(int x)
{
	return x&(-x);
}
int count1(int num)
{
	int ret=0;
	while(num)
	{
		ret++;
		num-=lowbit(num);
	}
	return ret;
}
int main()
{
	int n,i,j,l;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			scanf("%d",&a[i][j]);
	f[0][0]=1;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<(1<<n);j++)
		{
			if(count1(j)!=i)
				continue;
			for(l=0;l<n;l++)
				if((j&(1<<l))!=0&&a[i][n-l]==1)
					f[i][j]=(f[i-1][j^(1<<l)]+f[i][j])%1000000007;
		}
	}
	printf("%d",f[n][(1<<n)-1]);
	return 0;
}

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

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> c(h);
  rep(i,h) cin >> c[i];
  int ans=0;
  rep(is, 1<<h)rep(js, 1<<w){
    int black=0;
    rep(i,h)rep(j,w){
      if(is&(1<<i)) continue;
      if(js>>j&1) continue;
      if(c[i][j] == '#')black++;
    }
    if(black==k)ans++;
  }
  cout << ans << endl;
}



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

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int n; cin >> n;
  LL a, b; cin >> a >> b;
  LL ans = 0;
  LL l, r; cin >> l;
  for (int i = 1; i < n; i++) {
    cin >> r;
    ans += min(a * (r - l), b);
    l = r;
  }
  cout << ans << '\n';
  return 0;
}


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


int main(){
    int a, b;
    string s;
    cin >> a >> b >> s;
    bool flag = false;
    int n = s.size();
    if(n == a+b+1){
        rep(i,a){
            if('0' <= s[i] && s[i] <= '9') continue;
            else flag = true;
        }
        if(s[a] != '-') flag = true;
        rep(i,b){
            if('0' <= s[a+i+1] && s[a+i+1] <= '9') continue;
            else flag = true;
        }
    }else flag = true;

    cout << (flag ? "No\n" : "Yes\n");

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
int main() {
  string namber;
  cin >> namber;
  if (namber[0] == namber[1] && namber[1] == namber[2])
    cout << "Yes" << endl;
  else if (namber[1] == namber[2] && namber[2] == namber[3])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

#define DEBUG(x) cerr << #x << ": " << x << endl

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;



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

   string S;
   cin >> S;

   deque<char> dq(S.begin(), S.end());

   bool rev = false;

   int Q;
   cin >> Q;
   FOR(q, 1, Q) {
      int t;
      cin >> t;
      if (t == 1) {
         rev = !rev;
      }
      else {
         int f;
         string c;
         cin >> f >> c;
         --f;
         f ^= rev;
         if (f == 0) {
            dq.push_front(c[0]);
         }
         else {
            dq.push_back(c[0]);
         }
      }
   }

   string res(dq.begin(), dq.end());
   if (rev)
      reverse(res.begin(), res.end());
   cout << res << '\n';

   return 0;
}


Measured memory_bytes: 1232
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		int ans = 700;
		for(int i = 0; i < s.length(); ++i)
			if(s.charAt(i) == 'o')ans += 100;
		System.out.println(ans);
	}

}


Measured memory_bytes: 22484
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int n = sc.nextInt();
        System.out.println(solution(n));
    }
    public static int solution(int n) {
        if (n < 600)
            return 8;
        if (n < 800)
            return 7;
        if (n < 1000)
            return 6;
        if (n < 1200)
            return 5;
        if (n < 1400)
            return 4;
        if (n < 1600)
            return 3;
        if (n < 1800)
            return 2;
            return 1;
    }
}

Measured memory_bytes: 35636
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t,c;
    cin>>a>>b>>c;
    a=a-b;
    c-=a;
    if(c>0) cout<<c;
    else cout<<"0";
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <tuple>
#include <cmath>
#define rep(i, n) for(i = 0; i < (n); i++)
#define int long long
using namespace std;

int n;
int a[50];
int b[50];
int c[50];

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) { cin >> a[i]; a[i]--; }
	rep(i, n) cin >> b[i];
	rep(i, n - 1) cin >> c[i];
	
	int ans = 0;
	rep(i, n) {
		ans += b[i];
	}
	
	rep(i, n - 1) {
		if (a[i] == a[i + 1] - 1) {
			ans += c[a[i]];
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    
    if ((n / 10) % 111 == 0 || (n % 1000) % 111 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

typedef long long LL;
static LL INF = (1LL<<62);
static char ALPHA[27] = "abcdefghijklmnopqrstuvwxyz";

int stepAlpha(char x, char y){
	if(x == y) return 0;
	int ret = 0;
	unsigned char u = x;
	unsigned char v = y;
	if(v >= u){
		ret = v - u;
	}
	else{
		ret = stepAlpha(x, 'z') + 1;
		ret += stepAlpha('a', y);
	}
	return ret;
}


int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	string s;
	LL K;
	cin >> s;
	cin >> K;

	int i=0;
	while(true){
		int t = stepAlpha(s[i], 'a');
		if(t <= K){
			s[i] = 'a';
			K -= t;
		}
		i++;
		if(i >= s.size()){
			break;
		}
	}
	LL r = K % 26;
	int pos = s[s.size()-1] - 'a';
	pos += r;
	if(pos > 25){
		pos -= 26;
	}
	s[s.size()-1] = ALPHA[pos];
	printf("%s\n", s.c_str());
	return 0;
}



Measured memory_bytes: 3788
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int N;
  int A;
  int B;
  cin >>N>>A>>B;
  int count=0;
  repl(i,1,N+1) {
    int a=i/10000;
    int b=i/1000-a*10;
    int c=i/100-a*100-b*10;
    int d=i/10-a*1000-b*100-c*10;
    int e=i-a*10000-b*1000-c*100-d*10;
    
    int sum=a+b+c+d+e;
     //cout<<sum<<endl;
    if((sum>=A) &&(sum<=B)) {
      count+= i;
      
      //cout<<i<<endl;
    }
  }

  cout<< count<< endl;
}
  
  
 

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

int main(){
  int x,n;
  cin >> x >> n;
  vector<int> d(102);
  rep(i,n){
    int p;
    cin >> p;
    d[p] = 1;
  }
  P ans(99999,-1);
  rep(i,102){
    if(d[i]==1) continue;
    int dif = abs(x-i);
    ans = min(ans,P(dif,i));
  }
  cout << ans.second << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<ll, ll> II;
typedef vector<II> vi;

int n, a, b, res;

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    cin >> n >> a >> b;
    FOR(i,1,n) {
        int k;
        cin >> k;
        if (!(k >= a && k < b)) res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define per(i,j,n) for(int i=(int)(j);(int)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb push_back
#define mp make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::pair;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=pair<ll,ll>;
const ll MOD=1e9+7;
const int MAX=1e5;
const ll INF=(1ll<<62)-1;
signed main(){
    string S; cin>>S;
    int ans=0;
    std::map<int,int> M;
    M[0]++;
    reverse(ALL(S));
    int sum=0,cnt=1;
    rep(i,0,S.size()){
        int X=S[i]-'0';
        sum+=X*cnt%2019;
        sum%=2019;
        ans+=M[sum];
        M[sum]++;
        cnt*=10;
        cnt%=2019;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3720
import sys
readline = sys.stdin.readline
write = sys.stdout.write
sys.setrecursionlimit(10**6)
def scc(N, G, RG):
    order = []
    used = [0]*N
    group = [None]*N
    def dfs(s):
        used[s] = 1
        for t in G[s]:
            if not used[t]:
                dfs(t)
        order.append(s)
    def rdfs(s, col):
        group[s] = col
        used[s] = 1
        for t in RG[s]:
            if not used[t]:
                rdfs(t, col)
    for i in range(N):
        if not used[i]:
            dfs(i)
    used = [0]*N
    label = 0
    for s in reversed(order):
        if not used[s]:
            rdfs(s, label)
            label += 1
    return label, group

def construct(N, G, label, group):
    G0 = [set() for i in range(label)]
    GP = [[] for i in range(label)]
    for v in range(N):
        lbs = group[v]
        for w in G[v]:
            lbt = group[w]
            if lbs == lbt:
                continue
            G0[lbs].add(lbt)
        GP[lbs].append(v)
    return G0, GP

N, M = map(int, readline().split())
G = [[] for i in range(N)]
RG = [[] for i in range(N)]
for i in range(M):
    s, d = map(int, readline().split()); s -= 1; d -= 1
    G[d].append(s)
    RG[s].append(d)

N0, group = scc(N, G, RG)
G0, GP = construct(N, G, N0, group)

deg = [0]*N0
for v in range(N0):
    for w in G0[v]:
        deg[w] += 1
MOD = 10**9 + 7
def dfs(v):
    r = 1
    for w in G0[v]:
        r = r * dfs(w) % MOD
    return r + 1
ans = 1
for v in range(N0):
    if deg[v] == 0:
        ans = ans * dfs(v) % MOD
write("%d\n" % ans)


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

int main()
{
	char a, b;
	cin >> a >> b;

	if (a == 'H')
	{
		if (b == 'H')
		{
			cout << 'H' << endl;
		}
		else
		{
			cout << 'D' << endl;
		}
	}
	else
	{
		if (b == 'H')
		{
			cout << 'D' << endl;
		}
		else
		{
			cout << 'H' << endl;
		}
	}
}


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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 100000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int MAX = 100000;
void fill_dp(int dp[MAX + 1], int len){
  int dp_[MAX + 1][6] = {};
  dp_[1][0] = 1;
  for(int i = 1; i < MAX; i++){
    for(int j = 0; j < len; j++){
      dp_[i + 1][0] = (dp_[i + 1][0] + dp_[i][j]) % MOD;
      dp_[i + 1][j + 1] = (dp_[i + 1][j + 1] + dp_[i][j]) % MOD;
    }
  }
  for(int i = 1; i <= MAX; i++){
    for(int j = 0; j < len; j++){
      dp[i] = (dp[i] + dp_[i][j]) % MOD;
    }
  }
  for(int i = len; i <= MAX; i++){
    dp[i] = (dp[i] + dp[i - len]) % MOD;
  }
}

int main(){
  int dp3[MAX + 1] = {};
  int dp5[MAX + 1] = {};
  fill_dp(dp3, 3);
  fill_dp(dp5, 5);
  string s;
  while(cin >> s && s != "#"){
    int N = s.size();
    s += "#";
    int cur = 1;
    int ans = 1;
    REP(i, N){
      if(s[i] != s[i + 1]){
        if(s[i] == '8' || s[i] == '0'){
          ans = ((ll)ans * dp3[cur]) % MOD;
        }else{
          ans = ((ll)ans * dp5[cur]) % MOD;
        }
        cur = 1;
      }else{
        cur ++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 4452
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

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



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
//const ll MOD = 1e9 + 7;
const ll MOD = 998244353;




int main() {
	int n;
	cin >> n;
	vector<pll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i].first;
		a[i].second = i;
	}

	sort(a.begin(), a.end(), greater<pll>());

	vector<vector<ll>> dp(n + 1, vector<ll>(n + 1,-INF));
	dp[0][0] = 0;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= i; j++) {
			int l = i - j;
			int r = j;

			dp[l + 1][r] = max(dp[l + 1][r], dp[l][r] + a[i].first * (a[i].second - l));
			dp[l][r + 1] = max(dp[l][r + 1], dp[l][r] + a[i].first * ((n - r - 1) - a[i].second));

		}
	}

	ll ans = 0;
	for (int i = 0; i <= n; i++) {
		int l = n - i;
		int r = i;

		ans = max(ans, dp[l][r]);

	}

	cout << ans << endl;

}


Measured memory_bytes: 34676
# -*- coding: utf-8 -*-
"""
D - XXOR
https://atcoder.jp/contests/abc117/tasks/abc117_d

"""
import sys

from collections import Counter

def solve(N, K, A):
    cnt = Counter()
    for a in A:
        for i in range(40):
            if a & 2**i:
                cnt[i] += 1

    bits = sorted([i for i in range(40) if cnt[i] < N/2], reverse=True)
    X = 0
    for b in bits:
        t = 2**b
        if X + t <= K:
            X += t
    return sum([a^X for a in A])


def __solve(N, K, A):
    cnt = Counter()
    for a in A:
        for i in range(40):
            if a & 2**i:
                cnt[i] += 1

    for i in range(K.bit_length()+1):
        if cnt[i] == 0:
            cnt[i] += 1

    bits = sorted([k for k, v in cnt.items() if v%2])
    while bits:
        ans = sum([2**b for b in bits])
        if ans <= K:
            break
        bits.pop()
    ans = sum([2**b for b in bits]) if bits else 0
    return sum([a^ans for a in A])



def main(args):
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    ans = solve(N, K, A)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 74328
/* 
 * I used # 1687007 as a refference. Thx. 
 */
#include <iostream>
#include <queue>
#include <set>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cctype>

using namespace std;

typedef long long Board;

const int N = 9;
//const int PATTERN = 181440;       // NG; 9! / 2;
const int PATTERN = 362880;         // OK; 9!
const Board GOAL = 0x123456780LL;
const int DX[] = { -1, 0, 1,  0 },
          DY[] = {  0, 1, 0, -1 };

int history[PATTERN];
queue<Board> q;

// I made this function based on one by Haruhiko Okumura(Algorithm 
// Dictionary, p116) and one by M.Hiroi(Puzzle DE Programming).
inline int change_number(long long board) {
    static int fact_table[N] = {
         40320, 5040, 720, 120, 24, 6, 2, 1, 0      // on N = 8
    };
    int value = 0;
    for (int j = 0; j < N - 1; ++j) {
        int J = static_cast<int>((board >> (j*4) & 0xF));
        value += fact_table[j] * J;
        for (int k = j + 1; k < N; ++k) {
            int K = static_cast<int>((board >> k*4) & 0xF);
            if (J < K) {
                board &= ~(0xFLL << k*4);
                board |= (static_cast<long long>(K - 1) << k*4);
            }
        }
    }
//    printf("[change_number] value = %d\n", value);
    return value;
}

inline Board swap(int numpos, int zeropos, Board board) {
    long long num = (board >> (numpos * 4)) & 0xF;
    return (board | (num << zeropos * 4)) & ~(0xFLL << numpos * 4);
}

inline int check(Board newboad, Board board) {
    int hash = change_number(newboad);
    int direction = history[change_number(board)];
    if (history[hash] == 0) {
        q.push(newboad);
        history[hash] = direction + (direction > 0 ? 1 : -1);
    }
    else if ((history[hash] > 0 && direction < 0)
            || (history[hash] < 0 && direction > 0)) {
        return abs(history[hash]) + abs(direction) - 1;
    }
    return 0;
}

void print(Board b) {
    for (int i = N - 1; i >= 0; --i) {
        printf("%2lld", (b >> (i*4) & 0xF));
    }
    printf("\n");
}

// OK
int main(void) {

    Board board = 0;
    for (int i = N - 1, num; i >= 0; --i) {
        scanf("%d", &num);
        board |= static_cast<long long>(num) << (i * 4);
    }
//    print(board);
//    print(GOAL);

    int count = 0;
    if (board == GOAL)
        goto END;

    history[change_number(board)] =  1;     // forward
    history[change_number(GOAL)]  = -1;     // backward

    q.push(board);
    q.push(GOAL);
    while (!q.empty()) {
        board = q.front();
        q.pop();

        int zeropos = -1;
        while (++zeropos < N)
            if (((board >> (zeropos * 4)) & 0xF) == 0)
                break;

        int zx = zeropos % 3, zy = zeropos / 3;
        for (int i = 0; i < 4; ++i) {
            int nx = zx + DX[i], ny = zy + DY[i];
            if (nx < 0 || nx > 2 || ny < 0 || ny > 2)
                continue;
            int numpos = nx + ny * 3;
            Board newboard = swap(numpos, zeropos, board);
            if ((count = check(newboard, board)))
                goto END;
        }
    }

END:
    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 2668
#include<iostream>

using namespace std;

typedef long long ll;

int main() {
	//どんな結果でも文句は一つもない！
	int A, B;
	cin >> A >> B;
	if (A < 10 && B < 10)cout << A * B << endl;
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#111c
import collections
import copy

n = int(input()) #2≤n≤10**5 偶数
v_list = [int(e) for e in input().split()]

#数列 a1,a2,...,anが以下の条件を満たすとき、 /\/\/\/ と呼ぶことにします。

#・各 i=1,2,...,n−2について、ai=ai+2 
#・数列に現れる数はちょうど 2種類

#偶数長の数列 v1,v2,...,vnが与えられます。 
#要素をいくつか書き換えることでこの数列を /\/\/\/ にしたいです。 書き換える要素の数は最小でいくつになるか求めてください。

#一番多く出てくる文字を求め、書き換えない数字を決める
v_list_odd = [v_list[i] for i in range(n) if i%2==1]
v_list_even = [v_list[i] for i in range(n) if i%2==0]

#print(v_list_odd)
#print(v_list_even)

c = collections.Counter(v_list_odd)
v_list_odd_counter = copy.copy(c)
if len(c)>1:
    fix_picklist_for_v_list_odd = [((c.most_common(2))[0])[0],((c.most_common(2))[0])[1],((c.most_common(2))[1])[0],((c.most_common(2))[1])[1]]
else:
    fix_char_for_v_list_odd = fix_picklist_for_v_list_odd = [((c.most_common(2))[0])[0],((c.most_common(2))[0])[1]]
    
c = collections.Counter(v_list_even)
v_list_even_counter = copy.copy(c)
if len(c)>1:
    fix_picklist_for_v_list_even = [((c.most_common(2))[0])[0],((c.most_common(2))[0])[1],((c.most_common(2))[1])[0],((c.most_common(2))[1])[1]]
else:
    fix_picklist_for_v_list_even = [((c.most_common(2))[0])[0],((c.most_common(2))[0])[1]]
    
#固定文字の決定
#1文字目が重複していなければ、両方とも出現回数最多を固定する
if fix_picklist_for_v_list_even[0] != fix_picklist_for_v_list_odd[0]:
    fix_char_for_v_list_even = fix_picklist_for_v_list_even[0]
    fix_char_for_v_list_odd = fix_picklist_for_v_list_odd[0]

#1文字目が重複している場合
#両方1文字しかなければ片方のみ
elif len(fix_picklist_for_v_list_even) == 2 and len(fix_picklist_for_v_list_odd) == 2:
    fix_char_for_v_list_even = fix_picklist_for_v_list_even[0]
    fix_char_for_v_list_odd = "!"
#片方が1文字ならば、そうでない方は2文字目を使う。
elif len(fix_picklist_for_v_list_even) == 2 and len(fix_picklist_for_v_list_odd) != 2:
    fix_char_for_v_list_even = fix_picklist_for_v_list_even[0]
    fix_char_for_v_list_odd = fix_picklist_for_v_list_odd[2]
elif len(fix_picklist_for_v_list_even) != 2 and len(fix_picklist_for_v_list_odd) == 2:
    fix_char_for_v_list_even = fix_picklist_for_v_list_even[2]
    fix_char_for_v_list_odd = fix_picklist_for_v_list_odd[0]
#両方2文字あるなら、固定パターンの合計が多い方を採用
elif fix_picklist_for_v_list_even[1] + fix_picklist_for_v_list_odd[3] > fix_picklist_for_v_list_even[3]+fix_picklist_for_v_list_odd[1]:
    fix_char_for_v_list_even = fix_picklist_for_v_list_even[0]
    fix_char_for_v_list_odd = fix_picklist_for_v_list_odd[2]
elif fix_picklist_for_v_list_even[1] + fix_picklist_for_v_list_odd[3] <= fix_picklist_for_v_list_even[3] + fix_picklist_for_v_list_odd[1]:
    fix_char_for_v_list_even = fix_picklist_for_v_list_even[2]
    fix_char_for_v_list_odd = fix_picklist_for_v_list_odd[0]

#print(fix_char_for_v_list_odd)
#print(fix_char_for_v_list_even)
        
#書き換え要素数をカウント
ans_odd = n/2 - v_list_odd_counter[fix_char_for_v_list_odd]
ans_even = n/2 - v_list_even_counter[fix_char_for_v_list_even]
print(int(ans_odd + ans_even))

Measured memory_bytes: 25168
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
const int maxn=20+10;
const int INF=int(1e9)+10;
#define LL long long
char str[maxn][maxn];
int swaped[maxn];
bool used[maxn];
bool ans;
int n,m;
bool check() {    //判断在这种(n行配对)的情况下，是否可以通过列的转换实现对称 
	memset(used,0,sizeof(used));
	for(int i=0; i<m; i++) {       //枚举任意不相等的两列，在这种(n行配对)的情况下，这两列是否相等 
		if(used[i])                //相等则说明这两列可以通过列变换形成对称 
			continue;
		for(int j=0; j<m; j++) {
			bool vis=true;
			if(i==j||used[j])
				continue;
			for(int k=0; k<n; k++) {
				if(str[k][i]==str[swaped[k]][j])
					continue;
				vis=false;
				break;
			}
			if(vis){
				used[i]=used[j]=true;
				break;
			}
		}
	}
	int cnt=0;
	int pos=-1;
	for(int i=0; i<m; i++)   //计算有多少列没配对 
		if(!used[i]) {
			cnt++;
			pos=i;
		}
	if(cnt>=2||(cnt&&(m%2==0))) //没配对数大于等于2或者（列数为奇数且没配对数等于1） 
		return false;           //的情况都说明这种（n行配对）的情况无法通过列转移实现对称 
	if(cnt==1) {                //对于列数m为奇数的情况，需要特判这一列是否可以形成对称 
		for(int i=0; i<n; i++) {
			if(str[i][pos]!=str[swaped[i]][pos])
				return false;
		}
	}
	return true;
}
void dfs(int u,int falg) {   //dfs枚举出所有的（n行配对）的情况 
	if(u==(n+1)>>1) {      //u==(n+1)/2,说明所有的行已经配对成功，这是一种（n行配对）的情况 
		if(check())       //判断列是否通过转换形成对称 
			ans=true;
		return ;
	}
	if(ans==true)
	return;
	for(int i=u; i<n; i++) {
		if(swaped[i]==-1) {
			for(int j=i+1; j<n; j++) {
				if(swaped[j]==-1) {
					swaped[i]=j;
					swaped[j]=i;
					dfs(u+1,falg);
					swaped[i]=-1;
					swaped[j]=-1;
				}
			}
			if(falg) {     //对于行数n为奇数的情况，有一行是关于没有对称行的 
				swaped[i]=i;
				dfs(u+1,false);
				swaped[i]=-1;
			}
		}
	}
}
void init() {
	memset(swaped,-1,sizeof(swaped));
	ans=false;
}
int main() {
	while(~scanf("%d %d",&n,&m)) {
		init();
		for(int i=0; i<n; i++)
			scanf("%s",str[i]);
		if(n&1)
			dfs(0,true);
		else
			dfs(0,false);
		printf("%s\n",ans?"YES":"NO");
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

template <class T> inline bool chmin(T &a, const T &b) {
  return (a > b) ? a = b, true : false;
}

template <class T> inline bool chmax(T &a, const T &b) {
  return (a < b) ? a = b, true : false;
}

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  int N;
  std::cin >> N;
  std::string S;
  std::cin >> S;

  // Main
  int firstBlack = -1;
  for (int i = 0; i < S.length(); ++i) {
    if (S[i] == '.')
      continue;
    else {
      firstBlack = i;
      break;
    }
  }
  if (firstBlack == -1) {
    std::cout << 0 << std::endl;
    return 0;
  }


  std::vector<int> sum(N + 1, 0);
  for (int i = N - 1; i >= 0; --i) {
    if (S[i] == '.')
      sum[i] = sum[i + 1] + 1;
    else
      sum[i] = sum[i + 1];
  }

  int res = IINF;
  int black = 0;
  for (int i = firstBlack; i < N; ++i) {
    if (S[i] == '#') {
      int tmp = sum[i] + black;
      chmin(res, tmp);
      black += 1;
    }
  }

  int resWhite = 0;
  for (int i = firstBlack; i < S.length(); ++i) {
    if (S[i] == '#')
      resWhite += 1;
  }

  chmin(res, resWhite);


  std::cout << res << std::endl;

  // Output

  return 0;
}


Measured memory_bytes: 1412
#include<stdio.h>
int main(void){
  int n,t[100000],m,d[2][100],i,p=0,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&t[i]);
  for(i=0;i<n;i++)sum+=t[i];
  scanf("%d",&m);
  for(i=0;i<m;i++)scanf("%d%d",&d[0][i],&d[1][i]);
  for(i=0;i<m;i++){
    p=d[1][i]-t[d[0][i]-1];
    printf("%d\n",sum+p);
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<int> X(N);
  for(int i=0;i<N;i++)cin>>X[i];
  vector<int> Y=X;
  sort(ALL(X));
  for(int i=0;i<N;i++){
    if(Y[i]<=X[N/2-1])cout<<X[N/2]<<endl;
    else cout<<X[N/2-1]<<endl;
  }
}


Measured memory_bytes: 3840
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var str = Console.ReadLine();
            var strs = str.Split(' ');
            var a = new List<string>();
            var b = new List<string>();

            for (int i = 0; i < n; i++)
            {
                if (i % 2 == 0)
                {
                    a.Add(strs[i]);
                }
                else
                {
                    b.Add(strs[i]);
                }
            }

            var tableA = new Dictionary<string, int>();
            var tableB = new Dictionary<string, int>();
            foreach (var item in a)
            {
                if (tableA.ContainsKey(item))
                {
                    tableA[item]++;
                }
                else
                {
                    tableA.Add(item, 1);
                }
            }
            foreach (var item in b)
            {
                if (tableB.ContainsKey(item))
                {
                    tableB[item]++;
                }
                else
                {
                    tableB.Add(item, 1);
                }
            }

            var sortedA = tableA.OrderByDescending(x => x.Value);
            var sortedB = tableB.OrderByDescending(x => x.Value);
            var modeA = new string[2];
            var modeB = new string[2];
            var k = 0;
            foreach (var item in sortedA)
            {
                modeA[k] = item.Key;

                k++;
                if (k == 2) break;
            }

            k = 0;
            foreach (var item in sortedB)
            {
                modeB[k] = item.Key;

                k++;
                if (k == 2) break;
            }

            var hn = n / 2;
            if (modeA[0] != modeB[0])
            {
                var output = hn - tableA[modeA[0]] + hn - tableB[modeB[0]];
                Console.WriteLine(output);
                return;
            }

            if (tableA.Count == 1 && tableB.Count == 1)
            {
                Console.WriteLine(hn);
                return;
            }

            if (tableA.Count == 1)
            {
                Console.WriteLine(hn - tableB[modeB[1]]);
            }
            if (tableB.Count == 1)
            {
                Console.WriteLine(hn - tableB[modeA[1]]);
            }

            var cA = hn - tableA[modeA[0]] + hn - tableB[modeB[1]];
            var cB = hn - tableA[modeA[1]] + hn - tableB[modeB[0]];

            Console.WriteLine(cA < cB ? cA : cB);
        }
    }
}


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

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

int main() {
  ll n;
  ll l = 1;
  cin >> n;
  vector<ll> a(n);
  ll ans = 0;
  rep(i, n) {
    cin >> a[i];
    ans += (a[i]-1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
using namespace std;

int main()
{
while(true) {
const int dx[] = {-1, 0, 0, 1}, dy[] = {0, -1, 1, 0};
char fld[16][16];
if(scanf("%s", fld + 0) == EOF)
break;
for(int i = 1; i < 12; ++i)
scanf("%s", fld + i);
int ans = 0;
for(int sx = 0; sx < 12; ++sx) {
for(int sy = 0; sy < 12; ++sy) {
if(fld[sx][sy] == '0')
continue;
queue<pair<int, int> > q;
q.push(make_pair(sx, sy));
while(!q.empty()) {
int x = q.front().first, y = q.front().second;
q.pop();
fld[x][y] = '0';
for(int i = 0; i < 4; ++i) {
int nx = x + dx[i], ny = y + dy[i];
if(nx < 0 || ny < 0 || nx >= 12 || ny >= 12)
continue;
if(fld[nx][ny] == '1') {
q.push(make_pair(nx, ny));
fld[nx][ny] = '0';
}
}
}
ans += 1;
}
}
printf("%d\n", ans);
}
return 0;
}

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


int main(){
  char b;
  cin >> b;
  if (b == 'A') cout << 'T' << endl;
  else if(b == 'T') cout << 'A' << endl;
  else if(b == 'C') cout << 'G' << endl;
  else if(b == 'G') cout << 'C' << endl; 

}


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

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n;
  cin >> n;
  vll a(n);
  map<ll, ll> ct; 
  set<ll> st;
  for(ll i = 0; i < n; i++) {
  	cin >> a[i];
  	ct[a[i]]++;
  	st.insert(a[i]);
  }
  ll ans = 0;
  for(auto it: st) {
  	ans+= (ct[it] * (ct[it] - 1))/2;
  }
  ll prev = ans;
  for(ll i = 0; i < n; i++) {
  	ans-= (ct[a[i]] * (ct[a[i]] - 1))/2;
  	ct[a[i]]--;
  	ans+= (ct[a[i]] * (ct[a[i]] - 1))/2;
  	ct[a[i]]++;
  	cout << ans << endl;
  	// cout << " " << 	ans << endl;
  	ans = prev;
  }

  return 0;
} //good night.

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll md = 998244353;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

ll bin_pow(ll x, ll n, ll mod){
	ll res = 1LL;
	for(; n > 0; n >>=1, x = x*x %mod) if(n & 1) res = res * x %mod;
	return res;
}
ll  fct[300200], inv[300200];
void init(int cmx, ll mod){
	fct[0] = fct[1] = inv[1] = 1;
	rep2(i,2,cmx+10) fct[i] = fct[i-1] * i % mod;
	inv[cmx] = bin_pow(fct[cmx], mod-2, mod);
	repr(i,cmx,1) inv[i-1] = inv[i] * i % mod;
}
ll nCk(ll n, ll k, ll mod =md) {
	ll ret =fct[n] * inv[k] % mod * inv[n-k] % mod;
	return ret;
}
int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll n, a, b, k;
	cin >>n >>a >>b >>k;
	
	init(300100, md);

	ll ans = 0;
	//ia + jb = k;
	rep(i, n+1){
		ll j = (k - i*a)/b;
			if((k-i*a)%b || j<0 || j>n) continue;
		ans += nCk(n, i, md) * nCk(n, j, md);
		ans %=md;
	}
	
	cout << ans  << "\n";
	return 0;
}


Measured memory_bytes: 4992
import java.util.*;

public class Main {

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		int max = 0;
		int maxIdx = 0;
		boolean isPlus = false;
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
			int x = Math.abs(arr[i]);
			if (x > max) {
				max = x;
				maxIdx = i + 1;
				isPlus = (arr[i] >= 0);
			}
		}
		if (maxIdx == 0) {
			System.out.println(0);
			return;
		}
		int count = 0;
		StringBuilder sb = new StringBuilder(); 
		for (int i = 1; i <= n; i++) {
			if (maxIdx != i){
				sb.append(maxIdx).append(" ").append(i).append("\n");
				count++;
			}
		}
		if (isPlus) {
			for (int i = 1; i <= n - 1; i++) {
				sb.append(i).append(" ").append(i + 1).append("\n");
				count++;
			}
		} else {
			for (int i = n; i >= 2; i--) {
				sb.append(i).append(" ").append(i - 1).append("\n");
				count++;
			}
		}
		System.out.println(count);
		System.out.print(sb);
	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
using namespace std;
using ll = long long;
int main() {
	int N, M; cin >> N >> M;
	string A[50], B[50];
	for (int i = 0; i < N; i++)
		cin >> A[i];
	for (int i = 0; i < M; i++)
		cin >> B[i];

	bool exist = true;
	for (int i = 0; i + M <= N; i++) {
		for (int j = 0; j + M <= N; j++) {
			if (A[i][j] == B[0][0]) {
				exist = true;
				for (int k = 0; k < M; k++) {
					if (A[i + k].substr(j, M) != B[k]) {
						exist = false;
						break;
					}
				}
				if (exist) {
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}
	cout << "No" << endl;

	//system("pause");
	return 0;
}


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

typedef struct Node{
	int key;
	struct Node *next;
	struct Node *prev;
}Node;

void insert(int); //?????????????´???????
void delete(Node *);  //?????????????????¢?????¬????????????????????????
Node *search(int);  //???????????????key?????????????´??????¢????????????????????¢?????¬????????????

Node *nil; //????????????????????????

main(){
	int n,tmpKey,i;
	char tmpStr[12];
	Node *p;
	
	//??????
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil->prev = nil;

	scanf("%d", &n);

	for (i = 0; i < n; i++){
		scanf("%s", tmpStr);
		if (strcmp(tmpStr, "insert") == 0){
			scanf("%d", &tmpKey);
			insert(tmpKey);
		}
		else if (strcmp(tmpStr, "delete") == 0){
			scanf("%d", &tmpKey);
			delete(search(tmpKey));
		}
		else if (strcmp(tmpStr, "deleteFirst") == 0) delete(nil->next);
		else if (strcmp(tmpStr, "deleteLast") == 0) delete(nil->prev);
	}

	for (p = nil->next; p->next != nil; p = p->next){
		printf("%d ", p->key);
	}
	printf("%d\n", p->key);

	return 0;
}

void insert(int key){ //?????????????´???????
	Node *new;
	//printf("-- insert %d\n", key);

	new = (Node *)malloc(sizeof(Node));
	new->key = key;
	new->next = nil->next;
	new->prev = nil;
	nil->next = new;
	new->next->prev = new;

}

void delete(Node *ad){  //?????????????????¢?????¬????????????????????????
	if (ad == NULL){
		//printf("-- delete NULL\n");
		return;
	}
	//printf("-- delete %p\n", ad);
	ad->prev->next = ad->next;
	ad->next->prev = ad->prev;
	free(ad);
}

Node *search(int key){  //???????????????key?????????????´??????¢????????????????????¢?????¬????????????
	Node *find;
	//printf("-- search %d\n", key);
	for (find = nil->next; find != nil; find = find->next){
		if (find->key == key) return find;
	}

	return NULL;
}

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

ll gcd(ll a,ll b)
{
	return b==0?a:gcd(b,a%b);
}
ll quickpow(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1) ans*=a;
		a*=a;b>>=1;
	}
	return ans;
}
int main()
{
	int a,b;
	cin>>a>>b;
	if(a<=8 && b<=8)
	{
		cout<<"Yay!"<<endl;
	}
	else
	{
		cout<<":("<<endl; 
	}
	return 0;	
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cstring>
#include <bits/stdc++.h>
#include <search.h>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include<stack>
#include <utility>
using namespace std;
int main()
{
map < string , int > mp;
string s;
mp["SUN"]=7;
mp["MON"]=6;
mp["TUE"]=5;
mp["WED"]=4;
mp["THU"]=3;
mp["FRI"]=2;
mp["SAT"]=1;
cin>>s;
cout<<mp[s];
return 0;
}


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

#define int         long long
#define pb          push_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 all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int x,y,a,b,c,p[100005],q[100005],r[100005],ans;
void solve(){
    cin>>x>>y>>a>>b>>c;
    rep(i,0,a) cin>>p[i];
    rep(i,0,b) cin>>q[i];
    rep(i,0,c) cin>>r[i];
    sort(p,p+a);
    reverse(p,p+a);
    sort(q,q+b);
    reverse(q,q+b);
    sort(r,r+c);
    reverse(r,r+c);
    vi v;
    rep(i,0,x) v.pb(p[i]);   
    rep(i,0,y) v.pb(q[i]);
    rep(i,0,min(x+y,c)) v.pb(r[i]);
    sort(all(v));
    reverse(all(v));
    rep(i,0,x+y) ans+=v[i];
    cout<<ans<<endl;   
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 8304
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int n=stdIn.nextInt(),t=n,s=0;
		do {
			s+=t%10;
			t/=10;
		}while(t>0);
		System.out.print(n%s!=0?"No":"Yes");
	}
}

Measured memory_bytes: 21844
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]
    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]
    def get_group(self):
        a=0
        for i in range(len(self.par)):
          if self.find(i)==i:
            a+=1
        return a
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]
ans=0
for i in range(M):
  uf=UnionFind(N)
  for j in range(M):
    if i==j:
      continue
    a,b=AB[j]
    uf.union(a-1,b-1)
  if uf.get_group()!=1:
    ans+=1
print(ans)

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

#define fr(i,b,e) for(int i=(b); i!=(e); ++i)
#define rep(i,e) for(int i=0; i!=(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long int ll;
using graph = vector<vector<int>>;
using edgedp = vector<vector<pair<int,ll>>>;
constexpr int INF=1000000;
//constexpr int MOD=998244353;
constexpr int MOD=1e9+7;
constexpr double PI=3.14159265358979323846;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    
    double radh=(h*60+m)/360;
    double radm=m/30;
    cout << setprecision(11) << sqrt(a*a+b*b-2*a*b*cos(PI*(radh-radm))) << "\n";
}   
/*
3 4 9 0
3 4 10 40
*/

Measured memory_bytes: 4196
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 502


int main() {
	int a[N][N];
	int n, k;
	int x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%d", &n);
	if (n == 1) {
		printf("1\n");
		printf("1\n");
		return 0;
	}
	k = (n + 3) / 4;
	f(i, 2*k) {
		f(j, 2*k) {
			a[i][j] = (i + j + 1) % (2*k);
			if (a[i][j] == 0)a[i][j] += (2 * k);
			if (i % 2 == 1)a[i][j] += (2 * k);
			if (a[i][j] > n)a[i][j] -= (2 * k);

		}
	}
	printf("%d\n", 2 * k);
	f(i, 2 * k) {
		f(j, 2 * k) {
			printf("%d", a[i][j]);
			if (j < ((2 * k)-1))printf(" ");
			else printf("\n");
		}
	}

	return 0;
}

Measured memory_bytes: 2048
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int alice = 0;
		int bob = 0;
		int n = stdIn.nextInt();
		Integer [] a = new Integer[n];
		for(int i = 0; i < n; i++) {
			a[i] = stdIn.nextInt();
		}
		Arrays.sort(a,Collections.reverseOrder());
		for(int i = 0; i < n; i++) {
			if(i%2==0) {
				alice+= a[i];
			}else {
				bob += a[i];
			}
		}
		System.out.println(alice - bob);
	}

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e9;
int main(){
    ll s;
    cin>>s;
    ll y2=ceil((1.0*s)/(1.0*INF));
    ll x2=y2*INF-s;
    cout<<"0 0 1000000000 1"<<" "<<x2<<" "<<y2;
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
vector<ll>g[N];
ll n,u,v,color[N],c[N],son[N],res[N]={0};
ll f(ll n){return n*(n+1)/2;}
void dfs(ll u,ll fa){
    auto tmp=c[color[u]];
    for(auto v:g[u]){
        if(v==fa) continue;
        c[color[u]]=0;
        dfs(v,u);
        son[u]+=son[v];
        res[color[u]]+=f(son[v]-c[color[u]]);
    }
    c[color[u]]=tmp+son[u];
}

int main(){
    cin>>n;
    for(ll i=1;i<=n;i++){
        cin>>color[i];
        son[i]=1;
    }
    for(ll i=1;i<n;i++){
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1,-1);
    for(int i=1;i<=n;i++){
       // cout<<color[i]<<" "<<son[i]<<" "<<c[i]<<" "<<res[i]<<endl;
        cout<<f(n)-f(n-c[i])-res[i]<<endl;
    }
    return 0;
}



Measured memory_bytes: 39376
from bisect import bisect_right
n = int(input())
l = list(map(int, input().split()))

l = sorted(l)
ans = 0
for i in range(n - 1, -1, -1):
    for j in range(i - 1, -1, -1):
        x = l[i] - l[j]
        index = bisect_right(l, x, 0, n)
        ans += max(0, j - index)

print(ans)

Measured memory_bytes: 3188
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if (a <= c && c <= b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 22612
#include <iostream>
#include <math.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  long long sum = 0;
  string check = "0";
  for(int i=0; i<pow(2, S.length() - 1); i++){
    check = "0";
    for(int j=0; j<S.length(); j++){
      check += S[j];
      if(i & 1<<j || j == S.length() - 1){
        sum += stoll(check);
        check = "0";
      }
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256