akhauriyash/Code-Regression huggingface dataset:
//
//  Unhappy Hacking (ABC Edit).cpp
//  Practice
//
//  Created by Hajime Sakamoto on 2019/12/18.
//  Copyright © 2019 Hajime Sakamoto. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <iterator>

using namespace std;

class Editor
{
public:
    string s;
    vector<char> data;
    string s_outPut;
    
    //sから受けとったkey入力を，実際に出力する文字列に編集する
    void keyEdit(){
        data.clear();
        
        for (int i = 0; i<s.size(); i++) {
            if (s[i] == 'B'){
                
                if(data.size() != 0){
                    data.pop_back();
                }
            
            }
            else {
                data.push_back(s[i]);
            }
        }
    };
    
    //char型を持つvector変数dataを結合する
    void keyJoin(){
        std::ostringstream os;
        std::copy(data.begin(), data.end(), std::ostream_iterator<char>(os));//型をvectorの要素と揃える
        s_outPut  = os.str(); // 文字列結合
    }
    
    void keyOutPut(){
        cout << s_outPut;
    }
};

int main(){
    Editor Prc;
    cin >>Prc.s;
    
    Prc.keyEdit();
    Prc.keyJoin();
    Prc.keyOutPut();
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int cal(vector<bool> v)
{
	vi a;
	REP(i, v.size())
	{
		if (v[i]) a.push_back(i);
	}
	int res = 100;
	REP(i, a.size())REP(j, a.size())
	{
		if (a[i] == a[j]) continue;
		chmin(res, abs(a[i] - a[j]));
		chmin(res, abs(24 + a[i] - a[j]));
		chmin(res, abs(a[i] - a[j] - 24));
		chmin(res, abs(24 + a[j] - a[i]));
	}
	return res;
}
int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; cin >> n;
	vi v(13);
	v[0]++;
	REP(i, n)
	{
		int a; cin >> a;
		if (a == 0)
		{
			cout << 0 << endl;
			return 0;
		}
		v[a]++;
	}
	vector<bool> a(24);
	a[0] = true;
	vi w;
	FOR(i, 1, 13)
	{
		if (v[i] >= 3)
		{
			cout << 0 << endl;
			return 0;
		}
		else if (v[i] == 2)
		{
			a[i] = true;
			a[24 - i] = true;
		}
		else if (v[i] == 1)
		{
			w.push_back(i);
		}
	}
	int m = w.size();
	int ans = 0;
	REP(i, 1 << m)
	{
		vector<bool> b = a;
		REP(j, m)
		{
			if ((i >> j) & 1) b[w[j]] = true;
			else b[24 - w[j]] = true;
		}
		chmax(ans, cal(b));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin
from math import sqrt, ceil

s_in = lambda: stdin.readline()[:-1] # s = s_in()
d_in = lambda: int(stdin.readline()) # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split())) # List = ds_in()

N, M = ds_in()

def factorize(n):
    fct = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            fct.append(i)
            fct.append(n//i)
    fct.sort()
    return fct

cand = factorize(M)
for c in cand[::-1]:
    if M//c >= N:
        print(c)
        exit()


Measured memory_bytes: 3188
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.*;
public class Main {
	ArrayList<Edge>[] graph;
	int V,E;
	private class Edge implements Comparable<Edge>{
		int to,cost;
		public Edge(int to,int cost){
			this.to =  to;
			this.cost = cost;
		}
		
		public int compareTo(Edge e){
			return this.cost - e.cost;
		}
	}
	
	@SuppressWarnings("unchecked")
    public void solve() {
		V = nextInt();
		E = nextInt();
		graph = new ArrayList[V];
		for(int i = 0;i < V;i++){
			graph[i] = new ArrayList<Edge>();
		}
		for(int i = 0;i < E;i++){
			int s = nextInt();
			int t = nextInt();
			int w = nextInt();
			
			graph[s].add(new Edge(t,w));
			graph[t].add(new Edge(s,w));
		}
		
		int num = 1;
		int sum = 0;
		boolean[] used = new boolean[V];
		used[0] = true;
		PriorityQueue<Edge> pq = new PriorityQueue<Edge>();
		for(Edge e : graph[0]){
			pq.add(e);
		}
		while(pq.size() > 0){
			Edge e = pq.poll();
			if(used[e.to])continue;
			used[e.to] = true;
			num++;
			sum += e.cost;
			if(num == V)break;
			for(Edge next : graph[e.to]){
				if(used[next.to])continue;
				pq.add(next);
			}
		}
		
		out.println(sum);
    }
 
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}
		/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

int main() {
    int n; cin >> n;
    int tmp = n/7;

    if(n%7==0 || n%4==0){
        cout << "Yes" << endl;
        return 0;
    }

    int res = n;
    for(int i=1; i<=tmp; i++){
        res = n-7*i;
        if(res%4==0){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) 
{
    long sum=0;
    int m, n, i, min, max;
    scanf("%d\n", &n);
    for(i=0; i<n; i++){
        scanf("%d", &m);
        sum += m;
        if(i == 0){
            min=m;
            max=m;
        }
         
        if(min>m){
            min=m;
        }
        if(max<m){
            max=m;
        }
    }
    printf("%d %d %ld\n", min, max, sum);
}

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

int main() {
	int H[10010], W[10010];
	int n = 0;

	while (1) {
		cin >> H[n] >> W[n];
		if (!H[n] && !W[n]) break;
		++n;
	}

	for (int i = 0; i < n; ++i) {
		for (int h = 0; h < H[i]; ++h) {
			for (int w = 0; w < W[i]; ++w) {
				if (!(h % 2)) {
					if (!(w % 2)) cout << "#";
					else cout << ".";
				}
				else {
					if (!(w % 2)) cout << ".";
					else cout << "#";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3088
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 info = new HashSet<string>();

			for (int i = 0; i < N; i++) {
				var inputString = retreiveStringArray()[0];

				if (!info.Contains(inputString)) {
					info.Add(inputString);
				}

			}

			//答えの出力
			var ans = info.Count();
			Console.WriteLine(ans);

		}

		/// <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: 51272
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

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

  vector<int> P(M), Y(M);
  vector<vector<int>> a(N, vector<int>());
  for (int i = 0; i < M; ++i) {
    cin >> P[i] >> Y[i];
    a[P[i]-1].push_back(Y[i]);
  }

  for (int i = 0; i < N; ++i) {
    sort(ALL(a[i]));
  }

  for (int i = 0; i < M; ++i) {
    int rank = lower_bound(ALL(a[P[i]-1]), Y[i]) - a[P[i]-1].begin() + 1;
    printf("%06d%06d\n", P[i], rank);
  }
}

Measured memory_bytes: 7808
#include <iostream>
#include <vector>

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

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

  for (int i = 1; i <= 9; ++i) {
    for (int j = 1; j <= 9; ++j) {
      if (i * j == N){
        cout << "Yes" << endl;
        return 0;
      } 
    }
  }

  cout << "No" << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <utility>
#include <vector>
#include <tuple>
#include <cmath>

using namespace std;

int main() {
  int N;

  #ifdef DEBUG
  freopen("5-08.txt", "r", stdin);
  #endif

  while (cin >> N) {
    vector<tuple<int,int,int> > points;

    while (N--) {
      int t, x, y;
      cin >> t >> x >> y;
      points.push_back(make_tuple(t, x, y));
    }

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

    int prevx = 0, prevy = 0;
    int curx, cury, prevt = 0;
    bool flag = true;

    for (vector<tuple<int,int,int> >::iterator it = points.begin();
         it != points.end(); it++) {
      int t = get<0>(*it);
      curx = get<1>(*it);
      cury = get<2>(*it);

      int delt = t - prevt;

      int a = abs(curx - prevx) + abs(cury - prevy);
      if (a > delt || (abs(a - delt) & 1)) {
        flag = false;
        break;
      }

      prevx = curx;
      prevy = cury;
      prevt = t;
    }

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

  return 0;
}


Measured memory_bytes: 1912
#include<bits/stdc++.h>
using namespace std;
 long long dp[100005][3];
 long long func(int a[][3],int n,int i,int k)
 {
     int j=0;
     long long x[3],c=0;
     if(i==n)
        return 0;
     while(j<3)
     {
         if(j==k)
         {
            j++;
            continue;
         }
         if(dp[i][j]!=-1)
         {
             x[c++]=dp[i][j];
         }
         else
         {
             dp[i][j]=a[i][j]+func(a,n,i+1,j);
             x[c++]=dp[i][j];
         }
         j++;
     }
     if(i!=0)
     return max(x[0],x[1]);
     else
     return max(max(x[0],x[1]),x[2]);
 }
 int main()
 {
   int i,j,n;
   cin>>n;
   int a[n][3];
   memset(dp,-1,sizeof(dp));
   for(i=0;i<n;i++)
   {
       for(j=0;j<3;j++)
       {
           cin>>a[i][j];
       }
   }
    cout<<func(a,n,0,-1);
    return 0;
 }


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	int n;string s;cin>>n>>s;
	vector<pair<char,int>>v;
	rep(i,s.size()){
		if(v.empty()||v.back().first!=s[i])v.push_back({s[i],1});
		else v.back().second++;
	}
	cout<<v.size()<<endl;
}

Measured memory_bytes: 1528
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long K = sc.nextLong();
		if(N>K) N = N%K;
		long answer = Math.min(N, K-N);
		System.out.println(answer);
	}

}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
const int N=300+5;
int a[N][N];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
			scanf("%d",a[i]+j);
	long long ans=0;
	for(int i=1;i<=n;++i)
		for(int j=1,k;j<=n;++j){
			k=n;
			while(k&&(k==i||k==j||a[i][k]+a[k][j]>=a[i][j]))--k;
			if(k)
			{
				puts("-1");
				return 0;
			}
			k=n;
			while(k&&(k==i||k==j||a[i][k]+a[k][j]!=a[i][j]))--k;
			if(k==0)ans+=a[i][j];
		}
	printf("%lld\n",ans>>1);
}

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

using namespace std;

#define sz(vec) ( (int)(vec).size() )
using LL = long long;

int n, m, nStraw;
vector<vector<char> > s;
vector<vector<int> > ans;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n >> m >> nStraw;

    s.assign(n, vector<char>(m) );
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) cin >> s[i][j];
    }

    int cur = 1;
    ans.assign(n, vector<int>(m, {} ) );
    for (int i = 0; i < n; ++i) {
        if (any_of(s[i].begin(), s[i].end(), [&](char c) { return c == '#'; }) ) {
            for (int j = 0; j < m; ++j) {
                ans[i][j] = cur;
                if (s[i][j] == '#') ++cur;
            }
            for (int j = m - 1; ; --j) {
                if (s[i][j] == '#') break ;
                ans[i][j] = cur - 1;
            }
        }
    }

    for (int i = 1; i < n; ++i) {
        for (int j = 0; j < m; ++j) if (!ans[i][j]) ans[i][j] = ans[i - 1][j];
    }
    for (int i = n - 2; i >= 0; --i) {
        for (int j = 0; j < m; ++j) if (!ans[i][j]) ans[i][j] = ans[i + 1][j];
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) cout << ans[i][j] << ' ';
        cout << '\n';
    }

    return 0;
}


Measured memory_bytes: 1280
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
#define MAX_N 5005
struct data{
  int l,r;
  bool operator < (const data &p)const{ 
    return ( l == p.l ? r > p.r : l < p.l );
  }
};

int N,M,ans;
vector<data> T[MAX_N];

void calc(vector<data> &a,vector<data> &b){
  vector<data> tmp;
  sort(a.begin(),a.end());
  
  a.push_back((data){MAX_N,MAX_N-1});
  for(int i=1;i<(int)a.size();i++){
    if(a[i].r<=a[i-1].r)a[i]=a[i-1];
    else tmp.push_back(a[i-1]);
  }
  
  for(int i=1;i<(int)a.size();i++){
    if(a[i].l<=a[i-1].r+1){
      a[i].l=a[i-1].l;
      a[i].r=max(a[i].r,a[i-1].r);
    }else ans+=(a[i-1].r-a[i-1].l+1);
  }

  for(int i=0;i<(int)tmp.size();i++){
    tmp[i].r--;
    if(tmp[i].r<tmp[i].l)continue;
    b.push_back(tmp[i]);
  }
}

int main(){
  int a,b,c;
  scanf("%d%d",&N,&M);
  for(int i=0;i<M;i++){
    scanf("%d%d%d",&a,&b,&c);
    T[a+c].push_back((data){b,b+c});
  }
  ans=0;
  for(int i=N;i>=1;i--)calc(T[i],T[i-1]);
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 17488
def main():
    s = list(input())

    while "B" in s:
        b = s.index("B")
        if b != 0:
            s.pop(b-1)
            s.pop(b-1)
        else:
            s.pop(b)

    print("".join(s))


if __name__ == "__main__":
        main()


Measured memory_bytes: 2940
#pragma GCC optimize("Ofast")

//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
  // 高速化
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);


    ll K;
    cin >> K;

    cout << K * 2 *  M_PI  << "\n"; 

    return 0;



}


Measured memory_bytes: 3800
k = int(input())
if k % 2 == 0:
    print(-1)
else:
    val = 0
    for i in range(10**6+1):
        val = (val * 10 + 7) % k
        if val % k == 0:
            print(i+1)
            break
        elif i == 10**6:
            print(-1)

Measured memory_bytes: 63192
//============================================================================
// Name        : Hello5.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

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

int main() {
int x;
cin>>x;
int n=x/500;
int l=x%500;
int m=l/5;
int ans=n*1000+m*5;
cout<<ans<<endl;
	  return 0;
	}



Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    float xa,ya,xb,yb,xc,yc,xd,yd;
    double a1,a2;
    double s,l,t,u;
    while(scanf("%f",&xa) != EOF){
        scanf("%f%f%f%f%f%f%f",&ya,&xb,&yb,&xc,&yc,&xd,&yd);
        if(xa == xb && yd == yc){
            printf("YES\n");
            continue;
        }
        if(xd == xc && yb == ya){
            printf("YES\n");
            continue;
        }
        if(xb == xa || xd == xc){
            printf("NO\n");
            continue;
        }
        s = xb - xa;
        l = yb - ya;
        t = xd - xc;
        u = yd - yc;
         
        /*a1 = (double)((yb -ya) / (xb - xa));
        a2 = (double)((yd -yc) / (xd - xc));*/
        if(l * u == -1 * s * t){
            printf("YES\n");
        }
        else{
            printf("NO\n");
        }
    }
    return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <cstring>
#include <queue>
#include <cmath>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define rev(v) (v).rbegin(), (v).rend()
#define MP make_pair
using namespace std;

typedef vector<int> vi;
typedef pair<int, int> P;
typedef long long ll;

int main(){
	//freopen("test.txt", "r", stdin);

	cout.setf(ios::fixed);
	cout.precision(8);

	int n, m, k;
	while(cin >> n >> m >> k, n|m|k){
		int size = n*m+1;
		vector<vi> v(2, vi(size, 0));
		v[0][0] = 1;
		int next = 1;
		rep(j, n){
			v[next] = vi(size, 0);
			for(int k = j; k <= j*m; k++){
				if(v[!next][k] == 0)continue;
				for(int i = 1; i <= m; i++){
					v[next][k+i] += v[!next][k];
				}
			}
			next = !next;
		}

		double ans = 0;
		double d = pow((double)m, n);

		for(int i = n; i < size; i++){
//			printf("%d/%d*%d+", v[!next][i], (int)d, max(i-k, 1));
			ans += v[!next][i]*(max(i-k, 1))/d;
		}

		cout << ans << endl;

	}

	return 0;
}

Measured memory_bytes: 1404
#include <bits/stdc++.h>
using namespace std;
int n,k,h[100005],dp[100005];
int solve(int idx){
    if(idx > n - 1)
        return 1e9;
    if(idx == n - 1)
        return 0;
    int &ans = dp[idx];
    if(ans != -1)
        return ans;
    ans = 1e9;
    for(int i = 1; i <= k; i++)
        ans = min(ans, abs(h[idx] - h[idx + i]) + solve(idx + i));
    return ans;
}
int main()
{
    ios::sync_with_stdio(0);
    memset(dp , -1 ,sizeof dp);
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> h[i];
    cout << solve(0) << endl;
}


Measured memory_bytes: 5888
/**
*    author:  Dooloper
*    created: 17.09.2020 23:59:18
**/

#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
using P = pair<int,int>;
using ll = long long;

#define rep(i,n) for(int i = 0; i < (n); i++)
#define repn(i,n) for(int i = 1; i <= (n); i++)
#define pb push_back
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

const double PI = acos(-1);
const int mod = 1000000007;
class mint {
   long long x;
public:
   mint(long long x=0) : x((x%mod+mod)%mod) {}
   mint operator-() const {
     return mint(-x);
   }
   mint& operator+=(const mint& a) {
       if ((x += a.x) >= mod) x -= mod;
       return *this;
   }
   mint& operator-=(const mint& a) {
       if ((x += mod-a.x) >= mod) x -= mod;
       return *this;
   }
   mint& operator*=(const  mint& a) {
       (x *= a.x) %= mod;
       return *this;
   }
   mint operator+(const mint& a) const {
       mint res(*this);
       return res+=a;
   }
   mint operator-(const mint& a) const {
       mint res(*this);
       return res-=a;
   }
   mint operator*(const mint& a) const {
       mint res(*this);
       return res*=a;
   }
   mint pow(ll t) const {
       if (!t) return 1;
       mint a = pow(t>>1);
       a *= a;
       return a;
   }
   // for prime mod
   mint inv() const {
       return pow(mod-2);
   }
   mint& operator/=(const mint& a) {
       return (*this) *= a.inv();
   }
   mint operator/(const mint& a) const {
       mint res(*this);
       return res/=a;
   }

   friend ostream& operator<<(ostream& os, const mint& m){
       os << m.x;
       return os;
   }
};
#pragma endregion

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  cin >> s;
  ll ans = 1e9;
  vector<ll> rn(n+1,0);
  vector<ll> wn(n+1,0);
  if(s[0]=='R') rn[0]++;
  else wn[0]++;
  for(int i = 1; i < n; i++){
    if(s[i] == 'R') rn[i] = rn[i-1]+1,wn[i]=wn[i-1];
    else wn[i] = wn[i-1]+1,rn[i]=rn[i-1];
  }
  ans = rn[n-1];
  rep(i,n){
    ans = min(ans,max(wn[i],rn[n-1] - rn[i]));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6756
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
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++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



int main(void) {
  int n;
  cin >> n;
  int ans = 0;
  rep(i,n+1){
  	int cnt = 0;
      int m = i;
  	while(m>=1){
    	m/=10;
    	cnt++;
  	}
    if(cnt%2==1) ans++;
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
	int k, s;
	int ans = 0;
	
	cin >> k >> s;
	
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j <= k; j++) {
			if (s - (i + j) >= 0 && s - (i + j) <= k) ans++;
		}
	}
	
	cout << ans << endl;
	
	return (0);
}

Measured memory_bytes: 256
/*
--> WHEN IT'S OBVIOUS THAT THE GOAL CANNOT BE REACHED,
	DON'T ADJUST THE GOALS,
	ADJUST THE ACTION STEPS.

--> THE WAY YOU CONQUER SELF-DOUBT IS BY DOING THINGS THAT MAKE YOU UNCOMFORTABLE.

--> IT IS DURING OUR DARKEST MOMENTS WE MUST FOCUS TO SEE LIGHT.
*/

#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <climits>
using namespace std;
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sortAll(x) sort(all(x))
#define sz(x) (int)x.size()
#define clr(x) memset(x, 0, sizeof(x))
#define PI 3.1415926535897932384626
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); IO();
typedef long long ll;
typedef pair< int, int >	pii;
typedef pair< ll, ll >		pl;
typedef vector< int >		vi;
typedef vector< ll >		vl;
typedef vector< pii >		vpii;
typedef vector< pl >		vpl;
typedef vector< vi >		vvi;
typedef vector< vl >		vvl;

const int MOD = 1e9 + 7;

ll power(ll a, ll b)
{
	ll ans = 1;

	while (b > 0)
	{
		if (b & 1)
			ans *= a;
		a = a * a;
		b >>= 1;
	}
	return ans;
}

ll powm(ll a, ll b)
{
	a %= MOD;
	ll ans = 1;

	while (b > 0)
	{
		if (b & 1)
			ans = (ans * a) % MOD;
		a = (a * a) % MOD;
		b >>= 1;
	}
	return ans;
}

void IO()
{
	#ifndef ONLINE_JUDGE
		freopen("Input.txt", "r", stdin);
		freopen("Output.txt", "w", stdout);
	#endif
}

//================================

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

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

		A.insert(s);
	}

	cout << sz(A) << "\n";
	return 0;
}

Measured memory_bytes: 19180
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()

from collections import defaultdict
def resolve():
    n,W=map(int,input().split())
    WV=[tuple(map(int,input().split())) for _ in range(n)]

    weight=set()
    for i in range(n+1):
        for j in range(3*i+1):
            if(WV[0][0]*i+j>W): continue
            weight.add(WV[0][0]*i+j)
    weight=sorted(weight)

    dp=defaultdict(int)
    for i in range(n):
        ndp=defaultdict(int)
        w,v=WV[i]
        for key in weight:
            ndp[key]=max(ndp[key],dp[key])
            if(key+w<=W): ndp[key+w]=max(ndp[key+w],dp[key]+v)
        dp=ndp

    ans=0
    for key in weight:
        ans=max(ans,dp[key])
    print(ans)
resolve()

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

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	int count = 0;
	int sum = 0;
	for(int i=1; i<=n; i++){
		int temp = i;
		int sumTemp = 0;
		while(temp!=0){
			sumTemp += temp % 10;
			temp /= 10;
		}
		if(a <= sumTemp && sumTemp <= b){
			sum += i;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;


int main(){
  ll m;
  cin >> m;
  ll k=0, d=0;
  
  rep(i,m){
    ll a,b; cin >> a >> b;
    k += b;
    d += a*b;
  }
  
  ll ans = (d-1)/9 + k-1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h> 
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int a[200001];
int main()
{
    int i,j,k,l,n,m,t;
    l=0;
    memset(a,0,sizeof(a));
    scanf("%d%d",&n,&k);
    t=n;
    while(t--)
    {
    	scanf("%d",&m);
    	a[m]++;
    }
    sort(a,a+200001);
	j=1;
    for(i=200000;j<=k;i--)
    {
    	l=l+a[i];
		j++;	
    }
    printf("%d\n",n-l);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define rep0(i, b, s) for(int i=b;i<s;i++)
typedef long long ll;
int nums[50];


int main(){
    int N; cin >> N;
    rep(i, N) {
        int num; cin >> num;
        nums[i]=num;
    }

    int ch = 0;
    rep(i, N){
        if (nums[i] != i+1) ch++;
    }

    if (ch<=2) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return sorted 約数s 1 <= x <= n
vector<ll> divv(ll n) {
  vector<ll> v;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.push_back(i);
      if(i*i != n) v.push_back(n/i);
    }
  }
  sort(ALL(v));
  return v;
}

bool chk(string &s, ll a,ll b){
    fr(i,a - 1, b - 1){
        auto j = i +1;
        if(s[i] == '#' && s[j]== '#') {
            return false;
        }
    }
    return true;
}

int main() {
    string s;
    cin>>s;
    ll l = 0, r = s.size() -1;
    ll sa = 0;
    ll sum = 0;
    rep(i,s.size()){
        if(s[i] == 'A') sa++;
        else if(s[i]=='B' && i+1 < s.size() && s[i+1] == 'C' ) {
            sum += sa;
            i++;
        } else {
            sa  = 0;
        }
    }
    pr(sum);
    
    return 0;
}


Measured memory_bytes: 888
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
ans = 0
for i in range(N):
    l, r = MAP()
    ans = ans + (r - l + 1)
print(ans)


Measured memory_bytes: 27236
#include<stdio.h>
int main(void)
{
    int h1,h2,k1,k2,a,b,c,d,n,m;
	scanf("%d %d %d %d %d %d %d %d",&h1,&h2,&k1,&k2,&a,&b,&c,&d);
	n=h1*a+h2*b+c*(h1/10)+d*(h2/20);
	m=k1*a+k2*b+c*(k1/10)+d*(k2/20);
	if(n>m) printf("hiroshi\n");
	else if(n<m) printf("kenjiro\n");
	else if(n==m) printf("even\n");
	return 0;
}

Measured memory_bytes: 2616
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <limits>//setprecision
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#include <numeric> //accumulate,,,
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
long long MOD = 1000000007;
typedef pair<long long,long long> P;

void chmax(long long &a,long long b){if(a < b) a = b;}
void chmin(long long &a,long long b){if(a > b) a = b;}

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a; else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

//fac[]はn! inv[]はMODにおける逆元 finv[]はinv[]とfinv[]の累積積
const long long MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算(nCkをO(1)で)
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    COMinit();
    long long N;cin >> N;
    vector<int> retu(N+1);
    vector<bool> duplicate(N+1);
    int dupli = -1;
    for(int i = 0;i<N+1;i++){
        cin >> retu.at(i);
        if(duplicate.at(retu.at(i))){
            dupli = retu.at(i);
        }
        duplicate.at(retu.at(i)) = true;
    }
    long long left = -1,right = -1;
    for(long long i = 0;i<N+1;i++){
        if(retu.at(i) == dupli && left == -1) left = i;
        else if(retu.at(i) == dupli && left != -1) right = i;
    }
    right = N-right;
    for(long long i = 1;i<=N+1;i++){
        long long ans = COM(N+1,i);
        ans %= MOD;
        ans -= COM(left+right,i-1);
        ans %= MOD;
        if(ans < 0) ans += MOD;
        cout << ans << endl;
    }
}


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

int main() {
    int N;
    cin >> N;
    vector<double> u(N);
    for (int i=0;i<N;i++) cin>>u.at(i);
    sort(u.begin(), u.end());
    
    for (int i=0;i<N-1;i++) u.at(i+1)=((u.at(i)+u.at(i+1))/2);
    cout << setprecision(1000) << u.at(N-1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
P ps[200005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  REP(i, n) {
    int a, b;
    cin >> a >> b;
    ps[i] = P(b, a);
  }

  sort(ps, ps + n);

  ll now = 0;
  bool f = true;
  REP(i, n) {
    int a = ps[i].second;
    int b = ps[i].first;
    now += a;
    if(now > b) {
      f = false;
      break;
    }
  }

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


Measured memory_bytes: 1792
##初期値設定##
N, Q = map(int, input().split())
S = input()
dl=[]
dr=[]
for i in range(Q):
    line = list(map(int, input().split()))
    dl.append(line[0])
    dr.append(line[1])

##ACの個数配列計算##
a=[]
for i in range(N-1):
    tmp_S = S[i:i+2]
    if tmp_S == "AC":
        a.append(1)
    else:
        a.append(0)

##累積和計算##
s = [0]
for i in range(len(a)):
    s.append(s[i]+a[i])

##解答算出##
ans=[]
for l, r in zip(dl, dr):
    ans.append(s[r-1]-s[l-1])

for i in range(Q):
    print(ans[i])

Measured memory_bytes: 25412
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
	int H,W,i,j;
	string str;
	cin>>H>>W;
	vector<string> grid;
	vector<bool> hflag,wflag;
	for(i=0;i<H;i++){
		cin>>str;
		grid.push_back(str);
	}
	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			if(grid.at(i).at(j)=='#'){
				break;
			}
		}
		if(j==W){
			//cout<<"a";
			hflag.push_back(0);
		}else{
			//cout<<"b";
			hflag.push_back(1);
		}
	}
	for(i=0;i<W;i++){
		for(j=0;j<H;j++){
			if(grid.at(j).at(i)=='#'){
				break;
			}
		}
		if(j==H){
			//cout<<"c";
			wflag.push_back(0);
		}else{
			//cout<<"d";
			wflag.push_back(1);
		}
	}
	for(i=0;i<H;i++){
		if(hflag.at(i)){
			for(j=0;j<W;j++){
				if(wflag.at(j)){
					cout<<grid.at(i).at(j);
				}
			}
			cout<<endl;
		}
	}
}


Measured memory_bytes: 256
#表計算を行うプログラムを作成。

r,c=gets.split(" ").map(&:to_i)
h = Array.new(r+1).map{Array.new(c+1,0)} 

for i in 1..r                                       # 変数 i を1からrまで増やして繰り返し処理する。
    
a= gets.split.map(&:to_i)
    for j in 0..c-1                                   # 変数 i を1からcまで増やして繰り返し処理する。
    h[i-1][j] = a[j]
    h[i-1][c] += a[j]
    h[r][j] += a[j]
    h[r][c] += a[j]
    end
end
for i in 0..r
    for j in 0..c
      print " " unless j == 0
      print h[i][j]
    end
    print "\n"
  end




Measured memory_bytes: 8896
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a * b;
        int length = (a + b) * 2;
        System.out.println(area + " " + length);
        sc.close();
    }
}


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

int main(){
  int a,b; cin>>a>>b;
  int A,B,C,D,c,d;
  int sum=0;  
  for(int i=a;i<=b;i++){
    A=i%10; B=i/10000; C=(i%100-A)/10; D=(i-B*10000)/1000;
    if(A==B && C==D){
    sum++;
   }
  }
  cout<<sum<<endl;
  return 0;
}

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

int main() {
  string S;
  long long K;
  cin >> S >> K;

  rep(i, S.length()) {
    if (S[i] == '1' && K-1 == i) {
      cout << 1 << endl;
      return 0;
    } else if (S[i] != '1') {
      cout << S[i] << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
import sys
import collections

N=int(sys.stdin.readline().rstrip())
VList=list(map(int,sys.stdin.readline().split()))

evenList=[]
oddList=[]
for i in range(0, N-1, 2):
  evenList.append(VList[i])
  oddList.append(VList[i+1])
  
c1=collections.Counter(evenList)
c2=collections.Counter(oddList)

values1, counts1 = zip(*c1.most_common())
values2, counts2 = zip(*c2.most_common())

if len(c1)==1 and len(c2)==1:
  if values1[0] == values2[0]:
    print(len(oddList))
    exit()
  else:
    print(0)
    exit()    

ans=0
if values1[0] != values2[0]:
  ans = len(evenList)-counts1[0]
  ans += len(oddList)-counts2[0]
else:
  ansTmp1 = len(evenList)-counts1[1]
  ansTmp1 += len(oddList)-counts2[0]
  ansTmp2 = len(evenList)-counts1[0]
  ansTmp2 += len(oddList)-counts2[1]  
  ans = min(ansTmp1, ansTmp2)
  
print(ans)
  

Measured memory_bytes: 75152
// atcoder/abc154/A/mani.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }
template<typename P, typename Q> inline pair<Q, P> reverse(pair<P, Q> p) { return make_pair(p.second, p.first); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string s, t, u;
  int a, b;
  while (cin >> s >> t >> a >> b >> u) {
    cout << a - (s == u) << ' ' << b - (t == u) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;



int main() {
	int n, m, l, r, maxl = 0, minr = 100000;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> l >> r;
		maxl = max(maxl, l);
		minr = min(minr, r);
	}
	if (maxl > minr) {
		cout << 0 << endl;
	}
	else {
		cout << minr - maxl + 1 << endl;
	}


	return 0;
}

Measured memory_bytes: 256
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

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

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

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)

int main()
{

  ll x, a;
  cin >> x >> a;

  if (x < a)
  {
    cout << 0 << endl;
  }
  else
  {
    cout << 10 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    x,y = readInt()
    for i in range(x+1):
        if i*2+(x-i)*4==y:
            print("Yes")
            return
    print("No")
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
 
int gcd(int x,int y){
    if(y==0)return x;

    return gcd(y,x%y);
}
int lcm(int x,int y){
    return x*y/gcd(x,y);
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){

    long long X,Y,ans=1;
    cin>>X>>Y;

    while(1){
        if(2*X<=Y){
            ans++;
            X*=2;
        }else{
            break;
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,sum=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
      if(i%3!=0&&i%5!=0)
      sum=sum+i;
    }
    cout<<sum<<"\n";
}


Measured memory_bytes: 3640
#include <iostream>

using namespace std;
typedef long long LL;

int main(){
  LL N,P; cin >> N >> P;
  if(N == 1) return cout << P << endl, 0;
  LL ans = 1;
  for(LL i = 2 ; ; ++i){
    LL k = 1;
    for(LL t = 0 ; t < N  && k <= P ; ++t){
      k *= i;
    }
    if(P%k==0) ans = i;
    if(P < k) break;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

ans = 0
# 000 ～　999 がsから作成できるか確認していく
for i in range(1000):
    p = str(i).zfill(3)

    s_index_100 = s.find(p[2])
    if s_index_100 == -1:
        continue

    s_index_10 = s.find(p[1], s_index_100+1)
    if s_index_10 == -1:
        continue

    s_index_1 = s.find(p[0], s_index_10+1)
    if s_index_1 == -1:
        continue
    ans += 1

print(ans)


Measured memory_bytes: 3060