akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 5;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const ll N = 1e6+5;
string s;
vector<ll> v[N];
ll n;
ll a[N];

int main () {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  cout << 3*n*n << endl;
}


Measured memory_bytes: 25344
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mood;
		}
		x = x * x % mood;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n;

signed main() {
	cin >> n;
	cout << n * n << endl;
}

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

typedef long long ll;

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

int tmp = 1;
void func(int d) {
    if(d == 0) return;
    tmp *= 100;
    func(d-1);
}

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

    int n; cin >> n;
    vector<ll> a(n);
    int cnt = 0;
    rep(i, n) {
        cin >> a[i];
         while(a[i]%2 == 0) {
            cnt++;
            a[i] /= 2;
        }
    }

    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 384
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

const inf = math.MaxInt64

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt() - (i + 1)
	}
	sort.Ints(a)
	b := a[N/2 : N/2+1]
	if N%2 == 0 {
		b = a[N/2-1 : N/2+1]
	}

	ans := inf
	for _, v := range b {
		cnt := 0
		for i := 0; i < N; i++ {
			cnt += abs(a[i] - v)
		}
		ans = min(ans, cnt)
	}
	out(ans)
}


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var NY = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var N = NY[0];
            var Y = NY[1];

            for (var x = N; 0 <= x; x--)
            {
                for (var y = N - x; 0 <= y; y--)
                {
                    var z = N - x - y;
                    if (x * 10000 + y * 5000 + z * 1000 == Y && x + y + z == N)
                    {
                        Console.WriteLine($"{x} {y} {z}");
                        return;
                    }
                }
            }
            Console.WriteLine("-1 -1 -1");
        }
    }
}


Measured memory_bytes: 13396
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String s=sc.next();
		long mod=1000000007;
		long[][] dp=new long[n+1][n];
		long[] cum=new long[n+1];
		Arrays.fill(dp[1],1);
		for(int i=2; i<=n; i++){
			for(int j=1; j<=n-i+2; j++){
				cum[j]=(cum[j-1]+dp[i-1][j-1])%mod;
			}
			if(s.charAt(i-2)=='<'){
				for(int j=0; j<n-i+1;j++){
					dp[i][j]=(cum[n-i+2]-cum[j+1]+mod)%mod;
				}
			}else{
				for(int j=0; j<n-i+1;j++){
					dp[i][j]=cum[j+1];
				}
			}
		}
		System.out.println(dp[n][0]);
	}
}


Measured memory_bytes: 129872
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n, x, y := io.NextInt(), io.NextInt()-1, io.NextInt()-1
	dist := make([]int, n)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			ij := j - i
			ixyj := Abs(x-i) + 1 + Abs(y-j)
			iyxj := Abs(y-i) + 1 + Abs(x-j)
			d := Min(ij, ixyj, iyxj)
			dist[d]++
		}
	}
	for i := 1; i < n; i++ {
		io.Println(dist[i])
	}
}

// O(n^3): TLE

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

// Abs retuns absolutevalue of input
func Abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// Min returns minimum value of inputs
func Min(a ...int) (min int) {
	for i, ai := range a {
		if i == 0 || ai < min {
			min = ai
		}
	}
	return min
}


Measured memory_bytes: 1828
#include <set>
#include <cstdio>
#include <cstring>
using namespace std;
int v[9999];
int main(){
	int i,n;
	for(;scanf("%d",&n),n;){
		set<int>s;
		memset(v,0,sizeof(v));
		for(i=1;i<n;i++)s.insert(i*i%n);
		set<int>::iterator is,iS;
		for(is=s.begin();is!=s.end();is++)
			for(iS=is,iS++;iS!=s.end();iS++){
				i=*iS-*is;
				if(i>(n-1)/2)i=n-i;
				v[i]++;
			}
		for(i=1;i<=(n-1)/2;i++)printf("%d\n",v[i]*2);
	}
}

Measured memory_bytes: 1308
#include <iostream>

using namespace std;

int main() {
	int d = 0;
	int e = 0;
	int f = 0;
	cin >> d;
	do {
		e += d;
		f++;
		if (e >= 360) {
			e -= 360;
		}
	} while (e != 0);
	cout << f << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m,t;
	while(cin>>n>>m,n){
		pair<int,int> v[m];
		for(int i=0;i<m;i++)v[i]=make_pair(n,i+1);
		for(int i=0;i<n;i++)for(int j=0;j<m;j++)cin>>t,v[j].first-=t;
		sort(v,v+m);
		for(int i=0;i<m-1;i++)cout<<v[i].second<<' ';cout<<v[m-1].second<<endl;
	}
}

Measured memory_bytes: 1164
#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() {
  string S;
  cin >> S;
  if(S=="ABC")
    cout << "ARC" << endl;
  else 
    cout << "ABC" << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
vector<int> D(24);

void f(int d)
{
  for (int i = 0; i <= 12; i++)
  {
    D[(d + i) % 24] = min(D[(d + i) % 24], i);
    D[(d - i + 24) % 24] = min(D[(d - i + 24) % 24], i);
  }
}

int solve(int N, vector<int> &vd)
{
  vector<int> v = {0, 24};
  for (int i = 0; i < N; i++)
  {
    if (D[vd[i]] == 0 && D[24 - vd[i]] == 0)
      return 0;
    if (D[vd[i]] > D[24 - vd[i]])
    {
      f(vd[i]);
      v.push_back(vd[i]);
    }
    else
    {
      f(24 - vd[i]);
      v.push_back(24 - vd[i]);
    }
  }
  sort(v.begin(), v.end());
  int ans = 24;
  for (int i = 1; i < v.size(); i++)
  {
    ans = min(ans, v[i] - v[i - 1]);
  }
  return ans;
}

int main()
{
  int N;
  cin >> N;
  vector<int> vd(N);
  for (int i = 0; i < 24; i++)
  {
    D[i] = min(24 - i, i);
  }
  for (int i = 0; i < N; i++)
  {
    cin >> vd[i];
  }
  sort(vd.begin(), vd.end());
  cout << solve(N, vd) << endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); i++)

using namespace std;

int main() {
  string s;
  int n;
  cin >> n >> s;
  for (auto c : s) {
    cout << static_cast<char>((c - 'A' + n) % 26 + 'A');
  }
  cout << endl;
}


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

typedef long long int ll;
ll n, m, x;
ll c[17], p[17][17], t[17], ans = INT_MAX;

int main() {
    scanf("%lld %lld %lld", &n, &m, &x);
    for(ll i = 0; i < n; ++i) {
        scanf("%lld", &c[i]);
        for(ll j = 0; j < m; ++j) scanf("%lld", &p[i][j]);
    }

    for(ll mask = 0; mask < (1 << n); ++mask) {
        ll cost = 0;
        memset(t, 0, sizeof(t));

        for(ll i = 0; i < n; ++i) {
            if(mask & (1 << i)) {
                cost += c[i];
                for(ll j = 0; j < m; ++j) t[j] += p[i][j];
            }
        }

        bool ok = 0;
        for(ll i = 0; i < m; ++i) {
            if(t[i] < x) {
                ok = 1;
                break;
            }
        }

        if(!ok) {
            ans = min(cost, ans);
        }
    }

    if(ans == INT_MAX) ans = -1;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3816
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
#include <cassert>
using namespace std;

typedef long long ll;

int main() {
	int N, Q; cin >> N >> Q;
	string s; cin >> s;
	s = "@" + s + "@";
	vector<char> t(Q), d(Q);
	for (int i = 0; i < Q; i++) cin >> t[i] >> d[i];
	int pos = 0;
	for (int i = Q - 1; i >= 0; i--) {
		if (pos <= N && t[i] == s[pos + 1] && d[i] == 'L') pos = min(N + 1, pos + 1);
		else if (t[i] == s[pos] && d[i] == 'R') pos = max(0, pos - 1);
	}
	int ans = pos;
	pos = N + 1;
	for (int i = Q - 1; i >= 0; i--) {
		if (pos > 0 && t[i] == s[pos - 1] && d[i] == 'R') pos = max(0, pos - 1);
		else if (t[i] == s[pos] && d[i] == 'L') pos = min(N + 1, pos + 1);
	}
	ans = min(N, ans + N + 1 - pos);
	cout << N - ans << endl;
	return 0;
}


Measured memory_bytes: 896
/**
     **author : _KMS_
     **created : 12-03-2020
**/
#include<bits/stdc++.h>
using namespace std;
const long long M =1e5+100,MOD=2e9;
typedef long long ll;
string s;
int main() 
{ 
      
 ios::sync_with_stdio(false);
 cin.tie(0);
 cin>>s;
 int cnt=0,cnt2=0;
 for(int i=0;i<s.size();i++)
 {
       if(i%2==0&&s[i]=='0')cnt++;
       else if(i%2==1&&s[i]=='1')cnt++;
 }
  for(int i=0;i<s.size();i++)
 {
       if(i%2==0&&s[i]=='1')cnt2++;
       else if(i%2==1&&s[i]=='0')cnt2++;
 }
 cout<<min(cnt,cnt2)<<"\n";
 

 
	return 0; 
} 

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define submitStage int TCF = 1 ;
#define testStage int TCF = 1000 ;
#define Start while(TCF--)

void FastInputOutput(){
  ios_base :: sync_with_stdio( 0 ) ;
  cin.tie( 0 ) ;
  cout.tie( 0 ) ;
}
void ReadFromFile(){
  freopen( "in.txt", "r" , stdin ) ;
}
int D(){
	int t ;
	scanf( "%d" , &t ) ;
	return t ;
}
ll LLD(){
	ll t ;
	scanf( "%lld" , &t ) ;
	return t ;
}

const int N=2e5+7;
void init(){
}
pair<int,int> arr[N];

int main(){
submitStage Start{
  int n=D();
  for(int i =0 ; i < n ; ++i) scanf("%d %d",&arr[i].second , &arr[i].first);
  sort(arr,arr+n);
  ll sum=0 ; bool flag=true;
  for(int i=0 ; i < n ; ++i){
    sum+=arr[i].second;
    if(sum>arr[i].first) {flag=false; break;}
  }
  puts(flag?"Yes" : "No");
}}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(string, S);
  set<char> st;
  each(x, S) st.insert(x);
  print(S.length() == st.size() ? "yes" : "no");
}


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

int main(){
  int A, B;
  cin >> A >> B;
  
  int count = 1;
  
  for(int i = 1; i < 20; ++i) {
    if(B <= 1) {
      cout << 0 << endl;
      break;
    }
    
    if(count <= B) {
      count += A - 1;
    }
    
    if(count >= B) {
      cout << i << endl;
      break;
    }
  }
}

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

int a[101];

int main() {
	// 코틀린 ,문자열 알고리즘 보기, 앳코더, (시간되면 코드포스까지)
	ios_base::sync_with_stdio(false); cin.tie(NULL); //9 90 900 
	int n; cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a, a + n);
	int ans = 999999999;
	for (int i = a[0]; i <= a[n - 1]; i++) {
		int cnt = 0;
		for (int j = 0; j < n; j++) {
			cnt += (i - a[j]) * (i - a[j]);
		}
		ans = min(ans, cnt);
	}
	cout << ans << '\n';




}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
char grid[1000][1000];
int steps[1000][1000];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
queue<pair<int,int> > q; 
int calc(int x,int y){
	int xx=min(min(x,y),min(n-1-x,m-1-y));
	return (xx+k-1)/k+1;
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>m>>k;
	pair<int,int> stt;
	memset(steps,0x3f,sizeof(steps));
	for(int i=0;i<n;i++){
		scanf("%s",grid[i]);
		for(int j=0;j<m;j++){
			if(grid[i][j]=='S'){
				stt=make_pair(i,j); 
			}
		}
	}
	int res=1e9;
	res=min(res,calc(stt.first,stt.second));
	q.push(stt);
	steps[stt.first][stt.second]=0;
	while(!q.empty()){
		stt=q.front();
		q.pop();
		res=min(res,calc(stt.first,stt.second));
		if(steps[stt.first][stt.second]>=k)
			continue;
		for(int i=0;i<4;i++){
			int nx=stt.first+dx[i],ny=stt.second+dy[i];
			if(nx>=0&&nx<n&&ny>=0&&ny<m){
				if(grid[nx][ny]!='#'&&steps[nx][ny]>=1e9){
					steps[nx][ny]=steps[stt.first][stt.second]+1;
					q.push(make_pair(nx,ny));
				}
			}
		}
	}
	cout<<res<<endl;
	return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

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

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	llong r, d, x;
	cin >> r >> d >> x;

	for (int i = 1; i <= 10; i++) {
		x = r*x - d;
		cout << x << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, Q;
    cin >> N >> Q;
    vector<vector<ll>> edges(N);
    for (ll i = 0; i < N - 1; i++) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    vector<ll> num(N, 0);
    for (ll i = 0; i < Q; i++) {
        ll p, x;
        cin >> p >> x;
        num[p - 1] += x;
    }

    stack<pair<ll, ll>> st;
    st.push({0, 0});
    vector<bool> visit(N, false);
    while (!st.empty()) {
        auto t = st.top();
        st.pop();

        ll curr_node = t.first;
        ll add_num = t.second;
        num[curr_node] += add_num;
        visit[curr_node] = true;
        for (ll next_node : edges[curr_node]) {
            if (visit[next_node]) {
                continue;
            }
            st.push({next_node, num[curr_node]});
        }
    }

    for (ll i = 0; i < N; i++) {
        cout << num[i] << " \n"[i == N - 1];
    }
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<int> b(n);
    for(int i = 0; i < n; i++){
        cin >> b[i];
    }
    vector<int> c(n-1);
    for(int i = 0; i < n-1; i++){
        cin >> c[i];
    }
    int prev = -10;
    int sat = 0;
    int sum = 0;
    for(int i = 0; i < n; i++){
        if(a[i] == prev+1){
            sum = sum + b[a[i]-1] + c[prev-1];
            prev = a[i];
        } else {
            sum = sum + b[a[i]-1];
            prev = a[i];
        }
    }
    cout << sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  vector<int> v;

  for (int i = 0; i < n; i++)
  {
    int d;
    cin >> d;
    v.push_back(d);
  }

  sort(v.begin(), v.end());
  int lower = v[floor((n - 1) / 2.0)];
  int upper = v[ceil((n - 1) / 2.0)];

  if (upper == lower)
  {
    cout << 0 << endl;
  }
  else
  {
    cout << upper - lower << endl;
  }
}

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

int main()
{
	string s1,s2;
	int n;
	cin>>n;
	while(n--)
	{
		cin>>s1>>s2;
		if(s1.size()>81||s2.size()>81) cout<<"overflow"<<endl;
		else
		{
			int ans[90],now=1;
			int size1=s1.size(),size2=s2.size();
			bool over=false;
			while(1)
			{
				ans[now-1]=0;
				if(size1==0&&size2==0&&!over) break;
				
				if(size1>0)
				{
					ans[now-1]+=s1[size1-1]-'0';
					size1--;
				}
				if(size2>0)
				{
					ans[now-1]+=s2[size2-1]-'0';
					size2--;
				}

				if(over)
				{
					ans[now-1]+=1;
					over=false;
				}
				if(ans[now-1]>=10)
				{
					ans[now-1]%=10;
					over=true;
				}
				now++;
			}
			if(now>81) cout<<"overflow"<<endl;
			else
			{
				for(int i=now-2;i>=0;i--)
				{
					cout<<ans[i];
				}
				cout<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1204
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {

    static List<List<Integer>> edge_;

    static int[] answer_;

    static Deque<Integer> stack_;

    static boolean[] isChecked_;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Integer n = Integer.parseInt(scan.next());
        Integer q = Integer.parseInt(scan.next());

        edge_ = new ArrayList<List<Integer>>();
        for (int i = 0; i <= n; i++) {
            edge_.add(new ArrayList<Integer>());
        }

        for (int i = 0; i < n - 1; i++) {
            Integer a = Integer.parseInt(scan.next());
            Integer b = Integer.parseInt(scan.next());
            edge_.get(a).add(b);
            edge_.get(b).add(a);
        }

        answer_ = new int[n + 1];
        for (int i = 0; i < q; i++) {
            Integer p = Integer.parseInt(scan.next());
            Integer x = Integer.parseInt(scan.next());
            answer_[p] += x;
        }
        scan.close();

        isChecked_ = new boolean[n + 1];
        stack_ = new ArrayDeque<Integer>();
        pushNode(1, 0);
        while (!stack_.isEmpty()) {
            int node = stack_.poll();
            isChecked_[node] = true;
            for (Integer i : edge_.get(node)) {
                pushNode(i, answer_[node]);
            }
        }

        for (int i = 1; i <= n; i++) {
            System.out.print(answer_[i]);
            if (i != n) {
                System.out.print(" ");
            }
        }
    }

    private static void pushNode(int node, int value) {
        if (isChecked_[node]) {
            return;
        }
        answer_[node] += value;
        stack_.push(node);
    }
}


Measured memory_bytes: 155032
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <tuple>
#include <complex>
#include <stdio.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LD PI = acos(-1.0);
const LL mod = 1000000007;
const LL INF = 1e9;
const LL MAXN = 100001;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);

	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;

	FOR(i, n, 2*n + 1)
	{
		bool ok = 1;

		FOR(j, 0, 2 * n - i)
			if (t[j] != s[j + i - n])
				ok = 0;

		if (ok)
		{
			cout << i;
			return 0;
		}
	}
	cout << 2 * n;
	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    ans = 0
    for i in range(1, n):
        if a[i-1] > a[i]:
            gap = a[i-1] - a[i]
            a[i] += gap
            ans += gap
        
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 32232
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
using pii=pair<int,int>;
using vs=vector<string>;
using vpii=vector<pii>;

#define REP(i,a) for(int i=0;i<a;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rREP(i,a) for(int i=(a)-1;i>=0;i--)
#define rFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define out(S) cout<<(S)<<endl;
#define beginend(v) (v).begin(),(v).end()
#define IfOut(condition,text) if(condition){out(text);return 0;}
#define IfOutElse(condition,if_text,else_text) if(condition){out(if_text);return 0;}else{out(else_text);return 0;}
#define mod(s) ((s)%(ll)(1e9+7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a*modpow((ll)b,(ll)(1e9+5))))
#define pb(i) push_back(i)
#define fst first
#define snd second
#define Foreach(item,collection) for(auto item:collection)
#define INF 1e10
#define removeAll(vec,deleg) auto itr=remove_if(beginend(vec),deleg);vec.erase(itr,vec.end());
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
ll manhattanDistance(ll x1, ll y1, ll x2, ll y2) { return (abs(x2 - x1) + abs(y2 - y1)); }
vector<ll> sieveOfEratosthenes(int max) {ll prime;double sqrtmax = sqrt(max);vector<ll> primeVec, searchVec;FOR(i, 2, max + 1) searchVec.push_back(i);do{prime = searchVec[0];primeVec.push_back(prime);auto itr = remove_if(beginend(searchVec), [=](ll x)->bool {return x%prime == 0; });searchVec.erase(itr, searchVec.end());} while (prime < sqrtmax);primeVec.reserve(primeVec.size() + searchVec.size());primeVec.insert(primeVec.end(), beginend(searchVec));return primeVec;}
ll sum(vi v) {ll sum=0;Foreach(i,v){sum+=i;}return sum;}
#define ShowAll(v) Foreach(i,v) out(i);


int main(){
    vi ans;
    int n;
    cin>>n;
    int year3=590;
    ll miday=196471;
    REP(i,n){
        int Yi,Mi,Di;
        cin>>Yi>>Mi>>Di;
        Yi--;
        Mi--;
        ll birthday=Yi/3*year3+Yi%3*195+((Yi+1)%3==0?Mi*20:(Mi/2*39+Mi%2*20))+Di;
        ans.pb(miday-birthday);
    }

    ShowAll(ans);
    
    return 0;
}

Measured memory_bytes: 3040
#include <iostream>
using namespace std;
const int size = 21;
int map[size][size] = { 0 };

int main(){
	int n,m;
	while (1){
		cin >> n;
		if (n == 0) break;
		for (int i = 0; i < size; i++){
			for (int j = 0; j < size; j++){
				map[i][j] = 0;
			}
		}
		int cnt = 0; //???????????????????????°
		int rbx = 10, rby = 10; //???????????§?¨?
		//???????????????????????°
		for (int i = 0; i < n; i++){
			int x, y;
			cin >> x >> y;
			map[y][x] = 1;
		}
		//??????????????????
		cin >> m;
		for (int i = 0; i < m; i++){
			char d;
			int t;
			cin >> d >> t;
			switch (d){
			case 'N':
				for (int i = 0; i < t; i++){
					rby++;
					if (map[rby][rbx] == 1){
						cnt++;
						map[rby][rbx] = 0;
					}
				}
				break;

			case 'E':
				for (int i = 0; i < t; i++){
					rbx++;
					if (map[rby][rbx] == 1){
						cnt++;
						map[rby][rbx] = 0;
					}
				}
				break;

			case 'S':
				for (int i = 0; i < t; i++){
					rby--;
					if (map[rby][rbx] == 1){
						cnt++;
						map[rby][rbx] = 0;
					}
				}
				break;

			case 'W':
				for (int i = 0; i < t; i++){
					rbx--;
					if (map[rby][rbx] == 1){
						cnt++;
						map[rby][rbx] = 0;
					}
				}
				break;
			}
		}
		if (cnt == n){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define Senky_Bansal ios::sync_with_stdio(0); 
#define IIIT_ALLAHABAD cin.tie(0); cout.tie(0);
#define int long long
const int N=1e5+5;
int n, W;
int v[N],w[N];
int cache[102][N];
 
int dp(int idx,int weight)
{
	if(weight>W)
		return -1e18;
	if(idx>n)
		return 0;
	int &ans=cache[idx][weight];
	if(ans!=-1)
		return ans;
	ans=max(dp(idx+1,weight),v[idx]+dp(idx+1,weight+w[idx]));
	return ans;
}
 
signed main()
{
	Senky_Bansal
	IIIT_ALLAHABAD

	memset(cache, -1, sizeof(cache));
	cin>>n>>W;
	for(int i=1;i<=n;i++)
		cin>>w[i]>>v[i];
	int ans=dp(1,0);
	cout<<ans;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  int a;
  bool app = true;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a % 2 == 0 && (a % 3 != 0 && a % 5 != 0)) {
      app = false;
      break;
    }
  }
  
  if (app)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << endl;
  
  return 0;
}

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

int main() {
  int w, h, n, ans = 0;
  int x, y, a;
  cin >> w >> h >> n;
  vector<int> M(w*h, 0);
  for (int i = 0; i < n; i++) {
    cin >> x >> y >> a;
    for (int j = 0; j < h; j++) {
      for (int k = 0; k < w; k++) {
        if (a == 1) {
          if (k < x) M.at(k + j*w) = 1;
        } else if (a == 2) {
          if (k >= x) M.at(k + j*w) = 1;
        } else if (a == 3) {
          if (j < y) M.at(k + j*w) = 1;
        } else if (a == 4) {
          if (j >= y) M.at(k + j*w) = 1;
        }
      }
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (M.at(j + i*w) == 0) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
import math
def solve():
    N, H = map(int, input().split())
    katana = []
    for i in range(N):
        a, b = map(int, input().split())
        katana.append((a, 0, i))
        katana.append((b, 1, i))
    katana = sorted(katana, reverse = True)
    ans = 0
    for i in range(N*2):
        k = katana[i]
        #print(H, ans, k)
        if H<=0:
            return ans
        if k[1]==0:
            break
        H-=k[0]
        ans+=1
    return ans+math.ceil(H/k[0])
print(solve())

Measured memory_bytes: 30824
#include<bits/stdc++.h>
#define maxd 120
#define maxn 120000
using namespace std;
const int mod = 1000000007;
char s[maxn];
int K[maxn];
int f[maxn][maxd];
int main(){
	int D;
	cin >> s + 1 >> D;
	int n = strlen(s + 1);
	for(int i = 1; i <= n; i += 1) K[i] = s[i] - '0';
	int sum = 0;
	f[0][0] = 1;
	for(int i = 1; i <= n; i += 1){
		for(int j = 0; j < D; j += 1)
			for(int k = 0; k < 10; k += 1)
				f[i][j] = (f[i][j] + f[i - 1][(j + 10 * D - k) % D]) % mod;
		for(int k = K[i] + 1; k < 10; k += 1)
			f[i][(sum + k) % D] = (f[i][(sum + k) % D] + mod - 1) % mod;
		sum = (sum + K[i]) % D;
		
	}
	cout << (f[n][0] + mod - 1) % mod;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
ll C, K;
ll T[MAX_N];

void solve() {
	cin >> N >> C >> K;
	rep(i, 0, N) cin >> T[i];
	sort(T, T + N);
	int at = 0;
	int res = 0;
	rep(i, 0, N) {
		if(i < at) continue;
		res++;
		int k = 0;
		while(k < C && at < N && T[at] - T[i] <= K) {
			at++;
			k++;
		}
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h> 
using namespace std;
#define ll long long
#define endl "\n"
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    int ans=0;
    bool ar[n][m];
    for(int i=0;i<n;i++)for(int j=0;j<m;j++){
        char x;cin>>x;
        ar[i][j]= x == '#';
    }
    for(int i=0;i<(1<<n);i++){
        for(int j=0;j<(1<<m);j++){
            int cnt=0;
            for(int x=0;x<n;x++){
                for(int y=0;y<m;y++){
                    if(ar[x][y]&&(i&(1<<x))&&(j&(1<<y)))cnt++;
                }
            }
            if(cnt==k)ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
} 

Measured memory_bytes: 3648
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

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

    ll count500 = x / 500;
    ll remain = x % 500;

    ll count5 = remain / 5;

    cout << count500 * 1000 + count5 * 5 << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <iomanip>
#include <set>
#include <sstream>
#include <cmath>
#include <deque>
#include <list>
#include <bitset>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define FST first
#define SND second

signed main(){
    lint N, M; cin>>N>>M;
    vector<lint> A(N);
    priority_queue<lint, vector<lint>, greater<lint> > pq;
    REP(i, N){
        lint a; cin>>a;
        pq.push(a);
    }
    vector<P> B(M);
    REP(i, M){
        lint b, c; cin >> b >> c;
        B[i] = P(c, b);
    }
    sort(ALL(B), greater<P>());
    REP(i, M){
        lint b = B[i].second, c = B[i].first;
        if(pq.top()>=c) break;
        while(pq.top()<c and b){
            pq.pop();
            pq.push(c);
            b--;
        }
    }
    lint res = 0;
    while(pq.size()){
        lint x = pq.top(); pq.pop();
        res += x;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

vector<string> split(const string &s, char delim) {
    vector<string> elems;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
    if (!item.empty()) {
            elems.push_back(item);
        }
    }
    return elems;
}

ll eval(string s){
    vector<string> vs = split(s, '+');
    ll ret = 0;
    for(string a : vs){
        ll t = stoll(a);
        ret += t;
    }
    return ret;
}



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;cin>>S;
    int n = S.size();
    ll ans = 0;
    for(int bit=0; bit<(1<<n-1); bit++){
        string s = "";
        for(int i=0; i<n-1; i++){
            s += S[i];
            if((1<<i) & bit){
                s+="+";
            }
        }
        s += S[n-1];
        ans += eval(s);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    T, A = il()
    H = il()
    S = []

    for h in H:
        S.append(abs(A-(T-(h*0.006))))
    print(S.index(min(S))+1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
int main()
{
    //freopen("C.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int dif;
    vii mat(3, vi(3));
    rep(i, 0, 3)
    {
        rep(j, 0, 3)
        {
            cin >> mat[i][j];
        }
    }
    rep(i, 1, 3)
    {
        dif = mat[i][0] - mat[i - 1][0];
        rep(j, 1, 3)
        {
            if (mat[i][j] - mat[i - 1][j] != dif)
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    rep(j, 1, 3)
    {
        dif = mat[0][j] - mat[0][j-1];
        rep(i, 1, 3)
        {
            if (mat[i][j] - mat[i][j-1] != dif)
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<cstdio>
#include<cstring>
#include<algorithm>
const int MAXN=100010;
int h[MAXN],f[MAXN];

int main(){
	int n,k;scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&h[i]);
	memset(f,0x3f,sizeof(f));
	f[1]=0;
	for(int i=2;i<=n;i++){
		for(int j=1;j<=std::min(i-1,k);j++)
			f[i]=std::min(f[i],std::abs(h[i]-h[i-j])+f[i-j]);
	}
	printf("%d\n",f[n]);
}

Measured memory_bytes: 896
def bubble_sort(arr, n):
    for i in range(n):
        for j in reversed(range(i + 1, n)):
            if arr[j - 1].value > arr[j].value:
                arr[j - 1], arr[j] = arr[j], arr[j - 1]
    return arr


def selection_sort(arr, n):
    for i in range(n):
        min_idx = i
        for j in range(i, n):
            if arr[j].value < arr[min_idx].value:
                min_idx = j
        if min_idx != i:
            arr[i], arr[min_idx] = arr[min_idx], arr[i]
    return arr


class Card:
    def __init__(self, card_str):
        self.value = int(card_str[1])
        self.mark = card_str[0]
        self.str = card_str


def is_stable(stable_arr, target_arr):
    for s, t in zip(stable_arr, target_arr):
        if s.str != t.str:
            return False
    return True


def main():
    n = int(input())
    # cards = ["H4", "C9", "S4", "D2", "C3"]
    cards = input().split()
    arr = [Card(card_str) for card_str in cards]
    # n = 5
    b_arr = bubble_sort(arr, n)
    print(" ".join([b.str for b in b_arr]))
    print("Stable")
    arr = [Card(card_str) for card_str in cards]
    s_arr = selection_sort(arr, n)
    print(" ".join([s.str for s in s_arr]))
    if is_stable(b_arr, s_arr):
        print("Stable")
    else:
        print("Not stable")


if __name__ == "__main__":
    main()



Measured memory_bytes: 5608
import java.util.*;
import java.io.*;

class Main {
  public static String rotate(String s, int offset) {
    int i = offset % s.length();
    return s.substring(i) + s.substring(0, i);
  }
  public static void main(String[] args) throws Exception{
    try (Scanner sc = new Scanner(System.in)){
      String S = sc.next();
      String T = sc.next();
      boolean flag = false;
      for (int i = 0; i < S.length(); i++) {
        if (T.equals(rotate(S,i))) {
          flag = true;
        }
      }
      if (flag) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }

    }
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <cmath>
#include <sstream>
#include <algorithm>

using namespace std;

int main() {
	int K, N;
	vector<int> stick;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int t;
		cin >> t;
		stick.push_back(t);
	}
	sort(stick.begin(), stick.end());
	int total = 0;
	for (int i = 0; i < K; i++) {
		total += stick[N-1-i];
	}
	cout << total << endl;

	return 0;
}


Measured memory_bytes: 256
import bisect
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
for i in range(N):
    x = bisect.bisect_left(A, B[i])
    y = N-bisect.bisect_right(C, B[i])
    ans += x*y
print(ans)

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define PI 3.141592653589793
#define mod 1000000007
#define N 1000005
//int N;
//# define N 2003
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
# define INF 100000000
# define A 1000000

int main()
{
	IOS;
	ll n,m;
	cin >> n >> m;
	if(n>m)
		swap(n,m);
	ll ans;
	if(n==1)
	{
		if(m==1)
		 {
		 	cout << "1";
		   return 0;
		 }
		 else if(m==2)
		 {
		 	cout << "0";
		 	return 0;
		 }
		 else
		 {
		 	cout << (m-2);
		 	return 0;
		 }
	}
	else if(n==2)
	{
		cout << "0";
		return 0;
	}
	else
	{
		ans=(n-2)*(m-2);
		cout << ans;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
 
int main() {
  char a;
  cin >> a;
  if(((a + 0) >= ('a' + 0)) && ((a + 0) <= ('z' + 0))) cout << 'a' << endl;
  else cout << 'A' << endl;
}

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'

vector<string> v;
int n;

void f(string s,int last,int len)
{
    if(len==n)
    {
        v.pb(s);
        return;
    }
    ffor(i,0,last+1)
    {
        string s1=s+(char)(i+'a');
        f(s1,last,len+1);
    }
    
    string s1=s+(char)(last+1+'a');
    f(s1,last+1,len+1);
}

int main()
{
    cin>>n;
    f("a",0,1);
    sort(all(v));
    set<string> s;
    for(auto i:v) s.insert(i);
    for(auto i:s) cout<<i<<endl;
    return 0;
}



Measured memory_bytes: 13300
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int IsPrime(int n){
    int i;
  
    if(n < 2)
        return 0;
    else if(n == 2)
        return 1;
  
    if(n % 2 == 0)
        return 0;
  
    for(i = 3; i <= n / i; i += 2)
         if(n % i == 0)
            return 0;
    return 1;
}
 
int main (){
int a,b,c,d=0,e,f=0,g;
int sosu[1000000]={};
int kaisu[100];
for(b=2;b<1000000;b++){
    if(IsPrime(b)==1)d++;
    sosu[b]=d;
}
while(scanf("%d",&a)!=EOF){
    kaisu[f]=sosu[a];
 
    f++;
     
}
for(e=0;e<f;e++)
printf("%d\n",kaisu[e]);
}




Measured memory_bytes: 5600
//:::: Alien :::://
// Muhammad Eid //
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define prINT pair<int, int>

const int N = 10 +5;
bool fr[N];

void Mo35(){ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}

int main(){
Mo35();

    int in, sz; string s;
    int n, k; cin>> n>> k;
    for(int i=0; i<k; ++i) cin>> in, fr[in] = true;
    for(int i=n; i<1e6+5; ++i){
        s = to_string(i); sz = s.size();
        for(int j=0; j<sz; ++j){
            if(fr[s[j]-'0']) goto loop;
        }
        cout<<i;
        break;
        loop:;
    }

return 0;
}

Measured memory_bytes: 3732
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{int n,l[10000],s,i;
   while(~scanf("%d",&n))
      {s=0;
      for(i=0;i<2*n;i++)
        scanf("%d",&l[i]);
        sort(l,l+2*n);
        for(i=0;i<2*n;i=i+2)
        s=s+l[i];
        printf("%d\n",s);
      }
}

Measured memory_bytes: 256
#include <iostream>
    #include <stdio.h>
    #include <string>
    #include <cstdlib>
    #include <cmath>
    #include <algorithm>
    #include <string.h>
    #include <queue>
    #include <stack>
    #define _USE_MATH_DEFINES
    #define LL long long
    #define front top
    using namespace std;
    const double PI = acos(-1.0);
     
    int smax(int ary[]) {
    	int m = 0;
    	for (int i = 0; i < sizeof(ary) / sizeof(ary[0]); i++)
    		if (m < ary[i]) m = ary[i];
    	return m;
    }
     
    int nmax(int ary[]) {
    	int max = 0, num;
    	for (int i = 0; i < sizeof(ary) / sizeof(ary[0]); i++)
    		if (max < ary[i]) {
    			max = ary[i];
    			num = i;
    		}
    	return max, num;
    }
     
    bool dfs(int q, int value) {
    	return false;
    }
     
    int max2(int a, int b) {
    	if (a < b) a = b;
    	return a;
    }
     
    int min2(int a, int b) {
    	if (a > b) a = b;
    	return a;
    }
     
    int max3(int a, int b, int c) {
    	return max2(a, max2(b, c));
    }
     
    int min3(int a, int b, int c) {
    	return min2(a, min2(b, c));
    }
     
    int main() {
    	int n, k, l[50], sum = 0;
    	cin >> n >> k;
    	for (int i = 0; i < n; i++) cin >> l[i];
    	sort(l, l + n);
    	for (int i = 0, j = n - 1; i < k; i++, j--) {
    		sum += l[j];
    	}
    	cout << sum << endl;
    	return 0;
    }

Measured memory_bytes: 256