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

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define MP make_pair
#define n1 first
#define n2 second
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const int INF = 1e9;
const int MOD = 1000000007;
const int N = 202055;
const int M = 1211;

int a[N];
void solve() {
    int n;
    cin >> n;

    for (int i = 1; i <= n; i++){
        cin >> a[i];
    }

    int minx = INF;
    for (int x = -100; x <= 100; x++){
        int sum = 0;
        for (int i = 1; i <= n; i++){
            sum += sqr(x-a[i]);
        }
        minx = min(minx, sum);
    }

    cout << minx;

}

int main() {
    ios_base::sync_with_stdio(false);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


N = readint()
ans = 0
for i in range(1, N + 1, 2):
    if len(make_divisors(i)) == 8:
        ans += 1

print(ans)


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<pair<ll,ll>> svpl;
    char tmp = s.at(0);
    ll num = 1;
    for(i = 1;i < n;++i){
        if(s.at(i) == tmp) ++num;
        else{
            svpl.emplace_back(tmp-'0',num);
            tmp = s.at(i);
            num = 1;
        }
    }
    svpl.emplace_back(tmp,num);
    ll m = svpl.size();
    ll ans = 0;
    /**
    if(svpl.front().first == 0){
        for(i = 0;i < min(m, 2*k);++i){
            tmpans += svpl.at(i).second;
        }
    }else{
        for(i = 0;i < min(m, 2*k+1);++i){
            tmpans += svpl.at(i).second;
        }
    }
    **/
    for(i = 0;i < max(1ll, m-2*k+1);++i){
        ll tmpans = 0;
        if(svpl.at(i).first == 0){
            for(j = i;j < min(m, i + 2*k);++j){
                tmpans += svpl.at(j).second;
            }
        }else{
            for(j = i;j < min(m, i + 2*k+1);++j){
                tmpans += svpl.at(j).second;
            }
        }
        ans = max(ans, tmpans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2548
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<limits.h>
#include<string>
#include<math.h>
#include<map>
#include<unordered_map>

using namespace std;

int main() 
{ 
	cout.precision(20);
	int n;
	cin>>n;
	long double dp[n+1][n+1];
	long double prob[n+1];
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		cin>>prob[i];
		dp[i][i]=dp[i-1][i-1]*prob[i];
	}
	for(int i=1;i<=n;i++){
		// long double x = 
		dp[0][i] = (1-prob[i])*dp[0][i-1];
		dp[i][0] = 0;
		// cout<<dp[0][i]<<endl;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(i>j)
				dp[i][j]=0;
			else{
				// long double p = dp[i-1][j-1];
				dp[i][j] = dp[i-1][j-1]*prob[j] + dp[i][j-1]*(1-prob[j]);
			}
		}
	}
	// for(int i=0;i<=n;i++){
	// 	for(int j=0;j<=n;j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// 	cout<<endl;
	// }
	long double answer = 0;
	for(int i=n/2+1;i<=n;i++){
		answer+=dp[i][n];
	}
		cout<<answer;

} 

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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

// constexpr int INF = 1e9;
// constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;


int main(){
  int N, D;
  cin >> N >> D;
  vector<ll> X(N), Y(N);
  REP(i, N){
    cin >> X[i] >> Y[i];
  }
  int cnt = 0;
  REP(i, N){
    double dist = sqrt(X[i]*X[i]+Y[i]*Y[i]);
    if(dist <= D){
      cnt++;
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 6340
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T1, class T2>bool chmax(T1& a, const T2& b) { return a < b ? a = b, 1 : 0; }
template<class T1, class T2>bool chmin(T1& a, const T2& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    vector<ll> inv(N);

    rep(i, N) {
        rep(j, i + 1, N) {
            if (A[j] < A[i]) {
                inv[i]++;
            }
        }
    }

    vector<ll> smaller(N);
    rep(i, N) {
        rep(j, N) {
            if (A[j] < A[i]) {
                smaller[i]++;
            }
        }
    }

    ll ans = 0;
    rep(i, N) {
        ans = (ans + inv[i] * K) % MOD;
        ans = (ans + K * (K - 1) / 2 % MOD * smaller[i]) % MOD;
    }

    write(ans);
}

Measured memory_bytes: 256
N, M = list(map(int, input().split()))

class UnionFind():
	def __init__(self, n):
		self.parents = [-1] * n

	def find(self, x):
		if self.parents[x] < 0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)

		if x == y:
			return

		if self.parents[x] > self.parents[y]:
			x, y = y, x

		self.parents[x] += self.parents[y]
		self.parents[y] = x

	def roots(self):
		return [i for i, x in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

uf = UnionFind(N)
for _ in range(M):
	a, b = [int(t) - 1 for t in input().split()]
	uf.union(a, b)

ans = uf.group_count() - 1
print(ans)


Measured memory_bytes: 13132
def main():
  def sieve(n):
    prime=[]
    limit=n*0.5
    data=[i+1 for i in range(1,n)]
    p_append=prime.append
    while True:
        p=data[0]
        if limit<=p:
            return prime+data
        p_append(p)
        data=[e for e in data if e%p!=0]
        
  prime=sieve(1000)
  import sys
  import numpy as np
  input=sys.stdin.readline
  mod=10**9+7
  
  n=int(input())
  num=list(map(int,input().split()))
  num_copy=np.array(num)
  
  lcm=1
  for p in prime:
    while np.any(num_copy%p==0):
      num_copy[num_copy%p==0]//=p
      lcm *= p
      lcm %= mod
  
  for i in set(num_copy.tolist()):
    lcm *= i
    lcm %= mod
    
  #print(lcm,num)
  ans=0
  for i in range(n):
    ans += lcm * pow(num[i] ,mod-2 ,mod)
    ans %= mod 
    #print(ans)
  print(ans)
  
if  __name__=='__main__':
  main()

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

int main()
{
    int n, x, sum = 0;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> x;
        sum += x;
    }
    cout << sum-n << endl;
    return 0;
}

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

using namespace std;

int main() {
	string str, cmd;
	int a, b, q;
	cin >> str >> q;
	for (int i = 0; i < q; i++) {
		cin >> cmd >> a >> b;
		if (cmd == "print") {
			for (int j = a; j <= b; j++)
				cout << str[j]; cout << endl;
		}
		else if (cmd == "reverse") {
			int fend = (b - a + 1) / 2;
			for (int j = 0; j < fend; j++)
				swap(str[a++], str[b--]);
		}
		else if (cmd == "replace") {
			string p; int n = 0;
			cin >> p;
			for (int k = a; k <= b; k++) {
				str[k] = p[n++];
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1212
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n,a,b=MAP()
    print(min(n*a,b))

if  __name__=='__main__':
    main()


Measured memory_bytes: 5716
#include <stdio.h>

int main()
{
	int s,f,t,total;
	int i,j,n;
	
	scanf("%d",&t);
	while(t != 0){
		//初期化
		total = 0;

		scanf("%d",&n);
		for(i = 0; i < n; i++){
			scanf("%d%d",&s,&f);
			total += f-s;
		}

		if(total < t)	printf("%d\n",t-total);
		else			printf("OK\n");

		scanf("%d",&t);
	}

	return 0;
}

Measured memory_bytes: 1040
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

#define REP(i, n) for (int (i) = 0; (i) < (n); (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 FORR(i, a, b) for(int (i) = (a)-1; (i) >= (b); (i)--)
#define PI acos(-1.0)
#define DEBUG(C) cout<< C <<endl;
#define VI vector <int>
#define VII vector <VI>
#define VL vector <LL>
#define VLL vector <VL>
#define VD vector <double>
#define VDD vector <VD>
#define PII pair <int, int>
#define PDD pair <double, double>
#define PLL pair <LL, LL>
#define VPII vector <PII>
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define REVERSE(a) reverse(ALL(a))
#define MP make_pair
#define FORE(a,b) for(auto &&a:b)

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF = 1e9;
const int MOD = INF+7;
#define int LL
signed main(void) {
    int A, B, C;
    cin >> A >> B >> C;
    if ((A*B*C)%2 == 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << min({A*B, B*C, C*A}) << endl;
}


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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

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

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	int n;cin>>n;
	int as=0;
	vc<pi> ab;
	rep(_,n){
		int a,b;cin>>a>>b;
		ab.eb(max(a,b),b);
		as+=a;
	}
	sort(all(ab),greater<pi>());
	
	int s=0,k=0;
	while(1){
		s+=ab[k++].a;
		if(s>=as)break;
	}
	
	int num=1,den=1;
	auto upd=[&](int x,int y){
		if(num*y>x*den)
			tie(num,den)=tie(x,y);
	};
	rep(i,n){
		int w=as-(s-ab[min(i,k-1)].a);
		if(w<=ab[i].b)
			upd(w,ab[i].b);
	}
	
	num=den-num+den*(n-k);
	den*=n;
	int g=gcd(num,den);
	cout<<num/g<<" "<<den/g<<endl;
}


Measured memory_bytes: 2420
def Guide():
    N = int(input())
    lst = []
    for i in range(1, N + 1):
        city, score = input().split()
        lst.append([city, int(score), i])
    sorted_lst = sorted(lst, key=lambda x:(x[0], -x[1]))

    for l in sorted_lst:
        print(l[2])


Guide()


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    int top = 0;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        top = max(top, ++mp[s]);
    }
    vector<string> a;
    for (auto p : mp) {
        if (p.second == top) a.push_back(p.first);
    }
    sort(begin(a), end(a));
    for (auto s : a) {
        cout << s << '\n';
    }
    return 0;
}

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

int main(){
  double a, b, x;
  cin >> a >> b >> x;
  const double PI=3.1415926535897932;
  double res;
  double c = a*b*b/2/x;
  double d = (2*(b-x/a/a))/a;
  double ra = atan(c);
  double rb = atan(d);
  
  if(x < a*a*b/2){
    if(ra < 0){
      //r = PI/2 ＋ r;
      res = 180*ra/PI;
    }
    else{
      res = 180*ra/PI;
    }
  }
  else{
    res = 180*rb/PI;
  }
    
  cout << fixed << setprecision(10);
  cout << res << endl;
      
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int a,b,c,d,i,p,q,k=0;
    cin>>a>>b>>c>>d;
    while(a>0 && c>0)
    {
      if(k%2==0) {
         c-=b;k++;
      }
      else {
         a-=d;k++;
      }
    }
       if(a<=0)
         cout<<"No"<<endl;
         else cout<<"Yes"<<endl;


}


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

int alpha[26];
int bet[26];
int main(){
    string s;
    string t;

    cin >> s >> t;
    int ng_flg = 0;
    for (int i = 0; i < s.size(); i++){
        int tmp = (int)t[i] - (int)'a';
        if (alpha[tmp] == 0){
            alpha[tmp] = (int)s[i];
        } else {
            //printf("%d:%c, %c\n",i, (char)alpha[tmp], (char)s[i]);
            if (alpha[tmp] != (int)s[i]){
                ng_flg = 1;
            }
        }
    }
    for (int i = 0; i < s.size(); i++){
        int tmp = (int)s[i] - (int)'a';
        if (bet[tmp] == 0){
            bet[tmp] = (int)t[i];
        } else {
            //printf("%d:%c, %c\n",i, (char)alpha[tmp], (char)s[i]);
            if (bet[tmp] != (int)t[i]){
                ng_flg = 1;
            }
        }
    }
    if (ng_flg == 0){
        printf("Yes");
    }else{
        printf("No");
    }
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt int Q[100005]={0}
#define mp make_pair
#define test() int t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<int>()) 
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(int i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(int i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=mpowe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}

string s;
ll tree[400000+5];
ll a[100000+5];
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a;
    if(a==0)
        return b; 
    return gcd(b, a % b);  
      
}
void build(ll node,ll start,ll end)
{
    if(start==end)
    {
        tree[node]=a[start];
        
    }
    else
    {
        ll mid = (start+end)/2;
        build(2*node+1,start,mid);
        build(2*node+2,mid+1,end);
        tree[node]=gcd(tree[2*node+1],tree[2*node+2]);
    }
}
void update(ll tree[],ll node,ll start,ll end,ll idx)
{
    if(start==end)
    {
        tree[node] = max(0LL,tree[node]-1);
    }
    else
    {
        ll mid = (start+end)/2;
        if(start<=idx && mid>=idx)
        {
            update(tree,2*node+1,start,mid,idx);
        }
        else
        {
            update(tree,2*node+2,mid+1,end,idx);
        }
        tree[node] = tree[2*node+1]+tree[2*node+2];
    }
}
ll query(ll node,ll start,ll end,ll l,ll r)
{
    if(r<start || l>end)
    {
        return 0;
    }
    if(l<=start && r>=end)
    {
        return tree[node];
    }
    ll mid = (start+end)/2;
    ll p1 = query(2*node+1,start,mid,l,r);
    ll p2 = query(2*node+2,mid+1,end,l,r);
   return gcd(p1,p2);
}

int main()
{                       
    fastio();
    
    ll n;
    cin>>n;
    ll a = n/500;
    ll b = n%500;
    b = b/5;
    b=a*1000+b*5;
    cout<<b<<endl;
}

Measured memory_bytes: 256
n = int(input())
c = []
bs = 0
for i in range(n):
  a,b = map(int,input().split())
  bs += b
  c.append(a+b)

c.sort()

ans = -bs
for i in reversed(range(n)):
  cnt = n-1-i
  if cnt%2==0: ans += c[i]
    
print(ans)


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll a, b, k; cin >> a >> b >> k;
  if (a >= k) {
    cout << a - k << ' ' << b << endl;
  } else {
    cout << 0 << ' ' << max(0LL, b - (k - a)) << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

const int INF = 1 << 30;

void greedy(int D, const vector<int>& C, const vector<vector<int>>& S) {
    vector<int> last_day(26, 0);
    int score = 0;
    rep(i, 0, D) {
        int max_score = -INF;
        int max_type = -1;
        rep(j, 0, 26) {
            // タイプjのコンテストを開催したときのスコアを計算
            int now_score = score;
            now_score += S[i][j];
            last_day[j] = i;
            rep(k, 0, 26) {
                now_score -= C[k] * (i + 1 - last_day[k]);
            }
            last_day[j] = i;
            if (chmax(max_score, now_score)) {
                max_type = j;
            }
        }
        // max_typeのコンテストを選択
        cout << max_type + 1 << endl;
        score += S[i][max_type];
        last_day[max_type] = i;
        rep(j, 0, 26) {
            score -= C[j] * (i + 1 - last_day[j]);
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int D;
    cin >> D;
    vector<int> C(26);
    for (auto& c : C) {
        cin >> c;
    }
    vector<vector<int>> S(D, vector<int>(26));
    rep(i, 0, D) rep(j, 0, 26) {
        cin >> S[i][j];
    }
    greedy(D, C, S);
    return 0;
}

Measured memory_bytes: 3708
fun main(args: Array<String>) {
    edpa()
}

fun edpa() {
    val n = readLine()!!.toInt()
    val height = readLine()!!.split(" ").map { it.toLong() }

    val costsToReach = Array(height.size) { Long.MAX_VALUE }

    costsToReach[0] = 0
    costsToReach[1] = Math.abs(height[0] - height[1])

    for (i in 2 until height.size) {
        val oneStepCost = Math.abs(height[i] - height[i - 1])
        val twoStepCost = Math.abs(height[i] - height[i - 2])

        val oneStepTotalCost = oneStepCost + costsToReach[i - 1]
        val twoStepTotalCost = twoStepCost + costsToReach[i - 2]

        costsToReach[i] = Math.min(oneStepTotalCost, twoStepTotalCost)
    }

    println(costsToReach[n - 1])
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// assign avl ncm dij geo2 kruskal graph uf lca BIT

signed main()
{
    Int(n);

    int ans = 1;
    Rep(i, n+1) {
        ans *= i;
        ans %= MOD;
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
K,S = list(map(int,input().split()))

count = 0

if K>S: n=S
else: n=K
x=0
for i in range(n+1):
	if K>S-x: m=S-x
	else: m=K
	y=0
	for j in range(m+1):
		if S-x-y<=K: count +=1
		y+=1
	x+=1

print(count)


Measured memory_bytes: 3060
#include "iostream"
#include "string"
using namespace std;

int main()
{
	string N; //整数宣言
	cin >> N;
	if (N[0]==N[2])
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  vector<int> x(n);
  int pos;
  ll ans = 0;
  rep(i, n){
    int in;
    cin >> in;
    if(i != 0){
      ans += min((ll)a*(in-pos), (ll)b);
    }
    pos = in;
  }
  cout << ans << endl;
  return 0;
}

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define LEN(s)      (string(s)).length()
#define NPOS        string::npos
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<class T>string join(const vector<T>& v,string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(LEN(d));}

template<class T>ostream& operator<<(ostream& o,const vector<T>& v)
{o<<"{";if(SZ(v))o<<join(v,", ");o<<"}";return o;}

template<class T,class U>ostream& operator<<(ostream& o,const pair<T,U>& p)
{o<<"(";o<<p.first<<", "<<p.second;o<<")";return o;}

template<class T>bool contain(const string& s,const T& v)
{return s.find(v)!=NPOS;}

template<class T,class U>string& replace(string& s,const T& f,const U& t)
{for(auto p=s.find(f);p!=NPOS;p=s.find(f,p+LEN(t)))s.replace(p,LEN(f),t);}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

int main() {
    ll A, B; cin >> A >> B;
    cout << (A + B) % 24 << endl;
    
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

N=int(input())
N_s=[]
for i in range(N):
    N_s.append(input())
M=int(input())
M_t=[]
for j in range(M):
    M_t.append(input())
Monny_N=Counter(N_s)
Monny_M=Counter(M_t)

for key in Monny_N.keys():
    Monny_N[key] = Monny_N[key]-Monny_M[key]

Monny_max=max(Monny_N.values())

if Monny_max < 0:
    print("0")
else:
    print(Monny_max)



Measured memory_bytes: 3316
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int y = sc.nextInt();
		int a = y / 10000;
		y -= a * 10000;
		int b = y / 5000;
		y -= b * 5000;
		int c = y / 1000;
		while(a + b + c != n) {
			if((n - a - b - c) % 4 == 0 && b > 0) {
				b--;
				c += 5;
			}else if(a > 0){
			    a--;
			    b += 2;
			}else if(b > 0){
				b--;
				c += 5;
			}else{
				a = -1;
				b = -1;
				c = -1;
				break;
			}
		}
		System.out.print(a + " ");
		System.out.print(b + " ");
		System.out.println(c);
	}
}


Measured memory_bytes: 23764
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
#include <set>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 28;
const double EPS = 1E-10;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)

string tag;
size_t cur;

map<int, string> tag_name;
vector<int> ch[200];

int xl[200];
int yl[200];
int xr[200];
int yr[200];

int res;

string get_name(){
	string res;
	assert(cur < tag.size());
	while(tag[cur] != '>'){
		res.push_back(tag[cur++]);
	}
	return res;
}

int get_num(){
	int res = 0;
	while(isdigit(tag[cur])){
		res = res * 10 + tag[cur++] - '0';
	}
	return res;
}

void get_size(int id){
	xl[id] = get_num();
	assert(tag[cur++] == ',');
	yl[id] = get_num();
	assert(tag[cur++] == ',');
	xr[id] = get_num();
	assert(tag[cur++] == ',');
	yr[id] = get_num();
//	cout << id << " " << xl[id] << " "<< xr[id] << endl;
}

void tag_con(int &id){
	int num = id;
	assert(tag[cur++] == '<');
	tag_name[id] = get_name();
	assert(tag[cur++] == '>');
	get_size(id);

	while(true){
	
		assert(cur < tag.size() && tag[cur] == '<');
		char c = tag[cur+1];
		if(c == '/') break;
		ch[num].push_back(++id);
		tag_con(id);
	}
	while(tag[cur] != '>') cur++;
	cur++;
}

void get_tag(int x, int y, int id){
	//cout << id << " " << xl[id] << endl;
	if(xl[id] <= x && x <= xr[id] && yl[id] <= y && y <= yr[id]){
		res = id;
	}
	for(int i = 0; i < (int)ch[id].size(); i++){
		get_tag(x, y, ch[id][i]);
	}
}

int main(){
	int n, x, y;
	int cnt = 0;
	while(cin >> n && n){
		tag_name.clear();
		rep(i, 200) ch[i].clear();
		tag_name[120] = "OUT OF MAIN PANEL";
		ch[120].push_back(120);
		
		cur = 0;
		cnt = 0;
		cin >> tag;
		tag_con(cnt);
		rep(i, n){
			res = 120;
			cin >> x >> y;
			get_tag(x, y, 0);
			cout << tag_name[res] << " "<< ch[res].size() << endl;
		}
	}
	return 0;
}

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

// 一桁の数 i を作るのに必要なマッチ棒の数を nMatch[i] として持っておく
const int nMatch[10] = {0,2,5,5,4,5,6,3,7,6};

string append(string s, string t){
    // s は必ず降順の文字列なので、
    // s[i] <= t となる s[i] の直前に t を挿入する
    int n = s.length();
    for(int i=0; i<n; i++){
        if(s[i] <= t[0]){
            s.insert(i,t);
            break;
        }
    }
    return s;
}

int main(){
    int N, M;
    vector<int> A;
    cin >> N >> M;
    A = vector<int>(M,0);
    for(int i=0; i<M; i++) cin >> A[i];

    vector<string> dp(N+1,"");
    for(int i=0; i<M; i++){
        int n = nMatch[A[i]];
        if(n > N) continue;
        if(dp[n] == "" || dp[n] < to_string(A[i])) 
            dp[n] = to_string(A[i]);
    }

    for(int i=1; i<=N; i++){
        if(dp[i]=="") continue;
        for(int j=0; j<M; j++){
            // dp[i] に A[j] を追加すると、マッチ棒は合わせて nxt 本になる
            int nxt = i + nMatch[A[j]];
            if(nxt > N) continue;
            if(dp[nxt].length() < dp[i].length() + 1){  // (1)の場合
                dp[nxt] = append(dp[i], to_string(A[j]));
            }else if(dp[nxt].length() == dp[i].length() + 1){  // (2)の場合
                string tmp = append(dp[i], to_string(A[j]));
                if(dp[nxt] < tmp) dp[nxt] = tmp;
            }
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 53632
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 2e+5+5;

int n;
struct bag{
	int x,y;
}a[N];

bool cmp(bag a,bag b){return a.x<b.x;}

int main(){
	n=get();
	fo(i,1,n){
		a[i].x=get();a[i].y=get();
		if (a[i].x<a[i].y)swap(a[i].x,a[i].y);
	}
	sort(a+1,a+1+n,cmp);
	int Bmax=0,Bmin=1e+9,Rmax=0,Rmin=1e+9;
	fo(i,1,n){
		Bmax=max(Bmax,a[i].x),Bmin=min(Bmin,a[i].x);
		Rmax=max(Rmax,a[i].y),Rmin=min(Rmin,a[i].y);
	}
	LL ans=1ll*(Rmax-Rmin)*(Bmax-Bmin);
	int mx=max(Rmax,Bmax),mi=min(Rmin,Bmin);
	int Mx=0,Mi=1e+9;
	bool pdmax=0,pdmin=0;
	int wmax,wmin;
	fo(i,1,n)if (a[i].x==mx&&!pdmax){pdmax=1;wmax=i;Mx=max(Mx,a[i].y),Mi=min(Mi,a[i].y);}
	fd(i,n,1)if (a[i].y==mi&&!pdmin){pdmin=1;wmin=i;Mx=max(Mx,a[i].x),Mi=min(Mi,a[i].x);}
	if (wmax!=wmin){
		if (wmin>wmax)wmin--;
		fo(i,wmax,n-1)a[i]=a[i+1];
		n--;
		fo(i,wmin,n-1)a[i]=a[i+1];
		n--;
		fd(i,n,1){
			int tmpmx=Mx,tmpmi=Mi;
			tmpmx=max(tmpmx,a[i].x);
			tmpmi=min(tmpmi,a[i].x);
			if (i>1)tmpmi=min(tmpmi,a[1].x);
			LL tmp=1ll*(tmpmx-tmpmi)*(mx-mi);
			if (tmp<ans)ans=tmp;
			Mx=max(Mx,a[i].y);
			Mi=min(Mi,a[i].y);
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double EPS = 1e-10;


int main(void) {
  string s;
  cin >> s;
  ll n = 0;
  rep(i, s.length()) {
    n += s[i] - '0';
  }

  if (n % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#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 sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <ll, ll> P;

const ll MOD=1000000007;
vector<pair<P, ll>> v1, v2;
ll N;
bool used[100000];
ll res=0;
ll p=0;
ll l=0,r=0;
void f1(ll &x){
    while(used[v1[x].sc]){
        x++;
    }
    if(p<v1[x].fr.fr){
        res+=v1[x].fr.fr-p;
        p=v1[x].fr.fr;
    }
    used[v1[x].sc]=1;
    x++;
}
void f2(ll &x){
    while(used[v2[x].sc]){
        x++;
    }
    if(p>v2[x].fr.fr){
        res+=p-v2[x].fr.fr;
        p=v2[x].fr.fr;
    }
    used[v2[x].sc]=1;
    x++;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    rep(i,0,N){
        ll L,R;
        cin>>L>>R;
        v1.pb(make_pair(P(L,R), i));
        v2.pb(make_pair(P(R,L), i));
    }
    sor(v1);
    rev(v1);
    sor(v2);
    rep(i,0,N){
        if(i%2){
            f2(l);
        }
        else{
            f1(r);
        }
    }
    res+=abs(p);
    ll ans=res;
    res=0;
    p=0;
    l=0;
    r=0;
    rep(i,0,N) used[i]=0;
    rep(i,0,N){
        if(i%2==0){
            f2(l);
        }
        else{
            f1(r);
        }
    }
    res+=abs(p);
    cout <<max(ans,res)<<"\n";
}

Measured memory_bytes: 6700
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#pragma GCC optimize("Ofast")

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n, m;
    cin >> n >> m;
    priority_queue<ll> price;
    ll a;
    for (ll i = 0; i < n; ++i) {
        cin >> a;
        price.push(a);
    }
    for (ll j = 0; j < m; ++j) {
        ll max = price.top();
        price.pop();
        price.push(max / 2);
    }
    ll ans = 0;
    ll length = price.size();
    for (ll k = 0; k < length; ++k) {
        ans += price.top();
        price.pop();
    }
    cout << ans << "\n";
}


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

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

	int n;
	cin>>n;
	vector<ll> a,b;
	for(int i=0; i<n+1; ++i){
		ll x; cin>>x; a.push_back(x);
	}
	for(int i=0; i<n; ++i){
		ll x; cin>>x; b.push_back(x);
	}
	ll ans = 0;
	for(int i=0; i<n; ++i){
		if( a[i] >= b[i] ){ a[i] -= b[i]; ans += b[i]; b[i] = 0; }
		else{ b[i] -= a[i]; ans += a[i]; a[i] = 0; }

		if( a[i+1] >= b[i] ){ a[i+1] -= b[i]; ans += b[i]; b[i] = 0; }
		else{ b[i] -= a[i+1]; ans += a[i+1]; a[i+1] = 0;}
	}
	cout<<ans<<'\n';


	return 0;
}


Measured memory_bytes: 2548
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define FAST ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define f(i,n) for(int i=0 ; i<n ; i++)
#define fll(i,n) for(ll i=0 ; i<n ; i++)
#define f1(a,b,i) for(ll i=a ; i<b ; i++)
#define fd(i,n) for(int i=n-1 ; i>=0 ; i--)
#define ll long long
#define ld long double
#define vi vector<int>
#define  pii pair<int,int>
#define vl vector<ll>
#define INF 1e9
#define epsn 1e-12

using namespace std ;
int M=1e9+7 ;
ll pow(ll a, ll b){
    if(b==0)return 1 ;
    else if(b%2)return a*pow(a,b-1) ;
    else return pow(a,b/2)*pow(a,b/2) ;
}

int main(){
	ll x,y ;
  	cin>>x>>y ;
  	if(y&1)cout<<"No\n" ;
  	else{
		ll a=(y/2)-x,b=(2*x)-(y/2) ;
      	if(a>=0 && b>=0)cout<<"Yes\n" ;
      	else cout<<"No\n" ;
    }
      return 0 ;
}


Measured memory_bytes: 2944
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        long[] read = longa();
        if(read[2] > read[0]){
            read[2] -= read[0];
            read[0] = 0;
        }else{
            read[0] -= read[2];
            read[2] = 0;
        }
        if(read[2] > 0){
            read[1] = Max(read[1]-read[2],0);
        }
        WriteLine($"{read[0]} {read[1]}");
        
        

    
    }
    //各種読取
    static string rstr(){ return ReadLine(); }
    static int rint(){ return int.Parse(ReadLine()); }
    static long rlong(){ return long.Parse(ReadLine()); }
    static string[] stra(){ return ReadLine().Split(' '); }
    static int[] inta(){ string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for(int countup_i=0;countup_i<read_str_array.Length;countup_i++){ return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static int[,] inta2(int num_array,int in_array){ int[,] int_array2 = new int[num_array,in_array]; for(int i=0;i<num_array;i++){ int[] temp_array = inta(); for(int j=0;j<in_array;j++){ int_array2[i,j] = temp_array[j]; } } return int_array2; }
    static long[] longa(){ string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for(long countup_i=0;countup_i<read_str_array.Length;countup_i++){ return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea(){ string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for(long countup_i=0;countup_i<read_str_array.Length;countup_i++){ return_double_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_double_array; }
    // A/B小数点以下切上
    static long divideup(long divided,long divid){ long temp_divide = divided/divid; if(divided % divid > 0){ temp_divide++; } return temp_divide; }
    static long GCD(long a,long b){ if(a < b){ long temp = a; a = b; b = temp; } if(a % b == 0){ return b; } else{ long temp = b; b = a%b; a = temp; return GCD(a,b); } }
    static long LCM(long a,long b){ return a * b / GCD(a,b); }
}
//知見
// (string) hogestr -> (char[]) hoge
    // char hoge = hogestr.ToCharArray();
// (char[]) hoge -> (string) hogestr
    // string hoge = new string(hoge);
// Hashtable ×  Dictionary ○
// Dictionary hoge<string,int>
    // hoge.ContainsKey(string) -> return boolean
    // hoge[string] -> return int
    // hoge[int] -> CE
// Dictionary hoge<int1,int2>
    // hoge<int1,int2>: hoge[int1] -> return int2
    // KeyValuePair<int,int> k <-> k.Key == int1 / k.Value == int2
// SortedDictionary() > SortedList() ???
// キュー　-> 幅優先 ???
// スタック -> 深さ優先 ???
// if (list?.Count > 0) リストが空でもnullでもない


Measured memory_bytes: 13268
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		String yohou = scan.next();
		String tozitu = scan.next();
		int count = 0;

		for(int i=0;i<=2;i++) {
			if(yohou.charAt(i) == tozitu.charAt(i)) {
				count++;
			}
		}

		System.out.println(count);
		scan.close();

	}

}


Measured memory_bytes: 21844
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        StringBuilder build = new StringBuilder();
        int z = sc.nextInt();
        int[] ary = new int[z];
        for(int i = 0 ; i < ary.length; i++){
            ary[i] = sc.nextInt();
        }
        int count = 0;
        for(int i = 0; i < ary.length; i++){
            int min = i;
            for(int j = i; j < ary.length; j++){
                if(i != 0){
                    if(ary[min] == ary[i-1]){break;}
                }
                min = ary[min] > ary[j] ? j : min;
            }
            if(ary[i] != ary[min]){
                int temp = ary[i];
                ary[i] = ary[min];
                ary[min] = temp;
                count++;
            }
        }
        for(int i = 0; i < ary.length; i++){
            build.append(ary[i]);
            build.append(i==ary.length-1 ? "\n" : " ");
        }
        build.append(count);
        System.out.println(build.toString());
    }
}

Measured memory_bytes: 26312
def main():
    n = int(input().strip())
    L = list(map(int, input().strip().split()))
    
    rem=sum(L)
    cur=1
    ans=0
    for i in range(n+1):
        ans+=cur
        rem-=L[i]
        cur-=L[i]
        if cur<0 or cur==0 and i!=n:
            print(-1)
            return
        if cur<rem:
            cur=min(cur*2,rem)
            
    print(ans)

if '__main__' == __name__:
    main()

Measured memory_bytes: 20004
#include <stdio.h>
#include <string.h>

int main(){
	char str[120];
	scanf("%s", str);
	
	int i;
	int flag = 0;
	
	for(i = 0; i < strlen(str); i++)
	{
		if (i % 2 == 1)
		{
			 if(str[i] == 'R')
			 {
				printf("No");
				flag = 1;
				break;
			}
		} else {
			if (str[i] == 'L')
			{
				printf("No");
				flag = 1;
				break;
			}
		}
	}
	
	if (flag == 0)
	{
		printf("Yes");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)

int main(){
    long long K; std::cin >> K;
    
    std::cout << "50\n";
    long long a = K / 50;
    int k = K % 50;
    std::vector<long long> ans(50);
    for(int i = 0; i < k; ++i) {
        ans[i] = 50 - i;
    }
    for(int i = k; i < 50; ++i) {
        ans[i] = 50 - i - 1;
    }
    
    for(long long r : ans) {
        std::cout << r + a << " ";
    }
    std::cout << std::endl;
    
}


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

#define ll long long
#define sz(x) (ll)(x.size())

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

  ll h,w;
  cin>>h>>w;

  ll row[h+5]={0};
  ll col[w+5]={0};
  map< pair<ll,ll> ,ll>mp;
  ll n;
  cin>>n;
  for(ll i=0;i<n;i++)
  {
    ll a,b;
    cin>>a>>b;
    a--;b--;
    row[a]++;
    col[b]++;
    mp[{a,b}]=1;
  }

  ll row_mx=0,col_mx=0;
  for(ll i=0;i<h+5;i++)
    row_mx=max(row_mx,row[i]);
  for(ll i=0;i<w+5;i++)
    col_mx=max(col_mx,col[i]);

  vector<ll> max_col,max_row;

  for(ll i=0;i<h;i++)
    if(row[i]==row_mx)
      max_row.push_back(i);
  for(ll i=0;i<w;i++)
      if(col[i]==col_mx)
        max_col.push_back(i);

  ll ans=row_mx+col_mx-1;
  ll f=0;

  for(ll i=0;i<sz(max_row);i++)
  {
    if(f!=0)
      break;
    for(ll j=0;j<sz(max_col);j++)
    {
      if(mp.find({max_row[i],max_col[j]})==mp.end())
      {
        f++;
        ans++;
        break;
      }
    }
  }
  cout<<ans<<endl;

  return 0;


}

Measured memory_bytes: 34964
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	ans := "No"
	first := S[0 : (len(S)-1)/2]
	last := S[(len(S)+3)/2-1 : len(S)]
	if paindrome(S) && paindrome(first) && paindrome(last) {
		ans = "Yes"
	}
	// fmt.Println(S, first, last, (len(S)+1)/2)
	// fmt.Println(paindrome(S), paindrome(first), paindrome(last))
	fmt.Println(ans)
}

func paindrome(s string) bool {
	return s == Reverse(s)
	// slice := strings.Split(s, "")
	// result := true
	// // fmt.Println(len(slice) / 2)
	// if len(slice)%2 == 0 {
	// 	return false
	// }
	// for i := 0; i < (len(slice))/2; i++ {
	// 	fmt.Println(slice[i], slice[len(slice)/2+1+i])
	// 	if slice[i] != slice[len(slice)/2+1+i] {
	// 		result = false
	// 	}
	// }
	// return result
}

func Reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


Measured memory_bytes: 512
a=list(map(int,input().split()))
a.sort()
A=a[2]
B=a[1]
C=a[0]
if A%2==B%2 and A%2==C%2:
    print((A-B)//2+(A-C)//2)
    quit()
if A%2!=B%2 and A%2!=C%2:
    print((A-B)//2+(A-C)//2+1)
    quit()
if A%2!=B%2:
    B,C=C,B
print((A-B)//2+((A-C)//2+1)+1)


Measured memory_bytes: 38256
import java.util.Scanner;
     
    public class Main {
    	public static void main (String[] args) {
    		Scanner sc = new Scanner(System.in);
    		String S = sc.next();
    		
    		if (S.charAt(0) != 'A') {
    			System.out.println("WA");
    			return;
    		}
    		
    		int countC = 0;
    		
    		for (int i = 2; i < S.length() - 1; i++) {
    			
    			if (S.charAt(i) == 'C') {
    				countC++;
    				
    			}
    		}
    		
    		if (countC != 1) {
    			System.out.println("WA");
    			return;
    		}
    		
    		for (int i = 1; i < S.length(); i++) {
    			
    			if( Character.isUpperCase(S.charAt( i )) && S.charAt( i ) != 'C')  {
    				System.out.println("WA");
        			return;
    			}
    		}
    		
    		System.out.println("AC");
    		
    	}
    }

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int64_t> A(87);
  A.at(0)=2;
  A.at(1)=1;
  for(int i=2;i<n+1;i++){
    A.at(i)=A.at(i-1)+A.at(i-2);
  }
  cout << A.at(n) << endl;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define SW 100*a*i+100*b*j
#define SS c*k+d*l
int main(){
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    int i=0,j=0,k=0,l=0;
    double r = (double)e/(100.0+(double)e),max = 0.0;
    int ms=0,msw=0;
    for(i=0; SW+SS<=f; i++){
        for(j=0;SW+SS<=f;j++){
            for(k=0;SW+SS<=f;k++){
                for(l=0;SW+SS<=f;l++){
                    double rr = (double)(SS)/((double)(SW)+(double)(SS));
                    if(SW+SS!=0&&rr <= r){
                        if(rr>=max){
                            max = rr;
                            msw = SS+SW;
                            ms = SS;
                        }
                    }
                }
                l=0;
            }
            k=0;
        }
        j=0;
    }
    cout<<msw<<" "<<ms;
}

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

int main(void){
    int a=0 ,b=0;
    scanf("%d %d",&a ,&b);
    int i=0;
    double ans=0;
    int small=0,large=0;
    if(a>=b){
        small = b;
        large = a;
    }
    else{
        small = a;
        large = b;
    }
    
    for(i=0;i<large;i++){
        ans+= small*(pow(10,i));
    }
    printf("%.0f\n",ans); 
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int h1,w1,h2,w2;
  scanf("%d %d %d %d",&h1,&w1,&h2,&w2);
  h1 -= h2;
  w1 -= w2;
  h1 *= w1;
  printf("%d\n",h1);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,b) for(register int i=a;i<=b;++i)
#define rpd(i,a,b) for(register int i=a;i>=b;--i)
#define rep1(i,x) for(register int i=head[x];i;i=nxt[i])
typedef long long ll;
const int N=1;
using namespace std;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int main(){
	int n=read();
	printf("%d\n",(n<<1)/gcd(2,n));
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<VMAX;i++){
    C[i]=0;
  }
  for(j=1;j<=n;j++){
    C[A[j]]++;
  }
  for(i=1;i<=VMAX;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<=n;i++){
    printf("%d",B[i]);
    if(i!=n){
      printf(" ");
    }
    else{
      printf("\n");
    }
  }
    return 0;
}



Measured memory_bytes: 9600
a = int(input())
b = int(input())

if a == 1 and b == 2:
    print(3)
elif a == 1 and b == 3:
    print(2)
elif a == 2 and b == 1:
    print(3)
elif a == 2 and b == 3:
    print(1)
elif a == 3 and b == 1:
    print(2)
elif a == 3 and b == 2:
    print(1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void pr(A a){cout << a << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {}

int main(void) {
  int r;cin>>r;pr(3*r*r);
  return 0;
}


Measured memory_bytes: 256