akhauriyash/Code-Regression huggingface dataset:
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll x, ll y){return x / gcd(x, y) * y % MOD;};


int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  sort(A.begin(), A.end());
  vector<ll> SUM(N+1);
  SUM[0] = 0;
  rep(i, N) SUM[i+1] = SUM[i] + A[i];
  ll now = 0;
  for(int i = 0; i < N-1; i++){
    if(SUM[i+1] * 2 < A[i+1]) now = i+1;
  }
  cout << N - now << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
template <class T> inline bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> inline bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main() {
	int N;
	cin >> N;
	int K = N / 2 + 1;
	vector <vector <double> > dp( N + 1, vector <double>( K+1, 0.0f ));
	dp[ 0 ][ 0 ] = 1.0;

	rep( i, 0, N ){
		double rate;
		cin >> rate;
		rep( j, 0, K+1 ){
			dp[ i + 1 ][ j ] += dp[ i ][ j ] * ( 1.0 - rate );
			dp[ i + 1 ][ min( K, j + 1 ) ] += dp[ i ][ j ] * rate;
		}
	}
	printf("%1.10lf\n", dp[N][K]);

}


Measured memory_bytes: 35584
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();

    int reader = 0;
    for (int i = 0; i < N - 1; i++) {
      if (S.charAt(i) == 'W' && S.charAt(i + 1) == 'E') reader++;
      if (S.charAt(i) == 'E' && S.charAt(i + 1) == 'W') reader++;
      if (S.charAt(i) == 'E' && S.charAt(i + 1) == 'E') reader++;
      if (S.charAt(i) == 'W' && S.charAt(i + 1) == 'W') {
        int benefit = -1, idx = reader + 1;
        while (benefit < 0 && idx < N - 1) {
          if (S.charAt(idx) == 'E' && S.charAt(idx + 1) == 'E') benefit++;
          if (S.charAt(idx) == 'W' && S.charAt(idx + 1) == 'W') benefit--;
          idx++;
        }
        if (benefit == 0) {
          reader = idx;
          i = idx - 1;
        } else {
          break;
        }
      }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
      if (i == reader) continue;
      if (i < reader && S.charAt(i) == 'W') ans++;
      if (i > reader && S.charAt(i) == 'E') ans++;
    }
    System.out.println(ans);
  }
}

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

int main() {
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		if( i % 3 == 0 || i % 10 == 3 || i / 10 % 10 == 3 || i / 100 % 10 == 3 ||  i / 1000 % 10 == 3) cout << " " << i;
	}
	cout<<endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		int n = readNum();
		int ans = 1;
		while (ans <= n)
			ans *= 2;
		if (ans > n)
			ans /= 2;
		pln(ans);
	}

	int abs(int a) {
		return (a >= 0) ? a : -a;
	}

	long abs(long a) {
		return (a >= 0) ? a : -a;
	}

	int max(int a, int b) {
		return (a > b) ? a : b;
	}

	long max(long a, long b) {
		return (a > b) ? a : b;
	}

	int min(int a, int b) {
		return (a < b) ? a : b;
	}

	long min(long a, long b) {
		return (a < b) ? a : b;
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	long readLong() {
		String line = readLine();
		return plong(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++)
			nums[i] = pint(flds[i]);
		return nums;
	}

	long[] readLongs() {
		String[] flds = readFlds();
		long[] nums = new long[flds.length];
		for (int i = 0; i < flds.length; i++)
			nums[i] = pint(flds[i]);
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed)
			System.err.println((end - start) + "ms");
	}
}


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

using namespace std;

#define ll long long
int A, B, C, n;
vector<int> arr(1000);
int ans=INT_MAX;

void func(int sumA, int sumB, int sumC, int i, vector<int> a, vector<int> b, vector<int> c){
	//base case
	if(i == n){
		if(!a.empty()&&!b.empty()&&!c.empty()){
			int total = (a.size()-1 + b.size()-1 + c.size()-1)*10;
			total += (abs(sumA - A) + abs(sumB - B) + abs(sumC - C));
			ans = min(total, ans);
		}		
		return;
	}
	//recursive case
	//case1.
	func(sumA, sumB, sumC, i+1, a, b, c);
	//case2.
	if(sumA < A){
		a.push_back(arr[i]);
		func(sumA+arr[i], sumB, sumC, i+1, a, b, c);
		a.pop_back();
	}
	//case3.
	if(sumB < B){
		b.push_back(arr[i]);
		func(sumA, sumB+arr[i], sumC, i+1, a, b, c);
		b.pop_back();
	}
	//case4.
	if(sumC < C){
		c.push_back(arr[i]);
		func(sumA, sumB, sumC+arr[i], i+1, a, b, c);
	}
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cin>>n>>A>>B>>C;
	for(int i=0; i<n; i++){
		cin>>arr[i];
	}
	vector<int> a,b,c;
	func(0, 0, 0, 0, a, b, c);
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
 char a,b;
 cin >> a >> b;
 if (a==b) cout << "H" << endl;
 else cout << "D" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

const unsigned long MAX = 100000;
unsigned long A[MAX]={};


int main(){
    unsigned long n;
    unsigned long tmp;
    unsigned long cnt=0;

    cin >> n;

    for(int i=0; i<n; i++){
        cin >> tmp;
        if(A[tmp] == 0){
            cnt++;
            A[tmp] = 1;
        }
    }

    if(cnt%2 == 0)
        printf("%ld\n", cnt-1);
    else
        printf("%ld\n", cnt);


    return 0;
}

Measured memory_bytes: 1024
s = input()

f2 = int(s[:2])
b2 = int(s[2:])

if ((f2 >= 13 or f2 == 0) and (b2 >= 13 or b2 == 0)):
    print("NA")
elif ((f2 >= 1 and f2 <= 12) and (b2 >= 1 and b2 <= 12)):
    print("AMBIGUOUS")
elif (f2 >= 13 or f2 == 0):
    print("YYMM")
elif (f2 >= 1 and f2 <= 12):
    print("MMYY")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
int main() {
	ll N;
	cin >> N;
	map<char, ll>mp;
	map<char, ll>min_v;
	for (char c = 'a'; c <= 'z'; c++) {
		min_v[c] = 100000000;
	}

	for (ll i = 0; i < N; i++) {
		string S;
		cin >> S;
		for (ll i = 0; i < S.size(); i++) {
			mp[S[i]]++;
		}
		for (char c = 'a'; c <= 'z'; c++) {
			min_v[c] = min(mp[c], min_v[c]);
			mp[c] = 0;
		}
	}
	string s = "";
	for (auto p : min_v) {
		ll x = p.first;
		ll y = p.second;
		for (ll i = 0; i < p.second; i++) {
			s += x;
		}
	}
	cout << s << endl;
}











Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>

using namespace std;

int n,m,c;
int b[30];
int ans = 0;

int main(){
	cin>>n>>m>>c;
	for(int i = 1;i<=m;i++) cin>>b[i];
	for(int i = 1;i<=n;i++){
		int tmp,res = 0;
		for(int j = 1;j<=m;j++){
			cin>>tmp;
			res += tmp*b[j];
		}
		if(res + c> 0) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())

dp = [[[[0 for c3 in range(4)] for c2 in range(4)] for c1 in range(4)] for l in range(N + 1)]
dp[0][3][3][3] = 1
for l in range(N):  # len of str
    for c1 in range(4):  # last 1 char
        for c2 in range(4):  # last 2 char
            for c3 in range(4):  #last 3 char
#                print("dp[{}][{}][{}][{}] = {}".format(l, c1, c2, c3, dp[l][c1][c2][c3]))
                if(0 == dp[l][c1][c2][c3]):    continue
                for a in range(4):
                    # A:0, G:1, C:2
                    if((a == 2) & (c1 == 1) & (c2 == 0)):  continue
                    if((a == 2) & (c1 == 0) & (c2 == 1)):  continue
                    if((a == 1) & (c1 == 2) & (c2 == 0)):  continue
                    if((a == 2) & (c1 == 1) & (c3 == 0)):  continue
                    if((a == 2) & (c2 == 1) & (c3 == 0)):  continue

                    dp[l + 1][a][c1][c2] += dp[l][c1][c2][c3]
#                    print("new dp[{}][{}][{}][{}] = {}".format(l + 1, a, c1, c2, dp[l + 1][a][c1][c2]))
                    dp[l][c1][c2][c3] %= 10 ** 9 + 7

ans = 0
for c1 in range(4):  # last 1 char
    for c2 in range(4):  # last 2 char
        for c3 in range(4):  #last 3 char
            ans += dp[N][c1][c2][c3]
            ans %= 10 ** 9 + 7

print(str(ans))


Measured memory_bytes: 3316
n=int(input())
h=list(map(int,input().split()))

ans=0

for i in range(n):
    if i==0:
        rightsec=0
    else:
        if h[i-1]>=h[i]:
            rightsec+=1
        else:
            ans=(max(rightsec,ans))
            rightsec=0
            
print(max(ans,rightsec))

Measured memory_bytes: 63984
import java.io.{BufferedReader, InputStream, InputStreamReader, PrintWriter}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.reflect.ClassTag

object Main {
  val MOD = 1000000007
  val out = new PrintWriter(System.out)
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N = sc.nextInt()

    def step(i: Int, t0: Int, x0: Int, y0: Int): Boolean = {
      if (i == N) true
      else {
        val t1, x1, y1 = sc.nextInt()
        val d = abs(x1 - x0) + abs(y1 - y0)
        val t = t1 - t0
        val r = t - d
        if (r >= 0 && r % 2 == 0) step(i + 1, t1, x1, y1)
        else false
      }
    }

    val ans = if (step(0, 0, 0, 0)) "Yes" else "No"

    out.println(ans)
  }


  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

  private def rep(n: Int)(f: Int => Unit): Unit = {
    var i = 0
    while(i < n) {
      f(i)
      i += 1
    }
  }

  private def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    var i = 0
    while(i < n) {
      res(i) = f(i)
      i += 1
    }
    res
  }

  private implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
      if (as.nonEmpty) Some(as.maxBy(f)) else None
    }
  }
}


Measured memory_bytes: 38648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const string YES = "Yes";
const string NO = "No";

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

  for (int i=1; i<=9; i++) {
    if (N%i==0&&N/i<=9) {
      cout << YES << endl;
      return 0;
    }
  }
  cout << NO << endl;

  return 0;
}


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

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

    int v[4][13] = {
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
    }; // S,H,C,D
    

    for (int i = 0; i < n; i++) {
        string s;
        int x;
        cin >> s >> x;

        int index;
        if (s == "S") {
            index = 0;
        } else if (s == "H") {
            index = 1;
        } else if (s == "C") {
            index = 2;
        } else {
            index = 3;
        }

        v[index][x-1] = 1;
    }

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 13; j++) {
            if (v[i][j] == 1) { continue; }
            if (i == 0) { cout << "S "; }
            else if (i == 1) { cout << "H "; }
            else if (i == 2) { cout << "C "; }
            else { cout << "D "; }
            cout << j+1 << endl;
        }
    }
}


Measured memory_bytes: 3116
using System;
namespace t{
class submit{
public static void Main(string[] args){
string[] input=Console.ReadLine().Split(char.Parse(" "));
int a=int.Parse(input[0]);
int b=int.Parse(input[1]);
int c=int.Parse(input[2]);
if(a<b && b<c){
Console.WriteLine("Yes");
}else{
Console.WriteLine("No");
}
}
}
}


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

int main() {
	int i,k,n,a[10];
	while(cin >> n && n!=0) {
	for (i=0;i<10;i++) a[i]=0;	
	for (i=0;i<n;i++) { cin >> k; a[k]++;}
	for (i=0;i<10;i++) {
		if (a[i]==0) { cout << '-' << endl; continue;}
		for (k=0;k<a[i];k++) cout << '*'; cout << endl;
		}
}
	return 0;
}

Measured memory_bytes: 1152
n = int(input())
a = list(map(int,input().split()))
count = 0
for i in range(n):
    minj = i
    for j in range(i , n):
        if a[j] < a[minj]:
            minj = j
    if minj != i:
        count += 1
        a[i],a[minj] = a[minj],a[i]
print(*a)
print(count)


Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10;
int n;ll a[N];
map<ll,int>t;
int main(){
  cin>>n;
  for(int i=1;i<=n;i++)cin>>a[i];
  ll ans=0;
  t[0]=1;
  for(int i=1;i<=n;i++){
	  a[i]+=a[i-1];
	  ans+=t[a[i]];
	  t[a[i]]++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 14336
#include<stdio.h>

int main(){
	int n = 0, p = 0;
	char t = '\0';
	while(1){
		scanf("%c", &t);
		if( t == '\n'){ break; }
		n++;
		if( t == 'p' ){ p++; }
	}
	printf("%d\n", n/2-p);
	return 0;
}


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

using namespace std;

int main() {
	long long n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;
	
	long long min_val = min({a, b, c, d, e});
	long long hours = n / min_val + 5;
	
	if(n % min_val == 0) hours--;
	
	cout << hours;
	
	return 0;
}

Measured memory_bytes: 256
def LI(): return list(map(int,input().split()))
N,K = LI()
a = LI()
ans = float('INF')
for i in range(2**(N-1)):
    bit = [i>>j&1 for j in range(N-1)]
    if K-1!=sum(bit):
        continue
    cost,kijun = 0,a[0]
    for k in range(N-1):
        if bit[k]==0:
            kijun = max(kijun,a[k+1])
            continue
        if a[k+1]>=kijun+1:
            kijun = a[k+1]
            continue
        cost += (kijun+1)-a[k+1]
        kijun += 1
    ans = min(ans,cost)
print(ans)

Measured memory_bytes: 42608
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(K: int):
    A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
         1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    print(A[K-1])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import sys
from collections import Counter

bw, bh = 0, 0
w, h, n = map(int, input().split())
xya_array = [list(map(int, input().split())) for _ in range(n)]

for i in xya_array:
    if i[2] == 1:
        bw = max(bw, i[0])
    elif i[2] == 2:
        w = min(w, i[0])
    elif i[2] == 3:
        bh = max(bh, i[1])
    elif i[2] == 4:
        h = min(h, i[1])

if w-bw < 0 or h-bh < 0:
    print(0)
else:
    print((w-bw)*(h-bh))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
string s;
cin >> s;
int count = 0;
for(int i = 2; i < n; i++){
if(s[i] == 'C' and s[i - 1] == 'B' and s[i - 2] == 'A'){
count++;
}

}
cout << count << endl;
}

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

int main()
{
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++)
  {
    cin >> p[i];
    p[i]--;
  }
  int ans = 0;
  if (p[0] == 0)
  {
    swap(p[0], p[1]);
    ans++;
  }
  if (p[N - 1] == N - 1)
  {
    swap(p[N - 1], p[N - 2]);
    ans++;
  }
  for (int i = 1; i < N - 1; i++)
  {
    if (p[i] == i)
    {
      if (p[i - 1] == i - 1)
      {
        swap(p[i], p[i - 1]);
        ans++;
        continue;
      }
      else if (p[i + 1] == i + 1)
      {
        swap(p[i], p[i + 1]);
        ans++;
        continue;
      }
      else
      {
        swap(p[i], p[i - 1]);
        ans++;
        continue;
      }
    }
  }
  cout << ans << endl;
}


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

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 9;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

void solve()
{
    ll a;
    cin>>a;
    ll ans = a+a*a+a*a*a;
    cout<<ans;
}

int main()
{
    fastio;
    int t;

    t = 1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, N;
  cin >> K >> N;
  vector<int> vec(N);
  vector<int> sa(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    if (i != 0) {
      sa.at(i - 1) = vec.at(i) - vec.at(i - 1);
    }
  }
  sa.at(N - 1) = vec.at(0) + (K - vec.at(N - 1));
  sort(sa.begin(), sa.end());
  cout << K - sa.at(N - 1) << endl;
}

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

#define  int        long long int
 #define    sp(x)                 setprecision(x)
#define    bp(x)           __builtin_popcount(x)
 #define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff             first
#define  ss             second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
 #define  endl    "\n"
#define  mod  1000000007
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}

int32_t main()
{
    fast
    ld x,y=1;
    int n;
    cin>>n;
    ld a[n+1];
    f(i,1,n)
        cin>>a[i];
    sort(a+1,a+n+1);
    f(i,1,n)
    {
        x=a[i];
        if( 1e18/y < x)
        {
            cout<<"-1";
            exit(0);
        }
        y=y*x;
    }
    cout<<fixed<<sp(0)<<y;
}

Measured memory_bytes: 5376
#include <stdio.h>
#include <stdlib.h>

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define MAX 10010
#define MAX_INT 9223372036854775807
#define array(N, t) (t*)calloc(N, sizeof(t))

int main() {
  char S[4];
  scanf("%s", S);

  int cnt = 0;
  int max = 0;
  int ans = 0;
  char prev_char = '0';
  rep(i, 3) {
    if (prev_char == 'R') {
      if (S[i] == 'R') {
        cnt += 1;
      } else {
        max = cnt;
        cnt = 0;
      }
    } else {
      if (S[i] == 'R') {
        cnt = 1;
      } else {
        cnt = 0;
      }
    }
    prev_char = S[i];
  }

  if (max > cnt) {
    ans = max;
  } else {
    ans = cnt;
  }

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1724
#include<cstdio>
#define LL long long
#define N 2005
using namespace std;
int A,B;
int p=1e9+7;
LL inv[50*N],f[50*N];
LL C(LL n,LL m)
{
	return f[n]*inv[m]%p*inv[n-m]%p;
}
int main()
{
	inv[0]=inv[1]=f[0]=f[1]=1;
	for(int i=2;i<=100010;i++)
	{
		inv[i]=-(p/i)*inv[p%i];
		inv[i]=(inv[i]%p+p)%p;
	}
	for(int i=2;i<=100010;i++)
	{
		f[i]=f[i-1]*i%p;
		inv[i]=inv[i-1]*inv[i]%p;
	}
	scanf("%d%d",&A,&B);
	LL ans=A+1;
	for(int i=1;i<=B;i++)
	{
		if(B-i>A) continue;
		for(int j=1;j<=B-i;j++)
		{
			if(B-i+B-i-j>A) continue;
			ans+=C(B-1,i-1)*C(B-i-1,j-1)%p*C(A-(B-i)-(B-i-j)+2,2)%p;
			ans%=p;
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1664
a, b, c, x, y = map(int, input().split())
d = []
for num_c in range(max(x, y)+1):
    money = num_c * 2 * c + max(x-num_c, 0) * a + max(y-num_c, 0) * b
    d.append(money)
print(min(d))

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

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x = i;
    if (x % 3 == 0) {
      cout << " " << i;
      continue;
    }
    do {
      if (x % 10 == 3) {
        cout << " " << i;
        break;
      }
      x /= 10;
    } while (x);
  }
  cout << endl;
}



Measured memory_bytes: 3084
#include<iostream>
#include<string>
#include<utility>
#include<algorithm>
using namespace std;
bool cmp(pair<int,int> a,pair<int,int> b)
{
	if(a.second!=b.second)
	return a.second<b.second;
	return a.first<b.first;
}
int main()
{
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	sort(arr,arr+n);
	cout<<arr[n-1]-arr[0];
}

Measured memory_bytes: 256
n, m = map(int, input().split())
edges = {}

for i in range(m):
  a, b = map(int, input().split())
  if a in edges:
    edges[a].append(b)
  else:
    edges[a] = [b]
  if b in edges:
    edges[b].append(a)
  else:
    edges[b] = [a]
    
g = [-1 for i in range(n+1)]

from queue import Queue
ans = 1
for i in range(1, n+1):
  if g[i] != -1:
    continue
  if not i in edges:
    continue
  q = Queue()
  q.put(i)
  g[i] = 0
  tmp = 1
  while not q.empty():
    p = q.get()
    for edge in edges[p]:
      if g[edge] == -1:
        g[edge] = 0
        q.put(edge)
        tmp += 1
  ans = max(tmp, ans)
print(ans)

Measured memory_bytes: 56188
#include<bits/stdc++.h>
using namespace std;
int n,a[100005],f[100005];
int main(){
	ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
 	cin>>n;
	for(int i=1;i<=n;i++){
        cin>>a[i];
	}
	if(n==2) cout<<abs(a[1]-a[2]);
    else{
        for(int i=n-1;i>=1;i--){
            int r=abs(a[i]-a[i+1]),q=abs(a[i]-a[i+2]);
            f[i]=min(f[i+1]+r,f[i+2]+q);
        }
        cout<<f[1];
    }
}


Measured memory_bytes: 4396
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int max = 0;
		int num = 0;
		for(int i = 0; i < n; i++){
			int l = sc.nextInt();
			if(l > max){
				num = num + max;
				max = l;
			}else{
				num = num + l;
			}
		}
		if(max < num){
			System.out.print("Yes");
		}else{
			System.out.print("No");
		}
	}
}


Measured memory_bytes: 25300
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
x, y = map(int, input().split())
if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
elif x == y == 2:
    print("Yes")
else:
    print("No")

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

int main() {
  int n, q, b, e, t;
  int A[1010];

  cin >> n;

  for (int i = 0; i < n; ++i) {
    cin >> A[i];
  }

  cin >> q;
  for (int i = 0; i < q; ++i) {
    cin >> b >> e >> t;
    for (int k = 0; k < (e - b); ++k) {
      swap(A[b+k],A[t+k]);
    }
  }

  for (int i = 0; i < n; ++i) {
    if (i != 0 ) cout << ' ';
    cout << A[i];
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define Maxn 1005
using namespace std;

int a[Maxn],n;

template<typename Drake>
void read(Drake &x){
	x=0;char ch=getchar();
	while(!isdigit(ch)){
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
}

template<typename Drake>
void write(Drake x){
	if(x<0){x=-x;putchar('-');}
	if(x>9)write(x/10);
	putchar(x%10+'0');
}

template<typename Drake>
void writeln(Drake x){
	write(x);
	puts("");
}

void init(){
	read(n);
}

bool c(int Num){
	int a,b,c;
	c=Num%10;
	b=Num/10%10;
	a=Num/100;
	return(a==b)&&(b==c);
}

int main(){
	init();
	for(int i=n;i;++i)
	if(c(i)){
		cout<<i<<endl;
		return 0;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

int main() {
  string s;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

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

int main(){
  int n,m,ans=0;cin>>n>>m;
  vector<int> x(m,0),d(m-1,0);
  REP(i,m) cin>>x.at(i);
  sort(x.begin(),x.end());
  REP(i,m-1) d.at(i)=x.at(i+1)-x.at(i);
  sort(d.begin(),d.end());
  cout<<(m==1?0:accumulate(d.begin(),d.begin()+m-(min(n,m)),0));
}

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

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, m = 1 << 10;
    cin >> n;
    yukari<int> as(m, akari<int>(m));
    while (n--)
    {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        as[x1][y1]++;
        as[x2][y1]--;
        as[x1][y2]--;
        as[x2][y2]++;
    }
    for (int i = 0; i < m - 1; i++)
        for (int j = 0; j < m; j++)
        {
            as[i + 1][j] += as[i][j];
        }
    for (int i = 0; i < m; i++)
        for (int j = 0; j < m - 1; j++)
        {
            as[i][j + 1] += as[i][j];
        }
    int ans = 0;
    for (int i = 0; i < m; i++)
    {
        ans = max(ans, *max_element(as[i].begin(), as[i].end()));
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}



Measured memory_bytes: 7092
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
using ll = long long;

const long double PI = acos(-1.0);
const int MOD = 1e9 + 7;

int main() {
    char s;
    cin >> s;
    if(isupper(s)) cout << "A" << endl;
    else cout << "a" << endl;

    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

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



    cout<<180*(n-2);
}

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

string s;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> s;
  int flag = 0;
  for (int i = 0; i < s.size(); i++) {
    if (flag == 0 && s[i] == 'C') flag = 1;
    if (flag == 1 && s[i] == 'F') flag = 2;
  }
  cout << (flag == 2 ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
  int x,h;
  for(;;){
    scanf("%d%d",&x,&h);
    if(x==0&&h==0)
      break;
    printf("%lf\n",(sqrt(x*x+h*h*4)+x)*x);
  }
  return 0;
}

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

int main(){
  int c1, c5, c10, c50, c100, c500, sum;
  cin>>c1>>c5>>c10>>c50>>c100>>c500;
  sum = c1 + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500;
  if(sum >= 1000) cout<<1<<endl;
  else cout<<0<<endl;
  return 0;
}



Measured memory_bytes: 3096
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<math.h>
#include<set>
#include<iomanip>
#include<stdio.h>
#include<deque>
#include<stack>
#include<map>
#include<queue>
#include<cstring>
#define M 1000000007
#define pb push_back
#define mp make_pair
#define int long long
using namespace std;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b;cin>>a>>b;
	cout<<max((int)0,a-2*b)<<endl;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    if ((b - a) % 2 == 1) cout << "IMPOSSIBLE" << endl;
    else cout << (a + b) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>

int main() {
	char ch;

	while (1) {
		scanf("%c", &ch);

		if (islower(ch)) printf("%c", toupper(ch));
		else if (isupper(ch)) printf("%c", tolower(ch));
		else printf("%c", ch);

		if (ch == '\n') break;
	}

	return 0;
}



Measured memory_bytes: 2568
io = STDIN
n=io.gets.chomp.to_i
a=io.gets.chomp.split.map(&:to_i)
ar=a.unshift(0)
cnt = 0
(1...n).each do |i|
  p = ar[i]
  if i == ar[p] && ar[i]!=0
    ar[p]=0
    cnt+=1
  end
end
p cnt

Measured memory_bytes: 9092
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
int mon[12]={ 0,31,59,90,120,151,181,212,243,273,304,334 },yea[7000];
void countDays();
int serial(int, int, int);
int isleap(int);
int main() {
	int i;
	for (i = 1; i < 7000; i++)yea[i] = yea[i - 1] + 365 + isleap(i - 1);
	countDays();
	return 0;
}

void countDays() {
	int y, m, d, days, yy, mm, dd;
	while (fscanf(stdin, "%d%d%d%d%d%d", &y, &m, &d, &yy, &mm, &dd)) {
		if (y < 0 || m < 0 || d < 0 || yy < 0 || mm < 0 || dd < 0) break;
		days = serial(yy, mm, dd) - serial(y, m, d);
		P(d, days);
	}
}

int serial(int y, int m, int d){
	return yea[y] + mon[m - 1] + d + (m > 2 && isleap(y) ? 1 : 0);
}

int isleap(int y){
	int isleap;
	isleap = y % 4 == 0;
	isleap = isleap && y % 100 != 0;
	isleap = isleap || y % 400 == 0;
	return isleap;
}

Measured memory_bytes: 624
#include <iostream>
#include <utility>
#include <stdint.h>
#include <string>
#include <vector>
#include <iomanip>
#include <set>

using namespace std;

int main()
{
  string S;
  cin >> S;
  vector<int16_t> X;

  for (int idx=S.size()-1; idx>=0; --idx) {
    X.push_back(S[idx]-'0');
  }

  vector<int> DP = {0};

  DP.push_back(X[0]);

  vector<int> tens;
  tens.push_back(1);
  for (int idx=1; idx<X.size(); ++idx) {
    tens.push_back((tens[idx-1]*10)%2019);
  }

  for (int ii=1; ii<X.size(); ++ii) {
    int jj = ii;
    int temp = X[ii]*tens[ii];
    DP.push_back((DP.back() + temp)%2019);
  }

  vector<int> mods(2019,0);

  for (auto dp : DP) {
    ++mods[dp];
  }

  uint64_t ans = 0;
  for (auto mod : mods) {
    if (mod>1)
      ans += mod*(mod-1)/2;
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
  int a, b, c, d;
  int i=0;
  cin>>a>>b>>c>>d;
  while (i<100){
  	c=c-b;
    if(c<=0){
      cout<< "Yes" <<endl;
      	break;
    }
    a=a-d;
    if(a<=0){
      cout<< "No" <<endl;
      break;
    }
    i++;
  }

  return 0;
}

Measured memory_bytes: 3636
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
    
a.insert(0, 0)
ans = -1
push = 1

for i in range(1, n+2):
    
    if a[push] == 2:
        ans = i
        break
        
    else:
        push = a[push]
      
print(ans)

Measured memory_bytes: 13040
#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include <iostream>
//#include <algorithm>
#include <limits>
#include<string>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
ll XOR(ll a,ll b){
  ll result=0;
  while(1){
    if(a%2==b%2){
      result+=0;
    }else{
      result+=1;
    }
    a/=2;
    b/=2;
    if(a==0&&b==0){
      return result;;
    }
    result*=2;
  }
}
string printbinary(ll num){
  string result = "";
  while(num!=0){
    if(num%2==0){
      result =result + "0";
    }else{
      result =result + "1";
    }
    num/=2;
  }
  return result;
}
int main(void){
	ll a,b,aa,bb;
	cin >> a >> b;
	switch(b%4){
		case 0:
      bb= b;
      break;
    case 1:
      bb=  b^(b-1);
      break;
    case 2:
      bb=  (b-2)^(b-1)^b;
      break;
    case 3:
      bb=  (b-3)^(b-2)^(b-1)^b;
      break;
	}
  switch((a-1)%4){
		case 0:
      aa= a-1;
      break;
    case 1:
      aa=  (a-1)^(a-2);
      break;
    case 2:
      aa=  (a-3)^(a-2)^(a-1);
      break;
    case 3:
      aa=  (a-3)^(a-2)^(a-1)^(a-4);
      break;
	}
  cout << (aa^bb);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void Do(int H, int W){
  int h, w;
  scanf("%d %d", &h, &w);
  printf("%d\n", H * W - h * W - (w * H - h * w));
}

int main(void){
  int H, W;
  scanf("%d %d", &H, &W);
  Do(H, W);
  return 0;
}


Measured memory_bytes: 128
def hantei(n,data):
    v = 1

    for st in data:
        if st == v:
            v = v + 1

    if v == 1:
        return -1
    else:
        return n - v + 1

n = int(input())
data = [int(x) for x in input().split()]

print(hantei(n,data))

Measured memory_bytes: 25768
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

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

typedef long long ll;

void Main()
{
	ll X, Y; cin >> X >> Y;
	ll temp = X;
	ll cnt = 0;
	while (temp <= Y) {
		temp *= 2;
		++cnt;
	}
	cout << cnt << endl;
}

int main()
{
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	Main();
}


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

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

	vector<string> s(n);
	map<string, int> sm;
	int m = 0;
	for (string& si : s) {
		cin >> si;
		if (sm.find(si) == sm.end()) {
			sm[si] = 1;
		} else {
			++sm[si];
		}

		m = max(m, sm[si]);
	}

	sort(s.begin(), s.end());

	for (string si : s) {
		if (sm[si] == m) {
			cout << si << endl;
			sm[si] = 0;
		}
	}
	
	return 0;
}
	

Measured memory_bytes: 26752
N = int(input())
arr = [int(el) for el in input().split()]
d = {}
for i, sup in enumerate(arr):
    if sup in d:
        d[sup].append(i)
    else:
        d[sup] = [i]
for i in range(1, N + 1):
    print(len(d[i]) if i in d else 0)

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

typedef long long ll;

int main(){
    int N,A;
    cin >> N >> A;
    vector<int> v(N);
    for(int i = 0; i < N; i++){
        cin >> v.at(i);
    }

    // iまでの数, j個使う、和がk
    ll dp[N][N+1][N*A+1];
    for(int i = 0; i < N; i++){
        for(int j = 0; j <= N; j++){
            for(int k = 0; k <= N * A; k++){
                dp[i][j][k] = 0;
            }
        }
    }
    for(int i = 0; i < v.size(); i++){
        dp[i][1][v[i]]++;
    }


    for(int i = 1; i < N; i++){
        for(int j = 0; j <= N; j++){
            for(int k = 0; k <= N*A; k++){
                // v[i]を使う場合
                if(j-1 >= 0 && k - v[i] >= 0){
                    dp[i][j][k] += dp[i-1][j-1][k-v[i]];
                }
                // v[i]を使わない場合
                dp[i][j][k] += dp[i-1][j][k];
            }
        }
    }
    ll ans = 0;
    for(int j = 1; j <= N; j++){
        ans += dp[N-1][j][j*A];
    }
    cout << ans << endl;

}

Measured memory_bytes: 50048
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<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; }

int main(){

	char j;
	lli cnt=0;

	REP(i,0,3){
		cin>>j;
		if(j=='1')cnt++;
	}
	cout<<cnt<<endl;

    return 0;
}

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

//文字をリバースして戻す
bool isPalindrome(string s) {
  string t = s;
  reverse(t.begin(), t.end());
  return s == t;
}

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

  bool ans = true;
  if (!isPalindrome(s)) ans = false;
  if (!isPalindrome(s.substr(0, s.size()/2))) ans = false;

  cout << (ans ? "Yes" : "No") << endl;
}


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++)

int main() {
    ll N;
    cin >> N;
    vector<ll> V(N), C(N);
    rep(i, N) cin >> V[i];
    rep(i, N) cin >> C[i];

    rep(i, N) V[i] -= C[i];
    ll ans = 0;
    rep(i, N) if (V[i] > 0) ans += V[i];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//jian
#include<stdio.h>
int main()
{
	double r,A,p;
	scanf("%lf",&r);
	A=3.141592653589793*r*r;
	p=2*3.141592653589793*r;
	printf("%.6lf %.6lf\n",A,p);
	return 0;
	}



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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll X;
ll ans;
int main(){
	cin >> X;
	ans += (X / 500) * 1000;
	X %= 500;
	ans += (X / 5) * 5;
	p(ans);
	return 0;
}


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

int main(void) {

  char s[200001];
  scanf("%s", s);
  long length = strlen(s);
  long count = 1;
  int last = 1;
  for (long i = 1; i < length; i++) {
    if (last == 1) {
      if (s[i] != s[i-1]) {
        count++;
      } else {
        if (i == length-1) {
          count--;
        }
        count++;
        last = 2;
        i++;
      }
    } else {
      count++;
      last = 1;
    }
  }
  printf("%ld\n", count);

  return 0;
}

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



int main(){

	int n;
	cin>>n;

	double x;
	string u;

	double ans;

	for(int i=0;i<n;i++){
		cin>>x>>u;
		if(u=="JPY")ans+=x;
		if(u=="BTC")ans+=x*380000;
	}

	cout<<ans;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#define LL long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
using namespace std;
int n;
int a[210];
int res=0;
int main()
{
	cin >>n;
	n*=2;
	for (int i=0;i<n;i++) cin >>a[i];
	sort(a,a+n);
	for (int i=0;i<n;i+=2) res+=a[i];
	cout <<res;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
struct restaurant {
  string cityn;
  int score;
  int index;
} a[103];
bool cmp(restaurant x, restaurant y) {
  if (x.cityn != y.cityn) {
    return x.cityn < y.cityn;
  }
  return x.score > y.score;
}
int main() {
  int N;
  cin >> N;

  for (int i = 1; i <= N; i++) {
    cin >> a[i].cityn >> a[i].score;
    a[i].index = i;
  }

  sort(a + 1, a + 1 + N, cmp);

  for (int i = 1; i <= N; i++) {
    cout << a[i].index << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	int co = 0;
	for (int i = 0; i <= 3000; i++) {
		if (r * i > n) {
			continue;
		}
		for (int j = 0; j <= 3000; j++) {
			if (r * i + g * j <= n) {
				if ((n - r * i - g * j) % b == 0) {
					co++;
				}
			}
		}
	}
	cout << co << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
char s[101], t[101];
int  slen, tlen;
bool cbcmp(char a, char b) {
	return a > b;
}
bool cscmp(char a, char b) {
	return a < b;
}
int maxi(int a, int b) {
	return a > b ? a : b;
}
int main() {
	gets(s);
	gets(t);
	slen= strlen(s);
	tlen= strlen(t);
	sort(s, s + slen, cscmp);
	sort(t, t + tlen, cbcmp);
	for(int i= 0; i < maxi(slen, tlen); i++) {
		if(s[i] < t[i]) {
			printf("Yes\n");
			return 0;
		}
		if(s[i] > t[i]) break;
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
 
int main(){
 
    int a,b,c,d,train,bus;

    cin >> a>>b>>c>>d;

    if(a<b) train = a;
    else train = b;

    if(c<d) bus = c;
    else bus =d;

    cout << train + bus <<endl;

}

Measured memory_bytes: 764
# editorial解法
from math import sqrt
Q = int(input())
for i in range(Q):
	A,B = map(int,input().split(" "))
	if A == B or A + 1 == B:
		print(2*A-2)
		continue

	mul = A * B
	C = int(sqrt(mul))
	if C * C == mul:
		C -= 1
	if (C + 1) * C < mul:
		print((2*C) - 1) #(A-1) + (2*C - A)
	else:
		print((2*C) - 2) #(A-1) + (2*C - A - 1)



Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
string judgeSnakeType(string s){
  if(s.find( ">'") == 0 && s.find("~") == s.size()-1)
    {
      s.erase(s.size()-1,1); s.erase(0,2);
      int cnt = 0;
      if( s.size() == 0 ) return "NA";
      while( s.size() > 0 && s[0] == '=' ){
	if(s[0] == '='){
	  s.erase(0,1);
	  cnt++;
	}
      }
      if( s[0] != '#' || cnt == 0)return "NA";
      s.erase(0,1);
      while( s.size() > 0 && s[0] == '=' ){
	if(s[0] == '='){
	  s.erase(0,1);
	  cnt--;
	}
      }
      if(s.size() == 0 && cnt == 0) return "A";
      else return "NA";
    }
  else if( s.find( ">^") == 0 && s.find("~~") == s.size()-2)
    {
      s.erase(s.size()-2,2); s.erase(0,2);
      if( s.size() == 0 ) return "NA";
      while( s.size() > 0 && s.size() % 2 == 0){
	if(s[0] == 'Q' && s[1] == '='){
	  s.erase(0,2);
	}
	else {
	  return "NA";
	}
      }
      return s == "" ? "B" : "NA";
    }
  else
    {
      return "NA";
    }
  return "NA";
}
void solve(string snake){
  cout << judgeSnakeType( snake ) << endl;
}
int main(){
  int d;
  cin >> d;
  string snake;
  for(int i = 0 ; i < d; i++ )
    {
      cin >> snake;
      solve(snake);
    }
  return 0;
}

Measured memory_bytes: 1232