akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x=max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<pii>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,sz(v))i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(sz(v))o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
template <class T> inline ll suma(const v(T)& a) 
{ ll res(0); for(auto&& x:a) res += x; return res;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
const int MX = 200005;
//----------------------------------------------------------------

#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
#define MOD 1000000007
//----------------------------------------------------------------
void Main(){
  int n;
  cin>>n;
  v(pll) x(n);
  cin>>x;
  sort(rng(x));
  ll right = -LINF;
  int ans = 0;
  rep(i,n){
    if(right <= x[i].fi - x[i].se){
      right = x[i].fi + x[i].se;
      ans++;
    }else{
      mins(right,x[i].fi+x[i].se);
    }
  }
  cout<<ans;
} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<queue>
#define MN 100000
#define ll long long
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
char s[MN+5],t[MN+5];
int Q,a[MN+5],b[MN+5];
int main()
{
    scanf("%s%s",s+1,t+1);
    for(int i=1;s[i];++i) a[i]=a[i-1]+s[i]-'A'+1;
    for(int i=1;t[i];++i) b[i]=b[i-1]+t[i]-'A'+1;
    for(Q=read();Q--;)
    {
        int l=read(),r=read(),L=read(),R=read();
        puts((a[r]-a[l-1]-b[R]+b[L-1])%3==0?"YES":"NO");
    }
    return 0;
}


Measured memory_bytes: 1536
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, H);
    IN(ll, W);
    vs s(H + 1, ".");
    REP(i, W)
    {
        s[0].push_back('.');
    }
    REP1(i, H)
    {
        string r;
        cin >> r;
        s[i] += r;
    }
    vvi dp(H + 1, vi(W + 1, INF));
    dp[1][1] = (s[1][1] == '#');

    REP1(i, H)
    {
        REP1(j, W)
        {
            if (i == 1 and j == 1)
            {
                continue;
            }
            dp[i][j] = min(dp[i - 1][j] + (s[i - 1][j] == '.' and s[i][j] == '#'), dp[i][j - 1] + (s[i][j - 1] == '.' and s[i][j] == '#'));
        }
    }
    OUT(dp[H][W]);
}

Measured memory_bytes: 384
#define LOCAL

#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>

using namespace std;

// From Errichto's Youtube stream
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////

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

    string S;
    cin >> S;
    int N = S.size();

    bool losing = true;
    for (int i = 1; i + 1 < N; i++) {
        if (S[i-1] != S[i+1])
            losing = false;
    }

    if (losing) {
        cout << "Second\n";
        return 0;
    }

    int parity = N & 1;

    if (S.front() != S.back()) {
        cout << (parity ? "First\n" : "Second\n");
    } else {
        cout << (!parity ? "First\n" : "Second\n");
    }

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <list>
#include <stack>
#include <climits>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#define m7 1000000007
#define m9 1000000009
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second

using namespace std;
int dp[1 << 22 + 1][21], allmask, X[21][21];
int n;

int solve(int mask,int pre_man) {
	if (mask == allmask) 
		return 1;
	if (pre_man == n || mask > allmask)
		return 0;
	if (dp[mask][pre_man] != -1) return dp[mask][pre_man];
	
	dp[mask][pre_man] = 0;
	
	for (int i = 0; i < n; i++) {
		if (X[pre_man][i] && !(mask & (1<<i)) ) {
			dp[mask][pre_man] = (dp[mask][pre_man] + solve( mask | (1 << i) ,pre_man + 1) ) % m7;
		}
	}
	//cout << mask << ' ' << pre_man <<' '<< dp[mask][pre_man] << endl;
	return dp[mask][pre_man];
}
int main()
{
	memset(dp, -1, sizeof dp);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
			cin >> X[i][j];
	}
	allmask = (1 << n) - 1;
	cout<<solve(0, 0);

	

	return 0;
}


Measured memory_bytes: 688384
/*
Hanit Banga
*/

#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e3 + 5, mod = 1e9 + 7;

ll ctr[N] = {0};

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

	for (int i = 2; i <= n; ++i)
	{
		int sq = sqrt(i), temp = i;
		for (int j = 2; j <= sq; ++j)
		{
			while (temp % j == 0)
			{
				temp /= j;
				ctr[j]++;
			}
		}
		if (temp > 1)
			ctr[temp]++;
	}

	ll ans = 1;
	for (int i = 1; i <= n; ++i)
		ans = (ans * (ctr[i]+1)) % mod;
	
	cout << ans;
}

Measured memory_bytes: 256
// finish date: 2018/04/13

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    int N;
    cin >> N;
    vi a(3 * N);
    rep(i, 3 * N) cin >> a[i];
    sort(a.begin(), a.end());
    ll ans = 0;
    int c = 0;
    for (int i = 3 * N - 2; i > 0; i -= 2) {
        ans += a[i];
        c++;
        if (c >= N) break;
    }
    cout << ans << endl;

    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
typedef pair<long long, long long> pll; // 砂糖, 水

bool operator < (pll a, pll b) {
  return a.first * (b.first + b.second) < b.first * (a.first + a.second);
}
// Problem Specific Parameter:

int main() {
  int A, B, C, D, E, F; cin >> A >> B >> C >> D >> E >> F;
  pll res = pll(0, A*100);
  for (long long a = 0; a <= F; a += A*100) {
    for (long long b = 0; a + b <= F; b += B*100) {
      long long water = a + b;
      long long maxsugar = min(F - a - b, E * (water / 100));

      for (long long c = 0; c <= maxsugar; c += C) {
        for (long long d = 0; c + d <= maxsugar; d += D) {
          long long sugar = c + d;

          pll tmp = pll(sugar, water);
          chmax(res, tmp);
        }
      }
    }
  }
  cout << res.first + res.second << " " << res.first << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main(){
ll n;
cin>>n;
ll sum=0;
for(int i=1;i<=n;i++){
    if(ketasuu(i)%2>0){
        sum++;
    }
}
cout<<sum<<endl;
}










Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

void outPut(int Array[],char mark){
	for(int i = 1; i <= 13; i++){
		if(Array[i] == 0) printf("%c %d\n",mark,i);
	}
}

int main(){
	char mark[2];
	int n,S[14],H[14],C[14],D[14],tmp;
	for(int i = 0; i < 14; i++) S[i] = H[i] = C[i] = D[i] = 0;
	scanf("%d",&n);

	for(int i = 0; i < n; i++){
		scanf("%s %d",mark,&tmp);
		switch(mark[0]){
		case 'S':
			S[tmp] = 1;
			break;
		case 'H':
			H[tmp] = 1;
			break;
		case 'C':
			C[tmp] = 1;
			break;
		case 'D':
			D[tmp] = 1;
			break;
		}
	}
	outPut(S,'S');
	outPut(H,'H');
	outPut(C,'C');
	outPut(D,'D');
}



Measured memory_bytes: 2616
n,x=input().split()
l=input().split()
l.insert(0,0)
a=0
flag=0
for i in range(int(n)+1):
   a=a+int(l[i])
   #print(a)
   if a>int(x):
       print(i)
       flag=1
       break
if flag==0:
    print(int(n)+1)



Measured memory_bytes: 2940
<?php

// define('DEBUG', true);
define('DEBUG', false);

$TT = 0;
$AA = 0;

fscanf(STDIN, "%d", $N);
for ($i = 0; $i < $N; $i++) {
	fscanf(STDIN, "%d %d", $T, $A);
	if (DEBUG) {
		printf("T:%d A:%d\n", $T, $A);
	}

	if ($TT <= $T && $AA <= $A) {
		$TT = $T;
		$AA = $A;
	} else {
		$ratioT = odiv($TT, $T);
		$ratioA = odiv($AA, $A);
		$mmax = max($ratioT, $ratioA);
		$ratio = $mmax;
		$TT = omulti(strval($T), strval($ratio));
		$AA = omulti(strval($A), strval($ratio));
	}
	if (DEBUG) {
		printf("=> TT:%d AA:%d ratio:%20f ratioT:%.20f ratioA:%.20f\n", $TT, $AA, $ratio, $ratioT, $ratioA);
	}

}
printf("%d\n", $TT + $AA);

function omulti($a, $b) {
	$aa = str_split(strval($a));
	$bb = str_split(strval($b));
	foreach ($aa as $ka => $va) {
		foreach ($bb as $kb => $vb) {
			$res[$ka + $kb + 1] += intval($va) * intval($vb);
		}
	}
	for ($i = max(array_keys($res)); $i > 0; $i--) {
		if ($res[$i] > 9) {
			$res[$i - 1] += floor($res[$i] / 10);
			$res[$i] %= 10;
		}

	}
	ksort($res);
	return implode("", $res);
}

function odiv($a, $b) {
	$aa = str_split(strval($a));
	$bb = str_split(strval($b));
	$num = 0;
	$ret = "";
	for ($i = 0; $i < count($aa); $i++) {
		$num = $num * 10 + intval($aa[$i]);
		$tmp = 0;
		while ($num >= intval($b)) {
			$tmp++;
			$num -= intval($b);
		}
		if ($tmp == 0) {
			if ($ret != "") {
				$ret .= strval($tmp);
			}
		} else {
			$ret .= strval($tmp);
		}
	}
	if ($num != 0) {
		$ret++;
	}
	return $ret == "" ? "0" : $ret;
}


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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    for(int i=0; i<100;i++){
       c=c-b;
        if(c<=0){
            cout << "Yes" << endl;
            break;
        }

        a=a-d;
        if(a<=0){
            cout <<"No"<< endl;
            break;
        }
        
    }
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if ( (A + B) > (C + D) ) {
    cout << "Left" << endl;
  }
  else if ( (A + B) == (C + D) ) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <map>
using namespace std;

int n;
map<char, int> ctoi;
map<int, char> itoc;

void init(){
  ctoi['m'] = 1000;
  ctoi['c'] = 100;
  ctoi['x'] = 10;
  ctoi['i'] = 1;
  itoc[1000] = 'm';
  itoc[100] = 'c';
  itoc[10] = 'x';
  itoc[1] = 'i';
}

int mcxitoarab(string mcxi){
  string::iterator it;
  int num = 0, tmp;
  for(it = mcxi.begin(); it != mcxi.end(); it++){
    if(isalpha(*it)){
      tmp = ctoi[*it];
      if(isdigit(*(it - 1))){
        tmp *= *(it - 1) - '0';
      }
      num += tmp;
    }
  }
  return num;
}

string arabtomcxi(int num){
  string str;
  int N = 1000, tmp;
  while(num != 0){
    if((num / N) == 0){
      N /= 10;
      continue;
    }
    if((num / N) != 1) str += (num / N) + '0';
    str += itoc[N];
    num %= N;
    N /= 10;
  }
  return str;
}

int main(void){
  string opr1, opr2;
  cin >> n;
  init();
  for(int i = 0; i < n; i++){
    cin >> opr1 >> opr2;
    int op1 = mcxitoarab(opr1), op2 = mcxitoarab(opr2);
    int sum = op1 + op2;
    //cout << op1 << " + " << op2 << " = " << sum << endl;
    cout << arabtomcxi(sum) << endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include<stdio.h>
int main(void){
    int a=1,b=0,c=0,d;
    char x,y;
    while(scanf("%c,%c ",&x,&y)!=EOF){
        if((x=='A' && y=='B')||(x=='B' && y=='A')){
            d=a;
            a=b;
            b=d;
        }else if((x=='A' && y=='C')||(x=='C' && y=='A')){
            d=a;
            a=c;
            c=d;
        }else if((x=='B' && y=='C')||(x=='C' && y=='B')){
            d=b;
            b=c;
            c=d;
        }
    }
    if(a==1){
        printf("A\n");
    }else if(b==1){
        printf("B\n");
    }else if(c==1){
        printf("C\n");
    }
    return 0;
}

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

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	for (int i = 0; i < s.size()-1; ++i){
		if (s[i] == s[i+1]){
			cout << "no" << "\n";
			return 0;
		}
	}
	cout << "yes" << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
int main() {
    int N;
    cin >> N;
    map<i64, int, greater<i64>> x;
    for(int i = 0; i < N; i++) {
        i64 a;
        cin >> a;
        x[a]++;
    }
    int ans = 0;
    for(auto p : x) {
        i64 a; int n;
        tie(a, n) = p;
        if( (a & (a - 1)) == 0) {
            ans += n / 2;
        } else {
            int s = 1;
            while(s < a) s <<= 1;
            int m = x[s - a];
            x[s - a] -= min(n, m);
            ans += min(n, m);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 85504
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
typedef long long ll;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

int main(){
    int x;
    cin >> x;
    if(x==3||x==5||x==7){
        cout << "YES" << endl;
        return 0;
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc084c()
}

private data class Station(val takeTime: Int, val first: Int, val interval: Int)

fun abc084c() {
    val n = readLine()!!.toInt()
    val stations = (1 until n).map { readLine()!!.split(" ").map { it.toInt() } }
        .map { Station(it[0], it[1], it[2]) }

    val times = mutableListOf<Long>()
    for (i in 0 until n) {
        var time = 0L
        (i until n - 1).forEach {
            val nextStation = stations[it]
            when {
                time < nextStation.first -> time = nextStation.first.toLong()
                time % nextStation.interval == 0L -> Unit
                else -> time = time + nextStation.interval - time % nextStation.interval
            }
            time += nextStation.takeTime
        }
        times.add(time)
    }

    println(times.joinToString(separator = System.lineSeparator()))
}


Measured memory_bytes: 40760
#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 k;
  string s;
  cin >> k >> s;
  if(k >= s.size()){
    cout << s << endl;
  }
  else
    cout << s.substr(0,k) << "..." << endl;
}


Measured memory_bytes: 3624
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long MOD = 10^^9 + 7;

void main() {
    auto S = readln.chomp;
    auto N = S.length.to!int;
    auto dp = new long[][](N+1, 4); // Aの数, ABの数, ABCの数
    dp[0][0] = 1;

    foreach (i; 0..N) {
        foreach (j; 0..4) {
            dp[i+1][j] = S[i] == '?' ? dp[i][j] * 3 % MOD : dp[i][j];
        }
        if (S[i] == 'A' || S[i] == '?') {
            (dp[i+1][1] += dp[i][0]) %= MOD;
        }
        if (S[i] == 'B' || S[i] == '?') {
            (dp[i+1][2] += dp[i][1]) %= MOD;
        }
        if (S[i] == 'C' || S[i] == '?') {
            (dp[i+1][3] += dp[i][2]) %= MOD;
        }
    }

    dp[N][3].writeln;
}


Measured memory_bytes: 11800
#include <iostream>
using namespace std;
int main(){
        int n;
        cin>>n;
        for(int k=1;k<=n;k++)
        if(k%3==0||k%10==3||k/10==3||k/100==3||k/1000==3||k/10%10==3||k/100%10==3){
                cout<<" ";
                cout<<k;
        }
        cout<<endl;
        
}
//k/10%10==3||
//131??¨???

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

int main()
{
	const int mod=1e9+7;
	int N,A;
	int list[100010]={};
	int ans=1;
	
	cin >> N;
	for(int i=0;i<N;i++)
	{
		cin >> A;
		list[A]++;
	}
	
	if(N%2==0 && list[0]>0)
	{
		cout << 0 << endl;
		return 0;
	}
	if(N%2==1 && list[0]!=1)
	{
		cout << 0 << endl;
		return 0;
	}
		
	for(int i=1;i<N;i++)
	{
		if(list[i]==2)
		{
			ans*=2;
			ans%=mod;
		}
		if(list[i]%2==1 || list[i]>2)
		{
			cout << 0 << endl;
			return 0;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] A = new int[n][m];
		int[] b = new int[m];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		for(int k =0; k < m; k++) {
			b[k] = sc.nextInt();
		}
		
		int[] c = new int[n];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				c[i] += A[i][j] * b[j];
			}
		}
		for (int ans : c)System.out.println(ans);
		sc.close();
	}
}



Measured memory_bytes: 40952
def solve():
    _ = int(input())
    a = list(map(int, input().split()))
    
    counter = [0] * 9
    for ai in a:
        counter[min(8, ai // 400)] += 1
    
    ans_min = 0
    for i in range(8):
        if 0 < counter[i]:
            ans_min += 1
    
    ans_max = ans_min + counter[-1]
    if ans_min == 0:
        ans_min = 1
    print(ans_min, ans_max)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
import Control.Monad
import Data.List
main = do
  [n, a, b] <- words <$> getLine
  putStrLn.show $ solved a b n

cho:: Int -> [String]
cho n = map show [x | x <- [1..n] ]

parse:: String -> [Int]
parse str = map (read . return) str

hoge s = zip [1..10000] $ map (foldl (+) 0) $ map parse $ cho $ read s

fi:: Int -> Int -> (Int, Int) -> Bool
fi a b z
  | a <= zr && zr <= b = True
  | otherwise = False
  where
    zr = snd z

solved:: String -> String -> String -> Int
solved a b s = do
   foldl (+) 0 $ map fst $ filter (fi (read a) (read b)) $ hoge s


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

int a,b,c;

int main()
{
	scanf("%d %d %d",&a,&b,&c);
	if(a==b) {
		if(a==c) puts("No");
		else puts("Yes");
	}
	else if(a==c||b==c) {
		puts("Yes");
	}
	else puts("No");
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
using pii = pair<int, int>;
using lli = long long int;
vector<lli> visit;
vector<bool> visited;
void dfs(vector<vector<pii> > &g, vector<lli> &val, int v){
  if(visited[v])return;
  visit.push_back(v);
  visited[v] = true;
  for (int i = 0; i < g[v].size(); i++) {
    int u = g[v][i].first;
    if(visited[u])continue;
    val[u] = g[v][i].second - val[v];
    dfs(g, val, u);
  }
}

int main(){
  int r, c, n;
  std::cin >> r >> c >> n;
  vector<vector<pii> > g(r + c);
  for (int i = 0; i < n; i++) {
    int x, y, a;
    std::cin >> y >> x >> a;
    y--, x--;
    g[y].push_back(pii(x + r, a));
    g[x + r].push_back(pii(y, a));
  }
  vector<lli> val(r + c, 1e9);
  visited.resize(r + c, false);
  for (int i = 0; i < r + c; i++) {
    if(visited[i])continue;
    visit.clear();
    val[i] = 0;
    dfs(g, val, i);
    lli xmin = 1e10, ymin = 1e10;
    for (int j = 0; j < visit.size(); j++){
      if(visit[j] >= r) xmin = min(xmin, val[visit[j]]);
      else ymin = min(ymin, val[visit[j]]);
    }
    if(xmin + ymin < 0){
      std::cout << "No" << std::endl;
      return 0;
    }
  }
  for (int i = 0; i < g.size(); i++) {
    for (int j = 0; j < g[i].size(); j++) {
      if(val[i] + val[g[i][j].first] != g[i][j].second){
      std::cout << "No" << std::endl;
      return 0;

      }
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}


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

using namespace std;

int main(){
    int N, count=0;


    //入力
    cin >> N;
    vector<int> L(N);
    for(int i=0; i<N; i++){
        cin >> L[i];
    }

    //cout << "dfd" << endl;

    sort(L.begin(), L.end() ,greater<int>());
    

    for(int i=0; i<N-2; i++) {
        for(int j=i+1; j<N-1; j++) {
            for(int k=j+1; k<N; k++)  {
                if(L[i] - L[j] < L[k]){
                    count++;
                }
                //cout << i << " " << j << " " << k << " " << count << endl;
            }
            
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#  n= int(input())
# import math
# s =input()
n,m = map(int, input().split())
a = list(map(int, input().split()))
# a,b = map(str, input().split())
# ab = [list(map(int,input().split())) for _ in range(n)]

if n -sum(a) < 0 :
    print(-1)
else:
    print(n-sum(a))

Measured memory_bytes: 9880
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a+b < c+d) {
    cout << "Right";
  }
  else if (a+b == c+d) {
    cout << "Balanced";
  }
  else {
    cout << "Left";
  }
}

Measured memory_bytes: 256
N = int(input())
T,A = map(int,input().split())
H = [int(n) for n in input().split()]

min_t = 10**5
min_i = 0

for i in range(N):
    t = abs(A - (T - H[i]*0.006))
    if t <= min_t:
        min_t = t
        min_i = i


print(min_i+1)

Measured memory_bytes: 9264
S = list(input())
result = 'Yes'
for i in range(len(S)):
    if(i%2 != 0):
        if(S[i] != 'L' and S[i] != 'U' and S[i] != 'D'):
            
            result = 'No'
            break
    else:
        if(S[i] != 'R'and S[i] != 'U' and S[i] != 'D'):
            
            result = 'No'
            break

print(result)

Measured memory_bytes: 3060
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 

long long dp[51][51][3000]={};

int main(){

	int a,b;
	cin>>a>>b;

	if(a==b){
		cout<<"Draw"<<endl;
	}else if(a==1 || (b!=1 && b<a)){
		cout<<"Alice"<<endl;
	}else{
		cout<<"Bob"<<endl;
	}

}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/23  Problem: 080_abc_d / Link: https://abc080.contest.atcoder.jp/tasks/abc080_d?lang=en  ----- */
/* ------問題------

joisinoお姉ちゃんは、録画機を用いて N 個のテレビ番組を録画しようとしています。
テレビが受信できるチャンネルは C 個あり、1 から C までの番号がついています。
joisinoお姉ちゃんの録画したいテレビ番組のうち、i 個目のテレビ番組は、時刻 si から時刻 ti まで、チャンネル ci で放送されます。(ただし時刻 si を含み、時刻 ti を除く)
ただし、同じチャンネルで複数のテレビ番組が同時に放送されることはありません。
また、録画機は、あるチャンネルの時刻 S から時刻 T までを録画するとき、時刻 S−0.5 から時刻 T までの間、他のチャンネルの録画に使うことができません。(ただし時刻 S−0.5を含み、時刻 T を除く)
N 個のテレビ番組の全ての放送内容が含まれるように録画するとき、必要な録画機の最小個数を求めてください。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N,C;

LL ans = 0LL;

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

	cin >> N>>C;
	VVI m(C, VI(2e5 + 10, 0));
	FOR(i, 0, N) {
		int s, t, c;
		cin >> s >> t >> c;
		m[c - 1][2*s-1]++;
		m[c - 1][2*t]--;
	}
	FOR(i, 0, C) {
		FOR(j, 0, 2e5) {
			m[i][j + 1] += m[i][j];
		}
	}
	FOR(i, 0, C) {
		FOR(j, 0, 2e5) {
			if (m[i][j])m[i][j] = 1;
		}
	}
	FOR(i, 0, 2e5) {
		LL cnt = 0;
		FOR(c, 0, C) {
			cnt += m[c][i];
		}
		ans = max(ans, cnt);
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 24576
#include <stdio.h>
int main (void){
int a[10000],i=0,n=0,j;
a[0]=32;
while(a[i]!=0){
	i++;
	n++;
	scanf("%d",&a[i]);
}
for(j=1;j<n;j++){
	printf("Case %d: %d\n", j,a[j]);
}



return 0;
}

Measured memory_bytes: 1704
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
     int n;
     cin >> n;
     vector<int> v;
     for(int i = 0; i < 2 * n; i++){
	   int x;
	   cin >> x;
	   v.push_back(x);	
	 }
	 sort(all(v));
	 int ret = 0;
	 for(int i = 0; i < 2 * n; i += 2){
	    ret += v[i];	 
     }
     cout << ret << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 256
//ITP1_5_C
//

using System;
using System.Collections.Generic;



class Program
{
    static void Main(string[] args)
    {
        int[] h = new int[50];
        int[] w = new int[50];

        int count = 0;

        while (true)
        {
            //?????????????????????????????????int??????iaaray????????????????????\

            int[] iarray = Array.ConvertAll<string, int>((Console.ReadLine().Split(' ')), delegate (string value)
            {
                return int.Parse(value);
            });

            //???????????°??????????´?

            h[count] = iarray[0];
            w[count] = iarray[1];

            if (h[count] == 0 && w[count] == 0)
                break;
            count++;

        }

        for (int c = 0; c < count; c++)             //?????§?????????????§?????????????????????????
        {
            for (int i = 1; i <= h[c]; i++)         //???????????????
            {
                for (int j = 1; j <= w[c]; j++)     //?¨?????????????
                {                   
                    if (i % 2 == 1)
                    {
                        if(j % 2 == 1)              //?\???°???????\???°??????#???????????\?????????.?????????
                            Console.Write("#");
                        else
                            Console.Write(".");
                    }
                    else
                    {
                        if (j % 2 == 0)             //??¶??°????????¶??°??????#???????????\?????????.?????????
                            Console.Write("#");
                        else
                            Console.Write(".");
                    }
                }
                Console.Write("\r\n");
            }
            Console.Write("\r\n");
        }

    }
}

Measured memory_bytes: 8948
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>

using namespace std;

bool sorted(int n, int* p) {
    int old = INT_MIN;
    for (int i=0; i<n; i++) {
        if (old > *(p+i)) {
            return false;
        }
        old = *(p+i);
    }
    return true;
}

int ill(int n, int* p) {
    int old = INT_MIN;
    for (int i=0; i<n; i++) {
        if (old > *(p+i)) {
            return i-1;
        }
        old = *(p+i);
    }
    return -1;
}

int printarr(int n, int* p) {
    for (int i=0; i<n; i++) {
        cerr << *(p+i) << " ";
    }
    cerr << endl;
}

int main() {
    int n;
    int p[50];
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> p[i];
    }

    if (sorted(n, p)) {
        cout << "YES";
        return 0;
    }

    int ip = ill(n, p);
    cerr << ip << endl;

    for (int i=0; i<n; i++) {
        if (i == ip) continue;
        int tmp = p[i];
        p[i] = p[ip];
        p[ip] = tmp;
        printarr(n, p);
        if (sorted(n, p)) {
            cout << "YES";
            return 0;
        }
        p[ip] = p[i];
        p[i] = tmp;
    }

    cout << "NO";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n, a, b;
	scanf("%d %d %d", &n, &a, &b);
	int sum = 0;
	for(int i = 1; i <= n; i++){
		int numSum = 0;
		int temp = i;
		while(temp > 0){
			numSum = numSum + (temp % 10);
			temp = temp / 10;
		}
		if(numSum >= a && numSum <= b){
			sum += i;
		}
	}
	printf("%d", sum);
	return 0;
}

Measured memory_bytes: 1700
from fractions import gcd

n, m = map(int, input().split())

s = input()
t = input()

# accept
# a c p
# a  e

g = gcd(n, m)
a = n // g
b = m // g
for i in range(g):
    if s[i*a] != t[i*b]:
        print(-1)
        exit()

print(n*m//g)


Measured memory_bytes: 5436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    ll N,M;
    string S;
    cin >> N >> M >> S;
    reverse(S.begin(),S.end());
    vector<ll> ans;
    int now=0;
    while(now<N){
        for (int i=M;i>=1;--i){
            if (S[now+i]=='0'){
                ans.push_back(i);
                now+=i;
                break;
            }
            if (i==1){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    reverse(ans.begin(),ans.end());
    for (auto x:ans) cout << x << ' ';
}

Measured memory_bytes: 1528
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==================================================================
    public void solve() {
    	char[] C = sc.next().toCharArray();
    	int ans = 0;
    	for (int i = 0; i < C.length / 2; i++) {
//    		out.println("C[" + i + "] = " + C[i]);
//    		out.println("C[" + (C.length - i - 1) + "] = " + C[C.length - i - 1]);
			if(C[i] != C[C.length - i - 1])		ans++;
		}
    	out.println(ans);
    }
    // ==================================================================
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,x) for(int i=(n);i<(x);++i)
#define rem(i,n,x) for(int i=(n);i>=(x);--i)
#define SORT(x) sort(x.begin(),x.end())
#define RSORT(x) sort(x.rbegin(),x.rend())
#define rev(x) reverse(x.begin(),x.end())
#define al(x) x.begin(),x.end()
#define pb push_back
#define setp(x) setprecision(x)
using ll = long long;

int main() {
	string s; cin >> s;
	
	int c = 0;
	rep(i, 0, s.size()/2) {
		if (s[i] != s[s.size() - i - 1]) c++;
	}

	cout << c << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
	Scanner sc = new Scanner(in);
	int a=sc.nextInt();
	int b=sc.nextInt();
	int c=sc.nextInt();
	HashMap<Integer,Integer> map=new HashMap<>();
	map.put(a,map.getOrDefault(a,0)+1);
	map.put(b,map.getOrDefault(b,0)+1);
	map.put(c,map.getOrDefault(c,0)+1);
	if(map.get(5)==2&&map.get(7)==1){
	    out.println("YES");
	}else{
	    out.println("NO");
	}
    }
}

Measured memory_bytes: 21076
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(2*b<a)
	printf("%d\n",a-2*b);
	else
	printf("0\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <sstream>
#include <set>
using namespace std;

int main() {
  int q;
  cin >> q;
  while(q--) {
    string s;
    cin >> s;
    int size = s.size();
    int res, ans = 0;
    bool f = true;
    set<int> set1;
    set1.insert(atoi(s.c_str()));
    while(size > 1) {
      res = 0;
      for(int i=0; i<size-1; i++) {
	string a = s.substr(0, i+1);
	string b = s.substr(i+1);
	res = max(atoi(a.c_str())*atoi(b.c_str()), res);
      }
      if(set1.count(res)) { f = false; break; }
      set1.insert(res);
      stringstream ss; ss << res; s = ss.str();
      size = s.size();
      ans ++;
    }
    cout << ( f ? ans : -1 ) << endl;
  }
  
  return 0;
}

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

#define MAX_N 20
#define MAX_M 2100

bool solve(vector<int> &A, int i, int m){
    if( i == A.size() )
        return m==0;

    return solve( A, i+1, m-A[i]) || solve( A, i+1, m);
}

int main()
{

    int n;
    cin >> n;
    vector<int> A(n,0);
    for(auto&& x: A){
        cin >> x;
    }

    int q;
    cin >> q;
    for(int i=0; i<q; i++){
        int m;
        cin >> m;
        cout << (solve(A,0,m) ? "yes" : "no") << endl;
    }

}


Measured memory_bytes: 3104
#include<stdio.h>
int main(void)
{
	int x,y,flg,t,k,i;
	flg=0;
	scanf("%d %d",&x,&y);
	for(i=0;i<=x;i++){
		t=i;
		k=x-i;
		if(t*2+k*4==y){
			flg=1;
		}
	}
	if(flg==1){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1632
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


int main()
{

  int N, K;
  cin >> N >> K;

  int a;

  int r = 0;
  int right, left;
  for (int i = 0; i < N; ++i) {
    cin >> a;
    if (a == 1) {
      left  = i;
      right = N - i - 1;
    }
  }


  int left_min  = left / (K-1);
  int right_min = right / (K - 1);

  int left_amari = left % (K - 1);
  int right_amari = right % (K - 1);

  int amari_sum = (left_amari + right_amari);
  int amari_num = amari_sum > 0 ?  
                      ((amari_sum-1) / (K - 1)) + 1
    : 0
    ;

  cout << left_min + right_min + amari_num << '\n';
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	
	int n;
	string s;
	cin >> n >> s;
	set<int> lucky;
	int dig1, dig2, dig3;
	for(int i = 0; i < 10; i++){
		for(int j = 0; j < 10; j++){
			for(int k = 0; k < 10; k++){
				int now = 0;
				for(int l = 0; l < n; l++){
					if(now == 0){
						if(s[l] == i + '0'){
							dig1 =  (int) (s[l] - '0') * 100;
							now++;
						}
					}else if(now == 1){
						if(s[l] == j + '0'){
							dig2 =  (int) (s[l] - '0') * 10;
							now++;
						}
					}else{
						if(s[l] == k + '0'){
							int num = dig1 + dig2 + (int) (s[l] - '0');
							lucky.insert(num);
							break;
						}
					}
					
				}
			}
		}
	}
	cout << lucky.size() << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

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

Measured memory_bytes: 256
def main():
    S = input()

    if 1 <= int(S[0:2]) <= 12 and 1 <= int(S[2:4]) <= 12:
        print("AMBIGUOUS")
    elif 1 <= int(S[0:2]) <= 12:
        print("MMYY")
    elif 1 <= int(S[2:4]) <= 12:
        print("YYMM")
    else:
        print("NA")


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
A=int(input())
B=int(input())
C=int(input())
X=int(input())

ans = 0
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if 500 * a + 100 * b + 50 * c == X:
                ans += 1

print(ans)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication8
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] vals = Console.ReadLine().Split(' ').Select(tmp => long.Parse(tmp)).ToArray();
            
            if (vals[3] <= vals[0]) {
                Console.WriteLine(vals[3]);
            }
            else if (vals[3] <= vals[0] + vals[1])
            {
                Console.WriteLine(vals[0]);
            }
            else {
                Console.WriteLine(2*vals[0]+vals[1]-vals[3]);
            }


        }
    }
}


Measured memory_bytes: 28124
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) printf("Case #%d: ",i);
using namespace std;
typedef long long int ll;
typedef complex<double> com;
typedef pair<int, int> P;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;



int main(){
	ll k; cin >> k;
	printf("50\n");
	rep(i, 0, 50) printf("%lld ", 49 - i + (k + 49 - i) / 50);
	return 0;
}

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

s_A = 0
s_B = 0
for i in range(N):
    if i % 2 == 0:
        s_A += a[i]
    elif i % 2 == 1:
        s_B += a[i]

print(s_A - s_B)

Measured memory_bytes: 3060
#include <stdio.h>
#include<math.h>//
int main(void){
    int n,p,max=0,sum;
    int i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&p);
        if(p>max){
            sum+=p/2;
            sum+=max/2;
            max=p;
        }else{
            sum+=p;
        }
    }
    printf("%d",sum);
}


Measured memory_bytes: 128