akhauriyash/Code-Regression huggingface dataset:
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;
using System.Timers;

static class MainClass
{
    public static void Main(string[] args)
    {
        Console.WriteLine(PhiFunction(Console.ReadLine().ToInt32()));

        Console.ReadLine();
    }


    public static long PhiFunction(int n)
    {
        var ls = PrimeFactorize(n).Distinct();
        var a = 1l;
        foreach (var item in ls)
        {
            a *= item - 1;
        }

        var b = 1l;
        foreach (var item in ls)
        {
            b *= item;
        }
        return (a * n) / b;
    }
    // 素因数分解
    public static List<long> PrimeFactorize(long n)
    {
        var bases = n;
        var num = (long)Math.Pow(n, 0.5);
        var ls = new List<long>();
        for (int i = 2; i <= num; i++)
        {
            if (n % i == 0)
            {
                n = n / i;
                ls.Add(i);
                i--;
                continue;
            }
        }
        long nnn = 1;
        foreach (var item in ls)
        {
            nnn = nnn * item;
        }
        if (nnn != bases)
            ls.Add(n);
        return ls;
    }

    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();

    public const int INF = int.MaxValue / 2;
    #endregion
}



Measured memory_bytes: 18236
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long[] a = sc.LongArray();
        long q = sc.NextLong();

        Dictionary<long, long> dic = new Dictionary<long, long>();
        for (int i = 0; i < n; i++)
        {
            if (dic.ContainsKey(a[i]))
            {
                dic[a[i]]++;
            }
            else
            {
                dic.Add(a[i], 1);
            }
        }

        long answer = a.Sum();

        for (int i = 0; i < q; i++)
        {
            long b = sc.NextLong();
            long c = sc.NextLong();

            if (dic.ContainsKey(b))
            {
                long count = dic[b];
                answer += (c - b) * count;
                dic.Remove(b);
                if (dic.ContainsKey(c))
                {
                    dic[c] += count;
                }
                else
                {
                    dic.Add(c, count);
                }
            }
            Console.WriteLine(answer);
        }

    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 52880
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long &x, long long &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a%b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

int main() {
	string s;
	cin >> s;
	int ans = 0;
	int cnt = 0;
	rep(i, s.size()) {
		if (s[i]== 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') {
			cnt++;
			ans = max(cnt, ans);
		}
		else {
			cnt = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

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

	vector<ll> x(n);
	x[0] = accumulate(all(a),0LL);
	for (int i = 2; i < n; i+=2){
		x[0] -= 2*a[i];
	}
	for (int i = 1; i < n; i++){
		x[i] = 2*a[i]-x[i-1];
	}

	cout<<x[n-1] << " ";
	for (int i = 0; i < n-1; i++){
		cout<<x[i] << (i==n-2?"":" ");
	}
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 2944
#include<stdio.h>
int main(){
  int n,i,j;
  scanf("%d",&n);
  n%=28;
  for(i=0;i<7;i++)
    for(j=0;j<4;j++)
      if(n==4*i+7*j){
        puts("Yes");
        return 0;
      }
  puts("No");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
int main(){
    int n;cin >> n;
    ll m;cin >> m;
    ll mx=1;
    for(ll i=1;i*i<=m;i++){
        if(m%i==0){
            if(m/i>=n){
                mx=max(mx,i);
            }
            if(i>=n){
                mx=max(mx,m/i);
            }
        }
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int>alo(N);
    rep(i, 0, N){
        if (S[i] == 'R') alo[i] = 0;
        if (S[i] == 'G') alo[i] = 1;
        if (S[i] == 'B') alo[i] = 2;
    }
    vector<ll>cnt(3);
    rep(i, 0, N)cnt[alo[i]]++;
    ll ans = 1;
    rep(i, 0, 3)ans*=cnt[i];
    rep(j, 0, N){
        rep(i, 0, j){
            int k = j+(j-i);
            if (k<N) {
                if(alo[i] == alo[j])continue;
                if(alo[i] == alo[k])continue;
                if(alo[k] == alo[j])continue;
                ans--;
            }
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3628
N, K = map(int, input().split())
 
if K % 2 == 1:
    div = N // K
    print(div**3)
else:
    div = N // K
    if div * K + K/2 <= N:
        print(div**3 + (div+1)**3)
    else:
        print(2 * div**3)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define ll long long
#define lld long double
#define MOD 1000000007
#define inf 1000000007
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
// ll power(ll x,ll y, ll md=inf){ll res = 1;x%=md;while(y){if(y&1)res = (res*x)%md;x *= x; if(x>=md) x %= md; y >>= 1;}return res;}
 
using namespace std;


// #define ' ' '\n'
// #define int ll

signed main() {
	fast;

	int h,w;
	cin>>h>>w;

	pii v[200002];
	for(int i=0;i<h;i++) cin>>v[i].f>>v[i].s;

	map<int,int> mp;
	for(int i=1;i<=w;i++) mp[i] = 0;

	map<int,int> mini = {{0,w}};

	for(int i=0;i<h;i++) {
		int r = v[i].s;

		auto it = mp.lower_bound(v[i].f);


		if(r==w) {
			while(it!=mp.end() && it->f <= r) {
				auto it1 = it++;
				auto it2 = mini.find(it1->s);
				if(it2->s==1) mini.erase(it2);
				else it2->s --;
				mp.erase(it1);
			}

			if(mini.size()) cout<<mini.begin()->f+i+1<<' ';
			else cout<<-1<<' ';
		}
		else {
			int mn = inf;

			while(it!=mp.end() && it->f <= r) {
				mn = min(mn, r+1-(it->f)+(it->s));
				auto it1 = it++;
				auto it2 = mini.find(it1->s);
				if(it2->s==1) mini.erase(it2);
				else it2->s --;
				mp.erase(it1);
			}

			if(mn<inf) {
				if(it!=mp.end() && it->f == r + 1) {
					if(it->s > mn) {
						auto it1 = mini.find(it->s);
						if(it1->s ==1) mini.erase(it1);
						else it1->s --;
						mini[mn]++;
						it->s = mn;
					}
				}
				else {
					mp.insert({r+1,mn});
					mini[mn]++;
				}
				cout<<mini.begin()->f+i+1<<' ';
			}
			else {
				if(mini.size()) cout<<mini.begin()->f+i+1<<' ';
				else {
					for(int j=i;j<h;j++) {
						cout<<-1<<' ';
					}
					return 0;
				}
			}

		}

	}
}

Measured memory_bytes: 14508
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = null;
		PrintStream out = null;
		try {
			sc = new Scanner(System.in);
			out = System.out;
			exec(sc, out);
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			if(out != null) {
				out.close();
			}
			if(sc != null) {
				sc.close();
			}
		}
		System.exit(0);
	}
	public static void exec(final Scanner sc, final PrintStream out) throws Exception{
		final int N = sc.nextInt();
		final long[] A = new long[N+1];
		final long[] B = new long[N];
		for(int i=0;i<N+1;i++) {
			A[i] = sc.nextLong();
		}
		for(int i=0;i<N;i++) {
			B[i] = sc.nextLong();
		}
		long left = 0;
		long sum = 0;
		for(int i=0;i<N;i++) {
			if(A[i]>B[i]+left) {
				// 全消費しても倒しきれない。
				sum+=(B[i]+left);
				left = 0;
			}else {
				// リソース余り(全部倒せる)
				sum+=A[i];
				if(A[i]>left) {
					// 積み立て全消費
					// 積み立てからのあまりを引き継ぐ。
					left = (B[i])-(A[i]-left);
				}else {
					// 積み立て消失+全部再積み立て
					left = B[i];
				}
			}
		}
		if(A[N]>left) {
			sum += left;
		}else {
			sum += A[N];
		}
		out.println(sum);
	}
}


Measured memory_bytes: 85328
#include <functional>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <iostream>
using namespace std;

struct Line {
    int a, b, c, rank;
    Line(int a, int b, int c) : a(a), b(b), c(c) {}
    double eval(double x) { return -(a * x + c) / b; }
};

double search(vector<Line> &lines) {
    double lb = -1e9, ub = 1e9;
    const int n = lines.size();
    sort(lines.begin(), lines.end(), [](Line lhs, Line rhs) {
            return lhs.b * rhs.a < lhs.a * rhs.b;
        });
    for (int i = 0; i < n; i++) lines[i].rank = i + 1;
    while (ub - lb > 1e-10 && (ub - lb) / max(abs(lb), abs(ub)) > 1e-10) {
        double m = (ub + lb) / 2;
        sort(lines.begin(), lines.end(), [m](Line lhs, Line rhs) {
                return lhs.eval(m) < rhs.eval(m);
            });
        int bit[n+2];
        fill(bit, bit+n+2, 0);
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            Line l = lines[i];
            for (int j = l.rank; j > 0; j -= j&-j) cnt += bit[j];
            for (int j = l.rank; j <= n; j += j&-j) bit[j]++;
        }
        // cerr << m << " " << cnt << endl;
        if (cnt * 2LL >= n * (n - 1) / 2) ub = m;
        else lb = m;
    }
    return (ub + lb) / 2;
}

pair<double, double> bruteforce(vector<Line> &lines) {
    const int n = lines.size();
    vector<double> xs, ys;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            Line l = lines[i], m = lines[j];
            double det = - (l.a * m.b - l.b * m.a),
                x = (m.b * l.c - l.b * m.c) / det,
                y = (l.a * m.c - l.c * m.a) / det;
            xs.push_back(x);
            ys.push_back(y);
        }
    }
    const int i = (xs.size() - 1) / 2;
    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());
    return {xs[i], ys[i]};
}

int main() {
    int n; cin >> n;
    vector<Line> lines;
    for (int i = 0; i < n; i++) {
        int a, b, c; cin >> a >> b >> c;
        if (b > 0) lines.push_back(Line(a, b, -c));
        else lines.push_back(Line(-a, -b, c));
    }

    double ansx = search(lines);
    for (auto &l : lines) {
        swap(l.a, l.b);
        if (l.b < 0) { l.a *= -1; l.b *= -1; l.c *= -1; }
    }
    double ansy = search(lines);
    cout << setprecision(16) << ansx << " " << ansy << endl;

    // auto expect = bruteforce(lines);
    // function<bool(double, double)> check = [](double a, double b) {
    //     return min(abs(a - b), b == 0 ? 1 : abs(1 - a / b)) < 1e-10;
    // };
    // if (!check(expect.second, ansx) || !check(expect.first, ansy))
    //     cerr << setprecision(16)
    //          << "expect " << expect.second << " " << expect.first << endl
    //          << "got " << ansx << " " << ansy << endl;;
}


Measured memory_bytes: 3896
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define PI acos(-1)
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int modpow(int x, int n, int m) {
	x %= m;
	int res = 1;
	while(n > 0) {
		if(n & 1)
			res = res * x % m;
		x = x * x % m;
		n >>= 1;
	}
	return res;
}

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());
	#ifndef ONLINE_JUDGE
		// freopen("input.txt", "r", stdin);
		// freopen("output.txt", "w", stdout);
	#endif

	string s;
	cin >> s;
	for(auto it : s) {
		cout << 'x';
	}

	return 0;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

int euclid(int a, int b)
{
    if (a < b)
        euclid(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

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

    int f = 0;
    int cnt = 1;
    for (int i = 0; i < n - 1; i++)
    {
        if (f == 0)
        {
            if (a[i + 1] == a[i])
            {
                // OK.
            }
            else if (a[i + 1] >= a[i])
            {
                f = 1;
            }
            else
            {
                f = -1;
            }
        }
        else if (f == 1)
        {
            if (a[i + 1] >= a[i])
            {
                // OK.
            }
            else
            {
                cnt++;
                f = 0;
            }
        }
        else if (f == -1)
        {
            if (a[i + 1] <= a[i])
            {
                // OK.
            }
            else
            {
                cnt++;
                f = 0;
            }
        }
    }
    cout << cnt << endl;
}


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

#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)


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

  int cnt=0;
  rep(i,n){
    if(i==0 && p[0] == 0){
      if(p[0] == 0){
        swap(p[0],p[1]);
        cnt++;
      }
      continue;
    }
    if(i==n-1){
      if(p[n-1] == n-1){
        swap(p[n-1],p[n-2]);
        cnt++;
      }
      continue;
    }
    if(p[i]==i){
      if(p[i+1]==i+1){
        swap(p[i+1],p[i]);
        cnt++;
        continue;
      }
      swap(p[i-1],p[i]);
      cnt++;
    }
  }
  cout << cnt << endl;
}

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

int main()
{
    int num1, num2, num3, a, ans;

    cin >> num1 >> num2 >> num3;

    a = num2/num1;

    if(a >= num3){
        ans = num3;
    }
    else{
        ans = a;
    }

    cout << ans << endl;

    return 0;
}

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

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

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<char>> A(H,vector<char>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> A.at(i).at(j);
    }
  }
  bool b=false;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(A.at(i).at(j)=='.'){
        continue;
      }
      bool a=false;
      for(int d=0;d<4;d++){
        int NX=dx[d]+i;
        int NY=dy[d]+j;
        if(0<=NX && NX<H && 0<=NY && NY<W && A.at(NX).at(NY)=='#'){
          a=true;
          break;
        }
      }
      if(!a){
        b=true;
        break;
      }
    }
    if(b){
      break;
    }
  }
  if(b){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
import math
a, b, C = map(float, input().split())

C = math.radians(C)

S = abs((b * a*math.sin(C)) / 2)
L = a + b + math.sqrt(a**2 + b**2 - 2*a*b*math.cos(C))
h = abs(b*math.sin(C))

print(S)
print(L)
print(h)


Measured memory_bytes: 5692
///17571@nith.ac.in @Ankit Verma
#include <bits/stdc++.h>
using namespace std;
#define ff          first
#define ss          second
#define pb          push_back
#define MP          make_pair
#define int         long long
#define ll          long long
#define inf         0x3f3f3f3f
#define MOD         1000000007
#define ld          long double
#define eb          emplace_back
#define pii         pair<int,int>
#define ull         unsigned long long
#define all(v)      v.begin(), v.end()
#define f(i,x,n)    for(int i=x;i<n;i++)
#define fr(i,x,n)   for(int i=x;i>=n;i--)
#define fastio      ios::sync_with_stdio(false)

#define n_l '\n'
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); } 
#define debug(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl

void IO() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

int32_t main() {
    IO();
    fastio;
    cin.tie(nullptr);
    cout.tie(nullptr);
    int a; cin >> a;
    int x = a + (a * a) + (a * a * a);
    cout << x << endl;
    

    return 0;
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    cout << s.at(0) << s.size()-2 << s.at(s.size()-1) << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
 
int main(){
    int N;
    int a, b;
    cin >> a >> b;
    int ans = 0;
    if (a>b){
        int temp = a;
        a = b;
        b = temp;
    }
    for (int i=0; i<b; i++){
        ans += a * pow(10, i);
    }
    cout << ans << endl;
}

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

public class Test
{
	public static void Main()
	{
		 string line = Console.ReadLine();
		 bool ok = true;
		 int cnt = 0;
		 for(int i = 0 ; i < line.Length ; i++){
			 if(line[0].ToString() != "A"){
				 ok = false;
			 }
			 if(i >= 2 && i < line.Length){
				 if(line[i] == 'C'){
					 cnt++;
				 }
			 }
			 if(line[i] != 'A' && line[i] != 'C'){
				 if(char.IsUpper(line[i])){
					 ok = false;
				 }
			 }
			 if(char.IsUpper(line[line.Length-1]))
			 {
			     ok = false;
			 }
			 
		 }
		 if(cnt != 1){
			 ok = false;
		 }

		 if(ok){
			 Console.WriteLine("AC");
		 } else {
			 Console.WriteLine("WA");
		 }
	}
}


Measured memory_bytes: 13140
N = int(input())
S = input()

if N%2 == 1:
	print('No')
else:
	flag = 1
	for i in range(N//2):
		if S[i] != S[i+N//2]:
			flag = 0
	if flag == 0:
		print('No')
	else:
		print('Yes')

Measured memory_bytes: 38384
N=int(input())
T,X,Y=[],[],[]
for i in range(N):
  TT,XX,YY=map(int,input().split())
  T.append(TT)
  X.append(XX)
  Y.append(YY)
ans=1
if(X[0]+Y[0]>T[0] or (T[0]-X[0]+Y[0])%2):
  ans=0
for i in range(N-1):
  Z=abs(X[i+1]-X[i])+abs(Y[i+1]-Y[i])
  if(Z>T[i+1]-T[i] or (T[i+1]-T[i]-Z)%2):
    ans=0
if(ans):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 11764
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;

namespace IO {
  static const int SZ = 1 << 20;
  static FILE *fin = stdin, *fout = stdout;
  static char ibuf[SZ], *is = ibuf, *it = ibuf;
  static char obuf[SZ], *os = obuf, *ot = obuf + SZ;

  inline char nextChar() {
    if (is == it) {
      it = (is = ibuf) + fread(ibuf, sizeof(char), SZ, fin);
      if (is == it)
        return EOF;
    }
    return *is++;
  }
  template <typename T>
  inline void readInt(T &x) {
    x = 0;
    T flag(1);
    char ch;
    for (ch = nextChar(); isspace(ch); ch = nextChar())
      ;
    if (ch == '-')
      ch = nextChar(), flag = -flag;
    for (; isdigit(ch); ch = nextChar())
      x = x * 10 + ch - '0';
    x *= flag;
  }
  inline void readCh(char &now) {
    for (now = nextChar(); isspace(now); now = nextChar())
      ;
  }

  inline void flushBuffer() {
    fwrite(obuf, sizeof(char), os - obuf, fout);
    os = obuf;
  }
  inline void printChar(char ch) {
    if (os == ot)
      flushBuffer();
    *os++ = ch;
  }
  template <typename T>
  inline void printInt(T x) {
    static int dig[20], cnt;
    if (os + 20 > ot)
      flushBuffer();
    if (x < 0)
      *os++ = '-', x = -x;
    cnt = 0;
    do {
      dig[++cnt] = x % 10;
      x /= 10;
    } while (x);
    for (int i = cnt; i > 0; --i)
      *os++ = dig[i] + '0';
  }
}

using namespace IO;

const int N = 55;

int n, m;
char s1[N], s2[N];

int main() {
#ifdef LOCAL_DEBUG
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
#endif
  scanf("%s\n%s", s1 + 1, s2 + 1);
  n = strlen(s1 + 1), m = strlen(s2 + 1);
  for (int i = n - m + 1; i >= 1; --i) {
    bool flag = true;
    for (int j = 1; j <= m; ++j) {
      if (s1[i + j - 1] == '?' || s1[i + j - 1] == s2[j])
        continue;
      flag = false;
    }
    if (flag) {
      for (int j = 1; j <= m; ++j) {
        if (s1[i + j - 1] == '?')
          s1[i + j - 1] = s2[j];
      }
      for (int j = 1; j <= n; ++j)
        if (s1[j] == '?')
          s1[j] = 'a';
      puts(s1 + 1);
      return 0; 
    }
  }
  puts("UNRESTORABLE");
//  flushBuffer();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#include <set>
#include <iterator>
using namespace std;
using namespace __gnu_pbds;


#define ft first
#define sd second
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF INT_MAX

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )

typedef tree<pll, null_type, less<pll>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
const int N=30, M=(ll)1e6+10 ;
const int mod = 1e9+7 ;

// vl compute(string s){
//         vl has(s.length());
//         ll i;

//         for(i=0;i<s.length();i++){
//             if(i==0){
//                 has[i]=((s[i]-'a'+1))%mod;
//             }
//             else
//                 has[i]=(has[i-1]*p + (s[i]-'a'+1))%mod;
//         }
//         return has;
// }

void print(ll n,ll a,ll b){
    ll i,j;
    string s="aeiou";
    for(i=0;i<a;i++){
        for(j=0;j<b;j++){
            cout << s[(i+j)%5];
        }
    }
}
int main(){
 ios_base::sync_with_stdio(0);
 ll n,k;
 cin >> n >> k;
 string s;
 cin >> s;
 if(s[k-1]=='A')
  s[k-1]='a';
else if(s[k-1]=='B')
  s[k-1]='b';
else
  s[k-1]='c';
  cout << s;
 
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    string s;
    cin >> s;
    string s1, s2;
    
    s1 = s.substr(0,3);
    s2 = s.substr(1,3);

    if (s2 == "000" || s2 == "111" || s2 == "222" || s2 == "333" || s2 == "444" || s2 == "555" || s2 == "666"|| s2 == "777" || s2 == "888" || s2 == "999"  ||
    s1 == "000" || s1 == "111" || s1 == "222" || s1 == "333" || s1 == "444" || s1 == "555" || s1 == "666"|| s1 == "777" || s1 == "888" || s1 == "999")cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    string s; cin >> s;
    ll k; cin >> k;
    int n = s.size();
    ll ans = 0;

    //全部同じ場合は例外
    bool isSameAll = true;
    rep(i,n-1){
        if(s[i] != s[i+1]){
            isSameAll = false;
            break;
        }
    }
    
    if(isSameAll){
        ans = n*k/2;
    }else{

        //端の例外処理
        ll fcnt = 1, lcnt = 1;
        rep(i,n-1){ //最初から見た時に何個同じのが並ぶか
            if(s[i] != s[i+1]) break;
            fcnt++;
        }
        for(int i = n-1; i >= 1; --i){ //最期から見た時に何個同じのが並ぶか
            if(s[i] != s[i-1]) break;
            lcnt++;
        }
        
        //何個同じ文字が続くか
        int cnt = 1;
        for(int i = fcnt; i <= n - lcnt - 1; i++){
            if(s[i+1] == s[i]) cnt++;
            else{
                ans += cnt/2; //端以外の繰り返しはcnt/2
                cnt = 1; //1文字連続にリセット
            }
        }
        ans *= k; //端以外の繰り返しはk回起こる

        if(s[0] == s[n-1]){
            ans += (fcnt + lcnt)/2*(k-1);
        }else{
            ans += fcnt/2*(k-1);
            ans += lcnt/2*(k-1);
        }
        ans += fcnt/2; ans += lcnt/2;//左右端の処理
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MOD 1000000007
typedef long long  ll;

using namespace std;


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

	ll A;
	long double B;
	cin >> A >> B;

	ll ans = floor(A*B);
	//long double dns = A * B;

	cout << ans << endl;
	//cout << fixed << setprecision(2);
	//cout << dns << endl;

	return 0;
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

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

	for(int i=0; i<max(a, b); i++) cout << min(a, b);
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int n;cin>>n;
    vector<int>s(n);
    int sum = 0;
    rep(i,n){cin>>s[i];sum+=s[i];}
    if(sum%10!=0){co(sum);return 0;}
    sort(s.begin(),s.end());
    rep(i,n){
        if((sum-s[i])%10!=0){co(sum-s[i]);return 0;}
    }
    co(0);
}

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

int main(){
    int N;
    cin >> N;
    vector<int>a(N+1);
    for(int i=1;i<=N;i++){
        cin>>a.at(i);
    }
    int count=1,i=a.at(1);//ボタン1
    while(i != 2 && count<N+50){
        count++;
        i=a.at(i);
    }
    if(i==2){
        cout<<count<<endl;
    }else{
        cout<<-1<<endl;
    }
}



Measured memory_bytes: 640
D, G = [int(_) for _ in input().split()]

cnts = []
bonuses = []
for i in range(D):
    a, b = [int(_) for _ in input().split()]
    cnts.append(a)
    bonuses.append(b)

# bonus で全探索
ans = 1e12
for i in range(2 ** D + 1):
    j = i
    bidx = []
    cnt = 0
    point = 0
    for j in range(D):
        if (i >> j) & 1:
            bidx.append(j)
            point += bonuses[j] + cnts[j] * 100 * (j + 1)
            cnt += cnts[j]

    for j in range(D - 1, -1, -1):
        if point >= G: break
        if j in bidx: continue
        for k in range(1, cnts[j] + 1):
            if point >= G: break
            point += (j + 1) * 100
            cnt += 1
    ans = min(cnt, ans)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include<algorithm>

using namespace std;

int calc_digit(long long N) {
	int res = 0;
	while (N) {
		++res;
		N /= 10;
	}
	return res;
}

int main()
{
	long long N;
	cin >> N;
	int res = (1 << 29);
	for (long long A = 1; A * A <= N; A++) {
		if (N % A == 0) {
			long long B = N / A;
			int F = max(calc_digit(A), calc_digit(B));
			res = min(res, F);
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
# 最初上をむいてる数はなんでもいいっぽいので6と5をこの順番で繰り返し貪欲するのがいい
# 6まで -> 1回 11まで -> 2回 17まで -> 3回 22まで -> 4回  28まで -> 5回...
x = int(input())
if x <= 6:
    print(1)
elif x <= 11:
    print(2)
else:
    print((x // 11) * 2 + (2 if (x % 11) > 6 else 1 if (x % 11) > 0 else 0))


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//split??????????????§????????????????§£????????£??\
		String[] lines = sc.nextLine().split(" ");
		int width = Integer.parseInt(lines[0]);
		int height = Integer.parseInt(lines[1]);
		int x = Integer.parseInt(lines[2]);
		int y = Integer.parseInt(lines[3]);
		int r = Integer.parseInt(lines[4]);
		String result;

		if(x - r >= 0 && x + r <= width && y - r >= 0 && y + r <= height) {
			result = "Yes";
		} else {
			result = "No";
		}



		System.out.println(result);

	}
}

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

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

  int N1, N10 ,N100, N1000;
  N1000 = N / 1000;
  N100 = (N - N1000 *1000) / 100;
  N10 = (N - N1000 * 1000 - N100 * 100) / 10;
  N1 = N - N1000 * 1000 - N100 * 100 - N10 * 10;

  if (N1000 == N100 == N10 == N1) {
    cout << "Yes" << endl;
  }
  else if (N1000 == N100 && N100 == N10) {
    cout << "Yes" << endl;
  }
  else if (N100 == N10 && N10 == N1) {
    cout << "Yes" << endl;
  }
    else  {
      cout << "No" << endl;
    }
}

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

int main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        string str;
        cin >> str;
        int ar[27] = {};
        for (int i = 0; i < 4; i++) ar[str[i] - 'A']++;
        int h = 0;
        vector<int> v;
        for (int i = 0; i < 26; i++) if (ar[i]) { ++h; v.push_back(ar[i]); }
        if (h == 2) {
                if (v[0] == 2) {
                        cout << "Yes";
                        return 0;
                }
        }
        cout << "No\n";
return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

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

    int N; cin >> N;

    ll ans = 0;

    unordered_map<ll,int> c;
    c[0]++;
    ll sum = 0;
    rep(i, N) {
        int A; cin >> A;
        sum += A;
        // if (c.count(sum) > 0)
            ans += c[sum];
        c[sum]++;
    }

    cout << ans << endl;
}


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

vector<pair<int,int>> dir = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int h, w, k;
	cin >> h >> w >> k;
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	--x1; --y1; --x2; --y2;
	vector<string> grid(h);
	for (int i = 0; i < h; ++i)
		cin >> grid[i];
	auto valid = [&](const pair<int, int>& p){ return p.first >= 0 && p.first < h && p.second >= 0 && p.second < w; };
	
	vector<vector<int>> dist(h, vector<int>(w, 1e9));
	auto bfs = [&](){
		queue<pair<int, int>> q;
		vector<vector<bool>> vis(h, vector<bool>(w));
		q.emplace(x1, y1);
		dist[x1][y1] = 0;
		vis[x1][y1] = 1;
		while (!q.empty()){
			auto u = q.front(); q.pop();
			for (int j = 0; j < 4; ++j){
				for (int i = 1; i <= k; ++i){
					int nr = u.first + i * dir[j].first;
					int nc = u.second + i * dir[j].second;
					if (!valid({nr, nc})) continue;
					if (grid[nr][nc] == '@' || dist[nr][nc] <= dist[u.first][u.second]) break;
					if (vis[nr][nc]) continue;
					dist[nr][nc] = dist[u.first][u.second] + 1;
					if (nr == x2 && nc == y2) return dist[nr][nc];
					vis[nr][nc] = 1;
					q.emplace(nr, nc);
				}
			}
		}
		return -1;
	};
	cout << bfs() << '\n';
}


Measured memory_bytes: 12136
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    map<int, int> mp;
    rep(i, n) {
        mp[a[i]]++;
    }
    vll p;
    for (auto x : mp) {
        if (x.se >= 2) p.push_back(x.fi);
        if (x.se >= 4) p.push_back(x.fi);
    }
    sort(rall(p));
    ll ans = 0;
    if (p.size() >= 2) ans = p[0]*p[1];

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5376
#include<stdio.h>
int main(void){
    int a,b,s;
    char op;
    while(1){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='?') break;
        if(op=='+'){
            s=a+b;
        }else if(op=='-'){
            s=a-b;
        }else if(op=='*'){
            s=a*b;
        }else if(op=='/'){
            s=a/b;
        }
        printf("%d\n",s);
    }
    return 0;
}


Measured memory_bytes: 2044
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using Debug = System.Diagnostics.Debug;

class P
{
    static void Main()
    {
        long n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(long.Parse).ToList();
        var sum = a.Sum();
        var incr = n * (n + 1) / 2;
        if (sum % incr != 0) goto invalid;
        var operationCount = sum / incr;
        var diffs = a.Zip(a.Skip(1), (x, y) => y - x).Concat(Enumerable.Repeat(a.First() - a.Last(), 1)).ToList();
        long totalOperate = 0;
        foreach (var diff in diffs)
        {
            if ((operationCount - diff) < 0 || (operationCount - diff) % n != 0) goto invalid;
            totalOperate += (operationCount - diff) / n;
        }
        if (totalOperate != operationCount) goto invalid;

        Console.WriteLine("YES");
        return;
        invalid:;
        Console.WriteLine("NO");
    }
}


Measured memory_bytes: 24032
#include<stdio.h>
#include<iostream>
#include<algorithm> // sort(ALL())
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue> // push(), front(), pop() 先入れ先出し
#include<map> // 連想配列 map<string, int>
#include<iomanip>
#include<set>
#include<utility>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
#define MAX_INDEX(arg) distance(arg.begin(), max_element(arg.begin(), arg.end()))
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;
#define INT(argu) (int)(argu+EPS)

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

  int n;
  scan(n);
  n /= 2;
  vint a(100002), b(100002);
  int x, y;
  REP(i, n){
    cin >> x >> y;
    a[x]++; b[y]++;
  }

  vint::iterator itrmaxa = max_element(ALL(a));
  vint::iterator itrmaxb = max_element(ALL(b));
  vint::iterator itra = find(next(itrmaxa), a.end(), *itrmaxa);
  vint::iterator itrb = find(next(itrmaxb), b.end(), *itrmaxb);
  bool find_2_a = itra != a.end();
  bool find_2_b = itrb != b.end();
  if( !(find_2_a || find_2_b) && (distance(a.begin(), itrmaxa) == distance(b.begin(), itrmaxb)) ){
    cout <<
    n*2 -
    max(
      max(*max_element(a.begin(), prev(itrmaxa)), *max_element(next(itrmaxa), a.end())) + *itrmaxb
    , max(*max_element(b.begin(), prev(itrmaxb)), *max_element(next(itrmaxb), b.end())) + *itrmaxa
    )
    << endl;
  }else{
    cout << n*2 - *itrmaxa - *itrmaxb << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
n, k = gets.split(' ').map{|e|e.to_i}

mischief = []
n.times do |i|
  mischief[i] = true
end

k.times do
  gets
  a = gets.split(' ').map{|e|e.to_i}
  a.each do |e|
    mischief[e-1] = false
  end
end

puts mischief.count(true)


Measured memory_bytes: 14384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define chmin(a,b) a = min(a,b)
#define chmax(a,b) a = max(a,b)
#define all(a) a.begin(), a.end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;

int main(){
    int n; cin >> n;
    vi a(n), b(n), c(n);
    
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    rep(i,n)cin>>c[i];
    
    sort(all(a));
    sort(all(b));
    sort(all(c));
    
    ll ans = 0;
    
    
    rep(i,n){
        ll na = lower_bound(all(a), b[i]) - a.begin();
        ll nc = c.end() - upper_bound(all(c), b[i]);
        ans  += na * nc;
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 4560
#include<bits/stdc++.h>
using namespace std;
int N;
vector<int> G[100010];
template<class T> void chmax(T& x, T y) {if(x < y) x = y;}
int rnk(int n){
    int mx = G[n].size();
    vector<int> vs;
    for(auto& u : G[n]){
        vs.push_back(rnk(u));
    }
    sort(vs.rbegin(), vs.rend());
    for(int i = 0; i < vs.size(); i++){
        chmax(mx, vs[i] + i);
    }
    return mx + 1;
}

int main(){
    cin >> N;
    for(int i = 2; i <= N; i++){
        int a;
        cin >> a;
        G[a].push_back(i);
    }
    cout << rnk(1) - 1 << endl;
    return 0;
}

Measured memory_bytes: 16640
#include <stdio.h>

int main() {
	int H, W;
	int h, w;
	
	int x, y, total;

	scanf("%d %d", &H, &W);
	scanf("%d %d", &h, &w);

	x = H - h;
	y = W - w;

	total = x * y;

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

	return 0;


}

Measured memory_bytes: 128
# Import
from collections import deque

# I/O
def read(): return input()
def read_int(): return int(input())
def read_array(type=int): return list(map(type, input().split()))
def read_tupple(type=None):
    tmp = input().split()
    if type is None: return map(int, tmp)
    assert len(tmp) == len(type)
    return [type[i](tmp[i]) for i in range(len(tmp))]

# Implementation
class PrimeNumber:
    def __init__(self, N):
        self.N = N
        self.isP, self.P = self.compute(N)

    def compute(self, N):
        isP, P = [True] * (N + 1), []
        for i in range(2, N+1):
            if isP[i]:
                P.append(i)
                for j in range(2*i, N+1, i):
                    isP[j] = False
        return isP, P

N = read_int()

pn = PrimeNumber(1000006)
ans = 0
for p in pn.P:
    cnt = 0
    while N % p == 0:
        N /= p
        cnt += 1
    dec = 1
    while cnt >= dec:
        cnt -= dec
        dec += 1
        ans += 1
if N > 1:
    ans += 1
print(ans)

Measured memory_bytes: 80980