akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define mod (int)1e9+7
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/


signed main() {
	int a, b, c; cin >> a >> b >> c;
	cout << max(0ll, c - (a - b)) << endl;
}


Measured memory_bytes: 256
/// How many numbers x are there in the range a to b, where the digit d occurs exactly k times in x?
//https://github.com/flash7even/Programming-Contest/blob/master/Code%20Repository/Dynamic%20Programming/Digit%20DP/Digit-DP.cpp
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<int> num;
int a, b, d, k;
int DP[120][120][2];
/// DP[p][c][f] = Number of valid numbers <= b from this state
/// p = current position from left side (zero based)
/// c = number of times we have placed the digit d so far
/// f = the number we are building has already become smaller than b? [0 = no, 1 = yes]

int call(int pos, int cnt, int f){
    if(cnt > k) return 0;

    if(pos == num.size()){
        if(cnt == k) return 1;
        return 0;
    }

    if(DP[pos][cnt][f] != -1) return DP[pos][cnt][f];
    int res = 0;

    int LMT;

    if(f == 0){
        /// Digits we placed so far matches with the prefix of b
        /// So if we place any digit > num[pos] in the current position, then the number will become greater than b
        LMT = num[pos];
    } else {
        /// The number has already become smaller than b. We can place any digit now.
        LMT = 9;
    }

    /// Try to place all the valid digits such that the number doesn't exceed b
    for(int dgt = 0; dgt<=LMT; dgt++){
        int nf = f;
        int ncnt = cnt;
        if(f == 0 && dgt < LMT) nf = 1; /// The number is getting smaller at this position
        if(dgt == d) ncnt++;
        if(ncnt <= k) res += call(pos+1, ncnt, nf);
    }

    return DP[pos][cnt][f] = res;
}


signed main () {

    string s;
    cin >> s;
    cin >> k;
    k = s.size()-k;
    for(int i=0;i<s.size();i++){
      num.push_back(s[i]%48);
    }
    // cin >> a >> b >> d >> k;
    d = 0;
    memset(DP, -1, sizeof(DP));
    int res = call(0, 0, 0);
    // int res = call(0,0,0);
    // if(k==1)res--;
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i], a[i]--;

    ll need = 0;
    REP(i, n) {
        if(a[i] == need) {
            need++;
        }
    }

    if(need == 0) cout << -1 << endl;
    else cout << n-need << endl;

    return 0;
}

Measured memory_bytes: 1792
fun main(args: Array<String>) = abc155c()
// region
private inline fun printAnswer(function: StringBuilder.() -> StringBuilder) = print(StringBuilder().let(function))

private fun StringBuilder.println(message: Any?) = appendln(message)
private fun StringBuilder.print(message: Any?) = append(message)
// endregion
fun abc155c() = printAnswer {
    val n = readLine()!!.toInt()
    val list = (1..n).map { readLine()!! }

    val map = list.groupBy { it }.map { it.key to it.value.size }
    val max = map.maxBy { it.second }!!.second

    val answer = map.filter { it.second == max }.map { it.first }.sorted()

    for (a in answer) println(a)

    return@printAnswer this
}


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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        Point[] base = new Point[n];

        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            base[i] = new Point(x, y);
        }

        double sum = permutation(base);
        int cnt = 1;
        for (int i = 1; i <= n; i++) {
            cnt *= i;
        }

        System.out.println(sum / cnt);
    }

     static double permutation(Point[] base) {
        Point[] perm = new Point[base.length];
        boolean[] used = new boolean[base.length];
        return buildPerm(base, perm, used, 0);
     }

     static double buildPerm(Point[] base, Point[] perm, boolean[] used, int index) {
        if (index == base.length) {
            return calc(perm);
        }

         double sum = 0.0;
         for (int i = 0; i < base.length; i++) {
             if (used[i]) continue;
             perm[index] = base[i];
             used[i] = true;
             sum += buildPerm(base, perm, used, index+1);
             used[i] = false;
         }

         return sum;
     }

     static double calc(Point[] a) {
        double sum = 0.0;
        for (int i = 0; i < a.length-1; i++) {
            sum += dist(a[i], a[i+1]);
        }
        return sum;
     }

    static double dist(Point a, Point b) {
        return Math.sqrt(Math.pow((a.x - b.x), 2.0) + Math.pow((a.y - b.y), 2.0));
    }

    static class Point {
        int x, y;
        Point(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

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

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int X,Y;cin>>X>>Y;
	if (X<=Y) cout<<"unsafe";
	else cout<<"safe";
	
}


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

#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			1'010'000'000'000'000'017LL
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )

using namespace std;

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;
}


void Main()
{
	ll N;
	cin >> N;
	ll res = (N % 1000 == 0) ? 0 : 1000 - (N % 1000);
	cout << res << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	Main();
	return 0;
}

Measured memory_bytes: 3624
//git pull --rebase origin master
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define wi(t) int t;cin>>t;while(t--)
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];
ll int gcd(ll int a, ll int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
int tc=1;
void solve()
    { 
        ll int a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<max(a*c,max(b*c,max(a*d,b*d)));

    }

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

   // wi(t)
    {
      solve();
    }

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
    int i, u, v;
    while(m--){
        cin>>u>>v;
    u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
}

void dfs(int u, int par){
    for(int v:g[u]){
        if (v == par) continue;
        dfs(v, u);
    }
}







Measured memory_bytes: 10684
H, N = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]

dp = [10 ** 18] * (H + 1)

dp[0] = 0

for i in range(H + 1):
    for A, B in AB:
        if i + A >= H:
            dp[H] = min(dp[H], dp[i] + B)
        else:
            dp[i + A] = min(dp[i + A], dp[i] + B)

res = dp[H]

print(res)


Measured memory_bytes: 74188
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	d := make([]int, n)
	for i := 0; i < n; i++ {
		d[i] = nextInt()
	}

	sort.Ints(d)
	l, r := d[n/2-1], d[n/2]

	fmt.Println(r-l)
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ull Pow(ull a , ull b){
	if(b == 0) return 1 ;
	ull c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c) % mod)) % mod;
	return (c * c) % mod ;
}
vi l ;
int n , a , b, c ;

int main(){
	IOS;
	cout.precision(30) ;
	cin >> n >> a >> b >> c ;
	l.resize(n) ;
	for(int i = 0 ; i < n ; i++) cin >> l[i] ;
	int ans = 1e6 ;
	for(int i = 1 ; i <(1 << n) ; i++){
		for(int j = 1 ;j <(1 << n) ; j++){
			for(int k = 1 ; k < (1 << n) ; k++){
				if(((i & j) == 0) && ((i & k) == 0) && ((j & k) == 0)){
					int a1 = 0 , b1 = 0 , c1 = 0;
					for(int j1 = 0; j1 < n ; j1++) if(i & (1 << j1)) a1 += l[j1] ;
					for(int j1 = 0; j1 < n ; j1++) if(j & (1 << j1)) b1 += l[j1] ;
					for(int j1 = 0; j1 < n ; j1++) if(k & (1 << j1)) c1 += l[j1] ;
					ans = min( ans , abs(a - a1) + abs(b - b1) + abs(c - c1) + 10 * (__builtin_popcount(i) - 1) + 10 * (__builtin_popcount(j) - 1) + 10 * (__builtin_popcount(k) - 1)) ;
				}
			}
		}
	}
	cout << ans << endl ;
	return 0;
}


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


class Program
{


    static void Main(string[] args)
    {
        Solve();
    }

    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();

        var s = sc.intarr;
        int a = s[0];
        int b = s[1];
        int c = s[2];
        int k = sc.intarr[0];

        wr.wri(a + b + c - Math.Max(Math.Max(a, b), c) + Math.Max(Math.Max(a, b), c) * Math.Pow(2, k));
            
    }


}
    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 11348
n, d = map(int, input().split())
x = [list(map(int, input().split())) for number in range(n)]
ans = 0
for a in range(n):
    for b in range(n):
        if a < b:
            distance_element =  [(ai - bi) ** 2 for ai, bi in zip(x[a], x[b])]
            distance = sum(distance_element) ** (1/2)
            if distance - int(distance) == 0:
                ans += 1
            else:
                pass
        else:
            pass
print(ans)




Measured memory_bytes: 3188
#include <stdio.h>

int main(){

  int S;
  int h, m, s;

  scanf("%d", &S);

  h = S / 3600;
  m = (S % 3600) / 60;
  s = (S % 3600) % 60;
  
  printf("%d:%d:%d\n", h, m, s); 

  return 0;
}

Measured memory_bytes: 592
lst = [list(map(int, input().split())) for i in range(3)]
ans = 'No'
if (lst[1][0] - lst[0][0] + lst[0][1] == lst[1][1] and lst[1][2] - lst[0][2] + lst[0][1] == lst[1][1] and lst[1][0] - lst[2][0] + lst[2][1] == lst[1][1] and lst[1][2] - lst[2][2] + lst[2][1] == lst[1][1]):
  ans = 'Yes'
print(ans)

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

int main()
{
    string n;
    cin >> n;
    if (n[0] == n[1] && n[1] == n[2] || n[1] == n[2] && n[2] == n[3])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

int main()
{
    long N;
    cin >> N;
    long a[N];
    for(int i=1;i<N;i++){
        cin >> a[i];
    }
    long sub[N];
    for(int i=0;i<N;i++){
        sub[i]=0;
    }
    for(int i=1;i<N;i++){
        sub[a[i]-1]++;
    }
    for(int i=0;i<N;i++){
        cout << sub[i] << endl;
    }
}

Measured memory_bytes: 6720
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind, COM//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 0; ll INF = 9999999999999;
vl flag, color; vll path;
//***********//
int main() {
	cin >> N >> M;
	vector<vpll> list(N);
	for (i = 0; i < M; i++) {
		ll p, y;
		cin >> p >> y;
		list[p - 1].push_back(make_pair(y, i));
	}
	vector<string> A(M);
	for (i = 0; i < N; i++) {
		if (list[i].size() == 0) { continue; }
		//cout << i << " " << list[i].size() << endl;
		sort(list[i].begin(), list[i].end());
		for (j = 0; j < list[i].size(); j++) {
			ll k = list[i][j].second;
			ll I = i + 1;
			for (l = 0; l <= 5; l++) {
				ll p = pow(10, 5 - l);
				A[k].push_back((I / p) +'0');
				I %= p;
			}
			ll J = j + 1;
			for (l = 0; l <= 5; l++) {
				ll p = pow(10, 5 - l);
				A[k].push_back((J / p) + '0');
				J %= p;
			}
		}
	}
	for (i = 0; i < M; i++) {
		cout << A[i] << endl;
	}
}


Measured memory_bytes: 13952
#include <iomanip>
#include <iostream>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  vector<string> S(N);
  rep(i, N) cin >> S[i];

  if(A == 0 && B == 0 && C == 0) {
    cout << "No" << endl;
    return 0;
  }

  vector<char> answer(N);
  rep(i, N) {
    if (S[i] == "AB") {
      if(A == 0 && B == 0) {
        cout << "No" << endl;
        return 0;
      }
      if(A < B) {
        A++, B--;
        answer[i] = 'A';
      } else if(B < A) {
        B++, A--;
        answer[i] = 'B';
      } else {
        if(i < N - 1 && S[i + 1] == "BC") {
          B++, A--;
          answer[i] = 'B';
        } else if(i < N - 1 && S[i+1] == "AC") {
          A++, B--;
          answer[i] = 'A';
        } else {// AB or i == N-1
          // dont care
          A++, B--;
          answer[i] = 'A';
        }
      }
    } else if(S[i] == "BC") {
      if(B == 0 && C == 0) {
        cout << "No" << endl;
        return 0;
      }
      if(B < C) {
        B++, C--;
        answer[i] = 'B';
      } else if(C < B) {
        C++, B--;
        answer[i] = 'C';
      } else {
        if(i < N - 1 && S[i + 1] == "AB") {
          B++, C--;
          answer[i] = 'B';
        } else if(i < N - 1 && S[i+1] == "AC") {
          C++, B--;
          answer[i] = 'C';
        } else {// BC or i == N-1
          // dont care
          B++, C--;
          answer[i] = 'B';
        }
      }
    } else {// AC
      if(A == 0 && C == 0) {
        cout << "No" << endl;
        return 0;
      }
      if(A < C) {
        A++, C--;
        answer[i] = 'A';
      } else if(C < A) {
        C++, A--;
        answer[i] = 'C';
      } else {
        if(i < N - 1 && S[i + 1] == "AB") {
          A++, C--;
          answer[i] = 'A';
        } else if(i < N - 1 && S[i+1] == "BC") {
          C++, A--;
          answer[i] = 'C';
        } else {// AC or i == N-1
          // dont care
          A++, C--;
          answer[i] = 'A';
        }
      }
    }
  }

  cout << "Yes" << endl;
  rep(i, N) cout << answer[i] << endl;
  return 0;
}


Measured memory_bytes: 6652
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int a[25];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int cnt=0;
	for(int i=1;i+1<n;i++){
		if(a[i]>a[i-1] && a[i]>a[i+1])continue;
		if(a[i]<a[i-1] && a[i]<a[i+1])continue;
		cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 256
//
// Created by kashi on 26-06-2020.
//
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define Endl endl
#define int long long
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
bool cmps(pair<int,int>p1,pair<int,int>p2) {
    return p1.ss<p2.ss;
}
const int MAXN = 2e5+ 10;

int32_t main() {
    string s,t;
    cin>>s>>t;
    int count=0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i])
            count++;
    }
    cout<<count<<endl;
}

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

using namespace std;

void Main()
{
    int ab, bc, ca;
    cin >> ab >> bc >> ca;

    cout << ab * bc / 2;
}

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

    //std::cout << std::fixed << std::setprecision(10);

#ifdef DEBUG_BUILD
    while (true)
    {
        Main();
        cout << std::endl;
    }
#endif

    Main();
    cout << endl;

    return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 123;
const int mod = 1e9+7;

int n;
long long dp[N][4][4][4];

long long rek(int i, int ppp, int pp, int p) {
  if (i == n) return 1;
  long long &ret = dp[i][ppp][pp][p];
  if (ret != -1) return ret;
  ret = 0;
  ret = (ret + rek(i+1, pp, p, 0)) % mod; // 'A'
  if (!((pp == 0 && p == 2) || (ppp == 0 && p == 2) || (ppp == 0 && pp == 2) || (pp == 2 && p == 0)))
    ret = (ret + rek(i+1, pp, p, 1)) % mod; // 'C'
  if (!(pp == 0 && p == 1))
    ret = (ret + rek(i+1, pp, p, 2)) % mod; // 'G'
  ret = (ret + rek(i+1, pp, p, 3)) % mod; // 'T'
  return ret;
}

void solve() {
  memset(dp, -1, sizeof(dp));
  scanf("%d", &n);
  printf("%lld", rek(0, 3, 3, 3));
}

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


Measured memory_bytes: 3884
#include "bits/stdc++.h"
using namespace std;

#define rep(i,a,b) for(int i=a;i<=b;i++)
typedef long long ll;
typedef unsigned long long ull;

const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
const int bb=13331;
ll a,b,c,d,n,m;


int main()
{
    //ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin>>n;
    a=0;
    d=0,m=0;
    for(ll i=0;i<n;i++)
    {
    	cin>>b;
    	if(b>a) 
		{
			m=(d>m?d:m);d=0,a=b;
		}
    	else d++,a=b;
	}
	m=(d>m?d:m);
	cout<<m<<endl;
}

Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 300005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*
int inv[1000001]={0};int invf[1000001]={0};
void findinverse(){
	inv[0]=1;
	inv[1] = 1;
	for(int i = 2; i <=1e6 ; ++i)
		inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;
	invf[0]=1;invf[1]=1;
	for(int i=2;i<=1e6;i++){
		invf[i]=invf[i-1]*inv[i]%mod;
	}
}*/
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> orderedMultiset;
int n,k;
vi a,dp(MAX,-1);
int calc(int i){
	if(i==n-1)
		return 1;
	if(dp[i]!=-1)
		return dp[i];
	int x=-1,y=-1;
	for(int j=i+1;j<n;j++){
		if(a[j]-a[i]<=k && a[j]>=a[i]){
			x=j;
			break;
		}
	}
	for(int j=i+1;j<n;j++){
		if(a[i]-a[j]<=k && a[j]<a[i]){
			y=j;
			break;
		}
	}
	if(x==-1 && y==-1)
		dp[i]=1;
	else if(x==-1)
		dp[i]=1+calc(y);
	else if(y==-1)
		dp[i]=1+calc(x);
	else
		dp[i]=max(1+calc(x),1+calc(y));
	return dp[i];
}
int solve()
{
	int ans=0;
	cin>>n>>k;
	a.resize(n);
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++){
		ans=max(calc(i),ans);
	}
	cout<<ans<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}



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

int main() {
	// your code goes here
	int i, j, ans=0, n;
	string s;
	cin>>s;
	n=s.length();
	ans=n;
	int l=0;
	while(1) {
		string next="";
		n=s.length();
		for(i=0; i<n; ++i) {
			if(s[i]=='S')
				l++;
			else {
				j=i;
				int r=0;
				while(s[j]=='T')
					j++, r++;
				i=j-1;
				//cout<<l<<" "<<r<<endl;
				if(l>r) {
					for(j=0; j<l-r; ++j)	next+='S';
				}
				else {
					for(j=0; j<r-l; ++j)	next+='T';
				}
				ans-=2*min(l, r);
				l=0;
			}
		}
		if(l) {
			for(j=0; j<l; ++j)
				next+='S';
			l=0;
		}
		//cout<<next<<endl;
		if(s==next)	break;
		s=next;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 836
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main(){
	long n,h,w;
	cin >> n >> h >> w;
	int a,b,cnt=0;
	for(int i=0;i<n;i++){
		cin >> a >> b;
		if(a>=h && b>=w){
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


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

int main() {
  int N, A, B, C, D, n = 0, m = 0;
  cin >> N >> A >> B >> C >> D;
  while((n * A) < N) n++;
  while((m * C) < N) m++;
  cout << min((n * B), (m * D)) << endl;
  return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

typedef long long ll;
typedef pair<char, ll> query;



ll N, Q, ans;

//parent, nearest marked ancestor, ismarked
vector <ll> par, nma, ism;
vector <query> q;

//find nearest marked ancestor (keiroasshuku at the same time)
ll find_nma(ll x){
	if (nma[x] == x) return x;
	else return nma[x] = find_nma(par[x]);
}

void solve(void){
	//ENJYU;
	while (cin >> N >> Q) {
		if (N == 0 && Q == 0) break;
		//init
		par.clear(), ism.clear(), nma.clear(), q.clear();
		par.resize(N), ism.resize(N), nma.resize(N), q.resize(Q);
		par[0] = 0, ism[0] = 1, nma[0] = 0;
		ans = 0LL;
		rep(N-1, i) {
			cin >> par[i+1];
			par[i+1]--;
		}
		nma = par;

		//クエリ受け取り
		rep(Q, i) {
			cin >> q[i].fst >> q[i].snd;
			q[i].snd--;
			//先にMARKしておく
			if (q[i].fst == 'M') {
				ism[q[i].snd]++;
				nma[q[i].snd] = q[i].snd;
			}
		}

		//クエリを逆から見ていくと、頂点の更新は根の方向にのみ行われるので、前回の結果を使える
		repr(Q, i) {
			if (q[i].fst == 'M') {
				ism[q[i].snd]--;
				if (ism[q[i].snd]) continue;
				nma[q[i].snd] = find_nma(par[q[i].snd]);
				continue;
			}
			ans += find_nma(q[i].snd) + 1;
		}
		cout << ans << endl;
	}
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 7616
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
ALDS1_1-A

Getting Started - Insertion Sort
Time Limit : 1 sec, Memory Limit : 65536 KB
Japanese version is here
Insertion Sort

Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:

for i = 1 to A.length-1
    key = A[i]
    /* insert A[i] into the sorted sequence A[0,...,j-1] */
    j = i - 1
    while j >= 0 and A[j] > key
        A[j+1] = A[j]
        j--
    A[j+1] = key

Note that, indices for array elements are based on 0-origin.

To illustrate the algorithms, your program should trace intermediate result for each step.
Input

The first line of the input includes an integer N, the number of elements in the sequence.

In the second line, N elements of the sequence are given separated by a single space.
Output

The output consists of N lines. Please output the intermediate sequence in a line for each step. Elements of the sequence should be separated by single space.
Constraints

1 ??? N ??? 100
Sample Input 1

6
5 2 4 6 1 3

Sample Output 1

5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6

Sample Input 2

3
1 2 3

Sample Output 2

1 2 3
1 2 3
1 2 3

Hint
Template in C

=end
class Sort
  def initialize(v)
    @n = v.length
    @f = Array.new(@n, 0)
    (0..(@n-1)).each {|i| @f[i] = v[i]}
  end

  def insertion(debug)
    (0..@n-1).each{|i|
      key = @f[i]
      j = i-1
      while j>=0 and @f[j] > key
        @f[j+1] = @f[j]
        j -= 1
      end
      @f[j+1]=key

      puts @f.map{|x| x.to_s}.join(" ") if debug
    }
  end
end

class Main
  def initialize
    #fh = open("ALDS1_1_A.txt")
    fh = STDIN
    v=[]
    n = fh.gets.chomp.to_i
    v = fh.gets.chomp.split.map{|x| x.to_i}

    st = Sort.new(v)
    st.insertion(true)
  end
end

if $0==__FILE__ then
  Main.new()
end

Measured memory_bytes: 8792
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define maxn 55
#define maxm 2505
using namespace std;
int x[maxn],y[maxn],p[maxm][2],lp=0,n,Min=0x3fffffff;
bool flag[maxn];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d%d",&x[i],&y[i]);
	for(int i=1;i<=n;i++)
	  for(int j=1;j<=n;j++)
	  {
	  	if(i==j)continue;
	    p[++lp][0]=x[i]-x[j];  p[lp][1]=y[i]-y[j];
	  }
	for(int k=1;k<=lp;k++)
	{
	  memset(flag,0,sizeof(flag));
	  int ans=n,x1=p[k][0],y1=p[k][1];
	  for(int i=1;i<=n;i++)
	    for(int j=1;j<=n;j++)
	    {
		  if(i==j||flag[i])continue;
		  if(x[i]+x1==x[j]&&y[i]+y1==y[j])flag[i]=1,ans--;
		}
	  Min=min(Min,ans);
	}
	if(n==1)puts("1");
	else printf("%d\n",Min);
	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int MAXN=100000;
int a[MAXN+5],cnt1[MAXN+5],cnt2[MAXN+5];
int n,Max1,Max2,Max11,Max22,f1,f2;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i+=2)
	{
		cnt1[a[i]]++;
		if(cnt1[a[i]]>Max1)//最大
		{
			Max1=cnt1[a[i]];
			f1=a[i];
		}
		else if(cnt1[a[i]]>Max11)//次大
			Max11=cnt1[a[i]];
	}
	for(int i=2;i<=n;i+=2)
	{
		cnt2[a[i]]++;
		if(cnt2[a[i]]>Max2)
		{
			Max2=cnt2[a[i]];//最大
			f2=a[i];
		}
		else if(cnt2[a[i]]>Max22)//次大
			Max22=cnt2[a[i]];
	}
	if(f1==f2)
		printf("%d\n",min(n-Max11-Max2,n-Max1-Max22));
	else
		printf("%d\n",n-Max1-Max2);
    return 0;
}



Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ll A[n + 1];
	for(int i = 0; i < n; i++) cin >> A[i];
	bool flag = true;
	vector<ll> v, w;
	for(int i = n - 1; i >= 0; i--)
	{
		if(flag)
		{
			v.push_back(A[i]);
			flag = false;
		}
		else
		{
			w.push_back(A[i]);
			flag = true;
		}
	}
	reverse(w.begin(), w.end());
	v.push_back(-1);
	w.push_back(-1);
	for(int i = 0; v[i] != -1; i++)
		cout << v[i] << " ";
	for(int i = 0; w[i] != -1; i++)
	{
		if(i == 0) cout << w[i];
		else cout << " " << w[i];
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 5484
from bisect import*
s=input()
t=input()
if set(t)<=set(s):
    d={}
    for k,j in enumerate(s*2):
        if j in d:
            d[j].append(k)
        else:
            d[j]=[k]
    now=-1
    ans=0
    for i in t:
        nex=d[i][bisect_right(d[i],now)]
        ans+=nex-now
        if nex>=len(s):
            now=nex-len(s)
        else:
            now=nex
    print(ans)

else:
    print(-1)


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

static const double pi = 3.1415926535897932;

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

    double A, B, H, M;
    cin >> A >>  B >> H >> M;

    double theta1 = (M/60) * 2 * pi;
    double theta2 = (60*H+M)/(60*12) * 2 * pi;
    double theta = abs(theta1 - theta2);
    double kaku = min(theta, 2*pi - theta);

    double res = sqrt(A * A + B * B - 2 * A * B * cos(kaku));
    printf("%.10f\n", res); 

    return 0;
}

Measured memory_bytes: 4268
a,b,c=map(int,input().split())
if a==b==c:
    print(-int(not a%2))
else:
    cnt=0
    while not (a%2 or b%2 or c%2):
        cnt+=1
        a,b,c=(b+c)//2,(c+a)//2,(a+b)//2
    print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
 
using namespace std;
#define LOCAL  1
#define UPLOAD 2
#define ll long long
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
 
int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
 
  string S = input<string>(); 
  string T = input<string>(); 
  int A = input(); 
  int B = input(); 
  string U = input<string>(); 
 if(S == U){
   cout << A-1 << " " << B << endl;
 }
 else{
   cout << A << " " << B-1 << endl;
 }
 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

void exchange(int a, int b) {
  int left = (a < b) ? a : b;
  int right = (a < b) ? b : a;
  std::cout << left << " " << right << std::endl;
}

int main() {
  int left, right;
  int *swap;
  while (std::cin >> left >> right) {
    if (left == 0 && right == 0) break;
    else {
      exchange(left, right);
    }  
  }
  return 0; 
}      

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

const int N = 1e5 + 7;

int a[N];

int main()
{
	ios :: sync_with_stdio(false);
	int n;
	while (cin >> n)
	{
		for (int i = 1; i <= n; i++)
			cin >> a[i];
		int ans = 0;
		for (int i = 1; i < n; i++)
			if (a[i] == i)
			{
				swap(a[i], a[i + 1]);
				ans ++;
			}
		if (a[n] == n)
			ans ++;
		cout << ans << endl;
	}
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
 
int main() {
	int a, b; cin >> a >> b;
	double t; cin >> t;
 
	int bis = 0;
	for (int i = a; i < (t + 0.5); i += a) {
		if (i > t) break;
		bis += b;
	}
 
	cout << bis << endl;
 
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		String S = sc.next();
		int numS = S.length();
		if(numS <= K) {
			System.out.print(S);
		} else {
			System.out.print(S.substring(0, K) + "...");
		}
	}
}

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

int main() {
  int K, X; cin >> K >> X;
  for(int i = X - K+1; i < X + K; ++i) {
    std::cout << i;
    std::cout << ((i == X+K-1) ? "\n" : " ");
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

ans = 0
L = {}
R = {}
for i in range(n):
    if i+a[i] in L:
        L[i+a[i]].append(i)
    else:
        L[i+a[i]] = [i]
    if i-a[i] in R:
        R[i-a[i]].append(i)
    else:
        R[i-a[i]] = [i]
for i in range(n):
    if i in L and i in R:
        ans += len(L[i])*len(R[i])
print(ans)


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

typedef pair<int,int>pint;
typedef vector<int>vint;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

struct seg_tree{
    int N;
    vector<vint>dat;
    void init(vint &vec){
        N=1;
        while(N<vec.size())N*=2;
        dat.resize(N*2-1);
        rep(i,vec.size())dat[i+N-1].pb(vec[i]);
        for(int i=N-2;i>=0;i--){
            dat[i].resize(dat[i*2+1].size()+dat[i*2+2].size());
            merge(dat[i*2+1].begin(),dat[i*2+1].end(),
                  dat[i*2+2].begin(),dat[i*2+2].end(),dat[i].begin());
        }
    }
    int get(int a,int b,int x){return get(a,b,x,0,0,N);}
    int get_all(int x){return get(0,N,x,0,0,N);}
    int get(int a,int b,int x,int k,int l,int r){
        if(r<=a||b<=l)return 0;
        if(a<=l&&r<=b)return upper_bound(dat[k].begin(),dat[k].end(),x)-dat[k].begin();
        return get(a,b,x,k*2+1,l,(l+r)/2)+get(a,b,x,k*2+2,(l+r)/2,r);
    }
};

int N,Q,A[100000];
vint G[100000];

int par[100000],depth[100000],heavy[100000];
int chain[100000],head[100000];
vector<vint>vals;
vector<seg_tree>segs;

int hl_dfs(int v,int p,int d){
    par[v]=p;
    depth[v]=d;
    heavy[v]=-1;

    int ma=0,sum=0;
    rep(i,G[v].size()){
        int to=G[v][i];
        if(to==p)continue;
        int val=hl_dfs(to,v,d+1);
        if(ma<val){
            ma=val;
            heavy[v]=to;
        }
        sum+=val;
    }
    return sum+1;
}

void hl_init(){
    hl_dfs(0,-1,0);
    rep(i,N){
        if(par[i]<0||heavy[par[i]]!=i){
            vals.pb(vint());
            segs.pb(seg_tree());
            for(int j=i;j>=0;j=heavy[j]){
                vals.back().pb(A[j]);
                head[j]=i;
                chain[j]=vals.size()-1;
            }
            segs.back().init(vals.back());
        }
    }
}

int lca(int u,int v){
    while(chain[u]!=chain[v]){
        if(depth[head[u]]<depth[head[v]])swap(u,v);
        u=par[head[u]];
    }
    return depth[u]<depth[v]?u:v;
}

int get(int v,int x){
    int ret=0;
    while(v>=0){
        ret+=segs[chain[v]].get(0,depth[v]-depth[head[v]]+1,x);
        v=par[head[v]];
    }
    return ret;
}

void solve(){
    int a,b,k;
    scanf("%d%d%d",&a,&b,&k);
    a--;b--;
    int p=lca(a,b);

    int lb=-1,ub=N-1;
    while(ub-lb>1){
        int md=(lb+ub)/2;
        int tmp=get(a,A[md])+get(b,A[md])-get(p,A[md])-(par[p]>=0?get(par[p],A[md]):0);
        if(tmp<k)lb=md;
        else ub=md;
    }
    printf("%d\n",A[ub]);
}

int main(){
    scanf("%d%d",&N,&Q);
    rep(i,N)scanf("%d",&A[i]);
    rep(i,N-1){
        int a,b;
        scanf("%d%d",&a,&b);
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    hl_init();

    sort(A,A+N);
    while(Q--)solve();
    return 0;
}

Measured memory_bytes: 48800
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

template<typename T> 
void print(vector<T> &x) {
    int n = x.size();
    REP(i,n) {
        if (i != n-1) cout << x[i] << " ";
        else cout << x[i] << endl;
    }
}

void accu_sum(vector<ll> &D, vector<ll> &S, int n) {
    S[0] = 0;
    for (int i = 0; i < n; ++i) {
        S[i+1] = S[i]+D[i];
    }
    return;
}

int main(int argc, char const *argv[]) {
    int n, k;
    cin >> n >> k;
    vector<ll> t(n), d(n), MAX_D(n,0), rest;
    REP(i,n) {
        cin >> t[i] >> d[i];
        --t[i];
        if (MAX_D[t[i]] < d[i]) {
            rest.push_back(MAX_D[t[i]]);
            MAX_D[t[i]] = d[i];
        }
        else {
            rest.push_back(d[i]);
        }
    }
    int m = rest.size();
    sort(MAX_D.begin(), MAX_D.end(), greater<>());
    sort(rest.begin(), rest.end(), greater<>());
    ll T;
    REP(i,n) {
        if (MAX_D[i] == 0) {
            T = i;
            break;
        }
    }
    /*
    printf("MAX_D = ");
    print(MAX_D);
    printf("rest = ");
    print(rest);
    */

    vector<ll> S_MAX_D(n+1);
    vector<ll> S_rest(m+1);
    accu_sum(MAX_D, S_MAX_D, n);
    accu_sum(rest, S_rest, m);
    ll ans = -1;

    for (ll i = 1; i <= n; ++i) {
        if (i > k) break;
        ll tmp = 0;
        tmp += S_MAX_D[i];
        tmp += S_rest[k-i];
        // printf("i = %lld, tmp = %lld\n", i, tmp);
        ll x = min(i, T);
        tmp += (x*x);
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5108
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int arr[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int cnt=0;
    int n,m,c;
    cin>>n>>m>>c;
    for(int i=0; i<m; i++)
        cin>>arr[i];
    while(n--)
    {
        ll sum=c;
        for(int i=0; i<m; i++)
        {
            int a;
            cin>>a;
            a*=arr[i];
            sum+=a;
        }
        if(sum>0)
            cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 3652
N=int(input())
A,B=list(map(int,input().split()))
P=list(map(int,input().split()))
listA=[]
listB=[]
listC=[]
for i in range(N):
    if P[i] <=A:
        listA.append(P[i])
    elif P[i]<=B:
        listB.append(P[i])
    else:
        listC.append(P[i])
print(min(len(listA),len(listB),len(listC)))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
typedef pair<ll,ll> P;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;cin>>n;
  map<int,int> mp;
  int k=0;
  rep(i,n){
      int j;cin>>j;
      if(mp.find(j)!=mp.end())k++;
      else mp[j]=1;
  }
  if(k%2!=0)k++;
  cout<<n-k<<endl;
  return 0;
  }


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

int main(){
  int B[9],N;
  for(int i=0;i<9;i++){
    cin >> B[i];
  }
  cin >> N;
  int C[N];
  for(int j=0;j<N;j++){
    cin >> C[j];
    for(int i=0;i<9;i++){
      if(C[j]==B[i]){
        B[i]=0;
      }
    }
  }
  if(B[0]+B[1]+B[2]==0|B[3]+B[4]+B[5]==0|B[6]+B[7]+B[8]==0|B[0]+B[3]+B[6]==0|B[1]+B[4]+B[7]==0|B[2]+B[5]+B[8]==0|B[0]+B[4]+B[8]==0|B[2]+B[4]+B[6]==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
num = int(input())
numbers = str(input())

numbers = numbers.split(' ')
numbers = [int(n) for n in numbers]

cnt = 0
for i in range(1, num - 1):
    li = sorted([numbers[i - 1], numbers[i], numbers[i + 1]])
    if 1 == li.index(numbers[i]):
        cnt += 1

print(cnt)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define N 100
#define M 26
using namespace std;
string s;
int p,len;
  
string bnf(){
  string res;
  int c=0;
  while(p!=len){
    char t=s[p];
    if(t=='+')p++,c++;
    if(t=='-')p++,c--;
    if('A'<=t&&t<='Z')
      res+=((s[p++]+c+M*N)-'A')%M+'A',c=0;
    if(t=='?')res+=s[p++],c=0;
    if(t=='[')p++,res+=bnf();
    if(t==']'){
      p++;
      reverse(res.begin(),res.end());
      break;
    }
  }  
  return res;
}
  
int main(){
  while(1){
    cin>>s;
    if(s==".")break;
    len=s.size();
    p=0;
    string ans=bnf();
    for(int i=0;i<(int)ans.size();i++)
      if(ans[i]=='?')ans[i]='A';
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1196