akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = list(map(int,input().split()))
# print('A:',A)
#まず、一気に数えてしまおう！
num = [0]*N
for i in range(N):
    num[A[i]-1]+=1
# print('num:',num)


#その数のペアはいくつ？
C = [0]*N
cnt=0 #１つも抜かさない時の選び出す場合の数

for i in range(N):
    if num[i]!=0 and num[i]!=1:
        dammy = (num[i] * (num[i]-1))//2
        cnt+=dammy
        C[i] = dammy
# print('cnt,C:',cnt,C)


#実際に計算していく
for i in range(N):
    # print('A[i]',A[i])
    print(cnt - C[A[i]-1] + ((num[A[i]-1]-1)*(num[A[i]-1]-2)) //2)
        # print('ue')


Measured memory_bytes: 100708
package main
 
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := scanInt()
	if N >= 1800 {
		fmt.Println(1)
	} else if N >= 1600 {
		fmt.Println(2)
	} else if N >= 1400 {
		fmt.Println(3)
	} else if N >= 1200 {
		fmt.Println(4)
	} else if N >= 1000 {
		fmt.Println(5)
	} else if N >= 800 {
		fmt.Println(6)
	} else if N >= 600 {
		fmt.Println(7)
	} else {
		fmt.Println(8)
	}
}


// --------------- BASE DEFINITIONS ---------------

var sc = bufio.NewScanner(os.Stdin)
 
func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}


Measured memory_bytes: 1808
#include<iostream>
using namespace std;
int a,b,c,n,ans=0;
int main()
{
	cin>>a>>b>>c>>n;
	for(register int i=0;i<=a;i++)
		for(register int j=0;j<=b;j++)
			for(register int k=0;k<=c;k++)
				if(i*500+j*100+k*50==n)
					ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
s = input()
alphabet_small = [chr(i) for i in range(97, 97+26)]
avail = [True for i in range(26)]
for i in s:
    for j in range(26):
        if alphabet_small[j] == i:
            avail[j] = False
            break

for i in range(26):
    if avail[i]:
        print(s+alphabet_small[i])
        exit()

for i in range(25,-1,-1):
    alpha = s[i]
    k = -1
    for j in range(26):
        if alphabet_small[j] == alpha:
            avail[j] = True
            k = j
            break
    for j in range(26):
        if j > k and avail[j]:
            print(s[:i]+alphabet_small[j])
            exit()

print(-1)

Measured memory_bytes: 38384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	as := make([]int, n+1)
	for i := 0; i < n+1; i++ {
		as[i] = nextInt()
	}
	bs := make([]int, n)
	for i := 0; i < n; i++ {
		bs[i] = nextInt()
	}

	//fmt.Println(solve(n, as, bs))
	fmt.Println(answer(n, as, bs))
}

func answer(N int, A []int, B []int) int {
	c := 0
	for i := range B {
		m := min(A[i], B[i])
		A[i] -= m
		B[i] -= m
		c += m

		m = min(A[i+1], B[i])
		A[i+1] -= m
		B[i] -= m
		c += m
	}

	return c
}

func min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,x,y,f=0;
	cin>>n;
	if(n%4==0 || n%7==0){cout<<"Yes";return 0;}
	for(x=1;x<=n/4;x++)
	  for(y=1;y<=n/7;y++)
	    if(x*4+y*7==n){
	    	f=1;break;
	    }
	if(f)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
# D
class UnionFind:
    """size(int)を指定
    root(x:int)->int:      根を求める
    unite(x,y:int):        要素をグループにまとめる 
    isSame(x,y:int)->bool: 要素同士が同じグループか判定する
    """
    # 分離はできない
    # 始め各要素は別々のグループ  
    def __init__(self, size: int):
        self.par = [-1]*size # 親の番号
        for i in range(size):
            self.par[i] = i  # はじめ すべての頂点が根
    
    def root(self, x: int) -> int:
        """根を求める"""
        if self.par[x] == x: # if root
            return x
        else:
            self.par[x] = self.root(self.par[x]) # 経路圧縮
            return self.par[x]
    
    def isSame(self, x:int, y:int)->bool:
        """x と y が同じ集合に属するか否か"""
        return self.root(x)==self.root(y)
    
    def unite(self, x:int, y:int):
        """x と y の属する集合を併合"""
        x = self.root(x)
        y = self.root(y)
        if x == y: return
        self.par[x] = y
        
# ------------------
N,K,L = map(int, input().split())
uf_k = UnionFind(N)
uf_l = UnionFind(N)
for _ in range(K):
    p,q = map(int, input().split())
    uf_k.unite(p-1, q-1)
for _ in range(L):
    r,s= map(int, input().split())
    uf_l.unite(r-1, s-1)

cnt = dict()
for i in range(N):
    r_k,r_l = uf_k.root(i), uf_l.root(i)
    if (r_k,r_l) in cnt.keys():
        cnt[(r_k,r_l)] += 1
    else:
        cnt[(r_k,r_l)] = 1

ans = []
for i in range(N):
    r_k,r_l = uf_k.root(i), uf_l.root(i)
    ans.append(cnt[(r_k,r_l)])
print(*ans, sep=" ", end="\n")

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

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

  int N = s.size();
  int min = 10000000;
  for(int i=0;i+2<N;i++) {
    string sub = s.substr(i, 3);
    int num = stoi(sub);
    if(abs(num - 753) < min) {
      min = abs(num - 753);
    }
  }

  cout << min << endl;

}

Measured memory_bytes: 256
N = int(input())
a = input().split()
b = []
for ii in range(9):
    b.append(0)
for ii in range(N):
    if int(a[ii]) < 400:
        b[0] = b[0] + 1
    elif int(a[ii]) < 800:
        b[1] = b[1] + 1
    elif int(a[ii]) < 1200:
        b[2] = b[2] + 1
    elif int(a[ii]) < 1600:
        b[3] = b[3] + 1
    elif int(a[ii]) < 2000:
        b[4] = b[4] + 1
    elif int(a[ii]) < 2400:
        b[5] = b[5] + 1
    elif int(a[ii]) < 2800:
        b[6] = b[6] + 1
    elif int(a[ii]) < 3200:
        b[7] = b[7] + 1
    else:
        b[8] = b[8] + 1
min = 0
max = 0
for ii in range(8):
    if b[ii] > 0:
        min = min + 1
        max = max + 1
max = max + b[8]
if min == 0 and b[8] >0:
    min = 1
print(str(min) + ' ' + str(max))

Measured memory_bytes: 3064
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

S = inp()
if S == 10**18:
    print(0,0,10**9,0,10**9,10**9)
else:
    x2 = a = 10**9
    y3 = b = S//a + 1
    y2 = c = 1
    x3 = d = a*b-S
    x1 = y1 = 0
    print(x1,y1,x2,y2,x3,y3)

    #print(a*b-c*d)
    #print(abs((x1-x3)*(y2-y3)-(x2-x3)*(y1-y3)))


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

#define int long long

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

string C1, C2;

signed main() {
    cin >> C1 >> C2;
    if (C1[0] == C2[2] && C1[1] == C2[1] && C1[2] == C2[0]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
INF = 10 ** 7
n, m = gets.split.map(&:to_i)
desires = []
m.times { desires << gets.split.map(&:to_i) }
desires.sort!
right = INF
ans = 0
desires.each do |a, b|
  if a >= right
    ans += 1
    right = INF
  end
  right = b if right > b
end
ans += 1
puts ans


Measured memory_bytes: 10616
N,M = map(int, input().split())
piys = [[] for _ in range(N)] 
for i in range(M):
    p, y = map(int, input().split())
    piys[p-1].append((y,i))
    
ans = [None]*M
for p,iys in enumerate(piys):
    iys.sort()
    for k,(y,i) in enumerate(iys):
        ans[i] = "%06d%06d" % (p+1,k+1)
 
for i in ans:
    print(i)

Measured memory_bytes: 35944
#include <iostream>
#include <cstring>

using namespace std;

const int N = 2e5 + 5;

int n;
int a[N], mx;
long long ans;

int main() {
	cin >> n;
	for(int i = 1; i <= n; i++) {
		scanf("%d", a + i);
	}
	mx = a[1];
	for(int i = 2; i <= n; i++) {
		if(mx < a[i]) mx = a[i];
		else {
			ans += mx - a[i];
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {

    int n, k;
    cin >> n >> k;
    int costs[n];
    int h[n];
    for (int i=0; i<n; i++) {
        cin >> h[i];
    }
    costs[0] = 0;
    for (int i=1; i<min(k, n); i++) {
        costs[i] = abs(h[i] - h[0]);
    }
    for (int i=min(k, n); i < n; i++) {
        int lst = INT_MAX;
        for (int j=0; j<k; j++) {
            lst = min(lst, costs[i-k+j]+abs(h[i]-h[i-k+j]));
        }
        costs[i] = lst;
    }
    cout << costs[n-1];

}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

ld memo[500][500][500];
ld rec(ll i,ll j,ll k,const ll& N){
	if(memo[i][j][k])return memo[i][j][k];
	if(!i&&!j&&!k)return 0;
	if(i == 1 && !j && !k)return (ld)N/i;
	ld ans = 0;
	if(i)ans += i*rec(i-1,j,k,N);
	if(j)ans += j*rec(i+1,j-1,k,N);
	if(k)ans += k*rec(i,j+1,k-1,N);
	return memo[i][j][k] = (ld)(ans+N)/(i+j+k);
}

/*
memo[i][j][k] =
((N-i-j-k)/N)*memo[i][j][k]+
(i/N)*memo[i-1][j][k]+
(j/N)*memo[i+1][j-1][k]+
(k/N)*memo[i][j+1][k-1]+
1
*/

signed main(){
	ll N;
	cin >> N;
	vl a(N);
	ll counter[3] = {0};
	FOR(i,0,N){
		ll tmp;
		cin >> tmp;
		if(tmp)counter[tmp-1]++;
	}
	cout << rec(counter[0],counter[1],counter[2],N) << endl;
}

Measured memory_bytes: 954368
s = list(input())

if s[0] == "A" and s[2:-1].count("C") == 1:
    s.remove("A")
    s.remove("C")
    
    if "".join(s).lower() == "".join(s):
        print("AC")
    else:
        print('WA')

else:
    print("WA")

Measured memory_bytes: 3060
N = int(input())
b = list(map(int, input().split()))

for i in range(N):
	if b[i] > i+1:
		print(-1)
		exit()

a = []
for i in range(N):
	for j in range(len(b)-1, -1, -1):
		if b[j] == j+1:
			a += [b.pop(j)]
			break
a.reverse()
			
if len(b) != 0:
	print(-1)
else:
	for ai in a:
		print(ai)

Measured memory_bytes: 3064
class priorityQueue {
  constructor() {
    this.keys = [];
    Number.prototype.parentIdx = function() { return Math.ceil(this/2 - 1); };
    Number.prototype.leftIdx = function() { return this * 2 + 1; };
    Number.prototype.rightIdx = function() { return this * 2 + 2; };
  }

  insert(key) { this.heapIncrease(this.keys.push(key) - 1); }

  heapIncrease(idx) {
    const keys = this.keys;
    for (let i=idx, p=idx.parentIdx(); i > 0 && keys[i] > keys[p]; i=p, p=i.parentIdx()) {
      keys[p] = [keys[i], keys[i] = keys[p]][0];
    }
  }

  extract() {
    const res = this.keys[0];
    this.keys[0] = this.keys.pop();
    this.maxHeapify(0);
    return res;
  }

  maxHeapify(idx) {
    const keys = this.keys, n = keys.length;
    const innerMaxHeapify = (i) => {
      let left, right, largest = i;
      left = i.leftIdx();
      right = i.rightIdx();
      if (left < n && Number(keys[left]) > Number(keys[largest])) largest = left;
      if (right < n && Number(keys[right]) > Number(keys[largest])) largest = right;
      if (largest != i) {
        keys[largest] = [keys[i], keys[i] = keys[largest]][0];
        innerMaxHeapify(largest);
      }
    };
    innerMaxHeapify(idx);
  }
}

(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  lines.pop();
  const queue = new priorityQueue();
  let str = '';
  lines.forEach(function(cmd) {
    switch(cmd.charAt(0)) {
      case 'i': queue.insert(Number(cmd.split(' ')[1])); break;
      case 'e': str += `${queue.extract()}\n`; break;
    }
  });
  process.stdout.write(str);
})();




Measured memory_bytes: 203996
#include<bits/stdc++.h>
using namespace std; //std::の省略のため
using ll = long long;

int main(){
    string s;
    int count = 0;

    cin >> s;

    for(int i = 0; i<3; i++){
        if(s[i] == '1') count++;
    }

    cout << count << endl;
    
}

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

const int maxn = 100001;

vector < vector < pair < int, int > > > g(maxn);
vector < int > d(maxn, 0);

void dfs (int u, int p) {
    for (auto edge: g[u]) {
        int v = edge.first, w = edge.second;
        if (v != p) {
            d[v] = ((d[u] + w) & 1);
            dfs(v, u);
        }
    }
}

signed main () {
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int u, v, w;
        cin >> u >> v >> w;
        g[u].push_back(make_pair(v, (w & 1)));
        g[v].push_back(make_pair(u, (w & 1)));
    }
    dfs(1, -1);
    for (int i = 1; i <= n; ++i)
        cout << d[i] << '\n';
}


Measured memory_bytes: 8448
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<numeric>
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
bool isDigit(char c){return '0' <= c && c <= '9';}
template<typename T> void remove(std::vector<T>& vector, unsigned int index){vector.erase(vector.begin() + index);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;


signed main(){
    SPEED;
    int n;
    cin >> n;
    vi a(n);
    rep(i,n)cin >> a[i];
    RSORT(a);
    int ans = 0;
    rep(i,n-1)
    {
        ans += a[i] - a[i+1];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
        var s = Console.ReadLine();
        var cntZero = 0;
        var cntOne = 0;
        
        for(var i = 0;i < s.Length;i++){
            if(s[i] == '0'){
                cntZero++;
            }else{
                cntOne++;
            }
        }
        Console.WriteLine(Math.Min(cntZero,cntOne) * 2);
    }
}


Measured memory_bytes: 11232
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll p=pow(10,9)+7;
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      
    x = x % p;  
   while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p; 
    } 
    return res; 
} 
 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
}
 
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll r,n,i,j;
    cin>>n>>r;
    if(n>=10)
    cout<<r;
    else
    cout<<(r+100*(10-n));
   

    
    return 0;
    
}
    

Measured memory_bytes: 256
# 全探索の気持ちが芽生える なにを全探索する？
# Qだと2^50なので無理になる、
# Nをしたいが10^10では？と無理になる
# と思いきや条件からA[i-1]<=A[i]なのでだいぶ減りそうとなる
# 計算量の見積もりがぜんぜんできないがたぶんいけるとなる
from collections import deque
n, m, q = map(int, input().split())
queries = []
for _ in range(q):
    queries.append(tuple(map(int, input().split())))

queue = deque()
for i in range(1, m + 1):
    queue.append([i])

ans = 0


def calc(arr):
    ret = 0
    for a, b, c, d in queries:
        if arr[b - 1] - arr[a - 1] == c:
            ret += d
    return ret


while len(queue):
    nex_queue = deque()
    for qq in queue:
        if len(qq) == n:
            ans = max(ans, calc(qq))
        else:
            for i in range(qq[-1], m + 1):
                nex_qq = qq[:]
                nex_qq.append(i)
                nex_queue.append(nex_qq)
    queue = nex_queue

print(ans)

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

int main()
{
	int n, m;
	int a[100];

	cin >> n >> m;

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

	for (int j = 1; j <= m; j++)
		for (int i = 0; i < n - 1; i++)
			if ((a[i] % j) > (a[i + 1] % j))
				swap(a[i], a[i + 1]);

	for (int i = 0; i < n; i++)
		cout << a[i] << endl;

	return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

	int h,w;
	char field[501][501];
	while(cin>>h>>w&&!(h==0&&w==0)){
		for(int i = 0; i < h; i++)
			for(int j = 0; j < w; j++)
				cin>>field[i][j];
		int yokoEmp[501][501];
		for(int i= 0; i < 501; i++)
			fill(yokoEmp[i],yokoEmp[i]+501,-1);
		for(int i = 0; i < h; i++){
			int maxCnt=-1;
			int cnt=0;
			for(int j = w-1; j >=0; j--){
				if(field[i][j]=='*'){
					//cnt=0;
					//maxCnt=max(maxCnt,cnt);
					//continue;
					cnt=0;
				}
				else{
					yokoEmp[i][j]=cnt;
					cnt++;
					//yokoEmp[i][j]=cnt;
					//maxCnt=max(maxCnt,cnt);
					//cnt++;
				}
			}
			//for(int j = 0; j < w; j++){
			//	if(yokoEmp[i][j]!=-1){
			//		yokoEmp[i][j]=maxCnt-yokoEmp[i][j];
			//	}
			//}
		}
		int maxS=0;
		for(int i = 0; i < h; i++){
			if(maxS>=(h-i)*w){
				break;
			}
			for(int j = 0; j < w; j++){
				if(field[i][j]=='*'){
					continue;
				}
				else{
					int idx;
					int minSize=10000000;
					for(int k = 0; i + k < h; k++){
						if(field[i+k][j]=='*'){
							idx=i+k-1;
							break;
						}
						else if(i+k==h-1){
							minSize=min(minSize,yokoEmp[i+k][j]);
							idx=i+k;
							break;
						}
						else{
							minSize=min(minSize,yokoEmp[i+k][j]);
						}
						maxS=max(maxS,(minSize+1)*(k+1));
					}
					maxS=max(maxS,(minSize+1)*(idx-i+1));
				}
			}
		}
		cout<<maxS<<endl;
	}

	return 0;
}

Measured memory_bytes: 2092
#include <stdio.h>
#define REP(i,n) for (int i=0;i<(n);++i)
const int INF = 1e9;

int N[3];

int max(int a, int b){
    if(a > b){
        return a;
    } else {
        return b;
    }
}

int main(){
    scanf("%d%d%d",&N[0],&N[1],&N[2]);
    printf("%d\n",max(N[0]*10+N[1]+N[2], max(N[0]+N[1]*10+N[2],N[0]+N[1]+N[2]*10)));
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const double EPS = 1e-9;

struct Edge{
    int to,cap,rev;
    Edge(int to,int cap,int rev) : to(to),cap(cap),rev(rev) {};
};

void add_edge(vector<vector<Edge> >& E,int from,int to,int cap){
    E[from].push_back(Edge(to,cap,E[to].size()));
    E[to].push_back(Edge(from,0,E[from].size()-1));
}

vector<int> levels(vector<vector<Edge> > &E,int s){
    vector<int> level(E.size(),-1);
    level[s] = 0;
    queue<int> Q;
    Q.push(s);
    while(!Q.empty()){
        int v = Q.front();
        Q.pop();
        for(int i=0;i<E[v].size();i++){
            Edge &e = E[v][i];
            if(e.cap > 0 and level[e.to] == -1){
                level[e.to] = level[v]+1;
                Q.push(e.to);
            }
        }
    }
    return level;
}

int good_path(vector<vector<Edge> > &E,
        vector<int> &iter,
        vector<int> &level,
        int v,int t,int f){
    if(v == t) return f;
    for(int &i=iter[v];i<E[v].size();i++){
        Edge &e = E[v][i];
        if(e.cap > 0 and level[v] < level[e.to]){
            int d = good_path(E,iter,level,e.to,t,min(f,e.cap));
            if(d > 0){
                e.cap -= d;
                E[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(vector<vector<Edge> > E,int s,int t){
    int flow = 0;
    const int INF = 1 << 30;
    while(true){
        vector<int> level = levels(E,s);
        if(level[t] < 0) return flow;
        vector<int> iter(E.size());
        int f;
        while((f=good_path(E,iter,level,s,t,INF)) > 0){
            flow += f;
        }
    }
}


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

int main(){
    while(true){
        int m,n;
        cin >> m >> n;
        if(m == 0 and n == 0) break;

        vector<int> b(m);
        vector<int> r(n);
        for(int i=0;i<m;i++) cin >> b[i];
        for(int i=0;i<n;i++) cin >> r[i];

        vector<vector<Edge> > E(n+m+2);
        // 0 is start. 1 is end.
        int start = 0,end = 1;
        int blue_start = 2,red_start=2+m;

        for(int i=0;i<m;i++){
            add_edge(E,start,blue_start+i,1);
        }
        for(int i=0;i<n;i++){
            add_edge(E,red_start+i,end,1);
        }

        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                if(gcd(b[i],r[j]) != 1){
                    add_edge(E,blue_start+i,red_start+j,1);
                }
            }
        }
        cout << max_flow(E,start,end) << endl;
    }
    return 0;
}

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

int main() {
	int n,h; cin>>n>>h;
	vector<int> a(n),b(n);
	for (int i=0; i<n; i++)
		cin>>a[i]>>b[i];
	
	sort(a.begin(),a.end(),greater<int>());
	sort(b.begin(),b.end(),greater<int>());

	int moves=0;
	for (int i=0; i<n and h>0; i++) {
		if (b[i] < a[0]) break;
		h-=b[i];
		moves++;
	}

	if (h>0) {
		moves += h/a[0];
		if (h%a[0]>0) moves++;
	}
	/*
	while (h>0) {
		h-=a[0];
		moves++;
	}
	*/
	cout << moves << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

int main() {
	fast_io;
	int n, m;
	cin >> n >> m;
	vi adj[n + 1];
	for (int i = 0;i < m;i++) {
		int u, v;
		cin >> u >> v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	queue<int> Q;
	Q.push(1);
	vi p(n + 1, -1);
	while (!Q.empty()) {
		int cur = Q.front();
		Q.pop();
		for (auto next : adj[cur])
			if (p[next] == -1) {
				p[next] = cur;
				Q.push(next);
			}
	}
	bool ans = 1;
	for (int i = 2;i <= n;i++)
		if (p[i] == -1)
			ans = 0;
	if (ans) {
		cout << "Yes\n";
		for (int i = 2;i <= n;i++)
			cout << p[i] << '\n';
	}
	else
		cout << "no\n";
}


Measured memory_bytes: 10152
#include "bits/stdc++.h"
#define double long double
#define int long long
#define mii map<int,int>
#define pii pair<int,int>
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define inf 10000000000000000 //10^16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec));
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define P pair<int,int>
using namespace std;
signed main() {
	int h,w,n,cnt=1;
	cin>>h>>w>>n;
	int tab[h][w];
	int a[n];
	rep(i,h) rep(j,w) tab[i][j]=0;
	rep(i,n) cin>>a[i];
	int cn=0;
	rep(i,h) {
		rep(j,w) {
			int k=w-j-1;
			if(cn==a[cnt-1]) {
				cnt++;
				cn=0;
			}
			if(i%2==0) {
				tab[i][j]=cnt;
			}
			else {
				tab[i][k]=cnt;
			}
			cn++;
		}
	}
	rep(i,h) {
		rep(j,w) {
			cout<<tab[i][j];
			if(j<w-1) cout<<" ";
		}
		cout<<endl;
	}
}

Measured memory_bytes: 384
import java.util.*;
 
class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    //種類
    int n = sc.nextInt();
    //買う数
    int k = sc.nextInt();
    
    int[] p = new int[n];
    
    
    
    for(int i = 0; i < n;i++){
    	p[i] = sc.nextInt();
    }
    
    if(n == 1){
      System.out.println(p[0]);
      return;
    }
    
    Arrays.sort(p);
    
    int total = 0;
    for(int i = 0; i < k;i++){
      total += p[i];
    }
    
    System.out.println(total);
    
  }
}

Measured memory_bytes: 38996
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

    private static Scanner sc;

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            int n = sc.nextInt();
            int[] a = new int[n], b = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = i + 1;
                b[i] = n - i;
            }
            sc.next();
            for (int i = 1; i < n; i++) {
                int p = sc.nextInt() - 1;
                for (int j = p; j < n; j++) a[j] += i;
                for (int j = p; j >= 0; j--) b[j] += i;
            }
            System.out.println(Arrays.toString(a).replaceAll("[\\[\\],]+", ""));
            System.out.println(Arrays.toString(b).replaceAll("[\\[\\],]+", ""));


        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

#ifdef DEBUG
#define DBG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)
#else
#define DBG(fmt, ...)
#endif

struct point{
    point(){};
    point(int _x,int _y):x(_x),y(_y){};
    int x;
    int y;
};

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;
    cin >> N;
    vector<point> points(N);
    REP(i,N){
        int x,y;
        cin >> x >> y;
        points[i] = point(x,y);
    }

    ll fact = 1;
    for(int i = 1; i <= N ; i++){
        fact *=i;
    }

    ll comb = (N * (N-1))/2;

    ll k = (fact * (N-1)) /comb;

    double total=0;
    for(int i = 0; i < N; i++){
        for(int j = i+1; j < N; j++){
            ll prod = (points[i].x - points[j].x)*(points[i].x - points[j].x) + (points[i].y - points[j].y)*(points[i].y - points[j].y);
            total += (sqrt((double)prod) * k);
        }
    }

    cout << total/fact << endl;

}


Measured memory_bytes: 3860
import java.util.*;
import java.io.*;

public class Main {

	private static void solve(){
		//Implement solution here.
		int x = ni();
		while(true) {
			boolean ok = true;
			for(int i = 2; i <= Math.pow(x, 0.5); i++) {
				if(x % i == 0) {
					ok = false;
					break;
				}
			}
			if(ok)break;
			x++;
		}
		System.out.println(x);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 23380
n = int(input())
s = list(input())
t = list(input())
ans = n
for i in range(2 * n, n - 1, -1):
    c = 1
    x = ["?"] * i
    y = ["?"] * i
    for j in range(n):
        x[j] = s[j]
        y[i - j - 1] = t[n - j - 1]
    #print(x, y)
    for j in range(i):
        if x[j] != "?" and y[j] != "?":
            if not x[j] == y[j]:
                c = 0
    if c == 1:
        ans = i
print(ans)

Measured memory_bytes: 3064
n,x = map(int,input().split())
a = list(map(int,input().split()))

Slist = sorted(a)
cnt = 0
Sum = 0

if x > sum(Slist):
  print(n-1)
  exit()
  
for i in range(n):
  Sum += Slist[i]
  if x>=Sum:
    cnt +=1
  else:
    break
print(cnt)

Measured memory_bytes: 3064
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

H,N = imn()
A = iln()

if H - sum(A) <= 0:
    print('Yes')
else:
    print('No')

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

// dp[i][500yen][num_1000yen] := remain ([i] is deleted)
int dp[128][1024];
int n;
int P[128];

void init() {
  for(int j = 0; j < 128; ++j) {
    for(int k = 0; k < 1024; ++k) {
      dp[j][k] = -1;
    }
  }
}

int main() {
  for(;;) {
    init();
    scanf("%d", &n);
    if( n == 0 ) break;
    for(int i = 0; i < n; ++i) {
      scanf("%d", &P[i]);
    }
    dp[0][0] = 0;
    for(int i = 0; i < n; ++i) {
      for(int j = n-1; j >= 0; --j) {
        for(int k = 1024 - 1; k >= 0; --k) {
          if( dp[j][k] == -1 ) continue;
          int n1kyen = (P[i] + 999) / 1000;
          int rem = dp[j][k] + n1kyen * 1000 - P[i];
          int next_num500yen = j + (rem >= 500 ? 1 : 0);
          int next_num1kyen  = k + n1kyen;
          int next_rem       = rem >= 500 ? rem - 500 : rem;
          int& next = dp[next_num500yen][next_num1kyen];
          next = std::max(next, next_rem);
        }
      }
    }    
    int res = (1 << 28);
    int max = -1;
    for(int j = n; j >= 0; --j) {
      for(int k = 0; k < 1024; ++k) {
        if( dp[j][k] == -1 ) continue;
        int cost = k * 1000 - 500 * j - dp[j][k];
        res = std::min(res, cost);
      }
      if( res != (1 << 28) ) {
        max = j;
        break;
      }
    }
    printf("%d %d\n", max, res);
  }

  return 0;
}

Measured memory_bytes: 3616
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */

    //#pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(int i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(int i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(int i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 103000;

    void solve() {
      ll n, cnt = 0;
      cin >> n;
      map<ll, ll> mp;
      ll a[n], dp[n+1];
      rep(i, n) cin >> a[i];
      dp[0] = 0;
      mp[0]++;
      rep(i, n) dp[i+1] = dp[i] + a[i], mp[dp[i+1]]++;
      trav(i, mp) cnt+= (i.snd)*(i.snd - 1)/2;
      cout << cnt << endl;
    }

    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      //te
      solve();
      return 0;
    } 

Measured memory_bytes: 15872
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <math.h>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;

signed main(void){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int x;
    cin >> x;

    int res = 0;
    for(int i = 100; i < x; i += i * 0.01){
        ++res;
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;

int sieve_size;
bitset<10000001> bs;
vector<ll> pr;

void sieve(int size) {
	sieve_size = size;
	bs.set(); bs[0] = bs[1] = 0;
  	for (ll i = 2; i <= sieve_size; ++i) if (bs[i]) {
		for (ll j = i * i; j <= sieve_size; j += i) bs[j] = 0;
		pr.push_back(i);
	}
}

ll S[100001], a[100001], b[100001];
set<ll> sq;
map<ll, int> M;

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

	int N; cin >> N;
	for (int i = 0; i < N; ++i) cin >> S[i];

	sieve(1e5);
	for (ll p : pr) sq.insert(p * p);

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		a[i] = S[i];
		for (int j = 0; pr[j] < 2222; ++j) {
			ll x = pr[j] * pr[j] * pr[j];
			while (a[i] % x == 0) a[i] /= x;
		}
		++M[a[i]];

		b[i] = 1;
		for (int j = 0; pr[j] < 2222; ++j) {
			int cnt = 0;
			while (S[i] % pr[j] == 0) S[i] /= pr[j], ++cnt;
			if (cnt % 3 == 1) b[i] *= pr[j] * pr[j];
			else if (cnt % 3 == 2) b[i] *= pr[j];
		}
		if (sq.find(S[i]) != sq.end()) b[i] *= sqrt(S[i]);
		else b[i] *= S[i] * S[i];
	}

	if (M[1]) ++ans, M[1] = 0;	
	for (int i = 0; i < N; ++i) ans += max(M[a[i]], M[b[i]]), M[a[i]] = M[b[i]] = 0;
	cout << ans << '\n';
}

Measured memory_bytes: 20236
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

class dice{
  int* me;
public:
  dice(int me_[6]){
    me = me_;
  }
  int Top(){
    return me[0];
  }
  int Back(){
    return me[4];
  }
  int Right(){
    return me[2];
  }
  void East(){
    swap(me[0], me[3]);
    swap(me[3], me[5]);
    swap(me[5], me[2]);
  }
  void West(){
    swap(me[0], me[2]);
    swap(me[2], me[5]);
    swap(me[5], me[3]);
  }
  void North(){
    swap(me[0], me[1]);
    swap(me[1], me[5]);
    swap(me[5], me[4]);
  }
  void South(){
    swap(me[0], me[4]);
    swap(me[4], me[5]);
    swap(me[5], me[1]);
  }
};


int main(){ _;
  int me[6];
  REP(i,6) cin>>me[i];
  dice d{me};
  int n;cin>>n;
  REP(i,n){
    int u,f;cin>>u>>f;
    if(d.Back()==f){
      d.South();
    }
    REP(i,3){
      if(d.Top()==f) break;
      d.East();
    }
    if(d.Top()==f){
      d.South();
    }
    REP(i,3){
      if(d.Top()==u) break;
      d.East();
    }
    cout << d.Right() << endl;
  }
}

Measured memory_bytes: 1192
#include <iostream>
#include <string>
#include <map>
#define int long long
#define INF 4e+18
using namespace std;

signed main(){
	int n,tmp = 0;
	string m;
	while(cin >> n >> m,n){
	tmp = 0;
	for(int i = 0;i < m.length();i++){
		if('0' <= m[i] && m[i] <= '9'){
			tmp = tmp * n + m[i] - '0';
		}else {
			tmp = tmp * n + 10 + m[i] - 'A';
		}
	}
	map<int,int> insuu;
	for(int i = 2;i * i <= n;i++){
		while(n % i == 0) {
			insuu[i]++;
			n /= i;
		}
	}
	if(n != 1) insuu[n]++;
	int mi = INF;
	for(auto it = insuu.begin();it != insuu.end();it++){
		int t = tmp,cnt = 0;
		while(t){
			cnt += t / it->first;
			t /= it->first;
		}
		mi = min(mi,cnt / it->second);
	}
	cout << mi << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <utility>
using namespace std;
#define INF 100000005
#define MAX 200005

int a[MAX];
int main(){
	int n, k, ans = 0, tmp, sum = 0;
	cin >> n >> k;
	fill(a, a+MAX, INF);
	for(int i = 0;i < n;i++){
		cin >> tmp;
		if(a[tmp] != INF)a[tmp]++;
		else a[tmp] = 1;
		if(a[tmp] == 1)sum++;
	}
	sort(a, a+MAX);
	for(int i = 0;i < sum-k;i++){
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
//itp1_topic3_d

#include <bits/stdc++.h>

using namespace std;


    int main(){

	int a, b, c;

	cin>>a>>b>>c;


	int cnt = 0;

	for(int x = a; x <= b; x++){

	if(c % x == 0 ) cnt++;

	}

	cout<<cnt<<endl;

	return 0;
    }


Measured memory_bytes: 3084
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

struct Node {
    int par;
    int depth;
    vector<int> list;
};

Node G[100001];

void dfs(int n, int m)
{
    G[n].depth = m;
    for(int i = 0; i < G[n].list.size(); ++i){
        dfs(G[n].list[i], m + 1);
    }
}

int main()
{
    //ios_base::sync_with_stdio(false);
    int n,id,k,c;
    scanf("%d", &n);
    
    for(int i = 0; i < n; ++i){
        G[i].par = -1;
    }
    
    for(int i = 0; i < n; ++i){
        scanf("%d%d",&id,&k);
        for(int i = 0; i < k; ++i){
            scanf("%d",&c);
            G[c].par = id;
            G[id].list.push_back(c);
        }
    }
    
    int root;
    
    for(int i = 0; i < n; ++i){
        if(G[i].par == -1){
            root = i;
            break;
        }    
    }
    
    dfs(root,0);
    
    for(int i = 0; i < n; ++i){
         printf("node %d: parent = %d, depth = %d, %s, [", i, G[i].par, G[i].depth, i == root ? "root" : G[i].list.size() == 0 ? "leaf" : "internal node");
         for(int j = 0; j < G[i].list.size(); ++j){
             if(j != 0) printf(", ");
             printf("%d",G[i].list[j]);
         }
         printf("]\n");
    }
    
}

Measured memory_bytes: 4968
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;
using VC = vector<char>;
using VB = vector<bool>;

const int MOD = 1000000007;
const int INF = 1000000000;

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

int n;
vector<vector<VD>> dp;
double srch(int i, int j, int k){
    if(dp[i][j][k] >= 0) return dp[i][j][k];
    double ret = 0.0;
    if(i) ret += srch(i-1, j, k) * i;
    if(j) ret += srch(i+1, j-1, k) * j;
    if(k) ret += srch(i, j+1, k-1) * k;
    ret += n;
    ret /= (double)(i + j + k);
    return dp[i][j][k] = ret;
}



int main(){
    cin >> n;
    //i皿に1貫 j皿に2貫 k皿に3貫の時の期待値
    dp.resize(n+1, vector<VD>(n+1, VD(n+1, -1)));
    dp[0][0][0] = 0;
    int ei = 0, zw = 0, dr = 0;
    REP(i, n){
        int a; cin >> a;
        if(a == 1) ++ei;
        else if(a == 2) ++zw;
        else ++dr;
    }
    cout << fixed << setprecision(10) << srch(ei, zw, dr) << endl;
    return 0;
}


Measured memory_bytes: 216960
def quick_mod(a,b):
    res=1
    while b!=0 :
        if b&1 :
            res*=a
        a*=a
        b>>=1
    return res

n=int(input())
cnt=0
while n!=0 :
    n//=2
    cnt+=1
print(quick_mod(2,cnt)-1)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		int A = Integer.parseInt(sc.next());

		int B = Integer.parseInt(sc.next());

		if(A>12) {
			System.out.println(B);
		}else if(A>5){
			System.out.println(B/2);
		}else{
			System.out.println(0);
		}


		
	}
}

Measured memory_bytes: 21716