akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {
          
    		var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			var AArray = retreiveLongArray();

			var sortedArray = AArray.OrderBy(x => x).ToArray();
			var sortedDictonary = new Dictionary<long, long>();
			for (int i = 0; i < N; i++) {
				sortedDictonary.Add(i, sortedArray[i]);
			}


			var max = sortedDictonary[N - 1];
			var checkArray = new bool[max + 1];
			for (int i = 0; i < max + 1; i++) {
				checkArray[i] = true;
			}

			for (int i = 0; i < N; i++) {
				var x = sortedDictonary[i];
				if (!checkArray[x]) {
					continue;
				}

				var wareru = x*2; 
				while (wareru <= max) {
					checkArray[wareru] = false;
					wareru += x;
				}

				//同じ数がある場合の処理
				var k = i + 1;
				while (k<N && sortedDictonary[k]==x) {
					checkArray[x] = false;
					checkArray[sortedDictonary[k]] = false;
					k++;

				}

			}

			//答えの出力
			var ans = sortedDictonary.Where(x =>checkArray[x.Value]);

			//foreach (var a in ans) {
				//Console.WriteLine(a.Value);
			//}
			
			Console.WriteLine(ans.Count());


		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


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

using namespace std;

int n = 500, k, a[505][505];

int main() {
	scanf("%d", &k);
	if (k <= n) {
		printf("%d\n", k);
		for (int i = 1; i <= k; ++i)
			for (int j = 1; j <= k; ++j)
				printf("%d%c", i, j == k ? '\n' : ' ');
		return 0;
	}

	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			if (i + n + 1 > k)
				a[j][(i + j) % n] = i + 1;
			else
				a[j][(i + j) % n] = (j & 1) ? i + 1 + n : i + 1;
	printf("%d\n", n);
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			printf("%d%c", a[i][j], j == n - 1 ? '\n' : ' ');
}

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

int main(){
	int x;
	cin >> x;
	int number_500,number_5;
	number_500 = x / 500;
	x -= 500 * number_500;
	number_5 = x / 5;
	int total_point;
	total_point = 1000*number_500+5*number_5;
	cout << total_point << endl;
}



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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
const ll INF = 1e17;

int N, M, L, Q;
ll A[400][400];
ll A2[400][400];

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    cin >> N >> M >> L;
    FOR1(i, N) FOR1(j, N) A[i][j] = A2[i][j] = INF;
    FOR(i, M){
        int u, v;
        ll c;
        cin >> u >> v >> c;
        if (c > L) c = INF;
        A[u][v] = A[v][u] = c;
    }

    FOR1(k, N){
        FOR1(i, N){
            FOR1(j, N){
                if (A[i][k] + A[k][j] < A[i][j]){
                    A[i][j] = A[i][k] + A[k][j];
                }
            }
        }
    }

    FOR1(i, N) FOR1(j, N) if (A[i][j] <= L) A2[i][j] = 1;

    FOR1(k, N){
        FOR1(i, N){
            FOR1(j, N){
                if (A2[i][k] + A2[k][j] < A2[i][j])
                    A2[i][j] = A2[i][k] + A2[k][j];
            }
        }
    }

    cin >> Q;
    FOR(i, Q){
        int s, t;
        cin >> s >> t;
        if (A2[s][t] == INF)
            cout << - 1 << endl;
        else{
            cout << A2[s][t]-1 << endl;
        }
    }

    //if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

#define FOR(i,n) for(i=0;i<n;++i)

int i,j;

int main(void){
    cin>>i;
    if(i<1200)cout<<"ABC";
    else cout<<"ARC";
    
    
    return 0;
}

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

int main() {
    string s, cat1 = "mmewe", cat2 = "emeww";
    cin >> s;
    while(1){
        int pos;
        pos = s.find(cat1);
        if(pos!=s.npos){
            s.replace(pos,cat1.size(),"me");
            continue;
        }
        pos = s.find(cat2);
        if(pos!=s.npos){
            s.replace(pos,cat2.size(),"ew");
            continue;
        }
        break;
    }
    cout << (s=="mew"?"Cat":"Rabbit") << endl;
    return 0;
}


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

int n;
char S[11234][6];
int dice[6] = { 1,2,3,5,4,6 }, tmp = 0, ans = 0;

int main(void) {
	while (true) {
		ans = 0;
		dice[0] = 1;
		dice[1] = 2;
		dice[2] = 3;
		dice[3] = 5;
		dice[4] = 4;
		dice[5] = 6;
		scanf("%d", &n);
		if (n == 0) { break; }
		for (int i = 0; i < n; ++i) { scanf("%s", &S[i]); }

		for (int i = 0; i < n; ++i) {
			if (strcmp(S[i], "North") == 0) {
				tmp = dice[0];
				dice[0] = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[3];
				dice[3] = tmp;
				ans += dice[0];
			}
			else if (strcmp(S[i], "East") == 0) {
				tmp = dice[0];
				dice[0] = dice[4];
				dice[4] = dice[5];
				dice[5] = dice[2];
				dice[2] = tmp;
				ans += dice[0];
			}
			else if (strcmp(S[i], "South") == 0) {
				tmp = dice[0];
				dice[0] = dice[3];
				dice[3] = dice[5];
				dice[5] = dice[1];
				dice[1] = tmp;
				ans += dice[0];
			}
			else if (strcmp(S[i], "West") == 0) {
				tmp = dice[0];
				dice[0] = dice[2];
				dice[2] = dice[5];
				dice[5] = dice[4];
				dice[4] = tmp;
				ans += dice[0];
			}
			else if (strcmp(S[i], "Right") == 0) {
				tmp = dice[1];
				dice[1] = dice[2];
				dice[2] = dice[3];
				dice[3] = dice[4];
				dice[4] = tmp;
				ans += dice[0];
			}
			else if (strcmp(S[i], "Left") == 0) {
				tmp = dice[1];
				dice[1] = dice[4];
				dice[4] = dice[3];
				dice[3] = dice[2];
				dice[2] = tmp;
				ans += dice[0];
			}
		}
		printf("%d\n", ans + 1);
	}
	return 0;
}

Measured memory_bytes: 2632
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int n,a,b,c;
int l[10];
int ans=100000;
int nm[10];

void dfs(int rd=0){
  if(rd==n){
    int sum[3]={};
    int cnt=0;
    for(int i=0;i<n;i++){
	 if(nm[i]==3)continue;
	 sum[nm[i]]+=l[i];
	 cnt++;
    }

    if(sum[0]==0)return;
    if(sum[1]==0)return;
    if(sum[2]==0)return;
    
    int cost=(cnt-3)*10;
    cost+=abs(sum[0]-a);
    cost+=abs(sum[1]-b);
    cost+=abs(sum[2]-c);
	 
    ans=min(ans,cost);
    return;
  }
  for(int i=0;i<4;i++){
    nm[rd]=i;
    dfs(rd+1);
  }
}

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

  dfs();
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll a(n+1, 0);
    rep(i, n){
        cin >> a[i+1];
    }
    vll x(n+1, 0);
    ll ans = 0;
    for(ll i = n; i > 0; i--){
        int m = 0;
        for(ll j = 2*i; j <= n; j += i){
            m += x[j];
            m %= 2;
        }
        x[i] = (m ^ a[i]);
        if(x[i]) ans++;
    }
    cout << ans << endl;
    repr(i, 1, n+1){
        if(x[i]){
            ans--;
            cout << i;
            if(ans) cout << " ";
            else cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#include <set>
using namespace std;
int cnt = 0;
int cnt2 = 0;
bool check(long long x, int n){
    bool ans;
    set<int> st;
    while(x){
        st.insert(x%10);
        x /= 10;
    }
    if(st.size() == 3) ans = true;
    else ans = false;
    return ans;
}
void dfs(long long x,int n){
    if(n < x) return;
    if(check(x,n)) cnt++;
    dfs(10*x+3,n);
    dfs(10*x+5,n);
    dfs(10*x+7,n);
}
int main(){
   // ios::sync_with_stdio(false);
  //  cin.tie(0);
    int n; cin >> n;
    dfs(0,n);
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

struct UnionFind {
    vector< int > data;
    UnionFind(int sz) {
        data.assign(sz, -1);
    }
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return (false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }
    int find(int k) {
        if(data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }    
    int size(int k) {
        return (-data[find(k)]);
    }
};

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    vector<P> edge(m); for (auto &e: edge) cin >> e.first >> e.second;
    int ans = 0;
    rep (i, m) {
        UnionFind uf(n);
        rep (j, m) {
            if (i == j) continue;
            uf.unite(edge[j].first - 1, edge[j].second - 1);
        }
        if (uf.find(edge[i].first - 1) != uf.find(edge[i].second - 1)) ans++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int a[11][11];
int main()
{
	int n,d,ans=0,x=0;
	cin>>n>>d;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=d;j++)
			cin>>a[i][j];
	for(int i=1;i<=n-1;i++)
	{
		int q=i+1;
		int p=n;
		for(int l=q;l<=p;l++)
		{
			for(int j=1;j<=d;j++)
				x+=(a[i][j]-a[l][j])*(a[i][j]-a[l][j]);
			if(sqrt(x)==floor(sqrt(x)))
				ans++;
			x=0;
		}
		
	}
	cout<<ans;
 }

Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T& v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

/*
*/
#define NONE 0
#define SHEEP 1
#define WOLF 2
int main() {
  int n; in(n);
  string s; in(s);
  char c = s[0];
  
  loop(i,1,3) { // 0番目
    loop(j,1,3) { // 1番目
      vector<int> ans(n+1, NONE);
      ans[0] = i;
      ans[n] = i;
      ans[1] = j;
      if (i == SHEEP and c == 'o') {
        ans[n-1] = j;
      }
      else if (i == SHEEP and c == 'x') {
        ans[n-1] = (j == SHEEP) ? WOLF : SHEEP;
      }
      
      else if (i == WOLF and c == 'x') {
        ans[n-1] = j;
      }
      
      else if (i == WOLF and c == 'o') {
        ans[n-1] = (j == SHEEP) ? WOLF : SHEEP;
      }
      assert(ans[n-1] != NONE);
      
      bool ok = true;
      loop(k,1,n) {
        int k_1 = NONE;
        if (ans[k] == SHEEP and s[k] == 'o') {
          k_1 = ans[k-1];
        } else if (ans[k] == SHEEP and s[k] == 'x') {
          k_1 = ans[k-1] == SHEEP ? WOLF : SHEEP;
        } else if (ans[k] == WOLF and s[k] == 'o') {
          k_1 = ans[k-1] == SHEEP ? WOLF : SHEEP;
        } else if (ans[k] == WOLF and s[k] == 'x') {
          k_1 = ans[k-1];
        }
        assert(k_1 != NONE);
        if (ans[k+1] != NONE and ans[k+1] != k_1) {
          ok = false;
          break;
        }
        ans[k+1] = k_1;
      }
      
      if (ok) {
        loop(i,0,n) {
          if (ans[i] == SHEEP) print('S', "");
          else print('W', "");
        }
        print("");
        return 0;
      }
    }
  }
  
  print(-1);
  return 0;
}


Measured memory_bytes: 4228
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int *a = new int[n];
    int *b = new int[n];
    int *c = new int[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    int dp[100000][3];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for(int i=1;i<n;i++)
    {
        dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1] = max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2] = max(dp[i-1][1],dp[i-1][0])+c[i];
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;
int main(){
  string S;
  cin>>S;
  string ans="yes";
  sort(S.begin(),S.end());
  for(int i=1;i<S.size();i++){
    if(S.at(i-1)==S.at(i)){
      ans="no";
      break;
    }
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
# 最小全域木 Minumum spannin tree

MAX_EDGE_COST = 2001
n = int(input())
A = [[0 for i in range(n)] for i in range(n)]
for i in range(n):
    A[i] = [int(i) for i in input().split()]

col = [-1 for i in range(n)]
d = [MAX_EDGE_COST for i in range(n)]
p = [-1 for i in range(n)]

d[0] = 0
while True:
    mincost = MAX_EDGE_COST;
    for i in range(n):
        if col[i] != 1 and d[i] < mincost:
            mincost = d[i]
            u = i
    
    if mincost == MAX_EDGE_COST:
        break;
    
    col[u] = 1
    
    for v in range(n):
        if col[v] != 1 and A[u][v] != -1:
            if A[u][v] < d[v]:
                d[v] = A[u][v]
                p[v] = u
                col[v] = 0

sum = 0
for i in range(n):
    if p[i] != -1:
        sum += A[i][p[i]]

print(sum)


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



int main() 
{
  ll N;
  cin >> N;
  vector<ll> num(N);
  rep(i,N)
  {
    cin >> num.at(i);
  }
  sort(num.begin(),num.end());
  reverse(num.begin(),num.end());
  ll a = 0,b = 0;
  rep(i,(N + 1) / 2)
  {
    a += num.at(2 * i);
  }
  rep(i,N / 2)
  {
    b += num.at(2 * i + 1);
  }
  cout << a - b << endl;
}

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

int main(){
  string s;
  cin>>s;
  int N = s.size();
  vector <pair<int,ll>> ans;
  ll cnt(1);
  for (int i(0);i<N-1;i++){
    if (s[i]!=s[i+1]){
      if (s[i]=='<'){
        ans.push_back({cnt,(ll)(cnt*(cnt-1))/2});
      }else{
        int tmp = 0;
        if (!ans.empty()){
          if (ans.back().first > cnt) tmp =ans.back().first - cnt;
          ans.push_back({cnt,tmp + (ll)(cnt*(cnt+1))/2});
        }else{
          ans.push_back({cnt,tmp + (ll)(cnt*(cnt+1))/2});
        }
      }
      cnt=1;
    }else{
      cnt++;
    }
  }

  if (s[N-1]=='<'){
    ans.push_back({cnt,(ll)(cnt*(cnt+1))/2});
  }else{
    int tmp = 0;
    if (!ans.empty()){
      if (ans.back().first > cnt) tmp =ans.back().first - cnt;
      ans.push_back({cnt,tmp + (ll)(cnt*(cnt+1))/2});
    }else{
      ans.push_back({cnt,tmp + (ll)(cnt*(cnt+1))/2});
    }
  }

  ll sum(0);
  for (int i(0);i<ans.size();i++){
    sum+=ans[i].second;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 6520
#include <iostream>
#include <cmath>
#include <string>
using namespace std;

int main(){
    int N;
    cin >> N;
    int l,s;
    s = N / 100;
    l = s + 1;
    s = s*100 + s*10 + s;
    l = l*100 + l*10 + l;
    if(N <= s){
        cout << s << endl;
    }else{
        cout << l << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <iomanip>
#include <cstring>
#include <climits>
#include <cstdio>

#define nl '\n'

using namespace std;

long long n, a, cf, cs, x, o, p;

int main(){

    vector<long long> v;

    map<long long, long long> f;
    map<long long, long long> s;

    cin >> n;

    for(long long i = 0; i < n; i++){
        cin >> a;
        if(i%2 == 0){
            f[a]++;
        } else {
            s[a]++;
        }
        v.push_back(a);
    }

    for(map<long long, long long>::iterator it = f.begin(); it != f.end(); it++){
        if((*it).second > cf){
            cf = (*it).second;
            o = (*it).first;
        }
    }

    for(map<long long, long long>::iterator it = s.begin(); it != s.end(); it++){
        if((*it).second > cs){
            cs = (*it).second;
            p = (*it).first;
        }
    }

    for(long long i = 0; i < n; i++){
        if(i%2 == 0){
            if(v[i] != o){
                x++;
            }
        } else {
            if(v[i] != p){
                x++;
            }
        }
    }

    if(o == p){
        f[o] = -1;
        s[p] = -1;
        long long rf = 0;
        long long rs = 0;
        for(map<long long, long long>::iterator it = f.begin(); it != f.end(); it++){
            if((*it).second > rf){
                rf = (*it).second;
                o = (*it).first;
            }
        }

        for(map<long long, long long>::iterator it = s.begin(); it != s.end(); it++){
            if((*it).second > rs){
                rs = (*it).second;
                p = (*it).first;
            }
        }
        
        x = n - max((cf + rs), (rf + cs));
    }

    cout << x;


}
 
//g++ -std=c++14 comp.cpp -o c && c.exe
//g++ -std=c++14 comp.cpp -o c; ./c.exe
//g++ -std=c++14 comp.cpp && ./a.out


//Surely this is going to AC

Measured memory_bytes: 7284
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define inf (1ll<<60)
signed main(){
  int N; cin>>N;
  Priq Q;
  vi A(3*N);
  rep(i,0,3*N) cin>>A[i];
  vi B(N+1);
  rep(i,0,N){
    B[0]+=A[i];
    Q.push(A[i]);
  }
  rep(i,N,2*N){
    int K=i-N+1;
    B[K]=B[K-1]+A[i];
    Q.push(A[i]);
    B[K]-=Q.top();
    Q.pop();
  }
  vi C(N+1);
  priq P;
  REP(i,1,N){
    int K=3*N-i;
    C[0]+=A[K];
    P.push(A[K]);
  }
  REP(i,1,N){
    int K=2*N-i;
    C[i]=C[i-1]+A[K];
    P.push(A[K]);
    C[i]-=P.top();
    P.pop();
  }
  int ans=-inf;
  REP(i,0,N){
    ans=max(B[i]-C[N-i],ans);
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 6516
a = list(map(str, input()))+['a']
b = list(map(str, input()))+['b']
c = list(map(str, input()))+['c']
now = 'a'
ans = 'A'
while len(a) != 0 and len(b) != 0 and len(c) != 0:
    if now == 'a':
        now = a[0]
        a.pop(0)
        ans = 'A'
    elif now == 'b':
        now = b[0]
        b.pop(0)
        ans = 'B'
    else:
        now = c[0]
        c.pop(0)
        ans = 'C'
print(ans)
    


Measured memory_bytes: 9060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] A = new int[M];
		int[] B = new int[M];
		for(int i = 0; i < M; i++) {
			A[i] = sc.nextInt() - 1;
			B[i] = sc.nextInt() - 1;
		}
		sc.close();
		DisjointSet ds = new DisjointSet(N);
		long[] ans = new long[M];
		ans[M - 1] = (long)N * (N - 1) / 2;
		for(int i = M - 1; i >= 1; i--) {
			if(!ds.same(A[i], B[i])) {
				ans[i - 1] = ans[i] - (long)ds.size(A[i]) * ds.size(B[i]);
				ds.unite(A[i], B[i]);
			}else {
				ans[i - 1] = ans[i];
			}
		}
		for(int i = 0; i < M; i++) {
			System.out.println(ans[i]);
		}
	}
	static class DisjointSet {
        int[] p;
        int[] rank;
        int[] size;
        DisjointSet(){}
        DisjointSet(int size){
            this.rank = new int[size];
            this.p = new int[size];
            this.size = new int[size];
            for(int i = 0; i < size; i++) {
                makeSet(i);
            }
        }
        void makeSet(int x) {
            p[x] = x;
            rank[x] = 0;
            size[x] = 1;
        }
        boolean same(int x, int y) {
            return findSet(x) == findSet(y);
        }
        void unite(int x, int y) {
            link(findSet(x), findSet(y));
        }
        void link(int x, int y) {
            if(rank[x]  > rank[y]) {
                p[y] = x;
                size[x] = size[x] + size[y];
            }else if(rank[x] < rank[y]){
                p[x] = y;
                size[y] = size[x] + size[y];
            }else if(x != y) {
            	p[y] = x;
            	rank[x]++;
            	size[x] = size[x] + size[y];
            }
        }
        int findSet(int x) {
            if(x != p[x]) {
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
        int size(int x) {
        	if(x != p[x]) {
        		size[x] = size(findSet(x));
        	}
        	return size[x];
        }
    }
}

Measured memory_bytes: 97644
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define speed ios_base::sync_with_stdio(0); cin.tie(0);
#define FL(i,a,n) for(ll i=a;i<n;i++)
#define even(x) (((x)%(2))==(0))
#define odd(x) (((x)%(2))==(1))
#define meme(x) memset(x, 0, sizeof(x))
#define mod 1000000007

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

int main()
{
    speed
    int l,r,d;cin>>l>>r>>d;
    ll cnt=0;
    for(int i=l;i<=r;i++)
    {
        if(i%d==0)
        cnt++;
    }
    cout<<cnt<<endl;
}



Measured memory_bytes: 3604
import re

S = input()
T = input()

for i in range(len(S) - len(T), -1, -1):
    if re.fullmatch(S[i:i+len(T)].replace('?', '.'), T):
        print((S[:i] + T + S[i+len(T):]).replace('?', 'a'))
        break
else:
    print('UNRESTORABLE')


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define for_each(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = __INT_MAX__;               // 2^31 - 1
const long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    ll w, h;
    cin >> h >> w;
    ll ans = 0;
    ans += (h * w + 1) / 2;
    if (h == 1 || w == 1)
        ans = 1;
    out(ans);
}


Measured memory_bytes: 256
def main():
    from collections import Counter
    N = int(input())
    A_list = [A for A in input().split()]
    A_list = list(map(int, A_list))
    #ans_list = []
    ans = Counter(A_list)

    for n_cycle in range(N) :
        n_cycle = n_cycle + 1
        #ans_list.append(A_list.count(n_cycle))
        print(ans[n_cycle])

if __name__ == '__main__':
    main()


Measured memory_bytes: 35192
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
const int N=2e5+100;
int Log[N],p[N],pos[N];
struct ST{
	int mi[20][N];
	inline void build(int n,int o) {
		for (int i=1;i<=n;i++)
			mi[0][i]=(i&1)==o?p[i]:n+1;
		for (int t=1;t<20;t++)
			for (int i=n-(1<<t)+1;i>0;i--)
				mi[t][i]=min(mi[t-1][i],mi[t-1][i+(1<<(t-1))]);
	}
	inline int query(int l,int r) {
		int s=Log[r-l+1];
		return min(mi[s][l],mi[s][r-(1<<s)+1]);
	}
}T[2];
struct seg{
	int l,r,L,R;
	seg() {}
	seg(int _l,int _r) {
		l=_l,r=_r;
		L=pos[T[l&1].query(l,r)];
		R=pos[T[~L&1].query(L+1,r)];
	}
	inline bool operator < (const seg &b) const { return p[L]>p[b.L]; };
};
int main()
{
	int n=gi(),i;
	for (Log[0]=-1,i=1;i<=n;i++) pos[p[i]=gi()]=i,Log[i]=Log[i>>1]+1;
	T[0].build(n,0),T[1].build(n,1);
	priority_queue<seg>q;seg t;
	q.push(seg(1,n));
	while (!q.empty()) {
		t=q.top();q.pop();
		printf("%d %d ",p[t.L],p[t.R]);
		if (t.l!=t.L) q.push(seg(t.l,t.L-1));
		if (t.L+1<t.R) q.push(seg(t.L+1,t.R-1));
		if (t.R!=t.r) q.push(seg(t.R+1,t.r));
	}
	return 0;
}


Measured memory_bytes: 35828
import sys
input = sys.stdin.readline

n = int(input())
c = input()

rc = c.count('R')
wc = c.count('W')

if wc == 0 or rc == 0:
    print(0)
else:
    rstr = c[0:rc]
    wstr = c[rc:]
    print(max(rstr.count('W'), wstr.count('R')))


Measured memory_bytes: 9480
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>

uint64_t get_gcd (uint64_t a, uint64_t b)
{
    if (b == 0) return a;
    else return get_gcd(b, a % b);
}

int main (int argc, char const *argv[])
{
    int64_t N, A[(int)1e5];
    int64_t ans = 0;

    scanf("%"PRId64, &N);
    for (int i = 0; i < N; i++) {
        scanf("%"PRId64, &A[i]);
    }

    ans = A[0];
    for (int i = 1; i < N; i++) {
        ans = get_gcd(ans, A[i]);
    }

    printf("%"PRId64"\n", ans);

    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define in(s) ll s; cin>>s
#define pr(r) cout<<r<<endl
#define prr(m,n) cout<<m<<" "<<n<<endl
#define prarr(a,i,n) fab(j,i,n) cout<<a[j]<<" "
#define wh(t) ll t; cin>>t; while(t--)
#define sz(u) u.size()
#define all(v) v.begin(),v.end()
#define arr(a,n) ll a[n]; fab(i,0,n) cin>>a[i]
#define showdp(d,n,m) fab(i,0,n){ fab(j,0,m) if(d[i][j]==-1 || d[i][j]>9) cout<<d[i][j]<<" "; else cout<<" "<<d[i][j]<<" "; cout<<endl; }
#define prs(u) cout<<u<<" "
#define fab(i,a,b) for(ll i=a;i<b;i++)
#define fba(i,b,a) for(ll i=b;i>=a;i--)
#define sup ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MX 1000000007
#define MAX 10000007
#define endl "\n"
#define ll long long int
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define pl pair<ll,ll>
#define pll pair<ll,pl>
#define vvl vector<vl>
#define mxe(x,n) *max_element(x,x+n)
#define mne(x,n) *min_element(x,x+n)
#define mp make_pair
#define pb push_back
#define fs first
#define sd second
#define fr front()
#define bk back()
#define rr return
#define N 300005
#define inf 1e18+7
 
bool rsort1(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.first > b.first);}
bool rsort2(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.second>b.second);}
bool sort2(const pair<ll,ll> &a,const pair<ll,ll> &b){ return (a.second < b.second);}
 
bool isPrime(ll p)
{
    for(ll i=2;i*i<=p;i++)
        if(p%i==0)
            rr false;
    rr true;
}
 
void sieve(ll n,vl &v)
{
    v.pb(2);
    bool prime[n+1];
    memset(prime,true,sizeof(prime));
    for(ll i=3;i*i<=n;i+=2)
        if(prime[i])
            for(ll j=i;j*i<=n;j+=2)
                prime[j*i]=false;
        
    for(ll i=3;i<=n;i+=2)
        if(prime[i])
            v.pb(i);
}

ll phi(ll n)
{
    ll result=n;
    for(ll p=2;p*p<=n;p++)
    {
        if(n%p==0)
        {
            while(n%p==0)
                n/=p;
            result-=result/p;
        }
    }

    if(n>1)
        result-=result/n;
    return result;
}

ll fact[10];
void fct()
{
    fact[0]=1;
    fab(i,1,10)
        fact[i]=fact[i-1]*i;
}

int main()
{
	sup;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("error.txt","w",stderr);
    #endif*/
	
    fct();
    ll n,a[10],b[10],aa=1,bb=1,c1=1,c2=1,id[10],di[10];
    cin>>n;
    fab(i,0,n)
    {
        cin>>a[i];
        id[i+1]=i;
    }
    fab(i,0,n)
    {
        cin>>b[i];
        di[i+1]=i;
    }
    fab(i,1,n+1)
    {
        ll j=i-1;
        c1=id[a[j]];
        aa+=c1*fact[n-i];
        if(a[j]!=n)
            fab(k,a[j]+1,n+1)
                id[k]--;
        c2=di[b[j]];
        bb+=c2*fact[n-i];
        if(b[j]!=n)
            fab(k,b[j]+1,n+1)
                di[k]--;
    }
    pr(abs(aa-bb));
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		int x = Integer.parseInt(str);

		if (1 <= x && x <= 100) {
			System.out.println(x * x * x);
		}

	}

}



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

import re
def make_agct(n):        
    agct = ['A', 'G', 'C', 'T']
    accept_list = {}
    
    accept_list[3] = {}
    for s0 in agct:
        for s1 in agct:
            for s2 in agct:
                s = s0 + s1 + s2
                if s == 'AGC':
                    continue
                if s == 'ACG':
                    continue
                if s == 'GAC':
                    continue
                accept_list[3][s] = 1
    
    for i in range(3, n):
        accept_list[i+1] = {}
        for si, v in accept_list[i].items():
            for sn in agct:
                s = si + sn
                last4 = s
                if re.match('.AGC', last4 ):
                    continue
                if re.match('.ACG', last4 ):
                    continue
                if re.match('.GAC', last4 ):
                    continue
                if re.match('AG.C', last4 ):
                    continue
                if re.match('A.GC', last4 ):
                    continue
                last3 = s[1:]
                if last3 in accept_list[i+1]:
                    accept_list[i+1][last3] +=v
                else:
                    accept_list[i+1][last3] = v
    
    ans = 0
    for k, v in accept_list[n].items():
        ans += v
    
    ans = ans % (10 ** 9 + 7)
    print(ans)       
                
make_agct(N)


    




    









Measured memory_bytes: 4084
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define f first
#define s second
#define int long long
int t[114514],x[114514],y[114514];
signed main(){
	ic(n)
	rep(1,i,n+1){
		cin>>t[i];
		cin>>x[i];
		cin>>y[i];
	}
	t[0]=0;
	x[0]=0;
	y[0]=0;	
	rep(0,i,n){
		if((abs(x[i+1]-x[i])+abs(y[i+1]-y[i]))<=t[i+1]-t[i]&&(t[i+1]-t[i]-(abs(x[i+1]-x[i])+abs(y[i+1]-y[i])))%2==0){
		}			
		else{
			c("No")
			return 0;
		}	
	}
	c("Yes")
}		
		

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

int main(){
  int a,b,c,k; cin>>a>>b>>c>>k;
  int count = 0;
  while(a>=b){
    b *= 2;
    count++;
    if (count > k){
      cout << "No";
      return 0;
    }
  }
  while(b>=c){
    c *= 2;
    count++;
    if (count > k){
      cout << "No";
      return 0;
    }
  }
  if (count <= k) cout << "Yes";
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;
int main()
{
	int n;
	int a[100010];
	int b[100010]={};
	cin >> n;
	rep(i, n)
	{
		cin >> a[i];
		b[a[i]]++;
	}
	ll ans;
	int m;
	int muri=0;
	if(n%2==0)
	{
		m=n/2;
		for(int i=1; i<=m; i++)
		{
			if(b[2*i-1]!=2)
			{
				muri=1;
			}
		}
	}
	else
	{
		m=n/2;
		if(b[0]!=1)
		{
			muri=1;
		}
		for(int i=1; i<=m; i++)
		{
			if(b[2*i]!=2)
			{
				muri=1;
			}
		}
	}
	if(muri==1)
	{
		cout << '0' << endl;
	}
	else
	{
		ans=1;
		rep(i, m)
		{
			ans*=2;
			ans=ans%MOD;
		}
		cout << ans << endl;
	}
	return 0;
}

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

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

string s;

int main(){
    cin >> s;
    int tmp = 0, sz = s.size(), i = 0;
    while(i < sz){
        tmp += s[i]-'0';
        i++;
    }
    if(tmp%9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define MAXN 200100
#define pii pair<int, int>
#define pb push_back
typedef long long ll;

using namespace std;

ll a[MAXN], h[MAXN], n, ans = 0;
ll lo[4 * MAXN + 1], hi[4 * MAXN + 1], tree[4 * MAXN + 1], delta[4 * MAXN + 1];

void init(int i, int l, int r){
	lo[i] = l;
	hi[i] = r;
	if(l == r) return;
	int m = (l + r) / 2;
	init(2 * i, l, m);
	init(2 * i + 1, m + 1, r);
}

void prop(int i){
	delta[2 * i] += delta[i];
	delta[2 * i + 1] += delta[i];
	delta[i] = 0;
}

void update(int i){
	tree[i] = max(tree[2 * i] + delta[2 * i], tree[2 * i + 1] + delta[2 * i + 1]);
}

void inc(int i, int l, int r, ll val){
	if(r < lo[i] || hi[i] < l) return;
	if(hi[i] <= r && lo[i] >= l){
		delta[i] += val;
		return;
	}
	//partial cover case
	prop(i);
	inc(2 * i, l, r, val);
	inc(2 * i + 1, l, r, val);
	update(i);
}

ll query(int i, int l, int r){
	if(r < lo[i] || hi[i] < l) return 0;	//not in range
	if(hi[i] <= r && lo[i] >= l) return tree[i] + delta[i];	//completely in range
	prop(i);
	ll maxLeft = query(2 * i, l, r);
	ll maxRight = query(2 * i + 1, l, r);
	update(i);
	return max(maxLeft, maxRight);
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin >> n;
    init(1, 0, n);
    for(int i = 0; i < n; i++){
    	cin >> h[i];
    }
    for(int i = 0; i < n; i++){
    	cin >> a[i];
    	inc(1, h[i], h[i], a[i] + query(1, 0, h[i]));
    	ans = max(ans, query(1, 0, h[i]));
    }
    cout << ans;
}

Measured memory_bytes: 26368
n  = int(input())
arr = [int(i) for i in input().split()]
arr.sort()

total = 0

for i in range(n-2):
    aI = arr[i]
    k = i + 2
    
    for j in range(i+1,n):
        mySum = aI+arr[j]

        while (k<n) and arr[k]<mySum:
            k+=1
            
        if k>j:
            total+= k-j-1

print(total)



Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N; cin >> N;
    vector<LL> A(N);
    REP(i,N)
    {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());

    LL ans;
    LL edge1=-1,edge2=-1;
    int p = 0;

    while(p < SZ(A)-1)
    {
        if(A[p] == A[p+1])
        {
            if(edge1 == -1)
            {
                edge1 = A[p];
                p += 2;
            }
            else if(edge2 == -1)
            {
                edge2 = A[p];
                p += 2;
            }
            else
            {
                p += 2;
            }
        }
        else
        {
            p += 1;
        }
    }
    ans = edge1 * edge2;
    if(edge1 != -1 && edge2 != -1)
    {
        cout << ans << endl;
    }
    else
    {
        cout << "0" << endl;
    }



}


Measured memory_bytes: 1024
#include <iostream>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<algorithm>

int Ap(){
    int A;
    int P;
    scanf("%d", &A);
    scanf("%d", &P);
    
    printf("%d\n",(3*A+P)/2);
    
    
    return 0;
}

int Dp(){
    int N;
    int M;
    scanf("%d", &N);
    scanf("%d", &M);
    
    int A[N+1+(M+1)*N];
    int B[M+1];
    int C[M+1];
    
    for(int i=1;i<=N;i++){
        scanf("%d", &A[i]);
    }
    
    int num=N;
    for(int i=1;i<=M;i++){
        scanf("%d", &B[i]);
        scanf("%d", &C[i]);
        for(int K=0;K<B[i];K++){
            A[num+1]=C[i];
            num++;
        }
    }
    
    std::sort(A, A+num, std::greater<int>() );
    int sum=0;
    for(int i=1;i<=N;i++){
        sum=sum+A[i];
    }
    
    printf("%d\n",sum);
    
    return 0;
}
int main(){
    Ap();
    return 0;
}




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


using namespace std;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;
typedef long long ll;


ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

int main(){


    ll X, Y;
    cin >> X >> Y;
    if(Y / gcd(X, Y) == 1) cout << -1 << endl;
    else cout << X << endl;
    
    

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const int mod = 1e5;
const int MAX = 1e7;

int main() {
    double r; cin >> r;
    cout << (double)2 * r * 3.1415926535897 << endl;
}

Measured memory_bytes: 3752
#!/usr/bin/env python3
import sys
try:
    from math import gcd
except Exception:
    from fractions import gcd

class UnionFind:
    def __init__(self, n):
        self._parents = list(range(n))
        self._ranks = [0] * n
        self._size = [1] * n

    def root(self, x):
        if self._parents[x] == x:
            return x
        self._parents[x] = self.root(self._parents[x])
        return self._parents[x]

    def size(self, x):
        return self._size[self.root(x)]

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return

        if self._ranks[rx] < self._ranks[ry]:
            self._parents[rx] = ry
            self._size[ry] += self._size[rx]
        else:
            self._parents[ry] = rx
            self._size[rx] += self._size[ry]
            if self._ranks[rx] == self._ranks[ry]:
                self._ranks[rx] += 1



def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    uf = UnionFind(N)
    ret = [N * (N - 1) // 2]
    for a, b in zip(reversed(A), reversed(B)):
        a -= 1
        b -= 1
        sa = uf.size(a)
        sb = uf.size(b)
        cur_ret = ret[-1]
        if uf.root(a) != uf.root(b):
            cur_ret -= sa * sb
        ret.append(cur_ret)
        uf.unite(a, b)
    ret.reverse()
    return '\n'.join([str(x) for x in ret[1:]])


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]" 
    B = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    result = solve(N, M, A, B)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 29028
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N, Q;
    string S;
    cin >> N >> Q >> S;
    vector<ll> v(N, 0);
    ll sum = 0;
    rep(i, N) {
        if (S.substr(i, 2) == "AC") {
            v[i] = sum;
            sum++;
            v[i+1] = sum;
            i++;
        } else {
            v[i] = sum;
        }
    }
    rep(i, Q) {
        ll l, r;
        cin >> l >> r;
        print(v[r-1] - v[l-1]);
    }
    return 0;
}


Measured memory_bytes: 1792
def join_num(arr):
    result = 0
    for i in range(len(arr)):
        result += arr[i] * 10**(7-i)
    return result
    
n = int(input())
x = [0] * n
for i in range(n):
    x[i] = str(input())

for i in range(n):
    d = []
    for c in x[i]:
        d.append(int(c))
    d.sort()
    a = join_num(d)
    d.reverse()
    b = join_num(d)
    print(b-a)

Measured memory_bytes: 7676
def counting_sort(array, maxval):
    m = maxval+100
    count = [0] * (m)
    for a in array:
        count[a] += 1
    i = 0
    for a in range(m):
        for c in range(count[a]):
            array[i] = a
            i += 1
    return array
 
if __name__ == '__main__':
    N = int(input())
    l = list(map(int, input().split()))
    a = 0
    li = counting_sort(l, N)
    for a in range(N-1):
        print(li[a], end=" ") 
    print(li[N-1])

Measured memory_bytes: 220916
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

#include <unistd.h>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

vector<pair<int, int> > G[SIZE];

int ok[SIZE];

int N, T, S, E;
ll w[SIZE];
int counter[SIZE];

bool dfs1(int now, int back = -1) {
  bool res =  now == E;

  for(auto p : G[now]) {
    int to = p.first;
    int idx = p.second;
    if(to == back) continue;

    counter[now]++;
    res |= dfs1(to, now);
    counter[now]++;
  }

  return ok[now] = res;
}

priority_queue<pair<ll,pair<int,int> > > pq_[SIZE];
bool visited[SIZE];

pair<bool,bool> dfs2(int now, int back = -1) {
  auto &pq = pq_[now];
  bool res = true;

  visited[now] = true;

  for(auto p : G[now]) {
    int to = p.first;
    int idx = p.second;

    w[idx] -= T;

    if(to == back) continue;

    ll cost = w[idx];
    cost -= (ll)(counter[to] - 1) * T;
    cost += LLINF * ok[to];

    pq.push({-cost, {idx, to}});

  }

  while(pq.size()) {
    auto p = pq.top();
    pq.pop();

    int to = p.second.second;
    int idx = p.second.first;

    if (w[idx] <= 0) return {false, true};
    auto tmp = dfs2(to, now);
    if (tmp.second) return tmp;
    if (w[idx] <= 0) return {false, true};
    debug(idx);
    debug(w[idx]);

    res &= tmp.first;

    for(auto q : G[now]) {
      int idx = q.second;
      w[idx] -= T;
    }
  }

  return {res, now == E};
}


int main(){
  scanf("%d%d%d%d", &N, &T, &S, &E);
  S--; E--;

  for(int i=0; i<N-1; i++) {
    int a, b;
    scanf("%d%d%lld", &a, &b, w+i);
    a--; b--;

    if (a == S || b == S) {
      w[i] += T;
    }

    G[a].push_back({b, i});
    G[b].push_back({a, i});
  }

  dfs1(S);

  auto res = dfs2(S);

  if(res.first) {
    puts("Yes");

    for(int i=0; i<N; i++) assert(visited[i]);

  } else {
    puts("No");
  }

  return 0;
}



Measured memory_bytes: 22276
m, d = map(int, input().split())
if m < 4 or d < 22:
  print("0")
else:
  res=0
  for i in range(22, d+1):
    d1, d2 = int(i/10), i%10
    if d2 < 2:
      continue
    res += 1 if d1*d2<=m else 0
  print(res)

Measured memory_bytes: 3064