akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    int n;cin>>n;
    vl a(n+1),b(n);
    rep(i,n+1)cin>>a[i];
    rep(i,n)cin>>b[i];
    ll cnt=0;
    rep(i,n){
        if(a[i]<b[i]){
            cnt+=a[i];
            if(a[i+1]-(b[i]-a[i])>0){a[i+1]=a[i+1]-(b[i]-a[i]);cnt+=b[i]-a[i];}
            else {cnt+=a[i+1];a[i+1]=0;}
        }
        else{
            cnt+=b[i];
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
 	cin >> n;
  int a[n], b[n];
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n);
  int cnt = 0;
  for(int i = 0; i < n; i++){
    if(a[i] != b[i]) cnt++;
  }
  if(cnt == 0 || cnt == 2) cout << "YES";
  else cout << "NO";
  
}

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

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

	int keta = 0;
	for(int i = N; i > 0; i/=10){
		keta++;
	}

	int cnt = 0;
	int j;
	for(int i = 1 ; i <= keta; i++){
		if (i == 1) j = 1;
		else j *= 10;

		if( i % 2 == 0 ) continue;

		if( j <= N && N < j * 10 ){
			cnt += N - j + 1;
		}
		else {
			cnt += 9 * j;
		}
	}

	cout << cnt << endl;
}


Measured memory_bytes: 256
function main(input) {
  input=input.trim();
  const a = parseInt(input.split(" ")[0], 10);
  const b = parseInt(input.split(" ")[1], 10);

  var ans=0
  for(var i=a; i<=b; i++){
    var temp=0;
    for(var j=0; j<Math.floor(String(i).length/2); j++){
      //console.log(String(i).substr(j, 1));
      //console.log(String(i).substr(String(i).length-j-1, 1));
      if(String(i).substr(j, 1)!=String(i).substr(String(i).length-j-1, 1)){
        temp++
      }
    }
    if(temp==0){
      ans++
    }
  }
  console.log(ans);
}



main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 11952
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a,b;
bool vis[4];
int main(){
    scanf("%d%d",&a,&b);
    vis[a]=vis[b]=true;
    for(int i=1;i<=3;i++)if(!vis[i])return printf("%d\n",i),0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
  cout << fixed << setprecision(10);
  long long n,m,d;cin>>n>>m>>d;
  //m-1が最大値
  //1,1+d
  //n-d,n
  long long ok = 0;
  if(d!=0)ok = (n-d)*2;
  else ok = (n-d);
  long long al = n*n;
  cout << (long double)(m-1)*ok/al << endl;
}

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

using namespace std;


int n,q,com,x,y;
int rank[10000],parent[10000];

int find(int x){
	if(x == parent[x])return x;
	else{
		return parent[x] = find(parent[x]);
	}
}

bool isSame(int x,int y){
	return find(x) == find(y);
}

void unite(int x,int y){
	x = find(x);
	y = find(y);

	if(x == y)return;

	if(rank[x] < rank[y]){
		parent[x] = y;
	}else{
		parent[y] = x;
		if(rank[x] == rank[y])rank[x]++;
	}
}

int main(){

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

	for(int i = 0; i < n; i++){
		rank[i] = 0;
		parent[i] = i;
	}

	for(int i = 0; i < q; i++){
		scanf("%d %d %d",&com,&x,&y);

		if(com == 1){
			if(isSame(x,y))printf("1\n");
			else{
				printf("0\n");
			}
		}else{
			if(isSame(x,y))continue;

			unite(x,y);
		}
	}

	return 0;
}


Measured memory_bytes: 2772
#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9+10)
#define ll_MIN (ll)(-1e9*1e9-10)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
//using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 (long long)998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX
 

void solve()
{
  int n;
  cin >> n;
  int arr[n];
  inp(arr, n);
  int curr = 0;
  int ans = 0;
  rep(i,0,n-1)
    ans += max((int)0, curr-arr[i]), curr = max(curr, arr[i]);
  cout << ans << endl;
}


 
signed main()
{
    
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 5108
program main
  implicit none
  integer(8) :: n, i, k, fn, d
  character(10) :: s
  read(*, *) n
  write(s, "(i0)") n
  k = len(trim(s))
  fn = 0
  do i = 1, k
    read(s(i:i), "(i1)") d
    fn = fn + d
  end do
  if (mod(n, fn) == 0) then
    write(*, "(a)") "Yes"
  else
    write(*, "(a)") "No"
  end if
end program main


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        int[] input = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int kyori = input[3] * 2;

        if (Math.Abs(input[0] - input[2]) <= input[3])
        {
            WriteLine("Yes");
            return;
        }

        if (Math.Abs(input[0] - input[2]) <= kyori)
        {
            if (Math.Abs(input[0] - input[1]) <= input[3] &&
                Math.Abs(input[1] - input[2]) <= input[3])
            {
                WriteLine("Yes");
            }
            else
            {
                WriteLine("No"); 
            }
        }
        else
        {
            WriteLine("No");
        }

    }
}

Measured memory_bytes: 13396
#include <algorithm>
#include <deque>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  string s;
  cin >> s;
  deque<char> dq;
  for (int i = 0; i < s.size(); ++i) {
    dq.push_back(s[i]);
  }

  int q;
  cin >> q;
  bool rev = false;
  for (int i = 0; i < q; ++i) {
    int t;
    cin >> t;
    if (t == 1) {
      rev = !rev;
    } else {
      int f;
      char c;
      cin >> f;
      cin >> c;
      if (rev)
        f = 3 - f;
      if (f == 1) {
        dq.push_front(c);
      } else {
        dq.push_back(c);
      }
    }
  }

  if (!rev) {
	cout << string(dq.begin(), dq.end()) << endl;
  } else {
	cout << string(dq.rbegin(), dq.rend()) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1216
#include<iostream>
using namespace std;
#define ll long long int

int main(){
	ll hash[10000005]={};
	ll i;
	for(i=2;i<=10000001;i++){
		ll j=i;
		while(j<10000005){
			hash[j]++;
			j=j+i;
		}
	}
	ll n;
	cin>>n;
	ll ans = 0;
	for(i=1;i<=n;i++){
		ans =ans+i*(hash[i]+1);
	}
	cout<<ans;
}

Measured memory_bytes: 81764
def makelis(eve):
    li =[]
    for i in range(eve//2):
        li.append([eve-i,i+1])
    return li

N =int(input())



if N%2==0:
    numlis = makelis(N)
else:
    numlis = makelis(N-1)
    numlis.append([N])

num =0
for li in numlis:
    num += len(li)*(N-len(li))
print(num//2)

for li in numlis:
    for j in li:
        for i in range(N):
            if not i+1 in li and j < i+1:
                print("{} {}".format(j,i+1))


Measured memory_bytes: 3336
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;

int n,k,x,b[200050],m;

int main()
{
    scanf("%d%d",&n,&k);
    m=n;
    for (int i=1;i<=n;i++) 
    {
        scanf("%d",&x);
        b[x]++;
    }
    sort(b+1,b+n+1);
    for (int i=n;i>=n-k+1;i--) m-=b[i];
    cout<<m<<endl;
    return 0;
}
    
    


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

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

ll Q,H,S,D,N;

int main()
{
	cin >> Q >> H >> S >> D >> N;

	ll x = min({Q * 4,H * 2,S});
	ll ans = 0;
	if(x * 2 <= D){
		ans = x * N;
	}
	else{
		ans = D * (N / 2) + x * (N % 2);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;

class Main{
	public static void main(String Args[]){
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		BigInteger A = new BigInteger(str);
		str = sc.next();
		BigInteger B = new BigInteger(str);
		System.out.println(A.divide(B));
	}
}



Measured memory_bytes: 26524
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int H,W;
  cin>>H>>W;
  lint ans;
  auto dif_max=[](lint a,lint b,lint c){return lint(max({abs(a-b),abs(b-c),abs(c-a)}));};
  ans=min(H,W);
  if(H%3==0 or W%3==0)ans=0;
  ans=min(ans,dif_max(H*(W/3),(W-W/3)*(H/2),(W-W/3)*(H-H/2)));
  ans=min(ans,dif_max(H*(W/3+1),(W-W/3-1)*(H/2),(W-W/3-1)*(H-H/2)));
  int temp=H;
  H=W;
  W=temp;
  ans=min(ans,dif_max(H*(W/3),(W-W/3)*(H/2),(W-W/3)*(H-H/2)));
  ans=min(ans,dif_max(H*(W/3+1),(W-W/3-1)*(H/2),(W-W/3-1)*(H-H/2)));
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
def i_sort(l,g):
    cnt=0
    for i in range(g,len(l)):
        x=l[i]
        j=i
        while(0 <= j-g and l[j-g] > x):
            l[j-g],l[j]=l[j],l[j-g]
            j-=g
            cnt+=1
    return cnt


def mk_G(l):
    G=[1]
    i=0
    while(1):
        if(len(l) <= 3*G[i] +1):
            break
        G.append(3*G[i]+1)
        i+=1
    G.reverse()
    return G

def shell_sort(l,G):
    cnt=0
    if(len(l)!=1):
        for i in G:
            cnt+=i_sort(l,i)
    return cnt
        
        





n=int(input())
A=[]
for i in range(n):
    A.append(int(input()))

G=mk_G(A)

count=shell_sort(A,G)

print(len(G))
print(" ".join(list(map(str,G))))
print(count)
for i in A:
    print(i)


Measured memory_bytes: 45524
using System;

namespace ALDS1_4_C_Dictionary
{
	class Program
	{
		static void Main ( string[] args )
		{
			int orderCount = int.Parse (Console.ReadLine ());
			HashTable hashTable = new HashTable ();

			for (int lp = 0; lp < orderCount; lp++)
			{
				string[] inputStr = Console.ReadLine ().Split (' ');

				if (inputStr[0] == "insert")
				{
					hashTable.Insert (inputStr[1]);
				}
				else
				{
					bool isFind = hashTable.Find (inputStr[1]);

					if (isFind)
						Console.WriteLine ("yes");
					else
						Console.WriteLine ("no");
				}
			}
		}
	}

	class HashTable
	{
		//?????????????????????
		public HashTable ()
		{
			this.Table = new string[1046527];
		}

		//?????\
		public void Insert ( string item )
		{
			int count = 0;
			int key = GetKey (item);

			while (true)
			{
				int hashKey = GetHashKey (key, count);

				if (Table[hashKey] == null)
				{
					Table[hashKey] = item;
					return;
				}
				else if (Table[hashKey] == item)
				{
					return;
				}
				else
				{
					count++;
					hashKey = GetHashKey (key, count);
				}
			}
		}

		//????´¢
		public bool Find ( string item )
		{
			int count = 0;
			int key = GetKey (item);
			int hashKey = 0;

			while (true)
			{
				hashKey = GetHashKey (key, count);

				if (Table[hashKey] == item)
				{
					return true;
				}
				else if (Table[hashKey] == null || Table.Length <= count)
				{
					return false;
				}
				else
				{
					count++;
				}
			}
		}

		//???????????\??¢??°
		private int GetKey ( string item )
		{
			int sum = 0;
			int power = 1;

			foreach (var item2 in item)
			{
				int key = 0;

				switch (item2)
				{
					case 'A':
						key = 1;
						break;
					case 'C':
						key = 2;
						break;
					case 'G':
						key = 3;
						break;
					case 'T':
						key = 4;
						break;
				}

				sum += key * power;
				power *= 5;
			}

			return sum;
		}
		private int GetHashKey ( int key, int count )
		{
			int h1 = key % Table.Length;
			int h2 = 1 + (key % (Table.Length - 1));

			return (h1 + h2 * count) % Table.Length;
		}

		//??????
		private string[] Table { set; get; }
	}
}

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

const string yes = "Yes";
const string no = "No";

int main()
{
  int n; cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  if (a == b) {
    cout << yes << endl;
    return 0;
  }

  ll cnt = 0;
  rep(i, n) {
    if (b[i] >= a[i]) {
      cnt += (b[i]-a[i])/2;
    } else {
      cnt -= a[i]-b[i];
    }
  }

  if (cnt < 0) cout << no << endl;
  else cout << yes << endl;

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<map>

using namespace std;

int main(){
  string s, t;
  map<char, char> ms, mt;
  
  cin >> s >> t;
  
  for(int i = 0;i < s.size();i++){
    if(ms[s[i]] == '\0' && mt[t[i]] == '\0'){
      ms[s[i]] = t[i];
      mt[t[i]] = s[i];
    }
    if(ms[s[i]] != t[i] || mt[t[i]] != s[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 776
N = int(raw_input())
A = map(int, raw_input().split())

X = [0 for _ in range(13)]
for a in A:
    X[a / 400] += 1
cnt = 0
for x in X[:8]:
    if x != 0:
        cnt += 1
cnt2 = sum(X[8:])

print max(1, cnt), cnt + cnt2


Measured memory_bytes: 2568
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{
public static void main(String[] args) throws FileNotFoundException, IOException{
       Scanner s=new Scanner(System.in);
      int n=s.nextInt(),k=s.nextInt();
      long[] arr=new long[n+1];
      long sum=0; long res=0;
      for(int i=1;i<=n;i++){
        int p=s.nextInt();
        sum+=p;
        //if(p%k==1){res++;}
        arr[i]=(sum-i)%k;
        //System.out.print(arr[i]+" ");
      }
      Map<Long,Long>map=new HashMap<>();
     map.put(0l,1l); 
      int j=0;
      for(int i=1;i<=n;i++){
        if(i-j+1>k){
          map.put(arr[j],map.get(arr[j])-1);
          if(map.get(arr[j])==0){
            map.remove(arr[j]);
          }
          j++;
        }
          //System.out.println(arr[i]);
          res+=map.getOrDefault(arr[i],0l);
         map.put(arr[i],map.getOrDefault(arr[i],0l)+1);
      }
        System.out.println(res);
        }
    }


Measured memory_bytes: 92588
total, N = map(int, input().split())
nums = list(map(int, input().split()))
if N == 1:
    print(0)
else:
    ans = total - (total - nums[-1] + nums[0])
    prev = nums[0]
    for num in nums[1:]:
        ans = min(total-(num - prev), ans)
        prev = num
    print(ans)


Measured memory_bytes: 26100
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
// #define __lcm(a, b) std::__detail::__lcm(a, b)
#define PI 3.141592653589793
#define degrees(a) a * 180.0 / PI;

typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  double A, B, X;
  cin >> A >> B >> X;
  double s1 = X / (A * A) * A;
  double h1 = (2 * s1) / B;
  double ans1 = degrees(atan2(B, h1));

  double s2 = A * B - s1;
  double h2 = (2 * s2) / A;
  double ans2 = degrees(atan2(h2, A));

  if (X / (A * A) <= B / 2)
    cout << fixed << setprecision(10) << ans1 << endl;
  else
    cout << fixed << setprecision(10) << ans2 << endl;
  return 0;
}


Measured memory_bytes: 4120
import java.util.Scanner;

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

        String N2 = String.valueOf(N);
        String result = "";

        for(int i = 0; i<N2.length(); i++){
            String temp = N2.substring(i,i+1);
            if(temp.equals("9")) {
                temp = "1";
            }else{
                temp = "9";
            }

            result += temp;
        }
        System.out.print(result);
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define ft first
#define sd second
#define pb push_back
using ll = long long;
const int INF = 1e9+7;
const int EPS = -1e6;
inline void fastio() { ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);}
const int maxn = 100000+5;
int k,n;
int h[maxn];
int main(){
    fastio();
    cin >> n >> k;
    for(int i=0;i<n;i++) cin >> h[i];
    sort(h,h+n);
    int ans = INF;
    for(int i=0;i<n-k+1;i++)  ans = min(ans,h[i+k-1]-h[i]);
    
    cout << ans << endl;
}

Measured memory_bytes: 640
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let mut s = read::<String>().chars().collect::<Vec<_>>();
    s[3] = '8';
    let s: String = s.into_iter().collect();
    println!("{}", s);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end



int main(){
   int n; scanf("%d",&n);
   string s; cin>>s;
   int res=0;
   rep(i,0,n-2)if(s.substr(i,3)=="ABC")res++;
   printf("%d\n",res);
   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 a= sc.nextInt();
        int b= sc.nextInt();
        int c= sc.nextInt();
        if(a>b){
            if(b>c){
                System.out.printf("%d %d %d\n",c,b,a);
            }
            else if(c>a){
                System.out.printf("%d %d %d\n",b,a,c);
            }
            else {
                System.out.printf("%d %d %d\n",b,c,a);
            }
        }
        else if(a<b){
            if(c>b){
                System.out.printf("%d %d %d\n",a,b,c);
            }
            else if(c<a){
                System.out.printf("%d %d %d\n",c,a,b);
            }
            else{
                System.out.printf("%d %d %d\n",a,c,b);
            }
        }
        }
    }


Measured memory_bytes: 26276
N, P = map(int, input().split())
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table
prime = prime_decomposition(P)
now = -1
count = 0
res = 1
for i in range(len(prime)):
    if now != prime[-i-1]:
        count = 0
        now = prime[-i-1]
    count += 1
    if count == N:
        res *= prime[-i-1]
        count = 0
print(int(res))

Measured memory_bytes: 3064
n = int(input())

x = []
y = []
for i in range(n):
    a,b = map(int,input().split())
    x.append(a)
    y.append(b)
d1_max = x[0]+y[0]
d1_min = x[0]+y[0]
d2_max = x[0] - y[0]
d2_min = x[0]-y[0]
ans = -1
for i in range(1,n):
    d1_max = max(d1_max,x[i]+y[i])
    d1_min = min(d1_min,x[i]+y[i])
    d2_max = max(d2_max,x[i] - y[i])
    d2_min = min(d2_min,x[i]-y[i])
    ans = max((d1_max-d1_min),(d2_max-d2_min))
print(ans)

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

#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
	string s; cin>>s;
	string div[4]={"dream","dreamer","erase","eraser"};
	reverse(s.begin(),s.end());
	rep(i,4){
		reverse(div[i].begin(),div[i].end());
	}
	bool can=true;
	for(int i=0;i<s.size();){
		bool can2=false;
		rep(j,4){
			string d=div[j];
			if(s.substr(i,d.size())==d){
				can2=true;
				i+=d.size();
			}
		}
		if(!can2){
			can=false;
			break;
			}
	}
	if(can) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	string n;
	cin>>n;
	bool isok = false;
	for(int i=0;i<n.size();i++)
	{
		if(n[i] == '7')
			isok = true;;
	}
	if(isok)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
}

Measured memory_bytes: 3624
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def prime_factors(N): #素因数#エラーある
    ret = []
    middle = int( N**(1/2))
    tmp = N
    for i in range(2, middle+1):
        if tmp%i == 0:
            while tmp%i == 0:
                tmp //= i
            ret.append(i)
    if tmp != 1:
        ret.append(tmp)
    return ret


    
def main():
    a, b = map( int, input().split())
    d = gcd(a,b)
#    print(2, is_prime(2))
    if d == 1:
        print(1)
        return

    print(len(prime_factors(d))+1)

if __name__ == '__main__':
    main()


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
ll const N=(ll)3e2+11;
ll const LG=(ll)log2(N)+1;


void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        
        cin>>n;
        vll a(n+1);
        ll ans=0;
        ll sum=0;
        for(i=1;i<=n;i++){
                cin>>a[i];
                a[i]+=a[i-1];
        }
        ans=1e11;
        for(i=1;i<n;i++){
                ans=min(ans,abs(a[n]-a[i]-a[i]));
        }
        cout<<ans<<endl;
        
        
        
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if(a >= 13){
    cout << b << endl;
  }else if(a <= 5){
    cout << 0 << endl;
  }else {
    cout << b / 2 << 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<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod = 1000000007;		



int main() {

	int n, W;
	cin >> n >> W;

	VLL w(n), v(n);

	REP(i, n)cin >> w[i] >> v[i];

	VLL dp(100002, INFL);

	dp[0] = 0;

	REP(i, n) {
		for (int j = 100001; j >= v[i]; j--) {
			chmin(dp[j], dp[j - v[i]] + w[i]);
		}
	}

	ll ans = 0;
	REP(i, 100001)if (dp[i] <= W)chmax(ans, (ll)i);

	cout << ans << endl;

}
 


Measured memory_bytes: 1152
h,w = map(int,input().split())
s = [input() for i in range(h)]
for i in range(h):
         for j in range(w):
                  if s[i][j] == "#":
                           if s[max(0,i-1)][j] == "." and s[min(h-1,i+1)][j] == "." and s[i][max(0,j-1)] == "." and s[i][min(w-1,j+1)] == ".":
                                    print("No")
                                    exit()
print("Yes")



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

using namespace std;

using int64 = long long;

int64_t mod_pow(int64_t x, int64_t n, int64_t mod) {
  int64_t ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return ret;
}

vector< vector< int64_t > > get_combination(int N, int mod) {
  vector< vector< int64_t > > mat(N + 1, vector< int64_t >(N + 1));
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= i; j++) {
      if(j == 0 || j == i) mat[i][j] = 1;
      else mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j];
      mat[i][j] %= mod;
    }
  }
  return (mat);
}


int N, M;
int64 dp[5000][5000];


int main() {
  cin >> N >> M;
  auto table = get_combination(N, M);

  int64 ret = 0;

  vector< int64 > dp2(N + 2);
  dp2[0] = 1;

  for(int k = 0; k <= N; k++) {
    int64 latte = mod_pow(2, N - k, M), base = 1;
    int64 add = mod_pow(2, mod_pow(2, N - k, M - 1), M);
    for(int j = 0; j <= k; j++) { // 正確にj個選ぶ
      if(k % 2 == 0) ret += add * dp2[j] % M * base % M * table[N][k] % M;
      else ret += M - (add * dp2[j] % M * base % M * table[N][k] % M);
      ret %= M;
      (base *= latte) %= M;
    }
    for(int j = k; j >= 0; j--) {
      dp2[j + 1] += dp2[j];
      dp2[j + 1] %= M;
      dp2[j] += dp2[j] * j % M;
      dp2[j] %= M;
    }
  }
  cout << ret << endl;
}



Measured memory_bytes: 70784
#include <iostream>                                                                
                                                                                   
int main()                                                                         
{                                                                                  
  int x;                                                                           
  std::cin >> x;                                                                   
  if ( x < 1200 )                                                                  
    std::cout << "ABC";                                                            
  else                                                                             
    std::cout << "ARC";                                                            
  std::cout << std::endl;                                                          
  return 0;                                                                        
} 

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

int main () {
	int N;
	cin >> N;
	vector<int> v;
	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		v.push_back(x);
	}
	int bestMean = -101;
	int bestSum = 0;
	for (int curMean = -100; curMean <= 100; curMean++) {
		int cs = 0;
		for (int i = 0; i < N; i++) {
			int x = v[i];
			cs += ((x-curMean)*(x-curMean));
		}
		if (bestMean == -101 || cs < bestSum) {
			bestSum = cs;
			bestMean = curMean;
		}
	}
	cout << bestSum << "\n";
	return 0;
}

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

int main() {
	string S;
	cin >> S;
	int n = S.size();
	vector<char> v;
	
	for(int i = 0; i < n; i++) {
		if(S[i] == 'B') {
			if(v.size() == 0) continue;
			v.pop_back();
		} else {
			v.push_back(S[i]);
		}
	}
	
	for(int i = 0; i < v.size(); cout << v[i], i++);
	cout << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

int a[100010], b[100010];
int dp[2][100010];
bool used[100010];
signed main(void)
{
	int n, q;
	cin >> n >> q;
	REP(i, q) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
	}

	VI v[2];
	int cur = 0, vis = 1;
	dp[0][0] = 1;
	dp[0][1] = 2;
	v[0].PB(0); v[0].PB(1);
	//REP(i, n) cout << dp[cur][i] << " "; cout << endl;
	REP(i, q) {
		memset(used, false, sizeof(used));
		for(int j: v[cur]) {
			//cout << "j:" << j << endl;
			if(used[j]) continue;
			used[j] = true;
			if(a[i] == j) {
				dp[vis][b[i]] = dp[cur][j];
				v[vis].PB(b[i]);
				if(dp[cur][j] == 1) {
					if(b[i] != 0 && dp[vis][b[i]-1] == 0) {
						/*cout << "b-1:" << b[i]-1 << endl;*/ dp[vis][b[i]-1] = 2; v[vis].PB(b[i]-1);
					}
					if(b[i] != n-1 && dp[vis][b[i]+1] == 0) {
						/*cout << "b+1:" << b[i]+1 << endl;*/ dp[vis][b[i]+1] = 2; v[vis].PB(b[i]+1);
					}
				}
			}	else if(b[i] == j) {
				dp[vis][a[i]] = dp[cur][j];
				v[vis].PB(a[i]);
				if(dp[cur][j] == 1) {
					if(a[i] != 0 && dp[vis][a[i]-1] == 0) {
						/*cout<<"a-1:"<<a[i]-1;*/ dp[vis][a[i]-1] = 2; v[vis].PB(a[i]-1);
					}
					if(a[i] != n-1 && dp[vis][a[i]+1] == 0) {
						/*cout<<"a+1:"<<a[i]+1;*/ dp[vis][a[i]+1] = 2; v[vis].PB(a[i]+1);
					}
				}
			} else {
				dp[vis][j] = dp[cur][j];
				v[vis].PB(j);
				if(dp[cur][j] == 1) {
					if(j != 0 && dp[vis][j-1] == 0) {
						/*cout << "j-1:" << j-1 << endl;*/ dp[vis][j-1] = 2; v[vis].PB(j-1);
					}
					if(j != n-1 && dp[vis][j+1] == 0) {
						/*cout << "j+1:" << j+1 << endl;*/ dp[vis][j+1] = 2; v[vis].PB(j+1);
					}
				}
			}
			dp[cur][j] = 0;
		}
		v[cur].erase(ALL(v[cur]));
		//REP(j, n) cout << dp[vis][j] << " "; cout << endl;
		cur ^= 1;
		vis ^= 1;
	}

	ll ret = 0;
	REP(i, n) if(dp[cur][i] != 0) {
		ret++;
		//cout << i << " ";
	}
	cout << ret << endl;

	return 0;
}


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

int main() {
  int n;
  vector<int> b;
  cin>>n;
  for(int i=0; i<n-1; i++) {
    int m;
    cin>>m;
    b.push_back(m);
  }
  int ans=b[0];
  for(int i=0; i<n-1; i++){
    ans+=min(b[i],b[i+1]);
  }
  ans+=b[n-2];
  cout << ans << endl;
}

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

using namespace std;

int main() {
    int d;
    cin >> d;
    if (d == 25) cout << "Christmas" << endl;
    else if (d == 24) cout << "Christmas Eve" << endl;
    else if (d == 23) cout << "Christmas Eve Eve" << endl;
    else if (d == 22) cout << "Christmas Eve Eve Eve" << endl;
}



Measured memory_bytes: 384
fun main (args:Array<String>) {
    val (numOfSunuke , numOfCandy) = readLine()!!.split(" ").map(String::toInt)
    val haveList :MutableList<Int> = arrayListOf()
    for (i in 1..numOfCandy){
        val safeSunuke = readLine()!!.toInt()
        val b = readLine()!!.split(" ").map(String::toInt)
        haveList.addAll(b)

    }
    var count = 0
    for(i in 1..numOfSunuke){
        for (ii in 0..haveList.size-1){
            if(i == haveList[ii]){
                count++
                break
            }
        }
    }
    print(numOfSunuke - count)
}

Measured memory_bytes: 39264
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<endl
#define trii(x) cerr<<#x<<": ("<<x.F<<","<<x.S<<")\n";
#define trvii(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<"("<<a[zz].F<<","<<a[zz].S<<") ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<"\n"
#define trsetii(s) cerr<<#s<<": ";for(auto &i:s) trii(i);
#define epsilon 0.000000001L
#define mod 1000000007ll
#define inf 9999999999999999ll
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define modulo 998244353ll


int main()
{
    fast();
    ll k;
    string s;
    cin>>k>>s;
    if(sz(s)>k)
    {
        for(ll i=0;i<k;i++)
        {
            cout<<s[i];
        }
        cout<<"...\n";
    }
    else
        cout<<s<<nl;
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
typedef long long ll;
#define PI 3.14159265
ll exponent(ll x,ll n,ll m)
{  if(n==0)
    return 1;
    if(n%2!=0)
    {
        return (x*exponent(((x%m)*(x%m))%m,(n-1)/2,m))%m;
    }
    else
    return exponent(((x%m)*(x%m))%m,n/2,m);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(NULL);
    int n;
    cin>>n;
    map<pair<int,int>,int>m;
    for(int i=1;i<=n;i++)
    {
        int org=i;
        int last=org%10,first;
        while(org>0)
        {
            first=org;
            org=org/10;
        }
        m[{first,last}]+=1;
    }
    ll cnt=0;
    for(auto it:m)
    {
        int i=it.first.first;
        int j=it.first.second;
        //cout<<i<<" "<<j<<" "<<m[{i,j}]<<endl;
        cnt+=m[{i,j}]*m[{j,i}];
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 256
# Hina Arare solver (https://beta.atcoder.jp/contests/abc089/tasks/abc089_b)
module HinaArare
  # @param [Array[String]] s s(i) means i-th hina arare
  # @return [String] the number of the kind of hina arare (Three or Four)
  # Solve the hina arare problem
  def solve(s)
    for i in 1..s.size do
      if s[i] == 'Y'
        return 'Four'
      end
    end
    return 'Three'
  end
end

include HinaArare

gets # discard first input
s = gets.split(" ")
puts solve(s)

Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define MOD 1000000007 
#define INF 1000000000000000000
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing
#define int ll
int dist(int x1, int y1, int x2, int y2) {
	return abs(x1 - x2) + abs(y1 - y2);
}
signed main() {
	int n;
	cin >> n;
	vector <int> x(n), y(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		if(abs(x[i] + y[i]) % 2 != abs(x[0] + y[0]) % 2) {
			cout << -1;
			return 0;
		}
	}
	vector <int> v;
	for (int i = 30; i >= 0; i--) {
		v.push_back(1 << i);
	}
	if((x[0] + y[0]) % 2 == 0) {
		v.push_back(1);
	}
	cout << (int) v.size() << "\n";
	for (auto g: v)
		cout << g << " ";
	cout << "\n";
	string moves = "LRUD";
	vector <int> l({-1, 1, 0, 0});
	vector <int> r({0, 0, 1, -1});
	for (int i = 0; i < n; i++) {
		int cx = 0, cy = 0;
		string ans;
		for (auto g : v) {
			int mn = INF, p = -1;
			for (int j = 0; j < 4; j++) { 
				int tx = cx + g * l[j];
				int ty = cy + g * r[j];
				int d = dist(tx, ty, x[i], y[i]);
				if(d < mn) mn = d, p = j;
			}
			cx += g * l[p];
			cy += g * r[p];
			ans += moves[p];
		}
		cout << ans << "\n";
	}
}


Measured memory_bytes: 764
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	lint N;
	cin >> N;
	vector<lint>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	sort(A);
	reverse(A);
	lint ans1 = 0;
	lint ans2 = 0;
	lint I = 0;
	lint J = 0;
	rep(i, N - 1) {
		if (A[i] == A[i + 1]) {
			if (ans1 == 0) {
				ans1 = A[i];
				I = i;
			}
			else {
				if (i > I + 1) {
					ans2 = A[i];
					J = i;
					break;
				}
			}
		}
	}
	
	cout << ans1 * ans2 << endl;
}




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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

const int MN = 12;

int H, W;
string s[MN];

int mt[MN];
string t[MN];

bool check() {
	vi us(H);
	int now = 0;

	rep(i, H) {
		if (!us[i]) {
			if (mt[i] != -1) {
				t[now] = s[i];
				t[H-1-now] = s[mt[i]];
				us[i] = us[mt[i]] = 1;
				now++;
			} else {
				t[H/2] = s[i];
			}
		}
	}

	vi us_col(W);
	vector<string> vec(W);

	rep(j, W) {
		string cur;
		rep(i, H) cur.pb(t[i][j]);
		vec[j] = cur;
	}

	int sol = 0;

	rep(j, W) {
		if (!us_col[j]) {
			bool fd = false;
			int p = -1;
			string rev = vec[j];
			reverse(ALL(rev));

			for (int j2 = j + 1; j2 < W; ++j2) {
				if (!us_col[j2] && vec[j2] == rev) {
					fd = true;
					p = j2;
				}
			}
			if (fd) {
				us_col[j] = us_col[p] = true;
			} else if (W % 2 == 0) {
				return false;
			} else {
				if (rev != vec[j]) {
					return false;
				}
				us_col[j] = true;
				++sol;
			}
		}
	}
	return sol <= 1;
}

bool dfs(int p) {
	if (p == H) {
		int cnt = 0;
		rep(i, H) if (mt[i] == -1) {
			++cnt;
		}
		if (cnt <= 1) {
			return check();
		}
		return false;
	}

	if (mt[p] != -1) {
		return dfs(p + 1);
	}

	int cfree = 0;
	rep(i, p) {
		if (mt[i] == -1) {
			++cfree;
		}
	}
	if (H % 2 == 1 && cfree == 0) {
		if (dfs(p + 1)) {
			return true;
		}
	}

	for (int i = p + 1; i < H; ++i) {
		if (mt[i] == -1) {
			mt[p] = i;
			mt[i] = p;
			if (dfs(p + 1)) {
				return true;
			}
			mt[i] = mt[p] = -1;
		}
	}
	return false;
}

int main() {
	cin >> H >> W;
	rep(i, H) cin >> s[i];
	memset(mt, -1, sizeof(mt));

	bool res = dfs(0);
	puts(res ? "YES" : "NO");

	return 0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
count = 0
counts = []

if N <= 1:
    counts.append(0)
else:
    for i in range(N-1):
        if H[i] >= H[i+1]:
            count += 1
        else:
            counts.append(count)
            count = 0
    else:
        counts.append(count)

print(max(counts))

Measured memory_bytes: 14228
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list=new ArrayList<String>(Arrays.asList(s.split("")));
		List<Integer> list=new ArrayList<Integer>();
		int[] array = new int[2000000];
		Long[] tori = new Long[2000000];
		int n = sc.nextInt();

		for(int i=0;2000000>i;i++) {
			array[i]=0;
		}

		for(int i=0;n>i;i++) {
			int a = sc.nextInt();
			array[a]++;
			list.add(a);
		}

		for(int i=0;2000000>i;i++) {
			tori[i]=(((long)array[i]*(long)(array[i]-1))/2);
		}

		long goukei=0;

		for(int i=0;2000000>i;i++) {
			goukei=goukei+tori[i];
		}

		for(int i=0;n>i;i++) {
			int a = list.get(i);
			System.out.println(goukei-array[a]+1);
		}

	}
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;
using R=long double;
using edge=tuple<R,int>;

const int limit=310;
int x[limit],y[limit];

int main(void){
	int n,m;
	while(cin >> n >> m,n){
		rep(i,n) cin >> x[i] >> y[i];

		vector<edge> graph[limit];
		vector<int> used[limit];

		rep(i,m){
			int s,t;
			cin >> s >> t;
			s--,t--;
			graph[s].push_back(make_tuple(atan2(y[t]-y[s],x[t]-x[s]),t));
			used[s].push_back(-1);
			graph[t].push_back(make_tuple(atan2(y[s]-y[t],x[s]-x[t]),s));
			used[t].push_back(-1);
		}

		rep(v,n) sort(_all(graph[v]));
		
		int all=0;
		rep(v,n){
			rep(i,graph[v].size()){
				if(used[v][i]!=-1) continue;
				
				int cur=v,idx=i;
				do{
					used[cur][idx]=all;
					int nxt=get<1>(graph[cur][idx]),nidx=0;
					rep(j,graph[nxt].size()) if(get<1>(graph[nxt][j])==cur) nidx=(j+1)%int(graph[nxt].size());
					cur=nxt,idx=nidx;
				}while(cur!=v);
				all++;
			}
		}
	
		int dual[limit][limit];
		rep(i,all)rep(j,all) dual[i][j]=(i==j)?0:(1<<20);

		int outer=used[min_element(x,x+n)-x][0];
		
		rep(v,n){
			rep(i,graph[v].size()){
				int v2=get<1>(graph[v][i]),j=0;
				while(get<1>(graph[v2][j])!=v) j++;

				dual[used[v][i]][used[v2][j]]=1;
				dual[used[v2][j]][used[v][i]]=1;
			}
		}

		rep(k,all)rep(i,all)rep(j,all) chmin(dual[i][j],dual[i][k]+dual[k][j]);
		int ans=1;
		rep(v,all) chmax(ans,dual[outer][v]);
		cout << ans << endl;
	}		
	return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
const ll mod=998244353;
ll a[maxn];
ll poow(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1) ans=(ans*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return ans%mod;
}
int main()
{
	ll x,n;
	cin>>n;
	ll ma=0;
	bool flag=0;
	cin>>x;
	if(x!=0) flag=1;
	for(int i=1;i<n;i++)
	{
		cin>>x;
		a[x]++;	
		if(!x) flag=1;
		ma=max(ma,x);
	}
	ll sum=1;
	if(flag) cout<<0<<"\n";
	else{
		for(int i=2;i<=ma;i++)
		{
			sum=(sum*poow(a[i-1],a[i]))%mod;
		}
		cout<<sum<<"\n";
	}
	return 0;
} 

Measured memory_bytes: 1024
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String W = stdIn.next();
		int count = 0;
		while(true){
			String s = stdIn.next();
			if(s.equals("END_OF_TEXT"))
				break;
			s = s.toLowerCase();
			if(W.equals(s))
				count ++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 17272