akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
using namespace std;


int main() {
    int n;
    cin >> n;
    vector<double> arr(n);
    for(int i=0; i <n;i++)  {
      cin >> arr[i];
    }
    double ans=0;
    for(int i=0; i< n ;i++)  {
      ans+=(1/arr[i]);
    }
    ans=1/ans;
    cout<<fixed<<setprecision(10);
    cout<< ans <<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int A,B;
    cin >> A >> B;
    cout << max({A + B, A - B, A * B}) << endl;
}

Measured memory_bytes: 256
N = input()
T, A = map(int, raw_input().split())
H = map(int, raw_input().split())

min_diff = float("inf")
res = 0
for i in range(N):
	if abs(A - T + H[i] * 0.006) < min_diff:
		min_diff = abs(A - T + H[i] * 0.006)
		res = i
print res + 1


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

using namespace std;

int k , z , o , p;

int main() {

	int n  , m ;
	cin >> n >> m ;

	if( n <= 10 ){
		cout << m + ( 100 * ( 10 - n ) ) ;
	}
	else{
		cout << m << endl ;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  string input;
  cin >> input;
  if(input=="MON"){
    cout << 6;
  }
  else if(input=="TUE"){
    cout << 5;
  }
  else if(input=="WED"){
    cout << 4;
  }
  else if(input=="THU"){
    cout << 3;
  }
  else if(input=="FRI"){
    cout << 2;
  }
  else if(input=="SAT"){
    cout << 1;
  }
  else if(input=="SUN"){
    cout << 7;
  }
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main(){
	ll a,b,c;cin>>a>>b>>c;
	cout<<min(a+b+1,c)+b<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define rs (x<<1|1)
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define SZ(x) (int((x).size()))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
const int maxn=4e3+5,mod=1e9+7;
int n,m,K,ans;
int dp[2][maxn];
int add(int x,int y){
	return x+y>=mod?x+y-mod:x+y;
}
int main(){
	read(n);read(m);read(K);
	dp[0][0]=1;
	rep(i,0,(n+m-1)/(K-1)){
		int nxti=i+1;
		memset(dp[nxti&1],0,sizeof dp[nxti&1]);
		rep(j,0,n)rep(k,1,K-1){
			int nxtj=j+k;
			if(nxtj>n)continue;
			dp[nxti&1][nxtj]=add(dp[nxti&1][nxtj],dp[i&1][j]);
		}
		rep(j,1,n){
			int tot=(K-1)*(i+1);
			if(!((j-n)%(K-1))&&!((m-1-(tot-j))%(K-1))&&tot-j<=m-1)ans=add(ans,dp[nxti&1][j]);
		}
		rep(j,0,n)dp[nxti&1][j]=add(dp[nxti&1][j],dp[i&1][j]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = std::vector<int>;
using VI2D = std::vector<vector<int>>;
using VLL = std::vector<long long>;
using VLL2D = std::vector<vector<long long>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

constexpr int dx[] = {-1, 0, 1, 0};
constexpr int dy[] = {0, -1, 0, 1};

template <typename T, std::size_t N>
struct make_vector_type {
	using type =
		typename std::vector<typename make_vector_type<T, (N - 1)>::type>;
};

template <typename T>
struct make_vector_type<T, 0> {
	using type = typename std::vector<T>;
};

template <typename T, size_t N>
auto make_vector_impl(const std::vector<std::size_t>& ls, T init_value) {
	if constexpr(N == 0) {
		return std::vector<T>(ls[N], init_value);
	} else {
		return typename make_vector_type<T, N>::type(
			ls[N], make_vector_impl<T, (N - 1)>(ls, init_value));
	}
}

template <typename T, std::size_t N>
auto make_vector(const std::size_t (&ls)[N], T init_value) {
	std::vector<std::size_t> dimensions(N);
	for(int i = 0; i < N; i++) {
		dimensions[N - i - 1] = ls[i];
	}
	return make_vector_impl<T, N - 1>(dimensions, init_value);
}

template <typename T>
std::vector<T> make_vector(std::size_t size, T init_value) {
	return std::vector<T>(size, init_value);
}

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max<T>(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min<T>(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	string s, t;
	cin >> s;
	cin >> t;

	int n = s.size();
	int m = t.size();
	ll result = INF;
	REP(i, n - m + 1) {
		int diff = 0;
		REP(j, m) { diff += s[i + j] != t[j] ? 1 : 0; }
		chmin(result, diff);
	}
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
#define MOD 998244353 //1000000007

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

    // solution comes here
    ll r;
    cin >> r;
    cout << r*r << nl;
}

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

int main() {
    long n, a, b, c = 0, x;
    cin >> n >> a >> b;
    for(int i = 2; i < n; i++)
        cin >> x, c ^= x;
    x = b;
    for(int i = 0; i < 50; i++) {
        long j = 1l << i;
        if(a <= 0) {
            cout << -1 << endl;
            return 0;
        }
        if(~a & j && b & j && a ^ b ^ c || (~a ^ b) & j && (a ^ b ^ c) & j + j)
            a -= j, b += j;
    }
    cout << (a ^ b ^ c ? -1 : b - x) << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>
#include <stack>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator<< (ostream &out, const vector<int> &b) {
    for (auto k : b) out << k << " ";
    return out;
}

istream& operator>> (istream& in, pii& b) {
    in >> b.first >> b.second;
    return in;
}

ostream& operator<< (ostream& out, const pii& b) {
    out << "{" << b.first << ", " << b.second << "}";
    return out;
}

template <typename T1, typename T2> inline bool chkmin(T1 &x, const T2 &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T1, typename T2> inline bool chkmax(T1 &x, const T2 &y) {if (x < y) {x = y; return 1;} return 0;}


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 10;
#else
    #define dbg(x) 57
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 179;
#endif

const ld PI = acos(-1);

#define time clock() / (double) CLOCKS_PER_SEC

// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")  
// #pragma GCC optimize("section-anchors")
// #pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
// #pragma GCC optimize("vpt")
// #pragma GCC optimize("rename-registers")
// #pragma GCC optimize("move-loop-invariants")
// #pragma GCC optimize("unswitch-loops")
// #pragma GCC optimize("function-sections")
// #pragma GCC optimize("data-sections")

mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    if (s.back() == 's') {
        cout << s << "es\n";
    } else cout << s << "s\n";
}
/*

*/

Measured memory_bytes: 3656
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k; cin>>n>>k;
    vector<lint> h(n);
    lint wa = 0;
    REP(i,n){
        cin>>h[i];
        wa+=h[i];
    }
    lint ans;
    if(n>=k){
        sort(all(h),greater<int>());
        ans = wa;
        REP(i,k){
            ans-=h[i];
        }
    }
    else ans = 0;
    print(ans);
    return 0;
}

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

int main()
{
	//?????????????????°???
	int test[28];
	int sum[31];
	for(int i=0;i<28;i++){
		cin>>test[i];
	}
	for(int j=0;j<31;j++){
		sum[j]=0;
	}
	for(int k=0;k<28;k++){
		sum[test[k]]=1;
	}
	for(int w=1;w<=30;w++){
		if(sum[w]==0){
			cout<<w;
			cout<<"\n";
		}
	}
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<long long> vl;
typedef pair<long long, long long> pl;
typedef vector<vector<long long>> matrix;

#define F 						first
#define S 						second
#define PB 						push_back
#define MP 						make_pair
#define all(c) 					c.begin(), c.end()
#define f(i,a,b) 				for(ll i=a; i<b; i++)
#define rep(i,n) 				f(i,0,n)
#define tr(c,i) 				for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) 			(c.find(x) != c.end())	//for set and map
#define cpresent(c,x) 			(find(all(c),x) != c.end())	//for vectors
#define w(t)					ll t; cin>>t; while(t--)
#define epsilon 				1e-9
#define MOD						(ll)1e9

void doublade() {
	ios::sync_with_stdio(false); cin.tie(0); cout.precision(10);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

int main() {
	doublade();
	// w(t) {
		ll k;
		cin >> k;
		ll val = 7%k;
		f(i, 1, 1e7+1) {
			if(val==0) {
				cout<<i<<"\n";
				return 0;
			}
			val = (val*10+7)%k;
		}
		cout<<"-1\n";
	// }
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h> 
using namespace std;  
int main() { 
	char S; 
	cin >> S;  
	if(S == 'a'){
		cout << "vowel" << endl;
	}else if(S == 'i'){
		cout << "vowel" << endl;
	}else if(S == 'u'){
		cout << "vowel" << endl;
	}else if(S == 'e'){
		cout << "vowel" << endl;
	}else if(S == 'o'){
		cout << "vowel" << endl;
	}else{
		cout << "consonant" << endl;
	}}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template< typename T > using matrix = vector< vector< T > >;

//FUNCTION  


void solve(void)
{
  int N;
  cin>>N;
  vector<int> A(N),B(N),vec(N);
  vector<pair<int,int> > VP(N);
  for (int i = 0; i < N; i++)
  {
    cin>>A[i]>>B[i];
    VP[i].first = A [i] +  B[i];
    VP[i].second = i;
  }
  sort(ALL(VP));
  reverse(ALL(VP));
  int SUM_A = 0, SUM_B = 0;
  int turn = 0;// 0がAのターン;

  for (int i = 0; i < N; i++)
  {
    int index = VP[i].second;
    if(turn == 0)
    {
      SUM_A += A[index];
    }
    else
    {
      SUM_B += B[index];
    }
    turn ^= 1;
    // DEBUG(index);
  }
  
  cout<<SUM_A - SUM_B<<endl;
 

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,m;
    std::cin >> n>>m;
    vector<ll> a(n);
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        sum += a[i];
    }
    sort(a.rbegin(),a.rend());
    
    for (int i = 0; i < m; i++) {
        if(a[i]*4*m<sum){
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    
    std::cout << "Yes" << std::endl;
}



Measured memory_bytes: 256
#include<stdio.h>

int main() {
    int N;
    int a[201];
    scanf("%d", &N);
    for (int i = 0; i < N; ++i) {
        scanf(" %d", &a[i]);
    }
    int res = 0;
    bool canDivide = true;
    while (canDivide) {
        for (int i = 0; i < N; ++i) {
            if (a[i] % 2 == 0)
                a[i] /= 2;
            else {
                canDivide = false;
                break;
            }
        }
        if (canDivide)
            res++;
    }
    printf("%d", res);

    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <deque>

const int MAX_S = 1e5;

char s[MAX_S + 1], c;
int q, t, k;
bool f;
std::deque<char> d;

int main()
{
	scanf("%s%d", s, &q);
	for (int i = 0; s[i]; ++i)
		d.push_back(s[i]);
	while (q--)
	{
		scanf("%d", &t);
		if (t == 1)
			f = !f;
		else
		{
			scanf("%d %c", &k, &c);
			if (f ^ (k == 2))
				d.push_back(c);
			else
				d.push_front(c);
		}
	}
	if (f)
		for (int i = d.size() - 1; i >= 0; --i)
			printf("%c", d[i]);
	else
		for (int i = 0; i < d.size(); ++i)
			printf("%c", d[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 896
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  string A;
  cin >> A;
  int ta = 0;
  int tb = 0;
  for (int i = 0; i < A.length(); i++) {
    if (i % 2 == 0) {
      if (A[i] == '0') {
        ta++;
      } else {
        tb++;
      }
    } else {
      if (A[i] == '1') {
        ta++;
      } else {
        tb++;
      }
    }
  }
  
  cout << min(ta,tb);
  return 0;
}
  /*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
  cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
    //配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
int main(){
	cin>>s;
	ll sum=0;
	for(int i=0;i<s.size();i++){
		sum+=(s[i]-'0');
	}
	cout<<((sum%9)?"No":"Yes");
	return 0;
}


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

int main(){
  int N;
  cin >>N;
  int a[N];
  for(int i=0 ;i<N;i++){
    cin >> a[i];
  }
  int h[N]={0};
  for(int i=0;i<N;i++){
    h[i]+=a[i]-1;
  }
  int sum =0;
  for(int i=0;i<N;i++){
    sum +=h[i];
  }
  cout  << sum << endl;
}

Measured memory_bytes: 256
N = int(input())
As = [int(i) for i in input().split(" ")]
Bs = [int(i) for i in input().split(" ")]
ans = 0
for i in range(N):
    a = As[i]
    b = Bs[i]
    if a - b >= 0:
      ans += b
      As[i] = a - b
    else:
      rest = b - a
      ans += a
      As[i] = 0
      a2 = As[i + 1]
      if a2 - rest >= 0:
         As[i + 1] -= rest
         ans += rest
      else:
         As[i + 1] = 0
         ans += a2
print(ans)


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

int main(){
    int i, x, y, z;
    for(i = 1; 1; i ++){
        cin >> x >> y;
        if(x == 0 & y == 0){
            break;
        }
        if(x > y){
            z = x;
            x = y;
            y = z;
            } 
        else{
        }     
        cout << x << " " << y << endl;
        }
    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    cout << 48 - m << '\n';
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) FOR(i, 0, n)
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define FILLINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i, a, b) ((a) <= (i) && (i) <= (b))
using namespace std;
template <typename T> inline bool CHMIN(T& a, T b) { if(a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a, T b) { if(a < b) { a = b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(begin(a), end(a)); }
template <typename T> inline void REV(T& a) { reverse(begin(a), end(a)); }
template <typename T> inline void UNI(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <typename S, typename T> inline T LB(S& v, T a) { return *lower_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int LBP(S& v, T a) { return lower_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> inline T UB(S& v, T a) { return *upper_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int UBP(S& v, T a) { return upper_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> ostream& operator << (ostream& os, const pair<S, T>& p) { os << p.first << " " << p.second; return os; }
template <typename S, typename T> istream& operator >> (istream& is, pair<S, T>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator >> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) { for(auto &e : t) fill_v(e, v); }
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const lint MOD = 1000000007;

void _main() {
    int X;
    cin >> X;
    int ans = X / 500 * 1000;
    X %= 500;
    ans += (X / 5 * 5);
    cout << ans << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

#define lld long long int
#define llu unsigned long long

int main()
{
    //freopen("input.txt", "w", stdin);

    int a,b;
    while(cin>>a>>b)
    {
        if( !(a%3) || !(b%3) || !((a+b)%3) )
            cout<<"Possible"<<endl;
        else
            cout<<"Impossible"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>
#include <map>
#include <set>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl;
typedef long long ll;
typedef vector<int> V;
typedef pair<int, int> P;
typedef map<string, int> M;

int main(){
    int n;
    cin >> n;
    int cntOdd = 0;
    int cnt4 = 0;
    for (int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        if (tmp%2 != 0)
        {
            cntOdd++;
        }
        else if (tmp%4 == 0)
        {
            cnt4++;
        }
    }
    if ((cntOdd+cnt4 == n && cntOdd-1 <= cnt4) || cntOdd <= cnt4)
    {
        OUT("Yes");
    }
    else
    {
        OUT("No");
    }
}

Measured memory_bytes: 256
function main(input) {
  const args = input.split("\n");
  const N = args[0],
    nums = args.slice(1, args.length - 1);

  // console.log(nums.filter((n, i)=> nums.indexOf(n) === i).length);
  console.log(Array.from(new Set(nums)).length);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

//union_find begin
#define MAX 5000000
struct node{  int parent,size; };
node tree[MAX];
void init(){
  for(int i=0;i<MAX;i++){
    tree[i].parent=i;
    tree[i].size=1;    
  }
}
/*
int find(int x){ 
  if(tree[x].parent==x)return x;
  tree[x].parent = find( tree[x].parent );
  return tree[x].parent;
}
*/
int find(int x){
  stack<int> st;
  while(tree[x].parent!=x){    
    st.push(x);
    x=tree[x].parent;
  }
  while(!st.empty()){
    tree[st.top()].parent=x;
    st.pop();
  }
  return x;
}

int count(int x){
  x=find(x);
  return tree[x].size;
}

bool same(int x,int y){
  return ( find(x) == find(y) );
}

void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y)return;  
  if(count(x)>count(y))swap(x,y);
  tree[x].parent=y;
  tree[y].size+=tree[x].size;
}
// union find end

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

int W,H,N,target;
char t[1005][1005];

int change(int i,int j){
  return i*W+j;
}

int solve(){
  cin>>N;
  for(int ans=1;ans<=N;ans++){
    int i,j;
    cin>>j>>i;
    if(t[i][j]=='.')continue;
    t[i][j]='.';
    for(int k=0;k<4;k++){
      int ni=i+dy[k];
      int nj=j+dx[k];
      if(ni<0 || nj<0 || H<=ni || W<=nj)continue;
      if(t[ni][nj]=='#')continue;
      unite( change(i,j) , change(ni,nj) );
    }
    if(same(target,0))return ans;
  }
  return -1;
}

int main(){
  init();
  cin>>W>>H;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>t[i][j];
      if(t[i][j]=='t')target=change(i,j);
    }
  }  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(t[i][j]=='#')continue;
      for(int k=0;k<4;k++){
        int ni=i+dy[k];
        int nj=j+dx[k];
        if(ni<0 || nj<0 || H<=ni || W<=nj)continue;
        if(t[ni][nj]=='#')continue;
        unite( change(i,j) , change(ni,nj) );
      }
    }
  }
  if( same( target , 0 ) ){
    cout<<"0"<<endl;
  }else{
    cout<<solve()<<endl;
  }  
  return 0;
}

Measured memory_bytes: 41248
#include<iostream>
#include<queue>
#include<string>
#include <algorithm>
using namespace std;

int main(){

int n,q,l;
string name;

queue<pair<string,int> >Q;

cin >> n >> q;

for(int i=1;i<=n;i++){
  cin >> name >> l ;
  Q.push(make_pair(name,l));
 }
 pair<string,int>u;
 int b=0,a;


 while(!Q.empty()){
   u=Q.front();
   Q.pop();
   a = min(u.second,q);
   u.second-=a;
   b+=a;
   if(u.second<=0){
     cout <<u.first << " " << b << endl;
   }
   else{
     Q.push(u);
   }
 }


 return 0;
}

Measured memory_bytes: 4400
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

const ll mod = 1000000007;

struct UnionFind {
  vector<ll> par, sizes;
  ll cnt;
  UnionFind(ll N) : par(N), sizes(N, 1), cnt(N) {
    for (ll i = 0; i < N; i++) par[i] = i;
  }

  ll find(ll x) { return par[x] == x ? x : par[x] = find(par[x]); }

  bool same(ll x, ll y) { return find(x) == find(y); }

  ll size(ll x) { return sizes[find(x)]; }

  void unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
    cnt--;
  }

  ll count() const { return cnt; }
};

int main() {
  ll n, m;
  cin >> n >> m;
  vP eds(m);
  rep(i, m) {
    ll u, v;
    cin >> u >> v;
    u--;
    v--;
    eds[i] = P(u, v);
  }

  UnionFind uf(n);
  vll ans(m+1);
  ans[m] = n * (n - 1) / 2;
  rep(i, m) {
    ll u, v;
    tie(u, v) = eds[m - 1 - i];
    if(!uf.same(u,v)){
      ans[m - i - 1] = ans[m - i] - uf.size(u) * uf.size(v);
      uf.unite(u, v);
    } else {
      ans[m - i - 1] = ans[m - i];
    }
  }

  rep(i, m) cout << ans[i+1] << endl;


  return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>
#include <stack>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;
const ll mmod = 998244353;

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

vector<vector<ll>> g;
vector<vector<ll>> par;
vector<vector<ll>> dp;
vector<ll> d;


int main() {
    
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    ll n, s;
    cin >> n >> s;
    vector<ll> a(n);
    
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    vector<vector<ll>> dp(n + 1, vector<ll>(3001));
    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 0; j < dp[i].size(); ++j)
        {
            dp[i][j] = dp[i - 1][j] * 2ll;
            dp[i][j] %= mmod;
            if (j >= a[i - 1])
            {
                dp[i][j] += dp[i - 1][j - a[i - 1]];
                dp[i][j] %= mmod;
            }
        }
    }
    
    cout << dp[n][s] << endl;

    
    return 0;
}

Measured memory_bytes: 73560
s = gets.chomp
n = s.size

ans = 0
for i in 0..((1 << (s.size-1))-1)
    expr = ""
    for j in 0..n-1
        expr += s[j]
        if (i >> j & 1) == 1
            expr += '+'
        end
    end
    arr = expr.split('+').map(&:to_i)
    ans += arr.inject(&:+)
end
puts ans

Measured memory_bytes: 14288
#include<stdio.h>

#define MAXLENGTH 101
int main(void)
{
	int r, c, i, j;
	int rc[MAXLENGTH][MAXLENGTH];

	scanf("%d %d", &r, &c);

	for (i = 0; i < r; i++)
	{
		for (j = 0; j < c; j++)
		{
			scanf("%d", &rc[i][j]);
			rc[i][c] = 0;
			rc[r][j] = 0;
			rc[r][c] = 0;
		}
	}

	for (i = 0; i < r; i++)
	{
		for (j = 0; j < c; j++)
		{
			rc[i][c] += rc[i][j];
			rc[r][j] += rc[i][j];
		}
	}

	for (i = 0; i < c; i++)
	{
			rc[r][c] += rc[r][i];		
	}
	for (i = 0; i <= r; i++)
	{
		for (j = 0; j < c; j++)
		{
			printf("%d ", rc[i][j]);
		}
		printf("%d\n",rc[i][c]);
	}
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string s;
  cin >> s;
  long long int n = s.size();
  long long int ans = 0;
  long long int half = n/2;

  for(long long int i = 0; i < n/2; i++) {
      if(s[i] != s[n-1-i]) {
        ans += 1;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
  n,q=map(int,input().split())
  c=list(map(int,input().split()))
  lr=[list(map(int,input().split())) for _ in range(q)]
  lri=[[lr[i][0],lr[i][1],i] for i in range(q)]
  lri.sort(key=lambda x:x[1])
  
  class BIT:
      def __init__(self, n):
          self.n = n
          self.data = [0]*(n+1)
          self.el = [0]*(n+1)
      def sum(self, i):
          s = 0
          while i > 0:
              s += self.data[i]
              i -= i & -i
          return s
      def add(self, i, x):
          # assert i > 0
          self.el[i] += x
          while i <= self.n:
              self.data[i] += x
              i += i & -i
      def get(self, i, j=None):
          if j is None:
              return self.el[i]
          return self.sum(j) - self.sum(i)

  bt=BIT(n+1)
  dc={}
  ans=[0]*q
  j=0
  for i in range(n):
    x=c[i]
    if x in dc:
      bt.add(dc[x],-1)
    bt.add(i+1,1)
    dc[x]=i+1
    while j<q and i+1==lri[j][1]:
      l,r,k=lri[j]
      ans[k]=bt.get(l-1,r)
      j+=1
    if j==q:break
  print(*ans,sep='\n')


if __name__=='__main__':
  #import datetime
  #print(datetime.datetime.now())
  main()
  #print(datetime.datetime.now())


Measured memory_bytes: 282424
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main()
{
    int K;
    cin >> K;
    ll ans = 0;
    for(int i = 1; i <= K; i++)
    {
        for(int j = 1; j <= K; j++)
        {
            for(int k = 1; k <= K; k++)
            {
                int gcd = GCD(i,j);
                ans += GCD(gcd,k);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3136
#!/usr/bin/env python3

import sys

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, is_debug):
		self.debug = is_debug
	def print(self, *arg):
		if self.debug:
			print("logger:", *arg)
	def plane(self, lst, sep=" ", space=0):
		if self.debug:
			longest = space
			for i in range(len(lst)):
				for j in range(len(lst[i])):
					longest = max(longest, len(str(lst[i][j])))
			for i in range(len(lst)):
				for j in range(len(lst[i])):
					print("logger:", " "*(longest-len(str(lst[i][j])))+str(lst[i][j]), end=sep)
				print()

def main():
	h, w = map(int, sys.stdin.readline().split())
	s = [list(sys.stdin.readline().rstrip())[::-1] for i in [0]*h][::-1]
	cost = [[0]*w for i in [0]*h]
	for y in range(h):
		for x in range(w):
			if y == 0 and x == 0:
				if s[y][x] == "#":
					cost[y][x] = 1
			elif y == 0:
				if s[y][x] == "#" and s[y][x-1] != "#":
					cost[y][x] = cost[y][x-1] + 1
				else:
					cost[y][x] = cost[y][x-1]
			elif x == 0:
				if s[y][x] == "#" and s[y-1][x] != "#":
					cost[y][x] = cost[y-1][x] + 1
				else:
					cost[y][x] = cost[y-1][x]
			else:
				if s[y][x] == "#" and s[y-1][x] != "#":
					cost[y][x] = cost[y-1][x] + 1
				else:
					cost[y][x] = cost[y-1][x]
				if s[y][x] == "#" and s[y][x-1] != "#":
					cost[y][x] = min(cost[y][x], cost[y][x-1] + 1)
				else:
					cost[y][x] = min(cost[y][x], cost[y][x-1])
	logger = Logger(0)
	logger.print(h, w)
	print(cost[h-1][w-1])

main()

Measured memory_bytes: 3444
A, B, C, D, E, F = map(int, input().split())

maxVal = 0
ans = (100 * A, 0)
for aWater in range(0, F + 1, A * 100):
    for bWater in range(0, F + 1, B * 100):
        sumWater = aWater + bWater
        if sumWater == 0 or sumWater > F:
            continue
        maxSuger = sumWater * E // 100
        for cSuger in range(0, maxSuger + 1, C):
            for dSuger in range(0, maxSuger + 1, D):
                sumSuger = cSuger + dSuger
                if sumSuger + sumWater > F or sumSuger > maxSuger:
                    break
                if maxVal < sumSuger / (sumSuger + sumWater):
                    maxVal = sumSuger / (sumSuger + sumWater)
                    ans = (sumSuger + sumWater, sumSuger)

print(*ans)

Measured memory_bytes: 42732
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    S[K-1] -= ('A'-'a');
    cout << S << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>

using namespace std;

int main () {

        long n;
        int q;
        cin >> n >> q;

        queue<string> name;
        queue<long> t;
        for (long i = 0; i < n; i++) {
                string stc;
                cin >> stc;
                name.push(stc);
                long lin;
                cin >> lin;
                t.push(lin);
        }

        long total = 0;
        while (!(t.empty())) {
                if (t.front() > q) {
                        total += q;
                        name.push(name.front());
                        name.pop();
                        t.push(t.front() - q);
                        t.pop();
                } else {
                        total += t.front();
                        cout << name.front() << " ";
                        name.pop();
                        cout << total << endl;
                        t.pop();
                }
        }

        return 0;

}

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

typedef long long ll;
// typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
const double pi = 3.141592653589793238;

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

  int len = S.size();
  stack<char> st;

  for(int i = 0; i < len; i++) {
    if(S.at(i) == 'S') {
      st.push('S');
    } else if(S.at(i) == 'T') {
      if(st.empty()) {
        st.push('T');
      } else {
        if(st.top() == 'T') st.push('T');
        if(st.top() == 'S') st.pop();
      }
    }
  }

  cout << st.size() << endl;

}


Measured memory_bytes: 644
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	ll k,n,mx=-1; 
	cin>>k>>n;
	vector<ll> arr(n);
	for(auto i=0;i<n;++i)cin>>arr[i];
	for(auto i=0;i+1<n;++i){
		mx=max(mx,arr[i+1]-arr[i]);
	}
	mx=max(mx,k-(arr[n-1]-arr[0]));
	cout<<k-mx<<'\n';
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string S, T;
	cin >> S >> T;

	bool valid = true;
	for (int i = 0; i < S.length(); i++)
	{
		if (S[i] != T[i])
		{
			valid = false;
			break;
		}
	}

	if (valid)
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 3600
#include<stdio.h>
#define NMAX 20
#define QMAX 200
int solve(int,int);
int n,n1[NMAX],q1[QMAX];
int main(){
  int i,j,q;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&n1[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&q1[i]);
  }
  for(i=0;i<q;i++){
    if(solve(0,q1[i])==1)
    printf("yes\n");
    else printf("no\n");
  }

  
 

  return 0;
}
int solve(int i,int m){
  if (m==0){
    return 1;
    }
  if(i>=n){
    return 0;
  }
  if( solve(i+1,m)==0 && solve(i+1,m-n1[i])==0)
  return 0;
  else return 1;
  
   
}



Measured memory_bytes: 2104
import heapq
n,m=map(int,input().split())
a=[int(i) for i in input().split()]
d={}
w=[]
q=[]
for i in a:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
        w.append(i)
for i in w: heapq.heappush(q, i)
for i in range(m):
    b,c=map(int,input().split())
    while b:
        if c>q[0]:
            x=min(b,d[q[0]])
            if c in d:
                d[c]+=x
                b-=x
                d[q[0]]-=x
                if d[q[0]]==0:
                    heapq.heappop(q)
            else:
                d[c]=x
                b-=x
                d[q[0]]-=x
                heapq.heappush(q,c)
                if d[q[0]]==0:
                    heapq.heappop(q)
        else:
            break
ans=chk=0
for i in d:
    ans+=i*d[i]
print(ans)

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

using namespace std;

int main()
{
    int A,B;
    cin >> A >> B;
    for (int i = 0; i < 10000; i++)
    {
        int a = i*0.08;
        int b = i*0.1;
        if(a == A && b == B)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
}

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

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 100000000

typedef  long long ll;

using namespace std;

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return r;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}
int judge(char a){
    if(a == 'a') return 0;
    else if(a == 'b') return 1;
    return 2;
}

void solve(void){
   string a,b,c;
   cin >> a >> b >> c;
   int flag = 0;
   while(true){
        if(flag == 0){
            
            if(a.size() == 0){cout << 'A';break;}
            flag = judge(a[0]);a.erase(a.begin());
        }else if(flag == 1){
            
            if(b.size() == 0){cout << 'B';break;}
            flag = judge(b[0]);b.erase(b.begin());
        }else{
            
            if(c.size() == 0){cout << 'C';break;}
            flag = judge(c[0]);c.erase(c.begin());
        }
        
      
        
   }
}

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


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

dis_max=0

for i in range(n-1):
    dis_tmp = a[i+1]-a[i]
    if dis_tmp > dis_max:
        dis_max = dis_tmp

if a[0]+(k-a[n-1]) > dis_max:
    dis_max = a[0]+(k-a[n-1])

print(k-dis_max)


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

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> ii;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vii;
typedef long double ld;
typedef vector<ld> vld;
typedef vector<vector<ld>> vvld;
typedef vector<bool> vbl;
typedef vector<vbl> mbl;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(s) (s).begin(), (s).end()
const ll MOD = 1e9 + 7;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    ll k, n;
    cin >> k >> n;
    vll arr(n);
    for (auto &it : arr)
        cin >> it, it %= k;
    ll mx = -1;
    for (int i = 0; i < n - 1; i++)
        mx = max(mx, arr[i+1] - arr[i]);
    mx = max(mx, arr[0] - arr[n-1] + k);
    cout << k - mx << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
int main(){
long X, K, D, ans=0; cin >> X >> K >> D;
long Y=abs(X), k=Y/D;
if(K<=k){ ans=Y-K*D; }
else{ 
  Y=Y-k*D; K=K-k; 
  ans=(K%2)?abs(Y-D):Y;
}
cout << ans << "\n";
}

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


int main() {
    int N;
    cin >> N;
    vector<double> x(N), y(N);
    rep(i,N) cin >> x.at(i) >> y.at(i);
    double ans = 0;
    vector<int> order;
    rep(i,N) order.push_back(i);
    int cnt = 0;
    do {
        rep(i,N-1) {
            double diffx, diffy;
            diffx = x.at(order.at(i)) - x.at(order.at(i + 1));
            diffy = y.at(order.at(i)) - y.at(order.at(i + 1));
            ans += sqrt(diffx * diffx + diffy * diffy);
        }
        ++cnt;
    } while (next_permutation(order.begin(), order.end()));
    ans /= cnt;
    cout << fixed << setprecision(9) << ans << endl;
}


Measured memory_bytes: 3784
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){
	int a,b;
	char op;
	cin>>a>>op>>b;
	while(op!='?'){
		int c;
		if(op=='+')c=a+b;
		else if(op=='-')c=a-b;
		else if(op=='*')c=a*b;
		else c=a/b;
		cout<<c<<endl;
		cin>>a>>op>>b;
	}
}



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

int main()
{
    int a,b,j,i,len;
    long long int c=0;
    cin>>a>>b;
   for(i=a;i<=b;i++){
        string str=to_string(i);
        len=str.length();
        bool flag=true;
        for(j=0;j<len/2;j++){
                if(str[j]!=str[len-j-1]){
                    flag=false;
                    break;
                }
        }
        if(flag) c++;
    }
   cout<<c;

    return 0;
}


Measured memory_bytes: 3764
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		//		//int k = Integer.parseInt(sc.next());
		//		int[] x = new int[n];
		//
		//		for (int i = 0; i < n; i++) {
		//			x[i] = Integer.parseInt(sc.next());
		//		}

		System.out.println(Math.max(0, a - (2 * b)));
		sc.close();
	}
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<iomanip>
#include<algorithm>
using namespace std;



int main() {
  int a,b,c;cin >> a >> b >> c;
  int count = 3;
  if(a==b && b == c){
    count = count - 2;
  }else if(a == b){
    count = count - 1;
  }else if(b == c){
    count = count - 1;
  }else if(c == a){
    count = count - 1;
  }
  cout << count << endl;

  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end());
  int x=0,y=0;
  for(int i=n-1;i>=0;i-=2){
    x+=a[i];
  }
  for(int i=n-2;i>=0;i-=2){
    y+=a[i];
  }
  cout<<x-y<<endl;

  return 0;
}


Measured memory_bytes: 256