akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;

void BubbleSort(int x[], int N);
void trace(int x[], int N);

int main(){
    int N, i;
    string buf;

    cin >> buf;
    N = stoi(buf);

    int x[N];

    for(i = 0; i < N; i++){
        cin >> buf;
        x[i] = stoi(buf);
    }
    BubbleSort(x, N);

    return 0;
}

void BubbleSort(int x[], int N){
    int i, flag, num = 0;

    flag = 1;
    while(flag){
        flag = 0;
        for(i = N - 1; i > 0; i--){
            if(x[i] < x[i - 1]){
                swap(x[i], x[i - 1]);
                num++;
                flag = 1;
            }
        }
    }
    trace(x, N);
    cout << num << endl;
}

void trace(int x[], int N){
    int k;

    for(k = 0; k < N - 1; k++){
        cout << x[k] << " ";
    }
    cout << x[k] << endl;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

ll a, b, c;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> a >> b >> c;
    ll x = a / 2, y = b / 2, z = c / 2;
    ll p = a - 2 * x, q = b - 2 * y, r = c - 2 * z;
    ll m = b * c * p, n = a * c * q, o = a * b * r;
    cout << min(m, min(n, o));
}


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

#define ten(n) ((int)1e##n)
#define uni(x) x.erase(unique(all(x)),x.end())
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// dump macro{{{
// http://www.creativ.xyz/dump-cpp-652
#define DUMPOUT cerr // 変数ダンプ先。coutかcerr

#ifdef PCM
// 引数はいくつでもどんな型でも可（ストリーム出力演算子があればOK）
#define dump(...) DUMPOUT<<"  "; \
  DUMPOUT<<#__VA_ARGS__; \
  DUMPOUT<<":=> "; \
  dump_func(__VA_ARGS__); DUMPOUT<<"in ["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl;
#define dump_1d(x,n) DUMPOUT <<"  " \
  <<#x<<"["<<#n<<"]"<<":=> {"; \
  rep(i,n){ DUMPOUT << x[i] << (((i)==(n-1))?"}":", "); } DUMPOUT <<" in [" << __LINE__ << "]" << endl;

#define dump_2d(x,n,m) DUMPOUT <<"  " \
    <<#x<<"["<<#n<<"]"<<"["<<#m<<"]"<<":=> \n"; \
    rep(i,n)rep(j,m){ DUMPOUT << ((j==0)?"     |":" ") << x[i][j] << (((j)==(m-1))?"|\n":" "); } \
    DUMPOUT <<"  in [" << __LINE__ << "]" << endl;
#else
#define dump(...) 42
#define dump_1d(...) 42
#define dump_2d(...) 42
#endif

// デバッグ用変数ダンプ関数
void dump_func() {
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail)
{
    DUMPOUT << head;
    if (sizeof...(Tail) == 0) {
        DUMPOUT << " ";
    }
    else {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i<vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}/*}}}*/

#define rep(i, x) for(int i = 0; i < (int)(x); i++)/*{{{*/
#define reps(i,x) for(int i = 1; i <= (int)(x); i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define foreach(x,a) for(auto& (x) : (a) )
#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define INF 2147483647
#define INFLL 1000000000000000000LL
#define MOD 1000000007/*}}}*/

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;/*{{{*/
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<pii,vii,greater<pii> > spq;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*}}}*/

//--------------------------------------------------------------------------

int main() {
  int n;cin>>n;
  vi x;
  int t;
  rep(i,n){
    cin>>t;
    x.pb(t);
  }

  int l,r;
  l = *min_element(all(x));
  r = *max_element(all(x));
  cout << r-l << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N 36

typedef struct{
  char mark;
  int number;
  int order;
}trump;

int main()
{
  int i, j, num, mj, flag=1;
  trump array1[N], array2[N], tmp;

  scanf("%d", &num);

  for( i=0; i<num; i++){
    while(1){
      scanf("%c", &array1[i].mark);
      if( array1[i].mark != 'D' && array1[i].mark != 'C' && array1[i].mark != 'S' && array1[i].mark != 'H')continue;
      scanf("%d", &array1[i].number);
      break;
    }
    array1[i].order = i+1;
    array2[i] = array1[i];
  }

  for( i=0; i<num; i++){
    for( j=num-1; j>=i+1; j--){
      if( array1[j].number < array1[j-1].number ){
	tmp = array1[j];
	array1[j] = array1[j-1];
	array1[j-1] = tmp;
      }
    }
  }

  for( i=0; i<num-1; i++){
    printf("%c%d ", array1[i].mark, array1[i].number);
  }

  printf("%c%d\n", array1[i].mark, array1[i].number);

  for( i=1; i<num; i++){
    if( array1[i].number == array1[i-1].number && array1[i].order - array1[i-1].order < 0 )flag =0;
  }

  if( flag == 1 ) printf("Stable\n");
  else printf("Not stable\n");

  flag = 1;

  for( i=0; i<num; i++){
    mj = i;

    for( j=i; j<num; j++){
      if( array2[j].number < array2[mj].number )mj = j;
    }
      tmp = array2[i];
      array2[i] = array2[mj];
      array2[mj] = tmp;
    }

  for( i=0; i<num-1; i++){
    printf("%c%d ", array2[i].mark, array2[i].number);
  }

  printf("%c%d\n", array2[i].mark, array2[i].number);

  for( i=1; i<num; i++){
    if( array2[i].number == array2[i-1].number && array2[i].order - array2[i-1].order < 0 )flag =0;
  }

  if( flag == 1 ) printf("Stable\n");
  else printf("Not stable\n");
    
  return 0;
}

Measured memory_bytes: 608
def bubble_sort(ary)
  n = ary.size
  co = 0
  (n - 1).downto(1) do |i|
    i.times do |j|
      if ary[j] > ary[j + 1]
        ary[j], ary[j + 1] = ary[j + 1], ary[j]
        co += 1
      end
    end
  end
  co
end

until (n = $<.gets.to_i).zero?
  puts bubble_sort(n.times.map {$<.gets.to_i})
end


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> num(n, -1);
  bool make = true;

  while ( m-- > 0 ) {
    int s, c;
    cin >> s >> c;
    s--;
    if ( num[s] != -1 && num[s] != c ) {
      make = false;
      break;
    }
    num[s] = c;
  }
  if ( num[0] == 0 && n != 1 ) { make = false; }
  for ( int i = 0; i < n; i++ ) {
    if ( num[i] == -1 ) {
      num[i] = ( n != 1 && i == 0 ) ? 1 : 0;
    }
  }
  
  int ans = -1;
  if ( make ) {
    ans = 0;
    for ( int i = 0; i < 3; i++ ) {
      ans += num[i] * pow(10, n-i-1);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4012
import java.util.*;
public class Main{
  static int dp[];
  static List<Integer> list[];
  static int solve(int i){
    int ret = 0;
    if (dp[i] != - 1) return dp[i];
    else{
      for (int j = 0; j < list[i].size(); j++) {
        ret = Math.max(ret, solve(list[i].get(j)) + 1);
//        System.out.println(ret + " ret inside");
      }
    }
    return dp[i] = ret;
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    list = new LinkedList[n + 1];
    for (int i = 0; i <= n; i++)
      list[i] = new LinkedList<>();
    for (int i = 0; i < m; i++) {
      list[sc.nextInt()].add(sc.nextInt());
    }
    int ret = 0;
    dp = new int[n + 1];
    Arrays.fill(dp, -1);
    for (int i = 1; i <= n; i++){
      ret = Math.max(ret, solve(i));
//      System.out.println(ret + " ret");
    }
    System.out.println(ret);
  }
}


Measured memory_bytes: 96484
n=int(input())
a=[int(i) for i in input().split()]
dp=[[0]*(n+1) for i in range(n+1)]

for w in range(1,n+1):
#for w in range(1,3,1):
#    print(dp[1])
    for l in range(n-w+1):
        r=l+w
        dpl=-dp[l+1][r]+a[l]
        dpr=-dp[l][r-1]+a[r-1]
        dp[l][r]=max(dpl,dpr)
#print()
#for i in dp:
#    print(i)
print(dp[0][n])

Measured memory_bytes: 113644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,m,n) for (int i = m; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b;}
template<class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b;}
template<class T> void drop(const T &x) { std::cout<<x<<endl; exit(0);}
void debug_out() { std::cout << "\n";}
template<class T, class... Args> void debug_out(const T &x, const Args &... args) { std::cout<<x<< " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

struct InitIO{
  InitIO() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
  }
}init_io;

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.length();
  int ans = 0;
  rep(i,n) {
    if (s[i] != t[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f(ll x) {
	if (x == 0)return 0;
	ll y = (1 + x) * x / 2;
	return y;
}
int main() {
	string s;
	cin >> s;
	if (s.at(0) == '>')s = '<' + s;
	if (s.at(s.length() - 1) == '<')s += '>';

	vector<ll>a;
	ll l = 0;
	ll r = 0;
	bool lr = false;
	for (int i = 0; i < s.length(); i++) {
		if (lr == false && s.at(i) == '<')l++;
		else if (lr == false && s.at(i) == '>') {
			lr = true;
			r++;
		}
		else if (lr == true && s.at(i) == '>')r++;
		else if (lr == true && s.at(i) == '<') {
			a.push_back(l);
			a.push_back(r);
			l = 1;
			r = 0;
			lr = false;
		}
	}
	a.push_back(l);
	a.push_back(r);
	//for (int i = 0; i < a.size(); i++)cout << a.at(i) << " ";
	vector<ll>ans;
	for (ll i = 0; i < a.size() / 2; i++) {
		ll x = a.at(0 + i * 2);
		ll y = a.at(1 + i * 2);
		if (x > y)swap(x, y);
		x--;
		ans.push_back(x);
		ans.push_back(y);
	}
	ll an = 0;
	for (int i = 0; i < ans.size(); i++)an += f(ans.at(i));
	cout << an << endl;
}

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

typedef long long ll;

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

    string s;
    cin >> s;

    if(s.back() == '2' || s.back() == '4' || s.back() == '5' || s.back() == '7' || s.back() == '9') cout << "hon" << endl;
    else if(s.back() == '0' || s.back() == '1' || s.back() == '6' || s.back() == '8') cout << "pon" << endl;
    else cout << "bon" << endl;
}


Measured memory_bytes: 3640
#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const ll MOD = 1e9 + 7;

void solve(int N, vector<int>& A) {
    vector<ll> x(N);
    ll x1PlusX2 = A[0];
    ll x1MinusX2 = 0;
    REP(i,1,N) {
        if (i % 2 == 0) x1MinusX2 += A[i];
        else x1MinusX2 -= A[i];
    }
    x[0] = x1PlusX2 + x1MinusX2;
    REP(i,1,N) {
        x[i] = 2 * A[i-1] - x[i-1];
    }

	stringstream ss;
	REP(i,0,N-1) ss << x[i] << " ";
	ss << x[N-1];
	cout << ss.str() << '\n';

    return;
}

signed main() {
    int N;
    cin >> N;
    
    vector<int> A(N);
    REP(i,0,N) cin >> A[i];
    
    solve(N, A);
    
    return 0;
}



Measured memory_bytes: 4740
#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
typedef std::bitset<6> bit;
 
int main(){
  int K,A,B,Ksub=0,flug=0;
  cin>>K>>A>>B;
  int i=1;
    while(Ksub<=B){
      Ksub=K*i;
     // cout<<Ksub<<A<<B<<endl;
      if(Ksub>=A && Ksub<=B){
        flug=1;
        break;
      }
      i++;
    }
  
  if(flug==1) cout<<"OK";
  else cout <<"NG";
  
  return 0;
}

Measured memory_bytes: 3632
n = int(input())
a_n = [int(i) for i in input().split()]

def is_all_even(nums):
    for n in nums:
        if n % 2 == 1:
            return False
    return True

ret = 0
while is_all_even(a_n):
    i = 0
    for a in a_n:
        a_n[i] = a / 2
        i += 1
    ret += 1

print(ret)


Measured memory_bytes: 64296
#include<iostream>
#include<algorithm>

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	int a[1003];
	for(int i=1;i<=n;i++)
		cin >> a[i-1];
	sort(a,a+n);
	cout << a[n-1]-a[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define  int    long long int
 #define    sp(x)                 setprecision(x)
#define    bp(x)           __builtin_popcount(x)
 #define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff         first
#define  ss    second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
 #define  endl    "\n"
#define  mod  1000000007
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int32_t main()
{
    fast
    int n,ans=0;
    cin>>n;
    int a[n+1];
    f(i,1,n)
    {
        cin>>a[i];
        ans^=a[i];
    }
    f(i,1,n)
        cout<<(a[i]^ans) <<" ";
   
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n][3];

    for(int i=0; i<n; ++i) {
        for(int j=0; j<3; ++j) {
            cin >> a[i][j];
        }
    }
    
    int dp[n][3];
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];

    for(int i=1; i<n; ++i ) {
        for(int j=0; j<3; ++j) {
            int optimo = -1;    
            for( int k=0; k<3; ++k ) {
                if ( j == k ) continue;
                optimo = max(optimo, dp[i-1][k]);
            }
            dp[i][j] = optimo + a[i][j];
        }
    }
    cout << *max_element( dp[n-1], dp[n-1]+3 ) << '\n';
}

Measured memory_bytes: 2560
L,R=map(int, input().split())
n=R-L
ans=[]
if n == 1:
    print((L*R)%2019)
elif n < 2019:
    for i in range(n+1):
        for j in range(1,n+1):
            l=L+i
            r=l+j
            if r > R:
                break
            ans.append((l*r) % 2019)
    print(min(ans))
else:
    print(0)



Measured memory_bytes: 75316
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
using pii = pair<int, int>; using vi = vector<int>; using vl = vector<ll>;

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

signed main() {
    ll k;
    cin>>k;
    ll sum = 0;
    FOR(a,1,k+1) FOR(b,1,k+1)FOR(c,1,k+1) sum += gcd(gcd(a, b), c);
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3632
n,k = map(int, input().split())
list_v = list(map(int, input().split()))

retn = 0

k_cap = k
if (k > n):
    k_cap = n

for l in range(k_cap + 1):
    list_mine_l = list_v[:l]

    for r in range(k_cap - l + 1):
        list_mine_r = list_mine_l.copy()
        if (r > 0):
            list_mine_r.extend(list_v[-r:])
        list_mine_r.sort()

        sss = len(list_mine_r)
        if (sss > k-l-r):
            sss = k-l-r
        for s in range(sss + 1):
            list_mine_s = list_mine_r[s:]

            if (len(list_mine_s) > 0):
                tmp = sum(list_mine_s)
                if (retn < tmp):
                    retn = tmp

print(retn)

Measured memory_bytes: 3064
using System;

class ABC071B
{
	static public void Main(string[] args)
	{
		string S = Console.ReadLine();

		bool[] found = new bool[26];

		for(int i=0; i <S.Length; i++)
		{
			found[S[i] - 'a'] = true;
		}
		for(int i=0; i<26; i++)
		{
			if(found[i] == false)
			{
				char c = (char)('a' + i);
				Console.WriteLine(c);
				return;
			}
				
		}
		Console.WriteLine("None");
	}
}


Measured memory_bytes: 11232
S=input()
N=len(S)
s1=S[0:((N-1)//2)]
s2=S[(((N+3)//2)-1):N]
n1=len(s1);n2=len(s2)
for i in range(N):
    if(S[i]!=S[N-1-i]):
        print("No")
        exit()
for i in range(n1):
    if(s1[i]!=s1[n1-1-i]):
        print("No")
        exit()
for i in range(n2):
    if(s2[i]!=s2[n2-1-i]):
        print("No")
        exit()
print("Yes")

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

int cmp(const void *a,const void *b){
  return *(int*)a - *(int*)b;
}

int main(void){
  int n,x,i,ans=0;
  scanf("%d %d",&n,&x);
  int m[n];
  for(i=0;i<n;i++){
    scanf("%d",&m[i]);
    x=x-m[i];
  }
  qsort(m,n,sizeof(int),cmp);
  while(x>=0){
    ans++;
    x-=m[0];
  }
  printf("%d\n",ans+n-1);
  
  return 0;
}

Measured memory_bytes: 128
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <chrono>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <cassert>
# include <array>
# include <tuple>
# include <cctype>
# include <unistd.h>
# include <unordered_map>
# include <unordered_set>
using namespace std;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define fast_work {ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}

const ll INF = 1e18 + 5, NMAX = 2e5 + 5, MOD = 998244353, N = 1e9 + 5, LOG = 25;
const ld EPS = 1e-8, pi = 3.14159265358979323846;

ll sum(vector<ll> &v, int l, int r) {
    ll sum = 0;
    for(int i = l; i <= r; ++i) sum += v[i];
    return sum;
}

signed main() {
    fast_work

    ll n, x, m;
    cin >> n >> x >> m;

    vector<ll> v;
    v.pb(x);

    for(int i = 1; i < n; ++i) {

        ll next = v.back() * v.back() % m;

        for(int j = 0; j < i; ++j) {
            if(v[j] == next) {
                ll s = sum(v, j, i - 1);

                ll cnt = (n - i) / (i - j);
                ll ost = (n - i) % (i - j);

                cout << sum(v, 0, i - 1) + s * cnt + sum(v, j, j + ost - 1);
                return 0;
            }
        }

        v.push_back(next);
    }

    cout << sum(v, 0, n - 1);
}


Measured memory_bytes: 3884
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  // const int64_t L = static_cast<int64_t>(T.length());
  map<int64_t, int64_t> m;
  for (int64_t i = 0; i < N; ++i) {
    int64_t a;
    cin >> a;
    if (m.find(a) == m.end()) {
      m[a] = 1;
    } else {
      ++m[a];
    }
  }
  int64_t result = 1;
  auto itr = m.rbegin();
  int64_t hen = 0;
  while (itr != m.rend() && hen < 4) {
    if (itr->second >= 2) {
      hen += 2;
      itr->second -= 2;
      result *= itr->first;
    } else {
      ++itr;
    }
  }
  if (itr == m.rend()) {
    result = 0;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 9832
let () =
  let r = Array.make 4 0 and
      l = Array.make 4 0 and
      f n a =
        if n >= 1.1 then a.(0) <- a.(0) + 1
        else if n < 1.1 && n >= 0.6 then a.(1) <- a.(1) + 1
        else if n < 0.6 && n >= 0.2 then a.(2) <- a.(2) + 1
        else if n < 0.2 then a.(3) <- a.(3) + 1
  in
  let rec read () =
    try let line = read_line ()
                   |> Str.split (Str.regexp " ")
                   |> List.map float_of_string
                   |> Array.of_list
        in
        let (right,left) = (line.(0),line.(1))
        in
        f right r;
        f left l;
        read ()
    with
      End_of_file ->
      for i = 0 to 3 do
        Printf.printf "%d %d\n" r.(i) l.(i)
      done
  in
  read ()
;;

Measured memory_bytes: 2324
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace AtCoder
{
    static class Program
    {
        static void Main()
        {
            //ここから

            var N = IO.ReadLineToInt();
            List<List<int>> pos = new List<List<int>>();
            for(int i = 0; i < N; i++)
            {
                pos.Add(IO.ReadLineToIntList());
            }

            double sum = 0;
            for(int i = 0; i < N; i++)
            {
                for(int j = 0; j < N; j++)
                {
                    sum += Math.Sqrt(Math.Pow(pos[i][0] - pos[j][0], 2) + Math.Pow(pos[i][1] - pos[j][1], 2));
                }
            }

            var ans = sum / N;

            //ここまで

            Console.WriteLine(ans);
            Console.ReadKey();
        }
        
    }

    static class Func
    {
        static public long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(long a, long b) { return (long)a * b / GCD(a, b); }
        static public long Factorial(long a) { return a == 1 ? a : a * Factorial(a - 1); }


        public static double ToAngle(this double radian)
        {
            return (double)(radian * 180 / Math.PI);
        }

        public static double ToRadian(this double angle)
        {
            return (double)(angle * Math.PI / 180);
        }

        static public long Conbination(long n,long m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * Conbination(n - 1, m - 1) / m;
        }

        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    static class IO
    {
        static public string ReadLineToString() { return Console.ReadLine(); }

        static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public List<string> ReadLineToStringList() { return Console.ReadLine().Split(' ').ToList(); }

        static public List<int> ReadLineToIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }

        static public List<double> ReadLineToDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }

        static public void WriteStrings(object[] strings) { foreach (var o in strings) { Console.Write(o + " "); } }
    }
}

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

struct Stack
{
	int S[101];
	int top;
	int capacity;
};

typedef struct Stack *stack;

stack createStack()
{
	stack s;
	s = (stack)malloc(sizeof(struct Stack));
	s->top = -1;
	s->capacity = 100;
	return s;
}

int isFull(stack s)
{
	return s->top == s->capacity;
}

void push(stack s, int x)
{
	if (isFull(s))
		return;
	s->S[++s->top] = x;
}

int isEmpty(stack s)
{
	return s->top == -1;
}

int pop(stack s)
{
	if (isEmpty(s))
		return -1;
	return s->S[s->top--];
}

void solve(stack s)
{
	char s1[100];
	while (1)
	{
		if (scanf("%s", s1) == EOF)
			break;
		int a, b;
		switch (s1[0])
		{
		case '+':a = pop(s), b = pop(s), push(s, a + b); break;
		case '-':b = pop(s), a = pop(s), push(s, a - b); break;
		case '*':a = pop(s), b = pop(s), push(s, a * b); break;
		default:push(s, atoi(s1)); break;
		}
	}
	printf("%d\n", pop(s));
}

int main()
{
	stack s;
	s = createStack();
	solve(s);
}


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

#pragma GCC optimize("O3")

using namespace std;

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

typedef long long ll;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

int main() {
    int n;
    cin >> n;
	vector<int> x(n);
	for(int i = 0; i < n; ++i) {
		cin >> x[i];
	}
    ll sm_st = -1;
    for(int i = 1; i <= 100; ++i) {
		int sum = 0;
		for(auto y: x) {
			sum += pow((y - i), 2);
		}
		if(sm_st == -1 || sum < sm_st) sm_st = sum;
	}
	
	cout << sm_st;
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int n;
	cin>>n;

	ll total=0;
	ll x=0;
	for(int i=1; i<n+1; i++){
		ll a;
		cin>>a;
		x+=a;
		if(a==0){
			total+=(x/2);
			x=0;
		}
	}
	total+=(x/2);
	cout<<total<<endl;

	return 0;

}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a,b,c = LI()
    if a == b and b == c:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    n = I()

    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 39388
def main():
    n = int(input())
    num_list = list(map(int, input().split()))

    count = 0
    search_num = 1

    for num in num_list:
        if search_num == num:
            search_num += 1
            continue
        count += 1
        
    print(count if search_num != 1 else -1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 77516
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  int N;
  cin >> N;
  vi L(N);
  for(int i = 0; i < N; i++){
    cin >> L.at(i);
  }
  sort(ALL(L));
  ll counter = 0;
  for(int i = 0; i < N-2; i++){
    for(int j = i+1; j < N-1; j++){
      for(int k = j+1; k < N; k++){
        if(L.at(i) + L.at(j) > L.at(k)) counter++;
        else break;
      }
    }
  }
  cout << counter << endl;
}

Measured memory_bytes: 256
#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>
#include <chrono>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define 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 DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T>inline bool chmax(T &a, T b){return (a < b ? a = b, true : false);}
template<typename T>inline bool chmin(T &a, T b){return (a > b ? a = b, true : false);}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const long double EPS = 1e-9;

LL N;

int f(LL a, LL b) {
	int ca = 0, cb = 0;
	do {
		++ca;
	} while (a /= 10);
	do {
		++cb;
	} while (b /= 10);
	return max(ca, cb);
}

int main() {
	cin >> N;
	int ans = INF;
	for (LL i = 1; i * i <= N; ++i) {
		if (N % i == 0) {
			chmin(ans, f(N / i, i));
		}
	}
	cout << ans << endl;
}


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

int main(){
	int n;
	cin >> n;
	int a[n];
	int b[n];
	int c[n-1];
	for(int i=0; i<n; i++) cin >> a[i];
	for(int i=0; i<n; i++) cin >> b[i];
	for(int i=0; i<n-1; i++) cin >> c[i];
	int ans=b[a[0]-1];
	for(int i=1; i<n; i++){
		ans+=b[a[i]-1];
		if(a[i]==a[i-1]+1){
			ans+=c[a[i]-2];
		}
	}
	cout << ans;
  }

Measured memory_bytes: 256
# ABC 083
def getIntList(): return [int(x) for x in input().split()]
def db(x): 
    global debug
    if debug: print(x)
debug = True
N,A,B = getIntList()
nsum = 0
for n in range(N+1):
    k,dsum = n,0
    while k>0:
        dsum += k%10
        k //= 10
    if dsum>=A and dsum<=B:   nsum += n
print(nsum)

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

int main() {

  int n;
  cin >> n;
  
  vector<long long> a(n);
  for ( int i = 0; i < n; i++){
    cin >> a[i];
    if ( a[i] == 0 ){
      cout << 0 << endl;
      return 0;
    }
  }
  
  long long ans = 1;
  long long genkai = LLONG_MAX;
  
  for ( int i = 0; i < n; i++){
    if ( ans > genkai / a[i] ){
      cout << -1 << endl;
      return 0;
    }
    ans *= a[i];
    if ( ans > 1000000000000000000 ){
      cout << -1 << endl;
      return 0;
    }
  }
  
  cout << ans << endl;  
  
}

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

int main() {
  int n = 3;
  vector<char> s(n), t(n);
  for(int i = 0; i < n; i++){
    cin >> s.at(i);
  }
  for(int i = 0; i < n; i++){
    cin >> t.at(i);
  }

  int count = 0;
  
  for(int i = 0; i < n; i++){
    if(s.at(i) == t.at(i)) count++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
//114B
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
int main(void){
    string s=" ";
    int a=0,b=0,c=0, ans=1000;
    cin >> s;
    rep(i, s.size()-2){
        a = s[i]-'0';
        b = s[i+1]-'0';
        c = s[i+2]-'0';
        if (ans > abs(a*100 + b*10 + c -753)) ans =abs(a*100 + b*10 + c -753);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1e9+7, MAX = 1e9, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
long long sum = 0;

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

vector<ll> prime_factorization(ll num){
    vector<ll> vec;
    ll a = 2;
    while(num >= a*a){
        if(num%a==0){
            vec.push_back(a);
            num /= a;
        }else{
            a++;
        }
    }
    vec.push_back(num);
    return vec;
}

int main() {
    cin >> A >> B;
    vector<ll> vec_A = prime_factorization(A);
    vector<ll> prime_A;
    vector<ll> vec_B = prime_factorization(B);
    ll curr = vec_A[0];
    prime_A.push_back(curr);
    int count = 1;
    rep(i, vec_A.size()-1){
        if(vec_A[i+1] == curr) continue;
        prime_A.push_back(vec_A[i+1]);
        curr = vec_A[i+1];
    }
    rep(i, prime_A.size()){
        if(binary_search(vec_B.begin(), vec_B.end(), prime_A[i])) count++;
    }
    if(A == 1 && B == 1) cout << 1;
    else cout << count;
}


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

const int MAX_N = 19;
int N;
int a[MAX_N][MAX_N];
ll dp[1<<MAX_N];

void solve()
{
	for(int i=0;i<(1<<N);++i)for(int x=0;x<N;++x)if(i>>x&1){
		for(int y=x+1;y<N;++y)if(i>>y&1){
			dp[i]+=a[x][y];
		}
	}
	for(int i=0;i<(1<<N);++i){
		for(int j=i;j>0;j=(j-1)&i) {
			dp[i]=max(dp[i],dp[j]+dp[i^j]);
		}
	}
	cout << dp[(1<<N)-1] << '\n'; 
}

int main()
{
	cin >> N;
	for(int i=0;i<N;++i)for(int j=0;j<N;++j) cin>>a[i][j];
	solve();
	return 0;
}

Measured memory_bytes: 4064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
struct edge{ll to,cost;};
const int inf = 1<<28;
const ll INF = 1LL<<53;
const int COMBMAX = 500005;
const ll MOD = 1e9+7;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;++i)
#define repf(i,n) for(int i=0;i<=n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define eachdo(v, e) for(const auto& e : v)
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (ll)distance(v.begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (ll)distance(v.begin(), upper_bound((v).begin(), (v).end(), e))
ll mpow(ll a, ll n,ll mod=MOD){ll res=1;while(n>0){if(n&1)res=res*a%mod;a=a*a%mod;n>>=1;}return res;}
template<class T1, class T2> ll bcount(T1 v, T2 a){return upper_index(v,a)-lower_index(v,a);} 
template<class T> bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
template<class T> void debug2(T v){rep(i,v.size()){rep(j,v[i].size())cout<<v[i][j]<<" ";cout<<endl;}}
template<class T> void rdv(T &v){rep(i,v.size())cin>>v[i];}
template<class T> void rdvv(T &v){rep(i,v.size()){rep(j,v[i].size())cin>>v[i][j];}}
// multimap
// mmap.emplace(key,value);
// auto ngw = list.equal_range("");
// for(auto e = ngw.first; it != ngw.second ; ++e)


int main(){
    ll N, K; cin >> N >> K;
    vector<ll> v(N); rep(i, N) cin >> v[i];
    int opMax = min(N, K);
    ll ans = 0;
    for(int l = 0; l <= opMax; l++){
        for(int r = 0; r <= min(K - l, N - l); r++){
            vector<ll> takePos, takeNgt;
            rep(i, l){
                if (0 <= v[i]) takePos.emplace_back(v[i]);
                else takeNgt.emplace_back(v[i]);
            }
            rep(fi, r){
                int i = N - 1 - fi;
                if (0 <= v[i]) takePos.emplace_back(v[i]);
                else takeNgt.emplace_back(v[i]);
            }
            sort(all(takeNgt));
            ll part = 0;
            rep(i, min(K - l - r, (ll)takeNgt.size())) part += takeNgt[i];
            chmax(ans, (ll)accumulate(all(takePos), 0LL) + (ll)accumulate(all(takeNgt), 0LL) - part);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

class Point{
public:
    double y, x;
    Point(){
    }
    Point(double y0, double x0){
        y = y0;
        x = x0;
    }
    Point operator-(const Point& p) const{
        return Point(y-p.y, x-p.x);
    }
    double dot(const Point& p) const{
        return y*p.y + x*p.x;
    }
};

int main()
{
    for(;;){
        Point a, b, c, d;
        if(!(cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y >> d.x >> d.y))
            return 0;

        a = a - b;
        c = c - d;
        if(a.dot(c) == 0)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
}

Measured memory_bytes: 0
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

s = ns()
ans = 0
for symbol in s:
    if symbol == '+':
        ans += 1
    else:
        ans -= 1
print(ans)

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

int main() {
  int h, w;
  cin >> h >> w;
  char s[h][w];
  int i, j;
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      cin >> s[i][j];
    }
  }
  int h_sum[h][w], w_sum[h][w];
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      if (s[i][j] == '#') {
        h_sum[i][j] = 0;
        w_sum[i][j] = 0;
      } else {
        if (i == 0) {
          w_sum[i][j] = 1;
        } else {
          w_sum[i][j] = w_sum[i - 1][j] + 1;
        }
        if (j == 0) {
          h_sum[i][j] = 1;
        } else {
          h_sum[i][j] = h_sum[i][j - 1] + 1;
        }
      }
    }
  }
  for (i = h - 1; i >= 0; i--) {
    for (j = w - 1; j >= 0; j--) {
      if (i != h - 1) {
        if (w_sum[i][j] != 0) {
          w_sum[i][j] = max(w_sum[i][j], w_sum[i + 1][j]);
        }
      }
      if (j != w - 1) {
        if (h_sum[i][j] != 0) {
          h_sum[i][j] = max(h_sum[i][j], h_sum[i][j + 1]);
        }
      }
    }
  }
  int result = 0;
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      result = max(result, h_sum[i][j] + w_sum[i][j]);
    }
  }
  cout << result - 1 << endl;
/*
  cout << endl;
  cout << "h_sum" << endl;
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      cout << setw(1) << setfill(' ') << h_sum[i][j] << ' ';
    }
    cout << endl;
  }
  cout << endl << "w_sum" << endl;
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      cout << setw(1) << setfill(' ') << w_sum[i][j] << ' ';
    }
    cout << endl;
  }
*/
  return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int n, k;
string s;

int main(void) {
  // Here your code !
  scanf("%d", &n);
  cin >> s;
  scanf("%d", &k);

  char target = s[k - 1];

  for (auto e: s) {
    if (e != target) {
      printf("*");
    }
    else {
      printf("%c", target);
    }
  }

  printf("\n");

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    rep(i, min(k, 13+1)){ // log2(5000) < 13
        string t = s;
        reverse(all(t));
        s += t;
        reverse(all(s));
        string now = s.substr(0, n);
        REP(i, n)now = min(now, s.substr(i, n));
        reverse(all(now));
        s = now;
    }
    reverse(all(s));
    cout << s << endl;
}   


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll n; cin>>n;
    vector<ll>a(n);
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    ll sub=0;
    vector<ll>ans(n);
    for(int i=1;i<n;i+=2){
        sub+=a[i];
    }
    ans[0]=sum-2*sub;
    for(int i=1;i<n;i++){
        ans[i]=2*a[i-1]-ans[i-1];
    }
    rep(i,n)cout<<ans[i]<<" ";
    cout<<endl;
}





Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
const ll INF = 1LL << 50;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
 
struct edge{
    int from, to; ll cost;
};

int main(){
    ull x, y;
    cin >> x >> y;
    ull ans = 0;
    ull tmp = x;
    while(tmp <= y && 0 <= tmp){
        tmp *= 2;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner sc = new java.util.Scanner(System.in);

	public static void main(String[] args) {
		while (sc.hasNext()) {
			long a = sc.nextInt();
			long b = sc.nextInt();
			long x = a;
			long y = b;
			long max = y;
			while (x % y != 0) {
				max = x % y;
				x = y;
				y = max;
			}
			long min = a * b / max;
			System.out.println(max + " " + min);

		}

	}

}

Measured memory_bytes: 26196
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

bool isPrime(long long x) {
    if (x == 1) return true;
    for (long long i = 2; i*i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}

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

vector<long long> common_divisors(long long a, long long b) {
    long long n = gcd(a, b);
    vector<long long> ans;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            if (n / i == i) {
                ans.push_back(i);
            }
            else {
                ans.push_back(n / i);
                ans.push_back(i);
            }
        }
    }
    return ans;
}

int main() {
    int n;
    cin >> n;
    map<set<map<char, int>>, int> mp;
    while (n--) {
        string s;
        cin >> s;
        set<map<char, int>> set;
        map<char, int> m;
        for (int i = 0; i < (int)s.length(); i++) {
            m[s[i]]++;
        }
        set.insert(m);
        mp[set]++;
    }
    long long ans = 0;
    for (auto it : mp) {
        long long x = it.second;
        ans += x * (x - 1) / 2;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 61828
n, k = (int(_) for _ in input().split())
a = [int(_) for _ in input().split()]

found = False
bad = False
while not found:
    for i in str(n):
        if int(i) in a:
            bad = True
    if not bad:
        found = True
    bad = False
    n += 1

print(n - 1)

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
  long long n,i,a=0,b=0,m,d[100010];
  scanf("%lld",&n);
  for(i=0;i<n;i++){
    scanf("%lld",&d[i]);
    if(i%2==0)a+=d[i];
    b+=d[i];
  }
  m=a+a-b;
  printf("%lld",m);
  for(i=0;i<n-1;i++){
    m=d[i]*2-m;
    printf(" %lld",m);
  }
  printf("\n");
  return 0;
}


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

namespace D___Handstand
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ');
            var N = int.Parse(read[0]);
            var K = int.Parse(read[1]);

            var S = Console.ReadLine();

            var switch01 = new List<int>();
            switch01.Add(0);

            for(int i = 1 ; i < S.Length ; i++) if(S[i] != S[i-1]) switch01.Add(i);
            switch01.Add(S.Length);

            var continuousHandstand = new List<int>();
            
            for(int i = 0 ; i < switch01.Count-1 ; i++) continuousHandstand.Add(S[switch01[i]] == '0' ? switch01[Math.Min(switch01.Count-1,i+2*K)]-switch01[i] : switch01[Math.Min(switch01.Count-1,i+2*K+1)]-switch01[i]);
            
            Console.WriteLine(continuousHandstand.Max());
        }
    }
}


Measured memory_bytes: 15584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    string s; cin>>s;
    bool isok = true;
    for(int i=0; i<s.size(); i++){
        int num = i+1;
        char tmp = s[i];
        if(num%2) {
            if(tmp == 'L'){
                isok = false;
                break;
            } 
        } else {
            if(tmp == 'R'){
                isok = false;
                break;
            }
        }
    }
    if(isok) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256