akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
typedef long long ll;
typedef double ld;
const ld eps = 1e-7;
#define sqr(x) (x)*(x)
#define sz(x) ((x).size())
#define TASK ""
const ll MOD = 2999999989LL;
const ll BASE = 43;
#define hash hrescgwx

int run() {
    ll n;
    cin >> n;
    ll a, b;
    cin >> a >> b;
    ll t = __gcd(a, b);
    a /= t;
    b /= t;
    for (int i = 1; i < n; ++i) {
        ll c, d;
        cin >> c >> d;
        t = __gcd(c, d);
        c /= t;
        d /= t;
        ll cnt1 = (a + c - 1) / c;
        ll cnt2 = (b + d - 1) / d;
        ll cnt = max(cnt1, cnt2);
        a = cnt * c;
        b = cnt * d;
        //cerr << a << " " << b << endl;
    }
    cout << a + b;
}

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

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    if(strlen(TASK)!=0)
    {
        freopen(TASK".in", "r", stdin);
        freopen(TASK".out", "w", stdout);
    }
#endif
    run();
    return 0;
}

Measured memory_bytes: 256
s = input()

c = []
f = s[0]
count = 1
for si in list(s):
  if f != si:
    count += 1
    c.append(count)
    f = si
  else:
    c.append(count)

stone_count = len(set(c))
if stone_count == 2:
  print(1)
  exit()

if stone_count == 1:
  print(0)
  exit()
  
print(stone_count - 1)

Measured memory_bytes: 13796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

int main(){
    string T; cin>>T;
    ll ans=0;
    rep(i,0,T.size()){
        if(i!=T.size()-1 && T[i+1]=='?' && T[i]=='P')      T[i+1]='D';
        else if(i!=T.size()-1 && T[i]=='?' && T[i+1]=='D') T[i]='P';
      	else if(i!=T.size()-1 && T[i]=='?' && T[i+1]=='?'){T[i]='P';T[i+1]='D';}        
  		else if(T[i]=='?')T[i]='D';
    }
    cout<<T<<endl;
    return 0;
}

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


int a[100002];
int ans[100002];
int main() {
   int n;
   cin >> n;
   int i;
   for(i=1;i<=n;i++) cin >>a[i];
   
   ans[n] = 1;
   int fa = 1;
   for(i=n-1;i>=1;i--) {
       if(a[i]>=a[i+1]) ans[i]  = ans[i+1]+1;
       else
        ans[i] = 1;
    fa = max(fa, ans[i]);
   }
   cout<<fa-1<<"\n";
	return 0;
}

Measured memory_bytes: 1024
A,B=map(int,input().split())
number=[str(i) for i in range(10)]
S=input()

for i in range(A):
    if not S[i] in number:
        print("No")
        exit()

if S[A]!="-":
    print("No")
    exit()

for i in range(A+1,A+B+1):
    if not S[i] in number:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef vector <string> vs;

vs split(const string &text, char delim=' '){
	int p1 = 0, p2 = 0;
	vs tokens;

	for (int i=0; i<(int)text.size(); i++)
		if (text[i] == delim){
			p2 = i;
			tokens.push_back(text.substr(p1, p2 - p1));
			p1 = p2 + 1;
		}
	tokens.push_back(text.substr(p1));
	return tokens;
}

int rot(string &text){
	for (int i=0; i<(int)text.size(); i++){
		char c=text[i];
		if (islower(c))
			if (c=='z') text[i]='a';
			else text[i]++;
	}
	return 0;
}

bool check(string text){
	vs words = split(text);
	for (int i=0; i<(int)words.size(); i++){
		string s = words[i];
		if (s=="the" || s=="this" || s=="that")
			return true;
	}
	return false;
}

int main(void){
	string s;
	while (true){
		getline(cin, s);
		if (cin.eof()) break;
		for (int i=0; i<26; i++)
			if (check(s)) break;
			else rot(s);
		cout<<s<<endl;
	}
	return 0;
}

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

// #define multitest 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
#define pc(...) PC(#__VA_ARGS__, __VA_ARGS__);
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.first << ", " << p.second << ']';
	return out;
}
template <typename Arg>
void PC(const char *name, Arg &&arg)
{
	std::cerr << name << " { ";
	for (const auto &v : arg)
		cerr << v << ' ';
	cerr << " }\n";
}
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#define pc(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;
auto TimeStart = chrono::steady_clock::now();

const int nax = 2e5 + 10;
string s;
long long dp[nax][20], n;

long long solve(int index, int prevRem)
{
	if (index == n)
		return prevRem == 5;
	db(index, prevRem);
	auto &ret = dp[index][prevRem];
	if (ret >= 0)
		return ret;
	ret = 0;
	if (s[index] == '?')
	{
		for (int i = 0; i < 10; ++i)
			ret = (ret + solve(index + 1, (prevRem * 10 + i) % 13)) % mod;
	}
	else
		ret = solve(index + 1, (prevRem * 10 + s[index] - '0') % 13);
	db(index, prevRem, ret);
	return ret;
}

void solve()
{
	cin >> s;
	n = s.length();
	memset(dp, -1, sizeof(dp));
	cout << solve(0, 0) << '\n';
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
#ifdef TIME
	cerr << "\n\nTime elapsed: " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " seconds.\n";
#endif
	return 0;
}

Measured memory_bytes: 39504
#include <bits/stdc++.h>
using namespace std;
int main(){
double a,b,c,h;
cin>>a>>b>>c;
h=b*sin(M_PI*c/180);
printf("%f\n%f\n%f\n",a*h/2,a+b+sqrt(( a-(b*cos(M_PI*c/180)) )*( a-(b*cos(M_PI*c/180)) )+h*h),h);
return 0;
}



Measured memory_bytes: 3452
x,k,d = map(int,input().split())

tmp = abs(x) % d
cal = abs(x) // d
if tmp > abs(tmp - d):
    cal += 1
    tmp = abs(tmp - d)

if cal == k:
    print(tmp)
elif cal > k:
    print(abs(x) - k*d)
else:
    if (k - cal) % 2 == 0:
        print(tmp)
    else:
        print(min(abs(tmp-d),abs(tmp+d)))

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
int dx[4] = { 0,  0, 1, -1 };
int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

vi point;
vvi ki;

void dfs(int v, int p = -1) {
	for (auto i : ki[v]) {
		if (i == p) continue;
		point[i] += point[v];
		dfs(i, v);
	}
}

int main() {
	int n, q; cin >> n >> q;
	vi a(n - 1), b(n - 1); 
	ki.resize(n);
	rep(i, n - 1) {
		cin >> a[i] >> b[i];
		--a[i], --b[i];
		ki[a[i]].push_back(b[i]);
		ki[b[i]].push_back(a[i]);
	}

	vi p(q), x(q);
	point.resize(n);
	rep(i, q) {
		cin >> p[i] >> x[i];
		--p[i];
		point[p[i]] += x[i];
	}

	dfs(0);

	rep(i, n) {
		cout << point[i] << endl;
	}
}


Measured memory_bytes: 26624
using System;
using System.Linq;
namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] In = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int a = In[0];
            int b = In[1];
            Console.WriteLine(a + b / 2);
        }
    }
}


Measured memory_bytes: 27992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
vector<ll> fac, finv, inv;

ll combCalc(ll n, ll k){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll comb(ll x, ll y){
    fac = finv = inv = vector<ll>(x+1);
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i=2; i<=x; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
    return combCalc(x, y);
}
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<MOD>;
mint calc(ll N, ll K) {
    mint res = 1;
    for (long long n = 0; n < K; ++n) {
        res *= (N - n);
        res /= (n + 1);
    }
    return res;
}



int main(){
    int n, k;   cin >> n >> k;
    
    
    REP(i, k)        
        cout << comb(n-k+1, i+1)*comb(k-1, i)%MOD << endl;
    
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int S;
	int h=0, s=0, m=0;
	scanf("%d", &S);
	h = S / (60 * 60);
	S -= (h * 60*60);
	m = S / 60;
	S -= m * 60;
	s = S;
	printf("%d:%d:%d\n", h, m, s);
	return 0;

}


Measured memory_bytes: 2000
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cassert>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

#define read_int(X) \
    ll X;           \
    scanf("%lld\n", &X);

#define read_two_int(X, Y) \
    ll X, Y;               \
    scanf("%lld %lld\n", &X, &Y);

#define read_three_int(X, Y, Z) \
    ll X, Y, Z;                 \
    scanf("%lld %lld %lld\n", &X, &Y, &Z);

#define read_four_int(X, Y, Z, W) \
    ll X, Y, Z, W;                \
    scanf("%lld %lld %lld %lld\n", &X, &Y, &Z, &W);

int main()
{
    read_int(X);

    ll ans = abs(X - 1);
    printf("%lld\n", ans);
}


Measured memory_bytes: 3820
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N; cin >> N;
    vector<int>A(N);
    int ans = 1;
    rep(i, N) {
        cin >> A[i];
        if (A[i] % 2 == 0)ans *= 2;
    }
    cout << pow(3, N) - ans << endl;
}

Measured memory_bytes: 4140
import java.util.Scanner;

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

    int N = scanner.nextInt();
    char[] S = scanner.next().toCharArray();
    int left = 0;
    int count = 0;
    for (char ch : S) {
      if (ch == ')') {
        if (count <= 0) left++;
        else count--;
      }
      if (ch == '(') count++;
    }
    int right = 0;
    count = 0;
    for (int i = N - 1; i >= 0; i--) {
      char ch = S[i];
      if (ch == '(') {
        if (count <= 0) right++;
        else count--;
      }
      if (ch == ')') count++;
    }
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < left; i++) sb.append('(');
    for (int i = 0; i < N; i++) sb.append(S[i]);
    for (int i = 0; i < right; i++) sb.append(')');
    System.out.println(sb.toString());
  }
}


Measured memory_bytes: 21716
# -*- coding: utf-8 -*-
N = int(input())
s = [int(input()) for i in range(N)]
s.sort()
s_sum = sum(s)
inf=float("inf")
min_s_not10x = inf
for si in s:
    if si %10!=0:
        min_s_not10x=si
        break
if s_sum %10 != 0:
    print(s_sum)
else:
    if min_s_not10x==inf:
        print(0)
    else:
        print(s_sum-min_s_not10x)


Measured memory_bytes: 3060
using System;

class Program {
    private static int Main() {
        for( int i = 1; i <= 9; ++i ) {
            for( int j = 1; j <= 9; ++j ) {
                Console.WriteLine( "{0}x{1}={2}", i, j, i * j );
            }
        }

        return 0;
    }
}

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

#define repeat(i, x) for (int64_t i = 0; (i) < (int64_t)(x); (i)++)

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

    int64_t n, k;
    cin >> n >> k;

    if (k == 0) {
        cout << n * n << endl;
        return 0;
    }

    int64_t ans = 0;
    for (int64_t b = 1; b <= n; b++) {
        ans += (n / b) * max(b - k, (int64_t)0);

        if (k > 0) {
            ans += max((n % b + 1) - k, (int64_t)0);
        }
        // cerr << "b: " << b << " cnt: " << (n / b) * max(b - k, 0) + max(n % b - k, 0) << endl;
    }

    cout << ans << endl;

    return 0;
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static readonly double INF = 1e8;

        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                string[] temp = input.Split(' ');

                int W = int.Parse(temp[0]);

                List<double> r = new List<double>();

                for (int i = 1; i < temp.Length; i++)
                {
                    r.Add(double.Parse(temp[i]));
                }

                int n = r.Count;

                double[,] dp = new double[1 << n, n];

                for (int i = 0; i < (1 << n); i++)
                {
                    for (int j = 0; j < n; j++)
                    {
                        dp[i, j] = INF;
                    }
                }

                for (int i = 0; i < n; i++)
                {
                    dp[(1 << n) - (1 << i) - 1, i] = r[i];
                }

                for (int i = (1 << n) - 1; i >= 0; i--)
                {
                    for (int j = 0; j < n; j++)
                    {
                        if ((i & (1 << j)) != 0) continue;

                        for (int k = 0; k < n; k++)
                        {
                            double dist = 2 * Math.Sqrt(r[j] * r[k]);

                            dp[i, j] = Math.Min(dp[i, j], dp[i | (1 << j), k] + dist);
                        }
                    }
                }

                double min = INF;

                for (int i = 0; i < n; i++)
                {
                    min = Math.Min(min, dp[0, i] + r[i]);
                }
                sb.AppendLine(min > W ? "NA" : "OK");
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9940
#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;
    int h= N/100;
    int t = (N-h*100)/10;
    int a = (N-h*100-t*10);


    if (h==7||t==7||a==7)  {
        cout << "Yes" << endl;
        return 0;
    }
     cout << "No" << endl;
        return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define DEBUG true
#define coutd if(DEBUG) cout
#define ff first
#define ss second
#define len(x) int(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;


int main(){
	ios_base::sync_with_stdio(0);
	int a, b;
	cin >> a >> b;
	if(a>=13)
		cout << b << endl;
	else if(a<=5)
		cout << 0 << endl;
	else
		cout << b/2.0 << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int N=1e5+5;
int n,a[N];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	cout<<a[n/2]-a[n/2-1];
}

Measured memory_bytes: 640
"""
python3 c.py < input.txt
"""
import math
import itertools as it
import heapq

S=input()
N=len(S)
a=0
for i in range(N):
    if i%2==0 and S[i] == "1":
        a=a+1
    elif i%2 ==1 and S[i]=="0":
        a=a+1

b=0
for i in range(N):
    if i%2==0 and S[i] == "0":
        b=b+1
    elif i%2 ==1 and S[i]=="1":
        b=b+1
print(min([a,b]))


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int numg=0,nump=0;
    int ans=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='g'&&numg>nump)
        {
            nump++;
            ans++;
        }
        else if(s[i]=='g'&&numg<=nump)
            numg++;
        else if(s[i]=='p'&&numg>nump)
        {
            nump++;
        }
        else
        {
            ans--;
            numg++;
        }
    }
    printf("%d",ans);
    return 0;
}

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

int main(void){
    string s1, s2;
    cin >> s1 >> s2;
    reverse(s2.begin(), s2.end());
    if(s1==s2)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        o: chars,
        e: chars,
    }
    let mut s = String::new();
    let mut j = 0;
    let mut k = 0;
    for i in 0..o.len() + e.len() {
        if i % 2 == 0 {
            s.push(o[j]);
            j+=1;
        } else {
            s.push(e[k]);
            k+=1;
        }
    }
    println!("{}", s);
}

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

using namespace std;

typedef long long ll;

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

    int n;
    while (cin >> n, n)
    {
        int res = 0;
        for (int i = 0; i * i <= n; i++)
        {
            for (int j = i; j * j <= n; j++)
            {
                for (int k = j; k * k <= n; k++)
                {
                    for (int l = k; l * l <= n; l++)
                    {
                        if (i * i + j * j + k * k + l * l == n)
                            res++;
                    }
                }
            }
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const long long INF = 1LL << 58;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
UM<int, int> bunkai(int N)
{ //2以上の素因数がkey、その個数がvalue
    UM<int, int> ans;
    int i = 2;
    while (N != 1)
    {
        if (N % i == 0)
        {
            ans[i]++;
            N /= i;
        }
        else
            i++;
    }
    return ans;
}

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

    UM<int, int> soin, temp;
    FOR(i, 2, N + 1)
    {
        temp = bunkai(i);
        for (auto it = temp.begin(); it != temp.end(); ++it)
            soin[it->first] += it->second;
    }
    // for (auto a = soin.begin(); a != soin.end(); ++a)
    // cout << a->first << ":" << a->second << endl;

    int ans = 0;
    for (auto a = soin.begin(); a != soin.end(); ++a)
    {
        if (a->second >= 2)
        {
            for (auto b = soin.begin(); b != soin.end(); ++b)
            {
                if (a != b)
                {
                    if (b->second >= 4)
                        for (auto c = soin.begin(); c != soin.end(); ++c)
                            if (a != c and c->second >= 4 and b->first > c->first)
                                ans++;
                    if (b->second >= 14 and a->second >= 4)
                        ans++;
                    if (b->second >= 24)
                        ans++;
                }
            }
        }
        if (a->second >= 74)
            ans++;
    }
    cout << ans << endl;

    //system("pause");
}

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

int main() {
	int N, H, W,ans=0;
	cin >> N >> H >> W;
	for (int i = 0; i < N; i++) {
		int A, B;
		cin >> A >> B;
		if (A >= H && B >= W)ans++;
	}
	cout << ans;
}


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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 10001
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

const double PI = acos(-1);
typedef pair<int, int> P;

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

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

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void)
{
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++)
    {
        if (!prime[i])
        {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i)
        {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}
vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i - 1);
            if (i * i != n)
            {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

int main()
{
    string S, T;
    cin >> S >> T;
    for (int i = S.length() - 1 ; i >= 0; i--)
    {
        bool check = false;
        for (int j = 0; (i + T.length() <= S.length()) && (j < T.length()); j++)
        {
            if (S[i + j] != '?' && S[i + j] != T[j])
                break;
            if (j == T.length() - 1)
                check = true;
        }
        if (check)
        {
            for (int j = 0; j < T.length(); j++)
            {
                S[i + j] = T[j];
            }
            rep(j, S.length())
            {
                if (S[j] == '?')
                {
                    cout << "a";
                }
                else
                {
                    cout << S[j];
                }
            }
            cout << endl;
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int d(int n) {
    int ans = 0;
    while (n) ans++, n /= 10;
    return ans;
}
int main()
{
    int N; cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        ans += d(i) % 2;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	int N; cin >> N;
	vector<bool> zoros(N);
	REP(i, N)
	{
		int d1, d2; cin >> d1 >> d2;
		zoros[i] = d1 == d2;
	}
	bool ok = false;
	for (int i = 2; i < N; ++i)
	{
		if (zoros[i - 2] && zoros[i - 1] && zoros[i])
			ok = true;
	}
	cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
// ll x,y;
void solve(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long double x,y;
  cin >> x >> y;
  cout << (ll)(log2(y)- log2(x) + 1) << endl;
}
int main(){
  solve();
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define LL long long
#define uLL unsigned long long
#define db double

using namespace std;
const int N=250000+10;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9') {if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
    return x*w;
}
int fpow(int a,int b,int mod){int an=1;while(b){if(b&1) an=1ll*an*a%mod;a=1ll*a*a%mod,b>>=1;}return an;}
int ginv(int a,int mod){return fpow(a,mod-2,mod);}
struct node
{
	LL x,y,z;
	bool operator < (const node &bb) const {return x!=bb.x?x<bb.x:(y!=bb.y?y<bb.y:z<bb.z);}
	bool operator == (const node &bb) const {return x==bb.x&&y==bb.y&&z==bb.z;}
};
map<node,int> mp;
int m1=998244853,b1=233,iv1=ginv(b1,m1),m2=1e9+7,b2=677,iv2=ginv(b2,m2),m3=993244853,b3=149,iv3=ginv(b3,m3);
char cc[N];
int n,a,b,c;

int main()
{
	n=rd();
	scanf("%s",cc+1);
	a=b=c=0;
	for(int i=n;i;--i)
	{
		if(cc[i]=='+') a=(a+1)%m1,b=(b+1)%m2,c=(c+1)%m3;
		else if(cc[i]=='-') a=(a-1+m1)%m1,b=(b-1+m2)%m2,c=(c-1+m3)%m3;
		else if(cc[i]=='<') a=1ll*a*b1%m1,b=1ll*b*b2%m2,c=1ll*c*b3%m3;
		else if(cc[i]=='>') a=1ll*a*iv1%m1,b=1ll*b*iv2%m2,c=1ll*c*iv3%m3;
	}
	int na=0,nb=0,nc=0;
	int xa=1,xb=1,xc=1;
	LL ans=0;
	mp[(node){1ll*na*xa%m1,1ll*nb*xb%m2,1ll*nc*xc%m3}]=1;
	for(int i=n;i;--i)
	{
		if(cc[i]=='+') na=(na+1)%m1,nb=(nb+1)%m2,nc=(nc+1)%m3;
		else if(cc[i]=='-') na=(na-1+m1)%m1,nb=(nb-1+m2)%m2,nc=(nc-1+m3)%m3;
		else if(cc[i]=='<')
		{
			na=1ll*na*b1%m1,nb=1ll*nb*b2%m2,nc=1ll*nc*b3%m3;
			xa=1ll*xa*iv1%m1,xb=1ll*xb*iv2%m2,xc=1ll*xc*iv3%m3;
		}
		else if(cc[i]=='>')
		{
			na=1ll*na*iv1%m1,nb=1ll*nb*iv2%m2,nc=1ll*nc*iv3%m3;
			xa=1ll*xa*b1%m1,xb=1ll*xb*b2%m2,xc=1ll*xc*b3%m3;
		}
		ans+=mp[(node){1ll*(na-a+m1)*xa%m1,1ll*(nb-b+m2)*xb%m2,1ll*(nc-c+m3)*xc%m3}];
		++mp[(node){1ll*na*xa%m1,1ll*nb*xb%m2,1ll*nc*xc%m3}];
	}
	printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 39552
import itertools

N = int(input())
P = int(input().replace(' ', ''))
Q = int(input().replace(' ', ''))
l = [i for i in range(1, N+1)]
pl = itertools.permutations(l)
lis = []
for oc in pl:
  lis.append(int(''.join(map(str, list(oc)))))
lis.sort()
a = lis.index(P)
b = lis.index(Q)

print(abs(a - b))

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i=1; i < (int)(n); i++)
#define rrep(i, n) for (int i=((int)(n)-1); i>=0; i--)
#define rreps(i, n) for (int i=((int)(n)-1); i>0; i--)
#define ALL(x) (X).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;
using p = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  string s, t; cin >> s;
  int N = s.size();
  bool flag = true;
  rep (i, N) {
    if (i%2 == 0) {
      if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
        flag = false;
        break;
      }
    }
    else {
      if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
        flag = false;
        break;
      }
    }
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var A, B, C, r int
	fmt.Scan(&A, &B, &C)
	a := []int{A, B, C}
	for {
		sort.Ints(a)
		if a[0] == a[1] && a[1] == a[2] {
			break
		}
		if a[0] == a[1] {
			a[0]++
			a[1]++
		} else {
			a[0] += 2
		}
		r++
	}
	fmt.Println(r)
}

Measured memory_bytes: 512
/* ex 7_1
   Rikuta */

#include <stdio.h>
//point型の構造体を定義
typedef struct point
{   
    //中身はint型が二つ
    int x_elem;
    int y_elem;
}point;

//point型を返す，引数としてpointを二つもつ関数の定義
point shift_point(point p_past,point p_now){
    //次の点の宣言
    point nextpoint;

    //次の点のx,y座標の計算
    nextpoint.x_elem = p_now.x_elem - (p_now.y_elem - p_past.y_elem);
    nextpoint.y_elem = p_now.y_elem + (p_now.x_elem - p_past.x_elem);
    
    //次の点を返す
    return nextpoint;
}


int main(void)
{
    //point型の座標配列を準備
    point coordinates[4];

    //入力
    scanf("%d%d%d%d", &coordinates[0].x_elem, &coordinates[0].y_elem, &coordinates[1].x_elem, &coordinates[1].y_elem);
    
    for (int i = 2; i <= 3; i++)
    {   
        //shift_point関数を用いて，3,4番目の座標を計算
        coordinates[i] = shift_point(coordinates[i - 2], coordinates[i - 1]);
        
        //計算した座標を出力
        printf("%d %d ", coordinates[i].x_elem, coordinates[i].y_elem);
    }
    
    //改行
    printf("\n");
    return 0;
}

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

int main () {
	int n, a;
	cin >> n >> a;
	
	bool can = false;
	
	for (int i = 0; i <= 20; i++) {
		for (int j = 0; j <= a; j++) {
			if (500 * i + j == n) {
				can = true;
				break;
			}
		}
	}

	if (can) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys

n = int(sys.stdin.readline())
while n:
    l = list()
    for _ in range(n):
        l.append(int(input()))
    a = l.copy()
    for i in range(1,n):
        a[i] = max(a[i-1] + l[i], l[i])
    print(max(a))
    n = int(sys.stdin.readline())

Measured memory_bytes: 7804
<?php

$page = array();
while($line = fgets(STDIN)){
	list($a, $b) = explode(" ", trim($line));
	if(!isset($page[$a])){
		$page[$a] = array();
	}
	$page[$a][] = $b;
}

ksort($page);

foreach($page as $word => $arr){
	sort($arr, SORT_NUMERIC);
	echo $word."\n";
	echo implode($arr, " ")."\n";
}

Measured memory_bytes: 15460
n,k = map(int,input().split())
a = [0]*(n+1)
answer = 0
for i in range(k):
  d = int(input())
  b = list(map(int,input().split()))
  for j in range(d):
    a[b[j]] +=1
for q in range(1,n+1):
  if(a[q]==0):
    answer +=1
print(answer)

Measured memory_bytes: 9144
import heapq
q = []
cmd = []
heapq.heapify(q)
while True:
    cmd.clear()
    cmd = input().split()
    if cmd[0] =='insert':
        heapq.heappush(q, -int(cmd[1]))
    elif cmd[0] =='extract':
        p = heapq.heappop(q)
        print(-p)
    elif cmd[0]=='end':
        break;


Measured memory_bytes: 45312
I=lambda:list(map(int,input().split()));n,m=I();l=[I()+[i]for i in range(m)];c=[0]*-~n;a=[0]*m
for p,y,i in sorted(l,key=lambda x:x[1]):c[p]+=1;a[i]='%06d'%p+'%06d'%c[p]
for t in a:print(t)

Measured memory_bytes: 32612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader s = new FastReader();
        int n = s.nextInt();
        int [] baprr = new int[100000];
        Arrays.fill(baprr,0);
        int [] arr = new int[n];
        long sum=0;
        for(int i=0;i<n;i++){
            arr[i]=s.nextInt();
            baprr[arr[i]-1]++;
            sum+=arr[i];
        }
        int q =s.nextInt();
        int b,c;

        while(q-->0){
            b=s.nextInt();
            c=s.nextInt();
            sum+=((c-b)*baprr[b-1]);
            baprr[c-1]+=baprr[b-1];
            baprr[b-1]=0;
            System.out.println(sum);
        }
    }

    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

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

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

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

#define MAX 100005
#define INF 1001001001

int main(int, char**)
{
  int n;
  cin >> n;
  vector<int> a(n+1);
  rep(i,n) cin >> a[i];
  a[n] = -1;

  int m;
  cin >> m;
  vector<int> b(m+1);
  rep(i,m) cin >> b[i];
  b[m] = -1;

  int ans = 0;
  int i = 0;
  while (a[i] == b[i] && i < n && i < m) i++;
  if (a[i] < b[i]) ans = 1; 

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3092
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let buf = buf.trim().as_bytes();
    let len = buf.len();
    let mut ans = 0;
    for i in 0 .. len / 2 {
        if buf[i] != buf[len - i - 1] {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>

int main()
{
	int a, b, c, tmp;
	std::cin >> a >> b >> c;
	if(a>b){
		tmp = a;
		a = b;
		b = tmp;
	}
	if(b>c){
		tmp = b;
		b = c;
		c = tmp;
	}
	if(a>b){
		tmp = a;
		a = b;
		b = tmp;
	}
	std::cout << a << " " << b << " " << c << "\n";
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define MOD (long long)(1e9+7)
typedef long long int ll;
typedef unsigned long long int ull;

ll modularExponentiation(ll x, ll y, ll  p){
  ll res = 1;
  x = x % p;
  while (y > 0){
      if (y & 1) res = (res*x) % p;
      y = y>>1;
      x = (x*x) % p;
  }
  return res;
}

bool isPrime(ll n){
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll t=1;
  // cin>>t;
  while(t--){
    ll x;
    cin>>x;
    cout<<1000*(x/500) + 5*((x-(x/500)*500)/5)<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] input = sc.nextLine().split(" ");
    for(int i = 0; i < input.length; i++) {
      if ("0".equals(input[i])) {
        System.out.println(i + 1);
        return;
      }
    }
  }
}

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

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

void dfs(vvii &t, vi &c, vi &v, int node, int color) {
	c[node] = color;
	v[node] = 1;
	for (int i = 0; i < t[node].size(); i++) {
		if (v[t[node][i].first] == 0) 
			dfs(t, c, v, t[node][i].first, (t[node][i].second % 2 ? !c[node] : c[node]));
	}
}

int main()
{
	int n, u, v, w, i;
	scanf("%d", &n);
	vvii tree(n + 1);
	vi visit(n + 1);
	vi color(n + 1, 2);
	for (i = 0; i < n; i++) {
		scanf("%d %d %d", &u, &v, &w);
		tree[u].push_back(ii(v, w));
		tree[v].push_back(ii(u, w));
	}
	dfs(tree, color, visit, 1, 0);
	for (i = 1; i <= n; i++)
		printf("%d\n", color[i]);
	return 0;
}

Measured memory_bytes: 9344
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]
C = Counter(A)
t = {k: int(v*(v-1)/2) for k, v in C.items()}
s = sum(t.values())

for a in A:
    res = s - t[a] + int((C[a]-1)/2*(C[a]-2))
    print(res)

Measured memory_bytes: 32156
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int k, x;
    cin >> k >> x;

    for(int i = x - k + 1; i < x + k; i++){
        cout << i << " ";
    }
    cout << endl;

    return 0;
}


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

using namespace std;

int n, m, q;

vector<int> order;
int place[112123];
int ops[112123];
int seen[112123];

int main()
{
	fill(place, place + 112123, -1);
	cin >> n >> m >> q;
	for (int i = 0; i < q; i++)
	{
		cin >> ops[i];
	}
	for (int i = q-1; i >= 0; i--)
	{
		int x = ops[i];
		if (place[x] == -1)
		{
			place[x] = order.size();
			order.push_back(x);
		}
		if (place[x] == 0 || seen[order[place[x]-1]] > seen[x])
			seen[x]++;
	}
	bool good = true;
	for (int i = 1; i <= m; i++)
	{
		int x = i;
		if (place[x] == -1)
		{
			place[x] = order.size();
			order.push_back(x);
		}
		if (place[x] == 0)
			seen[x] = n;
		else if (seen[order[place[x]-1]] > seen[x])
			seen[x] = seen[order[place[x]-1]];
	}
	for (int i = 1; i <= m; i++)
		if (seen[i] < n) good = false;
	if (good) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}



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

#define rr(i, b)    for (int i = 0; i < int(b); i++)
#define vi(n, a) vector <int> a(n); rr(i, n) cin >> a[i]
#define pvec(a) rr(i, a.size()) cout << a[i] << " "; cout << endl
#define bug(x) cout << #x << " " << x << endl
#define ll long long
#define vii vector <int>

using namespace std;

bool check(int n) {
    string s = to_string(n);

    int l = 0;
    int r = s.size() - 1;

    while(l < r) {
        if(s[l] != s[r]) {
            return false;
        }
        l++;
        r--;
    }

    return true;
}

void solve() {
    string a, b, c;
    cin >> a >> b >> c;

    cout << a[0]<< b[1] << c[2] << endl;
}
 
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 3580
import sys
N = int(input())
array = list(map(int,input().split()))
array_base = [ I for I in range(1,N+1) ]

dic = {}
for I in range(N):
    if array[I] != I + 1:
        dic[I] = array[I]

if not (len(dic) == 2 or len(dic) == 0):
    print('NO')
else:
    print('YES')

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

vector<ll>adj[200010];
ll n_boat[200010];
bool vis[200010];

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

    ll n,m;
    cin>>n>>m;
    for(ll i = 0; i < n; i++) adj[i].clear();

    for(ll i = 0; i < m; i++){
        ll u,v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    memset(vis,false,sizeof vis);

    vis[1] = true;
    n_boat[1] = 0;

    queue<ll>q;
    q.push(1);
    
    while(!q.empty()){
        ll k = q.front();
        q.pop();
        for(ll i = 0; i < adj[k].size(); i++){
            ll pre = adj[k][i];
            if(!vis[pre]){
                q.push(pre);
                vis[pre] = true;
                n_boat[pre] = n_boat[k] + 1;
            }
        }
    }

    // if(n_boat[n] <= 2) cout<<"POSSIBLE"<<endl;
    if(n_boat[n]== 1 or n_boat[n] == 2) cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;

    return 0;
}

Measured memory_bytes: 18480