akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<map>
#include<string>
#include<queue>
using namespace std;
map <string,int> qwq;
queue<string> qaq;
int main(){
	int m,n;
	string a;
	cin>>n;
	int maxn=0;
	for(int i=0;i<n;i++){
		cin>>a;
		qwq[a]++;
		qaq.push(a);
	}
	cin>>m;
	for(int i=0;i<m;i++){
		cin>>a;
		qwq[a]--;
	}
	for(int i=1;i<=n;i++){
		a=qaq.front();
		maxn=max(maxn,qwq[a]);
		qaq.pop();
	}
	printf("%d\n",maxn);
	}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
typedef string::const_iterator iter;
 
struct Node {
  int value;
  int left_index;
  int right_index;
  Node(int v, int l, int r) : value(v), left_index(l), right_index(r) {}
};
 
typedef std::vector<Node> Tree;
 
int expr(iter &p, Tree &tree);
int term(iter &p, Tree &tree);
int factor(iter &p, Tree &tree);
int number(iter &p);
 
int expr(iter &p, Tree &tree) {
  // cerr << "expr *p = " << *p << endl;
  int left_index = term(p, tree);
  assert(*p == '[');
  ++p;
  int value = number(p);
  assert(*p == ']');
  ++p;
  int right_index = term(p, tree);
  tree.emplace_back(value, left_index, right_index);
  return tree.size() - 1;
}
 
int term(iter &p, Tree &tree) {
  // cerr << "term *p = " << *p << endl;
  assert(*p == '(');
  ++p;
  if(*p == ')') {
    ++p;
    return -1;
  }
  else {
    int ret = expr(p, tree);
    assert(*p == ')');
    ++p;
    return ret;
  }
}
 
int number(iter &p) {
  int r = 0;
  while(isdigit(*p)) {
    r *= 10;
    r += *p - '0';
    ++p;
  }
  return r;
}
 
int dfs(Tree &AT, Tree &BT, int a, int b, Tree &CT) {
  int left_index = -1;
  if(AT[a].left_index != -1 && BT[b].left_index != -1) {
    left_index = dfs(AT, BT, AT[a].left_index, BT[b].left_index, CT);
  }
 
  int right_index = -1;
  if(AT[a].right_index != -1 && BT[b].right_index != -1) {
    right_index = dfs(AT, BT, AT[a].right_index, BT[b].right_index, CT);
  }
 
  int value = AT[a].value + BT[b].value;
  CT.emplace_back(value, left_index, right_index);
  return CT.size() - 1;
}
 
void print(Tree &CT, int c, bool isTop) {
  if(c == -1) cout << "()";
  else {
    if(!isTop) cout << "(";
    print(CT, CT[c].left_index, false);
    cout << "[" << CT[c].value << "]";
    print(CT, CT[c].right_index, false);
    if(!isTop) cout << ")";
  }
}
 
signed main() {
  ios::sync_with_stdio(false);
  iter p;
 
  string A; cin >> A;
  Tree AT;
  p = A.begin();
  int topA = expr(p, AT);
 
  string B; cin >> B;
  Tree BT;
  p = B.begin();
  int topB = expr(p, BT);
  // DEBUG(ret);
  // for(int i = 0; i < (int)AT.size(); ++i) {
  //   auto node = AT[i];
  //   cout << i << " = (" << node.left_index << " " << node.value << " " << node.right_index << ")" << endl;
  // }
  Tree CT;
  int topC = dfs(AT, BT, topA, topB, CT);
 
  // DEBUG(topC);
  // for(int i = 0; i < (int)CT.size(); ++i) {
  //   auto node = CT[i];
  //   cout << i << " = (" << node.left_index << " " << node.value << " " << node.right_index << ")" << endl;
  // }
  print(CT, topC, true);
  cout << endl;
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
//const int mod= int(1e9)+7;
const int mod=998244353;
using P = pair<int,int>;
using Pl= pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;cin>>n;
    Vl a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    sort(all(a));
    ll ans=a.back()-a[0];
    cout <<ans <<"\n";
}

Measured memory_bytes: 3676
using System;

namespace ACpra4
{
    class Program
    {
        static void Main(string[] args)
        {

            int N = int.Parse(Console.ReadLine());
            int K = int.Parse(Console.ReadLine());
            if(N == 1)
            {
                Console.Write(2);   
            }
            if (N == 2)
            {
                if (K ==1)
                {
                    Console.Write(3);
                }
                else if (2<= K && K<= 10)
                {
                    Console.WriteLine(4);
                }
            }
            if(N == 3)
            {
                if(K == 2)
                {
                    Console.Write(6);
                }else if(K == 3)
                {
                    Console.Write(8);
                }
                else if(K == 1)
                {
                    Console.Write(4);
                }else if(K >=4)
                {
                    Console.Write(8);
                }
            }
            if (N >= 4)
            {
                if(K == 1)
                {
                    Console.Write(N * K + 1);
                }else if(K == 2 || K == 3)
                {
                    Console.Write(4 + (N-2) * K);
                }else if(K>=4&&K < 8)
                {
                    Console.Write(8 + (N - 3) * K);
                }
             
                
                else if(K >= 8 && K < 11)
                { 
                    Console.Write(16 + ((N - 4) * K));
                }
            }
        }
    }
}

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

int bubble_sort(long* a, int n){
    int count = 0;

    for (int i = 0; i < n; i++){
        for (int j = n - 1; j > i; j--){
            if(a[j] < a[j - 1]){
                swap(a[j], a[j - 1]);
                count++;
            }
        }
    }
    return count;
}

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

    int count = bubble_sort(a, n);

    for(int i = 0; i < n; i++){
        if (i != 0) cout << " ";
        cout << a[i];
    }
    cout << endl << count << endl;

    return 0;
}


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

int main(int argc, const char * argv[]) {
  
    int N;
    cin >> N;
  
  if(N % 10 == 7){
    cout << "Yes";
    return 0;
  }
  
  if(N / 10 % 10 == 7){
    cout << "Yes";
    return 0;
  }
  
  if(N / 100 % 10 == 7){
    cout << "Yes";
    return 0;
  }
  
  cout << "No";
  
  return 0;
  
}

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

int main(){
        int a,b, ans = 0;
        cin >> a >> b;

        for(int i = 0; i < 2; i++){
                if(a > b){
                        ans += a;
                        a--;
                } else {
                        ans += b;
                        b--;
                }
        }
        cout << ans << endl;
}

Measured memory_bytes: 256
let split = Str.split (Str.regexp_string " ");;
let tuple3 l = let nth i = List.nth l i |> int_of_string in
               (nth 0, nth 1, nth 2);;
let rec readMtx mtx = function
    0 -> Array.of_list (List.rev mtx)
  | i -> let a = read_line () |> split |> List.map int_of_string |> Array.of_list
         in readMtx (a::mtx) (i-1);;

let () =
  let (n,m,l) = read_line () |> split |> tuple3 in
  let nm = readMtx [] n and
      ml = readMtx [] m and
      nl = Array.init n (fun x -> (Array.init l (fun y->0))) in
  for i = 0 to n-1 do
    for j = 0 to l-1 do
      for k = 0 to m-1 do
        nl.(i).(j) <- nl.(i).(j) + (nm.(i).(k) * ml.(k).(j))
      done
    done
  done;
  Array.iter (fun x ->
      Array.fold_left (fun x y -> x^" "^(string_of_int y)) "" x|> String.trim |> print_endline) nl;;

Measured memory_bytes: 4440
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        Integer numHP = sc.nextInt();
        Integer numHissatsu = sc.nextInt();
        sc.nextLine();
        
        int count = 0;
        int[] attackLine = new int[numHissatsu];
        while (sc.hasNext()) {
            int j = sc.nextInt();
            attackLine[count] = j;
            count++;
        }
        //String numAttack = sc.nextLine();
        
        sc.close();
        
        //List<String> attack = Arrays.asList(numAttack.split(""));
        
        String result = "No";
        
        for(int i = 0; i < numHissatsu; i++) {
            numHP = numHP - attackLine[i];
        }
        
        if(numHP <= 0) {
            result = "Yes";
        }
        
        System.out.println(result);
    }
}


Measured memory_bytes: 54724
import java.util.*;

public class Main {


    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        if(Character.isUpperCase(a.charAt(0))){
            System.out.println("A");
        }else {
            System.out.println("a");
        }

    }

}

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

using namespace std;

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

    string s;
    cin >> s;

    bool check = false;
    for(size_t i = 0; i < s.size() - 1; ++i){
        if(s[i] == 'A' && s[i + 1] == 'C'){
            check = true;
        }
    }

    cout << (check ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <string>
using namespace std;
#define FL(i,a,b) for(int i = a;i<b;i++)
typedef vector<int> vi;

const int inf = numeric_limits<int>::max();


int main(){
    string s,t;
    cin>>s>>t;
    int n = s.size();
    int m = t.size();
    int arr[n+1][m+1] = { };
    FL(i,1,n+1){
        FL(j,1,m+1){
            arr[i][j] = max(arr[i-1][j],arr[i][j-1]);
            int val = 0;
            if(s[i-1]==t[j-1]){
                val = 1;
            }
            arr[i][j] = max(arr[i][j],arr[i-1][j-1]+val);
        }
    }
   /* FL(i,0,n+1){
        FL(j,0,m+1){
            cout<<arr[i][j]<<" ";
        }
        cout<<"\n";
    }
    cout<<endl;*/
    int i = n;int j = m;
    string ans = "";
    while(i>0 && j>0){
        if(arr[i][j]==arr[i-1][j]){
            i--;
        }
        else if(arr[i][j]==arr[i][j-1]){
            j--;
        }
        else{
            ans = s[i-1] + ans;
            i--;j--;
        }
    }
    cout<<ans;

}

















Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
ll M=1e9+7;
int quick_pow(int x,int p){
    int a=1,po=x;
    while(p){
        if(p&1)  a=1ll*a*po%M;
        po=1ll*po*po%M;p>>=1;
    }
    return a;
}
//Start from Here
int main(){
    int N;
    cin>>N;
    int a[N];
    int b;
    vector<int> S;
    rep(i, N){
        cin>>b;
        a[i]=-b-i;
        S.push_back(b-i);
    }
    S.push_back(1e9);
    sort(S.begin(), S.end());
    S.push_back(1e9);
    ll cnt=0;
    rep(i, N){
        auto itr1=lower_bound(S.begin(),S.end(),a[i]);
        auto itr2=upper_bound(S.begin(), S.end(),a[i]);
        cnt+=itr2-itr1;
    }
    cout<<cnt<<endl;
}

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

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n,m,p[100010],y[100010];

ll p_count[100010];

struct shi{
    ll i,y,p,o;
};

// 比較関数を定義
bool asc( const shi& left, const shi& right ) {
    return left.y < right.y;
}

// 比較関数を定義
bool asc2( const shi& left, const shi& right ) {
    return left.i < right.i;
}

shi ss[100010];

int main() {
    std::cin >> n>>m;
    for (int i = 0; i < m; i++) {
        std::cin >> p[i]>>y[i];
        ss[i].i = i;
        ss[i].p = p[i];
        ss[i].y = y[i];
    }
    sort(ss,ss+m,asc);
    for (int i = 0; i < m; i++) {
        ss[i].o = p_count[ss[i].p];
        p_count[ss[i].p]++;
    }
    
    sort(ss,ss+m,asc2);
    
    for (int i = 0; i < m; i++) {
        std::cout << std::setfill('0') << std::right << std::setw(6) << ss[i].p;
        std::cout << std::setfill('0') << std::right << std::setw(6) << ss[i].o+1;
        std::cout << std::endl;
    }
    
}


Measured memory_bytes: 7040
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>

#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

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

  set<string> freebie;
  for (int i = 0; i < N; ++i)
  {
    string s;
    cin >> s;
    freebie.insert(s);
  }
  cout << freebie.size() << endl;
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
LL mp[200009];
vector<LL>v;
int main()
{
    LL n;
    cin>>n;
    LL a[n];
    for(LL i=0; i<n; i++)
    {

        cin>>a[i];
        mp[a[i]]++;
        v.pb(a[i]);
    }
    LL ans=0;
    Unique(v);
    for(LL i=0; i<v.size(); i++)
    {

        LL x=mp[v[i]];
        ans+=(x*(x-1))/2;
    }
    for(LL i=0;i<n;i++)
    {

        LL x=mp[a[i]];
        LL y=x-1;
        cout<<ans-(x*(x-1))/2+(y*(y-1))/2<<"\n";
    }


}


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

using namespace std;
int main(){

    int N; cin >> N;
    int P[N];
    for (int i = 0; i < N; i++) cin >> P[i];

    int ans = 0;
    for (int i = 0; i < N - 2; i++){
        int sum = P[i] + P[i + 1] + P[i + 2];
        if (P[i + 1] == sum - max(P[i], max(P[i+1], P[i+2])) - min(P[i], min(P[i+1], P[i+2])) ){
            ans ++;
        }
    }
    cout << ans << 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;

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

int main(){
    long double a, b; cin >> a >> b;
    cout << (unsigned long long)(a*b) << endl;
}


Measured memory_bytes: 3728
import bisect
def main():
    N, K = map(int, input().split())
    V = list(map(int, input().split()))
    m = 0
    for i in range(min(N, K)+1):
        for j in range(min(K - i, N-i) + 1):
            t = V[:i] + V[N-j:]
            t.sort()
            ind = bisect.bisect_right(t, 0)
            d = min((i+j), K - i - j, ind)
            m = max(m, sum(t[d:]))
    print(m)
main()


Measured memory_bytes: 40556
n=gets.chomp.to_i
ary=Array.new
ary=gets.chomp.split(" ").map{|num| num.to_i}
k=0


for i in 0..n-1
	j=i
	while j>0
		if ary[j] < ary[j-1]
			x=ary[j-1]
			ary[j-1]=ary[j]
			ary[j]=x
			k+=1
		end
		j-=1
	end
end
puts ary.join(" ")
puts k

Measured memory_bytes: 8612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	int n; cin >> n;
	vector<int>a(n);
	for (int& ele : a)cin >> ele;
	ll ans = 0;
	for (int i = 1; i < n; ++i) {
		if (a[i - 1] > a[i]) {
			ans += (a[i - 1] - a[i]);
			a[i] = (a[i - 1]-a[i]) + a[i];
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 4040
ans = [1, 2, 3, 4, 5, 6, 7, 8, 9]
K = int(input())
if K <=9:
    print(K)
    exit()

b_num = 9
while True:
    num = 0
    tmp_ans = []
    for a in ans:
        if a%10 == 0:
            tmp_ans.append(a*10)
            tmp_ans.append(a*10+1)
            num += 2
        elif a % 10 == 9:
            tmp_ans.append(a*10+8)
            tmp_ans.append(a*10+9)
            num += 2
        else:
            k = a%10
            tmp_ans.append(a*10+k-1)
            tmp_ans.append(a*10+k)
            tmp_ans.append(a*10+k+1)
            num += 3
        if num+b_num >= K:
            tmp = K-b_num
            print(tmp_ans[tmp-1])
            exit()
    ans = tmp_ans
    b_num += num


Measured memory_bytes: 6236
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

total = 0
for i in range(N):
    total += min(A[i], B[i])
    rem = max(0, B[i] - A[i])
    total += min(A[i+1], rem)
    A[i+1] = max(0, A[i+1] - rem)

print(total)



Measured memory_bytes: 18624
#include <iostream>
#include <string>

class saikoro
{
	private:
		int up, down, right, left, before, behind;
	public:
		saikoro(int a, int b, int c, int d, int e, int f);
		void W(void);
		void S(void);
		void E(void);
		void N(void);
		int which_up(void);
};

int main(void)
{
	using namespace std;
	int a, b, c, d, e, f;
	string str;
	cin >> a >> b >> c >> d >> e >> f;
	cin >> str;
	saikoro sai(a, b, c, d, e, f);
	for(int i = 0; i < str.length(); i++)
	{
		switch(str[i])
			{
				case 'W':
					sai.W();
					break;
				case 'S':
					sai.S();
					break;
				case 'N':
					sai.N();
					break;
				case 'E':
					sai.E();
					break;
			}
		}
	cout << sai.which_up() << endl;
	return 0;
}

saikoro::saikoro(int a, int b, int c, int d, int e, int f)
{
	up = a;
	before = b;
	behind = e;
	right = c;
	left = d;
	down = f;
}

void saikoro::W(void)
{
	int temp = left;
	left = up;
	up = right;
	right = down;
	down = temp;
}

void saikoro::S(void)
{
	int temp = before;
	before = up;
	up = behind;
	behind = down;
	down = temp;
}

void saikoro::E(void)
{
	int temp = right;
	right = up;
	up = left;
	left = down;
	down = temp;
}

void saikoro::N(void)
{
	int temp = behind;
	behind = up;
	up = before;
	before = down;
	down = temp;
}

int saikoro::which_up(void)
{
	return up;
}


Measured memory_bytes: 3236
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>
#include<array>
#include<cassert>
#include<list>

using namespace std;

#define SPEEDY cin.tie(0);ios::sync_with_stdio(false);

#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)

#define DEB(X) if(mode==1)cout<< #X <<": "<<X<<" ";
#define DEB2(X) if(mode==1)cout<<X<<" ";
#define ARDEB(i,X) if(mode==1)cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define FORDEB(n,X) if(mode==1)for(int i=0;i<(n);i++)ARDEB(i,X)
#define END if(mode==1)cout<<endl;

typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
struct P2{int x,y;};
//struct edge{int from,cost,to;};

const int MOD7=1000000007;
const int INF=100000000;
int mode=0;

int main(){
	int n,k,ans=1;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		if(ans*2<ans+k){
			ans*=2;
		}
		else{
			ans+=k;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
const int M = 1e5+5;

int arr[M] = {0};

int main(){
	int n,i,j;
	int num1 = 0;
	int num2 = 0;
	int ans = 0;
	scanf("%d",&n);
	for(i = 0; i < n; i++){
		scanf("%d",&j);
		if(arr[j] == 0){
			arr[j] = 1;
			num1++;
		}
		else{
			num2++;
		}
	}
	if(num2 % 2 == 0) ans = num1;
	else ans = num1 -1;
	printf("%d",ans);
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>

int main() {
	int n;
	std::cin >> n;
	int a[100];
	for (int i = 0;i < n;i++) {
		std::cin >> a[i];
	}
	int nSum = 1;
	int Sum = 1;
	for (int i = 0;i < n;i++) {
		Sum *= 3;
		if (a[i] % 2 == 0) {
			nSum *= 2;
		}
	}
	std::cout << Sum - nSum << std::endl;
	
	return 0;
}

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

using namespace std;

int n;
int cost[100001][3];
long long dp[100001][3];
long long rec(int pos , int type){
    if(pos >= n)return 0;
    if(~dp[pos][type])return dp[pos][type];
    long long ans = 0;
    if(type==0){
        ans += max(rec(pos + 1, 1) + cost[pos][type] , rec(pos + 1, 2) + cost[pos][type]);
    }
    if(type == 1){
        ans += max(rec(pos + 1 , 2) + cost[pos][type] , rec(pos + 1 , 0) + cost[pos][type]);
    }
    if(type == 2){
        ans += max(rec(pos + 1 , 1) + cost[pos][type] , rec(pos + 1, 0) + cost[pos][type]);
    }
    return dp[pos][type] = ans;

}

int main() {
    cin>>n;
    for(int i = 0 ; i < n; ++i){
        for(int j = 0; j < 3; ++j){
            cin>>cost[i][j];
        }
    }
    memset(dp , -1 , sizeof(dp));
    long long ret0 = rec(0 , 0);
    memset(dp , -1 , sizeof(dp));
    long long ret1 = rec(0 , 1);
    memset(dp , -1 , sizeof(dp));
    long long ret2 = rec(0 , 2);
    cout<<max({ret0 , ret1 , ret2})<<"\n";
}

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    string S;
    cin >> S;
    int K;
    cin >> K;
    int N = S.length();
    vector<ll> vec;
    char current = S[0];
    int cnt = 0;
    REP(i, N) {
        if (S[i] == current) {
            cnt++;
        } else {
            vec.push_back(cnt);
            current = S[i];
            cnt = 1;
        }
    }
    if (cnt > 0) {
        vec.push_back(cnt);
    }
    vector<ll> vec2 = vec;
    if (S[0] == S[N-1]) {
        if (vec2.size() == 1) {
            ll total = vec2[0] * 2;
            vec2.erase(vec2.begin());
            vec2.push_back(total);
        } else {
            ll total = vec2[0] + vec2[vec2.size()-1];
            vec2.erase(vec2.begin());
            vec2.erase(vec2.end()-1);
            vec2.push_back(total);
        }
    }
    ll ans = 0;
    if (vec.size() == 1) {
        ans = vec[0] * K / 2;
        print(ans);
    } else {
        REP(i, vec.size()) {
            ans += vec[i] / 2;
        }
        ll tmp = 0;
        REP(i, vec2.size()) {
            tmp += vec2[i] / 2;
        }
        ans += tmp * (K - 1);

        print(ans);
    }
}

signed main() {
    solve();
}


Measured memory_bytes: 256
//verfied at interviewbit and AOJ GRL_2_A
#include <bits/stdc++.h>
using namespace std;

#define pinf 0x7FFFFFFF

struct Edge {
  int dst;
  int wgt;
  Edge(int idst, int iwgt) : dst(idst), wgt(iwgt) {}
};

class Graph {
private:
  int V;
  int E;
  vector <vector <Edge>> adj;
public:
  Graph(int n, int m);
  void addEdge(int src, int dst, int wgt);
  int prims();
};

Graph::Graph(int n, int m) {
  this->V = n;
  this->E = m;
  adj.resize(n);
}

void Graph::addEdge(int src, int dst, int wgt) {
  Edge a(dst, wgt);
  Edge b(src, wgt);
  adj[src].push_back(a);
  adj[dst].push_back(b);
}

int Graph::prims() {
  priority_queue <pair <int, int>, vector <pair <int, int>>, greater<pair <int, int>>> pq;
  vector <int> dist(V, pinf);
  vector <bool> mstset(V, false);

  //..starting at node 0
  int src = 0;
  dist[src] = 0;
  pq.emplace(0, src);

  while (!pq.empty()) {
    pair <int, int> pr = pq.top(); pq.pop();      
    int u = pr.second;
    mstset[u] = true;

    for (Edge &e : adj[u]) {
      int v = e.dst;
      if (!mstset[v] && e.wgt < dist[v]) {
        dist[v] = e.wgt;
        pq.emplace(dist[v], v);
      }
    }
  }

  int cost = 0;
  for (int i = 0; i < V; i++) {
    cost += dist[i];
  } 
  return cost;
}

int main() {
  int n, m;
  cin >> n >> m;
  Graph g(n, m);
  int s, t, w;
  for (int i = 0; i < m; i++) {
    cin >> s >> t >> w;
    g.addEdge(s, t, w);
  }
  cout << g.prims() << endl;
  return 0;
}


Measured memory_bytes: 6196
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,s;
int l[505],r[505];
int cost[505][505];
int dp[505][501];
vector<int> tid;

int get_time(int a,int b,int l,int r){
	int va=min(b,r)-max(a,l);
	return max(0,va);
}

int main(void){
	scanf("%d%d",&n,&s);
	s--;
	for(int i=0;i<n;i++){
		scanf("%d%d",&l[i],&r[i]);
		tid.push_back(r[i]);
	}
	tid.push_back(0);
	sort(tid.begin(),tid.end());
	tid.erase(unique(tid.begin(),tid.end()),tid.end());

	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			scanf("%d",&cost[i][j]);
		}
	}
	for(int k=0;k<n;k++){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
			}
		}
	}

	memset(dp,-1,sizeof(dp));
	dp[0][s]=0;
	for(int i=0;i+1<tid.size();i++){
		for(int j=0;j<n;j++){
			if(dp[i][j]<0)continue;
			//printf("%d %d %d\n",i,j,dp[i][j]);
			for(int k=0;k<n;k++){
				int nc=tid[i]+cost[j][k];
				if(nc>=tid.back())continue;
				int v=upper_bound(tid.begin(),tid.end(),nc)-tid.begin();
				//printf("%d->%d %d %d %d %d\n",j,k,nc,tid[v],l[k],r[k]);
				int val=get_time(nc,tid[v],l[k],r[k]);
				dp[v][k]=max(dp[v][k],dp[i][j]+val);
			}
		}
	}
	int ans=0;
	for(int i=0;i<n;i++){
		ans=max(ans,dp[tid.size()-1][i]);
	}
	printf("%d\n",ans);
	return 0;
} 


Measured memory_bytes: 5236
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl

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

  string S; cin >> S;

  int res = 0;
  int temp = 0;
  for(auto c : S) {
    if(c=='A' || c=='C' || c=='G' || c=='T') {
      ++temp;
      res = max(res, temp);
    }
    else temp = 0;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
loop {
    n = gets.to_i
    break if n == 0
    hand = [(1..n).map { gets.to_i }.sort]
    hand << (1..2*n).to_a - hand[-1]
    min = 0 
    i = 0 
    loop {
        x = hand[i].find{|y| y > min}
        if x 
            hand[i].delete(x)
            min = x
            break if hand[i].empty?
        else
            min = 0
        end 
        i = 1 - i
    }
    puts hand.map(&:size).reverse
}

Measured memory_bytes: 6096
#include "bits/stdc++.h"
using namespace std;

int64_t MAX = 1000000000000000;

int main()
{
	int n;

	cin >> n;
	vector<int64_t> a(n + 1);		// 葉
	vector<int64_t> mae(n + 1);		// 前から見た時の最大頂点数
	vector<int64_t> ushiro(n + 1);	// 後ろから見た時の最大頂点数
	for (int i = 0; i <= n; i++) {
		cin >> a.at(i);
	}

	if (n == 0) {
		if (a.at(0) == 1) {
			cout << 1 << endl;
		} else {
			cout << -1 << endl;
		}
		return 0;
	}

	mae.at(0) = 1;
	for (int i = 1; i <= n; i++) {
		mae.at(i) = min((mae.at(i - 1) - a.at(i - 1)) * 2, MAX);
		if (mae.at(i) < 0) {
			cout << -1 << endl;
			return 0;
		}
	}

	ushiro.at(n) = a.at(n);
	for (int i = n - 1; i >= 0; i--) {
		ushiro.at(i) = min(ushiro.at(i + 1) + a.at(i), MAX);
	}

	int64_t ans = 0;
	for (int i = 0; i <= n; i++) {
		int64_t temp = min(mae.at(i), ushiro.at(i));
		if (temp < a.at(i)) {
			cout << -1 << endl;
			return 0;
		}
		ans += temp;
	}

	cout << ans << endl;
}


Measured memory_bytes: 5616
#include<iostream>

int main(){
    int A,B,C,res;
    int MAX=0, MAX2=0;
    std::cin>>A>>B>>C;

    int max1=std::max(A,B);
    int max2=std::max(B,C);
    int max3=std::max(A,C);
    int min1=std::min(A,B);
    int min2=std::min(B,C);
    int min3=std::min(A,C);

    if(max1==max2) res=10*B+max3+min3;
    else if(max2==max3) res=10*C+max1+min1;
    else res=10*A+max2+min2;

    std::cout<<res<<std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
int main() {
    //freopen("input.txt", "r", stdin);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    while (a >= b && k > 0) {
        b *= 2;
        k--;
    }
    while (b >= c && k > 0) {
        c *= 2;
        k--;
    }
    if (a < b && b < c)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 3624
import itertools
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=list(range(1,n+1))
    a=tuple(map(int, input().split()))
    b=tuple(map(int,input().split()))
    cnt=0
    aa=0
    bb=0
    for i in itertools.permutations(l,n):
        cnt+=1
        if a==i:
            aa=cnt
        if b==i:
            bb=cnt
    print(abs(aa-bb))
resolve()

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>s;
      rep(i,4)cout<<s[i];
      cout<<" ";
      rrep(i,4,Size(s))cout<<s[i];
      cout<<"\n";
     

       
return 0;
}


Measured memory_bytes: 256
N, M = [int(a) for a in input().split()]
p = [0] * M
S = [None] * M

num_WA = [0] * N
num_AC = [0] * N

for i in range(M):
    p[i], S[i] = input().split()
    p[i] = int(p[i])

    if S[i] == "AC":
        num_AC[p[i]-1] = 1
    else:
        if num_AC[p[i]-1] == 0:
            num_WA[p[i]-1] += 1

nAC = sum(num_AC)
nWA = 0
for i in range(N):
    if num_AC[i] == 1:
        nWA += num_WA[i]

print(nAC, nWA)

Measured memory_bytes: 14860
S = input()
countlist = []
for i in range(0, 26):
	countlist.append(0)
for i in range(0, len(S)):
	countlist[ord(S[i])-97] += 1
flag = True
for i in range(0, 26):
	if countlist[i] > 1:
		flag = False
		break
if flag: print('yes')
else: print('no')

Measured memory_bytes: 38384
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

    /**
     * 本処理を実行します。
     */
    public static void execute() {
        Scanner sc = new Scanner(System.in);

        int n = nextInt(sc);
        int k = nextInt(sc);
        Map<Integer, Integer> countMap = new HashMap<>(n);

        for (int i = 0; i < n; i++) {
            int ai = nextInt(sc);

            putCountMap(countMap, ai);
        }

        // value降順ソート
        List<Entry<Integer, Integer>> countEntry = new ArrayList<Entry<Integer, Integer>>(countMap.entrySet());
        valueReverseSort(countEntry);

        // 最低種類数と実際の種類数の差を計算、この差の分だけ、最も数が少ないものから入れ替える
        int requireChangeValue = countMap.size() - k;
        int result = 0;

        if (requireChangeValue > 0) {
            for (int i = countEntry.size() - 1; i >= countEntry.size() - requireChangeValue; i--) {
                result += countEntry.get(i).getValue();
            }
        }

        out(result);

    }

    /**
     * 次の標準入力をintで受け取ります。
     * @return 標準入力値(int)
     */
    public static int nextInt(Scanner sc) {
        return sc.nextInt();
    }

    /**
     * 次の標準入力をStringで受け取ります。
     * @return 標準入力値(String)
     */
    public static String nextString(Scanner sc) {
        return sc.next();
    }

    /**
     * 次の標準入力を指定回数分intで受け取ります。
     * @param n 取得回数
     * @return 取得した標準入力値の配列(int)
     */
    public static int[] nextInts(Scanner sc, int n) {
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = nextInt(sc);
        }

        return arr;
    }

    /**
     * 標準出力にオブジェクトを出力します。
     * @param o 出力対象
     */
    public static void out(Object o) {
        System.out.println(o);
    }

    public static void main(String[] args) {
        execute();
    }

    public static void putCountMap(Map<Integer, Integer> map, int value) {
        if (map.containsKey(value)) {
            map.put(value, map.get(value) + 1);
        } else {
            map.put(value, 1);
        }
    }

    private static void valueReverseSort(List<Entry<Integer, Integer>> highEntry) {
        Collections.sort(highEntry, new Comparator<Entry<Integer, Integer>>() {
            //compareを使用して値を比較する
            public int compare(Entry<Integer, Integer> obj1, Entry<Integer, Integer> obj2)
            {
                //降順
                return obj2.getValue().compareTo(obj1.getValue());
            }
        });
    }
}

Measured memory_bytes: 101912
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner scan=new Scanner(System.in);
    int money=scan.nextInt();
    if(money%1000!=0){
      System.out.println(1000-money%1000);
    }else{
      System.out.println(0);
    }
  }
}

Measured memory_bytes: 35720
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	string s;
	cin >> s;
	print(s[0] + to_string(SIZE(s) - 2) + s[SIZE(s) - 1]);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
import java.util.Scanner;

class ACGTHashList {
    private int M;
    private String[] H;

    public ACGTHashList(int M) {
        this.M = M;
        this.H = new String[M];
        for (int i = 0; i < M; i++) this.H[i] = "";
    }

    private static int ACGTtoInt(char c) {
        switch (c) {
            case 'A': return 1;
            case 'C': return 2;
            case 'G': return 3;
            case 'T': return 4;
        }
        return 0;
    }

    private int getKey(String str) {
        int sum = 0;
        for (int i = 0, p = 1; i < str.length(); i++, p *= 5) {
            sum += p * ACGTtoInt(str.charAt(i));
        }
        return sum;
    }

    private int h1(int key) {
        return key % this.M;
    }

    private int h2(int key) {
        return 1 + key % (this.M - 1);
    }

    public boolean find(String str) {
        int key = getKey(str);
        int h;
        int h1 = h1(key), h2 = h2(key);
        for (int i = 0;; i++) {
            h = (h1 + i* h2) % this.M;
            if (this.H[h].equals(str)) return true;
            else if (this.H[h].equals("")) return false;
        }
    }

    public boolean insert(String str) {
        int key = getKey(str);
        int h;
        int h1 = h1(key), h2 = h2(key);
        for (int i = 0;; i++) {
            h = (h1 + i * h2) % this.M;
            if (this.H[h].equals(str)) return false;
            else if (this.H[h].equals("")) {
                this.H[h] = str;
                return true;
            }
        }
    }
}


class Main {
    public static void main(String[] args) {
        ACGTHashList list = new ACGTHashList(1046527);
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            String command = sc.next();
            String key = sc.next();
            switch(command.charAt(0)) {
            case 'i':
                list.insert(key);
                break;
            case 'f':
                System.out.println(list.find(key) ? "yes" : "no");
            }
        }
    }
}



Measured memory_bytes: 240664
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xs = readLine()!!.split(' ').map { it.toInt() }
    var x = 1
    var ans = 0
    for (i in 0 until n) {
        if (xs[i] == x) {
            x++
            continue
        }
        ans++
    }
    println(if (ans < n) ans else -1)
}


Measured memory_bytes: 84460
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin);i>(end);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())

#define ll long long
#define f first
#define s second
using namespace std;

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;

int main()
{
	// 入力
	string S;
	cin>>S;
	ll s=S.size();

	ll Anum=0;
	ll ans=0;
	REP(i,s){
		if(S[i]=='A') Anum++;
		else if(S.substr(i,2)=="BC") {
			ans+=Anum;
			i++;
		}
		else Anum=0;
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 640
// コメント修正して, 再提出.
#include <bits/stdc++.h>
using namespace std;
using vvi = vector<vector<int>>;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define pb push_back
int du[101010], dv[101010], duv[101010]; // 距離を保存

// グラフを幅優先探索する.
// https://ja.wikipedia.org/wiki/幅優先探索
// ※bfsの動作確認用.
// @param G: グラフ.
// @param s: グラフの探索開始頂点.
// @param d: 探索開始地点からの距離.
// @return: 特に無し.
void bfs(vvi &G, int s, int* d){
    
    // 1. 空のキュー.
    queue<int> q;
    
    // 2. 訪問済みフラグ設定.
    // ※スタート地点は, 距離ゼロを指定.
    d[s] = 0;
    
    // 3. 探索地点 s をキュー q に追加.
    q.push(s);
    while(!q.empty()){
        
        // 4. キューから取り出す.
        int u = q.front();
        q.pop();
        
        // 5. 取り出した要素を処理.
        for(auto &e : G[u]){
            
            // 6. 訪問済であれば, 処理をスキップ.
            if(d[e] > 0)            continue;
            if(d[e] == 0 && e != s) d[e] = d[u] + 1, q.push(e);
        }
    }
    return;
}

int main(){
    
    // 1. 入力情報.
    int N, u, v;
    scanf("%d %d %d", &N, &u, &v);
    u--, v--;
    vvi G(N);
    rep(i, N - 1){
        int a, b;
        scanf("%d %d", &a, &b);
        a--, b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    
    // 2. 頂点 u, v から 各頂点までの距離を計算.
    bfs(G, u, du);
    bfs(G, v, dv);
    
    // 3. 頂点 u, v の 中間地点 m を 取得.
    // -> 但し, 中間地点については, 頂点 u, v の 間の距離 du[v] が, 
    // 偶数 か 奇数 で 変わってくる点を考慮する必要があるっぽい.
    // [偶数の場合(du[v] = 8)]
    // ex.
    // 24 17 6
    // 1 2
    // 2 3
    // 11 2
    // 12 11
    // 4 3
    // 4 5
    // 4 6
    // 7 6
    // 8 7
    // 9 3
    // 13 12
    // 9 10
    // 14 12
    // 14 16
    // 14 15
    // 16 17
    // 17 18
    // 15 19
    // 19 24
    // 20 19
    // 20 21
    // 21 22
    // 23 22
    // -> 11 が 正解のはず.
    // 
    // [奇数の場合(du[v] = 3)]
    // ex.
    // 9 5 2
    // 1 2
    // 7 9
    // 7 4
    // 6 5
    // 5 4
    // 8 3
    // 4 3
    // 3 2
    // -> 3 が 正解のはず.
    int m = -1, dm = du[v] / 2;
    rep(i, N){
        if(du[v] % 2 == 0){
            if(du[i] == dm && dv[i] == dm){
                m = i;
                break;
            }
        }else{
            if(du[i] == dm && dv[i] == dm + 1){
                m = i;
                break;
            }
        }
    }
    
    // 4. 頂点 m から 各頂点までの距離を計算.
    bfs(G, m, duv);
    
    // 5. 頂点 m から 最も遠い頂点 f を 取得.
    // ※ 但し, 頂点 v よりも 頂点 u に近いものに限定.
    int f = -1, df = 0;
    rep(i, N){
        if(df < duv[i] && du[i] < dv[i]) f = i, df = max(df, duv[i]);
    }
    
    // 6. 出力.
    printf("%d\n", duv[v] + duv[f] - 1);
    return 0;
    
}

Measured memory_bytes: 7040
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
   // ll t;cin>>t;
    //while(t--)
    //{
       ll n,i,p=0,k=0;
       cin>>n;
       string a;
       cin>>a;
       k=n/2;
       if(n%2==0)
       {
           for(i=0;i<n/2;i++)
           {
               if(a[i]!=a[k])
                {p=1;
               break;}
               k++;
           }
          if(p==0)
            cout<<"Yes";
          else
            cout<<"No";
       }
       else
        cout<<"No";
             return 0;
}


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

const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
int a[maxn], p[maxn], dp[maxn];

int main() {
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);

    dp[0] = 1;
    for (int i = 1; i <= n; ++i) {
        dp[i] = dp[i - 1];
        if (p[a[i]] > 0 && p[a[i]] != i - 1)
            (dp[i] += dp[p[a[i]]]) %= mod;

        p[a[i]] = i;
    }

    printf("%d\n", dp[n]);
    return 0;
}


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

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

	vector<pair<int, int>> p(5);
	for (int i = 0; i < 5; i++) {
		p[i] = make_pair(a[i] % 10, a[i]);
	}
	sort(p.begin(), p.end());

	int ans = 0;
	int i = 0;
	while (i < 5) {
		ans += p[i].second;
		if (p[i].first != 0) {
			i++;
			break;
		}
		i++;
	}
	while (i < 5) {
		ans += p[i].second - p[i].first + 10;
		i++;
	}
	cout << ans << endl;



	return 0;
}

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

void dpA(){
    int n;
    cin >> n;
    auto h = vector<ll>(n,0);
    for(ll i =0;i<n;i++) cin >> h[i];

    auto dp = vector<ll>(n+2,1e9);
    
    dp[0] = 0;
    dp[1] = 0;
    for(ll i=1;i<n;i++){
        if(i>=2) dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2])); 
        else if(i>=1) dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
    }
    cout << dp[n-1];
}

void dpB(){
    ll n,k;
    cin >> n >> k;
    auto h = vector<ll>(n+1,0);
    for(ll i=0;i<n;i++) cin >> h[i];

    auto dp = vector<ll>(100000,1e9);
    dp[0] = 0;
    for(ll i=0;i<n;i++){
        for(ll j=1;j<=k;j++){
           if(i+j<=n) dp[i+j] = min(dp[i+j],dp[i] + abs(h[i+j]-h[i]));
        }
    }
    cout << dp[n-1];
}

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

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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; }

vector<ll> dp(100010,0);
vector<bool> ng(100010,false);

int main(int argc, char const *argv[]) {
  int n,m;
  cin >> n >> m;
  rep(i,m){
    int a; cin >> a;
    ng[a]=true;
  }
  ll ans = 0;
  dp[0] = 1;
  rep(i,n){
    if (!ng[i + 1]) dp[i + 1] += dp[i]%MOD;
    if (!ng[i + 2]) dp[i + 2] += dp[i]%MOD;
  }
  cout << dp[n]%MOD << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <memory.h>
#include <cstring>
#include <vector>
#include <deque>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <iostream>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef unsigned long long llu;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
const ll MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

priority_queue<int, vector<int>, greater<int> > pq;
vector<int> v;

int vec[200001];
int num[200001];

int main() {
	int n, k;
	scanf("%d %d", &n, &k);

	int t;
	for (int i = 0; i < n; i++) {
		scanf("%d", &vec[i]);
		num[--vec[i]]++;
	}


	for (int i = 0; i < n; i++)
		if (num[i] != 0) pq.push(num[i]);

	int ans = 0;
	while (sz(pq) > k) {
		ans += pq.top();
		pq.pop();
	}

	printf("%d", ans);
}

Measured memory_bytes: 2936