akhauriyash/Code-Regression huggingface dataset:
def main():
    s = input()
    ans = 0
    i = 0
    prev = ''
    while i < len(s):
        c = s[i]
        if c == prev:
            i += 1
            if i == len(s):
                break
            c += s[i]
        prev = c
        i += 1
        ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9292
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int n;

int legendre(int m) {
    int cnt = 0, t = n;
    while (t > 0) cnt += (t /= m);
    return cnt;
}

vector<int> p(100);

void prime(int m) {
    for (int i = 3; i * i <= m; ++i) if (m % i == 0) return;
    ++p.at(legendre(m));
}

int main() {
    cin >> n;
    p.at(legendre(2)) = 1;
    for (int i = 3; i <= n; i += 2) prime(i);
    for (int i = n - 2; i >= 0; --i) p.at(i) += p.at(i + 1);
    cout << p.at(74) + (p.at(2) - 1) * p.at(24) + (p.at(4) - 1) * p.at(14) + (p.at(2) - 2) * (p.at(4) - 1) * p.at(4) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
int a[5];
int main(int argc, char const *argv[])
{
	int n = 4;
	for(int i = 0;i < n; ++i)
	{
		cin>>a[i];
	}
	sort(a,a + n);
	if(a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9)
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}
	return 0;
}

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

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    n = int(lines[0])

    return (n,)


def solve(n):

    result = 0.5
    if n % 2 == 1:
        odd = (n-1) / 2 + 1
        result = odd / n

    return result


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
long long int a[100000];
int main(){
	long long int n, ans = 1;
	cin >> n;
	for(long long int i = 0;i < n;i++){
		cin >> a[i];
	}
	sort(a, a + n);
	for(long long int i = 0;i < n;i++){
		if((1000000000000000000 / ans) < a[i]){
			cout << "-1" << endl;
			return 0;
		}
		ans *= a[i];
		if(ans > 1000000000000000000){
			cout << "-1" << endl;
			return 0;
		}
		if(ans == 0){
			cout << 0 << endl;
			return 0;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 4420
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

const int N = 1e3 + 50;
int n, a[N][N], T, tp[N], vis[N];  // T: 时间戳

int main() {
    cin >> n;
    rep(i, 1, n) {
        tp[i] = 1;
        rep(j, 1, n - 1) cin >> a[i][j];
    }
    while (1) {
        T++;
        bool ff = 0;
        rep(x, 1, n) {
            if (tp[x] == n || vis[x] == T) continue;
            int y = a[x][tp[x]];
            if (vis[y] != T && tp[y] < n && a[y][tp[y]] == x) {
                ff = 1;
                vis[x] = vis[y] = T;
                tp[x]++, tp[y]++;
            }
        }
        if (!ff) break;
    }
    rep(i, 1, n) if (tp[i] != n) { puts("-1"); return 0; }
    printf("%d\n", T - 1);
    return 0;
}


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


if __name__ == '__main__':

    n = int(input())
    M = [[0 for i in range(n)] for j in range(n)]
    for _ in range(n):
        l = list(map(int, input().split(" ")))
        u = l[0]
        k = l[1]
        if k != 0:
            for v in l[2:]:
                M[u-1][v-1] = 1
    
    color = [0]*n
    d = [0]*n
    f = [0]*n
    time = 0
    
    def dfs(u): #depth-first search
        global time
        color[u] = 1
        time += 1
        d[u] = time
        for v in range(n):
            if M[u][v] == 1 and color[v] == 0:
                dfs(v)
        color[u] = 2
        time += 1
        f[u] = time
    
    for u in range(n):
        if color[u] == 0:
            dfs(u)

    for u in range(n):
        print(u+1, d[u], f[u])



Measured memory_bytes: 5800
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef pair<LL,LL>PL;
const LL INF=1e18;
int N,K,i,S;
int A[1234567];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>N>>K;
    for(i=0;i<N;i++)
        cin>>A[i];
    sort(A,A+N);
    for(i=0;i<N;i++)
    {
        S+=A[i];
        if(S>K)
            break;
    }
    if(S>K)
        cout<<i<<endl;
    else if(S==K)
        cout<<N<<endl;
    else
        cout<<N-1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  int A, B; cin >> A >> B;
  int ans = 0;
  FOR(i,1,N+1) {
    int x = i;
    int wa = 0;
    while(x) {
      wa += x % 10;
      x /= 10;
    }
    if(wa >= A && wa <= B) ans += i;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    pair<pair<string,int>,int> p[101];
    for(int i=0;i<n;i++){
        string name;
        int score;
        cin >> name >> score;
        p[i]=make_pair(make_pair(name,-score),i+1);
    }
    sort(p,p+n);
    for(int i=0;i<n;i++) cout << p[i].second << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main()
{
	int n, k;
	char s[50];
	cin >> n >> k >> s;
	if (s[k - 1] == 'A')s[k - 1] = 'a';
	if (s[k - 1] == 'B')s[k - 1] = 'b';
	if (s[k - 1] == 'C')s[k - 1] = 'c';
	cout << s << endl;
    return 0;
}

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

using namespace std;

int main(){
  string S,T;
  cin>>S>>T;
  unsigned long long h=0;
  unsigned long long B=99999999907ULL;
  for(int i=0;i<T.size();i++){
    h=h*B+T[i];
  }
  vector<unsigned long long> hashes;
  unsigned long long b=1;
  for(int i=T.size()-1;i>=0;i--){
    for(char c='a';c<='z';c++){
      if(T[i]!=c){
	hashes.push_back(h-T[i]*b+c*b);
      }
    }
    for(char c='A';c<='Z';c++){
      if(T[i]!=c){
	hashes.push_back(h-T[i]*b+c*b);
      }
    }
    b*=B;
  }
  sort(begin(hashes),end(hashes));
  unsigned long long sh=0;
  for(int i=0;i<T.size();i++){
    sh=sh*B+S[i];
  }
  int ans=0;
  for(int i=0;;i++){
    ans+=binary_search(begin(hashes),end(hashes),sh);
    if(i+T.size()>=S.size())break;
    sh=sh*B-b*S[i]+S[i+T.size()];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 69572
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
int main(){
    double r;
    cin>>r;
    cout<<2*r*3.14159265<<endl;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

struct UnionFind {
  vi parent, rank, count;
  UnionFind(const int nodeSize)
    : parent(nodeSize), rank(nodeSize, 1), count(nodeSize) {
    rep(i, nodeSize) parent[i] = i, count[i] = 1;
  }
  int find(int x) {
    if (parent[x] == x) return x;
    return parent[x] = find(parent[x]);
  }
  void unite(int x, int y) {
    int rx = find(x);
    int ry = find(y);
    if (rx == ry) return;
    if (rank[rx] < rank[ry]) swap(rx, ry);
    parent[ry] = rx;
    count[rx] += count[ry];
    if (rank[rx] == rank[ry]) ++rank[rx];
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  int num(int x) {
    return count[find(x)];
  }
};

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

  int n, m, k; std::cin >> n >> m >> k;
  vvi fr(n), bl(n);
  UnionFind uf(n);
  rep(i, m) {
    int a, b; std::cin >> a >> b;
    --a, --b;
    fr[a].pb(b), fr[b].pb(a);
    uf.unite(a, b);
  }
  rep(i, k) {
    int c, d; std::cin >> c >> d;
    --c, --d;
    bl[c].pb(d), bl[d].pb(c);
  }

  rep(i, n) {
    int ans = uf.num(i) - 1;
    ans -= fr[i].size();
    for (auto &v : bl[i]) ans -= (uf.same(i, v));
    std::cout << ans << (i+1 < n ? " " : "\n");
  }
}


Measured memory_bytes: 13048
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <set>
#include <bitset>
#include <limits>

using namespace std;

#define ll long long

int main(void){
    int n;

    cin >> n;

    set<string> s;
    for(int i = 0;i < n;++i){
        string tmp;
        cin >> tmp;
        s.insert(tmp);
    }

    cout << s.size() << endl;

    return 0;
}

Measured memory_bytes: 19124
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

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

	int count = 0;
	for(int i=0; i<s.size(); i++)
	{
		if(s[i]=='x')
		{
			count++;
		}
	}

	if(count>=8)
	{
		cout<<"NO"<<endl;
	}
	else
	{
		cout<<"YES"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
-module('Main').
-export([main/1]).

sum(N) when N =< 0 -> 0;
sum(N) -> sum(N div 10) + N rem 10.

solve() ->
    [N, A, B] = input("~d~d~d"),
    io:format("~B~n", [lists:sum(
        [I || I <- lists:seq(1, N), A =< sum(I), sum(I) =< B]
    )]),
    ok.

main(_) ->
    solve(),
    halt().

input(Pat) ->
    {ok, L} = io:fread("", Pat),
    L.


Measured memory_bytes: 22136
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		int N = I[0], K = I[1];
		var a = G;
		var s = new List<long>();
		var sum = new long[N + 1];
		for (var i = 0; i < N; i++) sum[i + 1] = sum[i] + a[i];
		for (var i = 0; i < N; i++) for (var j = i + 1; j <= N; j++) s.Add(sum[j] - sum[i]);
		var x = 0L;
		for (var i = 40; i >= 0; i--)
		{
			var y = x | (1L << i);
			var c = 0;
			foreach (var p in s) if ((y & p) == y) c++;
			if (c >= K) x = y;
		}
		WriteLine(x);
	}
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  long x, y;
	cin >> x >> y;
	auto f = [&](long c, long d) {
	   int count = 0;
	   while(c <= d) {
		   c = c * 2;
		   count++;
	   }
	   return count;
    };
  cout << f(x, y) << endl;
}


Measured memory_bytes: 256
n=int(input())
a=[int(x) for x in input().split()]
buy=[]
out=[]
if a[0]<a[1]:
  buy.append(a[0])
for i in range(1,n-1):
  if a[i-1]>=a[i] and a[i]<a[i+1]:
    buy.append(a[i])
  if a[i-1]<a[i] and a[i]>=a[i+1]:
    out.append(a[i])
if a[n-1]>a[n-2]:
  out.append(a[n-1])

m=1000
k=len(buy)
for j in range(k):
  stock=m//buy[j]
  m+=(out[j]-buy[j])*stock
print(m)

Measured memory_bytes: 9228
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll H, W;
  cin >> H >> W;
  vector<string> A(H);
  map<char, int> cnt;
  for (int i = 0; i < H; i++) {
    cin >> A[i];
    for (int j = 0; j < W; j++) {
      cnt[A[i][j]]++;
    }
  }

  int group4 = (H / 2) * (W / 2), group2 = 0, group1 = 0;
  if (H % 2 == 0 || W % 2 == 0) {
    if (!(H % 2 == 0 && W % 2 == 0)) {
      group2 = (H % 2 == 0 ? H : W) / 2;
    }
  } else {
    group1 = 1;
    group2 = (H / 2) + (W / 2);
  }
  for (int i = 'a'; i <= 'z'; i++) {
    while (group4 > 0 && cnt[i] >= 4) {
      cnt[i] -= 4;
      group4--;
    }
    while (group2 > 0 && cnt[i] >= 2) {
      cnt[i] -= 2;
      group2--;
    }
    while (group1 > 0 && cnt[i] >= 1) {
      cnt[i] -= 1;
      group1--;
    }
    if (cnt[i] > 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3580
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int len = Integer.parseInt(sc.nextLine());
		int[] line = Stream.of(sc.nextLine().split(" ", 0)).mapToInt(Integer::parseInt).toArray();
		int[] peaple = new int[len];

		for (int i = 0; i < len; i++) {
			peaple[i] = Integer.parseInt(sc.nextLine());
		}

		Main main = new Main();

		System.out.println(main.solve(len,line[0],line[1],peaple));
	}

	public int solve(int len,int d,int x,int[] peaple) {
		int let =0;
		int sum =0;

		for (int i = 0; i < len; i++) {
			let = 1;
			sum += let;
			while (true) {
				let = let + peaple[i];
				if (let > d) {
					break;
				}
				sum++;
			}
		}
		return sum + x;
	}
}

Measured memory_bytes: 36024
#include <bits/stdc++.h>
#define MAX 10000
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
struct Node{int p,l,r;};
Node T[MAX];
int D[MAX],H[MAX];
void setDepth(int u,int d){
	if(u==-1)return;
	D[u]=d;
	setDepth(T[u].l,d+1);
	setDepth(T[u].r,d+1);
}
int setHeight(int u){
	int h1=0,h2=0;
	if(T[u].l!=-1)
	h1=setHeight(T[u].l)+1;
	if(T[u].r!=-1)
	h2=setHeight(T[u].r)+1;
	H[u]=(h1>h2?h1:h2);
	return H[u];
}
int getsibling(int u){
	if(T[u].p==-1)return -1;
	if(T[T[u].p].l!=-1&&T[T[u].p].l!=u)
		return T[T[u].p].l;
	if(T[T[u].p].r!=-1&&T[T[u].p].r!=u)
		return T[T[u].p].r;
	return -1;
}
void print(int u){
	cout<<"node "<<u;
	cout<<": parent = "<<T[u].p;
	cout<<", sibling = "<<getsibling(u);
	int deg=0;
	if(T[u].l!=-1)deg++;
	if(T[u].r!=-1)deg++;
	cout<<", degree = "<<deg;
	cout<<", depth = "<<D[u];
	cout<<", height = "<<H[u]<<", ";
	if(T[u].p==-1)cout<<"root";
	else if(deg==0)cout<<"leaf";
	else cout<<"internal node";
	cout<<endl;
}
int main(){
    int root,n,a,b,c;
	cin>>n;
	r(i,n)T[i].p=-1;
	r(i,n){
	  cin>>a>>b>>c;
	  T[a].l=b;
	  T[a].r=c;
	  if(b!=-1)T[b].p=a;
	  if(c!=-1)T[c].p=a;
	}
	r(i,n)if(T[i].p==-1)root=i;
	setDepth(root,0);
	setHeight(root);
	r(i,n)print(i);
}

Measured memory_bytes: 3100
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
// #define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vi a(n);
    rep(i,n)cin>>a[i];
    vi b=a;
    RSORT(a);
    rep(i,n)cout<<(b[i]!=a[0]?a[0]:a[1])<<endl;
}

Measured memory_bytes: 3200
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] d1 = new int[N];
        int[] d2 = new int[N];
        int count = 0;
        String ans = "No";
        for(int i=0;i<N;i++){
            d1[i] = sc.nextInt();
            d2[i] = sc.nextInt();
            if(d1[i] == d2[i]){
                count++;
            }else{
                count = 0;
            }
            if(count == 3){
                ans = "Yes";
                break;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 36028
N, M = (int(i) for i in input().split())
A = [int(i) for i in input().split()]
num = [0,2,5,5,4,5,6,3,7,6] 

D = {} #同じ本数で作れる数字は大きい方に統一
for i in range(M):
  n = num[A[i]]
  if D.get(n):
    D[n] = max(D[n], A[i])
  else:
    D[n] = A[i]

#桁数を最大にした中で最上位が最大のものが分かれば良い
DP = [(-1, -1)]*(N+1) #DP[i] = (桁数, 含まれる最大の数字)
DP[0] = (0, 0)
for i in range(N+1):
  for key in D:
    if i - key >= 0 and DP[i-key] != -1:
      temp = (DP[i-key][0] + 1, max(DP[i-key][1], D[key]))
      DP[i] = max(DP[i], temp)

#復元
ans = ''
now = N
while now > 0:
  ans += str(DP[now][1])
  now = now - num[DP[now][1]]
print(ans)


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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec g(nmax);





void solve4ts()
{
    
    int n,m;
    cin>>n>>m;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vec b(n);
    rep(i,m){
        int x,y;
        cin>>x>>y;
        x--;y--;
        if(a[x]==a[y]){
            b[x]=b[y]=-1;
        }
        else if(a[x]<a[y]) b[x]=-1;
        else b[y]=-1;
    }
    int ans=0;
    rep(i,n) if(b[i]!=-1) ans++;
    cout<<ans<<endl;
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 9532
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int[] a;
    int i, j, tmp;

    a = new int[5];
    for(i = 0;i < 5;i++)a[i] = sc.nextInt();
    for(i = 0;i < 5;i++){
      for(j = 0;j < 4 - i;j++){
        if(a[j] < a[j + 1]){
          tmp = a[j];
          a[j] = a[j + 1];
          a[j + 1] = tmp;
        }
      }
    }

    for(i = 0;i < 4;i++)System.out.print(a[i] + " ");
    System.out.println(a[i]);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 17188
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ld r;
    cin >> r;
    cout << (2.f * r * 3.14159) << endl;
    return 0;
}




Measured memory_bytes: 3788
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 998244353;

using namespace std;

inline ll int max(ll int a,ll int b) { return a>b?a:b; }
inline ll int min(ll int a,ll int b) { return a<b?a:b; }

const int maxn=10;

char e[maxn][maxn];

int n,m,k;

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	while(cin>>n>>m>>k)
	{
		
		int sum=0;
		
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				cin>>e[i][j];
				
				if(e[i][j]=='#')
					sum++;
			}
		}
		
		int to1=(1<<n);
		int to2=(1<<m);
		
		int ans=0;
		
		for(int i=0;i<to1;i++)
		{
			for(int j=0;j<to2;j++)
			{
				int cnt=0;
				
				for(int x=0;x<n;x++)
				{
					for(int y=0;y<m;y++)
					{
						if( (i&(1<<x)) || (j&(1<<y)))
						{
							if(e[x][y]=='#')
							{
								cnt++;
							}
						}
					}
				}
				
				if(cnt+k==sum)
				{
					ans++;
				}
			}
		}
		
		cout<<ans<<endl;
		
	}
	
	
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#define llint long long 

using namespace std;

llint N;
llint a[100005], b[100005];

int main(void)
{
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> a[i] >> b[i];
	}
	reverse(a, a+N);
	reverse(b, b+N);
	
	llint ans = 0, sum = 0, add;
	for(int i = 0; i < N; i++){
		add = (b[i] - ((a[i]+sum) % b[i])) % b[i];
		ans += add;
		sum += add;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let line = read_as_vec::<i64>();
    let (n, d) = (line[0], line[1]);

    let mut ans: i64 = 0;

    for i in 0..n {
        let line = read_as_vec::<i64>();
        let (x, y) = (line[0], line[1]);
        if x * x + y * y <= d * d {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2144
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

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

    ll ans = 1;
    if(a+1 < b and k >= a-1+2) {
        ans = b;
        k -= a+1;
        if(k&1)ans++;
        ans += k/2*(b-a);
    } else ans += k;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long dp[2][5005];
int main()
{
	int n,a;
	scanf("%d%d",&n,&a);
	int b=0;dp[b][2500]=1;
	for(int i=0;i<n;i++,b^=1)
	{
		int x;scanf("%d",&x);x-=a;
		for(int j=0;j<=5000;j++)dp[b^1][j]=0;
		for(int j=0;j<=5000;j++)if(dp[b][j])dp[b^1][j]+=dp[b][j],dp[b^1][j+x]+=dp[b][j];
	}
	printf("%lld\n",dp[b][2500]-1);
	return 0;
}

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

using namespace std;

main(){
  int n;
  cin >> n;
  string s;
  while(n--){
    cin >> s;
    int ans = 0, sum = 0;
    for(int i=0;i<s.size();i++){
      sum += s[i]-'0';
      int tmp = sum / 10;
      ans += tmp;
      sum = sum % 10 + tmp;
    }
    ans += (int)s.size()-1;
    if(ans%2) cout << "Fabre wins.";
    else cout << "Audrey wins.";
    cout << endl;
  }
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void)
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	
	if(a > b)
	{
		if(a < c)
			printf("%d %d %d\n", b, a, c);
		else if(b > c)
			printf("%d %d %d\n", c, b, a);
		else 
		    printf("%d %d %d\n", b, c, a);
	}
	else if(a < b)
	{
		if(b < c)
		    printf("%d %d %d\n", a, b, c);
		else if(a > c)
		    printf("%d %d %d\n", c, a, b);
		else
		    printf("%d %d %d\n", a, c, b);
	}
	return 0;
}

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

int main() {
  int a,b,c;
  cin >> c >> a >> b;
  cout << c*a*1/2 << endl;
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    map<string,int> cards;

    int N; cin>>N;
    rep(n,0,N){
        string s; cin>>s;
        cards[s]++;
    }
    int M; cin>>M;
    rep(m,0,M){
        string s; cin>>s;
        cards[s]--;
    }

    int ans=0;
    for(auto m:cards) ans=max(ans,m.second);

    cout<<ans<<endl;
}

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

int main() {
  int S;
  cin >> S;
  int sen = S/1000;
  int hyaku = (S-(sen*1000))/100;
  int jyu = (S-(sen*1000)-(hyaku*100))/10;
  int iti = S%10;
  
  if(sen*10 + hyaku < 13 && sen*10 + hyaku > 0 && jyu*10 + iti <13 && jyu*10 + iti >0) cout << "AMBIGUOUS" << endl;
  else if(sen*10 + hyaku < 13 && sen*10 + hyaku >0) cout << "MMYY" << endl;
  else if(jyu*10 + iti < 13 && jyu*10 + iti >0) cout << "YYMM" << endl;
  else cout << "NA" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
	int n, q, s = 0;
	cin>>n;
	vi v(n);
	map<int, int>u;
	for(int i = 0; i < n; i++){
		cin>>v[i];
		u[v[i]]++;
		s+=v[i];
	}
	cin>>q;
	for(int i = 0; i < q; i++){
		int a, b;
		cin>>a>>b;
		s-=(u[a]*a);
		s+=(u[a]*b);
		u[b]+=u[a];
		u[a]=0;
		cout<<s<<"\n";
	}	
}
signed main(){
	speed;
	int t=1;
	//cin>>t;
	while(t--)solve();
}

Measured memory_bytes: 9876
// Author: πα

#include <bits/stdc++.h>
using namespace std;
#define long int64_t

int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> u(n+1), v(n);
    for(int& it : u)
        cin >> it;
    for(int& it : v)
        cin >> it;
    long ans = 0;
    for(int i = 0; i < n; ++i)
    {
        int x = min(u[i], v[i]);
        u[i] -= x, v[i] -= x, ans += x;
        x = min(u[i+1], v[i]);
        u[i+1] -= x, v[i] -= x, ans += x;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

long long int n,d,k,sa,l,r,a[200005],b[200005],sum=0,sum2=0,res[200005]={},cou[200005]={},now,pushnum=0;
long long int used[100005]={},x[11][11];
queue<long long int> que[100005],task;

int main() {
    const long long int mod = 1000000007,INF=99999999999999;
	map<long long int, long long int>mp;
    string str[2005],tmp;
	cout << fixed << setprecision(10);
    cin>>n>>k;
    for(int i=1;i<=n-1;i++){
        cin>>a[i]>>b[i];
        cou[a[i]]++;
        cou[b[i]]++;
        que[a[i]].push(b[i]);
        que[b[i]].push(a[i]);
        if(cou[a[i]]>k||cou[b[i]]>k){
            cout<<0<<endl;
            return 0;
        }
    }
    res[1]=k;
    used[1]=1;
    now=1;
    pushnum=k;
    while(!que[1].empty()){
        pushnum--;
        res[que[1].front()]=pushnum;
        task.push(que[1].front());
        que[1].pop();
    }
    while(!task.empty()){
        
            pushnum=k-1;
        while(!que[task.front()].empty()){
            used[task.front()]=1;
            if(used[que[task.front()].front()]==1){
                que[task.front()].pop();
                continue;
            }else{
                
                pushnum--;
                res[que[task.front()].front()]=pushnum;
                task.push(que[task.front()].front());
                que[task.front()].pop();
            }
        }
        task.pop();
    }

    sum=1;
    for(int i=1;i<=n;i++){
        sum*=res[i];
        sum%=mod;
        
    }
    
    cout<<sum;
} 


Measured memory_bytes: 74880
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF =1e9;
const ll LINF=1e18;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a / gcd(a, b)*b;}
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    int n=s.size();
    map<char,int> m;
    string sx="";
    vector<int> sum;
    int count=0;
    for (int i = 0; i < n; i++)
    {
        if(s[i]!='x'){
            sx+=s[i];
            sum.push_back(count);
            count=0;}
        else{
            count++;
        }
        m[s[i]]++;
    }
    sum.push_back(count);
    for(int i=0;i<sx.size()/2;i++){
        if(sx[i]!=sx[sx.size()-1-i])return cout<<-1<<"\n",0;
    }
    int ans=0;
    /*
    for(int i=0;i<sum.size();i++){
        cout<<sum[i]<<" ";
    }
    cout<<"\n";
    */
    if(sum.size()%2){
        for(int i=0;i<sum.size()/2;i++){
            ans+=abs(sum[i]-sum[sum.size()-1-i]);
        }
        //ans+=sum[sum.size()/2]%2;
    }
    else{
        for(int i=0;i<sum.size()/2;i++){
            ans+=abs(sum[i]-sum[sum.size()-1-i]);
        }
    }
    cout << ans << "\n";
}



Measured memory_bytes: 1104
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <fstream>
#include <cassert>
#pragma region ACL
#include <atcoder/fenwicktree>
//#include <atcoder/math>
#include <atcoder/string>
#include <atcoder/scc>
#include <atcoder/segtree>
#include <atcoder/lazysegtree>
#pragma endregion

using namespace std;
using namespace atcoder;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion

int op(int a, int b) { return max(a, b); }
int e() { return 0; }

int main()
{
	int n, k; cin >> n >> k;
	segtree<int, op, e> seg(300100);
	rep(i, n)
	{
		int a; cin >> a;
		int mn = max(0, a - k), mx = min(300005, a + k);
		seg.set(a, seg.prod(mn, mx + 1) + 1);
	}
	int res = 0;
	rep(i, 300005)
	{
		chmax(res, seg.get(i));
	}
	cout << res << endl;
}

Measured memory_bytes: 8560
#include <stdio.h>

int main()
{
    int tmp, x;
    int i;

    scanf("%d", &tmp);
    for (i = 1; i <= tmp; i++)
    {
        x = i;
        if (x % 3 == 0)
        {
            printf(" %d", x);
        }
        else
        {

            do
            {
                if (x % 10 == 3)
                {
                    printf(" %d", i);
                    break;
                }
                x /= 10;
            } while (x != 0);
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2748
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}


using namespace std;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(int argc, char *argv[]) {
    ll m, d;
    cin >> m >> d;
    if(d < 22){
        cout << 0 << endl;
        return 0;
    }
    
    ll count = 0;
    rep(i, m+1){
        For(j, 22, d + 1){
            ll d1 = j % 10;
            ll d10 = j / 10;
        
            if(d1 >= 2 && d10 >= 2 && d1 * d10 == i){
                count ++;
            }
        }
    }
    
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int N; cin >> N; 
	int a = 0; int b = 0; int c = 0; int d = 0; 
	for(int i = 0; i < N; i++){
		string s; cin >> s; 
		if(s == "AC") a ++; 
		if(s == "WA") b ++; 
		if(s == "TLE") c ++; 
		if(s == "RE") d ++; 
	}
	cout << "AC x " << a << "\n"; 
	cout << "WA x " << b << "\n"; 
	cout << "TLE x " << c << "\n"; 
	cout << "RE x " << d << "\n"; 
}

Measured memory_bytes: 3616
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
      InputStream inputStream = System.in;
      OutputStream outputStream = System.out;
      Scanner sc = new Scanner(inputStream);
      PrintWriter out = new PrintWriter(outputStream);
	  int A = Integer.parseInt(sc.next());
      int B = Integer.parseInt(sc.next());
      if(A == 1){
      	A = 14;
      }
      if(B == 1){
      	B = 14;
      }
      if(A == B){
      	out.println("Draw");
      }else if(A < B){
      	out.println("Bob");
      }else{
      	out.println("Alice");
      }
      out.close();
    }
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < N; X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair


using namespace std;

int main(){

    //2本以上同じ長さの棒があるものから上位2種類の棒で作る長方形かもしくは4本以上ある棒の中で最も長いもので作る正方形
    //O(N log N)のはず

    int n;
    cin >> n;

    map<ll,int> m;
    
    //10^9同士の掛け算になる可能性があるため long long int
    ll over2_1 = 0;
    ll over2_2 = 0;
    ll over4 = 0;

    rep(i,n){
        ll tmp;
        cin >> tmp;

        m[tmp]++;
    }

    for(auto i = m.begin(); i != m.end(); i++){
        
        if(i->second >= 4){
            over4 = max(over4, i->first);
        }

        if(i->second >= 2){
            if(over2_1 < i->first){
                over2_2 = over2_1;
                over2_1 = i->first;

            }else if(over2_2 < i->first){
                over2_2 = i->first;
            }
        }
    }

    cout << max(over2_1 * over2_2, over4 * over4) << endl;
    return 0;
}

Measured memory_bytes: 6528
"use strict";
function main(input) {
    const line = input.split("\n");
    const S = line[0];
    const T = line[1];
    let z = zip(S, T);
    let ans = 0;
    for (let val of z) if (val[0] === val[1]) ans++;
    console.log(ans);
    return;
};
const zip = (...arrays) => {
    const length = Math.min(...arrays.map(arr => arr.length));
    return Array.from({ length }, (value, index) => arrays.map((array => array[index])));
};
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 30340
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define INF 1000000000

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	while(1){
		int n, m;
		cin>>n>>m;
		if(n==0 && m==0) return 0;
		int s[15], d[100];
		for(int i=0; i<n; i++){
			cin>>s[i];
		}
		for(int i=0; i<m; i++){
			cin>>d[i];
		}
		sort(d, d+m);
		int ans[33000];
		fill(ans, ans+(1<<n), INF);
		ans[0]=0;
		for(int i=0; i<(1<<n)-1; i++){
			int sum=0;
			for(int j=0; j<n; j++){
				if(i&(1<<j)) sum+=s[j];
			}
			for(int j=0; j<n; j++){
				if(i&(1<<j)) continue;
				int ans1=ans[i];
				int k1=upper_bound(d, d+m, sum)-d, k2=upper_bound(d, d+m, sum+s[j])-d;
				for(int k=k1; k<k2; k++){
					ans1+=min(d[k]-sum, sum+s[j]-d[k]);
				}
				ans[i|(1<<j)]=min(ans[i|(1<<j)], ans1);
			}
		}
		int sum=0;
		for(int j=0; j<n; j++){
			sum+=s[j];
		}
		int k1=upper_bound(d, d+m, sum)-d;
		for(int k=k1; k<m; k++){
			ans[(1<<n)-1]+=(d[k]-sum);
		}
		cout<<ans[(1<<n)-1]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3248
N=int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

res=0
before=N
for i in range(N):
  if before+1 == A[i]:
    res+=C[A[i]-2]    
  res+=B[A[i]-1]
  before=A[i]

print(res)

Measured memory_bytes: 38256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class A_166_AC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();

            if (s == "ABC")
            {
                Console.WriteLine("ARC");
            }
            else if (s == "ARC")
            {
                Console.WriteLine("ABC");
            }

            Console.Out.Flush();
        }
    }
}


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

using namespace std;

int main() {
    int n, c[100009];
    fill(c, c+100009, 0);
    cin >> n;
    for(int i=0; i<n; i++) {
        int a;
        cin >> a;
        for(int x=0; x<3; x++) c[a+x]++;
    }
    int r = 0;
    for(int i=0; i<100003; i++) r = max(r, c[i]);
    cout << r << endl;
}

Measured memory_bytes: 640
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
int a,b;
cin>>a>>b;
cout<<max({a+a-1,a+b,b+b-1})<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n, k;
  cin >> n >> k;
  bool a[10];
  for(int i = 0; i < 10 ; i++)a[i] = false;
  for(int i = 0 ;i < k ; i++){
    int temp;
    cin >> temp;
    a[temp] = true;
  }
  long long int ans ;
  for(int i  = n; i <100000; i++)
  {
    long long int tp = i;
    bool flag = true;
    while(tp>0)
    {
      if(a[tp%10])flag = false;
      tp/=10;
    }
    if(flag)
    {
    	ans = i;
    	break;
    }
  
  }
  cout<<ans<<"\n";
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr auto MOD = 998244353;
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; }

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

    ll a, b;
    cin >> a >> b;

    ll x = 0;
    if (a % 2)x = a++;
    if (!(b % 2))x ^= ++b;
    ll ans = x ^ ((b - a + 1) / 2 % 2);
    cout << ans << "\n";
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int[] num = new int[n];
		for (int i = 0; i < n; i++)
			num[i] = scanner.nextInt();
		int[] ans = new int[n];
		while (m-- > 0) {
			int a = scanner.nextInt();
			for (int i = 0; i < n; i++) {
				if (num[i] <= a) {
					ans[i]++;
					break;
				}
			}
		}
		int ret = 0;
		int max = 0;
		for (int i = 0; i < n; i++) {
			if (max < ans[i]) {
				max = ans[i];
				ret = i;
			}
		}
		System.out.println(ret + 1);
	}
}

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

using namespace std;

const int MOD = 1000000007;

int main()
{
  int N, K;
  int A[2000];
  
  scanf("%d %d", &N, &K);
  
  for (int i = 0; i < N; i++) scanf("%d", A + i);
  
  long long ans = 0;
  int tmp = 0;
  for (int i = 0; i < N - 1; i++) {
    for (int j = 0; j < N - i - 1; j++) {
      if (A[j] > A[j + 1]) {
        swap(A[j], A[j + 1]);
        tmp++;
      }
    }
  }
  
  ans = (long long)tmp * K % MOD;
  
  int cnt = 0;
  long long coef = ((long long)K * (K - 1) / 2) % MOD;
  for (int i = 1; i < N; i++) {
    if (A[i] != A[i - 1]) cnt = i;
    ans = (ans + coef * cnt) % MOD;
  }
  
  printf("%lld\n", ans);
  
  return 0;
}

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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

using namespace std;
using ll = long long;
using P = pair<int, int>;

int r, s, p;
int sc(char c) {
  if (c == 'r')
    return p;
  else if (c == 's')
    return r;
  return s;
}

void Main() {
  int n, k;
  cin >> n >> k;
  cin >> r >> s >> p;
  string t;
  cin >> t;

  int ans = 0;
  rep(i, k) {
    vector<P> A;
    A.emplace_back(1, sc(t[i]));
    for (int j = i + k; j < n; j += k) {
      if (t[j] == t[j - k])
        A[A.size() - 1].first++;
      else
        A.emplace_back(1, sc(t[j]));
    }
    for (auto p : A) {
      ans += ((p.first + 1) / 2) * p.second;
    }
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 1480