akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main(){
    ll A, B, Q; cin >> A >> B >> Q;
    vector<ll> S(A), T(B);
    for(int i = 0; i < A; i++) cin >> S[i];
    for(int i = 0; i < B; i++) cin >> T[i];
    for(int i = 0; i < Q; i++){
        ll x; cin >> x;
        ll ans = 1e18;
        auto itrs = lower_bound(S.begin(), S.end(), x);
        auto itrt = lower_bound(T.begin(), T.end(), x);
        int idxs = distance(S.begin(), itrs);
        int idxt = distance(T.begin(), itrt);
        if(idxs < A && idxt < B) ans = min(max(S[idxs], T[idxt])-x, ans);
        //cout << ans << endl;
        if(idxs >= 1 && idxt >= 1)ans = min(x-min(S[idxs-1], T[idxt-1]), ans);
        //cout << ans << endl;
        if(idxs < A && idxt >= 1)ans = min(ans, 2*min(S[idxs]-x, x-T[idxt-1]) + max(S[idxs]-x, x-T[idxt-1]) );
        //cout << ans << endl;
        if(idxs >= 1 && idxt < B)ans = min(ans, 2*min(x-S[idxs-1], T[idxt]-x) + max(x-S[idxs-1], T[idxt]-x) );
        
        cout << ans << endl;
    }
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
	int D,N;
	cin>>D>>N;
	if((D==0)&&(N!=100)){
		cout<<N<<endl;
	}
	else if((D==0)&&(N==100)){
		cout<<101<<endl;
	}
	else if((D==1)&&(N!=100)){
		cout<<pow(100,D)*N<<endl;
	}
	else if((D==1)&&(N==100)){
		cout<<10100<<endl;
	}
	else if((D==2)&&(N!=100)){
		cout<<pow(100,D)*N<<endl;
	}	
	else{
		cout<<1010000<<endl;
	}
}

Measured memory_bytes: 256
#include "stdio.h"

void main()
{
    int N;
    scanf("%d", &N);
    int a = N / 100;
    int b = (N / 10) % 10;
    int c = N % 10;
    if (a == 7 || b == 7 || c == 7)
    {
        printf("Yes\n");
        return;
    }
    printf("No\n");
    return;
}

Measured memory_bytes: 1588
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
#pragma endregion Macros


ll score(vector<int> A, int Q, int M, vector<vector<int>> abcd){
    ll res = 0;
    rep(i, Q)
    {
        if(A[abcd[i][1]-1] - A[abcd[i][0]-1] == abcd[i][2]){
            res += abcd[i][3];
        }
    }
    return res;
}

bool next(vector<int> &A, int i, int M, int N){
    if(i==N-1){
        if(A[i]==M){
            return false;
        }else{
            A[i]++;
            return true;
        }
    }else{
        if(A[i] == A[i+1]){
            A[i] = 1;
            return next(A, i + 1, M, N);
        }else{
            A[i]++;
            return true;
        }
    }
}

int main()
{
    int N,M,Q;
    cin >> N >> M >> Q;

    vector<vector<int>> abcd(Q, vector<int>(4));
    rep(i, Q) cin >> abcd[i][0] >> abcd[i][1] >> abcd[i][2] >> abcd[i][3];

    vector<int> A(N,1);

    ll ans = 0;
    do{
        chmax(ans, score(A, Q, M, abcd));
    } while (next(A, 0, M, N));

    cout << ans << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



signed main() {
    ll n;
    cin >> n;
    ll a = n / 100;
    ll b = n % 100;
    
    if (a >= 1 && a <= 12 && b >= 1 && b <= 12) {
        mes("AMBIGUOUS");
        re0;
    }
    if (a >= 1 && a <= 12) {
        mes("MMYY");
        re0;
    }
    if (b >= 1 && b <= 12) {
        mes("YYMM");
        re0;
    }
    mes("NA");
    
    
    
    
   
    
    
}


Measured memory_bytes: 3600
//
// Created by Hideaki Imamura on 2020-03-28.
//
# include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int A, B, K;
    scanf("%d%d%d", &A, &B, &K);
    int tmp = A;
    for(int i = 0; i < K; i++){
        tmp = A+i;
        if(tmp > B) return 0;
        printf("%d\n", tmp);
    }
    for(int i = 0; i < K; i++){
        if(B-K+i+1 <= tmp) continue;
        printf("%d\n", B - K + i + 1);
    }
    return 0; 
}

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

struct point
{
    double x, y;
};

void koch(int d, point p1, point p2)
{
    if (d == 0)
    {
        return;
    }

    point s, t, u;
    s.x = (2 * p1.x + 1 * p2.x) / 3;
    s.y = (2 * p1.y + 1 * p2.y) / 3;

    t.x = (1 * p1.x + 2 * p2.x) / 3;
    t.y = (1 * p1.y + 2 * p2.y) / 3;

    double rad = M_PI * 60.0 / 180.0;
    u.x = cos(rad) * (t.x - s.x) - sin(rad) * (t.y - s.y) + s.x;
    u.y = sin(rad) * (t.x - s.x) + cos(rad) * (t.y - s.y) + s.y;

    koch(d - 1, p1, s);
    cout << s.x << " " << s.y << endl;
    koch(d - 1, s, u);
    cout << u.x << " " << u.y << endl;
    koch(d - 1, u, t);
    cout << t.x << " " << t.y << endl;
    koch(d - 1, t, p2);
}

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

    point p1, p2;
    p1.x = p2.y = 0.0;
    p2.x = 100.0;
    p2.y = 0.0;

    cout << p1.x << " " << p1.y << endl;
    koch(n, p1, p2);
    cout << p2.x << " " << p2.y << endl;

    return 0;
}


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

#define FOR(i,a,n) for (int i = a; i < (int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = int_fast64_t;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

int main() {
  int n, m; cin >> n >> m;
  vector<int> u(n);
  REP(i,m) {
    int a, b; cin >> a >> b;
    a--; b--;
    u[a] = 1 - u[a];
    u[b] = 1 - u[b];
  }
  bool f = true;
  REP(i,n) {
    if (u[i] == 1) {
      f = false;
    }
  }
  if (f) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

void print_vec(vector<int> vec)
{
  cout << "[";
  for (int i = 0; i < vec.size(); i++)
  {
    cout << vec.at(i) << ", ";
  }
  cout << "]" << endl;
}

int main()
{
  int w;
  cin >> w;
  cout << w * 32 << endl;
}



Measured memory_bytes: 3092
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

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

int main()
{
    int N;
    cin >> N;
    vector<int> Bs(N - 1);
    for (int i = 0; i < N - 1; ++i) cin >> Bs[i];
    int maxSumA = 0;
    // A0についてはB0と同じ値が最大
    maxSumA += Bs.front();
    // Ai=A1~A(N-2)についてはB(i-1)とBiのうち小さい側を選ぶ
    for (int i = 1; i <= N - 2; ++i)
    {
        int maxAi = min(Bs[i - 1], Bs[i]);
        maxSumA += maxAi;
    }
    // A(N-1)についてはB(N-2)と同じ値が最大
    maxSumA += Bs.back();
    cout << maxSumA << endl;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto S = readln.chomp.to!(wchar[]);

    int r = int.max;
    foreach (i; 0..S.length-2) {
        r = min(r, abs(753 - S[i..i+3].to!int));
    }
    writeln(r);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;

int main() {
    char a, b;
    cin >> a >> b;
    cout << (a == b ? "H" : "D") << endl;
    return 0;
}


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

static const int margin = 1;
static const int board_size = 32;

char board[board_size][board_size];
int W, H;
int ans_accume;

void init() {
	for(int i = 0; i < board_size; i++) {
		for(int j = 0; j < board_size; j++) {
			board[i][j] = '#';
		}
	}
	ans_accume = 0;
}

bool input() {
	cin >> W >> H;
	if(!W && !H)
		return false;
	for(int i = margin; i < H + margin; i++) {
		cin >> board[i] + margin;
	}
	return true;
}

// (p.second, p.first)
void solve(pair<int, int> p) {
	if(board[p.first][p.second + 1] == '.') {
		board[p.first][p.second + 1] = 'x';
		ans_accume++;
		solve(pair<int, int>(p.first, p.second + 1));
	}
	if(board[p.first][p.second - 1] == '.') {
		board[p.first][p.second - 1] = 'x';
		ans_accume++;
		solve(pair<int, int>(p.first, p.second - 1));
	}
	if(board[p.first + 1][p.second] == '.') {
		board[p.first + 1][p.second] = 'x';
		ans_accume++;
		solve(pair<int, int>(p.first + 1, p.second));
	}
	if(board[p.first - 1][p.second] == '.') {
		board[p.first - 1][p.second] = 'x';
		ans_accume++;
		solve(pair<int, int>(p.first - 1, p.second));
	}
}

pair<int, int> search_start() {
	for(int i = margin; i < H + margin; i++) {
		for(int j = margin; j < W + margin; j++) {
			if(board[i][j] == '@') {
				ans_accume++;
				return pair<int, int>(i, j);
			}
		}
	}

	return pair<int, int>(-1, -1);
}

int main(void) {
	while(init(), input()) {
		solve(search_start());
		cout << ans_accume << endl;
	}
}

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

namespace ABC064A_cs
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var xConnected = x[1] * 10 + x[2];
            if (xConnected % 4 == 0)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }

        }
    }
}


Measured memory_bytes: 13396
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

H, W = LI()
A = [[] for i in range(H)]
for i in range(H):
    a = list(str(input()))
    A[i] = a
# 複数のスタート地点が存在してもqueに突っ込むことで同様の効果が得られる．
visited = [[-1 for i in range(W)] for j in range(H)]

for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            d.append((i,j))
            visited[i][j] = 0

moves = [[0,1],[1,0],[-1,0],[0,-1]]
cnt = 0
while len(d) > 0:
    X, Y = d.popleft()
    cnt = visited[X][Y]
    for x, y in moves:
        n_X = X + x
        n_Y = Y + y
        if 0 <= n_X < H and 0 <= n_Y< W:
            if visited[n_X][n_Y] == -1:
                visited[n_X][n_Y] = cnt + 1
                d.append((n_X, n_Y))
print(cnt)


Measured memory_bytes: 165668
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define all(a)  (a).begin(),(a).end()

int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}

int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int kaijou(int a){
  int b=1;
  fo(i,a)
    b*=i+1;
  return b;
}

int lcm(int a,int b){
  return a*b/gcd(a,b);
}
signed main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;

  int ac=(a-1)/c;
  int ad=(a-1)/d;
  int acd=(a-1)/(lcm(c,d));
  int bc=b/c;
  int bd=b/d;
  int bcd=b/(lcm(c,d));
  cout<<(b-bc-bd+bcd)-((a-1)-ac-ad+acd)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	
	int n; cin >> n;
	
	//vector<int> a(n); rep(i,n) cin >> a[i];
	
	
//	sort(all(a));
	
	
	cout << ((n-1)/1000+1)*1000 - n << endl;
	
	return 0;
}


Measured memory_bytes: 3640
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

class Program
{
    static void Main()
    {
        var line1 = MyUtil.ReadlongArray();
        int switchCount = (int)line1[0];
        int denkyuCount = (int)line1[1];

        List<long>[] denkyu = new List<long>[line1[1]];

        for (int i = 0; i < line1[1]; i++)
        {
            var input = MyUtil.ReadlongArray().ToList();
            input.RemoveAt(0);
            denkyu[i] = input;
        }

        var target = MyUtil.ReadlongArray();
        int bit = 0;
        int res = 0;

        while (true)
        {
            if (bit.GetBit(switchCount + 1) == 1)
            {
                break;
            }

            int ok = 0;
            for (int i = 0; i < denkyu.Length; i++)
            {
                var count = denkyu[i].Count(sw => bit.GetBit((int)sw) == 1);
                if (count % 2 == target[i])
                {
                    ++ok;
                }
            }

            if (ok == denkyuCount)
            {
                res++;
            }

            bit++;
        }

        WriteLine(res);

        ReadKey();
    }
}


static class MyUtil
{
    public static int GetBit(this int num, int count)
    {
        int mask = (int)Math.Pow(2, count - 1);
        return (num & mask) == 0 ? 0 : 1;
    }

    public static int[] ToBit(this int num)
    {
        const int size = sizeof(int) * 8;
        var array = new int[size];
        for (int i = 0; i < size; i++)
        {
            array[i] = num.GetBit(size - i);
        }
        return array;
    }

    public static long[] ReadlongArray()
    {
        return ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
    }

    /// <summary>
    /// <see cref="IEnumerable{T}"/>の各要素を並べてコンソールに出力します。各要素の間には半角スペースが一つ入ります。
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="ts"></param>
    public static void WriteToConsole<T>(this IEnumerable<T> ts)
    {
        StringBuilder stringBuilder = new StringBuilder();
        foreach (T t in ts)
        {
            stringBuilder.Append(t.ToString());
            stringBuilder.Append(" ");
        }
        stringBuilder.Remove(stringBuilder.Length - 1, 1);
        Console.WriteLine(stringBuilder.ToString());
    }

    public static void WriteToDebugConsole<T>(this IEnumerable<T> ts)
    {
        StringBuilder stringBuilder = new StringBuilder();
        foreach (T t in ts)
        {
            stringBuilder.Append(t.ToString());
            stringBuilder.Append(" ");
        }
        stringBuilder.Remove(stringBuilder.Length - 1, 1);
        System.Diagnostics.Debug.WriteLine(stringBuilder.ToString());
    }
}


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

int main(){
    queue<unsigned long int> q;
    unsigned long int x;
    int K, remainder;
    cin >> K;

    for(int i = 1;i < 10;i++) q.push(i);
    
    for(int i = 0;i < K-1;i++){
        x = q.front();
        remainder = x % 10;
        q.pop();
        if(remainder != 0) q.push(10*x+remainder-1);
        q.push(10*x+remainder);
        if(remainder != 9) q.push(10*x+1+remainder);
    }
    cout << q.front() << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
 
typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vl;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
 
#define ALL(a) (a).begin(),a.end()
#define MAXE(a) *max_element(ALL(a))
#define MINE(a) *min_element(ALL(a))

int main(){
  int N; 
  int a[100000];
  cin >> N;
  REP(i,N)cin >> a[i];
  string p = "Yes";
  long int M = a[N-1];
  REP(i,N-1){
    //taka
    long int h = a[N-1-i-1];
    if(h>M){
      h--; 
      if(h>M){
        p = "No"; 
        break;
      }
    }
    M = h;
  }
  cout << p << endl;
}


Measured memory_bytes: 640
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int len = s.length() - 1;
        long result = 0;

        for (int i = 0; i < Math.pow(2, len); i++) {
            StringBuilder sb = new StringBuilder(s);
            for (int j = len - 1; j >= 0; j--) {
                if ((1 & i >> j) == 1) {
                    sb.insert(j+1, "+");
                }
            }
            String[] numstr = sb.toString().split("\\+", 0);
            result += Arrays.stream(numstr).mapToLong(Long::parseLong).sum();
        }
        System.out.println(result);

    }
}

Measured memory_bytes: 27092
#include<stdio.h>
int A[100000],n;

int binarySearch(int key){
  int left=0;
  int right=n;
  int mid;
  while(left<right){
    mid=(left+right)/2;
    if(A[mid]==key){
      return 1;
    }
    if(key>A[mid]){
      left=mid+1;
    }
    else if(key<A[mid]){
      right=mid;
    }
  }
  return 0;
}
int main(){
  int i, q, key, sum=0;

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

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(binarySearch(key)){
      sum++;
    }
  }
  printf("%d\n",sum);
  return 0;
}



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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;
    string s;
    cin >> s;

    string t;
    rep(i,0,s.size()){
        if(s[i]=='A'){
            t+="A";
            continue;
        }
        if(i+1<s.size() and s[i]=='B' and s[i+1]=='C') {
            t+="D";
            ++i;
            continue;
        }
        t+=s[i];
    }

    i64 ans=0,a=0;
    rep(i,0,t.size()){
        if(t[i]=='A'){
            ++a;
            continue;
        }
        if(t[i]=='D'){
            ans+=a;
            continue;
        }
        a=0;
    }

    print(t);

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

typedef long long       ll;
typedef vector<int>     vi;
typedef pair<int,int>   pi;
typedef map<int,int>    mi;

#define F               first
#define S               second
#define pb              push_back
#define mp              make_pair
#define M               1000000007
#define SQ(a)           (a)*(a)
#define rep(i,a,b)      for(int i=a; i<b; i++)

void solve(){
  ll a;
  cin >> a;
  ll gcd = __gcd(a,2LL);
  ll lcm = (a/gcd)*2;
  cout << lcm << endl;
}
int main(){
    //int t; cin >> t; while(t--)
    solve();

    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#include <boost/rational.hpp>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll a;
  ll bbu,bbd;
  scanf("%lld %lld.%lld", &a, &bbu, &bbd);

  ll bb = bbu*100+bbd;

  cout<<(ll)(a*bb/100)<<endl;
//  cout<<(ll)(a*bb)<<endl;

//cout<<a<<' '<<bb<<' '<<b<<endl;

  return 0;
}


Measured memory_bytes: 3764
using System;

class quiz
{
    public string solve(string S)
    {
        int heisei = 20190430;

        string d = "";
        d += S[0];
        d += S[1];
        d += S[2];
        d += S[3];
        d += S[5];
        d += S[6];
        d += S[8];
        d += S[9];
        int date = int.Parse(d);

        if (date > heisei)
            return "TBD";
        else
            return "Heisei";
    }

    public int[] ParseIntBySpace(string str)
    {
        int[] array = new int[str.Length];
        int lastloc = 0, spaceloc = -1;

        for (int i = 0; i < str.Length; i++)
        {
            if (str[i] == ' ')
            {
                array[lastloc++] = int.Parse(str.Substring(spaceloc + 1, i - spaceloc - 1));
                spaceloc = i;
            }
            else if (i == str.Length - 1)
            {
                array[lastloc++] = int.Parse(str.Substring(spaceloc + 1, i - spaceloc));
            }
        }

        Array.Resize(ref array, lastloc);

        return array;
    }
}

class Example
{
    static void Main()
    {
        quiz ex = new quiz();

        Console.WriteLine(ex.solve(Console.ReadLine()));
    }
}

Measured memory_bytes: 13268
#include<cstdio>
#include<string>
#include<iostream>
#include<map>
using namespace std;
string s,last;
int n,len;
map<string,bool> mp;
int main(){
	scanf("%d",&n);
	cin>>last;len=last.length();
	mp.insert(make_pair(last,true));
	while(--n){
		cin>>s;
		if(mp.count(s)||s[0]!=last[len-1]){
			printf("No");
			return 0;
		}
		mp.insert(make_pair(s,true));
		last=s;len=last.length();
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 256
N = int(input())
if N == 1:
    print('Yes')
    print('2')
    print('1 1')
    print('1 1')
    exit()
for subs in range(2, N):
    n = N - subs
    if n == subs*(subs-1) // 2:
        print("Yes")
        print(subs+1)
        print(subs, end='')
        for i in range(1, subs+1):
            print(' ', end='')
            print(i, end='')
        print()
        li = [[] for _ in range(subs)]
        num = subs+1
        for i in range(len(li)):
            for j in range(i+1, subs):
                li[i].append(num)
                li[j].append(num)
                num += 1
        for ll in range(len(li)):
            print(len(li[ll])+1, end=' ')
            print(ll+1, end='')
            for kk in li[ll]:
                print(' ' + str(kk), end='')
            print()
        exit()
print("No")





Measured memory_bytes: 9480
def kaibun(str)
  len = str.length
  iskaibun = true
  (len/2).times do |i|
    iskaibun = false if str[i] != str[len-1-i]
  end
  iskaibun
end

s = gets.chomp
len = s.length
if kaibun(s) && kaibun(s[0..((len-1)/2)-1]) && kaibun(s[((len+3)/2)-1..len-1])
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
from collections import deque

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

cnt_2 = 0
cnt_4 = 0
for i in range(n):
    a = A[i]
    if a%4==0:
        cnt_4+=1
    elif a%2==0:
        cnt_2+=1
cnt_else = n-cnt_2-cnt_4
cnt_else += cnt_2%2

if cnt_else-1 <= cnt_4:
    print("Yes")
else:
    print("No")

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

string S;

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

  ll n;
  cin>>S;
  n=S.size();

  ll cnt=0,res=0;
  rep(i,n){
    if(S[i]=='B')cnt++;
    else res+=cnt;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}





int main(){
    string w; cin >> w;
    rep(i,w.length()) if(w[i] >= 'A' && w[i] <='Z') w[i] += 32;

    string t;
    int ans = 0;
    while(cin >> t and t != "END_OF_TEXT"){
        rep(i,t.length()) if(t[i] >= 'A' && t[i] <='Z') t[i] += 32;
        
        if(t == w) ans++;
    } 

    cout << ans << endl;
}



Measured memory_bytes: 3160
#include <iostream>

using namespace std;

int main() {
  int n, count = 0;
  long long k;
  
  cin >> n >> k;
  for(int i = 0 ; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    
    if(x*x + y*y <= k*k)
      count++;
  }
  
  cout << count;
}

Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
#define MAX_V 100
#define MAX_E 10000
int V,E,par[MAX_V],rnk[MAX_V];
struct Colony{
  double x,y,z,r;
  Colony(){}
  Colony(double x,double y,double z,double r) : x(x),y(y),z(z),r(r) {}
};
struct Edge{
  int u,v;
  double dist;
  Edge(){}
  Edge(int u,int v,double dist) : u(u),v(v),dist(dist) {}
};
bool comp(const Edge &e1,const Edge &e2){
  return e1.dist < e2.dist;
}
 
Edge es[MAX_E];
 
void init(){
  for(int i = 0 ; i < V ; i++){
    par[i] = i;
    rnk[i] = 0;
  }
}
 
int find(int x){
  if(par[x] == x){
    return x;
  }
  return par[x] = find(par[x]);
}
 
void unite(int x,int y){
  x = find(x);
  y = find(y);
 
  if(x == y) return;
 
  if(rnk[x] < rnk[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rnk[x] == rnk[y]){
      rnk[x]++;
    }
  }
}
 
bool same(int x,int y){
  return find(x) == find(y);
}
 
double kruskal(){
  sort(es,es+E,comp);
  init();
  double res = 0.0;
  for(int i = 0 ; i < E ; i++){
    Edge e = es[i];
    if(!same(e.u,e.v)){
      unite(e.u,e.v);
      res += e.dist;
    }
  }
  return res;
}
 
double getDist(const Colony &c1,const Colony &c2){
  return sqrt(pow(c1.x-c2.x,2)+pow(c1.y-c2.y,2)+pow(c1.z-c2.z,2))-c1.r-c2.r;
}
 
int main(){
  while(cin >> V,V){
    E = 0;
    double x,y,z,r;
    Colony C[MAX_V];
    for(int i = 0 ; i < V ; i++){
      cin >> x >> y >> z >> r;
      C[i] = Colony(x,y,z,r);
    }
     
    for(int i = 0 ; i < V ; i++){
      for(int j = i+1 ; j < V ; j++){
        double dist = getDist(C[i],C[j]);
        es[E++] = Edge(i,j,max(dist,0.0));
      }
    }
    printf("%.3f\n",kruskal());
  }
  return 0;
}

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

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

  string s;
  cin >> s;

  if (s[1] == 'R') cout << "ABC\n";
  else cout << "ARC\n";

  return (0);
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>

int main() {
    int n;
    std::cin >> n;
    std::vector<long int> a;
    std::vector<long int> b;

    for (int i = 0; i < n+1; i++) {
        long int temp;
        std::cin >> temp;
        a.push_back(temp);
    }

    for (int i = 0; i < n; i++) {
        long int temp;
        std::cin >> temp;
        b.push_back(temp);
    }

    long int carry = 0;
    long int monsters_defeated_strat1 = 0;
    for (int i = 0; i < n; i++)
    {
        if(a[i] >= b[i] + carry) {
            monsters_defeated_strat1 += b[i] + carry;
            carry = 0;
        }
        else
        {
            monsters_defeated_strat1 += a[i];
            carry = b[i] - a[i];
            if(carry < 0) {
                carry = 0;
            }
        }

    }
    if(carry >= a[a.size()-1]) {
        monsters_defeated_strat1 += a[a.size()];
    } else {
        monsters_defeated_strat1 += carry;
    }

    carry = 0;
    long int monsters_defeated_strat2 = 0;
    for (int i = n-1; i >= 0; i--)
    {
        if(a[i+1] >= b[i] + carry) {
            monsters_defeated_strat2 += b[i] + carry;
            carry = 0;
        }
        else
        {
            monsters_defeated_strat2 += a[i+1];
            if(carry > a[i+1]) {
                carry = b[i];
            } else {
                carry = b[i] + carry - a[i+1];
            }
            if(carry < 0) {
                carry = 0;
            }
        }
    }
    if(carry >= a[0]) {
        monsters_defeated_strat2 += a[0];
    } else {
        monsters_defeated_strat2 += carry;
    }

    std::cout << (monsters_defeated_strat1 > monsters_defeated_strat2 ? monsters_defeated_strat1 : monsters_defeated_strat2) << std::endl;
}

Measured memory_bytes: 2548
n, m = map(int, input().split())
pos = []
che = []
for i in range(n):
    a, b = map(int,input().split())
    pos.append([a,b])
for i in range(m):
    a, b = map(int,input().split())
    che.append([a,b])
 
for i in range(n):
    dis = []
    for j in range(m):
        dis.append(abs(pos[i][0]-che[j][0])+abs(pos[i][1]-che[j][1]))
    print(dis.index(min(dis))+1)




Measured memory_bytes: 3064
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun main() {
    val (n, k) = readIntList()
    val okashi = Array(n+1) { 0 }.apply { this[0]++ }
    for (i in 0 until k) {
        readInt()
        val a = readIntList()
        a.forEach { okashi[it]++ }
    }
    println(okashi.count { it == 0 })
}


Measured memory_bytes: 38664
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int L = sc.nextInt();

		int[] c = new int[N + 1];

		for (int i = 1; i <= N; i++)
			c[i] = L + i - 1;

		int s = 0;
		int ans = 300;

		for (int i = 1; i <= N - 1; i++) {

			if (ans > Math.min(Math.abs(c[i]), Math.abs(c[i + 1])))
				ans = Math.min(Math.abs(c[i]), Math.abs(c[i + 1]));
		}
		for (int i = 1; i <= N; i++)
			s += c[i];

		for (int i = 1; i <= N; i++)
		if(c[i]==ans)
			s -= ans;

		for (int i = 1; i <= N; i++)
			if(c[i]== -ans)
				s += ans;




		System.out.println(s);

	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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


Measured memory_bytes: 21332
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    string s;
    cin >> s;
    n = s.length();
    vector<int> ans(n);
    rep(ri, 2) {
        int cnt = 0;
        rep(i, n) {
            if ( s[i] == 'R' ) ++cnt;
            else {
                ans[i] += cnt / 2;
                ans[i-1] += (cnt+1) / 2;
                cnt = 0;
            }
        }
        reverse(ans.begin(), ans.end());
        reverse(s.begin(), s.end());
        rep(i, n) {
            if ( s[i] == 'L' ) s[i] = 'R';
            else s[i] = 'L';
        }
    }
    rep(i, n) {
        printf("%d\n", ans[i]);
    }
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  vector<int> cnt(26, 0);
  rep(i,s.size()){
    cnt[s[i]-97]++;
  }
  rep(i,26){
    if(cnt[i]%2!=0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

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

const char newl = '\n';

int main() {
    int n;
    cin >> n;
    vector<int> ans;
    vector<ll> a(n);
    for (int i = 0;i < n;++i) cin >> a[i];
    ll mx = *max_element(a.begin(),a.end());
    if (mx < 0) {
        for (int i = 0;i < n;++i) {
            if (a[i] == mx) {
                for (int j = i+1;j < n;++j) ans.push_back(j+1);
                break;
            }
            ans.push_back(1);
        }
        reverse(ans.begin(),ans.end());
    } else {
        ll x[2] = {0,0};
        for (int i = 0;i < n;++i) {
            x[i&1] += max(0LL,a[i]);
        }
        bool f = (x[1] > x[0]);
        mx = x[f];
        int l = n,r = 0;
        for (int i = f;i < n;i += 2) if (a[i] >= 0) {
            l = min(i,l);
            r = max(i,r);
        }
        int c = (r-l)/2;
        for (int i = n-1;i > r;--i) ans.push_back(i+1);
        for (int i = r;i >= l;i -= 2) if (a[i] < 0) {
            ans.push_back(i+1);
            c--;
        }
        for (int i = 0;i < l;++i) ans.push_back(1);
        for (int i = 0;i < c;++i) ans.push_back(2);
    }
    cout << mx << newl;
    cout << ans.size() << newl;
    for (int i : ans) cout << i << newl;
}

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

using namespace std;

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

	int c1=0,c2=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='\)')
			c1--;
		else
			c1++;
		if(c1<0)c1=0;
	}
	for(int i=s.size()-1;i>=0;i--)
	{
		if(s[i]=='\)')
			c2++;
		else
			c2--;
		if(c2<0)c2=0;
	}

	for(int i=0;i<c2;i++)
		cout << "\(";
	cout << s;
	for(int i=0;i<c1;i++)
		cout << "\)";
	cout << endl;
}



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

using namespace std ; 

const int N = 1e5 + 7 ; 


int main(){
    ios_base::sync_with_stdio(0) ; 
    cin.tie(0) ; 
    //freopen("in.in" , "r" , stdin) ; 
     int n , m , ans = 0, sum = 0  ; 
     cin>>n>> m ; 
     double a[n+1] ; 
     for(int i =0 ; i < n ; i++)
     {
         cin>>a[i] ; 
         sum+=a[i] ; 
     }
     double lim = sum / (4.0 * m) ; 
     for(int i = 0 ; i < n;i++){
        if(a[i] >=lim)ans++ ; 
     }
     if(ans>=m)cout<<"Yes" ;
     else cout<<"No"; 


    return 0 ; 
}

Measured memory_bytes: 256
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define F first
#define S second
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << "\n"; cout << endl;

#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;
while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;
ll vis[N],res[N];

int solve() 
{
	//happy coding

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

	sort(b,b+n);
	std::vector<int> v;
	for(int i=0;i<n;i++){
		if(b[n-1]!=a[i]){
			v.pb(b[n-1]);
		}else{
			v.pb(b[n-2]);
		}
	}

	vout(v);

	
	return 0;
}
int main(){
	int test = 1;
  	//scanf("%d", &test);
  	while (test--)solve();return 0;
}

Measured memory_bytes: 4084
#include <stdio.h>

int main(void){
  int a, b, wa, sa, seki, bigger, max;

  scanf("%d %d", &a, &b);
  wa = a+b; sa = a-b; seki = a*b;
  bigger = (wa > sa) ? wa : sa;
  max = (bigger > seki) ? bigger : seki;

  printf("%d \n", max);
  return 0;
}


Measured memory_bytes: 128
#分割してみた。
#
iN,iA =[int(x) for x in input().split()]
aX = [int(x) - iA for x in input().split()]
aPlus = [x for x in aX if 0 < x ]
aMinus = [-1 * x for x in aX if x < 0  ]
iLenPlus = len(aPlus)
iLenMinus = len(aMinus)
iLen0 = iN - iLenPlus - iLenMinus

iCZero = 2**iLen0 - 1 #sum(k=1..N){nCk} = 2^n -1

iRet = 0
iRet += iCZero
iCZero += 1 #0の場合を追加

iSumPlus = sum(aPlus)
iSumMinus = sum(aMinus)
iUlim = min(iSumPlus , iSumMinus)
iOlim = max(iSumPlus , iSumMinus)
if 0 < iUlim:
    dp1 = [[0]*(iOlim +1) for _ in range(iLenPlus)]
    dp1[0][0] = 1
    dp1[0][aPlus[0]]=1
    for j in range(1,iLenPlus):
        for k in range(iUlim + 1):
            if k < aPlus[j] :
                dp1[j][k] = dp1[j-1][k]
            else:
                dp1[j][k] = dp1[j-1][k] + dp1[j-1][k-aPlus[j]]

    dp2 = [[0]*(iOlim +1) for _ in range(iLenMinus)]
    dp2[0][0] = 1
    dp2[0][aMinus[0]]=1
    for j in range(1,iLenMinus):
        for k in range(iUlim + 1):
            if k < aMinus[j] :
                dp2[j][k] = dp2[j-1][k]
            else:
                dp2[j][k] = dp2[j-1][k] + dp2[j-1][k-aMinus[j]]
    for i in range(1,iUlim+1):
        iRet += iCZero * dp1[-1][i] * dp2[-1][i]

print(iRet)


Measured memory_bytes: 3444
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#define int long 
using namespace std;

signed main() {
	int A,B,C;
	cin >> A >> B >> C;
	if(A == 7 && B == 5 && C == 5) {
		cout << "YES" << endl;
	}
	else if(A == 5 && B == 7 && C == 5) {
		cout << "YES" << endl;
	}
	else if(A == 5 && B == 5 && C == 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
m, k = map(int, input().split())
if k >= 2**m:
  print(-1)
elif m == 0:
  print(0, 0)
elif m == 1:
  if k == 0:
    print(0, 0, 1, 1)
  else:
    print(-1)
else:
  for i in range(2**m):
    if i == k:
      continue
    print(i, end=" ")
  print(k, end=" ")
  for i in range(2**m-1, -1, -1):
    if i == k:
      continue
    print(i, end=" ")
  print(k)

Measured memory_bytes: 9220
a = input()

t, c = int(a.split(" ")[0]), int(a.split(" ")[1])

if not c:
    print(t)
else:
    b = input()
    lst = [int(x) for x in b.split(" ")]

    for i in range(c+2):
        if t - i not in lst:
            print(t - i)
            break
        if t + i not in lst:
            print(t + i)
            break


Measured memory_bytes: 9100
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
//#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
#define rep(i,a,n) for(Int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(Int (i)=(a); (i)<=(n); (i)++)
const int MAX_N = 1000000;
const Int MAX_N_Int = 1000000000000;

template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}

int D;
string str,s,u;
vector<int>c(26);
vector<int>t(366),t0(366);
vector<vector<int>> ss(366, vector<int>(26));
//vector<vector<int>> last(365, vector<int>(26));
vector<int> last(26),last0(26);
int satisfaction=0;
int init_score;

int init(){
    vector<int>c_copy(26);
    c_copy=c;
    rsort(c_copy);
    int now=1;
    srand( time(NULL) );
    for (int i = 0; i < D; ++i) {
        t[i]=now;
        //now=min(now+1,26);
        now=rand () % 26+1;
        if(now>26)now=1;
    }

    return 0;

}

int score(){
    satisfaction=0;
    last=last0;
    for (int d = 0; d < D; ++d) {
        int i = t[d]-1;
        satisfaction+=ss[d][i];

        last[i]=d+1;
        for (int cc = 0; cc < 26; ++cc) {
            satisfaction-=c[cc]*((d+1)-last[cc]);
        }
        //cout<<satisfaction<<endl;
    }

    return satisfaction;
}
int hajime = clock();
int loop(){
    int old_score=init_score;
    int new_score=0;
    srand( time(NULL) );
    int cnt=0;
    while(cnt<=20000000){
        if ((clock() - hajime) > 1.95 * CLOCKS_PER_SEC) break;
        int d=rand()%365+1;

            int now=t[d];
            //t[d]++;
            //t[d]=min(t[d]+1,26);
            t[d]=min(rand()%26+1,26);
            new_score=score();
            if(new_score<=old_score){
                t[d]=now;

            }else{
                old_score=new_score;
                //cout<<cnt<<" "<<d<<" "<<new_score<<endl;
            }



        cnt++;
    }



    return 0;
}

int main() {
    IOS;
    prec;

    string sss;
    int ans=0;
    cin>>sss;
    if(sss=="RRR")cout<<3;
    else if(sss=="SSS")cout<<0;
    else if(sss=="RRS" or sss=="SRR")cout<<2;
    else cout<<1;






    cout<<endl;
    return 0;
}


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

    int i,n,m,j,k,l,o,p;
    cin>>n;
    int a[n];
    int tot= 0;
    unordered_map<int,int>M;
    for(i=0;i<n;i++){
        cin>>a[i];
        M[a[i]]+=1;
    }
    for(auto it =M.begin();it!=M.end();it++){
        int A = (*it).first;
        int B = (*it).second;
        if(B>=A)
        {
            tot+=(B-A);
        }
        else
        {
            tot+=(B);
        }
    }
    cout<<tot<<endl;
}

Measured memory_bytes: 4644