akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];

		for(int i=0; i<n; i++){
			a[i] = sc.nextInt();
		}
		for(int i=n-1; i>0; i--){
			System.out.print(a[i] + " ");
		}
		System.out.print(a[0]);
		System.out.println();

	}
}

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

int32_t main(){
	ios::sync_with_stdio(0);	
	int n, r;
	cin >> n >> r;
	if(n>=10)
		cout << r << endl;
	else
		cout << max(0, int(r+(100*(10-n)))) << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
using base = complex<double>;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M 1000000007
#define M2 998244353
#define ll long long
#define pll pair<long, long>
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define ff first
#define ss second
#define pb push_back
#define db pop_back
#define mp make_pair
#define mt make_tuple
#define g(a, b) get<a>(b)
#define INF (ll)1e18 + 100
#define vl vector<ll>
#define vi vector<int>
#define vll vector<pair<ll, ll>>
#define vii vector<pair<int, int>>
#define all(v) v.begin(), v.end()
#define bset(a, p) ((a) | (1ll << (p)))
#define bchk(a, p) ((a) & (1ll << (p)))
#define bxor(a, p) ((a) ^ (1ll << (p)));
#define brem(a, p) (bchk(a, p) ? (bxor(a, p)) : (a))
#define INT_SIZE 32

ll powM(ll x, ll y, ll m)
{
	ll ans = 1, r = 1;
	x %= m;
	while (r > 0 && r <= y)
	{
		if (r & y)
		{
			ans *= x;
			ans %= m;
		}
		r <<= 1;
		x *= x;
		x %= m;
	}
	return ans;
}


void solve() {
	ll n;
	cin >> n;
	map<ll, ll>m;
	REP(i, 0, n) {
		ll x;
		cin >> x;
		m[x]++;
	}
	ll ans = 1;
	if (n % 2) {
		if (m[0] != 1) {
			cout << 0; return;
		}
		for (auto y : m) {
			if (y.ff != 0) {
				if (y.ff % 2) {cout << 0; return;}
				if (y.ss != 2) {
					cout << 0; return;
				}
				if (y.ff > n - 1) {
					cout << 0; return;
				}
			}
		}
		cout << powM(2, m.size() - 1, M);
	}
	else {
		for (auto y : m) {
			if (y.ff % 2 == 0) {cout << 0; return;}
			if (y.ss != 2) {
				cout << 0; return;
			}
			if (y.ff > n - 1) {
				cout << 0; return;
			}
		}
		cout << powM(2, m.size(), M);
	}
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ll ntc;
	// cin >> ntc;
	ntc = 1;
	REP(tc, 1, ntc + 1)
	{
		// cout << "Case #" << tc << ": ";
		solve();
	}
}

Measured memory_bytes: 7576
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleTest
{
    class Program
    {

        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if (s == "AAA" || s == "BBB")
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }

        }
    }
}


Measured memory_bytes: 11092
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

public class Program
{

    public void Proc()
    {
        System.Text.StringBuilder ans = new System.Text.StringBuilder();
        while(true) {
            string inpt = Reader.ReadLine();
            if(inpt == null) {
                break;
            }
            ans.AppendLine(inpt.Split(' ').Select(a=>int.Parse(a)).Sum().ToString().Length.ToString());
        }
        Console.Write(ans.ToString());
        
    }

    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"


5 7
1 99
1000 999



";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}

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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main(){
  string s;
  cin >> s;
  
  reverse(s.begin(), s.end());
  for (int i=0; i<4; i++) reverse(divide[i].begin(), divide[i].end());
  
  bool can =true;
  for (int i=0; i<s.size();){
    bool can2 = false;
    for (int j=0; j<4; j++){
      string d = divide[j];
      if (s.substr(i, d.size()) == d){
        can2 = true;
        i += d.size();
      }
    }
    if (!can2){
      can = false;
      break;
    }
  }
  
  if (can) cout << "YES" << endl;
  else cout << "NO" << endl;
  
}


Measured memory_bytes: 512
#include <iostream>
#include <set>
using namespace std;
using ll = long long;

set<ll> s;

ll n;
struct {ll pos, l, r;} p[200005];
ll ans;

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) {
		ll a;
		cin >> a;
		p[a].pos = i;
	}

	p[1].l = 1;
	p[1].r = n;
	s.insert(p[1].pos);
	s.insert(n + 1);
	s.insert(0);
	for (int i = 2; i <= n; i++) {
		auto itr = s.lower_bound(p[i].pos);

		if (*itr != p[i].pos) {
			p[i].r = *itr - 1;
		}
		else {
			p[i].r = *itr;
		}

		while (*itr > p[i].pos) {
			itr--;
		}

		if (*itr != p[i].pos) {
			p[i].l = *itr + 1;
		}
		else {
			p[i].l = *itr;
		}

		s.insert(p[i].pos);
	}

	for (int i = 1; i <= n; i++) {
		ans += (p[i].pos - p[i].l + 1) * (p[i].r - p[i].pos + 1) * i;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 14336
import collections

n = int(input())
A = list(map(int, input().split()))
q = int(input())

CNT = collections.Counter(A)
ANS = []
ans = sum(A)

for i in range(q):
    b, c = map(int, input().split())
    t = CNT[b]
    ans +=(c - b) * t
    ANS.append(ans)
    CNT[c] += t
    CNT[b] = 0

for i in ANS:
    print(i)

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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
#define MP make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;
typedef pair < ll , ll > pll;

const double PI = acos(-1);
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;
const int INF = 1e9;
	

ll addMod(ll a, ll b){
	if(a + b >= MOD) return a + b - MOD;
	return a + b;
}

ll mulMod(ll a, ll b){
	return (a*b)%MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp,tmp);
	if(b%2 == 1) tmp = mulMod(tmp,a);
	return tmp;
}

ll GCD(ll a, ll b){
	if(a > b) return GCD(b,a);
	if(a == 0) return b;
	return GCD(b%a,a);
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

//////////////////////////////////////////////

const int N = 1e5;

int dp[N + 5];

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	dp[0] = 1;
	FOR(i,6){
		REP(j,100,N){
			if(j >= i + 100 && dp[j-i-100] == 1){
				dp[j] = 1;
			}
		}
	}
	int x; cin >> x;
	cout << dp[x] << endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void){
int n;
scanf("%d",&n);
if(n<=100){
int member[n],i;
for(i=0;i<n;i++){
scanf("%d",&member[i]);
}
for(i=n-1;i>=0;i--){
printf("%d",member[i]);
if(i!=0)
printf(" ");
}
printf("\n");
}
return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int ans;
int A[1000001];
int main(){
	scanf("%d%d%d",&a,&b,&c);
	for(int i=1;i<=a;i++){
		scanf("%d",&A[i]);
	}
	for(int i=1;i<=a;i++){
		if(A[i]>=c||A[i]<b)ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(x,a,b) for(int x=a;x<b;x++)
#define REP(x,b) for(int x=0;x<b;x++)
#define FORSIZE(x,A) for(int x=0;x<A.size();x++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define SORT(x) sort(x.begin(),x.end())
#define RSORT(x) sort(x.rbegin(),x.rend())
#define rsort(x,n) sort(x, x+n, greater<int>())
#define REV(x) reverse(x.begin(),x.end())
using namespace std;
typedef long long ll;
inline int toInt(std::string s) {int v; std::istringstream sin(s);sin>>v;return v;}
template<class T> inline std::string toString(T x) {std::ostringstream sout;sout<<x;return sout.str();}

int main( int argc, const char* argv[] )
{
    int a[101];
    int tmp;
    int c = 0;
    int m = 0;
    fill(a, a+101, 0);
    while (cin >> tmp) {
        a[tmp] += 1;
        c += 1;
    }
    FOR(i, 0, 101) {
        m = max(m, a[i]);
    }
    FOR(i, 0, 101) {
        if (a[i] == m) {
            cout << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1156
import numpy as np

N,K=list(map(int,input().split()))
x=list(map(int,input().split()))
t_min=10**9+7
for i in range(N-K+1):
    t=x[i+K-1]-x[i]+min(np.abs(x[i]),np.abs(x[i+K-1]))
    if t<t_min:
        t_min=t
print(t_min)

Measured memory_bytes: 23096
from collections import defaultdict
import sys
input = sys.stdin.readline

H,W,N = map(int,input().split())
D = defaultdict(bool)
B = []

for _ in range(N):
    a,b = map(lambda x: int(x)-1,input().split())
    D[(a,b)] = True
    B.append((a,b))

ans = [0 for _ in range(10)]

for a,b in B:
    for i in range(9):
        ix,iy = divmod(i,3)
        if a-ix<0 or b-iy<0:
            continue
        black_count = 0
        for j in range(9):
            jx,jy = divmod(j,3)
            if H<=a-ix+jx or W<=b-iy+jy:
                break
            if (a-ix+jx,b-iy+jy) in D:
                if -iy+jy<0 or (-iy+jy==0 and -ix+jx<0):
                    break
                black_count += 1
        else:
            ans[black_count] += 1

ans[0] = (H-2)*(W-2)-sum(ans)
print(*ans,sep='\n')

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

int main(){
	int n, m, l;
	long long a[100][100], b[100][100], c[100][100];

	cin >> n >> m >> l;

	for (int i = 0; i < 100; i++){
		for (int j = 0; j < 100; j++){
			a[i][j] = 0;
			b[i][j] = 0;
		}
	}

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

	for (int i = 0; i < m; i++){
		for (int j = 0; j < l; j++){
			cin >> b[i][j];
		}
	}

	for (int i = 0; i < n; i++){
		for (int j = 0; j < l; j++){
			c[i][j] = 0;
			for (int k = 0; k < m; k++){
				c[i][j] += a[i][k] * b[k][j];
			}
			if (j != 0) cout << " ";

			cout << c[i][j];
		}
		cout << endl;
	}


	return 0;
}

Measured memory_bytes: 1320
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    int n, a, b;
    ArrayList<Integer> ans;

    void run() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        a = sc.nextInt();
        b = sc.nextInt();

        if (Integer.bitCount(a^b) % 2 == 0) {
            System.out.println("NO");
            return;
        }
        System.out.println("YES");
        ans = new ArrayList<>();

        solve(a, b, (1 << n) - 1);

        boolean check = true;
        for (int i = 0; i < (1 << n) - 1; i++) {
            System.out.print(ans.get(i) + " ");
        }
        System.out.println(b);
    }

    void reverse(int[] ar, int l, int r) {
        int c = (l + r) / 2 - l;
        for (int i = 0; i < c; i++) {
            int tmp = ar[l + i];
            ar[l + i] = ar[r - i];
            ar[r - i] = tmp;
        }
    }

    void solve(int A, int B, int mask) {
//        debug(Integer.toBinaryString(A), Integer.toBinaryString(B), mask);

        if (Integer.bitCount(mask) == 1) {
            ans.add(A);
            ans.add(B);
            return;
        }

        int div = -1;
        for (int i = 0; i < n; i++) if ((((A ^ B) & mask) & (1 << i)) > 0) {
            div = i;
        }
        mask ^= 1 << div;

        int c = mask & (-mask);

        int C = A ^ c;
        solve(A, C, mask);
        solve(C^ (1 << div), B, mask);
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 49916
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>


using namespace std;

void dfs(int qi, int x, vector<vector<int>>& g, vector<long>& ans) {
  int a = ans[qi]+x;
  ans[qi] = a;
  x = a;
  for(auto v : g[qi] ) {
    dfs(v,x,g,ans);
  }
}

int main() {
  int n,q;
  cin >> n >> q;
  vector<vector<int>> g(n+1);
  vector<long> ans(n+1,0);

  for (int i=0; i<n-1; i++) {
    int a,b;
    cin >> a >> b;
    g[a].push_back(b);
  }

  for (int i=0; i<q; i++) {
    int qi,x;
    cin >> qi >> x;
    ans[qi] += x;
  }

  dfs(1,0,g,ans);

  for (int i=1; i<=n; i++) {
    cout << ans[i] << (i==n? '\n' : ' ');
  }
}

Measured memory_bytes: 24320
import java.util.Scanner;
import java.util.Vector;
import java.util.Collections;

class Main
{
	public static void main(String[] av)
	{
		Scanner sc = new Scanner( System.in );
		int num = sc.nextInt();

		Vector<Boolean> bools = new Vector<Boolean>();
		for ( int i = 0; i < num; ++i )
		{
			Vector<Integer> ps = new Vector<Integer>();
			for ( int j = 0; j < 3; j++ )
			{
				ps.add( sc.nextInt() );
			}
			Collections.sort( ps );
			if ( ps.get(0)*ps.get(0) + ps.get(1)*ps.get(1)
				== ps.get(2)*ps.get(2) )
			{
				bools.add( true );
			}
			else
			{
				bools.add( false );
			}
		}
		for ( Boolean bool: bools )
		{
			if ( bool )
			{
				System.out.println("YES");
			}
			else
			{
				System.out.println("NO");
			}
		}
	}
}
				
		

Measured memory_bytes: 24036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
  ll h,a;
  cin >> h >> a;
  ll ans;
  if(h%a==0)ans=h/a;
  else ans=h/a+1;
  cout << ans << endl;
}


Measured memory_bytes: 3496
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H;
long long int ans;


int main() {
	ios::sync_with_stdio(false);
	string a, b, c;
	cin >> a >> b >> c;
	if (*a.rbegin() == *b.begin() && *b.rbegin() == *c.begin())cout << "YES\n";
	else cout << "NO\n";
	return 0;
}

Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
ll findleft(vector<ll> &s, ll x){
  int left = -1, right = s.size();
  while(left + 1 < right){
    int middle = (right + left) / 2;
    if(s[middle] > x) right = middle;
    else left = middle;
  }
  if(left == -1 || left == s.size()) return 0;
  else return s[left] - x;
}
ll findright(vector<ll> &s, ll x){
  int left = -1, right = s.size();
  while(left + 1 < right){
    int middle = (right + left) / 2;
    if(s[middle] >= x) right = middle;
    else left = middle;
  }
  if(right == -1 || right == s.size()) return 0;
  else return s[right] - x;
}
int main(){
  int a,b,q;
  cin >> a >> b >> q;
  vector<ll> s(a), t(b);
  rep(i, a) cin >> s[i];
  rep(i, b) cin >> t[i];
  rep(i, q){
    ll x; cin >> x;
    ll ans = 10000000000000;
    ll spos1, spos2, tpos1, tpos2;
    spos1 = findleft(s, x);
    spos2 = findright(s, x);
    tpos1 = findleft(t, x);
    tpos2 = findright(t, x);
    if(spos2 && tpos1) ans = min(ans, 2 * (spos2 - tpos1) - max(spos2, -tpos1));
    if(tpos2 && spos1) ans = min(ans, 2 * (tpos2 - spos1) - max(tpos2, -spos1));
    if(spos1 && tpos1) ans = min(ans, -min(spos1, tpos1));
    if(spos2 && tpos2) ans = min(ans, max(spos2, tpos2));
    cout << ans << endl;
  }
}

Measured memory_bytes: 4760
N=int(input())
ALL=[]
for i in range(N):
  A=int(input())
  XY=[]
  for k in range(A):
    x,y=map(int,input().split())
    XY+=[[x,y]]
  ALL+=[XY]
ans=0  
for i in range(2**N):
  people=[-1]*N
  anssub=0
  for k in range(N):
    if ((i >> k) & 1):
      if people[k]==0 or people[k]==-2:
        people[k]=-2        
      else:
        people[k]=1
      anssub+=1
      for t in ALL[k]:
        if people[t[0]-1]!=t[1] and people[t[0]-1]!=-1:
          people[t[0]-1]=-2
        else:
          people[t[0]-1]=t[1]
    else:
      if people[k]==1 or people[k]==-2:
        people[k]=-2
      else:
        people[k]=0  
  if not -2 in people:
    ans=max(ans,anssub)
print(ans)            

Measured memory_bytes: 46060
#include<stdio.h>
#include<string.h>
int main()
{
    char a[1000];
    gets(a);
    int len,i;
    len=strlen(a);
    for(i=0; i<len; i++)
    {
        if(i==0)
            printf("%c",a[0]-32);
        if(a[i]==' ')
            printf("%c",a[i+1]-32);
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include "iomanip"

using namespace std;

int main() {
    int a, b;
    string op;
    cin >> a >> op >>  b;
    if (op == "+"){
        cout << a + b;
    } else{
        cout << a - b;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;



int main(){
	int n,x;
	scanf("%d %d", &n, &x);

	int m[100];

	for(int i=0;i<n;i++){
		scanf("%d", &m[i]);
	}
	sort(m,m+n);

	for(int i=0;i<n;i++){
		x -= m[i];
	}
	int ans = 0;
	ans += n;

	ans += x / m[0];

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;

#define bil ((ll)1e9)
#define mod ((ll)1e9+7)

int main(int argc,char* argv[]){
    char c;
    cin >> c;

    if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o')
        cout << "vowel" << endl;
    else
        cout << "consonant" << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const int INF = 1001001001;

int main(){
    int n;
    cin >> n; 
    string s;
    cin >> s;
    int red_c = 0;
    rep(i,n) {
        if(s.at(i) == 'R') red_c++;
    }
    if(red_c == 0 || red_c == n){
        cout << 0 << endl;
        return 0;
    }
    int white_c = n - red_c;
    int ans = 0;
    rep(i,red_c){
        if(s.at(i) == 'W') ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	auto x = vector<int>(n);
	for(auto&& xx : x) cin >> xx;
	int ans = 1000000;
	for(int i = 1; i <= 100; ++i){
		int a = 0;
		for(int j = 0; j < n; ++j){
			a += ((x[j] - i) * (x[j] - i));
		}
		ans = min(ans, a);
	}
	cout << ans << endl;
	return 0;
}

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

public class Main {
  public static void main(String [] args) {
    FastReader fr = new FastReader();
    int A = fr.nextInt();
    int B = fr.nextInt();
    int tmp = A - B * 2;
    System.out.println(Math.max(tmp, 0));
  }
}

class FastReader {
  BufferedReader br;
  StringTokenizer st;

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

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

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

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

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

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

Measured memory_bytes: 21332
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

int cmp(const void* x, const void* y) {
	int64_t a = *(const int64_t*)x, b = *(const int64_t*)y;
	return a > b ? -1 : a < b;
}

int N;
int64_t M;
int64_t A[114514];
int64_t A_ruiseki[114514];

/* target以上の要素の数を求める、ついでに和も求める */
int64_t ge_count(int64_t* sum, int64_t target) {
	int i;
	int64_t count = 0;
	if (sum) *sum = 0;
	for (i = 0; i < N; i++) {
		int ge = 0, less = N - 1;
		if (A[i] + A[0] < target) {
			count += 0;
		} else if (A[i] + A[N - 1] >= target) {
			count += N;
			if (sum) (*sum) += A[i] * N + A_ruiseki[N - 1];
		} else {
			while (ge + 1 < less) {
				int mid = ge + (less - ge) / 2;
				if (A[i] + A[mid] >= target) ge = mid; else less = mid;
			}
			count += ge + 1;
			if (sum) (*sum) += A[i] * (ge + 1) + A_ruiseki[ge];
		}
	}
	return count;
}

int main(void) {
	int i;
	int64_t less, ge;
	int64_t nyan, wa;
	if (scanf("%d%" SCNd64, &N, &M) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%" SCNd64, &A[i]) != 1) return 1;
	}
	qsort(A, N, sizeof(*A), cmp);
	A_ruiseki[0] = A[0];
	for (i = 1; i < N; i++) {
		A_ruiseki[i] = A_ruiseki[i - 1] + A[i];
	}
	/* その数以上のやつがM以上になる数を二分探索 */
	less = A[0] * 2 + 1;
	ge = 0;
	while (less - 1 > ge) {
		int64_t mid = ge + (less - ge) / 2;
		if (ge_count(NULL, mid) >= M) ge = mid; else less = mid;
	}
	nyan = ge_count(&wa, ge);
	printf("%" PRId64 "\n", wa - (nyan - M) * ge);
	return 0;
}


Measured memory_bytes: 1788
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Pine1999
 */

#include <bits/stdc++.h>

using namespace std;

class ECoprime {
public:
    void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        vector<int> a(n);
        for (int i = 0; i < n; ++i) {
            in >> a[i];
        }
        int MAX = (int) (1e6 + 50);
        vector<int> min_prime(MAX);
        for (int i = 2; i <= MAX; ++i) {
            if (min_prime[i]) continue;
            for (int j = i; j < MAX; j += i) {
                if (min_prime[j]) continue;
                min_prime[j] = i;
            }
        }
        bool suc = true;
        set<int> st;
        for (int i = 0; i < n; ++i) {
            int b = a[i];
            while (b > 1) {
                int p = min_prime[b];
                if (st.count(p)) {
                    suc = false;
                    break;
                }
                st.insert(p);
                while (b % p == 0) {
                    b /= p;
                }
            }
            if (!suc) {
                break;
            }
        }
        if (suc) {
            out << "pairwise coprime" << '\n';
            return;
        }
        int g = gcd(a[0], a[1]);
        vector<int> prime;
        for (int i = 2; i * i <= g; ++i) {
            if (g % i == 0) {
                prime.push_back(i);
                while (g % i == 0) {
                    g /= i;
                }
            }
        }
        if (g != 1) prime.push_back(g);
        for (int p : prime) {
            bool suc2 = true;
            for (int i = 0; i < n; ++i) {
                if (a[i] % p) {
                    suc2 = false;
                    break;
                }
            }
            if (suc2) {
                out << "not coprime" << '\n';
                return;
            }
        }
        out << "setwise coprime" << '\n';
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ECoprime solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 11128
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define rep(i,n) REP(i,0,n-1)
#define FORD(i,b,a) for(int i=b,_a=a;i>=_a;i--)
#define ford(i,n) FORD(i,n-1,0)
#define sqr(x) ((x)*(x))
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define vll vector<ll>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define add push_back
#define len(arr) arr.size()
#define print(x) cout<<(x)<<endl
using namespace std;

char p[3] = {'A', 'B', 'C'};
string a[3];

void solve(int start){
	if(len(a[start]) == 0){
		print(p[start]);
		return;
	}
	char c = a[start][0];
	a[start].erase(a[start].begin());
	solve(c - 'a');
}

int main(){
	//freopen("test_01.in", "r", stdin);

	rep(i, 3) cin >> a[i];
	solve(0);
	
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll  long long
#define PR  pair<int, int>

const int N = 3e5 + 10;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    int n;
    cin >> n;
    int ac = 0, wa = 0, tle = 0, re = 0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (s == "AC") {
            ac++;
        } else if (s == "WA") {
            wa++;
        } else if (s == "TLE") {
            tle++;
        } else if (s == "RE") {
            re++;
        }
    }
    cout << "AC x " << ac << '\n';
    cout << "WA x " << wa << '\n';
    cout << "TLE x " << tle << '\n';
    cout << "RE x " << re << '\n';
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x;cin >> x;
	ll ans = x / 11 * 2;
	x %= 11;
	if(x > 0){
		if(x <= 6) ans++;
		else ans += 2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll n, k;

    cin >> n >> k;

    ll ans = 0;

    for (int i = 0; i < k; i++)
    {
        if (i * 3 % k == i)
        {
            ll tmp = 0;
            for (int j = i; j <= n; j += k)
            {
                if (j)
                {
                    tmp++;
                }
            }

            ans += pow(tmp, 3);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 4088
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int A,B;
  cin >> A >> B;
  int add,sub,mul;
  add = A+B;
  sub = A-B;
  mul = A*B;
  if (add>=sub && add>=mul) cout << add << endl;
  else if (add<sub && sub>=mul) cout <<sub <<endl;
  else cout << mul << endl;
  return 0;
}





Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 3223372036854775807
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
//#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
//#define leng length()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invp(a,p)pom(a,p-2,p)
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll> a,pair<ll,ll> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se>b.se;
}
ll cmp(ll a,ll b){
    return abs(a)<abs(b);
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //------------------------------
    ll l,r,d;cin>>l>>r>>d;
    ll ans=0;
    for(ll i=l;i<=r;i++){
        if(i%d==0)ans++;
    }
    cout<<ans<<Endl;
    //------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //------------------------------- 
    return 0;
}
//----------------------------------------------------------------------







































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

int main(){
    string w,T;
    cin >> w;
    int c=0;
    while(1){
        cin >> T;
        if(T!="END_OF_TEXT"){
            for(int i=0;i<T.size();i++){
                T.at(i)=tolower(T.at(i));
            }
            if(T==w) c++; //スペースで区切ってTを読み込んでいるのであって、行ごとに読んでいるわけではない
           /*for(int i=0;i<T.size()-w.size();i++){
                if(T.substr(i,w.size())==w) c++;
            }*/
        }
        else break;
    }
    cout << c << endl;
}


Measured memory_bytes: 3192
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

MOD = 10**9 + 7


S = int(input())

ans = 0

max_div_num = S // 3

for i in range(1, max_div_num+1):
    div_num = i
    remain = S - (3 * div_num)

    num = cmb(div_num+remain-1, div_num-1)
    ans = (ans + num) % MOD
    
print(ans)

Measured memory_bytes: 68272
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;

int main() {
  ll a,b;
  int k;
  cin >> a >> b >> k;
  rep(i,k){
    if(i%2==0){
      if(a%2==1)a--;
      b += a/2;
      a /= 2;
    }else{
      if(b%2==1)b--;
      a += b/2;
      b /= 2;
    }
  }
  cout << a << " " << b;
}


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

int main() {
	string s;
	cin >> s;
	int answer = 0;
	int n = s.size();
	for(int i = 0; i < n - i - 1; ++i)
		answer += s[i] != s[n - i - 1];
	cout << answer;
}


Measured memory_bytes: 3628
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
using namespace std;
int h, w;
vector<string> s;
bool judge(int i, int j)
{
    bool flag = false;
    if ((j-1) >= 0 && s[i][j-1] == '#') {
        flag = true;
    }
    if ((j+1) < w && s[i][j+1] == '#') {
        flag = true;
    }
    if ((i-1) >= 0 && s[i-1][j] == '#') {
        flag = true;
    }
    if ((i+1) < h && s[i+1][j] == '#') {
        flag = true;
    }
    return flag;
}

int main()
{
    cin >> h >> w;
    s.resize(h);
    for (int i = 0; i < h; i++)
    {
        cin >> s[i];
    }
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (s[i][j] == '#' &&!judge(i, j))
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int h, w;
    scanf("%d %d", &h, &w);
    char s[w + 1];
    for (int i = 0; i < h; ++i) {
        scanf("%s", s);
        printf("%s\n%s\n", s, s);
    }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#define N 101
struct Card{char suit;int value; };
int main()
{
  struct Card a[N],b[N];
  int total,i,j,k,mini,m,sum=0;
  char ch;
  scanf("%d%c",&total,&ch);
  for(i=0;i<total;i++){
    scanf("%c%d%c",&a[i].suit,&a[i].value,&ch);
  }
  for(i=0;i<total+1;i++){
    b[i]=a[i];
  }
    for(i=0;i<total-1;i++){
    for(j=total-1;j>i;j--){
      if(a[j].value<a[j-1].value){
        m=a[j].value;
        a[j].value=a[j-1].value;
        a[j-1].value=m;
        ch=a[j].suit;
        a[j].suit=a[j-1].suit;
        a[j-1].suit=ch;
      }
    }
  }
  for(i=0;i<total-1;i++){
    mini=i;
    m=b[i].value;
    for(j=i;j<total;j++){
      if(b[j].value<m){
        m=b[j].value;
        mini=j;
      }
    }
     if(m!=b[i].value){
      k=b[i].value;
      b[i].value=b[mini].value;
      b[mini].value=k;
      ch=b[i].suit;
      b[i].suit=b[mini].suit;
      b[mini].suit=ch;
    }
  }
  for(i=0;i<total;i++){
    if(a[i].suit==b[i].suit && a[i].value==b[i].value){
    sum++;
    }
  }
  for(i=0;i<total-1;i++){
    printf("%c%d ",a[i].suit,a[i].value);
  }
  printf("%c%d",a[i].suit,a[i].value);
  printf("\nStable\n");

  for(i=0;i<total-1;i++){
    printf("%c%d ",b[i].suit,b[i].value);
  }
  printf("%c%d",b[i].suit,b[i].value);
  if(sum==total)printf("\nStable\n");
  else printf("\nNot stable\n");
  return 0;
}
    


Measured memory_bytes: 2084
#include <bits/stdc++.h>
#define us unordered_set
#define f first
#define s second
#define pb push_back
#define MOD 1000000007
#define MOD2 1000000009
#define BASE 29
#define BASE2 31
#define eps 1e-9
#define INF 1000000002

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int, pii> piii;
typedef pair<pii,pii> piiii;
const int N = 200002;
const int BIT = 30;
int m;
bool removed[N];
set<int> vs;
set<int> vis;
vector<pii> edges;
map<int, vi> adjList;
map<int,int> outDeg;
map<int,int> cmp;


int main() {
	int a,b;
  	cin>>a>>b;
 	if(a<=9 && b <=9)
      cout<<a*b;
  else
    cout<<-1;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int n;
    cin >> n;
    int l, r,result=0;
    REP(i,n){
        cin >> l >> r;
        result += r - l + 1;
    }
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_p(x) cerr<<#x": "<<(x).first<<' '<<(x).second<<endl
#define dbg_v(x, n) {cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<(x)[_]<<' ';cerr<<endl;}
#define all(v) v.begin(), v.end()
#define fi first
#define se second
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

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

template <typename T>
ostream& operator <<(ostream &out, const vector<T>& v) {
	for(const auto &item : v) out << item << ' ';
	return out;
}

int main()
{
	ios_base::sync_with_stdio(false);
	
	ll a, b, c;

	cin >> a >> b >> c;

	if(c - a - b > 0 && 4 * a * b < (c - a - b) * (c - a - b)) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  string S;
  cin >> S;
  S[3] = '8';
  cout << S << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 20;

vector<int> data;
int a[MAX_N];
int h[MAX_N];
int n,K;

template < class BidirectionalIterator >
bool next_combination ( BidirectionalIterator first1 ,
  BidirectionalIterator last1 ,
  BidirectionalIterator first2 ,
  BidirectionalIterator last2 )
{
  if (( first1 == last1 ) || ( first2 == last2 )) {
    return false ;
  }
  BidirectionalIterator m1 = last1 ;
  BidirectionalIterator m2 = last2 ; --m2;
  while (--m1 != first1 && !(* m1 < *m2 )){
  }
  bool result = (m1 == first1 ) && !(* first1 < *m2 );
  if (! result ) {
    while ( first2 != m2 && !(* m1 < * first2 )) {
      ++ first2 ;
    }
    first1 = m1;
    std :: iter_swap (first1 , first2 );
    ++ first1 ;
    ++ first2 ;
  }
  if (( first1 != last1 ) && ( first2 != last2 )) {
    m1 = last1 ; m2 = first2 ;
    while (( m1 != first1 ) && (m2 != last2 )) {
      std :: iter_swap (--m1 , m2 );
      ++ m2;
    }
    std :: reverse (first1 , m1 );
    std :: reverse (first1 , last1 );
    std :: reverse (m2 , last2 );
    std :: reverse (first2 , last2 );
  }
  return ! result ;
}
 
template < class BidirectionalIterator >
bool next_combination ( BidirectionalIterator first ,
  BidirectionalIterator middle ,
  BidirectionalIterator last )
{
  return next_combination (first , middle , middle , last );
}

int main()
{
	scanf("%d%d",&n,&K);
	int hmax=0;
	rep(i,n){
		scanf("%d",&a[i]);
		h[i] = hmax+1;
		if(a[i] > hmax){
			hmax = a[i];
		}
		data.push_back(i);
	}
	ll ans = (1LL<<60);
	do{
		int cri=0;
		ll res=0LL;
		rep(j,K){
			int id = data[j];
			cri = max(cri,h[id]);
			if(a[id] < cri){
				res += cri - a[id];
			}
			cri++;
		}
		ans = min(ans,res);
	}while(next_combination(data.begin(),data.begin()+K,data.end()));
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int	main()
{
	int x1, x2, x3, x4, x5;
	scanf("%d", &x1);
	scanf("%d", &x2);
	scanf("%d", &x3);
	scanf("%d", &x4);
	scanf("%d", &x5);
	if (x1 == 0) {
		printf("1\n");
	}
	else if (x2 == 0) {
		printf("2\n");
	}
	else if (x3 == 0) {
		printf("3\n");
	}
	else if (x4 == 0) {
		printf("4\n");
	}
	else if (x5 == 0) {
		printf("5\n");
	}
	return 0;
}


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

using namespace std;

int main()
{
    string str;
    vector<int> mx,mn;
    int n;
    int a,b;
    cin >> n;
    while(cin >> str)
    {
        a=0;b=0;
        for(int i=0;i<str.length();++i)
        {
            mn.push_back(str[i]-'0');
        }
        sort( mn.begin(), mn.end() );
        mx = mn;
        sort( mx.begin(), mx.end(), greater<int>() );
        for(int i=0;i<8;++i)
        {
            a += mx[i]*pow(10,i);
            b += mn[i]*pow(10,i);
        }
        cout << b-a << endl;
        str.clear();
        mn.clear();
        mx.clear();
    }
}

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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n, x;
  string s;
  list<int> lst;
  cin >> n;
  while (n--) {
    cin >> s;
    if (s[0] == 'i') {
      cin >> x;
      lst.push_front(x);
    } else if (s.size() > 6) {
      if (s[6] == 'F') lst.pop_front();
      else lst.pop_back();
    } else {
      cin >> x;
      for (auto it = lst.begin(); it != lst.end(); it++) {
        if (*it == x) {
          lst.erase(it);
          break;
        }
      }
    }
  }
  cout << lst.front();
  lst.pop_front();
  if (!lst.empty()) {
    for (auto it = lst.begin(); it != lst.end(); it++) {
      cout << " " << *it;
    }
  }
  cout << "\n";
}


Measured memory_bytes: 34380
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.IArray             as IA
import qualified Data.Array.IO                 as AI
import qualified Data.Array.MArray             as MA
import qualified Data.Array.ST                 as STA
import qualified Data.Array.Unboxed            as AU
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Graph                    as G
import           Data.Int
import qualified Data.IntMap                   as IM
import qualified Data.IntSet                   as IS
import           Data.List
import qualified Data.Map.Strict               as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence                 as SQ
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Tree                     as T
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putLn :: Show a => a -> IO ()
putLn = print

putList :: Show a => [a] -> IO ()
putList [n     ] = put n
putList (n : ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n     ] = putStr n
putStrList (n : ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b | b         = putStrLn "YES"
             | otherwise = putStrLn "NO"

yesNo b | b         = putStrLn "Yes"
        | otherwise = putStrLn "No"

main = do
  [a,b,c]<-readString
  yesNoUpper $ (last a == head b && last b == head c)

Measured memory_bytes: 380
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        for (int i = 1; i<n+1; i++){
            ans += i;
        }
        System.out.println(ans);
    }
}


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

using namespace std ;

const int MAXN(200000 + 10);
int n ;
int a[MAXN] ;
int b[MAXN] ;

int main(){
    scanf("%d" , &n) ;
    for(int i = 0 ; i < n ; i ++){
        scanf("%d" , &a[i]) ;
        b[i] = a[i] ;
    }

    sort(b , b + n) ;

    int h = b[n / 2 - 1] ;
    int hh = b[n / 2] ;


    for(int i = 0 ; i < n ; i ++){
        if(a[i] <= h) printf("%d\n" , hh) ;
        else printf("%d\n" , h) ;
    }
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  cout << a % 2 
    	+ (a - a % 2) % 100 / 10
    	+ (a - a % 2 -(a - a % 2) % 100 / 10) / 100;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void DrawRectangle(int H, int W);

int main()
{
	int H, W;

	while(1){
		cin >> H >> W;
		if ((H == 0) && (W == 0))
			break;

		DrawRectangle(H, W);
		cout << endl;
	}


	return 0;
}

void DrawRectangle(int H, int W)
{
	bool isSharp;
	for (int row = 0; row < H;  row++){
		if (row % 2) isSharp = false;
		else isSharp = true;
		for (int column = 0; column < W; column++){
			if(isSharp)
				cout << '#';
			else
				cout << '.';
			isSharp = !isSharp;
		}
		cout << endl;
	}

}


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

bool same(int n)
{
  int g = n%10;
  while(n)
  {
    if(g!=n%10)
      return false;
    n/=10;
  }
  return true;
}

int main()
{
 int n;
  cin>>n;
  while(!same(n))
    n++;
  cout<<n<<"\n";
  
  return 0;
}


Measured memory_bytes: 256