akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

template <typename T>
vector<T> divisor(T n)
{
    vector<T> divisor;
    for (T i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            divisor.push_back(i);
            if (i * i != n)
                divisor.push_back(n / i);
        }
    }
    sort(divisor.begin(), divisor.end());
    return divisor;
}

int main()
{
    ll N, ans = 0;
    cin >> N;
    auto div = divisor(N);
    for (auto &d : div)
    {
        if (d == 1)
            continue;
        ll m = d - 1;
        if (N / m == N % m)
            ans += m;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
n,m = map(int,input().split())
a_lst = []
for i in range(m):
  a_lst.append( list(map(int,input().split())) )
 
ans = "IMPOSSIBLE"
 
start_lst = []
goal_lst = []
for a in a_lst:
  if a[0] == 1:
    start_lst.append(a[1])
  if a[1] == n:
    goal_lst.append(a[0])
goal_lst = set(goal_lst)
for s in start_lst:
  if s in goal_lst:
    ans = "POSSIBLE"
    
print(ans)

Measured memory_bytes: 49760
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
using namespace std;
typedef long long int ll;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, k, num = 0;
	pair<ll, ll>p[100010];
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> p[i].first >> p[i].second;
	sort(p, p + n);
	for (int i = 0; i < n; i++) {
		num += p[i].second;
		if (num >= k) {
			cout << p[i].first << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#define A_MAX 1000000
#define A_MIN -1000000

int
main(void)
{
  int n, i;
  long a, max, min, sum;
  max = A_MIN;
  min = A_MAX;
  sum = 0;

  std::scanf("%d", &n);
  for (i = 0; i < n; i++) {
    std::scanf("%ld", &a);
    if (a > max) {
      max = a;
    }
    if (a < min) {
      min = a;
    }
    sum += a;
  }

  std::printf("%ld %ld %ld\n", min, max, sum);

  return 0;
}



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

int main() {
	long long N, A, ans = 0;
	static long long X[200010];
	set<long long> S;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A;
		X[A] = i;
	}
	S.insert(0);
	S.insert(N + 1);
	for (long long i = 1; i <= N; i++) {
		auto it = S.upper_bound(X[i]);
		ans += i * (*it - X[i]) * (X[i] - *--it);
		S.insert(X[i]);
	}
	cout << ans;
}

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

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


	for (int i = 0; i < 3; i++) {
		if (n[i] == '1') n[i] = '9';
		else if (n[i] == '9') n[i] = '1';
	}


	for (int i = 0; i < 3; i++) cout << n[i];

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;

int main(){
    int a=0,b=0,in;
    
    for(int i=0;i<4;i++){
        scanf("%d",&in);
        a+=in;
    }
    for(int i=0;i<4;i++){
        scanf("%d",&in);
        b+=in;
    }
    
    if(a>b)
        printf("%d\n",a);
    else
        printf("%d\n",b);
    
    return 0;
}

Measured memory_bytes: 1184
#include <stdio.h>

int main(void) {
  int N;
  scanf("%d",&N);
  int A[N];
  for(int i=0;i<N;i++)
    scanf("%d",&A[i]);
  
  int max=0,sec=0,count;
  for(int i=0;i<N;i++)
    if(max<A[i]){
      max=A[i];
      count=i;
      }
  A[count]=0;
  for(int i=0;i<N;i++)
    if(sec<A[i])
      sec=A[i];

  for(int i=0;i<N;i++)
    A[i]=max;
  
  A[count]=sec;

  for(int i=0;i<N;i++)
    printf("%d\n",A[i]);
  return 0;
}

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

from collections import Counter
cnt = Counter(a)
ans = 0
for i in range(n - 1, -1, -2):
    if cnt[i] == 2:
        ans += 1
        continue
    if i == 0 and cnt[i] == 1:
        break
    else:
        print(0)
        exit()
M = 10 ** 9 + 7
print((2 ** ans)%M)


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

int main ()
{
    int n1, n2, sum = 0, count = 0;
    double t = 0;
    while(scanf("%d,%d", &n1, &n2) != EOF) {
        sum += n1 * n2;
        t += (double)n2;
        count++;
    }
    int avg = t / (double)count;
    avg = (t / (double)count) - avg >= 0.5 ? avg + 1 : avg;
    cout << sum << endl << avg << endl;


    return 0;
}

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

using namespace std;

#define INT_MAX 2147483647

long gcd(long m, long n);
long lcm(long m, long n);

int main( void ){

	string str;
	cin >> str;
	str = str.substr(5, 2);
	int a = atoi(str.c_str());
	str =  a <= 4 ? "Heisei" : "TBD";
	cout << str << endl;

	return 0;

}

//最大公倍数
long gcd(long m, long n)
{
	long temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
long lcm(long m, long n)
{
	return m * n / gcd(m,n); 
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

const int INF = 1000000000;
const int zure = 20000;

int H, N, A[1000], B[1000];
int cost[40001];
int solve(int h){
	if(h > H) return INF;
	if(h == H) return 0;
	if(cost[zure+h] != -1) return cost[zure+h];
	int ret = INF;
	rep(i, N){
		ret = min(ret, solve(h+A[i])+B[i]);
	}
	return cost[zure+h] = ret;
}
signed main(){
	cin >> H >> N;
	rep(i, N) cin >> A[i] >> B[i];
	memset(cost, -1, sizeof(cost));
	int ans = INF;
	for(int i=-10000; i<=0; i++) ans = min(ans, solve(i));
	cout << ans << endl;
}

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

int main() {
    int64_t n;
    cin >> n;
    for(int64_t i = (int64_t)sqrt(n); i > 0; i--){
        if(n % i == 0){
            cout << (int64_t)log10(n/i) + 1 << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 512
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9223372036854775807
#define    ninf   -inf
#define    ima   2147483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(10)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
const    ld   PI=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}

int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{

ll s,w;
cin>>s>>w;
if(w>=s)
cout<<"unsafe";
else
cout<<"safe";














}return 0;}

Measured memory_bytes: 3640
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc *bufio.Scanner

func init() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
}

func loadint() (result int) {
	sc.Scan()
	result, _ = strconv.Atoi(sc.Text())
	return
}

func loadints(n int) []int {
	xs := make([]int, n)
	for i := 0; i < n; i++ {
		xs[i] = loadint()
	}
	return xs
}

func main() {
	n := loadint()
	x := loadint()
	a := loadints(n)
	sort.Ints(a)
	result := 0
	for i := 0; i < n; i++ {
		if (x >= a[i] && i < n-1) || (x == a[i]) {
			x -= a[i]
			result++
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 640
// lannisters don't act like fools
#include <bits/stdc++.h>

using namespace std;
#define yah_faster_baby ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007









void solve() {
    int l, r, d;
    cin >> l >> r >> d;
    int count = 0;
    for (int i = l; i <= r; i++) {
        if (i % d == 0)
            count++;
    }
    cout << count;
}



int main() {
    yah_faster_baby
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
#endif // ONLINE_JUDGE
    solve();
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cmath>
#include <set>
#include <string>
using namespace std;

int main() {
    string str;
    cin >> str;
    int len = str.length();
    int maxlen = 0;
    for (int i = 0; i < len; i++) {
        for (int j = i; j < len; j++) {
            for (int k = i; k <= j; k++) {
                if (str[k] != 'A' && str[k] != 'T' && str[k] != 'G' && str[k] != 'C') {
                    goto OUT;
                }
            }
            maxlen = max(maxlen, j - i + 1);
            OUT:
            ;
        }
        
    }
    cout << maxlen << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

char s[400000];
int val[400000];
int val1[400000];
int val2[400000];
int ans = 400000;

int main() {
	int n; cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
		val1[i] = val1[i - 1] + (s[i] == 'W');
	}
	for (int i = n; i >= 1; i--) {
		val2[i] = val2[i + 1] + (s[i] == 'E');
		val[i] = val1[i] + val2[i];
	}
	for (int i = 1; i <= n; i++) {
		ans = min(ans, val[i]);
	}

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

Measured memory_bytes: 4480
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
using namespace std;

int main(){
  int N;
  cin >> N;
  if(N == 1){
    cout << 0 << endl;
  }else{
    cout << 1 << endl;
  }
}


Measured memory_bytes: 3616
//****** @author mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll fast_pow(ll a, ll b) {
    if(b == 0) return 1l;
    ll val = fast_pow(a, b / 2);
    if(b % 2 == 0) return val * val % MOD;
    else return val * val % MOD * a % MOD;
}
void solve() {
    ll n;cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)cin>>a[i];
    ll sum = 0;
    for (ll i = 0; i < 64; i++)
    {
        ll zc = 0, oc = 0;
        ll idsum = 0;
        for (ll j = 0; j < n; j++)
        {
            if (a[j] % 2 == 0)
                zc++;
            else
                oc++;
            a[j] /= 2;
        }

        idsum = (oc * zc )%MOD;
        ll temp=fast_pow(2,i);
        idsum=(idsum*temp)%MOD;
        sum += idsum;
        sum%=MOD;
    }
    cout<<sum<<endl;

}
int main()
{
    IOS;
    ll t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 2560
import java.io.*
import java.util.*

fun solve(N: Int, A: Int, B: Int){
    fun digitSum(x: Int): Int{
        return x.toString().map{ it - '0' }.sum()
    }
    println((1..N).filter{ A <= digitSum(it) && digitSum(it) <=B }.sum())
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val A = sc.next().toInt()
    val B = sc.next().toInt()
    solve(N, A, B)
}



Measured memory_bytes: 33716
def vector_multiplication(A, B):
    res = [[0 for _ in range(len(B[0]))] for _ in range(len(A))]
    for i in range(len(A)):
        for j in range(len(B[0])):
            for k in range(len(B)):
                res[i][j] += A[i][k] * B[k][j]
    return res


n, m, l = list(map(int, input().split()))
A = [[int(x) for x in input().split()] for _ in range(n)]
B = [[int(x) for x in input().split()] for _ in range(m)]
ans = vector_multiplication(A, B)
for i in ans:
    print(' '.join(map(str,i)))


Measured memory_bytes: 6880
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++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(a) a.begin(),a.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 pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#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) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 3005;
 
int dp[MX][MX];
 
int main() {
  string s, t;
  cin>>s>>t;
  s += '$';
  t += '#';
  rep(i,sz(s))rep(j,sz(t)) {
    maxs(dp[i+1][j], dp[i][j]);
    maxs(dp[i][j+1], dp[i][j]);
    if (s[i] == t[j]) maxs(dp[i+1][j+1], dp[i][j]+1);
  }
  string ans;
  int i = sz(s)-1, j = sz(t)-1;
  while (i+j) {
    int x = dp[i][j];
    if (i && dp[i-1][j] == x) {
      i--;
    } else if (j && dp[i][j-1] == x) {
      j--;
    } else {
      i--; j--;
      ans += s[i];
    }
  }
  reverse(rng(ans));
  cout<<ans<<endl;
  return 0;
}
 
 
 
 
 
 
 
 

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

int n;
int a[100];

int print(int a[], int n) {
	for (int i = 0; i < n - 1; i++) {
		cout << a[i] << " ";
	}
	cout << a[n - 1] << endl;
}

int insertionSort(int a[], int n) {
	print(a, n);

	for (int i = 1; i < n; i++) {
		int v = a[i];
		int j = i -1;

		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;

		print(a, n);
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	insertionSort(a, n);
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
#include <string.h>
#include <iterator>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <limits.h>
#include <string>
#include <bitset>
#include <map>
#include <numeric>
#include<unordered_map>


#define endl cout<<"\n"
#define lli long long int
#define ld long double
#define M_PI (3.14159265358979323846264338327950288)
#define MOD (1000000007)

using namespace std;

//fast-exponentiation-lli
unsigned lli expo_fast(lli a, lli b) {
	a = a;
	lli result = 1;
	while (b) {
		//multiplyint(tos(result), a);
		if (b & 1)result = (result * a);
		b >>= 1;
		a = (a*a);
	}
	return (result);
}


void take_in(vector<lli> *arr) {
	for (int i = 0; i < arr->size(); i++)cin >> (*(arr))[i];
}


lli gcd(lli a, lli b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);

}

/* Iterative Function to calculate (x^y)%p in O(log y) */
unsigned lli power(lli x, unsigned lli y, lli p)
{
	lli res = 1;      // Initialize result 
	x = x % p;  // Update x if it is more than or equal to p 
	while (y > 0) {
		// If y is odd, multiply x with result 
		if (y & 1)res = (res*x) % p;
		// y must be even now 
		y = y >> 1;
		x = (x*x) % p;
	}
	return res;
}






int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n; cin >> n;
	vector<lli>arr(n + 1);
	for (int i = 1; i <= n; i++)cin >> arr[i];
	vector<vector<lli>> dp(n + 1, vector<lli>(n + 1,LLONG_MAX));
	vector<vector<lli>> dp2(n + 1, vector<lli>(n + 1,LLONG_MAX));
	for (int i = 1; i <= n; i++) {
		dp[i][i] = arr[i];
		dp2[i][i] = arr[i];
	}
	for (int sz = 2; sz <= n; sz++) {
		for (int i = 1; i+sz-1 <= n; i++) {
			int j = i + sz - 1;
			for (int k1 = i; k1 <= j - 1; k1++) {
				int k2 = k1 + 1;
				if (dp[i][j] > dp[i][k1] + dp2[i][k1] + dp[k2][j] + dp2[k2][j]) {
					dp[i][j] = dp[i][k1] + dp2[i][k1] + dp[k2][j] + dp2[k2][j];
					dp2[i][j] = dp2[i][k1] + dp2[k2][j];
				}
			}
		}
	}
	cout << dp[1][n]-dp2[1][n];
	//system("PAUSE");
}


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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

typedef long long ll;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

namespace pb_ds {   
    namespace io {
        const int MaxBuff = 1 << 15;
        const int Output = 1 << 23;
        char B[MaxBuff], *S = B, *T = B;
        #define getc() ((S == T) && (T = (S = B) + fread(B, 1, MaxBuff, stdin), S == T) ? 0 : *S++)
        char Out[Output], *iter = Out;
        inline void flush() {
            fwrite(Out, 1, iter - Out, stdout);
            iter = Out;
        }
    }
 
    template<class Type = int> inline Type read() {
        using namespace io;
        register char ch; register Type ans = 0; register bool neg = 0;
        while(ch = getc(), (ch < '0' || ch > '9') && ch != '-')     ;
        ch == '-' ? neg = 1 : ans = ch - '0';
        while(ch = getc(), '0' <= ch && ch <= '9') ans = ans * 10 + ch - '0';
        return neg ? -ans : ans;
    }
}
 
using namespace pb_ds;

void File() {
#ifdef zjp_shadow
	freopen ("D.in", "r", stdin);
	freopen ("D.out", "w", stdout);
#endif
}

const int N = 3e5 + 1e3;

int n, a[N];

ll pre[N], suf[N];

priority_queue<int> Max;
priority_queue<int, vector<int>, greater<int>> Min;

int main () {

	File();

	n = read();
	For (i, 1, n * 3) a[i] = read();

	For (i, 1, n)
		Min.push(a[i]), pre[i] = pre[i - 1] + a[i];

	For (i, n + 1, 2 * n) {
		pre[i] = pre[i - 1];
		if (a[i] > Min.top())
			pre[i] += a[i] - Min.top(), Min.pop(), Min.push(a[i]);
	}

	Fordown (i, n * 3, n * 2 + 1)
		Max.push(a[i]), suf[i] = suf[i + 1] + a[i];

	Fordown (i, n * 2, n + 1) {
		suf[i] = suf[i + 1];
		if (a[i] < Max.top())
			suf[i] += a[i] - Max.top(), Max.pop(), Max.push(a[i]);
	}

	ll ans = pre[n] - suf[n + 1];
	For (i, n, 2 * n)
		chkmax(ans, pre[i] - suf[i + 1]);
	printf ("%lld\n", ans);

	return 0;

}

Measured memory_bytes: 6520
#include<bits/stdc++.h>
using namespace std ;
const int maxn = 105 ;
const int inf = 0x3f3f3f3f ;
int h , w ;
char s[maxn][maxn] ;
int step[maxn][maxn] ;
int row[2] = {1 , 0} ;
int col[2] = {0 , 1} ;
struct node
{
	int x , y ;
	int num ;
} ;
queue<node> q ;
bool ok(int x , int y)
{
	return x >= 1 && x <= h && y >= 1 && y <= w ;
}
void bfs()
{
	int num = 0 ;
	if(s[1][1] == '#')  num ++ ;
	step[1][1] = num ;
	q.push(node{1 , 1 , num}) ;
	while(!q.empty())
	{
		node x = q.front() ;
		q.pop() ;
		for(int i = 0 ; i < 2 ; i ++)
		{
			int nx = x.x + row[i] ;
			int ny = x.y + col[i] ;
			if(ok(nx , ny))
			{
				int ns = x.num ;
				if(s[x.x][x.y] == '.'
				&& s[nx][ny] == '#')  ns ++ ;
				if(ns < step[nx][ny])
				{
				   step[nx][ny] = ns ;				
				   q.push({nx , ny , ns}) ;	
				}
			}
		}
	}
	printf("%d\n" , step[h][w]) ;
}
int main()
{
	scanf("%d%d" , &h , &w) ;
	for(int i = 1 ; i <= h ; i ++)  scanf("%s" , s[i] + 1) ;
	memset(step , inf , sizeof(step)) ;
	bfs() ;
	return 0 ;
}

Measured memory_bytes: 384
#n = int(input())
#s = input()
#n, k= map(int,input().split())
#da = list(map(int,input().split()))
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0]*n
        self.size = [1]*n
    def root(self, x):
        if self.par[x] != x:
            self.par[x] = self.root(self.par[x])
        return self.par[x]
    def unite(self, x, y):
        if self.root(x) == self.root(y):
            return
        if self.rank[x] > self.rank[y]:
            self.size[self.root(x)] += self.size[self.root(y)]
            self.par[self.root(y)] = self.root(x)
        else:
            self.size[self.root(y)] += self.size[self.root(x)]
            self.par[self.root(x)] = self.root(y)
        if self.rank[x] == self.rank[y]:
            self.rank[y]+=1
    def check(self, x, y):
        return self.root(x) == self.root(y)
    def sizeCheck(self, x):
        return self.size[self.root(x)]
    def len(self):
        return len(self.par)

n,m,k = map(int,input().split())
uf = UnionFind(n)
ans = [0]*n
for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    uf.unite(a,b)
    ans[a]-=1
    ans[b]-=1
co = [0]*n
for i in range(n):
    ans[i] += uf.sizeCheck(i)-1
for i in  range(k):
    c,d = map(int,input().split())
    if uf.check(c-1,d-1):
        ans[c-1]-=1
        ans[d-1]-=1
for i in range(n):
    if i == n-1:
        print(ans[i])
    else:
        print(ans[i],end=' ')

Measured memory_bytes: 11344
#include <iostream>

using namespace std;

int main() {
	int characterNum[26] = {0};
	char c;

	while(cin >> c) {
		if('A' <= c && c <= 'Z') {
			characterNum[c - 'A']++;
		} else if('a' <= c && c <= 'z') {
			characterNum[c - 'a']++;
		}
	}
	
	for(int i = 0; i < 26; ++i) {
		cout << char(i + 'a') << " : " << characterNum[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3096
N, A, B, C, D = map(int, input().split(" "))
S = input()

if C < D:
    if "##" in S[A:C] or "##" in S[B:D]:
        print("No")
    else:
        print("Yes")
else:
    if "##" in S[A:C] or "##" in S[B:D] or "..." not in S[B-2:D+1]:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 3572
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn=100005;
const int maxm=200005;

struct Edge
{
    int u,v,dist;
    Edge(){}
    Edge(int u,int v,int d):u(u),v(v),dist(d){}
    bool operator<(const Edge &rhs)const
    {
        return dist < rhs.dist;
    }
};
 struct node
 {
     int x,y,id;
 }p[maxn];
 bool cmp(node a,node b)
 {
     return a.x<b.x;
 }
 bool cmp2(node a,node b)
 {
     return a.y<b.y;
 }
struct Kruskal
{
    int n,m;
    Edge edges[maxm];
    int fa[maxn];
    int findset(int x){ return fa[x]==-1? x:fa[x]=findset(fa[x]); }

    void init(int n)
    {
        this->n=n;
        m=0;
        memset(fa,-1,sizeof(fa));
    }

    void AddEdge(int u,int v,int dist)
    {
        edges[m++]=Edge(u,v,dist);
    }

    ll kruskal()
    {
        ll sum=0;
        int cnt=0;
        sort(edges,edges+m);

        for(int i=0;i<m;i++)
        {
            int u=edges[i].u, v=edges[i].v;
            if(findset(u) != findset(v))
            {

                sum +=edges[i].dist;
                fa[findset(u)] = findset(v);
                if(++cnt>=n-1) break;
            }
        }
        if(cnt<n-1) return -1;
        return sum;
    }
}KK;



int main()
{
    int n;
    while(scanf("%d",&n)==1)
    {
        KK.init(n);
        for(int i=1;i<=n;i++)
            {scanf("%d%d",&p[i].x,&p[i].y);
        p[i].id=i;
    }
    sort(p+1,p+n+1,cmp);
    for(int i=1;i<n;i++)
       KK.AddEdge(p[i].id,p[i+1].id,abs(p[i+1].x-p[i].x));
    sort(p+1,p+n+1,cmp2);
    for(int i=1;i<n;i++)
        KK.AddEdge(p[i].id,p[i+1].id,abs(p[i+1].y-p[i].y));
    printf("%d\n",KK.kruskal());
    }
    return 0;
}


Measured memory_bytes: 4096
#include <stdio.h>
int main(){
	int a,b;
	int num;
	int flag = 0;
	scanf("%d %d",&a,&b);
	if(b == 100)
		num = a * 1000 + b;
	else if(b>=10)
		num = a * 100 + b;
	else
		num = a * 10 + b;
	for(int i=0;i<=1000;i++){
		if(i*i==num)
			flag = 1;
	}
	if(flag == 1)
		printf("Yes");
	else
		printf("No");
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int x, a, b;
  cin >> x >> a >> b;
  cout << (x - a) % b << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3652
a, b, x = map(int, input().split())

def calc(n):
    if n > -1 :
        cnt = n // x  + 1
    else:
        cnt = 0
    return int(cnt)
    
cnt_a = calc(a-1)
cnt_b = calc(b)

ans = cnt_b - cnt_a
print(int(ans))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
string a,b;
map<int,int> m;
bitset<30> bs;
int main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> a >> b;
	bool po = true;
	for(int i=0;i<a.size();i++) {
		if(m.find(a[i]) == m.end()) {
			if(bs[b[i]-'a']) {po = false;break;}
			m[a[i]] = b[i];
			bs.set(b[i]-'a');
		} else {
			if(m[a[i]] != b[i]) {po = false;break;}
		}
	}
	cout << (po?"Yes":"No") << '\n';
}

Measured memory_bytes: 916
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = sc.next();
		int count =0;
		while(true) {
			String t = sc.next();
			if (t.equals("END_OF_TEXT")) {
				break;
			}
			t = t.toLowerCase();
			t = t.replace(".", "");
			if (t.equals(W)) {
				count++;
			}
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 26396
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    rep(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
int main(){
ll n; cin>>n;
ll a[n]={};
rep(i,n) {
ll r; cin>>r;
a[r]++;}
ll k = 0;
rep(i,n){
if(a[i]>0) k++;}
if(k>2) cout << "No" << endl;
else{
if(k == 1){
ll k = 0;
rep(i,n){
if(a[i]>0){
k=i;
break;}
}
if(2*k<=n ||k == n-1) cout << "Yes" << endl;
else cout << "No" << endl;}
else{
k = 0;
ll b = 0, c = 0 , d = 0;
rep(i,n){
if(a[i]>0){
k = i;
b = a[i];
break;}
}
if(a[k+1]==0) cout << "No" << endl;
else{
c = a[k+1];
d = k+1;
ll e = n - d - 1;
if(b<=k && k - e <= b) cout << "Yes" << endl;
else{ cout << "No" << endl;}
}}}}

Measured memory_bytes: 4424
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    vector<int> L(n);
    rep(i, n) {
        cin >> L[i];
    }
    sort(L.begin(), L.end());

    ll ans = n*(n-1)*(n-2)/6LL;
    for(int i = 0; i <= n-3; i++) {
        for(int j = i+1; j <= n-2; j++) {
            int t = L[i] + L[j];
            auto pos = lower_bound(L.begin(), L.end(), t);
            ans -= (ll)(L.end() - pos); 
        }
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

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

const int MAXN = 101;

int sum[MAXN];

int main()
{
    int n;
    while(cin >> n)
    {
        vector<int> p(n);
        REP(n) cin >> p[i];
        sort(all(p));

        sum[0] = p[0];
        REP(n - 1) sum[i+1] = sum[i] + p[i+1];

        long long ans = 0;
        REP(n) ans += sum[i];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 0
/*
 * atcoder/abc089/b.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
void solve();
int main() { solve(); return 0; }

#define ld long double
void solve() {
  string s, t;
  int a, b;
  cin >> s >> t;
  a = stoi(s); b = stoi(t);
  string n = "", m = "";
  loop(i,0,a) n += t;
  loop(i,0,b) m += s;
  if (n > m) swap(n, m);
  cout << n << endl;
}


Measured memory_bytes: 3588
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}

// 二項係数計算
long long COM(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;
}

int main() {
    COMinit();
    ll N, K, mod = 1e9 + 7, sum = 0, ub = 0, lb = 0;
    cin >> N >> K;

    FOR(i, 0, K-1) {
        ub += N - i;
        lb += i;
    }

    // cerr << "ub = " << ub << " lb = " << lb << endl;

    FOR(i, K, N+1) {
        sum += ub - lb + 1;
        sum %= mod;
        ub+=N-i;
        lb+=i;
        if(ub < lb) {
            ub = 0;
            lb = 0;
        }
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 15552
package main

import "fmt"

func main() {
	var k, a, b int
	fmt.Scan(&k, &a, &b)

	ans := k + 1

	k -= a - 1
	v1 := a + (k / 2 * (b - a)) + (k % 2)
	if ans < v1 {
		ans = v1
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=200010;
int a[N],id[N],ans[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline bool cmp(const int &x,const int &y) {return a[x]<a[y];}
int main() {
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) a[i]=gi(),id[i]=i;
    sort(id+1,id+1+n,cmp);
    for(int i=1;i<=n;i++) {
	int t=id[i];
	if(i+i<=n) ans[t]=a[id[n/2+1]];
	else ans[t]=a[id[n/2]];
    }
    for(int i=1;i<=n;i++) printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
typedef pair<int,int> P;
typedef pair<int,P> PP; 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1e9+7;

signed main(){
  int n,d;
  cin>>n>>d;
  d+=d+1;
  cout<<(n+d-1)/d<<endl;
  return 0;
}


Measured memory_bytes: 256
import Text.Printf

main = do
    n <- getLine
    if n == "0"
        then return ()
        else do
            solve
            main

solve = do
    ss <- getLine
    let ns = map (\x -> read x :: Double) $ words ss
    printf "%.8f\n" (sd ns)

variance l = (sum $ map (\x -> (x- (avg l))^2) l) / (fromIntegral $ length l)
avg l = (sum l) / (fromIntegral $ length l)

sd l = sqrt $ variance l


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

    #define speed ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    #define test ll t; cin>>t; while(t--)
    #define ub(a,x) upper_bound(a.begin(),a.end(),x)-a.begin()
    #define lb(a,x) lower_bound(a.begin(),a.end(),x)-a.begin()
    #define ll long long
    #define endl "\n"
    #define all(v) v.begin(),v.end()
    #define ff first
    #define ss second
    #define pb push_back
    #define PI 3.1415926535897932384626
    #define inf 1e18
    #define forn(i, n) for (int i = 0; i < int(n); i++)
    #define MOD 1000000007

    int main()
    {
        speed;
        //test{}
        {
        	ll n,k;
        	cin>>n>>k;
        	ll a[n];
        	ll dp[n];
            forn(i,n)
                dp[i] = INT_MAX;
        	forn(i,n)
        		cin>>a[i];
            dp[0]=0;
        	for(ll i=0;i<n;++i)
        	{
        		for(ll j=1;j<=k;++j)
                {
                    if(i+j<n)
                        dp[i+j] = min(dp[i]+abs(a[i]-a[i+j]),dp[i+j]);
                }
        		
        	}
            
        	cout<<dp[n-1]<<endl;
        }
        return 0;
    }


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
int main() {
    long long N,K;
    cin >> N >> K;
    long  long a[N];
    long  long c = 0;
    long  long d = K;
    vector<long long> cnt;
    for (int i =0;i < N ;i++){
        cin >> a[i];
    }
    for (int i = 0;i< 50;i++){
        cnt.push_back(0);
    }
    for (int i = 0;i < N;i++){
        long long b = a[i];
        c = 0;
        while(b >= 1){
            if(b % 2 == 1){
                cnt[c]++;
            }     
            b = b / 2;
            c++;
        }
    }
    //kの二進法表示をストック
    vector<long long> e;
    for (int i = 0;i< 50;i++){
        e.push_back(0);
    }
    int f = 0;
    while(d >= 1){
        e[f] = d % 2;
        d = d / 2;
        f++;
    }
    bool flag = false;
    int g; 
    for (int i = 0;i < f;i++){
        if (e[f-1-i] == 1){
        if (cnt[f-1-i] <= N / 2){
            cnt[f-1-i] = N - cnt[f-1-i];
        }
        else{
            flag = true;
            g = f- 1 -i;
            break;
        }
        }
    }
    if (flag == true){
        for (int i= 0;i<g;i++){
            if(cnt[i] <= N /2){
                cnt[i] = N - cnt[i];
            }
        }
    }
    long long p = 0;
    long long h = 1;
    for (int i = 0;i < 49;i++){
        p = p + cnt[i]*h;
        h = h * 2;
    }
    cout << p << endl;    
}


Measured memory_bytes: 1024
using System;

class Atcoder126
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);

        if (a >= 13)
            Console.WriteLine(b);
        else if (a >= 6 && a <= 12)
            Console.WriteLine(b / 2);
        else
            Console.WriteLine(0);
    }
}

Measured memory_bytes: 11220
import collections

def other(a, b):
    if(a!="R" and b!="R"):
        return "R"
    if(a!="G" and b!="G"):
        return "G"
    if(a!="B" and b!="B"):
        return "B"


N = int(input())
S = str(input())
counterList = []

for i in range(N):
    counterList.append(collections.Counter(S[i:]))

result = 0
for j in range(1, N-1):
    for i in range(j):
        if(S[i] != S[j]):
            key = other(S[i], S[j])
            result += counterList[j][key]
            if(2*j-i < N):
                if(S[2*j-i] == key):
                    result -= 1
print(result)

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

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n),b(n);
	for(int i = 0;i<n;i++)
	cin >> a[i];
	for(int i = 0;i<n;i++)
	cin >> b[i];
	ll c= 0,d =0;

	for(int i = 0;i<n;i++)
	{
		if(b[i]-a[i]<0)
		{
			d += abs(b[i]-a[i]);
		}
		else 
		{
			c += (b[i]-a[i])/2;
		}
	}
	//cout<<c<<' '<<d<<endl;
	if(c<d)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}


Measured memory_bytes: 3748
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int i,n,q,s[10000],cnt,t,j,flg;
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&s[i]);
	scanf("%d",&q);
	cnt=0;
	for(i=0;i<q;i++)	{
		scanf("%d",&t);
		flg=0;
		for(j=0;j<n;j++)	{
			if(s[j]==t)	{
				flg=1;
				break;
			}
		}
		cnt+=flg;
	}
	printf("%d\n",cnt);
	return 0;
}



Measured memory_bytes: 2768
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,sum1;
    cin>>n;
    
    long long int a[n+1],sum=0,avg;
    for(long long int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    avg=sum/n;
    sum=0;sum1=0;
    for(long long int i=0;i<n;i++)
    {
        sum=sum+pow(a[i]-avg-1,2);
        sum1=sum1+pow(a[i]-avg,2);
    }
    if(sum<sum1)
    cout<<sum;
    else
    cout<<sum1;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int N, M;
    std::cin >> N >> M;

    std::vector<int> a(M);
    std::vector<int> b(M);
    for (int i = 0; i < M; i++) {
        std::cin >> a[i] >> b[i];
    }

    std::vector<int> num(51, 0);
    for (int i = 0; i < M; i++) {
        num[a[i]]++;
        num[b[i]]++;
    }

    for (int i = 1; i <= N; i++) {
        std::cout << num[i] << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void call(int n);

int main(void){
  int n;

  scanf("%d", &n);
  call(n);
  return 0;
}


void call(int n){
  int x, i;

  for(i = 1; i <= n; i++){
    x = i;
    if(x % 3 == 0){
      printf(" %d", i);
      continue;
    }
    while(x){
      if(x % 10 == 3){
	printf(" %d", i);
	break;
      }
      x /= 10;
    }
  }
  printf("\n");
}

Measured memory_bytes: 596
/* ****revpro**** */
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl	   '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii	    map<ll,ll>
using namespace std;

#define N  100005
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;  
//#define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update> 
signed main()
{
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
   // freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    //freopen("output1.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll k,x;
		cin>>k>>x;
		if(k*500>=x){
			cout<<"Yes\n";
		}
		else cout<<"No";	
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

const double pi = 3.141592653589793;

struct Cordinate{
  double x;
  double y;
};

void kock( int n, Cordinate p1, Cordinate p2 ){
  if( n==0 ){
    return;
  }

  Cordinate s, t, u;
  s.x = (2*p1.x+1*p2.x)/3;
  s.y = (2*p1.y+1*p2.y)/3;
  t.x = (1*p1.x+2*p2.x)/3;
  t.y = (1*p1.y+2*p2.y)/3;
  u.x = (t.x-s.x)*cos(pi/3)-(t.y-s.y)*sin(pi/3)+s.x;
  u.y = (t.x-s.x)*sin(pi/3)+(t.y-s.y)*cos(pi/3)+s.y;

  kock( n-1, p1, s );
  cout << fixed << setprecision(8) << s.x << " " << setprecision(8) << s.y << endl;
  kock( n-1, s, u );
  cout << fixed << setprecision(8) << u.x << " " << setprecision(8) << u.y << endl;
  kock( n-1, u, t );
  cout << fixed << setprecision(8) << t.x << " " << setprecision(8) << t.y << endl;
  kock( n-1, t, p2 );
}

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

  Cordinate p1, p2;
  p1.x = 0, p1.y = 0;
  p2.x = 100, p2.y = 0;

  cout << fixed << setprecision(8) << p1.x << " " << setprecision(8) << p1.y << endl;
  kock( n, p1, p2 );
  cout << fixed << setprecision(8) << p2.x << " " << setprecision(8) << p2.y << endl;

  return 0;
}


Measured memory_bytes: 3224
// Nguyen Anh Tu
#include <bits/stdc++.h>
#define FOR(x,a,b) for(int x=a;x<=b;x++)
#define FORD(x,a,b) for(int x=a;x>=b;x--)
#define maxn 100005
#define maxc 1000000007
#define MOD 1000000007
#define reset(x, y) memset(x,y,sizeof(x))
#define task ""
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define pii pair<int,int>
#define ll long long
#define bit(p,x) ((x>>p) & 1)
#define remain(a,b) (a+b >= MOD) ? (a+b - MOD) : (a+b)
using namespace std;
int n;
ll ans;
int main()
{
    ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
    if(fopen(task".inp", "r"))
    {
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    cin >> n;
    for(int i = 1; i<=n ;++i)
    {
        if(i % 3 && i % 5) ans += i;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3636
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
#define pb push_back
using namespace std;using ll = long long;
using vi = vector<ll>;
const int maxn = 1<<18, mod = 998244353;
int tr[2*maxn], n, tin[maxn], tout[maxn], par[maxn], timer = 0;
vi g[maxn];
void upd(int i, int v) {
	for(tr[i += n] = v; i>>=1;) tr[i] = min(tr[i<<1], tr[i<<1|1]);
}
int get(int l, int r) {
	int a = 1<<30;
	for(l += n, r += n+1; l < r; l>>=1, r>>=1) {
		if(l&1) a = min(a, tr[l++]);
		if(r&1) a = min(a, tr[--r]);
	}
	return a;
}
void euler(int v = 1, int p = -1) {
	par[v] = p;
	tin[v] = timer++;
	upd(tin[v], 1<<30);
	for(auto &i : g[v]) {
		if(i == p) continue;
		euler(i, v);
	}
	tout[v] = timer-1;
}
int cur = 0, ans[maxn], used[maxn], cnt = 0;
vi l;
void enq(int v) {
	if(used[v]) return;
	l.pb(v);
	cnt++;
	used[v] = 1;
	upd(tin[v], 1<<30);
	for(auto i : g[v]) {
		if(i == par[v]) continue;
		upd(tin[i], i);
	}
}
void deq(int v) {
	if(!used[v]) return;
	cnt--;
	used[v] = 0;
	upd(tin[v], 1<<30);
	for(auto i : g[v]) {
		if(i == par[v]) continue;
		upd(tin[i], 1<<30);
	}
}
void dfs(int v = 1, int p = -1, int mx = -1) {
	int t, q = l.size();
	enq(v);
	while((t = get(tin[v], tout[v])) < mx) {
		enq(t);
	}
	ans[v] = cnt;
	for(auto i : g[v]) {
		if(i == p) continue;
		dfs(i, v, max(mx, v));
	}
	while(l.size() > q) deq(l.back()), l.pop_back();
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for(int f, t, i = 1; i < n; i++) {
		cin >> f >> t;
		g[f].pb(t);
		g[t].pb(f);
	}
	euler();
	dfs();
	for(int i = 2; i <= n; i++) cout << ans[i]-1 << " ";
}


Measured memory_bytes: 37492
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    A = input_int_list()
    for i in range(n):
        A[i] = A[i] - (i + 1)

    A.sort()

    if n % 2 == 0:
        mid = (A[(n - 1) // 2] + A[((n - 1) // 2) + 1]) // 2
    else:
        mid = A[(n - 1) // 2]

    tmp0 = 0
    tmp1 = 0

    for a in A:
        tmp0 += abs(a - mid)
        tmp1 += abs(a - mid - 1)

    print(min(tmp0, tmp1))

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 93660