akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
long double pi=3.14159265358979323846L;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n;cin>>n;
    ll x[n+1];
    rep(i,1,n+1)cin>>x[i];
    ll ans=0;
    ll ka=1;
    rep(i,1,n){
        ka*=i;
        ka%=mod;
    }
    ll sum[n+1];
    sum[0]=0;
    rep(i,1,n+1)sum[i]=sum[i-1]+x[i];
    rep(i,1,n){
        ll a=ka*gyaku(i,mod)%mod;
        ll b=ka*gyaku(i+1,mod)%mod;
        ll c=sum[n-1]-sum[i]+mod;
        c%=mod;
        ll d=sum[n-i-1]-sum[0];
        c=c-d+mod;
        c%=mod;
        a=a-b+mod;
        a%=mod;
        a*=c;
        a%=mod;
        ans+=a;
        ans%=mod;
        ll u=x[n]-x[i];
        ll tt=ka*gyaku(n-i,mod)%mod;
        u*=tt;
        u%=mod;
        ans+=u;
        ans%=mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = (int)1e9+7;
const double PI = 3.14159265359;
 
ll sum(ll n, ll k){
	ll ans = 0;
	for(int i=k;i<=n;i++){
		ans = (ans + i * (n - i + 1) + 1) % MOD;
	}
	return ans;
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n,k;
	cin>>n>>k;
	
	cout<<sum(n,k)+1;
	
	
	
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <stack>
#include <string>
#include <cstdlib> // to convert string to int
#include <cstdio> //getchar
using namespace std;

// declare stack s
stack <int> s;

int solve(string str){
  int a = s.top(); s.pop();
  int b = s.top(); s.pop();

  if     (str == "+") return a+b;
  else if(str == "-") return b-a;
  else if(str == "*") return a*b;

}

int main(){
  string str;
  while(cin>>str){
    if(str == "+" || str == "-" || str == "*"){
      s.push(solve(str));
    }
    else s.push(atoi(str.c_str()));
    if(getchar() == '\n'){
      cout << s.top() << endl;
      return 0;
    }
  }
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    int a[n+2],b[n+2];
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        a[i]=x+y;
        b[i]=x-y;
    }
    sort(a,a+n);
    sort(b,b+n);
    cout<<max(a[n-1]-a[0],b[n-1]-b[0])<<endl;
}


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

int main(void){
	int N,i,j,v[55],temp,max=0,submax=0;
  	double ans;
  	scanf("%d",&N);
  	for(i=0;i<N;i++){
      scanf("%d",&v[i]);
    }
      /* sort */
      for(i=0;i<N-1;i++){
		for(j=i+1;j<N;j++){
          if(v[i]>v[j]){
            temp = v[i];
            v[i] = v[j];
            v[j] = temp;
          }
        }
      }
      /* sort */
  submax= v[i-1];
  max = v[i];
  
  ans = (v[0]+v[1])/(double)2.0;
  if(N>=3){
  	for(i=2;i<=N-1;i++){
 	   ans = (ans + v[i])/(double)2.0;
 	 }
  }
     printf("%f",ans);
  }

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
    int N, A[210];
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> A[i];
    }

    int counter = 0;
    bool frag = false;
    while(1){
        for (int i = 0; i < N; i++){
            if (A[i] % 2 == 1) frag = true;
            if (frag == true) break;
            else A[i] /= 2;
        }
        if (frag == true) break;
        counter += 1;
    }
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {     
	int n;
	cin >> n;                                               
	string ans = "";                   
	while (n) {
		--n;
		char c = (n % 26 + 'a');
		ans += c;
		n = (n - n % 26) / 26;
	}
	reverse(ans.begin(), ans.end());
	cout << ans;
}                                                    


Measured memory_bytes: 3644
#include <cstdio>
#include <vector>
#include <stack>

using namespace std;

bool is_visited[55];

void dfs(int n, int u, int v, vector<int> *graph, int cur) {
  is_visited[cur] = true;
  for (int i = 0; i < graph[cur].size(); i++) {
    int next_v = graph[cur][i];
    // 辺を使わない処理
    if (cur == u && next_v == v) { continue; }
    if (cur == v && next_v == u) { continue; }

    if ( is_visited[next_v] == false ) {
      dfs(n, u, v, graph, next_v);
    }
  }
}

int main() {
  int n, m;
  int aa[55], bb[55];
  vector<int> graph[55];

  scanf("%d %d", &n, &m);

  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--; b--;

    aa[i] = a; bb[i] = b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  int ans = 0;
  for (int i = 0; i < m; i++) {
    int u = aa[i], v = bb[i];
    for (int i = 0; i < 55; i++) {
      is_visited[i] = false;
    }
    dfs(n, u, v, graph, 0);
    bool f = true;
    for (int i = 0; i < n; i++) {
      if ( is_visited[i] == false ) {
        f = false; break;
      }
    }
    if (!f) { ans++; };
  }

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

  return 0;
}

Measured memory_bytes: 384
N=int(input())
T,A=map(int, input().split())
H=list(map(int, input().split()))
m=10000000000
n=0
for i in range(N):
    if abs(A-T+H[i]*0.006)<m:
        m=abs(A-T+H[i]*0.006)
        n=i+1
print(n)

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

using namespace std;
typedef long long int ll;

#define p(V) for(int iiv=0;iiv<V.size();iiv++) cout<<V[iiv]<<" ";
#define mp make_pair
#define pb push_back
#define graph vector<vector<int> >
#define pf first
#define ps second
#define pq priority_queue
const int N = 2e5;
const int l = 18;
const double pi = acos(-1);
struct d{
    int a , b , c;
    d(){
        a=b=c=0;
    }
};
int dp[N][4];
int n;
vector<d> day;
int calc(int idx,int back){
    if(idx==n) return 0;
    int &dp = ::dp[idx][back];
    if(dp!=-1) return dp;
    if(back!=0) dp=max(dp,day[idx].a+calc(idx+1,0));
    if(back!=1) dp=max(dp,day[idx].b+calc(idx+1,1));
    if(back!=2) dp=max(dp,day[idx].c+calc(idx+1,2));
    return dp;
}
int main(){   
    memset(dp,-1,sizeof dp);
    cin >> n;
    day.resize(n);
    for(int i=0;i<n;i++) cin>>day[i].a>>day[i].b>>day[i].c;
    cout<<calc(0,3);
    return 0;
}


Measured memory_bytes: 12288
#include<cstdio>

using namespace std;

int r,c;
const int MAX_R = 10;
const int MAX_C = 10000;
int ary[MAX_R][MAX_C];
int rev[MAX_R];
int count_col[2];

int count(){
	int ret = 0;
	for(int j=0;j<c;j++){
		count_col[0] = 0;
		count_col[1] = 0;
		for(int i=0;i<r;i++){
			count_col[ ary[i][j] ^ rev[i] ]++;
		}
		if(count_col[0]>count_col[1]){
			ret += count_col[0];
		}else{
			ret += count_col[1];
		}
	}
	return ret;
}

int dfs(int i){
	if(i==r)return count();
	rev[i] = 0;
	int tmp0 = dfs(i+1);
	rev[i] = 1;
	int tmp1 = dfs(i+1);
	if(tmp0>tmp1)return tmp0;
	return tmp1;
}

int main(){
	while(true){
		scanf("%d%d",&r,&c);
		if(r==0 && c==0)break;
		for(int i=0;i<r;i++){
			for(int j=0;j<c;j++){
				scanf("%d",&ary[i][j]);
			}
		}
		int ans = dfs(0);
		printf("%d\n",ans);
	}
}

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

int x;
bool is_prime[200010];

int main()
{
    cin >> x;
    for (int i = 0; i <= 200009; i++)
    {
        is_prime[i] = true;
    }

    for (int i = 2; i <= 200000; i++)
    {
        if (!is_prime[i])
        {
            continue;
        }

        for (int j = 2 * i; j <= 200000; j += i)
        {
            is_prime[j] = false;
        }
    }

    for (int i = x; i <= 200000; i++)
    {
        if (is_prime[i])
        {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}


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

int main(){
	int N;
  	cin >> N;
  	int b1 = 0;
  	int b2 = 0;
  	int b4 = 0;
  	bool judge = true;
  	for(int i = 0; i < N; i++){
    	int num;
      	cin >> num;
      	int count = 0;
      	while(num % 2 == 0){
        	count++;
          	num /= 2;
        }
      	//cout << count << endl;
      	if(count == 0){
          	b1++;
        }else if(count == 1){
          	judge = false;
          	b2++;
        }else{
          	b4++;
        }
    }
  	if(judge && b1 <= b4 + 1){
    	cout << "Yes" << endl;
      	return 0;
    }else if(judge && b4 + 1 < b1){
    	cout << "No" << endl;
      	return 0;
    }
  	if(judge == false && b1 <= b4){
    	cout << "Yes" << endl;
    }else if(judge == false && b4 < b1){
    	cout << "No" << endl;
    }
}

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

int main(){
  ll N,K;
  cin>>N>>K;
  
  if(K%2==0)
    cout<<(N/K)*(N/K)*(N/K)+((2*N+K)/(2*K))*((2*N+K)/(2*K))*((2*N+K)/(2*K))<<endl;
  else
    cout<<(N/K)*(N/K)*(N/K)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
#define ll long long
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);B

//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int main(){
	fastio();
	int h,w,n;
	cin>>h>>w>>n;
	int x,y;
	for(int i=1;i<=h;i++){
		if(i*w>=n){
			x = i;
			break;
		}
	}
	for(int i=1;i<=w;i++){
		if(i*h>=n){
			y = i;
			break;
		}
	}	
	cout<<min(x,y);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define PUTS(x) cout << (x) << endl;
#define PB push_back
struct Node {
    vector<int> adjacents = vector<int>();
    bool flag = false;
};
int main() {
    int n, m;
    cin >> n >> m;
    auto nodes = vector<Node>(n + m);
    rep(i, n) {
        int k;
        cin >> k;
        rep(j, k) {
            int l;
            cin >> l;
            l += n - 1;
            nodes[i].adjacents.PB(l);
            nodes[l].adjacents.PB(i);
        }
    }
    function<void(int, int)> reach = [&](int index, int prev) {
        auto &node = nodes[index];
        node.flag = true; // 訪問済みフラグを立てる
        for (auto nextIndex : node.adjacents) {
            if (nextIndex == prev)
                continue; // 一つ前のノードに戻らない
            if (nodes[nextIndex].flag)
                continue; // 訪問済みノードはスキップ
            reach(nextIndex, index); // 隣接ノードに訪問済みフラグを立ててゆく
        }
    };
    reach(0, -1); // ノード0を起点にして隣接全頂点をDFSで訪問
    rep(i, n) {
        if (nodes[i].flag == false) {
            PUTS("NO");
            return 0;
        }
    }
    PUTS("YES");
}

Measured memory_bytes: 9976
#include<stdio.h>
#include<string.h>
int main()
{
	int N,A,B,C,X,Y[100],i,j,s;
	for(;scanf("%d%d%d%d%d",&N,&A,&B,&C,&X),N;)
	{
		for(i=0;i<N;i++)
			scanf("%d",&Y[i]);
		for(i=s=0;i<=10000;i++)
		{
			if(Y[s]==X)
			{
				if(++s==N)
					break;
			}
			X=(A*X+B)%C;
		}
		printf("%d\n",i==10001?-1:i);
	}
	return 0;
}

Measured memory_bytes: 600
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

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

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N = I()
A = ILs(N)
import copy
B = copy.copy(A)
B.sort()

MAX1 = B[-1]
MAX2 = B[-2]

for a in A:
  if a == MAX1:
    P(MAX2)
  else:
    P(MAX1)


Measured memory_bytes: 63072
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;


int main() {
    string s;
    cin >> s;
    
    int cnt = 0;
    for (auto& c : s) { if (c == '1') { cnt++; } }
    cout << cnt << endl;

    return 0;
}

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

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

constexpr int INF = 1e9;

using graph = vector<vector<int>>;

bool dfs(graph const& g, int v, int b, vector<int>& visited, pii& res) {
    (b ? res.first : res.second) += 1;
    visited[v] |= (1 << b);
    bool ret = (visited[v] == 0b11);
    for(auto to : g[v]) {
        int nb = !b;
        if(visited[to] & (1 << nb)) {
            continue;
        }
        ret |= dfs(g, to, nb, visited, res);
    }
    return ret;
}

int main() {
    int V, E;
    cin >> V >> E;
    graph g(V);
    for(int i = 0; i < E; ++i) {
        int a, b;
        cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }

    vector<int> visited(V);
    vector<int> C(V + 1);
    ll sum = 0;
    for(int i = 0; i < V; ++i) {
        if(visited[i] == 0) {
            auto p = make_pair(0, 0);
            if(dfs(g, i, 0, visited, p)) {
                cout << -1 << endl;
                return 0;
            }
            if(p.first > p.second) {
                swap(p.first, p.second);
            }
            C[p.second - p.first]++;
            sum += p.first;
        }
    }
    vector<pii> s;
    for(int i = 1; i < C.size(); ++i) {
        if(C[i] > 0) {
            s.emplace_back(i, C[i]);
        }
    }

    vector<bool> dp(V + 1);
    dp[0] = true;
    for(int i = 0; i < s.size(); ++i) {
        auto nxt = dp;
        int prev = -1;
        int val = s[i].first, m = s[i].second;
        for(int j = 0; j < val; ++j) {
            for(int k = 0; k * val + j < V + 1; ++k) {
                nxt[k * val + j] = nxt[k * val + j] | (prev != -1);
                if(dp[k * val + j]) {
                    prev = k;
                }
                if(k - prev >= m) {
                    prev = -1;
                }
            }
        }
        dp = move(nxt);
    }

    ll res = 0;
    for(int i = 0; i < V + 1; ++i) {
        if(dp[i]) {
            ll a = sum + i;
            ll b = V - a;
            res = max(res, a * b - E);
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 9856
N = int(input())
zyousi_arr = [int(i) for i in input().split(' ')]
res_map = {}

for i in range(1, N + 1):
    res_map[i] = 0

for zyousi in zyousi_arr:
    res_map[zyousi] += 1

for k, v in sorted(res_map.items()):
    print(v)

Measured memory_bytes: 47880
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int K;
  ci(K);
  ll a = 0;
  rep(i, K){
    rep(j, K){
      rep(k, K){
        a += __gcd((i + 1), __gcd((j + 1), (k + 1)));
      }
    }
  }
  co(a);
}


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

vector<ll> dijkstra(const vector<vector<pair<int, ll>>> &graph, int s) {
  vector<ll> dist(graph.size(), 1e18);
  priority_queue<pair<ll, int>> q;
  q.push(pair<ll, int>{0, s});
  while (!q.empty()) {
    int i = q.top().second;
    ll di = -q.top().first;
    q.pop();
    if (dist[i] <= di) continue;
    dist[i] = di;
    for (auto e : graph[i]) {
      int j = e.first;
      ll dj = di + e.second;
      if (dist[j] > dj) q.push(pair<ll, int>{-dj, j});
    }
  }
  return dist;
}

int main() {
  int n, m, s, t;
  cin >> n >> m >> s >> t;
  s--;
  t--;
  vector<vector<pair<int, ll>>> a(n), b(n);
  for (int i = 0; i < m; i++) {
    int u, v, ai, bi;
    cin >> u >> v >> ai >> bi;
    u--;
    v--;
    a[u].push_back({v, ai});
    a[v].push_back({u, ai});
    b[u].push_back({v, bi});
    b[v].push_back({u, bi});
  }
  vector<ll> c = dijkstra(a, s), d = dijkstra(b, t);
  vector<ll> r(n);
  for (int i = 0; i < n; i++) {
    r[i] = c[i] + d[i];
  }
  for (int i = n - 2; i >= 0; i--) {
    r[i] = min(r[i], r[i + 1]);
  }
  for (auto e : r) {
    cout << (ll)1e15 - e << endl;
  }
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const long double EPS = 0.0000000001;

int h,w,n;
int main(){
	cin >> h >> w >> n;
	int a = max(w, h);
	int ans = n/a;
	if(n % a != 0)ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 998244353

a, b, c, d = MAP()
dp = list2d(c+1, d+1, 0)

dp[a][b] = 1
for i in range(a, c+1):
    for j in range(b, d+1):
        dp[i][j] += dp[i-1][j] * j
        dp[i][j] += dp[i][j-1] * i
        dp[i][j] -= dp[i-1][j-1] * (i-1) * (j-1)
        dp[i][j] %= MOD
ans = dp[c][d]
print(ans)


Measured memory_bytes: 136376
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;

struct edge{int to,cost;};

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

	ll x;
	cin >> x;

	ll ans=(x/11)*2;
	if(x%11>6)ans+=2;
	else if(x%11 >= 1) ans+=1;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
/*
 xy 平面上に、左下の座標が (0,0)、右上の座標が (W,H) で、各辺が x 軸か y 軸に平行な長方形があります。最初、長方形の内部は白く塗られています。


すぬけ君はこの長方形の中に N 個の点を打ちました。i 個目 (1≦i≦N) 点の座標は (xi,yi) でした。

また、すぬけ君は長さ N の数列 a を決めて、各 1≦i≦N に対し、

ai=1 のときは長方形の x<xi をみたす領域
ai=2 のときは長方形の x>xi をみたす領域
ai=3 のときは長方形の y<yi をみたす領域
ai=4 のときは長方形の y>yi をみたす領域
を黒く塗りました。

塗りつぶしが終わったあとの長方形内での白い部分の面積を求めてください
*/

import java.util.Scanner;

public class Main {

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

		int h = sc.nextInt();
		int w = sc.nextInt();
		int n = sc.nextInt();

		int x, y, a;
		int xmax = 0;
		int xmin = h;
		int ymax = 0;
		int ymin = w;

		for (int i = 0; i < n; i++) {
			x = sc.nextInt();
			y = sc.nextInt();
			a = sc.nextInt();

			if (a == 1) {
				if (x > xmax) {
					xmax = x;
				}
			} else if (a == 2) {
				if (x < xmin) {
					xmin = x;
				}
			} else if (a == 3) {
				if (y > ymax) {
					ymax = y;
				}
			} else if (a == 4) {
				if (y < ymin) {
					ymin = y;
				}
			}
		}

		int area;
		if (xmin - xmax <= 0 || ymin - ymax <= 0) {
			System.out.println(0);
		} else {
			System.out.println((xmin - xmax) * (ymin - ymax));
		}
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <set>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

int n,m;
int a,b;
set<int> g[200010];

int main() {
	scanf("%d%d",&n,&m);
	for (int i=0;i<m;i++) {
		scanf("%d%d",&a,&b);
		g[a].insert(b);
		g[b].insert(a);
	}
	bool flag=false;
	for (int i=2;i<n;i++) {
		if (g[i].find(1)!=g[i].end()&&g[i].find(n)!=g[i].end()) {
			flag=true;
			break;
		}
	}
	if (flag) printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
}


Measured memory_bytes: 28416
#include<stdio.h>

int main(void){
  int i,n,s=0;
  int a[1000];

  scanf("%d",&n);

  for(i=0;i<n;i++)
    scanf("%d",&a[i]);

  while(1){
    for(i=0;i<n;i++){
      if(a[i]%2==1) break;
      a[i]/=2;
    }
    if(i==n) s++;
    else break;
    i=0;
  }

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

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

ll modpow(ll a,ll n,ll mod){
  ll res=1;
  while(n){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a,ll mod){
  return modpow(a,mod-2,mod);
}

const int MAX=510000;
const int mod=998244353;
ll fac[MAX],finv[MAX],inv[MAX];

void init(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  rep(i,MAX){
    if(i>1){
      fac[i]=fac[i-1]*i%mod;
      inv[i]=mod-inv[mod%i]*(mod/i)%mod;
      finv[i]=finv[i-1]*inv[i]%mod;
    }
  }
}

ll com(int n,int k){
  if(n<k) return 0;
  if(n<0||k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

int main(){
  ll N,A,B,K;
  cin>>N>>A>>B>>K;
  init();
  ll ans=0;
  rep(i,N+1){
    if((K-i*A)%B==0 and (K-i*A)/B<=N){
      ll tmp=com(N,i)*com(N,(K-i*A)/B)%mod;
      (ans+=tmp)%=mod;
    }
  }
  cout<<ans<<endl;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  int sum=0;
  for(int i=0;i<M;i++){
    int A;
    cin >> A;
    sum+=A;
  }
  if(N-sum<0){
    cout << -1 << endl;
  }else{
    cout << N-sum << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
int main(void){
  int a,b,c,d,i;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&d);
  for(i=1;a>0&&c>0;i++){
    if(i%2==1)
      c=c-b;
    else
      a=a-d;
  }
  if(c<1)
    printf("Yes");
  if(a<1)
    printf("No");
  return 0;
} 
    
    

Measured memory_bytes: 1728
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
#include<functional>
using namespace std;
pair<long,vector<long>> getResult(int m,long *c,long *a,vector<int> bl){
    long csum=0;
    vector<long> asum(m);
    for_each(bl.begin(),bl.end(),[&](int x){
    	csum+=c[x];
      	for(int i=0;i<m;i++){
          asum[i]+=a[x*m+i];
        }
    });
  
	pair<long,vector<long>> p = make_pair(csum,asum);
    return p;
}
bool check(long x, vector<long> vc){
	for(auto it=vc.begin();it!=vc.end();++it){
        if(*it<x)return false;
    }
    return true;
}
void recursive_comb(int *indexes, int s, int rest, std::function<void(int *)> f) {
  if (rest == 0) {
    f(indexes);
  } else {
    if (s < 0) return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s;
    recursive_comb(indexes, s - 1, rest - 1, f);
  }
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(int *)> f) {
  int indexes[k];
  recursive_comb(indexes, n - 1, k, f);
}
int main(int,char**){
    int n,m;
    long x;
    cin>>n>>m>>x;
    long *c=new long[n], *a=new long[n*m];
    for(int i=0;i<n;i++){
      cin>>c[i];
      for(int j=0;j<m;j++) cin>>a[i*m+j];
    }
    long lc=-1;
    vector<long> la;
    for(int i=1;i<=n;i++){
    	foreach_comb(n,i,[&](int *picks){
            vector<int> bl(i);
            bl.assign(picks,picks+i);
            auto p=getResult(m,c,a,bl);
            if(check(x,p.second)&&(lc==-1||p.first<lc)){
              lc=p.first;
              la=p.second;
            }
        });
    }
  
  	cout<<lc<<endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    for (auto& e : x) cin >> e;

    vector<int> s = x;
    sort(begin(s), end(s));

    for (auto& e : x) cout << (e <= s[n/2-1] ? s[n/2] : s[n/2-1]) << endl;
}


Measured memory_bytes: 3712
#include <stdio.h>

int main(void)
{
	int a,b,c;

	scanf("%d %d %d", &a,&b,&c);

	if(a == b && b == c){
		printf("1\n");
	}else if(a == b && b != c){
		printf("2\n");
	}else if(b == c && c != a){
		printf("2\n");
	}else if(c == a && a != b){
		printf("2\n");
	}else if (a != b && b != c && c != a) {
		printf("3\n");
	}

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
using namespace std;
typedef long long LL;
const int N=2e5;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int head[N],nxt[N],to[N];
inline bool dfs(int k,int fa) {
	bool match=false;
	for (int i=head[k];i;i=nxt[i])
		if (to[i]!=fa) {
			if (dfs(to[i],k))
				if (match) { puts("First"); exit(0); }
				else match=true;
		}
	return !match;
}
int main()
{
	int n=gi(),i,a,b,tot=0;
	for (i=1;i<n;i++) {
		a=gi(),b=gi();
		to[++tot]=b,nxt[tot]=head[a],head[a]=tot;
		to[++tot]=a,nxt[tot]=head[b],head[b]=tot;
	}
	puts(dfs(1,0)?"First":"Second");
	return 0;
}


Measured memory_bytes: 2304
using System;
using System.Linq;
 
class AtCoder {
  public static void Main() {
    //var inputs = Console.ReadLine().Trim().Split(' ');
    var N = int.Parse(Console.ReadLine().Trim());
    var A = Console.ReadLine().Trim().Split(' ').Select(x => long.Parse(x)).ToArray();
    var U = A.Distinct().ToArray();
    Console.WriteLine(A.Length == U.Length ? "YES" : "NO");
  }
}

Measured memory_bytes: 49436
#include<iostream>
using namespace std;
#define MAX 500005

int H, A[MAX + 1];

void maxHeap(int i) {
	int l, r, large;
	l = 2 * i;
	r = 2 * i + 1;

	if (l <= H&&A[l] > A[i]) {
		large = l;
	}
	else {
		large = i;
	}
	if (r <= H&&A[r] > A[large]) {
		large = r;
	}
	if (large!=i) {
		swap(A[large], A[i]);
		maxHeap(large);
	}
}

int main()
{
	cin >> H;
	for (int i = 1; i <= H; i++) cin >> A[i];
	for (int i = H / 2; i >= 1; i--) maxHeap(i);
	for (int i = 1; i <= H; i++) {
		cout << " " << A[i];
	}
	cout << endl;
    return 0;
}

Measured memory_bytes: 4996
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	int n, k, c;
	string str;
	cin >> n >> k >> c >> str;
	vector<int> inds;
	for(int i = 0; i < n; i++)
		if(str[i] == 'o') inds.push_back(i);
	vector<int> mxi(inds.size() + 1);

	for(int i = inds.size() - 1; i >= 0; i--) {
		int w = int(lower_bound(inds.begin(), inds.end(), inds[i] + c + 1) - inds.begin());
		mxi[i] = mxi[w] + 1;
	}

	if(mxi[0] > k) return 0;
	for(int i = 0; i < inds.size(); i++) LOG << inds[i] << ' ' << mxi[i] << '\n';

	int prv;
	for(int i = 0, j = 0; i < inds.size(); i = j) {
		for(; j < inds.size() && mxi[i] == mxi[j]; j++);
		//LOG << "prv " << prv << '\n';
		if(!i) {
			if(j - i == 1) cout << inds[i] + 1 << '\n';
			prv = inds[0];
		} else {
			if(j - i == 1 || prv + c + 1 > inds[j - 2]) cout << inds[j - 1] + 1 << '\n';
			prv = *lower_bound(inds.begin(), inds.end(), prv + c + 1);
		}
	}
}



Measured memory_bytes: 3468
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
using namespace std;
int a[200005];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	int r=0;
	long long ans=0,sum=a[0];
	for(int l=0;l<n;l++){
		if(l>0)sum-=a[l-1];
		while(r<n-1 && sum+a[r+1]==(sum^a[r+1])){
			r++;
			sum+=a[r];
		}
		ans+=r-l+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4416
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int n,t;
    cin >> n >> t;
    int ans = INF;
	rep(i, n){
        int a,b;
        cin >> a >> b;
        if(b <= t && a < ans){
            ans = a;
        }
    }
	if(ans != INF) cout << ans << "\n";
    else cout << "TLE" << "\n";
	return 0;
}

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

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;

void solve(void)
{
    int m;
    cin >> m;
    cout << 24 - m + 24 << endl;
}
int main(void)
{
    solve();
}

Measured memory_bytes: 3480
import java.util.*;
public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N;
        int[] L = new int[200];
        int dmin = 100;
        N = sc.nextInt();
        for (int i = 0; i < N; ++i) {
            int A;
            A = sc.nextInt();
            int d = 0;
            while (A % 2 == 0) {
                A /= 2;
                ++d;
            }
        	dmin = Math.min(dmin, d);
        }
        System.out.println(dmin);
    }
}

Measured memory_bytes: 23636
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();
        int a = Integer.parseInt(scan.next());
        int intans = 0;
        int odd = 0;
        int eve = 0;
        for(int i = 1;i<=a;i++){
            if(i%2==0){
                eve += 1;
            }else{
                odd += 1;
            }
        }
    intans = eve * odd;
        PrintWriter out = new PrintWriter(System.out);
        out.println(intans);
        out.flush();
        scan.close();
    }
}

Measured memory_bytes: 21844
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
	#define debug(A,args...) fprintf(stderr,A,##args)
#else
	#define debug(A,args...) printf("")
#endif
#define deb debug("line %d\n",__LINE__)
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void GG(){puts("-1");exit(0);}

	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int MM=5e6+10;
	ll fac[MM],facinv[MM],Inv[MM];ll Comb(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,MM-1) fac[i]=fac[i-1]*i%MOD;
		facinv[MM-1]=invm(fac[MM-1]);fd(i,MM-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,MM-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}

	const int N=1e6+10;
	//------------------FIXED------------------
	
	void main()
	{
		int n=qread();map<int,int> ct;while(n--) ct[qread()]++;ll ans=0,lstmx=0;
		for(auto a:ct) {if(a.SE>=2) chmax(ans,1ll*lstmx*a.FR),lstmx=a.FR;if(a.SE>=4) chmax(ans,1ll*a.FR*a.FR);}write(ans);
 	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::main();
	debug("\n------------------------------------------\nTime: %.2lf s\n",1.0*clock()/CLOCKS_PER_SEC);
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int x,n,p,maxv=1000,dist,ans;
int main() {
    cin >> x >> n;
    bool s[102] = {false};
    for( int i = 0;i<102;i++){
        cin >> p;
        s[p] = true;
    }
    for(int i = 0;i<102;i++){
        if(s[i]){
            continue;
        }
        dist = abs(x - i);
        if(maxv == dist){
            cout << ans << endl;
            return 0;
        }
        if(maxv > dist){
            maxv = dist;
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main(void) {
	int R, G, B, num, ans = 0, i;
	scanf("%d%d%d%d", &R, &G, &B, &num);
	for (; num >= 0; num -= R) {
		for (i = num; i >= 0; i -= G) {
			if (i % B == 0)
				ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
     
    public class Main {
      public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int []sunuke = new int[N];
        
        int cou = 0;
        for(int i=0; i<K; i++) {
        	int d = sc.nextInt();
        	for(int j=0; j<d; j++) {
        		int A = sc.nextInt();
        		sunuke[A-1]++;
        	}
        }
        for(int i=0; i<N; i++) {
        	if(sunuke[i] == 0) {
        		cou++;
        	}
        }
        System.out.println(cou);
      }
    }

Measured memory_bytes: 45952
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
from itertools import combinations,permutations # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
S = input()
cnt = 0
for i in range(len(S)):
    if i == 0:
        prv = S[i]
    else:
        if prv != S[i]:
            cnt += 1
            prv = S[i]
        else:
            pass
print(cnt)


Measured memory_bytes: 3572
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

class BinSearchTree1 {

	Node root;

	public void run() {

		root = null;

		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

			int m = Integer.parseInt(br.readLine());
			for (int i = 0; i < m; i++) {

				String line = br.readLine();

				if(line.charAt(0) == 'i') {
					int val = Integer.parseInt(line.substring(7));
					insert(val);
				} else {
					print();
				}

			}

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

	private void insert(int val) {

		Node y = null;
		Node x = root;

		Node z = new Node();
		z.key = val;
		z.left = null;
		z.right = null;

		while (x != null) {
			y = x;
			if (val < x.key) {
				x = x.left;
			} else {
				x = x.right;
			}
		}
		z.parent = y;

		if (y == null) {
			root = z;
		} else {
			if (val < y.key) {
				y.left = z;
			} else {
				y.right = z;
			}
		}
	}

	private void print() {

		pByInOrder(root);
		System.out.println();
		pByPreOrder(root);
		System.out.println();

	}

	private void pByInOrder(Node node) {

		if(node == null) return;

		pByInOrder(node.left);
		System.out.print(" " + node.key);
		pByInOrder(node.right);

	}

	private void pByPreOrder(Node node) {

		if(node == null) return;

		System.out.print(" " + node.key);
		pByPreOrder(node.left);
		pByPreOrder(node.right);

	}

}

class Node {

	int key;
	Node left, right, parent;

}

Measured memory_bytes: 127028
#include<stdio.h>

#define MAX 100
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int prim();

int n, M[MAX][MAX];

int prim(){
  int u, minv, i=0, v=0;
  int d[MAX], p[MAX], color[MAX];

  for(i=0; i<n; i++){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for( i=0; i<n; i++){
      if(minv > d[i] && color[i] != BLACK){
        u = i;
        minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(v=0; v<n; v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
        if(d[v] > M[u][v]){
          d[v] = M[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
    }
  }
  int sum = 0;
  for(i=0; i<n; i++){
    if(p[i] != -1)sum += M[i][p[i]];
  }
  return sum;
}

int main(){

  int i=0, j=0;

  scanf("%d",&n);

  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      int e;
      scanf("%d",&e);

      M[i][j] = (e==-1) ? INFTY : e;
    }
  }
  printf("%d\n",prim());

  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int x;
  cin >> x;

  if (x == 3 || x == 5 || x == 7) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <set>
#include <cctype>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <limits>
#include <cmath>
#include <typeinfo>
 
 
using namespace std; 
 
 
// ||    


// upper to lower = + 32;
// lower to upper = - 32;

int firstDigit(int n) 
{ 
    while (n >= 10)  
        n /= 10;  
    return n; 
} 

int lastDigit(int n) 
{ 
    return (n % 10); 
} 


void sortString(string &str) 
{ 
   sort(str.begin(), str.end());
}
 
void reverseStr(string& str) 
{ 
    int n = str.length(); 
    for (int i = 0; i < n / 2; i++) 
        swap(str[i], str[n - i - 1]); 
} 

void bubbleSort(string s, int o, int n)
{  
    for(int i = 1; i <= n; i++) {
    	for(int j = 1; j <= n; j++)  {
       		if (s[o] < s[j]) {
       			swap(s[o], s[j]); 

       		}  
    	}
    }      
 
} 


bool allCharactersSame(string s) 
{ 
	int n = s.length();
    for (int i = 1; i < n; i++) 
        if (s[i] != s[0]) 
            return false; 
  
    return true; 
}
int factorial(int n) 
{ 
    return (n==1 || n==0) ? 1: n * factorial(n - 1);  
}


int main() {
	int a = 0, b = 0, c = 0;
	cin >> a >> b >> c;
	if(a + b + c >= 22) {
		cout << "bust" << endl;
	}
	else {
		cout << "win" << endl;
	}

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

struct node{

    int key;
    node *right, *left, *parent;

};

node *NIL, *root;

void insert( int k ){

    node *y = NIL;
    node *x = root;
    node *z;

    z = ( node * )malloc( sizeof(node) );

    z -> key = k;
    z -> left = NIL;
    z -> right = NIL;

    while( x != NIL ){

        y = x;

        if( z -> key < x -> key ){

            x = x -> left;

        } else {

            x = x -> right;

        }

    }

    z -> parent = y;

    if( y == NIL ){

        root = z;

    } else {

        if( z-> key < y -> key ){

            y -> left = z;

        } else{

            y -> right = z;

        }

    }

}

node * find( node *u, int k ){

    while( u != NIL && k != u->key ){

        if( k < u->key ){

            u = u->left;

        } else {

            u = u->right;

        }

    }

    return u;

}


void inorder( node *u ){

    if( u == NIL ) return;
    inorder( u -> left );
    printf(" %d", u -> key );
    inorder( u -> right );

}

void preorder( node *u ){

    if( u == NIL ) return;
    printf(" %d", u -> key );
    preorder( u -> left );
    preorder( u -> right );   

}


int main(){

    int n, i, x;
    string com;

    scanf("%d", &n);

    for( i = 0 ; i < n ; i++ ){

        cin >> com;

        if( com == "insert" ){

            scanf("%d", &x);
            insert(x);

        } else if( com == "print" ){

            inorder( root );
            printf("\n");
            preorder( root );
            printf("\n");

        } else if( com == "find" ){

            scanf("%d", &x);
            node *t = find( root, x);

            if( t == NIL ) printf("no\n");
            else printf("yes\n");

        }

    }

    return 0;

}




Measured memory_bytes: 21912