akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int INF = 100000000;

ll i,j,k;
int main(){
    ll n,m;cin>>n>>m;
    vector<ll> p(m),y(m);//p:所属する県 y:市の誕生年
    map<pair<ll,ll>,ll> answer;//pair:県と誕生年　ll:同じ県の中での誕生番号

    vector<pair<ll,ll>> yp_set(m),yp_set2(m);
    for(i=0;i<m;i++){
        cin>>p[i]>>y[i];
        yp_set[i]=make_pair(y[i],p[i]);//yとpのset
        yp_set2[i]=make_pair(y[i],p[i]);//yとpのset（順番保持）
        answer[yp_set2[i]]=0;
    }

//////県番号の小さい順　かつ　誕生番号の小さい順に並べる/////////////////////////////////////

    sort(yp_set.begin(),yp_set.end());//y(誕生年)でsort
    
    ll ins;
    for(i=0;i<m;i++){//y p swap
        ins=yp_set[i].first;
        yp_set[i].first=yp_set[i].second;
        yp_set[i].second=ins;
    }
    sort(yp_set.begin(),yp_set.end());

    for(i=0;i<m;i++){//y p swap(元に戻した)　　これで県と誕生番号が適切にsortされた
        ins=yp_set[i].first;
        yp_set[i].first=yp_set[i].second;
        yp_set[i].second=ins;
    }

/////////////////////////////////////////////////////////////////////////////////

    answer[yp_set[0]]=1;//一番最初
    for(i=0;i<m-1;i++){
        if(yp_set[i].second!=yp_set[i+1].second){answer[yp_set[i+1]]=1;}//違う県になったら、はじめは1にする
        else{answer[yp_set[i+1]]=answer[yp_set[i]]+1;}
    }//県内で何番目に誕生したか


    for(i=0;i<m;i++){
        answer[yp_set[i]]+=1000000*yp_set[i].second;
    }//県番号

    for(i=0;i<m;i++){
        printf("%012lld\n",answer[yp_set2[i]]);
    }
    return 0;
}

Measured memory_bytes: 12416
// ███▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓╬╬╬╬╬╬▓█
// ███▓███████▓▓╬╬╬╬╬╬╬╬╬╬╬╬▓███▓▓▓▓█▓╬╬╬▓█
// ███████▓█████▓▓╬╬╬╬╬╬╬╬▓███▓╬╬╬╬╬╬╬▓╬╬▓█
// ████▓▓▓▓╬╬▓█████╬╬╬╬╬╬███▓╬╬╬╬╬╬╬╬╬╬╬╬╬█
// ███▓▓▓▓╬╬╬╬╬╬▓██╬╬╬╬╬╬▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ████▓▓▓╬╬╬╬╬╬╬▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ███▓█▓███████▓▓███▓╬╬╬╬╬╬▓███████▓╬╬╬╬▓█
// ████████████████▓█▓╬╬╬╬╬▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬█
// ███▓▓▓▓▓▓▓╬╬▓▓▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ████▓▓▓╬╬╬╬▓▓▓▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ███▓█▓▓▓▓▓▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// █████▓▓▓▓▓▓▓▓█▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// █████▓▓▓▓▓▓▓██▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// █████▓▓▓▓▓████▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// ████▓█▓▓▓▓██▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// ████▓▓███▓▓▓▓▓▓▓██▓╬╬╬╬╬╬╬╬╬╬╬╬█▓╬▓╬╬▓██
// █████▓███▓▓▓▓▓▓▓▓████▓▓╬╬╬╬╬╬╬█▓╬╬╬╬╬▓██
// █████▓▓█▓███▓▓▓████╬▓█▓▓╬╬╬▓▓█▓╬╬╬╬╬╬███
// ██████▓██▓███████▓╬╬╬▓▓╬▓▓██▓╬╬╬╬╬╬╬▓███
// ███████▓██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬████
// ███████▓▓██▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓████
// ████████▓▓▓█████▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█████
// █████████▓▓▓█▓▓▓▓▓███▓╬╬╬╬╬╬╬╬╬╬╬▓██████
// ██████████▓▓▓█▓▓▓╬▓██╬╬╬╬╬╬╬╬╬╬╬▓███████
// ███████████▓▓█▓▓▓▓███▓╬╬╬╬╬╬╬╬╬▓████████
// ██████████████▓▓▓███▓▓╬╬╬╬╬╬╬╬██████████
// ███████████████▓▓▓██▓▓╬╬╬╬╬╬▓███████████
//#include "grader.h"
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <cassert>
#define For(i, a, b) for (int i = a; i < b; ++i)
#define Out(i, a, b) for (int i = a - 1; i >= b; --i)
#define pb push_back
#define x first
#define y second
#define files(FileName) read(FileName); write(FileName)
#define read(FileName) freopen((FileName + ".in").c_str(), "r", stdin)
#define write(FileName) freopen((FileName + ".out").c_str(), "w", stdout)
using namespace std;
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }

using namespace std;

const string FILENAME = "input";
const int p = 1e9 + 7;

typedef long long base;
typedef pair <base, base> point;

int n, m;
int dp[4001][2];
int d[4001][2];

void sum(int &a, int b) {
	a = (a + b) % p;
}

int main() {
	srand(time(0));
	ios::sync_with_stdio(0);
	//read(FILENAME);
	cin >> n >> m;
	for (int i = 0; i <= n; ++i) {
		bool s = false;
		dp[i][0] = 1;
	}
	for (int t = 0; t < m; ++t) {
		for (int i = 0; i <= n; ++i) {
			for (int s = 0; s < 2; ++s) {
				if (i > 0) sum(d[i - 1][s || (i == 1)], dp[i][s]);
				if (i > 0) sum(d[i][s || (i == 1)], dp[i][s]);
				if (i < n) sum(d[i][s || (i == 0)], dp[i][s]);
				if (i < n) sum(d[i + 1][s || (i == 0)], dp[i][s]);
				dp[i][s] = 0;
			}
			//cout << endl;
		}
		//cout << endl;
		for (int i = 0; i <= n; ++i) {
			for (int s = 0; s < 2; ++s) {
				swap(dp[i][s], d[i][s]);
			}
		}
	}	
	int ans = 0;
	for (int i = 0; i <= n; ++i) {
		sum(ans, dp[i][1]);		
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val N = sc.nextInt
  val d = Array.fill(N)(sc.nextInt)

  val x = d.sorted
  val abc = x(N / 2 - 1)
  val arc = x(N / 2)
  println(arc - abc)
}


Measured memory_bytes: 59888
#include<iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
if(a==b)
cout<<"Draw";
else if(a>b&&b!=1)
cout<<"Alice";
else if(a<b&&a!=1)
cout<<"Bob";
else if(a==1)
cout<<"Alice";
else if(b==1)
cout<<"Bob";
	
	
	
	
	
	
	
	
	
	
	
}

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

int gcd(int x, int y)
{
	if (y == 0) return x;
	return gcd(y, x % y);
}

signed main(void)
{
	int n, cnt;
	cin >> n;
	int a[n];
	bool ok;
	for (int i = 0; i < n; i++) cin >> a[i];
	
	ok = true;
	cnt = 0;
	while (ok)
	{
		for(int i = 0; i < n; i++)
		{
			if (a[i] % 2 == 0)
				a[i] /= 2;
			else
			{
				ok = false;
				break;
			}
		}
		if (ok)
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 100005

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	ll n; cin>>n;
	cout<<(n-1)/2<<'\n';
	
	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
requests = [tuple(map(int, input().split())) for i in range(M)]

requests.sort(key=lambda x: x[1])
count = 0
end = 0
for r in requests:
    if r[0] >= end:
        count += 1
        end = r[1]
        
print(count)

Measured memory_bytes: 18172
#include <iostream>
#include <vector>
#include <boost/range/irange.hpp>
#include <string>
#include <array>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    array<ull, 87> answer{};
    for (auto i: irange((unsigned int) 0, (uint)87)){
        if (i == 0){
            answer.at(i) = 2;
        } else if (i == 1){
            answer.at(i) = 1;
        } else {
            answer.at(i) = answer.at(i-1) + answer.at(i-2);
        }
    }

    uint N;
    cin >> N;
    cout << answer.at(N);
    return 0;

}

Measured memory_bytes: 256
s = input()

if s == "SUN":
    print(str(7))
elif s == "MON":
    print(str(6))
elif s == "TUE":
    print(str(5))
elif s == "WED":
    print(str(4))
elif s == "THU":
    print(str(3))
elif s == "FRI":
    print(str(2))
else:
    print(str(1))

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


int main() {
  int n,ans=0;
  cin >> n;
  rep(i,n){
    ans+=i+1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/**
 * File    : D.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-7-21 21:06:53
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, M;

typedef tuple<int, int> P;

vector<P> V;
int now = -1;
int ans = 0;

int main()
{
  cin >> N >> M;
  for (auto i = 0; i < M; i++)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    V.push_back(P(b, a));
  }
  sort(V.begin(), V.end());
  for (auto x : V)
  {
    int b = get<0>(x);
    int a = get<1>(x);
    if (a <= now && now < b)
    {
      // nothing
    }
    else
    {
      now = b - 1;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1400
/*	Don’t Quit
	
	When things go wrong as they sometimes will;
		When the road you’re trudging seems all uphill;
			When the funds are low, and the debts are high;
				And you want to smile, but you have to sigh;
					When care is pressing you down a bit
						Rest if you must, but don’t you quit.
*/
#pragma gcc optimize ("unroll-loop")
#pragma gcc optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int a[N];
int pre[N];
int32_t main()
{
	IOS;
	int a,b,c;
	cin>>a>>b>>c;
	cout<<min(c,b/a)<<endl;




}

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

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

int main() {
    string s;
    int ans=3;
    cin >> s;
    rep(i,3){
        if(s.at(i) == 'S'){
            ans--;
        }
    }
    if(s == "RSR"){
        ans=1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
using System;

namespace ABC_059_A_C___ver
{
    class Program
    {
        static void Main(string[] args)
        {
            var word = Console.ReadLine().Split(' ');
            string s1 = word[0];
            string s2 = word[1];
            string s3 = word[2];
            string s11 = s1.Substring(0, 1).ToUpper();
            string s22 = s2.Substring(0, 1).ToUpper();
            string s33 = s3.Substring(0, 1).ToUpper();
            Console.WriteLine(s11 + s22 + s33);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main
{

  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;
    String[]       in_str_split;

    int   in_N;
    int   in_D;
    int   in_X;
    int[] in_A;

    int cnt;
    int ans;

    try
    {
      in_stream = new BufferedReader(new InputStreamReader(System.in));

      /*----------------
       * 引数
       *----------------*/
      in_str = new String(in_stream.readLine());
      in_N   = Integer.parseInt(in_str);

      in_str       = new String(in_stream.readLine());
      in_str_split = in_str.split(" ");
      in_D         = Integer.parseInt(in_str_split[0]);
      in_X         = Integer.parseInt(in_str_split[1]);


      in_A = new int[in_N];
      for(cnt=0; cnt<in_N; cnt++)
      {
        in_str    = new String(in_stream.readLine());
        in_A[cnt] = Integer.parseInt(in_str);
      }


      /*----------------
       * 計算
       *----------------*/
      ans = 0;
      for(cnt=0; cnt<in_N; cnt++)
      {
        ans++;
        ans += (in_D - 1) / in_A[cnt];
      }

      ans += in_X;

      System.out.println("" + ans);
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
}


Measured memory_bytes: 25044
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  vi nums;
  int now = 1;
  int cnt = 0;
  rep(i,n) {
    if (s[i] == (char)(now + '0')) cnt++;
    else {
      nums.pb(cnt);
      now = 1 - now; // now ^= 1;
      cnt = 1;
    }
  }
  if (cnt != 0) nums.pb(cnt);
  if (nums.size()%2 == 0) nums.pb(0);

  int add = 2*k +1;
  int ans = 0;
  for (int i = 0; i < nums.size(); i += 2) {
    int tmp = 0;
    
    int left = i;
    int right = min(i+add, (int)nums.size());
    for (int j = left; j < right; ++j) {
      tmp += nums[j];
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second

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

const ll MOD = 998244353;
const ll inv = 499122177;

ll dp[3007][3007];

ll binExp(ll x, ll p){
	ll ans = 1;
	while(p){
		if(p&1)
			ans = ans * x % MOD;
		x = x * x % MOD;
		p>>=1;
	}
	return ans;
}


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

	int n, s; cin >> n >> s;
	vi v(n); FOR(i, n) cin >> v[i];

	memset(dp, 0, sizeof(dp));

	sort(all(v));

	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= s; j++){
			if(j < v[i-1]){
				dp[i][j] = dp[i-1][j];
			}else{
				dp[i][j] = (dp[i-1][j] + dp[i-1][j-v[i-1]] * inv % MOD) % MOD;
			}
			if(j == v[i-1])
				dp[i][j] = (dp[i][j] + binExp(2, n-1)) % MOD;
		}
	}

	cout << dp[n][s] << '\n';

 	return 0;
}

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

using namespace std;
int minPrice( map<int,int> map)
{   int min;
    for(auto it=map.begin();it != map.end();++it )
    {
        if(it==map.begin())
        {
            min =it->second;
        }
       if(it->second < min)
       {
           min =it->second;
       }
    }
    return min;
}
int minPriceKey( map<int,int> map)
{   int min;
    int key;
    for(auto it=map.begin();it != map.end();++it )
    {
        if(it==map.begin())
        {
            min =it->second;
            key =it->first;
        }
       if(it->second < min)
       {
           min =it->second;
           key =it->first;
       }
    }
    return key;
}
int main()
{  map<int,int> fruits;
   int n,k,x,sum =0;
   cin>>n;
   cin>>k;
   for(int i=1 ;i<n+1 ;i++)
   {
       cin>>x;
       fruits[i] = x;
   }
for(int i= 0 ;i<k ;i++)
{
  sum+= minPrice(fruits);
  fruits.erase(minPriceKey(fruits));
}
cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3744
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			double g = scan.nextDouble();
			if(g <= 48.00){
				System.out.println("light fly");
			}else if(g <= 51.00){
				System.out.println("fly");
			}else if(g <= 54.00){
				System.out.println("bantam");
			}else if(g <= 57.00){
				System.out.println("feather");
			}else if(g <= 60.00){
				System.out.println("light");
			}else if(g <= 64.00){
				System.out.println("light welter");
			}else if(g <= 69.00){
				System.out.println("welter");
			}else if(g <= 75.00){
				System.out.println("light middle");
			}else if(g <= 81.00){
				System.out.println("middle");
			}else if(g <= 91.00){
				System.out.println("light heavy");
			}else{
				System.out.println("heavy");
			}
		}
	}
}

Measured memory_bytes: 19288
#include <algorithm>
#include <functional>
#include <iostream>
#include <set>
#include <vector>
using namespace std;

#ifdef _MSC_VER
int debug = 1;
#else
int debug = 0;
#endif

int main() {
    int n;
    cin >> n;
    auto a = vector<int>(n);
    for (auto &a_i : a)
        cin >> a_i;

    auto minset = multiset<int, greater<int>>();

    for (int i = 0; i < n; i++) {
        auto v = a[i];

        if (debug)
            cerr << "current value " << v << ", ";

        auto itr = minset.upper_bound(v);
        if (itr == minset.end()) {
            minset.insert(v);
            if (debug)
                cerr << "new set\n";

        } else {
            if (debug)
                cerr << "append to " << *itr << "\n";
            minset.erase(itr);
            minset.insert(v);
        }
    }

    if (debug) {
        for (auto m : minset)
            cerr << m << ", ";
        cerr << "\n";
    }

    cout << minset.size();
    return 0;
}


Measured memory_bytes: 5376
#include<stdio.h>
struct people
{
	int h;
	int flag;
};
int main()
{
	int n, m,i,sum=0;
	int s,t; //表示正在处理的两个人 
	scanf("%d%d",&n,&m); 
	struct people people[n];
	for (i = 0;i < n;i++)
	{
		scanf("%d",&people[i].h);
		people[i].flag=1;  //是good 
	}
	for(i=0;i<m;i++)
	{
		scanf("%d%d",&s,&t);
		if(people[s-1].h>=people[t-1].h) people[t-1].flag=0;
		if(people[s-1].h<=people[t-1].h) people[s-1].flag=0;
	}
	for(i=0;i<n;i++)
	{
		if(people[i].flag==1) sum++;
	}
	printf("%d",sum);
	return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define PI (acos(-1))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

#define MAXN 1123456
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;

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

  int x;
  cin >> x;

  int p = x/500;
  x -= p*500;
  int q = x/5;
  cout << p*1000 + q*5 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);

	string A,B,C;
	string result;
	cin >> A;
    cin >> B;
    cin >> C;
    result=A.substr(0,1)+B.substr(0,1)+C.substr(0,1);
	transform(result.begin(),result.end(),result.begin(),::toupper);
    cout << result << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int N,D;
	scanf("%d %d",&N,&D);
	int w;
	w = 2 * D + 1;
	int ans,ans_w;
	ans = N / w;
	ans_w = N % w;
	if(ans_w != 0) ans++;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;

struct BIT{
	using D = int;
	int N;
	vector<D> bit;
	BIT(int n){		//nは区間幅!!!
		N=n;
		bit.assign(n+1,0);
	}
	D sum(int i){		//i個の和a[0]+..a[i-1]
		D s=0;
		while(i>0){
			s+=bit[i];
			i-=(i&-i);
		}
		return s;
	}
	void add(int i,D x){	//a[i]+=x (0-indexed)
		i++;
		while(i<=N){
			bit[i]+=x;
			i+=(i&-i);
		}
	}
};


int N;
int dp[2001][2001];
int costi[2001][2001];	//(i,j) -> put i
int costj[2001][2001];	//(i,j) -> put j
int p[2][2000];

void input(){
	cin>>N;
	rep(i,N*2){
		char c;
		int a;
		cin>>c>>a;
		a--;
		p[(c=='B')][a] = i;
	}
}

int main(){
	input();
	rep(i,N+1){
		BIT bit(2*N);
		rep(k,i) bit.add(p[0][k],1);
		rep(j,N+1){
			if(i!=N){
				costi[i][j] = i+j - bit.sum(p[0][i]);
			}
			if(j!=N){
				costj[i][j] = i+j - bit.sum(p[1][j]);
			}
			if(j==N) continue;
			bit.add(p[1][j],1);
		}
	}
	rep(i,N+1) rep(j,N+1){
		int tmp = 1e9;
		if(i==0 && j==0) tmp = 0;
		if(i>0) chmin(tmp,dp[i-1][j]+costi[i-1][j]);
		if(j>0) chmin(tmp,dp[i][j-1]+costj[i][j-1]);
		dp[i][j] = tmp;
	}
	cout<<dp[N][N]<<endl;
}

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

int top,S[1000];

void push(int x){
  S[++top]=x;
}

int pop(){
  top--;
  return S[top+1];
}

int main() {
  int a,b;
  top=0;
  char s[100];
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }
    else if(s[0]=='-'){
      a=pop();
      b=pop();
      push(b-a);
    }
    else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }
    else push(atoi(s));
  }
  printf("%d\n",pop());
  return 0;
}



Measured memory_bytes: 3220
N=list(input())
A=int(''.join(N[0:2]))
B=int(''.join(N[2:4]))

FLG_A = (A>12) | (A==0)
FLG_B = (B>12) | (B==0)


if FLG_A & FLG_B:
    ans='NA'
elif FLG_A & ~FLG_B:
    ans='YYMM'
elif ~FLG_A & FLG_B:
    ans='MMYY'
elif ~FLG_A & ~FLG_B:
    ans='AMBIGUOUS'

print(ans)

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

int main() {
  int a,b;
  cin >> a >> b;
  if(a%2 == b%2){
    cout << (a+b)/2 << endl;
  }
  else{
    cout << (a+b)/2+1 << endl;
  }
}


Measured memory_bytes: 3472
#include <sys/time.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define IT(a,it) for(auto it=a.begin(); it != a.end(); it++)
#define REV_IT(a,it) for(auto it=a.rbegin(); it != a.rend(); it++)
#define LL long long
#define LD long double
#define MP make_pair
#define FF first
#define SS second
#define PB push_back
#define INF (int)(1e9)
#define EPS (double)(1e-9)

#ifndef ONLINE_JUDGE
#  define LOG(x) cerr << #x << " = " << (x) << endl
#else
#  define LOG(x) 0
#endif

#define MAXX 5000005

using namespace std;

typedef pair <int, int> pi_i;
typedef pair<int, pi_i> pi_ii;

bool cmp(int a, int b){ return a>b; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a * (b / gcd(a, b)); }

double getTime(){
   timeval tv; 
   gettimeofday(&tv, 0); 
   return tv.tv_sec + tv.tv_usec * 1e-6;
}

LL n, x, ans;
vector<int> vv;

int main(){
	ios_base::sync_with_stdio(false);
	
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	cin >> n >> x;
	LL a = x, b = n-x;
	if(a < b) swap(a, b);
	ans = n;

	while(1){
		if(a % b == 0){
			ans += 2LL * a - b;	//last traingles last side not included
			break;
		}else{
			ans += (a/b) * b * 2LL;
			LL ta, tb;
			ta = b, tb = a % b;
			a = ta, b = tb;
		}
	}

	cout << ans << endl;
	
	//fclose(stdin);
	//fclose(stdout);
return 0;	
}

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

int n;
double x[100], y[100];

double distance(double p){
	double sum = 0;
	for(int i = 0; i < n; i++){
		double w = abs(x[i] - y[i]);
		sum += pow(w, p);
	}
	return pow(sum, 1.0/p);
}

int main(){
	cout << fixed << setprecision(12);
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> x[i];
	}
	for(int i = 0; i < n; i++){
		cin >> y[i];
	}
	cout << distance(1) << endl;
	cout << distance(2) << endl;
	cout << distance(3) << endl;
	double mx = 0;
	for(int i = 0; i < n; i++){
		mx = max(mx, abs(x[i] - y[i]));
	}
	cout << mx << endl;
	return 0;
}


Measured memory_bytes: 3388
n,k=map(int, input().split())

#11段で1周するのでそこまで計算する
r=[]
for i in range(1,12):
    m=0
    for j in range(1,6):
        t = 0
        for x in range(3):
            for y in range(3):
                t += 7*(i+y) + (j+x) - 7
        if t % 11 == k: m += 1
    r.append(m)

a,b=divmod(n,11)
ans = 0
ans += a*sum(r)
if b < 1: ans -= r[-2]
if b < 2: ans -= r[-1]
if b >= 3:
    for i in range(b-2): ans += r[i]
print(ans)

Measured memory_bytes: 38256
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn = 110;

char str[maxn];

int main()
{
	scanf("%s",str); int len=strlen(str); len-=8;
	for(int i=0;i<len;i++) putchar(str[i]);
	
	return 0;
}


Measured memory_bytes: 256
#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>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pi              pair<int,int>
#define vi              vector<int>
#define mi              map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define MOD             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1N
#define loop(i,a,b)     for(int i=a;i<b;i++)

void FIO(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin) ;
    // freopen("output.txt","w",stdout) ;
    // #endif
}

int32_t main(){
    FIO();
    int a,b ;cin>>a>>b;
    cout<<a*b;

    


}




































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Measured memory_bytes: 3640
#include <iostream>
int main(){
    std::string s;
    std::cin >> s;
    int a = 0;
    long ans = 0;
    for(int i = 0; i < s.length(); i++){

        if(s[i]=='A')a++;
        else if(s[i]=='B' && s[i+1]=='C'){
                ans += a;
                i++;
        }else{
            a = 0;
        }
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }
        static void Solve()
        {
            (long N, long A, long B) = Slice3<long>();
            var Vi = Sarray();
            Array.Sort(Vi);Array.Reverse(Vi);
            var min = Vi[A - 1];
            var sum = 0L;
            var l = -1L;
            for (var i = 0; i < A; ++i)
            {
                sum += Vi[i];
                if (l == -1 && Vi[i] == min)
                    l = i;
            }
            double mean = (double)sum / A;
            WriteLine($"{mean:f6}");
            var cnt = 0L;
            var minNum = Vi.Count(v => v == min);
            if (l == 0)
            {
                for (var i = A; i <= B; ++i)
                    cnt += nCr(minNum, i - l);
            }
            else
                cnt += nCr(minNum, A - l);
            WriteLine(cnt);
        }
        static long nCr(long n, long r)
        {
            if (n < r) return 0;
            BigInteger ret = 1;
            for (var i = 1; i <= n; ++i)
                ret *=  i;
            for (var i = 1; i <= r; ++i)
                ret /= i;
            for (var i = 1; i <= n - r; ++i)
                ret /= i;
            return (long)ret;
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 28556
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=100010;
int n,m,arr[N],diff[N],sum,sum1;
int main()
{
  cin>>n>>m;
  for(int i=0;i<m;i++) cin>>arr[i];
  if(n>=m) cout<<"0\n";
  else
  {
    sort(arr,arr+m);
    for(int i=1;i<m;i++) diff[i]=arr[i]-arr[i-1];
    sort(diff+1,diff+m);
    // for(int i=1;i<m;i++) cout<<diff[i]<<" ";
    // cout<<endl;
    for(int i=1;i<=(m-n);i++) sum1+=diff[i];
    cout<<sum1<<endl;
  }
  return 0;
}


Measured memory_bytes: 1024
while True:
    w, h = map(int, raw_input().split())
    if w | h == 0:
        break
    dp = [[[0] * (w + 1) for _ in xrange(h + 1)] for _ in xrange(4)]    
    dp[0][1][0] = dp[3][0][1] = 1
    for y in xrange(h):
        for x in xrange(w):
            dp[0][y + 1][x] += dp[0][y][x] + dp[2][y][x]
            dp[1][y][x + 1] += dp[0][y][x]
            dp[2][y + 1][x] += dp[3][y][x]
            dp[3][y][x + 1] += dp[1][y][x] + dp[3][y][x]
    print sum(dp[i][h-1][w-1] for i in xrange(4)) % 100000

Measured memory_bytes: 5820
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

using namespace std;
int N;

int main() {
  cin >> N;
  vector<long> sum(N);
  long tmp = 0;
  for (int i=0; i<N; i++) {
    long a;
    cin >> a;
    tmp += a;
    sum.at(i) = tmp;
  }
  long ans = LONG_MAX;
  int posp = 0;
  int posr = 2;
  for (int i=1; i<N-2; i++) {
    long pq = sum.at(i);
    while (posp < i-1) {
      if (abs(pq - sum.at(posp)*2) > abs(pq - sum.at(posp+1)*2)) {
        posp++;
      } else {
        break;
      }
    }
    long p = sum.at(posp);
    long q = pq-p;

    long rs = sum.at(N-1) - sum.at(i);
    while (posr < N-2) {
      long tmp = sum.at(posr) - sum.at(i);
      long tmp1 = sum.at(posr+1) - sum.at(i);
      if (abs(rs - tmp*2) > abs(rs - tmp1*2)) {
        posr++;
      } else {
        break;
      }
    }
    long r = sum.at(posr) - sum.at(i);
    long s = rs - r;
    // cout << "p: " << p << " q: " << q << " r: " << r << " s: " << s << endl;
    long ss[4] = {p, q, r, s};
    sort(ss, ss+4);
    ans = min(ans, ss[3] - ss[0]);
  }
  cout << ans << endl;
}


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

int main() {
  int S;
  cin >> S;
  
  int mae = S / 100;
  int ushiro = S % 100;
  
  if(mae < 1 || mae > 12) {
    if(ushiro < 1 || ushiro > 12) {
      cout << "NA" << endl;
    }
    else
      cout << "YYMM" << endl;
  }
  
  else {
    if(ushiro < 1 || ushiro > 12) {
      cout << "MMYY" << endl;
    }
    else
      cout << "AMBIGUOUS" << endl;
  }
  
}

Measured memory_bytes: 256
int main(void){
    long a,m=10000000,n=-10000000;
    int N,i,b[100000];
    scanf("%d",&N);
    for(i=0;i<N;i++)
    {
        scanf("%d",&b[i]);
    }
    for(i=0;i<N;i++)
    {
        a=a+b[i];
        if(m>b[i]){
            m=b[i];
        }
        if(n<b[i]){
            n=b[i];
        }
    }
    printf("%ld %ld %ld\n",m,n,a);









    return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
        using namespace std;
         
        int main () {
          cin.tie(0);
          ios::sync_with_stdio(false);
          
          int h, n;
          cin >> h >> n;
          int a[n];
          int  total = 0;
          for(int i = 0; i < n; i++) {
            cin >> a[i];
            total += a[i];
          }
          if(total < h) {
            cout << "No" << endl;
          }else {
            cout << "Yes" << endl;
          }
        }

Measured memory_bytes: 640
import bisect
inf = 10**18
a, b, q = map(int, input().split())
s = [-inf] + [int(input()) for _ in range(a)] + [inf]
t = [-inf] + [int(input()) for _ in range(b)] + [inf]

for _ in range(q):
    x = int(input())
    i = bisect.bisect_right(s, x)
    j = bisect.bisect_right(t, x)
    ans = inf
    for s_x in [s[i-1], s[i]]:
        for t_x in [t[j-1], t[j]]:
            ans0 = abs(s_x - x) + abs(t_x - s_x)
            ans1 = abs(t_x - x) + abs(s_x - t_x)
            ans = min(ans, ans0, ans1)
    print(ans)

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int n, bit[500005];

int query(int i) {
    int ret = 0;
    for (; i>0; i-=i&-i)
        ret += bit[i];
    return ret;
}

void update(int i, int val) {
    for (; i<=n; i+=i&-i)
        bit[i] += val;
}

int c[500005], ret[500005], last[500005];
vector<pair<int, int>> queries[500005];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int q;
    cin >> n >> q;
    for (int i=1; i<=n; i++)
        cin >> c[i];
    for (int i=0; i<q; i++) {
        int l, r;
        cin >> l >> r;
        queries[r].emplace_back(l, i);
    }

    for (int i=1; i<=n; i++) {
        if (last[c[i]])
            update(last[c[i]], -1);
        update(i, 1);
        last[c[i]] = i;
        for (auto &p : queries[i])
            ret[p.second] = query(i) - query(p.first - 1);
    }

    for (int i=0; i<q; i++)
        cout << ret[i] << "\n";

    return 0;
}


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

int visited[101];

int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=k;i++)
	{
		int d1,v;
		cin>>d1;
		for(int j=1;j<=d1;j++)
		{
			cin>>v;
			visited[v]=1;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(visited[i]==0)ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>

const char marks[] = {'S', 'H', 'C', 'D', };

int card_encode(char mark, int num){
  int mm = 0;
  for(int i = 0; i < 4; i++){
    if(mark == marks[i]){
      mm = i;
      break;
    }
  }
  return mm * 13 + num - 1;
}

int main(){
  int n;
  std::cin >> n;
  int cards[n];
  bool used[52];
  for(int i = 0; i < 52; i++){
    used[i] = false;
  }
  
  for(int i = 0; i < n; i++){
    char mark;
    int num;
    std::cin >> mark;
    std::cin >> num;
    used[card_encode(mark, num)] = true;
  }

  for(int i = 0; i < 52; i++){
    if(!used[i]){
      std::cout << marks[i / 13] << " " << i % 13 + 1 << std::endl;
    }
  }
  
  
  return 0;
}



Measured memory_bytes: 3068
import math

N = int(input())
A = []
B = []
for i in range(N):
    in1, in2 = list(map(int,input().split()))
    A.append(in1)
    B.append(in2)
AA = sorted(A)
BB = sorted(B)

if N%2==1:
    low = AA[N//2]
    high = BB[N//2]
    print(high - low +1)

else:
    low = AA[N//2-1] + AA[N//2]
    high = BB[N//2-1] + BB[N//2]
    #print(low,high)
    print(high - low +1)

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

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

	std::vector<int> count(100000 + 1);
	for (int i = 0; i < n; ++i) {
		int a;
		std::cin >> a;

		++count[a];
	}

	int numRemoved = 0;
	for (auto&& e : count) {
		if (e <= 2)
			continue;

		if (e % 2 == 0) {
			numRemoved += e - 2;
			e = 2;
		}
		else {
			numRemoved += e / 2 * 2;
			e = 1;
		}
	}

	int r2 = 0;
	for (auto&& e : count)
		if (e == 2)
			++r2;

	numRemoved += (r2 + 1) / 2 * 2;

	std::cout << n - numRemoved << std::endl;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    string s,p;
    cin >> s >> p;
    s += s;
    if(s.find(p) != string::npos)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    
    return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;
int MOD = 1e9 + 7;

struct Query {
	int w, v;
};

int main() {
	int N;
	cin >> N;
	vector<vector<int>> good;   //男性、相性のいい人
	good.resize(N + 1);
	for (int n = 1; n <= N; n++) {
		for (int girl = 0; girl < N; girl++) {
			int g;
			cin >> g;
			if (g == 1)good[n].push_back(girl);
		}
	}
	vector<vector<long long>> DP;
	DP.resize(N + 1, vector<long long>((1 << N), 0));
	DP[0][0] = 1;
	for (int girl : good[1]) {
		DP[1][1 << girl] = 1;
	}
	for (int n = 1; n < N; n++) {
		int comb = (1 << n) - 1;
		while (comb < (1 << N)) {
			DP[n][comb] %= MOD;
			for (int girl : good[n + 1]) {
				if ((comb & (1 << girl)))continue;   //すでに取られているので
				DP[n + 1][(comb | (1 << girl))] += DP[n][comb];
			}
			int x = comb & (-comb);
			int y = comb + x;
			comb = ((comb & ~y)/x >> 1) | y;
		}
	}
	cout << DP[N][(1 << N) - 1] % MOD << endl;
	return 0;
}

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

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

    int ans =0;
    int count;
    for(int i=1;i<=N;i++){
        count =0;
        if(i%2==1){
            for(int j=1;j<=i;j++){
                if(i%j==0) count++;
            }
            if(count==8) ans++;
        }
    }
    cout << ans << endl;


}

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

int main() {
  int n;
  cin >> n;
  vector<ll> comfort;

  for (int i=0; i<n; i++) {
    ll a;
    cin >> a;
    comfort.push_back(a);
  }

  sort(comfort.begin(), comfort.end(), greater<ll>());

  ll ans = 0;
  for (int i=1; i<n/2; i++) {
    ans += comfort[i];
  }
  ans *= 2;
  ans += comfort[0];

  if (n%2 == 1) {
    ans += comfort[n/2];
  }

  cout << ans << endl;
}

Measured memory_bytes: 5320
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
#define pll pair<ll,ll>
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

ll a[110000];
int main(){
    char x;
    cin>>x;
    if((int)(x)>=0x61)cout<<'a';
    else cout<<'A';
    
}



Measured memory_bytes: 3560
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: u64, p: [u64; n]);
    let mut min: u64 = 1000000007;
    let mut count: u64 = 0;
    for pp in p {
        min = if min < pp { min } else { pp };
        if min == pp {
            count += 1;
        }
    }
    println!("{}", count);
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

unsigned int N, K;
int A[220000][70];
signed main() {
    cin >> N >> K;
    rep(i, N) {
        cin >> A[i][0];
        A[i][0]--;
    }
    rep(i, 69) {
        rep(j, N) {
            A[j][i + 1] = A[A[j][i]][i];
        }
    }
    int cur = 0;
    rep(i, 64) {
        if (~K & bit(i)) { continue; }
        cur = A[cur][i];
    }
    cout << cur + 1 << endl;

}


Measured memory_bytes: 113012
#pragma GCC target ("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int D=365;
const int beam = 230;
int c[26];
int s[D][26];
int ans[D];

struct State{
    ll val = 0;
    int out[D]={0};
    int cnt[26]={0};
};

bool operator< (const State &a, const State &b){
    return a.val<b.val;
}
bool operator> (const State &a, const State &b){
    return a.val>b.val;
}


void solve(int ca){
    int waste;
    scanf("%d",&waste);
    for (int i = 0; i < 26; ++i) {
        scanf("%d",c+i);
    }
    for (auto & i : s) {
        for (int & j : i) {
            scanf("%d",&j);
        }
    }

    priority_queue<State> pq[2];
    pq[0].push(State());
    for (int i = 0; i < D; ++i) {
        int prev=i&1,next = prev^1;
        for (int j = 0; !pq[prev].empty()&&j < beam; ++j) {
            auto state = pq[prev].top();
            pq[prev].pop();
            ll dec=0;
            for (int k = 0; k < 26; ++k) { 
                state.cnt[k]++;
                dec+=(ll)c[k]*state.cnt[k];
            }
            for (int k = 0; k < 26; ++k) {
                const ll inc = (ll)c[k]*state.cnt[k];
                const int tmp = state.cnt[k];
                const int tmp_val = state.val;
                state.val = state.val-dec+inc+s[i][k];
                state.cnt[k]=0;
                state.out[i]=k;
                pq[next].push(state);
                state.cnt[k]=tmp;
                state.val = tmp_val;
            }
        }
        pq[prev]=priority_queue<State>();
    }
    auto best = pq[D&1].top().out;
    for (int i = 0; i < D; ++i) {
        ans[i]=best[i]+1;
    }
    for (int i = 0; i < D; ++i) {
        printf("%d\n",ans[i]);
    }

}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


Measured memory_bytes: 34412
def olcnt(s):
    i = 0
    lst = []
    while i < len(s):
        j = 1
        while i + j < len(s) and s[i] == s[i + j]:
            j += 1
        lst.append((s[i], j))
        i += j
    return lst

  
s = list(input())
k = int(input())

if len(set(s)) == 1:
    print(int(len(s)*k/2))
else:
    cnt1 = sum([int(x[1]/2) for x in olcnt(s)])
    cnt2 = sum([int(x[1]/2) for x in olcnt(s+s)])

    print(cnt1 + (cnt2-cnt1)*(k-1))

Measured memory_bytes: 3064