akhauriyash/Code-Regression huggingface dataset:
using System;

namespace abc059_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            string a = input[0].Substring(0, 1);
            string b = input[1].Substring(0, 1);
            string c = input[2].Substring(0, 1);
            string big = a + b + c;
            Console.WriteLine(big.ToUpper());
            Console.Read();
        }
    }
}


Measured memory_bytes: 13140
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n").map(Number);
Arr.forEach(function(v){
var t=v/9.8;
var y=4.9*t*t;
var n=Math.ceil((y+5)/5);
console.log(n);
});

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

long long modexp(int x, long long e, int m) {
    long long ans = 1, p = x % m;
    while (e > 0) {
        if (e % 2 != 0) ans = (ans * p) % m;
        p = (p * p) % m;
        e >>= 1;
    }
    return ans;
}

class Hash {
    constexpr static int N = 6;
    const int base = 987654321;
    const int primes[N] = {
        1000000007, 1000000009, 1000000021,
        1000000033, 1000000087, 1000000093,
    };
public:
    class Value {
        friend Hash;
        long long val[N];
    public:
        bool operator==(Value &other) {
            for (int i = 0; i < N; i++)
                if (val[i] != other.val[i]) return false;
            return true;
        }
    };
    vector<long long> hash_values[N];
    vector<long long> inverse_pow[N];
    Hash(string &s) {
        const int n = s.size();
        for (int j = 0; j < N; j++) {
            const int p = primes[j];
            hash_values[j].resize(n+1, 0);
            for (int i = 0, pw = 1; i < n; i++) {
                hash_values[j][i+1] = (hash_values[j][i] + s[i] * (long long)pw) % p;
                pw = (long long)pw * base % p;
            }
            inverse_pow[j].resize(n+1, 1);
            inverse_pow[j][n] = modexp(base, p - 1 - n, p);
            for (int i = n-1; i >= 0; i--)
                inverse_pow[j][i] = inverse_pow[j][i+1] * base % p;
        }
    }
    Value get(int l, int r) {
        Value ret;
        for (int i = 0; i < N; i++) {
            const int p = primes[i];
            const long long diff = (hash_values[i][r] - hash_values[i][l]);
            ret.val[i] = diff * inverse_pow[i][l] % p;
            if (ret.val[i] < 0) ret.val[i] += p;
        }
        return ret;
    }
};

int main() {
    string w; cin >> w;
    const int n = w.size();
    Hash h(w);
    vector<bool> p(n+1, false), s(n+1, false);
    vector<bool> skip(n+1, false);
    for (int i = 1; i <= n/2; i++) {
        if (skip[i]) continue;
        Hash::Value v = h.get(0, i);
        for (int j = i; j + i <= n; j += i) {
            if (h.get(j, j + i) == v) {
                p[j + i] = true;
                skip[j + i] = true;
            }
            else break;
        }
    }
    fill(skip.begin(), skip.end(), false);
    for (int i = 1; i <= n/2; i++) {
        if (skip[i]) continue;
        Hash::Value v = h.get(n - i, n);
        for (int j = n - i; j - i >= 0; j -= i) {
            if (h.get(j - i, j) == v) {
                s[j - i] = true;
                skip[n - (j - i)] = true;
            }
            else break;
        }
    }

    if (!p[n]) cout << "1\n1\n";
    else {
        int ans = n - 1;
        for (int i = 1; i < n; i++)
            if (p[i] || s[i]) ans--;
        if (ans > 0) cout << "2\n" << ans << endl;
        else cout << n << "\n1\n";
    }
}


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

int n; //登録者数
int w[30]; //各登録者の戦闘力

int dfs(int A, int B, int m){//AはグループAの総力、BはグループBの総力、mは登録者の順番
    int a, b;
    if(m >= n) return abs(A - B); 
    a = dfs(A + w[m], B, m + 1);
    b = dfs(A, B + w[m], m + 1); 
    return min(a, b);
}

int main(void){
    while(true){
        cin >> n;
        if(n == 0) break;
        rep(i, n) cin >> w[i];

        cout << dfs(0, 0, 0) << endl;
    }
}



Measured memory_bytes: 2992
#include<iostream>
#include<algorithm>
using namespace std;
long long n,k,r,a[100010],sum,cnt;

bool D(int i,int j){
	long long h=a[j]-a[i]-k;
	h=-h;
	if(h%n>0)return false;
	cnt+=h/n;
	return true;
}

int main(){
	cin>>n;sum=0;
	bool n2judge=true;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
		r+=i+1;
	}
	k=sum/r,cnt=0;
	
	for(int i=0;i<n;i++){
		if(k>a[i])n2judge=false;
	}
	if(!n2judge){
		cout<<"NO"<<endl;
		return 0;
	}
	
	bool ok=true;
	for(int i=0;i<n-1;i++){
		if(!D(i,i+1)){
			ok=false;
			break;
		}
	}
	if(!D(n-1,0))ok=false;
	
	if(cnt!=k)ok=false;
	if(sum%r>0)ok=false;
	
	if(ok)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		
		InputStreamReader in = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(in);
		
		String line = br.readLine();
		
		if((line.lastIndexOf("A") != -1)
				&& (line.lastIndexOf("B") != -1)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
	}

}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
void read (int &x) {
    char ch = getchar(); x = 0;
    while (!isdigit(ch)) ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
} const int N = 1e5 + 5, m = 1e5;
int n; pair<int, int> pa[N], pb[N];
#define x first
#define y second
signed main() {
    read (n); int mx = 0;
    for (int i = 1, a; i <= n; ++i)
        read (a), (i & 1) ? (++pa[a].x) : (++pb[a].x);
    for (int i = 1; i <= m; ++i) pa[i].y = pb[i].y = i;
    sort (pa + 1, pa + m + 1);
    sort (pb + 1, pb + m + 1);
    if (pa[m].y != pb[m].y) mx = pa[m].x + pb[m].x;
    else mx = max (pa[m].x + pb[m - 1].x, pa[m - 1].x + pb[m].x);
    return printf ("%d\n", n - mx), 0;
}


Measured memory_bytes: 5292
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

int main(){
	int n;cin>>n;
	
	ll a[n];
	ll sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=(a[i]-1);
	}
	
	cout<<sum<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 998244353
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 3010
long long dp[N];
long long dp2[N];
long long ddp[N];

int main() {
	long long a, b, c, d, x, y, z;
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
	f(i, a)dp[i] = 0;
	dp[a] = 1;
	f(i, c - a)dp[a + i + 1] = (dp[a + i] * b) % MOD;
	f(ii, d - b) {
		dp2[a] = (dp[a] * a) % MOD;
		ddp[a] = dp2[a];
		f(i, c - a) {
			x = (dp[a + i+1] * (a + i+1)) % MOD;
			ddp[a + i + 1] = x;
			x = (dp[a + i + 1] * (a + i + 1)) % MOD;
			y = (dp2[a + i] * (b + ii + 1)) % MOD;
			z = (ddp[a + i] * (b + ii)) % MOD;
			dp2[a + i + 1] = (x + y + MOD - z) % MOD;
		}
		f(i, c - a + 1) {
			dp[a + i] = dp2[a + i];
		}
	}
	printf("%lld\n", dp[c]);
	return 0;
}


Measured memory_bytes: 1744
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vb vector< bool >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sort(a) sort(a.begin(),a.end())
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define moddd (1000*1000*1000+9)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
//cout<<fixed<<setprecision(15)<<ans;
 
template <typename T>
void printvec(vector<T>& vec){
	for(int i=0;i<vec.size();i++){
		cout<<vec[i]<<" ";
	}
	cout<<endl;
}

int main(){
	std::ios::sync_with_stdio(false); 
	int ttt=1;
	//cin>>ttt;
	while(ttt--){
		ll a,b,c,k,i;
		cin>>a>>b>>c>>k;
		if(k%2==1) cout<<b-a;
		else cout<<a-b;
	}
	return 0;
} 
 


Measured memory_bytes: 256
let lower_bound arr p =
  let rec f l r =
    if l >= r then r
    else
      let m = (l+r) / 2 in
      if p arr.(m) then f l m else f (m+1) r in
  f 0 (Array.length arr)

let () =
  let n = Scanf.scanf "%d" (fun n -> n) in
  let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
  let b = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
  let am = Array.make n 0 in
  let bm = Array.make n 0 in
  let rec nxt v i =
    if i >= n then nxt v (n-1) else if bm.(i) >= v then (if i = 0 then 0 else nxt v (i-1)) else i+1 in
  Array.init 29 (fun i ->
    let m, mm = 1 lsl i, (2 lsl i) - 1 in
    a |> Array.iteri (fun i e -> am.(i) <- e land mm);
    b |> Array.iteri (fun i e -> bm.(i) <- e land mm);
    Array.fast_sort (-) am;
    Array.fast_sort (-) bm;
    am |> Array.fold_left (fun (acc, (l0, r0, l1, r1)) x ->
      let l0' = nxt (1 * m - x) l0 in
      let r0' = nxt (2 * m - x) r0 in
      let l1' = nxt (3 * m - x) l1 in
      let r1' = nxt (4 * m - x) r1 in
      (acc + r0'-l0' + r1'-l1', (l0', r0', l1', r1'))) (0, (n, n, n, n))
    |> fst |> (fun s -> (s land 1) lsl i))
  |> Array.fold_left (+) 0 |> Printf.printf "%d\n"

Measured memory_bytes: 18688
#include<iostream>
#include<cstdio>
#include<string>
#define FOR(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
	int h,w;
	string s[100];
	cin>>h>>w;
	FOR(i,h){
		cin>>s[i];
	}
	FOR(i,w+2){
		cout<<"#";
	}
	cout<<endl;
	FOR(i,h){
		cout<<"#";
		cout<<s[i];
		cout<<"#";
		cout<<endl;
	}
	FOR(i,w+2){
		cout<<"#";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
# define _CRT_SECUREj_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) (x).begin(),(x).end()
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl;
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }

int main()
{
	string a;
	int FF = 16 * 16 - 1;
	int f[][3] = { { FF,FF,FF },{ FF,FF,0 },{ FF,0,FF },{ FF,0,0 },{ 0,FF,FF },{ 0,FF,0 },{ 0,0,FF },{ 0,0,0 } };
	string ans[] = { "white","yellow","fuchsia","red","aqua","lime","blue","black" };
	while (cin >> a&&a != "0")
	{
		int g[3];
		FOR(i, 3)g[i] = strtol(a.substr(i * 2 + 1,2).c_str(),NULL,16);
		int d = INT_MAX, id = 0;
		FOR(i, 8)
		{
			double D = 0;
			FOR(j, 3)
			{
				D += pow(f[i][j] - g[j], 2);
			}
			if (D <= d)
			{
				d = D;
				id = i;
			}
		}
		cout << ans[id] << endl;

	}
}

Measured memory_bytes: 3132
import java.util.*;
public class Main{
	public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int t = sc.nextInt();
      int sum = (int)((t+0.5)/a)*b;
      System.out.println(sum);
        sc.close();
    }
}


Measured memory_bytes: 21844
#include<stdio.h>

int main(void){
	int a = 100000;
	int x, y, i;
	scanf("%d", &x);
	for (i = 0; i < x; i++){
		a = a*1.05;
		if (a % 1000 != 0){
			a = a / 1000;
			a = (a + 1) * 1000;
		}
	}
	printf("%d\n", a);
	return 0;
}

Measured memory_bytes: 592
N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]

def dfs(cur, a, b, c):
	if cur == N:
		return abs(a - A) + abs(b- B) + abs(c - C) - 30 if min(a, b, c) > 0 else float("inf")

	ret0 = dfs(cur + 1, a, b, c)
	ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
	ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
	ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10

	return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 9148
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Fri Jan 11 02:29:10 2019
//
package main

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

var sc = bufio.NewScanner(os.Stdin)

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()

	arr := make([]int, n)
	for i := range arr {
		arr[i] = nextInt()
	}

	b := make([]int, 2*n)

	lindex := len(arr)
	rindex := len(arr) - 1
	for i := range arr {
		if i%2 == 0 {
			b[lindex] = arr[i]
			lindex++
		} else {
			b[rindex] = arr[i]
			rindex--
		}
	}
	if n%2 == 0 {
		for i := rindex + 1; i < lindex; i++ {
			if i != rindex+1 {
				fmt.Print(" ")
			}
			fmt.Print(b[i])
		}

	} else {
		for i := lindex - 1; i > rindex; i-- {
			if i != lindex-1 {
				fmt.Print(" ")
			}
			fmt.Print(b[i])
		}
	}
	fmt.Println()
}


Measured memory_bytes: 10496
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;// ;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<LL>>g;
vector<edge>ed;
vector<Pll>pv;
map<string, LL>ma;
set<LL>st;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m, k, p, q, w, h, ans, cnt, sum[5000][5000], a[210000], b[210000]; 
string str;
bool f;
char c[1100][1100];
int main() {
	cin >> str;
	w = (str[0] - '0') * 10 + (str[1] - '0');
	h = (str[2] - '0') * 10 + (str[3] - '0');
	if (w <= 12 && h <= 12 && w > 0 && h > 0) {
		cout << "AMBIGUOUS" << endl;
	}
	else if ((w > 12 || w == 0) && h <= 12 && h > 0) {
		cout << "YYMM" << endl;
	}
	else if (w <= 12 && w > 0 && (h > 12 || h == 0)) {
		cout << "MMYY" << endl;
	}
	else {
		cout << "NA" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define SORTR(v,n) sort(v, v+n, greater<int>());
#define SORTPairSecond(v, n) sort(v, v+n, pairCompareSecond);
#define int long long    // %d=>%lld, 1<<n  => 1LL<<n
#define pb push_back
#define EPS 1e-9

using namespace std;
typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;
bool pairCompareSecond(const pii& firstEl, const pii& secondEl) {
    return firstEl.second > secondEl.second;
}

const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);


const int MAX_n = 200000;
int n,a[MAX_n];

signed main(){


    int sumN=0;

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


    int sumS=0;

    int ans1=LLINF;

    for(int i = 0;i < n-1;i++){
        sumS+=a[i];
        ans1=min(ans1,abs(sumN-2*sumS));
    }

    cout<< ans1<< endl;


    return 0;
}

Measured memory_bytes: 1792
(function() {
    'use strict';

    var lines = [];
    require('readline').createInterface({
      input: process.stdin,
      output: process.stdout
    }).on('line', function(line) {
      lines.push(line);
    });
    process.stdin.on('end', function() {
      //lines.forEach(function(line) {
        //var tokens = line.split(' ').map(Number);
        //    console.log(tokens[0] + ' ' + tokens[1]);
      //}
      //)
      ;

    // ToDo start
      var inLines = lines[0].split(" ")
      var X = parseInt(inLines[0]);
      var Y = parseInt(inLines[1]);
      var Z = parseInt(inLines[2]);

      console.log(Math.floor( (X - Z ) / (Y + Z ) ) )
      
//      console.log( Math.pow(parseInt(lines[0]),2) - parseInt(lines[1])  )
    // ToDo end

    });


})();



Measured memory_bytes: 21448
#include <stdio.h>
int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(b/a>=c){
        printf("%d\n",c);
    }
    if(b/a<c){
        printf("%d\n",b/a);
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int k;
 cin>>k;
 if(k==1){
   cout<<"ACL"<<endl;
 } else if(k==2){
   cout<<"ACLACL"<<endl;
 } else if(k==3){
   cout<<"ACLACLACL"<<endl;
 }
 else if(k==4){
  cout<<"ACLACLACLACL"<<endl;
 } else {
   cout<<"ACLACLACLACLACL"<<endl;
 }
}
   
   

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
int memo[110000];
int dfs(int n){
    if(n == 0) return 0;
    if(memo[n] != -1) return memo[n];
    int ans = n;
    for (int i6 = 1; i6 <= n; i6*=6) {
        ans = min(ans,dfs(n-i6)+1);
    }
    for (int i9 = 1; i9 <= n; i9*=9) {
        ans = min(ans,dfs(n-i9)+1);
    }
    return memo[n] = ans;
}
int main() {
    int n;
    cin >> n;
    for (int i = 0; i < 110000; ++i) {
        memo[i] = -1;
    }
    cout << dfs(n) << endl;
    return 0;
}

Measured memory_bytes: 3840
#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()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
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; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N,M;cin >> N >> M;
    map<int,int> m;
    rep(i,M){
        int a,b;cin >> a >> b;
        m[a]++;
        m[b]++;
    }

    bool ok = true;
    for(auto t : m){
        if(t.S % 2 != 0)ok = false;
    }
    
    if(ok)cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int n,tg;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    while (n != 0)
    {
        cin >> tg;
        if (tg%2 == 0)
            if (tg%3 == 0 || tg%5 == 0)
            {
                n--;
                continue;
            }
            else 
            {
                cout << "DENIED";
                return 0;
            }
        n--;
    }
    cout << "APPROVED";
}

Measured memory_bytes: 256
import itertools
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
l = [IL() for i in range(N)]

t,x,y = 0,0,0
for i in range(N):
	ti,xi,yi = l[i]
	if 0 <= ti-t\
		and (ti-t -abs(xi-x)-abs(yi-y)) >= 0\
		and (ti-t -abs(xi-x)-abs(yi-y)) %2 == 0:
		t,x,y = ti,xi,yi
	else:
		print("No")
		exit()
print("Yes")

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

public class Main {

    static int N;
    static int K;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        K = sc.nextInt();

        System.out.println(solve());
    }

    static long solve() {
        int[] knt = new int[K];
        for (int i = 1; i <= N ; i++) {
            knt[i % K]++;
        }

        long ret = 0;
        for (int a = 0; a < K; a++) {
            if( a * 2 % K == 0 ) {
                ret += (long)knt[a] * knt[a] * knt[a];
            }
        }
        return ret;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

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

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

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())



void solve(){
    ll X;
    cin >> X;

    int idx=0;
    while(X > 0){
        idx++;
        X -= idx;
    }

    cout << idx << endl;
    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


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

int main(){
 int a=0;
 int b=0;
 cin>>a>>b;
 if((a+b)%3==0){
 	cout<<"Possible";
 }else if(a%3==0){
 	cout<<"Possible";
 }else if(b%3==0){
 	cout<<"Possible";
 }else{
 	cout<<"Impossible";
 }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n, m; cin >> n >> m;
	int a[50], b[50], c[50], d[50];
	rep(i, n) {
		cin >> a[i] >> b[i];
	}
	rep(i, m) {
		cin >> c[i] >> d[i];
	}
	rep(i, n) {
		int mi = 2 * (int)MOD; int out = 0;
		rep(j, m) {
			int dis = abs(c[j] - a[i]) + abs(d[j] - b[i]);
			if (dis < mi) {
				mi = dis; out = j + 1;
			}
		}
		cout << out << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll dp[100005];
ll ar[100005];
int n;
ll f(ll ind){
	if(ind==n) return 0;
	if(dp[ind]>=0) return dp[ind];
	ll a = f(ind+1)+abs(ar[ind]-ar[ind+1]);
	ll b = 100000000000;
	if(ind!=n-1){
		b = f(ind+2)+abs(ar[ind]-ar[ind+2]);
	}
	return dp[ind]=min(a,b);
}

int main(){
	cin>>n;
	fill(dp,dp+n,-1);
	for(int i=1;i<=n;i++){
		cin>>ar[i];
	}
	cout<<f(1);
}


Measured memory_bytes: 4992
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()

 
using namespace std;
 
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
 
const int INF=1<<29;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int n,a,x[60],aaa;
long long int res = 0ll;
long long int sumr[2500] = {},suml[2500] = {};

void dfs(int side,int r,int l,int sum){
	if(sum > aaa) return;
	if(r == l) {
	if(side == 0){
		sumr[sum]++;
	}else suml[sum]++;
		return;
	}
	 if(side == 0){
	 	dfs(0,r+1,l,sum);
		dfs(0,r+1,l,sum - x[r] + a);
	 }else{
	 	dfs(1,r+1,l,sum);
		dfs(1,r+1,l,sum + x[r] - a);
	 }
	 return;
}

int main(){
	cin >> n >> a;
	for(int i = 0;i < n;i++) cin >> x[i];
	int r = 0,l = 0,ra = 0,la = 0,multi = 0;
	sort(x,x + n);
	for(int i = 0;i < n;i++){
		if(x[i] < a) r++;
		else if(x[i] == a) multi++;
		else l++;
	}
	for(int i = 0;i < r;i++) ra += a - x[i];
	for(int i = r + multi;i < n;i++) la += x[i] - a;
	aaa = min(ra,la);
	dfs(0,0,r,0);
	dfs(1,r + multi,n,0);
	for(int i = 0;i <= ra;i++){
		res += sumr[i] * suml[i];
	}
	for(int i = 0;i < multi;i++) res *= 2;
	cout << res -1 << endl;
	return 0;
}

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

int h, m;
char s[110];

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

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)


using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

const ll MOD = INF + 7;

ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n & 1)ans = ans * x % MOD;
        x = x * x % MOD;
        n = n >> 1;
    }
    return ans;
}

int main(){
    ll n;
    cin >> n;
    ll m = n - 1;
    map<ll, ll> mp;
    for(ll i = 2; i * i <= m; i++){
        while(m % i == 0){
            mp[i]++;
            m /= i;
        }
    }
    if(m != 1)mp[m]++;
    m = n - 1;
    map<ll, ll> seen;
    for(ll i = 1; i * i <= m; i++){
        if(m % i == 0){
            seen[i] = 1;
        }
    }

    ll res = 1;
    for(auto m : mp){
        res *= (1 + m.second);
    }


    for(ll i = 2; i * i <= n; i++){
        if(seen[i] == 1)continue;
        ll cop = n;
        while(cop % i == 0){
            cop /= i;
        }
        if(cop == 1)res++;
        else if((cop - 1) % i == 0)res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 65664
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>

using namespace std;

void b_bingo(void) {
	int a[3][3];
	int n;
	for (int j = 0; j < 3; j++) {
		for (int i = 0; i < 3; i++) {
			cin >> a[j][i];
		}
	}
	cin >> n;
	vector<int>b(n);
	for (int i = 0; i < n; i++)cin >> b[i];

	for (int j = 0; j < 3; j++) {
		for (int i = 0; i < 3; i++) {
			for (int k = 0; k < n; k++) {
				if (b[k] == a[j][i]) {
					a[j][i] = 0;
				}
			}
		}
	}

	// yoko
	int cnt = 0;
	for (int j = 0; j < 3; j++) {
		cnt = 0;
		for (int i = 0; i < 3; i++) {
			if (a[j][i] == 0) cnt++;
		}
		if (cnt == 3) {
			cout << "Yes" << endl;
			return;
		}
	}
	// tate
	for (int i = 0; i < 3; i++) {
		cnt = 0;
		for (int j = 0; j < 3; j++) {
			if (a[j][i] == 0) cnt++;
		}
		if (cnt == 3) {
			cout << "Yes" << endl;
			return;
		}
	}
	// naname
	if ((a[0][0] == 0) && (a[1][1] == 0) && (a[2][2] == 0)) {
		cout << "Yes" << endl;
		return;
	}
	else if ((a[0][2] == 0) && (a[1][1] == 0) && (a[2][0] == 0)) {
		cout << "Yes" << endl;
		return;
	}

	cout << "No" << endl;

}

int main()
{
    b_bingo();

    return 0;
}

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


int main() {
  double a, b, x, theta;
  cin >> a >> b >> x;

  if (x > a * a * b / 2) {
    theta = atan(2 * (a * a * b - x) / (a * a * a));
  } else {
    theta = atan((a * b * b) / (2 * x));
  }

  double PI = 3.14159265358979;
  theta = theta * 180 / PI;
  cout << fixed << setprecision(10) << theta;
  cout << endl;
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N+1);
    for (int i = 1; i <= N; i++) cin >> A[i];
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (A[A[i]] == i) ans++;
    }
    cout << ans/2 << endl;
    return 0;
}


Measured memory_bytes: 640
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*  ________       __      ________  _    __       __       ________               *
* |  ______|     /  \    |  ____  || |  / /      /  \     |  ____  |              *
* | |______     / /\ \   | |____| || |_/ /      / /\ \    | |____| |              *
* |______  |   / /__\ \  |  __  __||  __ \     / /__\ \   |  __  __|              *
*  ______| |  / ______ \ | |  \ \  | |  \ \   / ______ \  | |  \ \                *
* |________| /_/      \_\|_|   \_\ |_|   \_\ /_/      \_\ |_|   \_\               *
*                                                                                 *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________

#include<bits/stdc++.h>
using namespace std;


int main()
{
    int i,len;
	char s[101];

    cin >> s;
    len = strlen(s);

    for(i = 0; i < len; i++)
    {
        cout << "x";
    }

    cout << endl;

	return 0;
}


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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	string s; cin >> s;
	int c = 0;
	for (int i = 0; i < 15; i++) {
		if (s.length() <= i) c++;
		else if (s[i] == 'o') c++;
	}
	if (c >= 8) cout << "YES" << '\n';
	else cout << "NO" << '\n';
	return 0;
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  int idA = -1;
  int idB = 0;
  for(int i = 0; i < s.length(); i++) {
    if(s[i] == 'A' && idA == -1) {
      idA = i;
    }
    if(s[i] == 'Z') {
      idB = i;
    }
  }
  cout << (idB - idA + 1) << endl;

}


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

long read_long() {
	long ret=0;char c=getchar();
	while(c<'0' || c>'9') c=getchar();
	while(c>='0' && c<='9') {
		ret=ret*10+c-'0';
		c=getchar();
	}		return ret;
}

const long MAXN=100010;
long remain[MAXN];
long n,a;
long long ans=1;
const long long mod=1000000007;

int main() {
	remain[0]=3;
	cin>>n;
	for(register long i=1;i<=n;++i) {
		a=read_long();
		if(remain[a]==0) {
			cout<<"0"<<endl;
			return 0;
		}
		ans*=(long long)remain[a];
		ans%=mod;
		--remain[a];
		++remain[a+1];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};

struct edge {
    ll to;
    ll cost;
};

ll V;
const ll MAX_V=500000;
vector<edge> G[MAX_V];
ll d[MAX_V];

void dijkstra(ll s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        ll v = p.second;
        if (d[v] < p.first) continue;

        for (ll i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main(){
  ll n;cin>>n;ll m;cin>>m;
  V=n*3;
  rep(i,m){
    ll u,v;cin>>u>>v;u--;v--;
    G[u].push_back(edge{v+n,1});
    G[u+n].push_back(edge{v+2*n,1});
    G[u+2*n].push_back(edge{v,1});
  }
  ll s,t;cin>>s>>t;
  s--;t--;
  dijkstra(s);
  if(d[t]>=INF)cout<<-1<<endl;
  else cout<<d[t]/3<<endl;
}

Measured memory_bytes: 25216
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
int main(){
	int n,r;
	cin>>n>>r;
	if(n>10)cout<<r;
	else cout<<r+100*(10-n); 
}


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

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 50 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e9 + 7;
const ll infll = 1e18 + 7;



signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int a, b, n; cin >> a >> b >> n;
    cout << (a * min(b - 1, n)) / b;
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

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

int main(){
  int n;
  cin>>n;
  long long int a[n];
  for(int i=0;i<n;i++)
     cin>>a[i];
  long long sum=0;
  for(int i=0;i<n;i++){
    long long h=0;
    for(int j=i+1;j<n;j++){
      h=h+a[j];
    }
    sum+=(h*a[i]);
  }
  cout<<sum;
}


Measured memory_bytes: 256
function Main(s){
  ans = "AC"
  if(s[0] !== "A")ans = "WA";
  var f = 0;
  for(var i = 1; i < s.length; i++){
    if(s[i] === "C"){
      if(i > 1 && s.length - 1 > i)f++;else ans = "WA";
    }else{
      if("a" > s[i]) ans = "WA";
    }
  }
  if(f !== 1)ans = "WA";
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin","utf8").trim());

Measured memory_bytes: 21064
fun main(args:Array<String>) {
	val n = readLine()!!.toInt()
	val a = readLine()!!.split(" ").map{ it.toLong() }
	
	((n-1 downTo 0 step 2)+(n-2 downTo 0 step 2).reversed())
			.map{a[it]}
			.fold(StringBuilder()){sb,it->
				sb.append(it).append(" ")
			}.let {println(it)}
}

Measured memory_bytes: 101380
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define sortall(obj) sort(ALL(obj))
#define revall(obj) reverse(ALL(obj))
#define SortRevAll(obj) revall(sortall(obj))
typedef string str;
typedef long long ll;
const int mod=1e9+7;
const int INF=1e9;
const ll LINF=1e18;
#define VI vector<int>
#define P pair
#define M map
#define F first()
#define S second()
#define PB(a) push_back(a)
#define IN(a) insert(a)
#define ins(a) int a;cin >> a
#define lls(a) ll a;cin >> a
#define in(a) cin >> a
#define sts(a) string (a);cin >> a
#define For(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) For(i,0,n)
#define Forr(i,m,n) for(int i=n-1;i>=m;i--)
#define repr(i,n) Forr(i,0,n)
#define print(a) cout << a << endl
#define Endl cout << endl
#define YES(n) cout << ((n)? "YES" : "NO") << endl
#define Yes(n) cout << ((n)? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE" ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define br(c,y,n) cout << ((c)? y : n) << endl

int main()
{
    ins(ans);
    ans*=ans+1;
    ans/=2;
    print(ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2020000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
//const int mod = 1e9 + 7;
const int mod = 998244353;

int main(){
	int n; cin >> n;
	vl a(n); rep(i,n) cin >> a[i];
	ll mx = *max_element(all(a));
	vl ans;
	if(mx <= 0){
		cout << mx << "\n";
		int id = max_element(all(a)) - a.begin();
		for(int i=n-1; i>=id+1; i--) ans.push_back(i+1);
		rep(i,id) ans.push_back(1);
	}else{
		vl sum(2,0);
		rep(i,n){
			sum[i&1] += max(0LL,a[i]);
		}
		int t = sum[0] < sum[1];
		while((int)a.size() % 2 == t || a.back() < 0){
			ans.push_back((int)a.size());
			a.pop_back();
		}
		int u = 0;
		while(u != t || a[0] < 0){
			a.erase(a.begin());
			ans.push_back(1);
			u = 1-u;
		}
		int m = a.size();
		for(int i=m-3; i>=2; i-=2){
			if(a[i] < 0){
				ans.push_back(i+1);
				a.erase(a.begin()+i+1);
				a.erase(a.begin()+i-1);
			}
		}
		rep(i,(int)a.size()/2) ans.push_back(2);
		cout << max(sum[0], sum[1]) << "\n";
	}
	cout << ans.size() << "\n";
	rep(i,ans.size()) cout << ans[i] << "\n";
}

Measured memory_bytes: 3628
#include<iostream>

using namespace std;

int data[101][101];

int main(){
	int n;
	while(cin>>n && n){
	for(int i=0;i<101;i++)
		for(int j=0;j<101;j++)data[i][j]=0;
		for(int i=1;i<=n;i++){
			int m;
			cin>>m;
			for(int j=0;j<m;j++){
				int p;
				cin>>p;
				data[i][p]=1;
			}
		}
		int k;
		cin>>k;
		for(int i=0;i<k;i++){
			int l;
			cin>>l;
			for(int j=1;j<=n;j++){
				if(data[j][l]==1 && data[j][0]!=2)data[j][0]=1;
				if(data[j][l]==0)data[j][0]=2;
			}
		}
		int ans=0;		
		for(int i=1;i<=n;i++){
			if( data[i][0]==1){
				if(ans==0)ans=i;
			 	else if(ans!=0){
				ans=-1;
				break;
				}
			}

		}
		if(ans==0)ans=-1;
		cout<<ans<<endl;
	}
	
}

Measured memory_bytes: 1200
package main

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

var (
	rdr   = bufio.NewReaderSize(os.Stdin, 1000000)
	reply string
)

func main() {
	in := nextSlice()
	solve(in)
}

func solve(buf []string) {
	var (
		a, _ = strconv.Atoi(buf[0])
		b, _ = strconv.Atoi(buf[1])
		k, _ = strconv.Atoi(buf[2])
	)
	if a >= k {
		reply = fmt.Sprintf("%s %s", strconv.Itoa(a-k), buf[1])
	} else if a+b >= k {
		reply = fmt.Sprintf("0 %s", strconv.Itoa(a+b-k))
	} else {
		reply = "0 0"
	}
	fmt.Println(reply)
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func nextSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func scanSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func scanFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

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

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

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

func yesOrNo(b bool) {
	if b {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func yesorNO(b bool) {
	if b {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

Measured memory_bytes: 640
var
  a:array[0..100010]of int64;
  k,l,r,n,ans:int64;
  i:longint;

function min(x,y:int64):int64;
begin
  if x<y then exit(x);
  exit(y);
end;

function max(x,y:int64):int64;
begin
  if x>y then exit(x);
  exit(y);
end;

begin
  readln(n,k);
  for i:=1 to n do
    read(a[i]);
  ans:=maxlongint;
  for i:=1 to n-k+1 do
  begin
    l:=min(a[i],0);
    r:=max(a[i+k-1],0);
    ans:=min(ans,r-l*2);
    ans:=min(ans,r*2-l);
  end;
  writeln(ans);
end.

Measured memory_bytes: 896