akhauriyash/Code-Regression huggingface dataset:
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	An := make([]int, N)
	Ancnt := make(map[int]int)
	for i := 0; i < N; i++ {
		An[i] = nextInt()
		Ancnt[An[i]]++
	}
	sort.Sort(sort.Reverse(sort.IntSlice(An)))
	keys := make([]int, 0)
	for k := range Ancnt {
		keys = append(keys, k)
	}
	sort.Sort(sort.Reverse(sort.IntSlice(keys)))
	var ans, index, cnt int
	ans += An[0]
	index++
	for i := 1; i < N-1; i++ {
		ans += An[index]
		cnt++
		if cnt == 2 {
			cnt = 0
			index++
		}
	}
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

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

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}

// ここから拝借
// https://shoman.hatenablog.com/entry/2020/02/25/185456
// Stackは[]intのエイリアス
type Stack []int

// Push adds an element
func (s *Stack) Push(v int) {
	*s = append(*s, v)
}

// Pop removes the top element and return it
func (s *Stack) Pop() (int, error) {
	if s.Empty() {
		return 0, fmt.Errorf("stack is empty")
	}

	v := (*s)[len(*s)-1]
	*s = (*s)[:len(*s)-1]
	return v, nil
}

// Peek returns the top value
func (s *Stack) Peek() (int, error) {
	if s.Empty() {
		return 0, fmt.Errorf("stack is empty")
	}

	return (*s)[len(*s)-1], nil
}

// Size returns the length of stack
func (s *Stack) Size() int {
	return len(*s)
}

// Empty returns true when stack is empty
func (s *Stack) Empty() bool {
	return s.Size() == 0
}

// NewStack generates stack
func NewStack() *Stack {
	s := new(Stack)
	return s
}


Measured memory_bytes: 22836
#include<iomanip>
#include <string>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
#define nin(n) int n; cin >> n;
#define kin(k) int k; cin >> k;

int main() {
  int r,d,x;
  cin >> r >> d >> x;
 long long int n=x;
  for(int i=0;i<10;i++){
    n=r*n-d;
    cout << n << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<array>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

using namespace std;

int main(){

  int n;
  cin >>n;
  
  vector<int> l = vector<int>(n,0);
  rep(i,n){
    cin >> l[i];
  }
  map<int,map<int,bool>> m;

  rep(i,n){
    if(i == l[l[i]-1]-1){
      int a=i+1,b=l[i];
      if(a > b) swap(a,b);
      m[a][b] = true;
    }
  }
  
  cout << m.size() << endl;
}




Measured memory_bytes: 7680
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	m := make([][]int, 2)
	for i := 0; i < 2; i++ {
		n := make([]int, N)
		for j := 0; j < N; j++ {
			fmt.Scan(&n[j])
		}
		m[i] = n
	}
	// 1段目
	n := make([]int, N)
	n[0] = m[0][0]
	for j := 1; j < N; j++ {
		n[j] = n[j-1] + m[0][j]
	}
	// 2段目
	s := make([]int, N)
	s[0] = m[1][0] + m[0][0]
	for i := 1; i < N; i++ {
		s[i] = max(n[i]+m[1][i], s[i-1]+m[1][i])
	}
	fmt.Println(s[N-1])
}
func max(a, b int) int {
	if b > a {
		return b
	}
	return a
}


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

using ti = tuple < int, int, int >;
using lint = long long;
using ii = pair < int, int >;
using ll = pair < lint, lint >;

int main() {
	//freopen("in.txt", "r", stdin);
	int n;
	scanf("%d", &n);
	int m = n;
	int t = 0;
	while (true) {
		t += n % 10;
		if (n / 10 == 0)break;
		n /= 10;
	}
	if (m%t == 0)puts("Yes");
	else puts("No");
	return 0;
}

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

int main()
{
   int D;
   cin >> D;
switch (D){
case 25:
cout <<"Christmas"<<endl;
break;
case 24:
cout <<"Christmas Eve"<<endl;
break;
case 23:
cout <<"Christmas Eve Eve"<<endl;
break;
case 22:
cout <<"Christmas Eve Eve Eve"<<endl;
break;
default:
break;
}
}

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

int main(void){
	vector<int> a(4);
	for(int i = 0; i < 4; ++i){
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	if(a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

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

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

    string s;
    cin >> s;
    vector<bool> A(26, false);
    rep(i, s.size()) { A[s[i] - 'a'] = true; }

    rep(i, 26) {
        if (!A[i]) {
            char ans = i + 'a';
            cout << ans << endl;
            return 0;
        }
    }

    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline
N,M = map(int,input().split())
F = [i for i in range(N)]

def find(n):
	if F[n] == n:
		return n
	ret = find(F[n])
	F[n] = ret
	return ret

def union(n,m):
	i, j = find(n), find(m)
	F[max(i,j)] = min(i,j)

for _ in range(M):
	A,B = map(int,input().split())
	A -= 1
	B -= 1
	union(A,B)

cnt = [0 for _ in range(N)]
for i in range(N):
	cnt[find(i)] += 1
print(max(cnt))

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;
LLi mod;

//vector<LLi>を出力
void PVL(vector<LLi> pvv) {
	rep(i, (int)pvv.size()-1) cout << pvv[i] SP;
	cout<< pvv[(int)pvv.size()-1] <<endl;
}
 
LLi modpow(LLi a, LLi n) {
    LLi res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){

	LLi n, p, ans;
  	string s;
	vector<LLi> v, ten(1), bak;
	cin>> n >> p >> s;
  
  	v.resize(n);
  	bak.resize(p);
  
  	rep(i, n) v[i]=(LLi)(s[i]-'0');
  
  	if(p==2){
      	ans=0;
      	rep(i, n) if(v[i]%2==0) ans+=i+1;
      	cout<< ans <<endl;
      	return 0;
    }
  
  	if(p==5){
      	ans=0;
      	rep(i, n) if(v[i]%5==0) ans+=i+1;
      	cout<< ans <<endl;
      	return 0;
    }
  
  	reverse(all(v));
      
    ten[0]=1;
  	rep(i, n-1) ten.push_back((ten[i]*10)%p);
  
  	rep(i, n) v[i]=(v[i]*ten[i])%p;
  	rep(i, n-1) v[i+1]=(v[i+1]+v[i])%p;
  
  	rep(i, n) bak[v[i]]++;
  	ans=bak[0]*(bak[0]+1)/2;
  	for(int i=1;i<p;i++) ans+=bak[i]*(bak[i]-1)/2;
  
  	//PVL(v);
  	//PVL(bak);
  	cout<< ans <<endl;

	return 0;
}

Measured memory_bytes: 4220
N, Q = map(int, input().split())
S = input()

cnt = 0
tmpS = S
i = 1
L = [0]
lapp = L.append
while i < N:
    t = tmpS[i]
    if t == 'A':
        lapp(cnt)
        i += 1
    elif t == 'C':
        if tmpS[i-1] == 'A':
            cnt += 1
        lapp(cnt)
        lapp(cnt)
        i += 2
    else:
        lapp(cnt)
        lapp(cnt)
        i += 2
for _ in range(Q):
    li, ri = map(int, input().split())
    print(L[ri - 1] - L[li - 1])
 


Measured memory_bytes: 6148
import math
a,b,x = list(map(int,input().split()))
height = x / (a**2)
margin = b-height
squaremargin = margin*a
if squaremargin <= a*b/2:
        tiltedmargin = squaremargin/a*2
        rad = math.atan(tiltedmargin/a)
else:
        tiltedmargin = squaremargin*2/b-a
        rad = math.atan(b/(a-tiltedmargin))
print(rad*(180/3.141592653589793238))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

int main() {
  int n,k;
  string s;
  cin >> n >> k;
  cin >> s;
  int ans = 0;


  vector<int> con;
  if (s[0] == '0') con.push_back(0);
  for (int i=0; i<n; ) {
    int j=i;
    while(j<n && s[i]==s[j]) j++;
    con.push_back(j-i);
    i = j;
  }
  if (s.back() == '0') con.push_back(0);

  vector<int> sum(con.size()+1, 0);
  for (int i=0; i<con.size(); i++) sum[i+1] = sum[i] + con[i];

  for (int l=0; l<sum.size(); l+=2) {
    int r = l + k*2+1;
    if (r >= sum.size()) r = sum.size()-1;
    ans = max(ans, sum[r]-sum[l]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 1336
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,e,s=0;
    
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;
    
    if(a<0){
        a=-a;
        s=a*c;
        s += d;
        s += b*e;
    }
    else{
        s=(b-a)*e;
    }
    cout << s << endl;
}



Measured memory_bytes: 3016
#include <iostream>
using namespace std;
int cnt;
int n;
int A[1000000];
int h = 1;

void insertionSort(int A[], int n,int g);
void shellSort(int A[], int n);

int main(void)
{
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> A[i];

	shellSort(A, n);

	cout << cnt << endl;

	for(int i = 0; i < n; i++)
		cout << A[i] << endl;
	return 0;
}

void insertionSort(int A[], int n, int g)
{
	for(int i = g; i < n; i++)
	{
		int v = A[i];
		int j = i - g;
		while(j >= 0 && A[j] > v)
		{
			A[j + g] = A[j];
			j = j - g;
			cnt++;
		}
		A[j + g] = v;
	}
}

void shellSort(int A[], int n)
{
	cnt = 0;
	//int m = 1;
	int G[100];
	int num = 0;
	while(1)
	{
		G[num++] = h;
		h = 3 * h + 1;
		if(h > n)
			break;
	}
	for(int i = num - 1; i >= 0; i--)
		insertionSort(A, n, G[i]);

	cout << num << endl;
	for(int i = num - 1; i >= 0; i--)
	{
		if(i != num - 1)
			cout << " ";
		cout << G[i];
	}
	cout << endl;
}

Measured memory_bytes: 5064
#include <bits/stdc++.h>
#define zcin(type, a) type a; cin >> a;
#define zcout(a, sep1, b, sep2) cout << a << sep1 << b << sep2;
#define zfor(i, b, n) for (int i = b; i < n; ++i)
#define pb push_back

using namespace std;

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

	zcin(int, n);
	zcin(int , m);
	zfor(i, 0, m)
	{
		zcin(int , x);
		n -= x;
	}
	if (n < 0)
		cout << "-1";
	else
		cout << n;

	return 0;
}


Measured memory_bytes: 3620
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] A = new int[N];
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(A);
        long h = 0;
        long w = 0;

        int count = 0;

        int idx = N-1;
        while(idx > 0){
            if(A[idx] == A[idx-1]){
                if(count == 1){
                    w = A[idx];
                    count++;
                }
                if(count == 0){
                    h = A[idx];
                    count++;
                } 
                idx--;
            }
            idx--;
        }
        System.out.println(h*w);
    }
}

Measured memory_bytes: 50812
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef pair<ll, int> P;

int main(){
	int H, W, ans = 0; cin >> H >> W;
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			char c; cin >> c;
			if(c == '#') ans++;
		}
	}
	if(ans == H+W-1) cout << "Possible" << "\n";
	else cout << "Impossible" << "\n";
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<ll> v1;
typedef vector<v1> v2;
typedef vector<v2> v3;

typedef unordered_map<ll, unordered_map<ll, ll>> graph;

const ll INF = 1ll << 50;
const ll mod = 1000000007;

ll n,m,q;
vector<tuple<ll,ll,ll,ll>> query;

ll calc(v1 &mem){
    ll ret = 0;
    for(ll i = 0;i < q;i++){
        ll a,b,c,d;
        tie(a, b, c, d) = query[i];
        if(mem[b]-mem[a] == c){
            ret += d;
        }
    }
    return ret;
}

ll dfs(v1 &mem, ll d){
    ll ans = 0;
    if(d > n){
        return calc(mem);
    }
    for(ll i = mem[d-1];i <= m;i++){
        mem[d] = i;
        ans = max(ans, dfs(mem, d+1));
    }
    return ans;
}

int main(){
    cin >> n >> m >> q;
    query = vector<tuple<ll,ll,ll,ll>>(q);
    for(ll i = 0;i < q;i++){
        ll a,b,c,d;
        cin >> a >> b >> c >> d;
        query[i] = make_tuple(a,b,c,d);

    }
    v1 mem = v1(n+1);
    mem[0] = 1;

    cout << dfs(mem, 1) << endl;


}


Measured memory_bytes: 3600
N = int(input())
A = [int(input()) for i in range(N)]
m = max(A)
mindex = A.index(m)
for i in range(N):
    if(i != mindex):
        print(m)
    else:
        pop = A.pop(i)
        print(max(A))
        A.insert(i,pop)

Measured memory_bytes: 17000
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a,j=1,b=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a;
		if(a==j)j++;
		else b++;
	}
	if(j==1)cout<<-1;
	else cout<<b;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())

using namespace std;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

using ll = long long;
constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u * v / gcd(u, v);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    int N;
    string S;
    cin >> N >> S;

    int west = 0;
    int east = count(ALL(S), 'E');
    if (S[0] == 'E')east--;
    if (S[0] == 'W')west++;

    int ans = east;

    FOR(i, 1, N) {
        if (S[i] == 'E')east--;
        ans = min(ans, west + east);
        if (S[i] == 'W')west++;
    }

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 720
from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]


def to_bin(n):
    return bin(n)[2:]


cnt = [0] * 40
for a in A:
    b = to_bin(a)
    b = b[::-1]
    for i in range(len(b)):
        if b[i] == '1':
            cnt[i] += 1

ans = 0
cnt.reverse()
k_str = to_bin(K)
while len(k_str) < 40:
    k_str = '0' + k_str

for j in range(len(cnt)):
    if k_str[j] == '1':
        tmp_ans = 0
        for k in range(len(cnt)):
            power = 39 - k
            if k <= j - 1:
                if k_str[k] == '0':
                    tmp_ans += cnt[k] * (2 ** power)
                else:
                    tmp_ans += (N - cnt[k]) * (2 ** power)
            elif k == j:
                tmp_ans += cnt[k] * (2 ** power)
            else:
                tmp_ans += max(cnt[k], N - cnt[k]) * (2 ** power)
        ans = max(ans, tmp_ans)
tmp_ans = 0
for k in range(len(cnt)):
    power = 39 - k
    if k_str[k] == '0':
        tmp_ans += cnt[k] * (2 ** power)
    else:
        tmp_ans += (N - cnt[k]) * (2 ** power)
ans = max(ans, tmp_ans)
print(ans)

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

using namespace std;

int main()
{
    int N, K;
    while (cin >> N >> K, N) {
        vector<int> a(N + 2, 0);
        vector<int> b(N + 2, 0);
        int x;
        bool white = 0;

        for (int i = 0; i < K; i++) {
            cin >> x;
            if (x == 0) {
                white = 1;
                continue;
            }
            a[x] = b[x] = 1;
        }
        for (int i = 1; i <= N; i++) {
            if (a[i] != 0) {
                a[i] += a[i-1];
            }
        }
        for (int i = N; i >= 1; i--) {
            if (b[i] != 0) {            
                b[i] += b[i+1];
            }
        }
        
        int res = 0;
        for (int i = 1; i <= N; i++) {            
            res = max(res, a[i]);
            if (white) {
                res = max(res, a[i-1] + b[i+1] + 1);
            }
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3556
#include<stdio.h>
int main()
{
    int food,i,person,item,j,f=0,a[1000]={0};
    scanf("%d%d",&person,&food);
    for(i=1;i<=person;i++)
    {
        scanf("%d",&item);
        for(j=1;j<=item;j++)
        {
            scanf("%d",&f);
            a[f]++;
        }
    }
    f=0;
    for(i=1;i<=food;i++)
    {
        if(a[i]==person)
            f++;
    }
    printf("%d\n",f);
    return 0;
    }


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<string>
#include<cstring>
#include<sstream>
using namespace std;int main(){
long long n;
cin>>n;
long long n2=sqrt(n);
for(int i=n2;i>=1;i--){
	if(n%i==0){
string b;
stringstream a;
a<<n/i;
a>>b;
cout<<b.size()<<endl;
return 0;
}
}
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,ans,c,i,d;
int main(){
	cin>>a>>b;
	d=b;
while(b!=0){
		b/=10;
		ans++;
	}
	for(i=1;i<=ans;i++){
		a*=10;
	}
	c=a+d;
	for(i=1;i<=sqrt(c);i++){
		if(i*i==c){
		cout<<"Yes";
	return 0;
	}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
#define chmax(a,b) if(b>a) a = b
#define chmin(a,b) if(b<a) a = b
typedef long long ll;

using namespace std;

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

int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int h,w; cin >> h >> w; int N = h * w;
      

      char s[h][w];
      rep(i,h)rep(j,w) cin >> s[i][j];

      rep(i,500)rep(j,500) d[i][j] = 1000;
      rep(i,500) d[i][i] = 0;
      rep(i,h)rep(j,w){
            if(s[i][j] == '#') continue;
            int num = i * w + j;
            rep(k,4){
                  int nx = i + dx[k], ny = j + dy[k];
                  if(nx < 0 || ny < 0 || nx >= h || ny >= w || s[nx][ny] == '#') continue;
                  int num2 = nx * w  + ny;
                  d[num][num2] = 1;
                  d[num2][num] = 1;
            }
      }

      
      rep(i,N)rep(j,N)rep(k,N) chmin(d[j][k], d[j][i] + d[i][k]);

      int ans = 0;
      rep(i,N)rep(j,N) if(d[i][j]< 1000) chmax(ans,d[i][j]);

      cout << ans << endl;

      return 0;
}

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

using i64 = long long;

vector<int> v;
int n;

int main() {
#ifdef HOME
	freopen("agc.in", "r", stdin);
	freopen("agc.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int ant = 0, ptr = 10000;

	cin >> n;
	v.resize(n);
	for (auto &i: v)
		cin >> i;

	for (int i = 1; i < n; ++i)
		if (v[i] == v[i - 1]) {
			v[i] = ptr--;
			ant++; }

	cout << ant << endl;

	return 0; }



Measured memory_bytes: 256
import java.util.*;

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

        for(int i=1; i<=n; i++){
            double pow = 0;
            for(int j=2; j<=n; j++){
                pow = Math.pow(i, j);
                if(pow > n){
                    break;
                }
                if(pow >= max){
                    max = pow;
                }
            }
        }

        System.out.println((int)max);
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }

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

    public static int lcm(int a, int b){
        return a * b / gcd(a, b);
    }
}


Measured memory_bytes: 21716
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  xs <- getl $ wrds toInt
  unless (all (== 0) xs) $ do
    print $ solve xs
    main

solve :: [Int] -> Int
solve [b,r,g,c,s,t] = 100 + 77 * b + 51 * r + 4 * g + (-1) * c + (-3) * k
  where
    k = t - b * 6 - r * 4 - g - c - s

toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 4084
n = int(input())
cnt = 0
A = []
for _ in range(n):
    t = sorted(input())
    t = "".join(t)
    A.append(t)

import collections
C = collections.Counter(A)
lC = list(C.values())
for i in lC:
    cnt += i * (i-1) // 2
print(cnt)

Measured memory_bytes: 68952
from collections import deque
class csr:
    def __init__(self,N,edges):
        self.start = [0]*(N+1)
        self.elist = [0]*len(edges)
        for e in edges:
            self.start[e[0]+1] += 1
        for i in range(1,N+1):
            self.start[i] += self.start[i-1] 
        counter = self.start[:]
        for e in edges:
            self.elist[counter[e[0]]] = e[1]
            counter[e[0]] += 1

class scc_graph:
    def __init__(self,N):
        self.N = N
        self.edges = []
    
    def add_edge(self,v,w):
        self.edges.append((v,w))

    def scc_ids(self):
        g = csr(self.N,self.edges)
        now_ord = group_num = 0
        visited = deque()
        low = [0]*self.N
        order = [-1]*self.N
        ids = [0]*self.N
        parent = [-1]*self.N
        for i in range(self.N):
            if order[i] == -1:
                stack = []
                stack.append(i)
                stack.append(i)
                while stack:
                    v = stack.pop()
                    if order[v] == -1:
                        low[v] = order[v] = now_ord
                        now_ord += 1
                        visited.append(v)
                        for i in range(g.start[v],g.start[v+1]):
                            to = g.elist[i]
                            if order[to] == -1:
                                stack.append(to)
                                stack.append(to)
                                parent[to] = v
                            else:
                                low[v] = min(low[v],order[to])
                    else:
                        if low[v] == order[v]:
                            while True:
                                u = visited.pop()
                                order[u] = self.N
                                ids[u] = group_num
                                if u == v:
                                    break
                            group_num += 1
                        if parent[v] != -1:
                            low[parent[v]] = min(low[parent[v]],low[v])
        for i,x in enumerate(ids):
            ids[i] = group_num-1-x

        return group_num,ids
    
    def scc(self):
        group_num,ids = self.scc_ids()
        groups = [[] for _ in range(group_num)]
        for i,x in enumerate(ids):
            groups[x].append(i)
        return groups
    
import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
N,M = map(int,readline().split())
ab = list(map(int,read().split()))
sg = scc_graph(N)

it = iter(ab)
for a,b in zip(it,it):
    sg.add_edge(a,b)

scc = sg.scc()
print(len(scc))
for group in scc:
    print(str(len(group))+' '+' '.join(map(str,group)))


Measured memory_bytes: 213520
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) 
{
    ll k, x;
    cin >>k >>x;
    
    for(int i = x -(k-1); i <= x +(k-1); i++) {
        if (i == x +(k-1)) cout <<i << endl; else cout <<i << " ";
    }
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N;
    cin >> N;
    vector<int> t(N);
    vector<int> v(N);
    for (int i = 0; i < N; i++) {
        cin >> t[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }

    int T = 0; 
    for (int i = 0; i < N; i++) {
        T += t[i];
    }
    vector<int> mae(2*T+1), ushiro(2*T+1), speed(2*T+1), M(2*T+1);
    int z = 1;
    M[0] = 0;
    for (int i = 0; i < N; i++) {
        z--;
        M[z] = min(M[z], 2*v[i]);
        z++;
        for (int j = 1; j < 2*t[i]+1; j++) {
            M[z] = 2*v[i];
            z++;
        }
    }

    mae[0] = 0;
    for (int i = 1; i < 2*T+1; i++) {
        mae[i] = min(M[i], mae[i-1] + 1);
    }
    ushiro[2*T] = 0;
    for (int i = 2*T-1; i >= 0; i--) {
        ushiro[i] = min(M[i], ushiro[i+1] + 1);
    }

    for (int i = 0; i < 2*T+1; i++) {
        speed[i] = min(mae[i], ushiro[i]);
    }

    double ans = 0;
    ans = speed[0] + speed[2*T];
    for (int i = 1; i < 2*T; i++) {
        ans += 2 * speed[i];
    }
    ans = ans / 8.0;


    printf("%32.18f\n", ans);
}

Measured memory_bytes: 4100
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
using namespace std;

void printVector(vector<int> vec) {
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << endl;
	}
}

int main() {
	int N;
	cin >> N;
	vector<int> vec;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		vec.push_back(A);
	}
	sort(vec.begin(), vec.end());
	for (int i = 0; i < N - 1; i++) {
		if (vec[i] == vec[i + 1]) {
			cout << "NO" << endl;
			return EXIT_SUCCESS;
		}
	}
	cout << "YES" << endl;
	return EXIT_SUCCESS;
}

Measured memory_bytes: 1400
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


int main(void){
    string s;
    cin >> s;
    ll k;
    cin >> k;

    ll now = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '1'){
            if(i == k - 1){
                cout << '1' << endl;
                return 0;
            }
            continue;
        }

        cout << s[i] << endl;
        return 0;
    }

}



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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

// 繰り返し二乗法
ll power(ll a, ll b){
    if(a==1)return a;
    // if(a==0)re
    ll res=1;
    while(b>0){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}

const int MAX=2100000;

ll fact[MAX], fact_inv[MAX];

void init_fact(ll n){
    fact[0]=1;
    // 階乗の計算
    for(ll i=0; i<n; i++) fact[i+1]=fact[i]*(i+1)%MOD;
    fact_inv[n]=power(fact[n], MOD-2);
    // 逆元の計算
    for(ll i=n-1;i>=0;i--) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
}

ll comb(ll n, ll r){
    return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}

ll perm(ll n, ll r){
    return (fact[n]*fact_inv[n-r])%MOD;
}

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

    ll n; cin>>n;
    vint a(n); rep(i,n) cin>>a[i];

    vpint vp;
    vp.emplace_back(0, a[0]);
    rep(i,n){
        if(a[i] > vp.back().second){
            vp.emplace_back(i, a[i]);
        }
    }
    vp.emplace_back(n, LLONG_MAX);

    vint ans(n+1, 0);
    ll cnt = 0;
    priority_queue<ll> pq;
    repr(i,vp.size()-1){
        ll x,y;
        tie(x,y) = vp[i];
        ll xx, yy;
        tie(xx, yy) = vp[i+1];
        repf(j, x, xx){
            pq.push(a[j]);
        }
        ll tmp = 0;
        tmp += cnt*(yy-y);
        while(pq.top() > y){
            tmp += pq.top() - y;
            pq.pop();
            cnt++;
        }
        ans[xx] = tmp;
    }

    ans[0] += cnt*a[0];
    while(!pq.empty()){
        ans[0] += pq.top();
        pq.pop();
    }

    rep(i,n) cout<<ans[i]<<endl;

    return 0;

}

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

int main() {
  long long n, d;
  cin >> n >> d;
  int count = 0;
  for (int i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    if (d*d >= x*x + y*y)
      count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3524
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = 0;
		if((a+b)%2==0){
			c = (a+b)/2;
		}else{
			c = ((a+b)/2)+1;
		}
		System.out.println(c);
	}
}


Measured memory_bytes: 21844
package main

import (
	"fmt"
)

func main() {
	var x int
	fmt.Scan(&x)

	ans := (x / 11) * 2
	if x%11 > 6 {
		ans += 2
	} else if x%11 > 0 {
		ans += 1
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int a,b,c,d;
cin >> a >> b >> c >> d;
int ans=0;
ans += min(a,b) + min(c,d);
cout << ans << endl;
return 0;
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  bool ans=false;
  for(int i=0;i<1e7;i++){
    if(a*i%b==c){
      ans=true;
    }
  }
  cout << (ans?"YES":"NO") << endl;
}

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

typedef pair<int,int> pii;
const int N=2e5+5;
int n,m;
int a[N],b[N],c[N];
int ta[N],tb[N];
set<pii> sc;
set<int> sa,sb;
vector<pii> ans;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	for(int i=1;i<=n;i++) scanf("%d",b+i);
	for(int i=1;i<=n;i++){
		ta[a[i]]++;
		sa.insert(a[i]);
		c[a[i]]++;
		tb[b[i]]++;
		sb.insert(b[i]);
		c[b[i]]++;
	}
	for(int i=1;i<=n;i++) if(c[i]>n){
		puts("No");
		return 0;
	}
	puts("Yes");
	for(int i=1;i<=n;i++) if(c[i]) sc.insert(make_pair(-c[i],i));
	m=n;
	while(-(sc.begin()->first)<m){
		set<int>::iterator ia=sa.begin();
		set<int>::iterator ib=sb.begin();
		if((*ia)==(*ib)){
			ia++;
			if(ia==sa.end()){
				ia--;
				ib++;
			}
		}
		int x=*ia,y=*ib;
		ta[x]--;
		tb[y]--;
		sc.erase(make_pair(-c[x],x));
		c[x]--;
		if(c[x]) sc.insert(make_pair(-c[x],x));
		sc.erase(make_pair(-c[y],y));
		c[y]--;
		if(c[y]) sc.insert(make_pair(-c[y],y));
		if(!ta[x]) sa.erase(x);
		if(!tb[y]) sb.erase(y);
		ans.push_back(make_pair(x,y));
//		printf("--%d %d\n",x,y);
		m--;
	}
	if(sc.begin()->first==-m){
		int spe=sc.begin()->second;
		sa.erase(spe);
		sb.erase(spe);
		assert(ta[spe]+tb[spe]==m);
//		printf("%d %d %d\n",spe,ta[spe],tb[spe]);
		for(int i=1;i<=ta[spe];i++){
			int x=*sb.begin();
			tb[x]--;
			if(!tb[x]) sb.erase(sb.begin());
			ans.push_back(make_pair(spe,x));
//			printf("--%d %d\n",spe,x);
		}
		for(int i=1;i<=tb[spe];i++){
			int x=*sa.begin();
			ta[x]--;
			if(!ta[x]) sa.erase(sa.begin());
			ans.push_back(make_pair(x,spe));
//			printf("--%d %d\n",x,spe);
		}
	}
	sort(ans.begin(),ans.end());
	for(int i=0;i<ans.size();i++) printf("%d ",ans[i].second);
	puts("");
	return 0;
}

Measured memory_bytes: 35620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define ff first
#define ss second
#define N 1000000007
#define INF (1ll<<60) - 1
#define M 998244353
#define rep(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define nrep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t,i,j,x,y,q,n,z,l,k,r,ans=0;
    cin>>n;
    if(n%1000) cout<<1000- n%1000;
    else cout<<0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

const bool debug = 0;

#define MAX 100100
int N,Q;
int A[MAX], X[MAX];
ll sum[MAX], sum0[MAX];

bool check(int i, int x) {
  int diff = abs( A[i] - x );
  int L = lower_bound(A,A+N,x-diff) - A;
  int idx = i - L;
  int xyz = N - 1 - i;
  if( debug ) {
    cout << "    -- i = " << i << ", x = " << x << endl;
    cout << "     idx = " << idx << ", xyz = " << xyz << endl;
  }
  return idx < xyz;
}

int calcPos(int x) {
  int L = 0, R = N;
  while( R - L ){
    int M = ( L + R ) / 2;
    if( check(M,x) ) L = M + 1LL;
    else             R = M;  
  }
  return L;
}

void compute() {
  sum[0] = sum0[0] = A[0];
  REP(i,1,N) {
    sum[i] = sum[i-1] + A[i];
    sum0[i] = sum0[i-1];
    if( i % 2 == 0 ) sum0[i] += A[i];
  }
  rep(i,Q) {
    int tL = calcPos(X[i]);
    int len = N - tL;
    int aL = tL - len;
    
    if( debug ) {
      cout << i << "-th :" << endl;
      cout << "  tL = " << tL << endl;
      cout << "  aL = " << aL << endl;
    }

    if( aL - 1 < 0 ) {
      cout << sum[N-1] - ( ( tL - 1 >= 0 ) ? sum[tL-1] : 0 ) << endl;
    } else {
      ll answer = sum[N-1] - ( ( tL - 1 >= 0 ) ? sum[tL-1] : 0 );
      if( N & 1 ) {
	answer += sum0[aL-1];
      } else {
	answer += ( sum[aL-1] - sum0[aL-1] );
      }
      cout << answer << endl;
    }
  }
}

int main() {
  cin >> N >> Q;
  rep(i,N) cin >> A[i];
  rep(i,Q) cin >> X[i];
  compute();
  return 0;
}


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

int main(){
    int N; cin >> N;
    int a[N]; rep(i,N) cin >> a[i];
    int sum = 0;
    for(int i = 0; i < N - 1; ++i){
        for(int j = i + 1; j < N; ++j){
            sum += a[i] * a[j];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
#define inf 0x3f3f3f3f
int a[15];

int main()
{
	for(int i=0;i<3;i++)
	cin>>a[i];
	sort(a,a+3);
	int x=a[0],y=a[1],z=a[2];
	int ans=0;
	while(x+2<=y)
	{
		ans++;
		x+=2;
	}
	if(x==y)
	ans+=z-y;
	else
	{
		if(z==y)
		{
			ans+=2;
		}
		else
		{
			ans+=z-y+2;
		}
	 } 
	cout<<ans;
	return 0;
}

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

#define N 500

int n, m, q;
int cnt[N][N];
int acc[N][N];

int main()
{
	cin >> n >> m >> q;
	for( int i = 0; i < m; i++ ) {
		int l, r;
		cin >> l >> r;
		l--;
		r--;
		cnt[l][r]++;
	}

	for( int i = 0; i < n; i++ ) {
		for( int j = 0; j < n; j++ ) {
			if( j == 0 ) {
				acc[i][j] = cnt[i][j];
			}
			else {
				acc[i][j] = acc[i][j - 1] + cnt[i][j];
			}
		}
	}
	for( int i = 0; i < q; i++ ) {
		int p, q;
		cin >> p >> q;
		p--;
		q--;
		int ans = 0;
		for( int j = p; j <= q; j++ ) {
			if( p <= 0 ) {
				ans += acc[j][q];
			}
			else {
				ans += acc[j][q] - acc[j][p - 1];
			}
		}

		cout << ans << endl;
	}

	return 0;
}


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

using namespace std;

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

int main() {

	ll n;
	cin>>n;

	ll t=0;
	rep(i,n){
		if((i+1)%3>0&&(i+1)%5>0)t+=i+1;
	}
	cout<<t<<endl;
	return 0;
}


Measured memory_bytes: 3632
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)

	var n int
	fmt.Fscan(r, &n)

	dist := -9999999999
	min := 9999999999
	for i := 0; i < n; i++ {
		var e int
		fmt.Fscan(r, &e)

		if dist < e-min {
			dist = e - min
		}

		if min > e {
			min = e
		}
	}

	fmt.Println(dist)
}



Measured memory_bytes: 5848
#include <stdio.h>

int main() {
    int n, r,ans;
    scanf("%d %d", &n, &r);
    if (n >= 10) {
        ans = r;
    }
    else {
        ans = r + 100 * (10 - n);
    }
    printf("%d\n", ans);
    
    return 0;
}

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

ll mod = 998244353;

ll bin_pow(ll a, ll p) {
  ll r = 1;
  while (p) {
    if (p&1) r = r*a%mod;
    a = a*a%mod;
    p >>= 1;
  }
  return r;
}

ll fac[1000000], ifac[1000000];

ll ncr(int n, int k) {
  if (n < 0 || k < 0 || k > n) return 0;
  return fac[n]*ifac[k] %mod * ifac[n-k] %mod;
}
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  ll w, h;
  cin >> w >> h;
  fac[0] = ifac[0] = 1;
  for (int i = 1; i <= w || i <= h; i++) {
    fac[i] = fac[i-1]*i%mod;
    ifac[i] = bin_pow(fac[i], mod-2);
    assert(fac[i]*ifac[i]%mod == 1);
  }
  ll ans = 0;
  for (int k = 0; k <= w && k <= h; k++) {
    (ans += (k%2 ? -1 : 1)* ncr(w,k)*ncr(h,k) %mod *fac[k]%mod *bin_pow(w+1,h-k) %mod *bin_pow(h+1,w-k)) %= mod;
  }
  cout << (ans+mod)%mod << endl;
}


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

using namespace std;

int main(void){
	map<int,int> m;
	double tmp;
	int n,i=0,t;
	cin >> n;
	for(;i<n;i++){
		cin >> tmp;
		if(tmp < 165){
			m[1]++;
		}else if(tmp < 170){
			m[2]++;
		}else if(tmp < 175){
			m[3]++;
		}else if(tmp < 180){
			m[4]++;
		}else if(tmp < 185){
			m[5]++;
		}else{
			m[6]++;
		}
	}
	for(int i=1;i<=6;i++){
		cout << i << ":";
		for(int j=0;j<m[i];j++) cout << "*";
		cout << endl;
	}
}

Measured memory_bytes: 0
import itertools

N, M = map(int, input().split())

Mod = 1000000007
Sum = 0

if abs(N - M) > 1:
    print("0")
else:

    n = 1
    m = 1

    for i in range(N):
        n = (n * (i + 1)) % Mod
    for j in range(M):
        m = (m * (j + 1)) % Mod

    Sum = (n * m) % Mod

    if N == M:
        Sum = (Sum * 2) % Mod

    print(Sum)


Measured memory_bytes: 39280
from fractions import gcd

def lcm(a,b): return a*b//gcd(a,b)

n=int(input())
a=[int(i) for i in input().split()]
l=1
mod=10**9+7
for i in range(n):
    l=lcm(l,a[i])
ans=0
for i in a:
    ans+=l//i
print(ans%mod)

Measured memory_bytes: 6108
import java.util.*;
import java.lang.Integer;

class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      
      int r = sc.nextInt();
      int D = sc.nextInt();
      int x2000 = sc.nextInt();
      
      int preX = x2000;
      int nextX = 0;
      
      for(int i = 0; i < 10; i++){
        nextX = r * preX - D;
        System.out.println(nextX);
        preX = nextX;
      }
    }
}

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

const int MAXN = 110;
const int MAXW = 1e5+10;
using ll = long long;

struct item {
    int w, v;
};
item a[MAXN];
int N, W;
ll dp[MAXN][MAXW];
int main() {
    cin >> N >> W;
    for(int i=1; i<=N; i++) {
        cin >> a[i].w >> a[i].v;
    }

    memset(dp, 0, sizeof(dp));
    for(int i=1; i<=N; i++) {
        for(int j=0; j<=W; j++) {
            if(j-a[i].w<0) dp[i][j] = dp[i-1][j];
            else dp[i][j] = max(dp[i-1][j], dp[i-1][j-a[i].w] + a[i].v);
        }
    }
    ll ans = 0;
    for(int j=1; j<=W; j++) {
        ans = max(ans, dp[N][j]);
/*
        if(ans < dp[N][j]) {
            ans = dp[N][j];
            printf("dp[%d][%d]=%d\n", N, j, ans);
        }
        */
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 86144
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
  string s; cin>>s;
  int a=0;
  if(s[0]=='+'){
    a++;
  }else{
    a--;
  }
  if(s[1]=='+'){
    a++;
  }else{
    a--;
  }if(s[2]=='+'){
    a++;
  }else{
    a--;
  }if(s[3]=='+'){
    a++;
  }else{
    a--;
  }
  cout<<a<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(n) for(int i=0;i<n;i+=1)
#define fill(c,v) memset(c,v,sizeof(c));
#define prarr(a,n) rep(n) cout<<a[i]<<" \n"[i==n-1]; 
#define sc(a) scanf("%d",&a);
#define scl(a) scanf("%lld",&a);
#define scf(a) ascanf("%f",&a);
#define ff first
#define ss second
#define pu push_back
#define inf 1000000001
#define MOD 1000000007 
#define INF 100000000000001
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,m;
    vector<pll> v;
    cin>>n>>m;
    rep(n)
    {
    	ll a,b;
    	cin>>a>>b;
    	v.push_back({a,b});
    }

    sort(v.begin(),v.end());
    ll c = 0;
    int i  = 0;

    while(i<n && m>0)
    {
    	c+=(v[i].ff)*(min({v[i].ss,m}));
    	m-=v[i].ss;
    	i++;
    }
    cout<<c<<endl;
    return 0;

}


Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <utility>
#include <set>
#include <queue>


typedef long long ll;


#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

#define pb push_back
#define all(v) v.begin(),v.end()

using namespace std;





int main()
{
    ll a; long double b; cin >> a >> b;
    long double ans = a * b;

    cout << (ll)ans << endl;
}

Measured memory_bytes: 3728