akhauriyash/Code-Regression huggingface dataset:
x1,y1,x2,y2 = input().split(" ")
x1 = float(x1)
x2 = float(x2)
y1 = float(y1)
y2 = float(y2)

d =((x2 - x1)**2 +(y2 - y1)**2)**(0.5)
print("{:8}".format(d))


Measured memory_bytes: 5628
#include <iostream>

using namespace std;

int main() {
	int b, r, g, c, s, t;
	while (cin >> b >> r >> g >> c >> s >> t) {
		if (b == 0 && r == 0 && g == 0 && c == 0 && s == 0 && t == 0) break;
		int point = 100;
		point += b * 15;
		point += (b*5) * 16;
		point += r * 15;
		point += (r*3) * 16;
		point += g * 7;
		point += c * 2;
		point += s * 3;
		point -= t * 3;

		cout << point << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import fractions
a,b,c,d = map(int,input().split())
e = c*d//fractions.gcd(c,d)
cnt = b-a+1
c_cnt = b//c-(a-1)//c
d_cnt = b//d-(a-1)//d
e_cnt = b//e-(a-1)//e
print(cnt-c_cnt-d_cnt+e_cnt)

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  map<char,int> m;

  rep(i,n){
    m[s[i]]++;
  }
  ll ans = 1;
  for(auto x : m){
    ans *= x.second+1;
    ans %= ll(1e9 + 7);
  }
  cout << ans-1 << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;

string change1(string s){
  map<char, string> p;
  p[' '] = "101";
  p['\''] = "000000";
  p[','] = "000011";
  p['-'] = "10010001";
  p['.'] = "010001";
  p['?'] = "000001";
  p['A'] = "100101";
  p['B'] = "10011010";
  p['C'] = "0101";
  p['D'] = "0001";
  p['E'] = "110";
  p['F'] = "01001";
  p['G'] = "10011011";
  p['H'] = "010000";
  p['I'] = "0111";
  p['J'] = "10011000";
  p['K'] = "0110";
  p['L'] = "00100";
  p['M'] = "10011001";
  p['N'] = "10011110";
  p['O'] = "00101";
  p['P'] = "111";
  p['Q'] = "10011111";
  p['R'] = "1000";
  p['S'] = "00110";
  p['T'] = "00111";
  p['U'] = "10011100";
  p['V'] = "10011101";
  p['W'] = "000010";
  p['X'] = "10010010";
  p['Y'] = "10010011";
  p['Z'] = "10010000";
  string res = "";
  for(int i = 0 ; i < s.size() ; i++) res += p[s[i]];
  while(res.size() % 5 != 0) res += '0';
  return res;
}

string change2(string s){
  map<string, char> p;
  p["00000"] = 'A';
  p["00001"] = 'B';
  p["00010"] = 'C';
  p["00011"] = 'D';
  p["00100"] = 'E';
  p["00101"] = 'F';
  p["00110"] = 'G';
  p["00111"] = 'H';
  p["01000"] = 'I';
  p["01001"] = 'J';
  p["01010"] = 'K';
  p["01011"] = 'L';
  p["01100"] = 'M';
  p["01101"] = 'N';
  p["01110"] = 'O';
  p["01111"] = 'P';
  p["10000"] = 'Q';
  p["10001"] = 'R';
  p["10010"] = 'S';
  p["10011"] = 'T';
  p["10100"] = 'U';
  p["10101"] = 'V';
  p["10110"] = 'W';
  p["10111"] = 'X';
  p["11000"] = 'Y';
  p["11001"] = 'Z';
  p["11010"] = ' ';
  p["11011"] = '.';
  p["11100"] = ',';
  p["11101"] = '-';
  p["11110"] = '\'';
  p["11111"] = '?';
  
  string res = "";
  for(int i = 0 ; i < s.size() ; i+=5) res += p[s.substr(i, 5)];
  return res;
}

int main(){
  string s;
  while(getline(cin, s)){
    s = change1(s);
    s = change2(s);
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <iostream>

int main() {
	std::uint16_t A, B;
	std::cin >> A >> B;

	if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
		std::cout << "Possible" << std::endl;
	} else {
		std::cout << "Impossible" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <string>

using namespace std;

#define PI 3.14159265359

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

	
	float result = (float)N * 2.0 * PI;

	cout << result << endl;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> v(N);
    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }
    int ans = 0;
    for (int i = 0; i <= N; i++) {
        for (int j = i + 1; j <= N; j++) {
            int num = i + (N - j);
            if (num > K) continue;
            int cnt = K;
            priority_queue<int, vector<int>, greater<int>> que;
            for (int r = 0; r < i; r++) {
                que.push(v[r]);
                cnt--;
            }
            for (int l = j; l < N; l++) {
                que.push(v[l]);
                cnt--;
            }
            int sum = 0;
            for (int k = 0; k < cnt; k++) {
                if (!que.empty() && que.top() < 0) {
                    que.pop();
                }
            }
            while (!que.empty()) {
                sum += que.top();
                que.pop();
            }
            ans = max(sum, ans);
        }
    }
    if (K >= N) {
        int sum = accumulate(v.begin(), v.end(), 0);
        sort(v.begin(), v.end());
        for (int i = 0; i < K - N && i < N; i++) {
            if (v[i] < 0) sum += abs(v[i]);
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
string s;


void solve(){
    int count = 0;
    if(s[0]!='C')count++;
    if(s[1]!='O')count++;
    if(s[2]!='D')count++;
    if(s[3]!='E')count++;
    if(s[4]!='F')count++;
    if(s[5]!='E')count++;
    if(s[6]!='S')count++;
    if(s[7]!='T')count++;
    if(s[8]!='I')count++;
    if(s[9]!='V')count++;
    if(s[10]!='A')count++;
    if(s[11]!='L')count++;
    if(s[12]!='2')count++;
    if(s[13]!='0')count++;
    if(s[14]!='1')count++;
    if(s[15]!='6')count++;
    cout << count <<endl;

}

int main() {
    cin >> s;
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
 
public class Main {
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    
    int a[ ] = new int[x]; 
    
    for(int i=0; i<x; i++){
      a[i] =  sc.nextInt();
    }
    
    int min = Integer.MAX_VALUE;
    
    for(int j = -100; j <=100; j++) {
      
      int sum  = 0;

      for(int k=0; k<x; k++){
        sum = sum + (int)Math.pow(a[k]-j, 2);
      }
      
      if(sum<min){
        min = sum;
      }
    }
    
    System.out.println(min);
  }
}

Measured memory_bytes: 36048
#include "bits/stdc++.h"
using namespace std;
#define ll long long int

int main(){
	int t;
	char g;
	string a="";
	scanf("%d", &t);
	scanf("%c", &g);
	a += g;
	for(int i=0; i<2; i++) {
		for(int ii=0; ii<5; ii++) scanf("%c", &g);
		a += g;
	}
	cout << a << "\n";
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
    ll a,b,n;
    cin>>a>>b>>n;
    if(n>=b-1){
        cout<<(a*(b-1))/b-a*((b-1)/b)<<endl;
    }
    else{
        cout<<(a*n)/b-a*(n/b)<<endl;
    }
}



Measured memory_bytes: 3596
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using P = pair<ll, ll>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1<<30;
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; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> const&P){
    os << P.first;
    os << " ";
    os << P.second;
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
    os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
//fixed<<setprecision(10)<<ans<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,A;
    cin >> N >> A;
    vi X(N);
    REP(i,N) cin>>X[i];

    int max_val = 50*50*2;
    vector<vector<vector<ll>>> DP(N+1,vector<vector<ll>>(max_val+1,vector<ll>(N+1,0)));
    DP[0][0][0]=1;
    REP(i,N+1){
        REP(v,max_val+1){
            REP(k,N+1){
                if(i==0)continue;
                DP[i][v][k] = DP[i-1][v][k];
                if(v>=X[i-1] && k){
                    DP[i][v][k] += DP[i-1][v-X[i-1]][k-1];
                }
            }
        }
    }
    ll ans=0;
    REP(k,N+1){
        int val = A*k;
        ans += DP[N][val][k];
    }
    cout << ans-1 << endl; //DP[N][0][0]のぶん
}

Measured memory_bytes: 112000
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def load_input():
    n = int(input())
    h = list(map(int, input().split()))
    return n, h


def main():
    n, h = load_input()

    output = 0
    max_height = 0
    for i in range(n):
        if max_height <= h[i]:
            output += 1
            max_height = h[i]
    print(output)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

class Main {

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

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            List<String> input = Arrays.asList(br.readLine().split(" "));
            List<Integer> airportToAiport = new ArrayList<>();

            for (String s : input) {
                airportToAiport.add(Integer.parseInt(s));
            }

            sortNatualOrder(airportToAiport);

            int firstMin = airportToAiport.get(0);
            int secondMin = airportToAiport.get(1);

            System.out.println(firstMin + secondMin);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }

    private static void sortNatualOrder(List<Integer> intList) {
        for (int i = 0; i < intList.size() - 1; i++) {
            for (int j = intList.size() - 1; j > i; j--) {
                if (intList.get(j -1) > intList.get(j)) {
                    int tmp = intList.get(j - 1);
                    intList.set(j - 1, intList.get(j));
                    intList.set(j, tmp);
                }
            }
        }
    }
}

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

int main() {
    long long int n, m, x, ans = 1000000000;
    cin >> n >> m >> x;
    int c[n], a[n][m];
    for(int i = 0; i < n; ++i) {
        cin >> c[i];
        for(int j = 0; j < m; ++j) cin >> a[i][j];
    }

    for (int bit = 0; bit < (1<<n); ++bit){
        long long int sum = 0;
        int rikai[m] = {0};
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // i が bit に入るかどうか
                sum += c[i];
                for(int j = 0; j < m; ++j) rikai[j] += a[i][j];
            }
        }

        bool flag = true;
        for(int i = 0; i < m; ++i) {
            if(rikai[i] < x) {
                flag = false;
                break;
            } 
        }
        if(flag) ans = min(sum, ans);

    }
    if(ans == 1000000000) cout << -1 << '\n';
    else cout << ans << '\n';

    return 0;
}


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

using namespace std;

#define ll long long

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	ll sum = 0;
	for (int i = 0; i < m; i++) {
		int x;
		scanf("%d", &x);
		sum += x;
	}
	if (sum > n)
		puts("-1");
	else
		printf("%lld\n", n - sum);

	return 0;
}

Measured memory_bytes: 3816
N, M = map(int, input().split())
H = list(map(int, input().split()))
CHECK = [1]*N
for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] > H[B-1]:
        CHECK[B-1] = 0
    elif H[B-1] > H[A-1]:
        CHECK[A-1] = 0
    else:
        CHECK[A-1] = 0
        CHECK[B-1] = 0
print(sum(CHECK))


Measured memory_bytes: 19972
//package cf;

import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException {
        Scanner io = new Scanner(System.in);
        int x = io.nextInt(), y = io.nextInt(), z = io.nextInt();
        System.out.println(z + " " + x + " " + y);
    }
}




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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

// 約数列挙
vector<ll> divisor(ll N) {
    vector<ll> res;
    for (ll i = 1L; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            ll j = N / i;
            if (j != i)  {
                res.push_back(j);
            }
        }
    }
    sort(res.begin(), res.end());
    return res;
}

void Main() {
    ll N, R;
    cin >> N >> R;
    if (N >= 10){
        cout << R << endl;
    } else {
        cout << R + 100 * (10 - N) << endl;
    }
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define db long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define EB emplace_back
#define fi first
#define se second
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
 
#define inf 1e18
#define sqr(x) ((x)*(x))
using namespace std;
map<int,int> mp[200005];
int h,w,n;
int main(){
	scanf("%d%d%d",&h,&w,&n);
	for (int i=1;i<=n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		mp[x][y]=1;
	}
	int ans=h,ed=0;
	for (int r=1;r<=h;r++){
		bool flag=0;
		for (auto i:mp[r])
			if (i.fi<=ed){
				flag=1;
				break;
			}
		if (flag){
			ans=r-1;
			break;
		}
		if (!mp[r][ed+1])
			ed++;
	}
	printf("%d\n",ans);
}
//f[i][0]=

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

void insertionSort(vector<int> A, int N);
void outputResult(vector<int> A);
//-----------------------------------------------
//???????????¢??°
int main(){
	
	int n;
	cin>> n;
	vector<int> vlist;
	vlist.resize(n);
	//??\???
	for(int i = 0; i<vlist.size(); i++){
		cin >> vlist[i];
	}
	outputResult(vlist);
	//?????????
	insertionSort(vlist, n);
	return 0;
}
//-----------------------------------------------
void insertionSort(vector<int> A, int N){
	for(int i=1; i<N ; i++){
		int v = A[i];
		int j= i-1;
		while((j>=0) && (A[j]>v)){
			A[j+1] = A[j];
			j--;
		}
		A[j+1]=v;
		//??????
		outputResult(A);
	}
}
//-----------------------------------------------
void outputResult(vector<int> A){
	for(int i = 0; i<A.size(); i++){
		cout << A[i];
		if((A.size()-i-1)){
			cout << " ";
		}
	}
	cout << endl;
}
//-----------------------------------------------

Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define pb emplace_back
#define ll long long
#define mp make_pair
#define PI acos(-1)
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll i,j,k,x,y,z,m,t,n,b,c,d,a,l,r;
    cin>>n;
    vector<ll>v(n);
    for(i=0; i<n; i++)
        cin>>v[i];
    sort(v.begin(),v.end());
    ll ans=INT_MAX,cnt;
    for(i=v[0]; i<=v[n-1]; i++)
    {
        cnt=0;
        for(j=0; j<n; j++)
        {
            x=abs(i-v[j]);
            x=x*x;
            cnt+=x;
        }
        ans=min(cnt,ans);
    }
    cout<<ans<<'\n';
}














Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main (void)
{
    int a, b, c, x, ans = 0;

    cin >> a >> b >> c >> x;

    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                if (500 * i + 100 * j + 50 * k == x) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  int A, B, M;
  cin>>A>>B>>M;
  int a[A], b[B];
  for (int i=0; i<A; i++) cin>>a[i];
  for (int i=0; i<B; i++) cin>>b[i];
  int min_a = 1e5 + 1;
  int min_b = 1e5 + 1;
  for (int i=0; i<A; i++) min_a = min(a[i], min_a);
  for (int i=0; i<B; i++) min_b = min(b[i], min_b);
  int ans = min_a + min_b;
  for (int _=0; _<M; _++) {
    int x, y, c;
    cin>>x>>y>>c;
    --x;
    --y;
    ans = min(a[x] + b[y] - c, ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int a,s[11],d,f,g,h,i,j;
	char k[101];
	scanf("%d",&a);
	while(a!=0){
		scanf("%s",k);
		g=0;
		for(i=0;i<a;i++){
			s[i]=0;
		}
		for(i=0;i<100;i++){
			h=i%a-1;
			if(h==-1){
				h=a-1;
			}
			s[h]++;
			if(k[i]=='S'){
				g+=s[h];
				s[h]=0;
			}
			if(k[i]=='L'){
				s[h]+=g;
				g=0;
				//printf(" %d = %d ",h,s[h]);
			}
			//printf("%c",k[i]);
		}
		for(i=0;i<a;i++){
			for(j=i;j<a;j++){
				if(s[j]<=s[i]){
					f=s[j];
					s[j]=s[i];
					s[i]=f;
				}
			}
		}
		for(i=0;i<a;i++){
			printf("%d ",s[i]);
		}
		printf("%d\n",g);
		scanf("%d",&a);
	}
	return 0;
}

Measured memory_bytes: 1032
import java.util.HashMap;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		HashMap<Character, Integer> cnt = new HashMap<Character, Integer>();
		char[] march = {'M', 'A', 'R', 'C', 'H'};
		for(char c : march) cnt.put(c, 0);
		int N = sc.nextInt();
		for(int i = 0; i < N; i++) {
			String S = sc.next();
			char st = S.charAt(0);
			boolean exist = false;
			for(char c : march) exist |= (st == c);
			if(exist) cnt.put(st, cnt.get(st) + 1);
		}
		long ans = 0;
		int comb = (1 << 3) - 1;
		while(comb < (1 << 5)){
			boolean make = true;
			for(int i = 0; i < 5; i++) {
				if(((comb >> i) & 1) == 1) make &= (cnt.get(march[i]) > 0);
			}
			if(!make) {
				int x = (comb & -comb), y = comb + x;
				comb = ((comb & ~y) / x >> 1) | y;
				continue;
			}

			long tmp = 1;
			for(int i = 0; i < 5; i++) {
				if(((comb >> i) & 1) == 1) {
					tmp *= (long)cnt.get(march[i]);
				}
			}
			ans += tmp;

			int x = (comb & -comb), y = comb + x;
			comb = ((comb & ~y) / x >> 1) | y;
		}
		System.out.println(ans);
	}
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int A, B;
  cin >> A >> B;
  if(B == 1) {
    cout << 0 << endl;
  } else if(B <= A) {
    cout << 1 << endl;
  } else {
    cout << 1 + ((B-A)/(A-1) + ((B-A) % (A-1) == 0 ? 0 : 1)) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct node
{
  int key;
  int parent;
  int left;
  int right;
}node;
int main()
{
  int i, n;
  node *N;
  scanf("%d",&n);
  N = malloc(sizeof(struct node)*(n+1));
  for(i = 1; i <= n; i++)
    scanf("%d",&N[i].key);
  for(i = 1; i <= n; i++)
  {
    N[i].parent = N[i/2].key;
    N[i].left = N[2*i].key;
    N[i].right = N[2*i+1].key;
  }
 
  for(i = 1; i <= n; i++)
  {
     printf("node %d: key = %d, ",i, N[i].key);
   if(i != 1) printf("parent key = %d, ",N[i].parent);
   if(2*i <= n)  printf("left key = %d, ",N[i].left);
   if(2*i+1 <= n) printf("right key = %d, ", N[i].right);
   printf("\n");
  }
 free(N);
 return 0;
}

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

int main() {
	int a,b,h,m;
	cin >> a >> b >> h >> m;
	double p = 3.141592653589793,
	     st = (30 * h - 5.5 * m) * p / 180.0;
	double k = a * a + b * b;
	double kk = 2 * a * b * cos(st);
	double rr = sqrt(k - kk);
	cout << fixed << setprecision(15) << rr << endl;
	return 0;
}


Measured memory_bytes: 4192
#include <stdio.h>

int min(int a, int b){
  if(a < b){
    return a;
  }else{
    return b;
  }
}

int main(){
  int n;
  scanf("%d", &n);
  int a[n], b[n - 1];
  for(int i = 0; i < n - 1; i++){
    scanf("%d", &b[i]);
  }
  a[0] = b[0];
  a[n - 1] = b[n - 2];
  for(int i = 1; i < n - 1; i++){
    a[i] = min(b[i - 1], b[i]);
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    ans += a[i];
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
int main(){
  int a,c=0,d=0,min,s,x,i;
  int *b;
  scanf("%d",&a);
  b=(int *)malloc(sizeof(int) * a);
  for(i=0;i<a;i++){
    scanf("%d",&b[i]);
  }
  while(c<a-1){
    min=b[c];
    for(i=c;i<a;i++){
      if(min>b[i]){min=b[i];s=i;}
    }
      if(min<b[c]){x=b[c];b[c]=b[s];b[s]=x;d++;}
  c++;
  }
  for(i=0;i<a;i++){
  printf("%d",b[i]);
  if(i!=a-1)printf(" ");
  }
  printf("\n");
  printf("%d\n",d);
  return 0;
}



Measured memory_bytes: 2736
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        k: usize
    }
    if k % 2 == 1 {
        println!("{}", (k/2) * ((k+1)/2));
    } else {
        println!("{}", k * k / 4);
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a;

    cout << a*a;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define N 1000000
ll dp[N];
string s;
ll n;
int main()
{
	cin>>s;
	n=s.length();
	dp[0]=1;
	for(int i=1;i<=200000;++i) {
		dp[i]=dp[i-1]*10%2019;
	}
	
	int t=0;
	vector<int> cnt(2019);
	ll ans=0;
	cnt[0]++;
	for(int i=n-1;i>=0;i--) {
		t+=dp[n-1-i]*(s[i]-'0');
		t%=2019;
		ans+=cnt[t];
		cnt[t]++;
	}
	cout<<ans<<"\n";
	return 0;
}

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

using namespace std;

#define rep(i, a, b)	for (int i(a); i <= (b); ++i)
#define dec(i, a, b)	for (int i(a); i >= (b); --i)
#define MP		make_pair
#define fi		first
#define se		second


typedef long long LL;

const int N = 1e3 + 5;

int a[N], b[N];
int n, m, c, fg;
char s[45];


int main(){

	scanf("%d", &n);
	c = 0;

	rep(i, 1, n){
		scanf("%d%d", a + i, b + i);
		if ((a[i] + b[i]) & 1) ++c;
		else --c;
	}

	if (abs(c) != n) return 0 * puts("-1");

	m = 31 + (c < 0);

	printf("%d\n", m);
	rep(i, 0, 30) printf("%d ", 1 << i);
	if (c < 0) putchar(49);
	putchar(10);

	rep(i, 1, n){
		int x = a[i], y = b[i];
		if (c < 0) s[31] = 'R', --x;
		fg = 0;
		dec(j, 30, 0){
			if (abs(x) < abs(y)) swap(x, y), fg ^= 1;
			if (x > 0) x -= 1 << j, s[j] = fg ? 'U' : 'R';
			else x += 1 << j, s[j] = fg ? 'D' : 'L';
		}

		puts(s);
	}

	return 0;
}




Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#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;
// util {{{
#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(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

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;
}
// }}}

// init {{{
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;
// }}}

//--------------------------------------------------------------------

signed main() {
    int n; string s;
    cin>>n>>s;
    if(n%2 != 0){
        cout<<"No"<<endl;
        return 0;
    }
    bool flg = true;
    REP(i,n/2){
        if(s.at(i) != s.at(i+n/2)){
            flg = false;
            break;

        }
    }
    if(flg){
        cout<<"Yes"<<endl;

    } else{ cout<<"No"<<endl; }

    // cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main() {
 
  char str[1050] = {0};
  char ch[1050] = {0};
  char mei[30] = {0};
  char pl[1050]={0};
  int i,j,k,l,m,n,o,p;
 
  
  scanf("%s",str);
  scanf("%d",&n);
    
  for(i=0; i<7 ;i++) {
    ch[i] = str[i];
  }
 
  j=0;
  o=0;
  k=l=0;
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", mei);
    scanf("%d %d", &k, &l);
    // printf("mei= %s",mei);
   
     
    if(mei[2] =='p') {
      
      scanf("%s", pl);
 
      for(m=0;m<l-k+1;m++) {
 
    //  printf("str[%d]%c = pl[%d]%c\n",m+k,str[m+k] ,m,pl[m]);
    str[m+k] = pl[m];   
      }
    }
 
    else if(mei[2] == 'v') {
       
      for(m=0; m<strlen(str);m++) {
    ch[m] = str[m];
      }
       
      for(m=0;m<l-k+1;m++) {
    //  printf("str[%d]%c = ch[%d]%c\n",k+m,str[k+m],l-m,ch[l-m]);
    str[k+m] = ch[l-m];
      }
     
    }
 
    else if(mei[0] = 'p') {   
       
      for(m=k; m<=l;m++) {
    printf("%c" ,str[m]);
      }
      printf("\n");
    }
     
  }
 
    
  return 0;
 
}

Measured memory_bytes: 576
import collections
s=int(input())
count=1
ans=s
prev=0
counter = collections.defaultdict(int)
counter[ans]=1
while(1):
  count+=1
  if ans % 2 == 0:
    ans = ans / 2
  else:
    ans = 3*ans+1
    
  if ans not in counter.keys():
    counter[ans]=count
  else:
    print(count)
    break

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

const int INF=1<<30;

vector<int> dx={1, 0, -1, 0}, dy={0, 1, 0, -1};

int main(){
    int H, W; cin >> H >> W;
    vector<vector<char>> s(H, vector<char>(W));
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> s[i][j];
        }
    }
    int res=0;
    vector<int> cnt(H*W, 0);
    vector<vector<int>> dist(H, vector<int>(W, -1));
    dist[0][0]=0;
    queue<pair<int, int>> que;
    que.push(make_pair(0, 0));
    while(!que.empty()){
        int x, y;
        tie(x, y)=que.front();
        que.pop();
        for(int i=0; i<4; i++){
            int nx=x+dx[i];
            int ny=y+dy[i];
            if(nx<0 || nx>=H || ny<0 || ny>=W) continue;
            if(dist[nx][ny] != -1) continue;
            if(s[nx][ny] == '#') continue;
            dist[nx][ny]=dist[x][y]+1;
            cnt[dist[nx][ny]]++;
            que.push(make_pair(nx, ny));
        }
    }
    for(int i=dist[H-1][W-1]+1; i<H*W; i++){
        if(cnt[i] > 0) cnt[i]++;
    }
    for(int i=1; i<cnt.size(); i++){
        while(cnt[i] > 1){
            res++;
            cnt[i]--;
        }
    }
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(s[i][j]=='.' && dist[i][j]==-1) res++;
        }
    }
    if(dist[H-1][W-1] == -1) cout << -1 << endl;
    else cout << res << endl; 
    return 0;
}

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

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL)
    ;
	cout.tie(0);
    
    int n,m;
    cin>>n>>m;
    
    long int arr[m],i,sum=0;
    
    for(i=0;i<m;i++) cin>>arr[i];
    
    for(i=0;i<m;i++) sum += arr[i];
    
    if(n<sum) cout<<-1<<endl;
    else{
        cout<<(n-sum)<<endl;
    }
     return 0;
}
    
    

Measured memory_bytes: 3664
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(), (V).end())
#define pb push_back
#define endl '\n'
#define int long long

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

// 変数定義
int n,tmp;
vector<int> a;
//

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  vector<int> ans(n);
  REP(i, n) {
    cin >> tmp;
    ans[tmp-1] = i+1;
  }
  REP(i,n) {
    cout << ans[i];
    if (!(i+1 == n)) {
      cout << " ";
    }
  }
  cout << endl;
}

Measured memory_bytes: 1664
S = list(input())
T = list(input())
L = []
M = []
al = list('abcdefghijklmnopqrstuvwxyz')

for i in range(len(al)):
    l = []
    for j in range(len(S)):
        if al[i] == S[j]:
            l.append(j)
        else:
            pass
    L.append(l)
i = 0
for i in range(len(al)):
    l = []
    for j in range(len(T)):
        if al[i] == T[j]:
            l.append(j)
        else:
            pass
    M.append(l)
if sorted(L)==sorted(M):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 24436
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;

}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x) / log(base));
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll n,i,j,l,m,h,w,c,q,f,k,need,cur,a,b,ans;
    	string s;
    	cin>>s;
    	if(s[2]==s[3] && s[4]==s[5])
    	cout<<"Yes";
    	else
    	cout<<"No";
    	
    	
    	
    	
    	
    	
    	
    	
    	
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#include<ext/rope>
//using namespace __gnu_cxx
//#include<ext/pb_ds/priority_queue.hpp>
//using namespace __gnu_pbds;
#define lowbit(x) (x&-x)
#define pb push_back
#define empb emplace_back
#define all(x) (x).begin(),(x).end()
#define clr(a,b) memset(a,b,sizeof(a))
#define caze(T) for(cin>>T;T;T--)
#define inf (1<<29)
#define Endl ('\n')
#define fi first
#define se second
#define db double
#define ldb long double
#define ll long long
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define ull unsigned long long
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
inline char nc() {
	#define SZ 1000000
	static char buf[SZ], *p1, *p2;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,SZ,stdin),p1==p2)?EOF:*p1++;
}
template<typename T>
inline int scan(T &x) {
	char c, sign=1; 
	while(!isdigit(c=nc())&&c!=EOF)if(c=='-')sign*=-1;
	if(c==EOF) return EOF;
	for(x = 0; isdigit(c); c = nc())
		x = (x<<1) + (x<<3) + (c&15);
	return x *= sign, 1;
}
template<typename T, typename...Args>
inline int scan(T &x, Args&...args) {
	return scan(x), scan(args...);
}
const int N=1<<18;
const int zero=1<<17;
int t[N],a[N],n;
int b[N],cc;
void add(int x,int v){for(;x<N;t[x]+=v,x+=lowbit(x));}
int sum(int x){int ret=0;while(x)ret+=t[x],x-=lowbit(x);return ret;}
int sum(int l,int r){return sum(r)-sum(l-1);}
ll calc(int x)
{
	int y=zero;
	ll ret=0;
	clr(t,0);
	add(zero,1);
	for(int i=1;i<=n;++i)
	{
		y+=(a[i]<=x?1:-1);
		ret+=sum(y-1);
		add(y,1);
	}
	return ret;
} 
int main()
{IOS;
	cin>>n;cc=0;
	for(int i=1;i<=n;++i)
		cin>>a[i],b[++cc]=a[i];
	sort(b+1,b+1+cc);
	cc=unique(b+1,b+1+cc)-b-1;
	int L=1,R=cc,mid;
	ll ans,tp;
	ll ok=1LL*(n+1)*n/4+1;
	while(R>=L)
	{
		mid=(L+R)>>1;
		if((tp=calc(b[mid]))>=ok)
			ans=b[mid],R=mid-1;
		else L=mid+1;
	}
	cout<<ans<<Endl;
}

Measured memory_bytes: 2048
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 
 using namespace std;
 
 double abs(double x)
 {
   if(x<0) return -x;
   else return x;       
 }
  
 int main()
 {
   int n;
   int result;
   cin>>n;
   double xa,ya,ra,xb,yb,rb;
   while(n--)
   {
     cin>>xa>>ya>>ra>>xb>>yb>>rb;
     double dis=sqrt(pow(yb-ya,2)+pow(xb-xa,2));
     if(dis>ra+rb) result=0;
     else if(dis>=abs(ra-rb)) result=1;
     else
     {
       if(dis+ra<rb) result=-2;
       else if(dis+rb<ra) result=2;    
     }
     cout<<result<<endl;        
   }
   //while(1);      
   return 0;    
 }

 

Measured memory_bytes: 3124
n, m, x = map(int, input().split())
refs = [tuple(map(int, input().split())) for _ in range(n)]

min_fee = 1 << 64
for purchases in range(1 << n):
    total_fee = 0
    understands = [0] * m

    for i in range(n):
        if (purchases >> i) & 1:
            total_fee += refs[i][0]
            for j in range(m):
                understands[j] += refs[i][j + 1]

    if all([understand >= x for understand in understands]) and total_fee < min_fee:
        min_fee = total_fee

print(min_fee if min_fee != 1 << 64 else -1)


Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
long long n;
int main()
{
	cin>>n;
	long long k=sqrt(n),tt,ll,ss;
    for(int i=k;i>=1;i--)
    {
        if(n%i==0)
		{
            tt=i;
			ll=n/i;
            ss=1;
            while(ll>=10)
			{
                ss++;
                ll/=10;
            }
			printf("%d\n",ss);
        	return 0;
        }
    }
} 

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <time.h>
#define int long long
#define ll long long
#define us unsigned
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define nin(ary, n) for (int i = 0; i < (n); i++) cin >> ary[i]
#define nnin(ary, h, w) for (int i = 0; i < (h); ++i) for (int j = 0; j < (w); ++j) cin >> ary[i][j]
#define opt(conditions, a, b) cout << ((conditions) ? #a : #b) << endl
using namespace std;
const double PI = acos(-1.0);
const int MOD = 1e9 + 9;

int max_n(int ary[], int length) {
	int max = ary[0];
	for (int i = 1; i < length; i++)
		if (max < ary[i]) max = ary[i];
	return max;
}

int max_o(int ary[], int length) {
	int max;
	max = max_n(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == max) return i;
	}
	return -1;
}

int min_n(int ary[], int length) {
	int min = ary[0];
	for (int i = 1; i < length; i++)
		if (min > ary[i]) min = ary[i];
	return min;
}

int min_o(int ary[], int length) {
	int min;
	min = min_n(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == min) return i;
	}
	return -1;
}

int gcm(int a, int b) {
	int result = a;
	int k = 0;
	int n = b;
	do {
		k = result % n;
		result = n;
		n = k;
	} while (k != 0);
	return result;
}

int gcm_n(int ary[], int length) {
	int g = ary[0];
	for (int i = 0; i < length; i++)
		g = gcm(g, ary[i]);
	return g;
}

int lcm(int a, int b) {
	int g, n;
	g = gcm(a, b);
	n = gcm(a, g);
	a = a / n;
	b = b / (g / n);
	return a*b;
}

int lcm_n(int ary[], int length) {
	int l = ary[0];
	for (int i = 0; i < length; i++)
		l = lcm(l, ary[i]);
	return l;
}






signed main() {
	
	string s;
	cin >> s;
	opt((s[0] == '9' || s[1] == '9'), Yes, No);

	return 0;
}

Measured memory_bytes: 384
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    ll n;
    cin >> n;
    ll res = INF;
    FOR(i, 1, ceil(sqrt(n))) {
        if (n % i == 0) {
            res = min(res, i + (n / i) - 2);
        }
    }
    cout << res << endl;
    return 0;
}

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

int solve( int N,const vector<int> &A){
  int count = 1;
  
  for ( int i =0; i < N; i++){
    if ( A.at(i) == count ){
      count ++;
    }
  }
     
  if ( count == 1 ){
    return -1;
  }else{
    return N-(count - 1);
  }
  
} 

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

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

using namespace std;

#define fr(i, n) for(int i = 0; i < n; i++)
#define frr(i, n) for(int i = 1; i <= n; i++)
#define frm(i, n) for(int i = n-1; i >= 0; i--)

#define pb push_back
#define f first
#define s second

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<double, double> ponto;
typedef vector<vector<ll>> matrix;

#define mem(v, k) memset(v, k, sizeof(v));

#define db cout << "Debug" << endl;

#define mp make_pair
#define pq priority_queue

#define mx(a, b) a = max(a, b);
#define mod(a, b) a = a%b;

#define MAXN 2010
#define MOD 1000000007
#define MAXL 30
#define ROOT 1
#define INF 987654321

int ans[MAXN];
vector<int> adj[MAXN];

int n;

void read(){
	int x, y;
	cin >> n >> x >> y;

	frr(i, n-1){
		adj[i].pb(i+1);
		adj[i+1].pb(i);
	}

	adj[x].pb(y);
	adj[y].pb(x);
}

void bfs(int v){
	queue<pii> q;
	int dist[MAXN];
	frr(i, n) dist[i] = -1;

	q.push(mp(0, v));

	dist[v] = 0;

	while(!q.empty()){
		pii p = q.front();
		q.pop();

		//cout << p.s << endl;

		for(int z: adj[p.s]){
			if(dist[z] == -1){
				q.push(mp(dist[p.s] + 1, z));
				dist[z] = dist[p.s] + 1;
			}
		}
	}


	frr(i, n) ans[dist[i]]++;
}

int main(){
	ios::sync_with_stdio(false);
	read();

	//bfs(1);

	frr(i, n) bfs(i);

	frr(i, n-1) cout << ans[i]/2 << endl;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans=0;
    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            a[i+1]=-1;
            ans++;
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
	in >> P.first >> P.second;
	return in;
}
template<class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P){
	out << "(" << P.first << ", " << P.second << ")";
	return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
template<class T>
istream &operator>>(istream &in, deque<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const deque<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}


int32_t main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	rep(i,0,s.size()){
		s[i] = ((s[i] - 'A') + n)%26 + 'A';
	}
	cout<<s<<endl;
}

Measured memory_bytes: 384
//前置き
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>

using namespace std;

typedef  long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

//関数定義
//最大公約数
ll gcd(ll a, ll b);

//最小公倍数
ll lcm(ll a, ll b);

int main(){
    // ========================================================
    int a, b, c;
    cin >> a >>  b >> c;
    if(a + b + c > 21) cout << "bust" << endl;
    else cout << "win" << endl; 
}

//最大公約数
ll gcd(ll a, ll b) {  
    if (!b)  
        return a;  
    return gcd(b, a%b);  
}

//最小公倍数
ll lcm(ll a, ll b) {  
    return a*b/gcd(a,b);  
} 

Measured memory_bytes: 256
#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;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    string s;cin >>s;
    char key='R';
    vector<ll>cnt;
    ll now=0;
    ll n=s.size();
    for (int i = 0; i < n; ++i) {
        if(key==s[i]){
            now++;
        }
        else {
            if(key=='L'){
                key='R';
            }
            else {
                key='L';
            }
            cnt.push_back(now);
            now=1;
        }
    }
    cnt.push_back(now);
//    for (int i = 0; i < cnt.size(); ++i) {
//        cout <<cnt[i]<<" ";
//    }
//    cout <<endl;
    vector<ll>ans(n,0);
    ll k=0;
    for (int i = 0; i <cnt.size();i+=2) {
        k+=cnt[i]-1;
        ans[k]+=(cnt[i]-1)/2+1;
        ans[k]+=cnt[i+1]/2;
        ans[k+1]+=cnt[i]/2;
        ans[k+1]+=(cnt[i+1]-1)/2+1;
        k+=cnt[i+1]+1;
    }
    for (int i = 0; i < n; ++i) {
        cout <<ans[i]<<" ";
    }
    cout <<endl;
    return 0;
}

Measured memory_bytes: 2292
#include<stdio.h>
int main(void)
{
	int S,h,m,s;
	scanf("%d",&S);
	h=S/3600;
	m=(S-h*3600)/60;
	s=S-(m*60)-(h*3600);
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
from collections import defaultdict, Counter
n = int(input())
v = [int(x) for x in input().split()]

cnt_even = Counter(v[0::2])
cnt_odd = Counter(v[1::2])

# [(要素, 出現回数), (要素, 出現回数), ....]
common_even = cnt_even.most_common()
common_odd = cnt_odd.most_common()
if len(common_even) == 1:   # 1種類の数しかない
    common_even.append((0, 0))
if len(common_odd) == 1:
    common_odd.append((0, 0))

# 偶数番目に一番多く現れる数と奇数番目に一番多く現れる数が異なる
if common_even[0][0] != common_odd[0][0]:
    ans = n - common_even[0][1] - common_odd[0][1]
else:
    ans = min(n - common_even[1][1] - common_odd[0][1], \
              n - common_even[0][1] - common_odd[1][1])

print(ans)

Measured memory_bytes: 21184