akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)

typedef long long int ll;

std::vector<ll> enum_div(ll n);
long long comb(int n, int r);
bool IsPrime(int num);
bool dp[110][10010];
class UnionFind;
using Graph = vector<vector<int>>;

//自作関数一覧---------------------------
ll gcd(ll a, ll b); //最小公倍数の導出
ll lcm(ll x, ll y); //最大公約数の導出
ll bur(ll N, ll X); //??
//---------------------------------------

//UF木
class UnionFind {
public:
	//親
	vector<int> Parent;

	//初期状態
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//サイズ確認
	int size(int A) {
		return -Parent[root(A)];
	}

	int connect(int A, int B) {
		//root同氏をくっつける
		A = root(A);
		B = root(B);

		//結合済み
		if (A == B) {
			return false;
		}
		//大きいほうに小さいほうをくっつける
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズ更新
		Parent[A] += Parent[B];
		//Bの親をAに
		Parent[B] = A;

		return true;
	}

};

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll D = 0;


	string S, T;
	char fi[50], fv[50];
	char board[4][4];
	bool start = false;
	ll left = 0, right = 0;
	
	std::vector<char> zo;

	cin >> S;

	rep(i, 0, S.length()) {
		if (S[i] == '0')
			zo.push_back('0');
		else if (S[i] == '1')
			zo.push_back('1');
		else if (S[i] == 'B' && zo.size()>0)
			zo.pop_back();


		
	}


	rep(i, 0, zo.size()) {
		cout << zo[i];
	}

	cout << endl;
	return 0;
}


std::vector<ll> enum_div(ll n)//nの約数を列挙
{
	vector<ll> res;
	for (int i = 1; i*i <= n; ++i) {
		if (n % i != 0) continue;
		res.push_back(i);
		if (n / i == i) continue; // 上の行で追加済み。
		res.push_back(n / i);
	}
	return res;
}








bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}



//combination
long long comb(int n, int r) {
	std::vector<std::vector<long long>> v(n + 1, std::vector<long long>(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v[n][r];
}


ll gcd(ll a, ll b) {

	/* 自然数 a > b を確認・入替 */
	if (a<b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}
	ll x = b;
	ll y = a;
	/* ユークリッドの互除法 */
	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}


	return y / b*x;
}

// 最大公約数を求める関数
ll lcm(ll x, ll y)
{
	if (x == 0 || y == 0)  // 引数チェック
	{
		//fprintf(stderr, "引数エラーです。\n");
		return 0;
	}

	return (x * y / gcd(x, y));
}

ll bur(ll N, ll X) {
	ll pan = 1;
	ll pat = 1;
	ll burg = 0;



	if (X > burg) {
		if (N == 0)
			return pat;


		burg += pan;
		burg += bur(N - 1, X);
		burg += pat;
		burg += bur(N - 1, X);
		burg += pan;


	}

	return burg;

}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cerr << (*begin) << " ";
    *begin++;
  }
  cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cerr << " " << Array[i][j];
    }
    cerr << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

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

signed main() {
  int a, b, k;
  cin >> a >> b>> k;
  int cnt = 0;
  for (int i = max(a, b); i >= 1; i--) {
    // dbg(i)
    if (a % i == 0 and b % i == 0) {
      cnt++;
      if (cnt == k) {
      cout << i << endl;
      break;

      }
      // break;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;
string s;

int main() {
  int a,p;cin >> a >> p;
  int out = a*3+p;
  cout << out/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=2e5+9,inf=1e8;
	int head[N*3],nex[N*3],to[N*3],fl[N*3],cnt=1;
	inline void add(int u,int v,int flow){
		nex[++cnt]=head[u],head[u]=cnt,to[cnt]=v,fl[cnt]=flow;
		nex[++cnt]=head[v],head[v]=cnt,to[cnt]=u,fl[cnt]=0;
	}
	int S,T,dist[N],cur[N];
	queue<int> q;
	inline bool bfs(){
		while(!q.empty()) q.pop();
		for(int i=1;i<=T;i++) dist[i]=inf;
		q.push(S),dist[S]=0;

		while(!q.empty()){
			int u=q.front();q.pop();
			if(u==T) return 1;
			for(int i=head[u];i;i=nex[i])
				if(fl[i] && dist[to[i]]==inf){
					dist[to[i]]=dist[u]+1;
					q.push(to[i]);
				}
		}
		return 0;
	}
	inline int dfs(int u,int flow){
		if(u==T) return flow;
		int rest=flow,k;
		for(int &i=cur[u];i && rest;i=nex[i])
			if(dist[u]+1==dist[to[i]]){
				k=dfs(to[i],min(fl[i],flow));
				fl[i]-=k,fl[i^1]+=k,rest-=k;
			}
		return flow-rest;
	}

	int n,P[N],Q[N],visP[N],visQ[N],num,ans;
	int main(){
		n=read<int>();
		for(int i=1;i<=n;i++) P[i]=read<int>()+1;
		for(int i=1;i<=n;i++) Q[i]=read<int>()+1;

		for(int i=1;i<=n;i++) if(!visP[i]){
			int tmp=i;num++;
			while(!visP[tmp]) visP[tmp]=num,tmp=P[tmp];
		}for(int i=1;i<=n;i++) if(!visQ[i]){
			int tmp=i;num++;
			while(!visQ[tmp]) visQ[tmp]=num,tmp=Q[tmp];
		}


		S=++num,T=++num;
		for(int i=1;i<=n;i++){
			if(P[i]==Q[i] && i==P[i]){ans++;continue;}
			else if(P[i]==i) add(S,visQ[i],1);
			else if(Q[i]==i) add(visP[i],T,1);
			else if(P[i]==Q[i]) add(visP[i],visQ[i],1),add(visQ[i],visP[i],1);
			else add(visP[i],visQ[i],1);
		}

		while(bfs()){
			int d;
			for(int i=1;i<=T;i++) cur[i]=head[i];
			do{d=dfs(S,inf),ans+=d;}while(d);
		}
		printf("%d\n",n-ans);
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

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

#define FOR(i, a, b) for(int i = a; i<b; ++i)
#define FR(a, b) for(int i = a; i>=b;--i)
#define _upgrade cin.tie(0); ios_base::sync_with_stdio(0)
#define pb push_back
#define mp make_pair
#define INF 1e9
#define all(x) (x).begin(), (x).end()

using namespace std;

typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef pair<int, int> iPair;

const int MAX = 1e5+1;
const int M = 1e9+7;

int n, k, tab[MAX], dp[MAX];
int main()
{
    _upgrade;
    cin>>n>>k;
    FOR(i, 0, n)
        cin>>tab[i];
    dp[0] = 0;

    FOR(i, 1, n)
    {
        dp[i] = INF;
        FOR(j, 1, k+1)
        {
            if(i-j<0)break;
            dp[i] = min(dp[i-j] + abs(tab[i-j]- tab[i]), dp[i]);
        }
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split();
        var N = int.Parse(input[0]);
        var K = int.Parse(input[1]);
        input = Console.ReadLine().Split();
        var h = new int[N];
        for (int i = 0; i < N; i++)
        {
            h[i] = int.Parse(input[i]);
        }

        var ans = 0;
        foreach (var item in h)
        {
            if (item >= K)
                ans++;
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 15968
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vi2;
typedef vector<vi2> vi3;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef vector<vll> vll2;
typedef vector<vll2> vll3;
typedef vector<bool> vb;

#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define umap unordered_map
#define uset unordered_set
#define vec vector
#define loop(a) for (auto &x : a)
#define all(a) a.begin(), a.end()
#define mp make_pair

const int INF = 1e7;

vi a;
int n;
vi2 cache;

int dfs(int which, int one_more) {
    int digit = a[which];
    if (which + 1 == n) {
        int ans = digit - one_more;
        if (one_more != 0) {
            ans = min(ans, 10 - digit);
        }
        return ans;
    }
    int &c = cache[which][one_more + 1];
    if (c != -INF) {
        return c;
    }

    int ans = digit + dfs(which + 1, 0) - one_more;
    if (one_more != 0) {
        ans = min(ans, 10 - digit + dfs(which + 1, 0));
    }
    ans = min(ans, digit + 1 + dfs(which + 1, 1) - one_more);
    if (one_more != 0) {
        ans = min(ans, 10 - digit - 1 + dfs(which + 1, -1));
    }
    // #ifdef LOCAL
    // assert(ans>=0);
    // #endif

    return c = ans;
}

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

    string s;
    cin >> s;
    n = s.size();
#ifdef LOCAL
    cout << "n:" << n << el;
#endif
    a = vi(n);
    rep(i, 0, n) {
        a[i] = s[i] - '0';
    }
    cache = vi2(n, vi(3, -INF));
    cout << min(1 + dfs(0, 1), dfs(0, 0)) << el;
}


Measured memory_bytes: 122396
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n,a,q,r,k;
    cin>>n>>a;
    if(n<=a)
        cout<<1<<endl;
    else {
           q=n/a;
           if(n%a==0)
                cout<<q<<endl;
           else
            cout<<q+1<<endl;
    }
    //cout<<k<<endl;

}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2001;
const int XRZ = 1000000007;
int dp[maxn], s, sum;
int main() {
	dp[0] = 1;
	for(int i = 3; i <= 2000; ++ i) {
		sum = (sum + dp[i - 3]) % XRZ;
		dp[i] = (dp[i] + sum) % XRZ;
	}
	cin >> s;
	cout << dp[s];
	return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
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(){
  string S;
  cin>>S;
  ll N=(ll)S.size(),cnt=0;
  
  REP(i,N){
    if(S[i]=='p') cnt++;
  }
  
  cout<<N/2-cnt<<endl;
  return 0;
}

Measured memory_bytes: 3756
ans = 0
x = []
for i in range(5):
	a = int(input())
	ans += int(a // 10) * 10
	x.append(a % 10)

x = sorted(x)
for i in range(5):
	if x[i] != 0:
		ans += (4 - i) * 10 + x[i]
		break
print(ans)

Measured memory_bytes: 3060
/**
 *    author:  yoseph
 *    created: 12.07.2020 11:52:51      
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int l,r,d;
	cin >> l >> r >> d;
	int cnt = 0;
	for (int i = l; i <= r; ++i) {
		if (i % d == 0)
			++cnt;
	}
	cout << cnt << "\n";
	return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iterator>
#include <math.h>
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define dd double
#define mp make_pair
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // int T,p;
    // cin>>T;
    // for(p=1;p<=T;p++)
    // {
      ll N;
      cin>>N;
      ll A[N],i,j,k,a=0,b,c,sum[N],prod=0;
      for(i=0;i<N;i++)
      {
        cin>>A[i];
        a+=A[i];
        a=a%1000000007;
        sum[i]=a;
      }
      for(i=0;i<N;i++)
      {
        j=a-sum[i];
        if(j<0)
        j+=1000000007;
        prod=(prod+(j*A[i])%1000000007)%1000000007;
      }
      cout<<prod;
      return 0;
}

Measured memory_bytes: 6720
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int kakuketa(int a){
  int sum = 0;
  while(a){
    sum += a % 10;
    a /= 10;
  }
  return sum;
}

int main(){
  
  	int n,memo = 0,ans = 100000000;
  	cin >> n;
  
  	rep(i,1,n){
		memo = kakuketa(i) + kakuketa(n-i);
      	ans = min(memo,ans);
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
struct UnionFind {
private:
    vector<int> par;
    vector<int> count;
    vector<int> rank;
public:
    UnionFind(int N) {
        count.assign(N, 1);
        rank.assign(N, 0);
        par.assign(N, 0);
        rep(i, N) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x)
            return x;
        else {
            par[x] = root(par[x]);
            return par[x];
        }
    }

    void unite(int x, int y) {
        x = root(x), y = root(y);
        if (x == y) return;
        if (rank[x] < rank[y])
            swap(x, y);
        else if (rank[x] == rank[y])
            rank[y]++;
        par[y] = x;
        count[x] += count[y];
        return;
    }

    int size(int x) {
        return count[root(x)];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }
};
using UF = struct UnionFind;
int main() {
    init();
    ll N, M, K;
    cin >> N >> M >> K;
    UF fr(N), br(N);
    vl E(N);
    rep(i,M){
        ll a, b;
        cin >> a >> b;
        a--, b--;
        fr.unite(a, b);
        E[a]++, E[b]++;
    }
    vl ans(N);
    rep(i,K){
        ll a, b;
        cin >> a >> b;
        a--, b--;
        if (fr.issame(a, b)) ans[a]--, ans[b]--;
    }

    rep(i,N){
        ans[i] += fr.size(i) - E[i] - 1;
    }
    rep(i, N) cout << ans[i] << " ";
    cout << endl;
}

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	int n = s.length();
	vector<int> ans(n);
	
	for(int i = 0, j = 0; i < n; i = j) {
		for(j = i; j < n && s[j] == s[i]; j++);
		int len = j - i;
		if(s[i] == 'R') {
			ans[j-1] += (len+1)/2;
			ans[j] += len/2;
		} else {
			ans[i-1] += len/2;
			ans[i] += (len+1)/2;
		}
	}
	
	for(int i = 0; i < n; i++) {
		cout << ans[i] << " \n"[i==n-1];
	}
}


Measured memory_bytes: 1104
#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <cmath>

int main() {
    char buffer[64];

    scanf("%s", &buffer[0]);
    scanf("%s", &buffer[strlen(buffer)]);

    int number = (int)atol(buffer);

    printf("%s", (int)sqrt(number) == sqrt(number) ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		double n = in.nextDouble();

		double ans = 0.5;
		if ( n == 1.0 ) {
			ans = 1;
		} else if ( n % 2 == 1 ) {
			ans = Math.ceil(n / 2.0) / n;
		}

		System.out.println(ans);
		in.close();
	}
}

Measured memory_bytes: 25044
from itertools import chain
  
n = int(input())
ts = list(map(int, input().split()))
vs = list(map(int, input().split()))
  
va = list(chain.from_iterable([v] * (2 * t) for t, v in zip(ts, vs)))
va = [min(v1, v2) for v1, v2 in zip([0] + va, va + [0])]
lt = len(va)
  
pv = 0
for ct in range(1, lt):
    va[ct] = pv = min(va[ct], pv + 0.5)
  
pv = 0
for ct in range(lt - 1, 0, -1):
    va[ct] = pv = min(va[ct], pv + 0.5)
  
print(sum((v1 + v2) / 4 for v1, v2 in zip(va, va[1:])))

Measured memory_bytes: 4384
from collections import Counter
import sys


def read() -> str:
    return sys.stdin.readline().rstrip()


def main():
    n = int(read())
    s = [read() for _ in range(n)]
    counter = Counter(s).most_common()
    c = counter[0][1]
    print(*sorted(ci[0] for ci in counter if ci[1] == c), sep="\n")


if __name__ == '__main__':
    main()

Measured memory_bytes: 45112
package main

import (
  "bufio"
  "container/list"
  "fmt"
  "os"
  "strconv"
  "strings"
)

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,100)}
  n,m := input.NextInts()
  if m%2 == 1 { fmt.Println(-1);return }
  uf := NewUnionFind(n)
  es := []Edge{}
  num := make([]int,n)
  tree := make([][]int,n)
  extra := make([][]int,n)
  for i:=0;i<m;i++ {
    a,b := input.NextInts()
    a,b = a-1,b-1
    if uf.Same(a,b) {
      extra[a] = append(extra[a],b)
      es = append(es,Edge{a,b})
      num[a]++
    } else {
      uf.Unite(a,b)
      tree[a] = append(tree[a],b)
      tree[b] = append(tree[b],a)
    }
  }
  order := order_from_leaf(tree)
  for _,node := range order {
    if node.par < 0 { continue }
    par := node.par
    v := node.id
    if num[v]%2 == 0 {
      es = append(es,Edge{par,v})
      num[par]++
    } else {
      es = append(es,Edge{v,par})
    }
  }
  for _,e := range es { fmt.Println(e.fm+1,e.to+1) }
}

type Edge struct { fm,to int }
type Node struct { par,id int }
func order_from_leaf(tree [][]int) []Node {
  n := len(tree)
  order := make([]Node,n)
  q := list.New()
  q.PushBack(Node{-1,0})
  i := n-1
  for q.Len() > 0 {
    p := q.Remove(q.Front()).(Node)
    order[i] = p
    i--
    for _,e := range tree[p.id] {
      if e == p.par { continue }
      q.PushBack(Node{p.id,e})
    }
  }
  return order
}

type UnionFind struct { par,rank []int }
func NewUnionFind(n int) UnionFind {
  par := make([]int,n)
  rank := make([]int,n)
  for i:=0;i<n;i++ { par[i] = i }
  return UnionFind{par,rank}
}
func(u UnionFind) Find(i int) int {
  if u.par[i] == i { return i }
  u.par[i] = u.Find(u.par[i])
  return u.par[i]
}
func(u UnionFind) Same(i,j int) bool { return u.Find(i) == u.Find(j) }
func(u UnionFind) Unite(i,j int) {
  i,j = u.Find(i),u.Find(j)
  if i == j { return }
  if u.rank[i] < u.rank[j] { u.par[i] = j;return }
  u.par[j] = i
  if u.rank[i] == u.rank[j] { u.rank[i]++ }
}

type Input struct { reader *bufio.Reader }
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) NextInts() (int,int) {
  s := strings.Fields(i.NextLine())
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  return x,y
}

Measured memory_bytes: 19712
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    var inps = new BigInteger[4];
    try (var sc = new Scanner(System.in)) {
      for (int i = 0; i < 4; ++i) {
        inps[i] = new BigInteger(String.valueOf(sc.nextInt()));
      }
    }
      var ac = inps[0].multiply(inps[2]);
      var ad = inps[0].multiply(inps[3]);
      var bc = inps[1].multiply(inps[2]);
      var bd = inps[1].multiply(inps[3]);

      ac = ac.max(ad);
      ac = ac.max(bc);
      ac = ac.max(bd);

      System.out.println(ac);
  }
}


Measured memory_bytes: 35896
#include <cstdio>
#include <cmath>
#include <map>
typedef long long LL;
const LL maxs=10000000000ll;
const int N=100005,M=2155;
bool u[M];
int p[330],m=0;
LL a[N],b[N];
std::map<LL,int> f;
void Pre(){
	for (int i=2;i<M;i++){
		if (!u[i]) p[++p[0]]=i;
		for (int j=1;j<=p[0] && i*p[j]<M;j++){
			u[i*p[j]]=1;
			if (i%p[j]==0) break;
		}
	}
}
int Sqrt(LL x){
	LL y=sqrt(x*1.0);
	for (;y*y<x;y++);
	return y*y==x?y:-1;
}
bool solve(){
	LL s,x=1,y=1;
	scanf("%lld",&s);
	for (int j=1;j<=p[0];j++){
		int cnt=0;
		for (;s%p[j]==0;s/=p[j]) cnt++;
		cnt%=3;
		if (cnt==1) x*=p[j],y*=p[j]*p[j];
			else if (cnt==2) y*=p[j],x*=p[j]*p[j];
		if (y>maxs) return 1;
	}
	int z=Sqrt(s);
	if (z!=-1) x*=s,y*=z;
		else if (y*s>maxs/s) return 1;
			else x*=s,y*=s*s;
	f[a[++m]=x]++;b[m]=y;
	return 0;
}
int main(){
	int n,ans=0;
	scanf("%d\n",&n);
	Pre();
	for (int i=1;i<=n;i++) ans+=solve();
	if (f[1]) ans++,f[1]=0;
	for (int i=1;i<=m;i++)
	if (f[a[i]]){
		ans+=std::max(f[a[i]],f[b[i]]);
		f[a[i]]=f[b[i]]=0;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 12032
#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;
  vi p(n);
  rep(i,n) cin >> p[i];
  int cnt = 0;
  vi q = p;
  //rep(i,n) cout << q[i];
  sort(q.begin(),q.end());
  rep(i,n){
    if(p[i]!=q[i]) cnt++;
  }
  if(cnt==0 || cnt==2) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))

ltor=[]
rtol=[]
tmp_ltor=0
tmp_rtol=0
for i in range(N):
    tmp_ltor+=a[i]
    ltor.append(tmp_ltor)
    tmp_rtol+=a[N-1-i]
    rtol.append(tmp_rtol)
num=2*10**9
for i in range(N-1):
    num=min(num,abs(ltor[i]-rtol[N-1-i-1]))
print(num)

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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b);a>c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
int n,a[100001],b[100001];
int pow3(int x,int n){
    int res = 1;
    while(n){
        if(n & 1){
            res = (res * x) % Mod;
        }
        x = x * x % Mod;
        n>>=1;
    }
    return res;
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int topa=0,topb=0;
    cin >> n;
    rep(i,0,n){
        cin >> a[i];
        if(a[i]>topa)topa=a[i];
    }
    rep(i,0,n){
        cin >> b[i];
        if(b[i]>topb)topb=b[i];
    }
    int top=topa;
    bool no=false;
    bool oh=false;
    int ma=-1,mb=-1;
    if(topa!=topb){
        no=true;
    }
    bool yh[100001];
    rep(i,0,100001){
        yh[i]=false;
    }
    rep(i,1,n){
        if(a[i]<a[i-1])no=true;
    }
    rep(i,0,n-1){
        if(b[i]<b[i+1])no=true;
    }
    if(!no)rep(i,0,n){
        if(i!=0){
            if(a[i]!=a[i-1])yh[i]=true;
        }if(i!=(n-1)){
            if(b[i]!=b[i+1])yh[i]=true;
        }
        if((!oh&&a[i]>b[i])||(oh&&a[i]<b[i])){
            no=true;
            break;
        }
        if(a[i]==b[i]){
            if(ma==-1)ma=i;
            if(top!=a[i]){
                no=true;
                break;
            }
            mb=i;
            oh=true;
        }
    }
    yh[0]=true;yh[n-1]=true;
    int ans=1;
    if(!no){
        rep(i,0,ma){
            if(!yh[i]){
          //      cout <<i <<" "<< a[i] << endl;
                (ans*=a[i])%=Mod;
            }
        }
     //   cout << ans << " "<<ma<<" mb " << mb <<  endl;
        rep(i,mb+1,n){
            if(!yh[i]){
                //cout << i <<" "<<b[i] << endl;
                ans*=b[i];
                ans%=Mod;
            }
        }
        if((mb-ma-1)>0){ans*=pow3(a[ma],(mb-ma-1))%Mod;ans%=Mod;}
        cout << ans%Mod << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}





Measured memory_bytes: 1920
import networkx as nx

N, M = map(int, input().split())
S = [list(input()) for i in range(N)]
G = nx.DiGraph() # 有向グラフ
G.add_nodes_from(['S', 'T']) # 'S' -> 'T'のflowを考える

# (i+j)の偶奇でグループ分け
# 偶数のマスは奇数のマスと隣接しており、奇数のますは偶数のマスと隣接している
for i in range(N):
    for j in range(M):
        if S[i][j] == '#':
            continue
        if (i + j) % 2 == 0:
            G.add_edge('S', (i, j), capacity=1) # 偶数のマスは'S'と繋ぐ
            # 隣接する奇数のマスが空なら辺を追加('S' -> 'T'の向きで)
            for di, dj in ((1, 0), (0, 1), (-1, 0), (0, -1)):
                ii = i+di; jj = j+dj
                if 0<=ii<N and 0<=jj<M and S[ii][jj]=='.':
                    G.add_edge((i, j), (ii, jj), capacity=1)
        else:
            G.add_edge((i, j), 'T', capacity=1) # 奇数のマスは'T'と繋ぐ

max_flow, flow = nx.maximum_flow(G, 'S', 'T')
for i in range(N):
    for j in range(M):
        if (i, j) in flow:
            for t, f in flow[(i, j)].items():
                if t == 'T' or f == 0:
                    continue

                ii, jj = t
                if ii == i+1:
                    S[i][j] = 'v'; S[ii][jj] = '^'
                elif ii == i-1:
                    S[i][j] = '^'; S[ii][jj] = 'v'
                elif jj == j+1:
                    S[i][j] = '>'; S[ii][jj] = '<'
                else:
                    S[i][j] = '<'; S[ii][jj] = '>'

print(max_flow)
for s in S:
    print(''.join(s))


Measured memory_bytes: 119248
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		int kyoriA = Math.abs(x-a);
		int kyoriB = Math.abs(x-b);

		if(kyoriA < kyoriB) {
			System.out.println("A");
		} else {
			System.out.println("B");
		}


	}
}

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

using namespace std;

int main(){
	string input;
	cin >> input;
	vector<char> v;

	for (auto c:input){
		if (c == 'C' && v.size() == 0){
			v.push_back(c);
		}else if (c == 'F' && v.size() == 1){
			v.push_back(c);
		}
	}
    
    if (v.size() == 2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int main() {
    int n;
    cin >> n;
    if (n >= 100)
        cout << "ABC" << n << endl;
    else if (n < 100 && n >= 10) {
        cout << "ABC0" << n << endl;
    } else {
        cout << "ABC00" << n << endl;
    }

    return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n;cin >>n;
    ll g=0;
    for (int i = 0; i < n; ++i) {
        ll a;cin >>a;
        g=__gcd(g,a);
    }
    ll ans=0;
    while(g%2==0){
        ans++;
        g/=2;
    }
    cout <<ans <<endl;
}



Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

ans = 0
[x,y] = inpl()

alpha = ( 2*x-y )//3
beta = (2*y-x)//3
alpha_c = ( 2*x-y )%3
beta_c = (2*y-x)%3

MAX_NUM = 10**6 + 1
MOD = 10**9+7

fac  = [0]*MAX_NUM
finv = [0]*MAX_NUM
inv  = [0]*MAX_NUM

fac[0]  = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1

for i in range(2,alpha+beta+1):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

def combinations(n,k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD

ans = combinations(alpha+beta,alpha) if alpha_c == 0 and beta_c == 0 else 0
print(ans)

Measured memory_bytes: 99020
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

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

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

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

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

signed main() {
    char c;
    cin>>c;
    c = c + 1;
    cout<<c<<endl;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long 
#define f(j) for(ll i=0;i<j;i++)
#define pb(i) push_back(i)
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;    
typedef vector<vector<long long> > matrix; 
vector<int>	adj[100001];
int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	// faster
	int n,m,a,b,ecount[100001]={0},node;
	cin>>n>>m;
	f(m){
		cin>>a>>b;
		adj[a].pb(b);
		ecount[b]++;
	}
	int distance[100001]={0};
	int start,ans=0;
	queue<int>	q;
	for(int i=1;i<=n;i++)
		if(ecount[i]==0)
			q.push(i);
	while(!q.empty()){
		node = q.front();
		q.pop();
		for(int b : adj[node]){
			ecount[b]--;
			distance[b]=max(distance[b],distance[node]+1);
			ans = max(ans,distance[b]);
			if(!ecount[b])
				q.push(b);
		}
	}
	cout<<ans<<"\n";
return 0;	
}

Measured memory_bytes: 9808
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
#include <stdlib.h>
using namespace std;
#define rep(i,n) for (int i = 0; i <n; i++) 
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}

using namespace std;
int main(){
    int a,b;std::cin >> a>>b;
    std::cout <<( (a%2==0||b%2==0)?"No":"Yes" )<< std::endl;
    
    
}



Measured memory_bytes: 256
#include <cstdio>
#include <deque>
using namespace std;
int len,ans;
char ch[200005];
deque<int>v;
int main(){
	scanf("%d%s",&len,ch);
	for(int i=0;i<len;++i){
		if(ch[i]=='R')v.push_back(i);
	}
	for(int i=0;i<len;++i){
		if(v.empty())break;
		if(v[0]<i)v.pop_front();
		if(v.empty())break;
		if(ch[i]=='W'){
			v.pop_back();
			++ans;
		}
		if(v.empty())break;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4132
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

std::string s,t, tori;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> s >> t; tori = t;

	int32_t lev = 0;
	auto s_iter = s.begin();
	auto t_iter = t.begin();
	while (s_iter != s.end())
	{
		if (*s_iter == *t_iter) {
			++t_iter;
			if (t_iter == t.end()) {
				++lev;
				std::string new_t = t;
				for (auto& ss : tori) {
					new_t.push_back(ss);
					new_t += t;
					if (new_t.size() > s.size()) { out << lev << endl; return 0; }
				}
				auto oldt_size = t.size();
				t = std::move(new_t);
				t_iter = t.begin()+ oldt_size;
			}
		}
		++s_iter;
	}
	out << lev << endl;

	return 0;
}
#endif



Measured memory_bytes: 3488
n = gets.to_i
n.times{|i|
    x, y, farthest = 0, 0, [-1, -1, -1]
    while true
        dx, dy = gets.chomp.split.map(&:to_i)
        break if [dx, dy] == [0, 0]
        x, y = x + dx, y + dy
        d = x * x + y * y
        farthest = [d, x, y] if (farthest[0] < d || (farthest[0] == d && farthest[1] < x))
    end
    puts "#{farthest[1]} #{farthest[2]}"
}


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

struct city {
    int i;
    int p;
    int y;
    int order_in_pref;
};

bool asc_py(const city& a, const city& b) {
    return a.p == b.p ? a.y < b.y : a.p < b.p;
}

bool asc_i(const city& a, const city& b) {
    return a.i < b.i;
}

int main() {
    int n, m;
    cin >> n >> m;

    city c[m];
    for (int i = 0; i < m; i++) {
        c[i].i = i;
        cin >> c[i].p >> c[i].y;
    }
    sort(c, c + m, asc_py);

    int before_p = 0;
    int order_in_pref;

    for (int i = 0; i < m; i++) {
        if (before_p != c[i].p) {
            before_p = c[i].p;
            order_in_pref = 1;
        }
        c[i].order_in_pref = order_in_pref++;
    }

    sort(c, c + m, asc_i);

    for (int i = 0; i < m; i++) {
        cout << setw(6) << setfill('0') << c[i].p;
        cout << setw(6) << setfill('0') << c[i].order_in_pref << endl;
    }

    return 0;
}


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

//#template
template <class T> inline T min(T a, T b, T c) { return min(min(a, b), c); }
template <class T> inline T max(T a, T b, T c) { return max(max(a, b), c); }
template <class T> inline T min(T a, T b, T c, T d) { return min(min(a, b), min(c, d)); }
template <class T> inline T max(T a, T b, T c, T d) { return max(max(a, b), max(c, d)); }
//#endtemplate

//#define
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define clr(x) memset(x, 0, sizeof(x))
#define mmid ((lf + rg) >> 1)
#define lson root * 2, lf, mmid
#define rson root * 2 + 1, mmid + 1, rg
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template <class T, class S> ostream &operator<<(ostream &o, const pair<T, S> &A) {
    o << "(" << A.fi << " " << A.se << ")";
    return o;
}
template <class T> ostream &operator<<(ostream &o, const vector<T> &A) {
    o << "[";
    for (auto &i : A) {
        o << " " << i;
    }
    o << " ]";
    return o;
}
//#enddefine

const int mod = int(1e9) + 7;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const int dx[] = { -1, 0, 1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };

const int N = 1e5 + 5;
int a[N];

void sol() {
    // Solve Function
    int a, b;
    while (cin >> a >> b) {
        cout << (a - 1) + (a <= b) << endl;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(0);
#ifdef CFENGLV
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    clock_t _time = clock();
#endif
    int T;
    // cin >> T;
    // for (int cas = 1; cas <= T; ++cas) {
    // cout << "Case #" << cas << ": ";
    sol();
    // }
#ifdef CFENGLV
    cerr << "Time: " << static_cast<double>(clock() - _time) / CLOCKS_PER_SEC * 1000 << "ms" << endl;
#endif
    return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

namespace ZTP002
{
    class B
    {
        static void Main(string[] args)
        {

            int N = int.Parse(Console.ReadLine());
            int[] D = Console.ReadLine().Split().Select(int.Parse).ToArray();
            long MOD = 998244353;
            long[] DCount = new long[N];

            //エラー処理
            if (D[0] != 0) { Console.WriteLine(0); return; }
            if (N <= D.Max()) { Console.WriteLine(0); return; }
            var Dsorted = D.OrderBy(x => x).ToArray();
            for (int i = 0; i < N - 1; i++)
            {
                if (i < N - 1 && Dsorted[i] + 2 <= Dsorted[i + 1]) { Console.WriteLine(0); return; }
            }
            if (1 < D.Count(x => x == 0)) { Console.WriteLine(0); return; }

            for (int i = 0; i < N; i++)
            {
                DCount[D[i]]++;
            }
            //Console.WriteLine(string.Join(",", DCount));

            long parent = 1;
            for (int i = 1; i < N; i++)
            {
                if (0 < DCount[i])
                {
                    for (int j = 0; j < DCount[i]; j++)
                    {
                        parent = (parent * DCount[i - 1]) % MOD;
                    }
                }
            }

            Console.WriteLine(parent);

        }
    }
}

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

int main() {
  int n,k;
  cin>>n>>k;
  set<int> memo;
  for(int i=0;i<k;i++){
    int d;
    cin>>d;
    for(int j=0;j<d;j++){
      int a;
      cin>>a;
      memo.insert(a);
    }
  }
  cout<<n-memo.size()<<endl;
  return 0;
}


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


int main() {
    int A[3];
    int max = 0;
    int maxi= -1;
    int sum = 0;
    for(int i=0;i<3;i++){
        cin >> A[i];
        if(A[i] > max){
            max = A[i];
            maxi = i;
        }
    }
    for(int i = 0; i < 3; i ++ ){
        if(maxi == i) A[i] *= 10;
        sum += A[i];
    }
    cout << sum;

}

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

int main() {
  int a,b,c,x,y; cin >>a >>b >>c >>x >>y;
  /* a+b>2cの場合、xとyの差が偶数ならcを出来るだけ買う。
    で、残りの例えばxが4枚とかになったとき、aを4枚買うかcを8枚
    買うかで場合分け
  */
  int ans;
  if (a+b<=2*c) ans = a*x + b*y;
  else{
    if (x==y) ans = c * 2*x;
    else if (x>y){
      if (a>2*c) ans = c * 2*x;
      else       ans = c * 2*y + a*(x-y);
    }else if (x<y){
      if (b>2*c) ans = c * 2*y;
      else       ans = c * 2*x + b*(y-x);
    }
  }
  cout <<ans;
  cout <<endl;
}


Measured memory_bytes: 256
#include <unistd.h>
#include <algorithm>
#include <functional>

char ibuf[4000000];
char *ibufe = ibuf-1;

void readall(){
  int k, t = 0;
  while((k=read(STDIN_FILENO, ibuf+t, sizeof(ibuf)-t))>0) t += k;
}

int read_uint(){
  int x=0;
  while(*(++ibufe) <'0');
  do {
    x *= 10;
    x += *ibufe-'0';
  } while(*(++ibufe) >='0');

  return x;
}

int n;
int S[1<<18];
int Q[19];

int main(){
  readall();
  n = read_uint();
  for(int i=0;i<(1<<n);i++) S[i] = read_uint();
  std::sort(S, S+(1<<n), std::greater<int>());
  int k = 0;
  for(int i=0;i<(1<<n);){
    int j = i;
    for(i++; S[i] == S[j]; i++) ;
    S[k++] = i-j;
  }
  Q[n] = 1;
  for(int i=0;i<k;i++){
    int l;
    int a=0;
    for(l=n;l>=0 && a < S[i];l--){
      int x = Q[l];
      Q[l] = a;
      a += x;
    }
    if(a<S[i]){
      write(STDOUT_FILENO, "No\n", 3);
      return 0;
    }
    l++;
    Q[l] += a-S[i];
    for(int t=0;t<l;t++) Q[t] += S[i];
    n -= !Q[n];
  }
  write(STDOUT_FILENO, "Yes\n", 4);
  return 0;
}

Measured memory_bytes: 4224
import sys
sys.setrecursionlimit(10**7)
#input = sys.stdin.readline
from collections import Counter

def main():
    a = input()
    n = len(a)

    base = n * (n - 1) // 2
    counter = Counter(a)

    def f():
        for c in counter.values():
            yield c * (c - 1) // 2

    print(base - sum(f()) + 1)

main()

Measured memory_bytes: 3752
#include<bits/stdc++.h>
#define ll long long int
#define cin(a,n) for(i=0;i<n;i++){cin>>a[i];sum+=a[i];}
#define ll long long int
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rf1(i,a,n) for(int i=a;i>n;i--)
#define cases() int q;cin>>q;while(q--)
#define ld long double
#define cout(a,n) for(i=0;i<n;i++)cout<<a[i]<<" ";
#define inf 1e9;
#define mod 1000000007;
#define PI 3.14159265358979323846264338327950L
using namespace std;
int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
 if(k<=a) cout<<k<<endl;
 else if(k<=a+b) cout<<a<<endl;
 else cout<<a-(k-a-b)<<endl;
return 0;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

string s;

int main() {
  cin >> s;
  for (int i = 0; i < s.size(); ++i) {
    if (i % 2 == 0) {
      cout << s[i];
    }
  }
}


Measured memory_bytes: 3636
x = int(input())

s = set()
for i in range(1, 32):
    for j in range(2, 10):
        if i**j <= 1000:
            s.add(int(i**j))

l = [int(i) for i in s]
l = sorted(l)

ans = 0
for i in l:
    if i <= x:
        ans = i
    else:
        break

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  map<int, int> amap;
  for(int x=1;x<=100;++x) {
    for(int y=1;y<=100;++y) {
      for(int z=1;z<=100;++z) {
        amap[x*x+y*y+z*z+x*y+y*z+z*x]++;
      }
    }
  }
  for(int i=1;i<=N;++i) cout<<amap[i]<<endl;
}



Measured memory_bytes: 5304
N=int(input())
monster_num = list(map(int,input().split()))
maximum_kill = list(map(int,input().split()))

kill_num = [[0,0] for i in range(N)]

kill_num[0][0] = min(monster_num[0],maximum_kill[0])
kill_num[0][1] = min(monster_num[1], maximum_kill[0] - kill_num[0][0])
for i in range(1,N):
    kill_num[i][0] = min(monster_num[i] - kill_num[i-1][1], maximum_kill[i])
    kill_num[i][1] = min(monster_num[i+1], maximum_kill[i] - kill_num[i][0])
#print(kill_num)
print(sum(sum(kill) for kill in kill_num))

Measured memory_bytes: 27940
// In the name of Allah

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define X first
#define Y second
#define mp make_pair
#define pb push_back

const ll MAX = 1e5 + 5, mod = 1e9 + 7, inf = 1e17 + 100;

ll n, m, seg[MAX * 4], carry[MAX * 4];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
	string s;
	cin >> s;
	bool f=  0;
	for (int i = 0; i < s.size()-1; i++)
		if (s[i] == 'A' && s[i+1] == 'C')
			f = 1;
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256