akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;



int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ios_base& scientific (ios_base& str);
int a, b;
cin >> a >> b;
if(a>=13)
	cout << b;
else if(a>6 && a<12)
	cout << b/2;
else if(a==6||a==12)
	cout << b/2;
else
	cout << 0;
return 0;
}



Measured memory_bytes: 256
s = int(input())
dic = {s:1}
ap = s
ans = 1
while True:
    ans += 1
    if(ap%2==0):
        an = ap // 2
    else:
        an = 3*ap + 1
    ap = an
    if not an in dic:
        dic[an] = 1
    else:
        print(ans)
        break

Measured memory_bytes: 3060
N=int(input())
V=list(map(int,input().split()))
o={0:0}
e={0:0}
n=1
for i,v in enumerate(V):
    if n:
        if v in o.keys():
            o[v]+=1
        else:
            o[v]=1
    else:
        if v in e.keys():
            e[v]+=1
        else:
            e[v]=1
    n=1-n
O=sorted(o.items(),key=lambda x:-x[1])
E=sorted(e.items(),key=lambda x:-x[1])
if O[0][0]==E[0][0]:
    m=max(O[0][1]+E[1][1],E[0][1]+O[1][1])
else:
    m=O[0][1]+E[0][1]
print(N-m)

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b >= c){
        cout << b + c << endl;
    }else{
        cout << b + a + b + 1 << endl;
    }
    return 0;
}



Measured memory_bytes: 3556
#include<stdio.h>
#include<math.h>
typedef struct{
  double x;
  double y;
}p;
void kochcurve(int n,p value1,p value2){
  p a,b,c;
  double th=M_PI*60/180;
  if(n==0)return;

  a.x=(2.0*value1.x + 1.0*value2.x)/3.0;
  a.y=(2.0*value1.y + 1.0*value2.y)/3.0;
  b.x=(1.0*value1.x + 2.0*value2.x)/3.0;
  b.y=(1.0*value1.y + 2.0*value2.y)/3.0;
  c.x=(b.x-a.x)*cos(th)-(b.y-a.y)*sin(th)+a.x;
  c.y=(b.x-a.x)*sin(th)+(b.y-a.y)*cos(th)+a.y;
  kochcurve(n-1,value1,a);
  printf("%.8f %.8f\n",a.x,a.y);
  kochcurve(n-1,a,c);
  printf("%.8f %.8f\n",c.x,c.y);
  kochcurve(n-1,c,b);
  printf("%.8f %.8f\n",b.x,b.y);
  kochcurve(n-1,b,value2);
}
int main(){
  p value1,value2;
  int n;

  scanf("%d",&n);
  value1.x=0;
  value1.y=0;
  value2.x=100;
  value2.y=0;
  printf("%.8f %.8f\n",value1.x,value1.y);
  kochcurve(n,value1,value2);
  printf("%.8f %.8f\n",value2.x,value2.y);
  return 0;
}



Measured memory_bytes: 2092
#include <cstdio>

int	A, B;			// 整数の数 (2≦A,B≦10^9)
int K;				// 整数列


/* -----------------------------------------------------------------------------
	大域データ
----------------------------------------------------------------------------- */

int main () {

	// 整数の数の読込み
	scanf("%d %d", &A, &B);

	if((A + B) % 2 == 0) 
		printf("%d\n", (A + B) / 2);
	else 
		printf("IMPOSSIBLE\n");

	return 0;
}

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

// sum, cnt
ll dp[55][55][2600];

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

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

  dp[0][0][0]=1;
  for(int i=1;i<=n;i++){
    int v = x[i-1];
    for(int j=0;j<=2500;j++){
      for(int k=0;k<n;k++){
        dp[i][k + 1][v + j] += dp[i-1][k][j];
        dp[i][k][j] += dp[i-1][k][j];
      }
    }
  }
  ll ans = 0;
  for(int i=1;i<=n;i++){
    ans += dp[n][i][i * a];
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 56448
# import bisect
from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    h, w = list(map(int, readline().split()))

    s = [input() for _ in range(h)]
    n = [[INF] * w for _ in range(h)]

    que1 = deque()
    que2 = deque()

    if s[0][0] == "#":
        n[0][0] = 1
        que2.append((0, 0))
    else:
        n[0][0] = 0
        que1.append((0, 0))

    wall = 0
    while True:
        while que1:
            y, x = que1.popleft()
            ny = y + 1
            nx = x + 1
            if y == h - 1 and x == w - 1:
                print(wall)
                sys.exit()

            if ny < h and n[ny][x] == INF:
                if s[ny][x] == "#":
                    n[ny][x] = min(n[ny][x], wall + 1)
                    que2.append((ny, x))
                elif s[ny][x] == ".":
                    n[ny][x] = min(n[ny][x], wall)
                    que1.append((ny, x))

            if nx < w and n[y][nx] == INF:
                if s[y][nx] == "#":
                    n[y][nx] = min(n[y][nx], wall + 1)
                    que2.append((y, nx))
                elif s[y][nx] == ".":
                    n[y][nx] = min(n[y][nx], wall)
                    que1.append((y, nx))

        wall += 1
        while que2:
            y, x = que2.popleft()
            ny = y + 1
            nx = x + 1
            if y == h - 1 and x == w - 1:
                print(wall)
                sys.exit()

            if ny < h and n[ny][x] == INF:
                if s[ny][x] == "#":
                    n[ny][x] = min(n[ny][x], wall)
                    que2.append((ny, x))
                elif s[ny][x] == ".":
                    n[ny][x] = min(n[ny][x], wall)
                    que1.append((ny, x))

            if nx < w and n[y][nx] == INF:
                if s[y][nx] == "#":
                    n[y][nx] = min(n[y][nx], wall + 1)
                    que2.append((y, nx))
                elif s[y][nx] == ".":
                    n[y][nx] = min(n[y][nx], wall)
                    que1.append((y, nx))

    print(n[h - 1][w - 1])


if __name__ == '__main__':
    main()


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

struct City{
    vector<int> connections;
    int c;
    int d;

    void add(int c){
        connections.push_back(c);
    }
};

struct Pair{
    int city;
    int cost;
};

int main(void)
{
    int N, M, S;
    cin >> N >> M >> S;
    vector<City> cities(N, City());
    vector<vector<int>> costs(N, vector<int>(N, 0));
    vector<vector<int>> time(N, vector<int>(N, 0));
    for(int i=0;i<M;i++){
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--;
        v--;
        costs[u][v] = a;
        costs[v][u] = a;
        time[v][u] = b;
        time[u][v] = b;
        cities[u].add(v);
        cities[v].add(u);
    }
    for(int i=0;i<N;i++){
        int c, d;
        cin >> c >> d;
        cities[i].c = c;
        cities[i].d = d;
    }
    vector<vector<ll>> dp(N, vector<ll>(3000, LLONG_MAX));

    // solve
    queue<Pair> city_q;
    // first city
    for(int i=0;i<=min(S, 3000);i++){
        dp[0][i] = 0;
        Pair p = {0, i};
        city_q.push(p);
    }
    while(!city_q.empty()){
        Pair p = city_q.front();
        city_q.pop();
        // + cost, or go next city
        int next_cost = p.cost + cities[p.city].c;
        if(next_cost < 3000){
            ll next_time = dp[p.city][p.cost] + ll(cities[p.city].d);
            if(dp[p.city][next_cost] > next_time){
                // update
                dp[p.city][next_cost] = next_time;
                Pair next_p = {p.city, next_cost};
                city_q.push(next_p);
            }
        }
        // go next
        for(int next_city:cities[p.city].connections){
            int next_c = p.cost - costs[p.city][next_city];
            if(next_c < 0){
                continue;
            }
            ll next_time = dp[p.city][p.cost] + ll(time[p.city][next_city]);
            if(dp[next_city][next_c] > next_time){
                // update
                dp[next_city][next_c] = next_time;
                Pair next_p = {next_city, next_c};
                city_q.push(next_p);
            }
        }
    }
    for(int i=1;i<N;i++){
        ll min_time = LLONG_MAX;
        for(int j=0;j<3000;j++){
            min_time = min(min_time, dp[i][j]);
        }
        cout << min_time << endl;
    }

    return 0;
}

Measured memory_bytes: 5076
n=int(input())
a=list(map(int,input().split()))
b=sorted(a)
if n%2==1:
    b=b[1:]

if n%2==0:
    for i in range(n):
        if b[i] != (i//2)*2+1:
            print(0)
            exit()
    else:
        print(2**(n//2) % (10**9+7))

if n%2==1:
    for i in range(n-1):
        if b[i] != (i//2)*2+2:
            print(0)
            exit()
    else:
        print(2**(n//2) % (10**9+7))

Measured memory_bytes: 14008
#include <iostream>
#include <vector>
#include <map>
#include <set>

using namespace std;

const int kInf = 1e9;

int p[100010];

void Read(vector<int>& a, int n) {
	int sum = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		sum ^= a[i];
	}
	a[n+1] = sum;
}

int parent(int x) {
	if (p[x] != 0) {
		return p[x] = parent(p[x]);
	}
	return x;
}

bool unite(int x, int y) {
	x = parent(x);
	y = parent(y);

	if (x != y) {
		p[x] = y;
		return true;
	}
	return false;
}

void Solve() {
	int n;
	cin >> n;

	vector<int> a(n+2), b(n+2);
	Read(a, n);
	Read(b, n);

	vector<int> go(n+1);
	vector<bool> viz(n+1);

	map<int, vector<int>> where;
	map<int, int> seen;

	for (int i = 1; i <= n+1; ++i) {
		if (a[i] == b[i])
			continue;

		where[b[i]].push_back(i);
	}

	for (int i = 1; i <= n+1; ++i) {
		if (a[i] == b[i])
			continue;

		if (where[a[i]].empty()) {
			cout << -1 << "\n";
			return;
		}

		go[i] = where[a[i]].back();
		where[a[i]].pop_back();
	}

	if (a[n+1] == b[n+1]) {
		seen[a[n+1]] = n+1;
	}

	int ans = 0;

	for (int i = 1; i <= n+1; ++i) {
		if (!viz[i] && a[i] != b[i]) {
			int cnt = 0;
			int special = 0;
			bool merged = false;

			vector<int> now;
			for (int j = i; !viz[j]; j = go[j]) {
				// cerr << j << " ";
				++cnt;
				viz[j] = true;
				if (j == n+1)
					special += 2;
				if (seen.find(a[j]) != seen.end() && !merged) {
					special += unite(seen[a[j]], i);
				}
				now.push_back(a[j]);
			}
			// cerr << "\n";

			for (auto el : now) {
				seen[el] = i;
				// cerr << el << " ";
			}
			// cerr << "\n";

			ans += cnt + 1 - special;
		}
	}

	cout << ans << "\n";
}

int main() {
	int tests = 1;
	for (;tests; --tests) {
		Solve();
	}
}

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

int main(){
    string s;
    int k;
    vector<string> a(0);
    cin >> s >> k;
    for(int i = 0;i<s.length();i++){
        for(int j = 1;j<=k && i+j<=s.length();j++){
            a.push_back(s.substr(i,j));
        }
    }
    sort(a.begin(),a.end());
    unique(a.begin(),a.end());
    cout << a[k-1] << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

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

  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  char prev = '_';
  int cnt = 0;
  for (auto c : s) {
    if (prev != c) {
      cnt++;
    }
    prev = c;
  }
  cout << (n - max(1, cnt - 2 * k)) << endl;

  return 0;
}


Measured memory_bytes: 3756
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int[][] board = new int[3][3];
			
			for(int i = 0; i < 3; i++){
				char[] strs = sc.nextLine().toCharArray();
			
				if(strs[0] == '0'){
					return;
				}
				
				for(int j = 0; j < 3; j++){
					board[i][j] = strs[j] == 'b' ? 1 : strs[j] == 'w' ? -1 : 0;
				}
			}
			
			if((board[0][0] == 1 &&  board[0][1] == 1 && board[0][2] == 1) ||
			   (board[1][0] == 1 &&  board[1][1] == 1 && board[1][2] == 1) ||
			   (board[2][0] == 1 &&  board[2][1] == 1 && board[2][2] == 1) ||
			   (board[0][0] == 1 &&  board[1][0] == 1 && board[2][0] == 1) ||
			   (board[0][1] == 1 &&  board[1][1] == 1 && board[2][1] == 1) ||
			   (board[0][2] == 1 &&  board[1][2] == 1 && board[2][2] == 1) ||
			   (board[0][0] == 1 &&  board[1][1] == 1 && board[2][2] == 1) ||
			   (board[0][2] == 1 &&  board[1][1] == 1 && board[2][0] == 1)){
				System.out.println('b');
			}else if((board[0][0] == -1 &&  board[0][1] == -1 && board[0][2] == -1) ||
					(board[1][0] == -1 &&  board[1][1] == -1 && board[1][2] == -1) ||
					(board[2][0] == -1 &&  board[2][1] == -1 && board[2][2] == -1) ||
					(board[0][0] == -1 &&  board[1][0] == -1 && board[2][0] == -1) ||
					(board[0][1] == -1 &&  board[1][1] == -1 && board[2][1] == -1) ||
					(board[0][2] == -1 &&  board[1][2] == -1 && board[2][2] == -1) ||
					(board[0][0] == -1 &&  board[1][1] == -1 && board[2][2] == -1) ||
					(board[0][2] == -1 &&  board[1][1] == -1 && board[2][0] == -1)){
				System.out.println('w');
			}else{
				System.out.println("NA");
			}
			   
		}
		
		
		
	}
	
	
}

Measured memory_bytes: 12000
#include<stdio.h>
int main(void)
{
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a<b){
    if(c<a)
      printf("%d %d %d\n",c,a,b);
    else if(c<b)
      printf("%d %d %d\n",a,c,b);
    else
      printf("%d %d %d\n",a,b,c);
  }
  else{
    if(c<b)
      printf("%d %d %d\n",c,b,a);
    else if(c<a)
      printf("%d %d %d\n",b,c,a);
    else
      printf("%d %d %d\n",b,a,c);
  }

return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

//---------------------------------------------
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y]; //rootに素集合のサイズにマイナス符号をつけて保持
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    int p[N];
    rep(i,N) {
        cin >> p[i];
        p[i]--;
    }

    UnionFind UF(N);
    
    rep(i,M) {
        int x,y;
        cin >> x >> y;
        x--;
        y--;
        UF.merge(x,y);
    }
    int ans =0;
    rep(i,N) {
        if (UF.issame(p[i],i)) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <vector>
#include <algorithm>

std::vector<int> T;

int main(void){
    int n, c, k; scanf("%d%d%d", &n, &c, &k);
    T.resize(n); for(int i = 0; i < n; ++i) scanf("%d", &T[i]);
    std::sort(T.begin(), T.end());
    int res = 0, idx = 0;
    while(idx < n){
        int cnt = 1; // 乗る人数
        int L = T[idx] + k;
        while(cnt < c and idx + cnt < n and T[idx + cnt] <= L) cnt++;
        idx += cnt; res++;
    }
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
using namespace std;
int main(){
  while(true){
  int n,r,p,c;
  cin>>n>>r;
  if(!n&&!r)break;
  string deck;
  for(int i=0;i<n;i++)
    deck = char(48+i)+deck;
  for(int i=0;i<r;i++){
    cin>>p>>c;
    deck = deck.substr(p-1,c)+deck.substr(0,p-1)+deck.substr(p+c-1);
  }
  cout<<(deck[0]-47)<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N, K = rl()
A = rl()

plus = []
minus = []
zero = []
for a in A:
	if a > 0:
		plus.append(a)
	elif a < 0:
		minus.append(a)
	else:
		zero.append(a)

plus.sort(reverse=True)
minus.sort()

def get_positive():
	i, j = 0, 0
	ans = 1
	k = 0
	while k < K:
		if K == k+1:
			if i > len(plus)-1:
				return -1
			ans = (ans * plus[i]) % mod
			i += 1
			k += 1
		else:
			p, m = -1, -1
			if i <= len(plus)-2:
				p = plus[i]*plus[i+1]
			if j <= len(minus)-2:
				m = minus[j]*minus[j+1]
			if p < 0 and m < 0:
				return -1
			if p > m:
				ans = (ans * plus[i]) % mod
				i += 1
				k += 1
			else:
				ans = (ans * m) % mod
				j += 2
				k += 2
	return ans

def get_negative():
	plus.reverse()
	minus.reverse()
	i, j = 0, 1
	ans = minus[0]
	k = 1
	while k < K:
		if K == k+1:
			if i > len(plus)-1:
				print('ErrorX!')
				return -999
			ans = (ans * plus[i]) % mod
			i += 1
			k += 1
		else:
			p, m = float('inf'), float('inf')
			if i <= len(plus)-2:
				p = plus[i]*plus[i+1]
			if j <= len(minus)-2:
				m = minus[j]*minus[j+1]
			if p < 0 and m < 0:
				print('ErrorXX!')
				return -999
			if p < m:
				ans = (ans * plus[i]) % mod
				i += 1
				k += 1
			else:
				ans = (ans * m) % mod
				j += 2
				k += 2
	return ans

if N-K < len(zero):
	print(0)
	exit()
p = get_positive()
if p > 0:
	print(p % mod)
	exit()
if len(zero) > 0:
	print(0)
	exit()
n = get_negative()

print(n % mod)



Measured memory_bytes: 102688
#include<iostream>
#include<math.h>
#include<vector>
using namespace std;

int main(){
    int M,D,x=0;
    cin>>M>>D;
    for(int m=1;m<=M;++m){
        for(int d=1;d<=D;++d){
            int d10=d/10;
            int d1=d%10;
            if(d1>=2&&d10>=2&&d10*d1==m)x++;
        }
    }
    cout<<x<<endl;
}

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

int main(){
  int N,K;
  cin >> N >> K;
  long A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  unsigned long long score = 1;
  unsigned long long score_before = 0;
  for(int i=0;i<N;i++){
    if(i>=K){
      //score = score*A[i]/A[i-K];
      if(A[i]>A[i-K]) printf("Yes\n");
      else printf("No\n");
      //score_before = score;
    }
  }
  return 0;
}

Measured memory_bytes: 5100
# include <iostream>
# include <vector>
# include <limits>
# include <algorithm>
# include <map>
# include <string>
# include <functional>
using namespace std;

int main() {
	int n,m;
	cin >> n >> m;
	vector <int> studentx, studenty, goalx, goaly;
	int a,b;
	for (int i = 0; i < n; i++) {
		cin >> a>>b;
		studentx.emplace_back(a);
		studenty.emplace_back(b);
	}
	for (int i = 0; i < m; i++) {
		cin >> a>>b;
		goalx.emplace_back(a);
		goaly.emplace_back(b);
	}
	for (int i = 0; i < n; i++) {
		int ans = 1000000000;
		int ansp = 0;
		for (int j = m - 1; j >= 0; j--) {
			if (ans >= abs(studentx[i] - goalx[j]) + abs(studenty[i] - goaly[j])) {
				ans = abs(studentx[i] - goalx[j]) + abs(studenty[i] - goaly[j]);
				ansp = j + 1;
			}
		}
		cout << ansp << endl;
	}
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            String s = in.next();

            int ans = 0;
            for (int i = 0; i < s.length(); i++)
                ans += s.charAt(i) == '+' ? 1 : -1;
            out.println(ans);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufLength == -1)
                throw new InputMismatchException();
            if (bufPointer >= bufLength) {
                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (bufLength == -1)
                    return -1;
            }
            return buffer[bufPointer++];
        }

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

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

    }
}



Measured memory_bytes: 21460
#pragma comment(linker, "/STACK:64000000")
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define y1 stupid_cmath
#define left stupid_left
#define right stupid_right
#define vi vector <int>
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))

const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);

int n, m;

int main(){

    cin >> n >> m;

    if (abs(n - m) > 1) {
        printf("0\n");
        return 0;
    }

    int ans = 1;
    for (int i = 1; i <= n; i++) ans = 1ll * ans * i % mod;
    for (int i = 1; i <= m; i++) ans = 1ll * ans * i % mod;

    if (n == m)
        ans = 1ll * ans * 2 % mod;

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>



#ifndef DEBUG 
#define fprintf (void)
#endif 

int main(void){

	int m;
	
	scanf("%d",&m);
	
	int d[m][7];
	int i,j,k,n;
	int g,h;
	int rec1=0;
	int rec2=0;
	int ans=0;
	int top, front;
	char roll;
	char trash;
	
	for(i=0;i<m;i++){
		for(j=1;j<7;j++){	
			scanf("%d",&d[i][j]);
		}
	}
	
	for(g=0;g<m-1;g++){
		int turn[3][7]={{d[g][1],d[g][2],d[g][6],d[g][5],d[g][1],d[g][2],d[g][6]},
				 		{d[g][2],d[g][3],d[g][5],d[g][4],d[g][2],d[g][3],d[g][5]},
						{d[g][1],d[g][3],d[g][6],d[g][4],d[g][1],d[g][3],d[g][6]}
						};
	
		for(h=g+1;h<m;h++){ /*????????????h??¨???????????§????????????*/
			for(j=0;j<3;j++){
				for(k=0;k<4;k++){
					if(d[h][1]==turn[j][k] && d[h][2]==turn[j][k+1]){
						rec1=1;
						fprintf(stdout,"%d,%d:%d %d %d ,%d&%d\n",j,k,turn[j][k],turn[j][k+1],turn[j][k+3],rec1,rec2);
					}
					if(d[h][1]==turn[j][k]&&d[h][2]==turn[j][k+3]){
						rec2=1;
						fprintf(stdout,"%d,%d:%d %d %d ,%d&%d\n",j,k,turn[j][k],turn[j][k+1],turn[j][k+3],rec1,rec2);
					}
					if(rec1!=0||rec2!=0){
						if(j==0){
							if(rec1){
								if(d[h][3]==d[g][3] && d[h][4]==d[g][4] && d[h][6]==turn[j][k+2] && d[h][5]==turn[j][k+3]){
									ans=1;
								}
							}
							if(rec2){
								if(d[h][3]==d[g][4] && d[h][4]==d[g][3] && d[h][6]==turn[j][k+2] && d[h][5]==turn[j][k+1]){
									ans=1;
								}
							}
						}else if(j==1){
							fprintf(stdout,"in route \n");
							if(rec1){
								if(d[h][3]==d[g][1] && d[h][4]==d[g][6] && d[h][6]==turn[j][k+2] && d[h][5]==turn[j][k+3]){
									ans=1;
								}
							}
							if(rec2){
								if(d[h][3]==d[g][6] && d[h][4]==d[g][1] && d[h][6]==turn[j][k+2] && d[h][5]==turn[j][k+1]){
									ans=1;
								}
							}
						}else if(j==2){
							if(rec1){
								if(d[h][3]==d[g][5] && d[h][4]==d[g][2] && d[h][6]==turn[j][k+2] && d[h][5]==turn[j][k+3]){
									ans=1;
								}
							}
							if(rec2){
								if(d[h][3]==d[g][2] && d[h][4]==d[g][5] && d[h][6]==turn[j][k+2] && d[h][5]==turn[j][k+1]){
									ans=1;
								}
							}
						}
					}
					rec1=0;
					rec2=0;
					if(ans==1){
						break;
					}
				}
				if(ans==1){
					break;
				}
			}
			if(ans==1){
				break;
			}
		}
		if(ans==1){
			break;
		}
	
	}
	if(ans==0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return 0;

}

Measured memory_bytes: 2684
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try { st = new StringTokenizer(br.readLine()); }
                catch (IOException e) { e.printStackTrace(); }
            }
            return st.nextToken();
        }
        int nextInt() { return Integer.parseInt(next()); }
        long nextLong() { return Long.parseLong(next()); }
        double nextDouble() { return Double.parseDouble(next()); }
        String nextLine() { String str = "";
            try { str = br.readLine(); }
            catch (IOException e) { e.printStackTrace(); }
            return str;
        }
    }

    public static void main(String[] args)
    {
        FastReader in=new FastReader();

        long x = in.nextLong() ;
        long a = in.nextLong() ;

        if(x<a) System.out.println(0);
        else System.out.println(10);

    }
}


Measured memory_bytes: 23124
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;

    vector<int> dp(N);
    vector<int> heights(N);
    REP(n, N) {
        int h;
        cin >> h;
        heights[n] = h;
        if (n >= 2) {
            dp[n] = min(dp[n - 2] + abs(heights[n] - heights[n - 2]),
                        dp[n - 1] + abs(heights[n] - heights[n - 1]));
        } else if (n == 1) {
            dp[n] = dp[n - 1] + abs(heights[n] - heights[n - 1]);
        } else if (n == 0) {
            dp[n] = 0;
        }
    }
    cout << dp[N - 1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
int main(){
  char s[100001];
  int sum1=0,sum0=0,len;
  scanf("%s",s);
  len=strlen(s);
  for (int i=0;i<len;i++){
    if (i%2 && s[i]=='0'){
      sum1++;
    }
    if (i%2 && s[i]=='1'){
      sum0++;
    }
    if (i%2==0 && s[i]=='0'){
      sum0++;
    }
    if (i%2==0 && s[i]=='1'){
      sum1++;
    }
  }
  if (sum1>sum0) printf("%d\n",sum0);
  else printf("%d\n",sum1);
  return 0;
}

Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
			ArrayList<Integer> one = nextIntArray();
			int N = one.get(0);
			int A = one.get(1);
			int B = one.get(2);
			myout(Math.min(B, N * A));
	}
	//Method addition frame start




	//Method addition frame end
}


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

#define ll long long

int main(){
    ll n;
    cin>>n;
    ll count = 0;
    ll arr[n+1][n+1][n+1];
    for (ll i=1;i<=n;++i){
        for (ll j=1;j<=n;++j){
            for (ll k=1;k<=n;++k){
                // arr[i][j][k]=0;
                count+=__gcd(i,__gcd(j,k));
            }
        }
    }
    cout<<count;
    // int count = 0;
    // for (int i=1;i<=n;++i){
    //     for (int j=1;j<=n;++j){
    //         for (int k=1;k<=n;++k){
    //             // cout<<__gcd(i,__gcd(j,k))<<" ";
    //             arr[i][j][k]==__gcd(i,__gcd(j,k));
    //         }
    //     }
    // }
    // for (int i=1;i<=n;++i){
    //     for (int j=1;j<=n;++j){
    //         for (int k=1;k<=n;++k){
    //             cout<<arr[i][j][k]<<" ";
    //         }
    //     }
    // }
    // cout<<count;
    
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
const int N = 2e5+5;
const dd eps = 1e-8;
const int mod = 1e9+7;

int ans[N],now,n;

int main(){
  ios::sync_with_stdio(false);
  // freopen("input.txt","r",stdin);
  cin>>n;
  for(int i = 2;i <= n;i++){
    cin>>now;
    ans[now]++;
  }
  for(int i = 1;i <= n;i++){
    cout<<ans[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 4424
import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))

    C = [0] * (N + 1)
    D = [0] * (N + 1)

    for i in range(N):
        C[A[i]] += 1
        D[B[i]] += 1

    for i in range(1, N + 1):
        if C[i] + D[i] > N:
            print('No')
            return

    print('Yes')

    C = list(accumulate(C))
    D = list(accumulate(D))

    B.reverse()

    i = 0
    while i < N and A[i] != B[i]:
        i += 1

    if i == N:
        print(*B)
        return

    n = A[i]
    leftA = C[n - 1]
    rightA = C[n]
    leftB = N - D[n]
    rightB = N - D[n - 1]

    i1 = min(leftA, leftB)
    i2 = max(leftA, leftB)
    i3 = min(rightA, rightB)
    i4 = max(rightA, rightB)

    for i in range(i3 - i2):
        if i < i1:
            B[i], B[i + i2] = B[i + i2], B[i]
        else:
            B[i - i1 + i4], B[i + i2] = B[i + i2], B[i - i1 + i4]

    print(*B)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 133552
/*
　　　　 ∧＿∧　にっぽんちゃちゃちゃ
　／＼（　・∀・）／ヽ
（ ●　と　　　つ　● ）　にっぽんちゃちゃちゃ
　＼/⊂、 ノ　　＼ノ
　　　　　し'
*/
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define MOD 1000000007
#define INF 9223372036854775807
int gcd( int x, int y ){ return y ? gcd(y, x%y) : x; }
signed main() {
int x=0,y=0,z=0,w=0,n=0;
int a=0,b=0;
std::cin >> a>>b;
n=(a+1)+(b+1)-(gcd(a,b)-1)-2;
std::cout << n << '\n';
}



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

using namespace std;

bool t[1000000];

int main(){
	memset(t,1,sizeof(t));
	t[0] = t[1] = false;
	for(int i = 2; i < 1000; i++){
		if(t[i])
			for(int j = 2 * i; j < 1000000; j += i){
				t[j] = false;
			}
	}

	int n;
	while(cin>>n){
		int ans = 0;
		for (int i = 0; i <= n; i++)
		{
			ans += t[i];
		}
		cout << ans << endl;
	}

	return 0;
}

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

typedef long long ll;

int n;
ll a[200005];
ll Max;
ll vis[200005];
map<ll,ll>cnt;

int main(){
	cin>>n;
	
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		cnt[a[i]]++;
	}
	
	for(auto Num : cnt){
		Max += 1LL * ( (Num.second - 1) * Num.second) / 2;
	}
	
	for(int i = 1; i <= n; i++) cout << Max - cnt[a[i]] + 1 << endl;
	
	return 0;
}

Measured memory_bytes: 11136
#include <iostream>
using std::cin;
using std::cout;
using std::endl;

int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    bool inX = false;
    bool inY = false;
    
    if((r <= x) && (x <= (W-r))) inX = true;
    if((r <= y) && (y <= (H-r))) inY = true;
    
    if(inX && inY){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}



Measured memory_bytes: 3092
import sys

N=int(sys.stdin.readline().rstrip())
BList=list(map(int,sys.stdin.readline().split()))

AList=[]
bBefore=10**5+1
for b in BList:
  AList.append(min(bBefore,b))
  bBefore=b
AList.append(BList[-1])
print(sum(AList))
  

Measured memory_bytes: 38256
char A[999],B[999],C[999];a,b,v;main(c){for(*C=10;~scanf("%*d%s%s"+!!*A*3,A,B);c=1){for(a=strlen(A),b=strlen(B);a|b|v;v/=10)v+=(a?A[--a]:48)+(b?B[--b]:48)-96,C[c++]=v%10+48;for(c>81&&puts("overflow",c=0);c--;)putchar(C[c]);}}

Measured memory_bytes: 0
=begin
    Problem https://atcoder.jp/contests/abc086/tasks/abc086_a
    Reference https://qiita.com/Hayate_0807/items/2e9705091b181a104621
             https://docs.ruby-lang.org/ja/search/version:2.3.0/query:even/#entry-1

=end
a,b = gets.chomp().split(" ").map(&:to_i)
=begin
p a
p b
=end
c = ( a * b ).even?
if c
    puts("Even")
else
    puts("Odd")
end


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

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

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

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

typedef long long LL;
static LL INF = (1LL<<62);
static LL P = 1000000007LL;

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

void COMBinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % P;
        inv[i] = P - inv[P%i] * (P / i) % P;
        finv[i] = finv[i - 1] * inv[i] % P;
    }
}

long long COMB(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % P) % P;
}

int isPrime(LL p){
	if(p<=1) return 0;
	if(p==2 || p==3 || p==5 || p==7) return 1;
	if(p==4 || p==6 || p==8 || p==9) return 0;

	LL i;
	int ret = 1;
	for(i=2; i*i<=p; i++){
		if(p%i==0 && i!=p){
			ret = 0;
			break;
		}
	}
	return ret;
}

// N を素因数分解して mp に格納する。long longは素数、intは指数。
void factorize(long long N, map<long long, int> &mp){
	if(N == 1){
		return;
	}
	if(isPrime(N)){
		mp[N] += 1;
		return;
	}

	long long i = 2, n = N;
	for(i = 2; n != 1 && i < (N/2) + 1; i++){
		if((n % i)==0){
			if(isPrime(i)){
				int e = 0;
				long long u = n;
				while((u % i)==0){
					e++;
					u = u / i;
					n = u;
				}
				mp[i] = e;
				if(isPrime(n)){
					mp[n] = 1;
					break;
				}
			}
		}
	}
	return;
}

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

	LL N, M;
	cin >> N >> M;

	COMBinit();

	map<long long, int> mp;
	factorize(M, mp);

	if(N == 1){
		printf("1\n");
		return 0;
	}

	LL ans = 1;
	for(auto itr = mp.begin(); itr != mp.end(); itr++){
		LL p = itr->first;
		int e = itr->second;
		//重複組みあわせ
		//e個のものをN個に分割する
		LL u = COMB(e+N-1, N-1);
		ans *= u;
		ans %= P;
	}
	ans %= P;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 15680
N, M = map(int, input().split())
ss = [[] for _ in range(N)]
for i in range(M):
    p, y = map(int, input().split())
    ss[p-1].append((i, y))
ls = [''] * M
for p in range(N):
    s = ss[p]
    s.sort(key=lambda g: g[1])
    for d, (i, y) in enumerate(s):
        ps = str(p+1).zfill(6)
        ds = str(d+1).zfill(6)
        ls[i] = ps+ds
for l in ls:
    print(l)

Measured memory_bytes: 35944
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! { cs: chars }
    let cs = cs.iter().cloned();
    let res: String = if 3 == cs.len() {
        cs.rev().collect()
    } else {
        cs.collect()
    };
    println!("{}", res);
}

Measured memory_bytes: 4352
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
ll A[100010];

int main () {
  cin >> N;
  for (auto i = 0; i < N; ++i) {
    cin >> A[i];
  }
  sort(A, A+N);
  reverse(A, A+N);
  vector<ll> V;
  for (auto i = 0; i < N-1; ++i) {
    if (A[i] == A[i+1]) {
      V.push_back(A[i]);
      i++;
    }
  }
  if ((int)V.size() < 2) {
    cout << 0 << endl;
  } else {
    cout << V[0] * V[1] << endl;
  }
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  int k = -1;
  int l = -1;
  for (int i = 2; ; i++) {
    int d = i * (i-1) / 2;
    if (n < d) {
      cout << "No" << endl;
      return 0;
    }
    if (n == d) {
      k = i; l = k-1;
      break;
    }
  }
  cout << "Yes" << endl;
  cout << k << endl;
  vector<int> c; int end_index = 1;
  for (int i = 0; i < k; i++) {
    cout << l; int index = 0; int csize = (int) c.size();
    for (int j = 0; j < l; j++) {
      if (index < csize) {
        cout << " " << c[index];
        c[index]++;
      } else {
        if (index == csize) c.push_back(end_index);
        cout << " " << end_index;
        end_index++;
      }
      index++;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 1408
//Only the Creator has given me strength!🖤
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<bitset>
typedef long long ll;
#define pi 3.1415926535897931159979635
#define pb push_back
#define vctr vector<int>
#define vvtr vector<vctr>
int mod=1e9+7;
ll ans,g;
using namespace std;
void fastio() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int main() {
    fastio();
    int n;
    cin>>n;
    int ar[n],ans=0;
    for(int i=0; i<n; i++) {
        cin>>ar[i];
        if(i%2==0 && ar[i]%2==1) ans++;
    }

    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 3608
import java.util.HashSet;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashSet<Integer> set = new HashSet<>();
		for(int i = 0; i < n; i++) {
			set.add(sc.nextInt());
		}
		System.out.println(set.size());
	}
}

Measured memory_bytes: 23764
n,m=map(int,input().split())
b=(n==m)
ans=0
if n&1:
  ans=n
  n+=1
s=(m-n+1)%4
if b:
  ans=m
elif s==1:
  ans^=m
elif s==2:
  ans^=1
elif s==3:
  ans^=1^m
print(ans)

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

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

    int posA, posZ;

    for (int i = 0; ; i++) {
        if (s[i] == 'A') {
            posA = i;
            break;
        }
    }

    for (int i = s.size() - 1; ; i--) {
        if (s[i] == 'Z') {
            posZ = i;
            break;
        }
    }

    cout << (posZ - posA + 1) << endl;

    return 0;
}


Measured memory_bytes: 640
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int H, W;
bool purple[500][500], red[500][500], blue[500][500];

int main(int argc, char **argv) {
	cin >> H >> W;
	CLEAR(red); CLEAR(blue);
	REP(y, H) REP(x, W) {
		char t;
		cin >> t;
		purple[x][y] = (t == '#');
		if (purple[x][y]) red[x][y] = blue[x][y] = true;
	}
	REP(x, W - 1) red[x][0] = blue[x + 1][H - 1] = true;
	REP(y, H - 1) red[0][y] = blue[W - 1][y + 1] = true;
	REP(x, W / 2 - 1) REP(y, H - 2) red[(x + 1) * 2][y + 1] = true;
	REP(x, (W - 1) / 2) REP(y, H - 2) blue[x * 2 + 1][y + 1] = true;

	REP(y, H) {
		REP(x, W) cout << (red[x][y] ? '#' : '.');
		cout << endl;
	}
	cout << endl;
	REP(y, H) {
		REP(x, W) cout << (blue[x][y] ? '#' : '.');
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 1536
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 

 
void solve()
{
	string  s; 
	cin>>s; 
	int n =  s.size() ; 
	rep(i  ,n){
		cout<<"x";
	}
}
 
int main() {
    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif
    
    // ios_base::sync_with_stdio(0);
    // cin.tie(NULL);
    int t = 1;
    // cin>>t;
    while(t--)
    {
        solve();
    } 
    // cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	h := nextInt()

	rank := 0
	for i := h; i > 0; i >>= 1 {
		rank++
	}

	fmt.Println(pow(2, rank) - 1)

}
func pow(a, b int) int {
	var ret int = 1
	for b > 0 {
		if (b & 1) == 1 {
			ret *= a
		}
		a *= a
		b >>= 1
	}
	return ret
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780