akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC optimize("O3")
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}

template <class T>
ostream& operator << (ostream& out, vector<vector<T>> &v)
{
	for (vector<T> &x : v)
		out << x << '\n';
	return out;
}

template <class T>
ostream& operator << (ostream& out, vector<T> &v)
{
	for (T &x : v)
		out << x << ' ';
	return out;
}

long long gcd (long long a, long long b)
{
	if (b > a)
		swap(a, b);
	return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
#define per(i,b,a) for (int i = b; i > a; i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

void f(int rem, string p, char mx)
{
	if(rem == 0)
	{
		cout << p << '\n';
		return;
	}
	for(char c = 'a'; c <= mx; c++)
		f(rem-1, p + c, mx);
	f(rem-1, p + char(mx + 1), mx+1);
}

signed main()
{
	ios::sync_with_stdio(false);
	#ifdef ONLINE_JUDGE
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.setstate(ios::failbit);
	#endif

	int n;
	cin >> n;
	f(n-1, "a", 'a');
}


Measured memory_bytes: 1536
use proconio::input;
use std::collections::HashSet;
use std::collections::VecDeque;
fn main() {
    input! {
        n:usize,
        m:usize,
    }
    let mut udg = vec![Vec::new(); n];
    for i in 1..=m {
        input! {
         a:usize,
         b:usize,
        }
        udg[a - 1].push(b - 1);
        udg[b - 1].push(a - 1);
    }

    let mut bfs_table: VecDeque<usize> = VecDeque::new();
    bfs_table.push_back(0);
    let mut hists: HashSet<usize> = HashSet::new();
    hists.insert(0);
    let mut answer = vec![0; n];
    while let Some(bfs_target) = bfs_table.pop_front() {
        for i in udg[bfs_target].iter() {
            if !hists.contains(i) {
                bfs_table.push_back(*i);
                answer[*i] = bfs_target;
                hists.insert(*i);
            }
        }
    }
    println!("Yes");
    for i in answer[1..n].iter() {
        println!("{}", i + 1);
    }
}


Measured memory_bytes: 15532
S=input()
if S[0] != 'A' or S[1] <= 'Z' or S[-1] <= 'Z':
  print('WA')
  quit()
n = 0
for i in range(2, len(S)-1):
  if S[i] > 'Z':
    pass
  elif S[i] == 'C':
    n += 1
  else:
    n =2
if n != 1:
  print('WA')
else:
  print('AC')


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

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputNM = Console.ReadLine().Split(' ');
            var n = int.Parse(inputNM[0]);
            var m = int.Parse(inputNM[1]);

            var a = new int[n];
            var b = new int[n];
            for (int i = 0; i < n; i++)
            {
                var inputAB = Console.ReadLine().Split(' ');
                a[i] = int.Parse(inputAB[0]);
                b[i] = int.Parse(inputAB[1]);
            }

            var c = new int[m];
            var d = new int[m];
            for (int i = 0; i < m; i++)
            {
                var inputCD = Console.ReadLine().Split(' ');
                c[i] = int.Parse(inputCD[0]);
                d[i] = int.Parse(inputCD[1]);
            }

            var nearestPoint = new int[n];
            var minDistance = new int[n];
            for (int i = 0; i < n; i++)
            {
                minDistance[i] = int.MaxValue;
            }

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < m; j++)
                {
                    var distance = Math.Abs(a[i] - c[j]) + Math.Abs(b[i] - d[j]);

                    if (distance < minDistance[i])
                    {
                        nearestPoint[i] = j + 1;
                        minDistance[i] = distance;
                    }
                }
            }

            for (int i = 0; i < n; i++)
            {
                Console.WriteLine(nearestPoint[i].ToString());
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
int main()
{
    int a, b;
    cin >> a >> b;
    if (b % a == 0)
    {
        cout << a + b << endl;
    }
    else
    {
        cout << b - a << endl;
    }
}

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


// ABC127A - Ferris Wheel
// https://atcoder.jp/contests/abc127/tasks/abc127_a

void ABC127A() {

	int A, B;
	cin >> A >> B;

	if (A >=13 ) {
		cout << B << endl;
	}
	else if(A >=6 && A<=12){
		cout << B/2 << endl;
	}
	else {
		cout << 0 << endl;
	}
}


int main() {
	ABC127A();

	return 0;
}

Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    A, B = map(int, input().split())
    print(A * B)


if __name__ == "__main__":
    main()


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

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<int>());
    if (s < t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int const NMAX = int(1e5)+1;
int const INF = int(2e9);

int main() {
    int dp[NMAX][3];

    int n;
    cin >> n;
    vector<vector<int>> v(3, vector<int>(n));
    for (int i = 0; i < n; ++i)
        for (int k = 0; k < 3; ++k) cin >> v[k][i];

    fill(&(dp[0][0]), &(dp[0][0])+(NMAX*3), 0);
    for (int i=1; i<=n; ++i) {
        for (int k = 0; k < 3; ++k) {
            int p = (k+1)%3;
            int q = (k+2)%3;
            dp[i][k] = max(dp[i-1][p], dp[i-1][q]) + v[k][i-1];
        }
    }

    int ans = 0;
    for (int k=0; k<3; ++k) ans = max(ans, dp[n][k]);

    cout << ans << endl;
}

Measured memory_bytes: 2556
import sys
input = sys.stdin.readline
from itertools import accumulate
s = input()[:-1]
t = input()[:-1]
d = {"A": 1, "B": 2}
ds = [0] + list(accumulate([d[x] for x in s]))
dt = [0] + list(accumulate([d[x] for x in t]))
ans = []
append=ans.append
for _ in range(int(input())):
	a, b, c, d = map(int, input().split())
	if (ds[b]-ds[a-1])%3==(dt[d]-dt[c-1])%3:
		append("YES")
	else:
		append("NO")
print("\n".join(ans))


Measured memory_bytes: 13012
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;


void solve()
{
	int N, M;
	cin >> N >> M;
	map<int, int> Map;
	for (int i = 0; i < N; ++i)
	{
		int K;
		cin >> K;
		for (int j = 0; j < K; ++j)
		{
			int A;
			cin >> A;
			Map[A]++;
		}
	}
	int ans = 0;
	for (map<int, int>::iterator it = Map.begin(); it != Map.end(); ++it)
	{
		if (it->second == N)
		{
			++ans;
		}
	}
	cout << ans << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define repm(i,a,b) for(ll i=(ll)(a);i>(ll)(b);i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(),(x).rend()
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb =vector<bool>;
using vvb=vector<vb>;
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 (b<a) { a=b; return 1; } return 0; }
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp

int main(){
    ll x;
    cin >> x;
    ll n;
    cin >> n;
    vll p(300,0);
    rep(i,n){
        ll d;
        cin>>d;
        p[d+150]++;
    }
    rep(i,150){
        if(p[x+150-i]==0){
            cout << x-i << endl;
            return 0;
        }
        if(p[x+150+i]==0){
            cout << x+i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3588
import java.util.*;class Main{public static void main(String[]e){Scanner s=new Scanner(System.in);for(double t=s.nextInt(),a,b;t-->0;){double[]d=new double[6];for(int i=6;i-->0;)d[i]=s.nextDouble();a=(a=d[5]-=d[2])*a+(a=d[4]-=d[1])*a;b=d[3]+d[0];System.out.println(b*b<a?0:(b-=2*d[0])*b<=a?1:d[3]>d[0]?2:-2);}}}

Measured memory_bytes: 12000
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
#define LL long long

int n, num2;
int num4;
int a[100005];

int main()
{
    while(~scanf("%d", &n))
    {
        num2 = 0, num4 = 0;
        for(int i = 1; i <= n; ++i)
        {
            scanf("%d", &a[i]);
            if(a[i] % 2 == 0 && a[i] % 4 != 0) num2++;
            if(a[i] % 4 == 0) num4++;
        }
        if(num2 + num4 == n)
        {
            printf("Yes\n");
            continue;
        }
        if(num2 >= 2)
        {
            n -= num2;
            if(n % 2 == 1) n++;
        }
        if(num4 >= n / 2)
        {
            printf("Yes\n");
            continue;
        }
        printf("No\n");
    }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << x << endl;
#define printv(x) for(int i = 0; i < x.size(); i++){ cout << (x[i]) << " "; } cout << endl; 
#define printa(x) for(int i = 0; i < (sizeof(x)/sizeof(x[0])); i++){ cout << (x[i]) << " ";} cout << endl;

typedef long long ll;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    ll x[1001], y[1001], z[1001];
    rep(i,0,N){
        ll t1,t2,t3;
        cin >> t1 >> t2 >> t3;
        x[i] = t1;
        y[i] = t2;
        z[i] = t3;
    }
    ll ans = 0;
    rep(i,0,2){
        rep(j,0,2){
            rep(k,0,2){
                ll sum[1001] = {0};
                rep(m,0,N){
                    ll xt = (i == 1) ? x[m] : x[m] * -1;
                    ll yt = (j == 1) ? y[m] : y[m] * -1;
                    ll zt = (k == 1) ? z[m] : z[m] * -1;
                    sum[m] = xt+yt+zt;
                }
                sort(sum, sum+N);

                ll ans_tmp = 0;
                rep(m,0,M){
                    ans_tmp += sum[N - m - 1];
                }
                ans = max(ans, ans_tmp);
            }
        }
    }
    print(ans);
}


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

int main(){
  int N;
  string S;
  cin >> N >> S;
  string ans="";
  int count=0;
  for(int i=0;i<N;i++){
    if(S.at(i)=='('){
      count++;
      ans.push_back('(');
    }else if(S.at(i)==')'){
      ans.push_back(')');
      if(count==0){
        ans.insert(ans.begin(),'(');
      }else{
        count--;
      }
    }
  }
  while(count>0){
    ans.push_back(')');
    count--;
  }
  cout << ans << endl;
  return 0;
}


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

//再帰関数を用いる方法
int64_t f(vector<int64_t> a) {
  int64_t n,i,ans=0;
  n=a.size();
  vector<int64_t> b(n-1);
  if (n==1) return a.at(0);
  else if (n>=2) {
    for(i=0;i<n-1;i++) b.at(i)=a.at(i+1);
    ans+=a.at(0)*(1<<(n-2))+f(b);
    b.at(0)+=10*a.at(0);
    ans+=f(b);
    return ans;
  }
}
int main() {
  string s;
  int64_t n,i;
  cin>>s;
  n=s.length();
  vector<int64_t> a(n);
  for(i=0;i<n;i++) a.at(i)=s.at(i)-'0';
  cout<<f(a)<<endl;
}

Measured memory_bytes: 256
# import numpy as np

N, M = list(map(int, input().split()))
C = list(map(int, input().split()))
T = [float('inf')] * (N+1)
T[0] = 0

for i in range(M):
    for j in range(C[i], N + 1):
        T[j] = min(T[j], T[j - C[i]] + 1)

print(T[-1])


Measured memory_bytes: 7524
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int X, Y;
    cin >> X >> Y;
    cout << X + (Y / 2) << endl;
    return 0;
}


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

using namespace std;

#define ll long long
int main()
{
    ll n, w;   cin >> n >> w;
    vector <ll> dp(w + 1);
    for (ll i = 0; i < n; i++)
    {
        ll weight, value;  cin >> weight >> value ;
        for (ll k = w - weight ; k >= 0; k--)
            dp[k + weight] = max(dp[k + weight], dp[k] + value);
        
    }
    cout << dp[w] << "\n";
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  string s,t;
  cin>>s>>t;
  ll ans=0;
  for(ll i=0;i<3;i++){
    if(s.at(i)==t.at(i)){ans++;}
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  cin >> n;
  vec a(n);
  for(ll i=0;i<n;i++) cin >> a[i];
  ll max_n=a[0];
  ll max_id=0;
  ll min_n=a[0];
  ll min_id=0;
  for(ll i=1;i<n;i++) {
    if(max_n<a[i]) {
      max_id=i;
      max_n=a[i];
    }
    if(min_n>a[i]) {
      min_id=i;
      min_n=a[i];
    }
  }
  cout << 2*(n-1) << endl;
  if(abs(max_n)>=abs(min_n)) {
    for(ll i=0;i<n;i++) {
      if(i==max_id) continue;
      cout << max_id+1 << " " << i+1 << endl;
    }
    for(ll i=0;i<n-1;i++) {
      cout << i+1 << " " << i+2 << endl;
    }
  }
  else {
    for(ll i=0;i<n;i++) {
      if(i==min_id) continue;
      cout << min_id+1 << " " << i+1 << endl;
    }
    for(ll i=n-2;i>-1;i--) {
      cout << i+2 << " " << i+1 << endl;
    }
  }
}

Measured memory_bytes: 256
import sys
import itertools
import numpy as np
from collections import Counter
import math

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, input().split(' '))
G = [[] for _ in range(N+1)]
ans = [0]*(N+1)
count = 0
for i in range(M):
    A, B = map(int, input().split(' '))
    G[A].append(B)
    G[B].append(A)

s = [1]
for i in range(N):
    ne = []
    for i in s:
        for j in G[i]:
            if ans[j] == 0:
                ans[j] = i
                count += 1
                ne.append(j)
    s = ne
# if 0 in ans[1:]:
#     print('No')
#     exit()
# else:
print('Yes')
for i in ans[2:]:
    print(i)


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;
ll a,b,x;

double v(double theta) {
  if (theta < 0.0000000000001) {
    // 0
    return 0;
  } else if(theta >= M_PI/2) {
    // 4
    return a*a*b;
  } else if (tan(theta) < (double)a/b) {
    // 1
    return b*b*tan(theta)*a/ 2.0;
  } else if (tan(theta) > (double)a/b) {
    // 3
    return (2*b-a/tan(theta))*a*a/2.0;
  } else {
    // 2 
    return a*a*b/2.0;
  }
}

signed main() {
  cin >> a >> b >> x;
  double ok = M_PI/2.0, ng = 0;
  while(ng+0.00000000000001 < ok) {
    double theta = (ok+ng)/2.0;
    if (v(theta) > x) {
      ok = theta;
    } else {
      ng = theta;
    }
  }
  double ans = (90.0 - (ok * 180.0 / M_PI));
  printf("%.10f\n", ans);
}


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

template <int MOD>
struct ModInt {
    using lint = long long;
    using mint = ModInt<MOD>;

    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // assignment
    ModInt& operator=(const ModInt& x) {
        if (this != &x) { this->val = x.val; }
        return *this;
    }

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt operator~() const {
        // non-recursive extended euclidean algorithm
        int s = val, t = MOD;
        mint sx = 1, sy = 0, tx = 0, ty = 1;
        while (s % t != 0) {
            int div = s / t;
            s -= t * div;
            sx -= tx * div;
            sy -= ty * div;

            std::swap(s, t);
            std::swap(sx, tx);
            std::swap(sy, ty);
        }
        return mint(tx);
    }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= ~x; }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

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

    std::vector<mint> dp(n + 1, 0), ndp(n + 1);
    dp[0] = 1;
    for (int i = 0; i < n; ++i) {
        char c;
        std::cin >> c;
        if (c == '-') continue;

        std::fill(ndp.begin(), ndp.end(), 0);

        for (int k = 0; k < n; ++k) {
            if (c == 'U') {
                // 埋める
                ndp[k] += dp[k] * k;
                // 空ける
                ndp[k + 1] += dp[k];
            } else {
                // 埋める
                if (k - 1 >= 0) ndp[k - 1] += dp[k] * k * k;
                // 空ける
                ndp[k] += dp[k] * k;
            }
        }

        std::swap(dp, ndp);
    }

    std::cout << dp[0] << std::endl;
    return 0;
}



Measured memory_bytes: 3088
//_nebula_
#include<bits/stdc++.h>
using namespace std;
#define int long  long
#define double long double
int t;
const int M=1e9+7;
const int inf=INT64_MAX;
int max(int a,int b,int c){
    return max(a,max(b,c));
}
int min(int a,int b,int c){
    return min(a,min(b,c));
}
int fspow(int x,int y){
    int ans;
    if(y==0) return 1;
    ans=fspow(x, y/2);
    if(y%2==0) return ((ans*ans)%M);
    return (x*((ans*ans)%M))%M;
}
int gcd(int x,int y){
    if(x<y) swap(x,y);
    if(y==0) return x;
    return gcd(x%y,y);
}
int p2(int x){
    int ans=0;
    while(x>1){
        ans++;
        x/=2;
    }
    return ans;
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    t=1;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
   //  cin>>t;
    //int tmp=t;
    while(t--){
        string s="ACL";
        string ans;
        int k;
        cin>>k;
        for(int i=0;i<k;i++) ans=ans+"ACL";
        cout<<ans<<"\n";
    }
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int A, B, K;
    cin >> A >> B >> K;
    rep(i, A, B + 1)
    {
        if (i - A < K || B - i < K)
        {
            cout << i << endl;
        }
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#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()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
#define ve vector
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
// *max_element(all(d))
// priority_queue<int,vector<int>,greater<int>>
int solve(){
  string s;
  cin >> s;
  vector<int>cnt(26);
  rep(i,s.size())if(cnt[s[i] - 'a'] < 1)cnt[s[i] - 'a']++;
  rep(i,26){
    if(!cnt[i]){
      char a = 'a' + i;
      cout << a << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 512
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	c := make(map[string][]bool)
	suits := []string{"S", "H", "C", "D"}
	for _, s := range suits {
		c[s] = make([]bool, 13)
	}
	for i := 0; i < n; i++ {
		var s string
		var x int
		fmt.Scan(&s, &x)
		c[s][x-1] = true
	}
	for _, s := range suits {
		for i := 0; i < 13; i++ {
			if !c[s][i] {
				fmt.Println(string(s), i+1)
			}
		}
	}
}



Measured memory_bytes: 1128
n=int(input())
s=input()
r=s.count("R")
g=s.count("G")
b=s.count("B")
ans=r*g*b
for i in range(n):
    a=s[i]
    for j in range(i+1,n):
        b=s[j]
        d=j-i
        if j+d>=n:
            break
        c=s[j+d]
        if a!=b and b!=c and c!=a:
            ans-=1
print(ans)

Measured memory_bytes: 72596
n=int(input())
s=[input()for _ in range(n)]
from collections import Counter
cs=Counter(s)
d=dict(cs)
a=list(d.items())
a.sort(key=lambda x:x[1])
ansc=a[-1][1]
ans=[]
while a and ansc==a[-1][1]:
    b,c=a.pop()
    ans.append(b)
ans.sort()
print(*ans,sep='\n')

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

int N;
long long A[10110];
int min() {
	long long min_v = A[0];
	for (int i = 0; i < N; ++i) {
		if (A[i] < min_v)
		{
			min_v = A[i];
		}
	}
	return min_v;
}

int max() {
	long long max_v = A[0];
	for (int i = 0; i < N; ++i) {
		if (A[i] > max_v)
		{ max_v = A[i];
		}
	}
	return max_v;
}



long long sum() {
	long long sum_v = 0;
	for (int i = 0; i < N; ++i) {
		sum_v += A[i];
	}
	return sum_v;

}

int main() {
	
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
	}
	cout << min() <<' '<<max()<<' '<<sum()<<endl;
	return 0;

	

}


Measured memory_bytes: 3208
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
flg = 'War'
for i in range(X+1, Y+1):
	if max(x) < i and i <= min(y):
		flg = 'No ' + flg
		break
print(flg)

Measured memory_bytes: 3060
from math import ceil
n = int(input())
def solve(a, k):
	if a < k:
		return 0
	while a%k != 0:
		a -= ceil((a%k)/((a//k)+1)) * ((a//k)+1)
	return a//k
ans = 0
for _ in range(n):
	a, k = map(int, input().split())
	ans ^= solve(a, k)
if ans == 0:
	print("Aoki")
else:
	print("Takahashi")

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

int A, B, C, X, sum;

int main() {
    cin >> A >> B >> C >> X;

    for (int a = 0; a <= A; ++a) {
        for (int b = 0; b <= B; ++b) {
            for (int c = 0; c <= C; ++c) {
                if (500 * a + 100 * b + 50 * c == X) {
                    ++sum;
                }
            }
        }
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))
gus=[]
for i in L:
    if i%2==0:
        gus.append(i)

ans=True
for i in gus:
    if not i%3==0:
        if not i%5==0:
            print("DENIED")
            ans=False
            break

if ans:
    print("APPROVED")

Measured memory_bytes: 3064
import sys
from math import log2,floor,ceil,sqrt
# import bisect
# from collections import deque

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
 
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7

s = ri()
t = ri()
if s ==t[:-1]:
    Yes()
else:
    No()

Measured memory_bytes: 62220
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define PI 3.14159265359
#define rep(i,n) for(int i=0; i<n; ++i)
#define INF 1001001001
#define MAX_N 100005
#define MAX_M 100005
typedef long long ll;
typedef pair<int, int> P;

vector<int> h(MAX_N);
vector<int> edge[MAX_M];

int main() {
    int n, m;
    cin >> n >> m;   
    rep(i, n) cin >> h[i];

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    int ans = 0;
    rep(i, n) {
        bool flg = true;
        for(auto e : edge[i]) {
            if (h[i] <= h[e]) flg = false;
        }
        if (flg) ++ans;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8784
from collections import defaultdict
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n=int(input())
    cnt=defaultdict(int)
    for _ in range(n):
        a=int(input())
        cnt[a]+=1
    print(sum(v%2 for v in cnt.values()))
main()

Measured memory_bytes: 15452
def resolve():
    N, M = list(map(int, input().split()))
    ls = []
    for _ in range(N):
        a, b = list(map(int, input().split()))
        ls.append([a, b])
    ls = sorted(ls, key=lambda x: x[0])
    ans = 0
    drink = 0
    for i in range(N):
        if drink >= M:
            break
        if drink + ls[i][1] >= M:
            ans += ls[i][0] * (M - drink)
            drink = M
        else:
            ans += ls[i][0] * ls[i][1]
            drink += ls[i][1]

    print(ans)
    return

resolve()

Measured memory_bytes: 26176
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let ab = get!(usize, usize;n);
    let mut cnt = 0;

    for (a,b) in ab.into_iter().rev() {
        let a = a+cnt;
        if a % b > 0 {
            cnt += (a/b+1)*b-a;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 10620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

int main() {
    ll N;
    cin>>N;
    VL H(N);
    ll flg=1;
    ll ma=0;
    rep(i,0,N){
        cin>>H[i];
        ma=max(ma,H[i]);
        if(i!=0){
            ll d=H[i]-H[i-1];
            if(H[i]-ma<-1)flg*=0;
            //if(d<-1)flg*=0;
            if(i==N-1&&d<-1)flg*=0;
        }
    }
    cout<<(flg ? "Yes":"No")<<endl;
}

Measured memory_bytes: 1152
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;

  std::vector<i64> A000217;
  for (i64 i = 0; (i - 1) * i / 2 < N; ++i) {
    A000217.push_back(i * (i + 1) / 2);
  }

  while (N > 0) {
    i64 answer = std::distance(A000217.begin(), std::lower_bound(A000217.begin(), A000217.end(), N));
    std::cout << answer << std::endl;
    N -= answer;
  }
  return 0;
}

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

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

  string color;
  int yellow = 0;
  for(int i = 0; i < N; ++i) {
    cin >> color;
    if (color == "Y") {
      yellow = 1;
    }
  }
  if (yellow == 1) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }

}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        char[] ca = scanner.next().toCharArray();
        boolean fl1 = false;
        if(ca[0] != 'A'||Character.isUpperCase(ca[1])){
            System.out.println("WA");
            return;
        }
        for (int n = 2;n < ca.length - 1;++n){
            if(ca[n] == 'C'){
                if(fl1){
                    System.out.println("WA");
                    return;
                }
                else fl1 = true;
            }
            else if(Character.isUpperCase(ca[n])){
                System.out.println("WA");
                return;
            }
        }
        if(fl1&&Character.isLowerCase(ca[ca.length - 1])){
            System.out.println("AC");
        }
        else{
            System.out.println("WA");
        }
    }
}


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

int main()
{
    int n, temp;
    int count = 0;

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

    int now = 0;
    for (int i = 0; i < n; i++)
    {
        count++;
        now = a[now];
        if (now == 1)
        {
            cout << count;
            exit(0);
        }
    }
    cout << -1;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  ll n, c;
  cin >> n >> c;

  vector<pair<ll, ll>> xv(n);
  vector<ll> x, y;

  ll ans = 0;
  vector<ll> r(n, 0);  // 右に i 回以内進んだときのベストスコア
  vector<ll> l(n, 0);  // 左に n-i 回以内進んだときのベストスコア
  ll cal = 0;
  ll rbest = 0;
  rep(i, n) {
    ll x, v; cin >> x >> v;
    xv[i] = {x, v};
    cal += v;
    if (i == 0) cal -= x;
    else cal -= x - xv[i-1].first;
    chmax(rbest, cal);
    chmax(ans, cal);
    r[i] = rbest;
  }

  ll lbest = 0;
  cal = 0;
  for (int i = n-1; i >= 0; i--) {
    cal += xv[i].second;
    if (i == n-1) cal -= c - xv[i].first;
    else cal -= xv[i+1].first - xv[i].first;
    chmax(lbest, cal);
    chmax(ans, cal);
    l[i] = lbest;
  }

  // 先に右回りして途中で向きを変える
  ll sum = 0;
  rep(i, n-1) {
    sum += xv[i].second;
    ll tmp = sum - xv[i].first * 2;
    chmax(ans, tmp + l[i+1]);
  }

  // 先に左回りして途中で向きを変える
  sum = 0;
  for (int i = n-1; i > 0; i--) {
    sum += xv[i].second;
    ll tmp = sum - (c - xv[i].first) * 2;
    chmax(ans, tmp + r[i-1]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3456
H, W = map(int, input().split())
grid = [list('.'+input()+'.') for i in range(H)]
grid.insert(0, list('.' * (W + 2)))
grid.append(list('.' * (W + 2)))
ans = []

for i in range(1, H + 1):
  for j in range(1, W + 1):
    if grid[i][j] == '#':
      ans.append('#')
    else:
      ans.append(str((grid[i-1][j-1:j+2]+grid[i][j-1:j+2]+grid[i+1][j-1:j+2]).count('#')))

  ans.append('\n')
print(''.join(ans))
      


Measured memory_bytes: 3188
N = int(input())
Dic = {}
for n in range(N):
    S = input()
    if S in Dic.keys():
        Dic[S] = Dic[S] + 1
    else:
        Dic[S] = 1

max_val = max(Dic.values())
max_k_list = [kv[0] for kv in Dic.items() if kv[1] == max_val]
max_k_list = sorted(max_k_list)
for t in max_k_list:
    print(t)

Measured memory_bytes: 32988
#include<cstdio>

using namespace std;

typedef long long ll;

#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < n; i++)

int n, a[100000];
int c[100000];

ll mod_pow(ll x, int n){
	if(n == 0) return 1;
	return x * mod_pow(x, n - 1) % MOD;
}

ll solve(){
	rep(i, n){
		if(!(n ^ (a[i] & 1))) return 0;
		if(a[i] >= n) return 0;
	}
	if(c[0] > 1) return 0;
	rep(i, n) if(c[i] > 2) return 0;
	return mod_pow(2, n / 2);
}

int main(){
	scanf("%d", &n);
	rep(i, n){ scanf("%d", &a[i]); c[a[i]]++; }
	printf("%lld\n", solve());
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iomanip>
using namespace std;
int main(){
	string a;
	string s;
	cin >> s;
	for(int i=0;i<=s.size()-1;i++){
		if(s[i]=='0'){
			a = a+'0';
		}else if(s[i]=='1'){
			a = a+'1';
		}else if(s[i]='B'){
			if(a.size()!=0)
				a.erase(a.end()-1);
		}
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 764
<?php

fscanf(STDIN, "%d %d", $K, $S);

$from = max(0, $S - $K - $K);
$to = min($K, $S);
 
for ($i = $from; $i <= $to; $i++) {
    $rest = $S - $i;
    if (0 <= $rest && $rest <= $K + $K) {
        $ans += min($rest, $K + $K - $rest) + 1;
    }
}
 
echo $ans . PHP_EOL;

Measured memory_bytes: 2812
from bisect import bisect_right

mod = 10**9+7
N, K = map(int, input().split())
A = list(map(int, input().split()))
A_front = []
A_sorted = sorted(A)
ans = 0
for a in A:
    ans += (N - bisect_right(A_sorted, a)) * K*(K-1)//2
    ans %= mod
    i = bisect_right(A_front, a)
    ans += (len(A_front) - i) * K
    ans %= mod
    A_front.insert(i, a)
print(ans)

Measured memory_bytes: 41072
import itertools

antenna = [int(input()) for _ in range(5)]
k = int(input())

count = 0
for p in itertools.permutations(antenna, 2):
    x, y = p
    if abs(x - y) > k:
        count += 1

if count == 0:
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 9144
#include <stdio.h>
#include <string.h>

int main(void){
    char S[1001];
    char T[1001];
    int sn, tn;
    int i, j, tmp, max;

    scanf("%s", S);
    scanf("%s", T);
    sn = strlen(S);
    tn = strlen(T);

    max = 0;
    for (i=0;i < sn - tn+1;++i) {
        tmp = 0;
        for (j=0;j<tn;++j) {
            if ( S[i+j] == T[j]) {
                tmp++;
            }
            if ( ((tn-j)+tmp) < max) {
                break;
            }
        }
        if ( max < tmp) {
            max = tmp;
        }
        // printf("%d : %d\n", i, tmp);
    }
    printf("%d\n", tn-max);
}

Measured memory_bytes: 1688
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#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 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) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

LL ruisekiA[100010];
LL ruisekiC[100010];
LL ruisekiQ[100010];
LL threes[100010];
int main(){
    SCIN(str);
    ruisekiA[0]=0;
    ruisekiC[0]=0;
    ruisekiQ[0]=0;
    for(int a = 0;a < str.size();a++){
        if(str.at(a)=='A'){
            ruisekiA[a+1]=ruisekiA[a]+1;
        }else{
            ruisekiA[a+1]=ruisekiA[a];
        }
        if(str.at(a) == 'C'){
            ruisekiC[a+1]=ruisekiC[a]+1;
        }else{
            ruisekiC[a+1]=ruisekiC[a];
        }
        if(str.at(a) == '?'){
            ruisekiQ[a+1]=ruisekiQ[a]+1;
        }else{
            ruisekiQ[a+1]=ruisekiQ[a];
        }
    }
    threes[0]=1;

    for(int a = 1;a < str.size();a++){
        threes[a]=(threes[a-1]*3)%MOD;
    }
    LL ans = 0;
    for(int a = 0;a < str.size();a++){
        if(str.at(a)!='?'&&str.at(a)!='B')continue;
        LL insA = ruisekiA[a]*threes[ruisekiQ[a]]%MOD;
        if(ruisekiQ[a]!=0)insA += ruisekiQ[a]*threes[ruisekiQ[a]-1]%MOD;
        LL insB = (ruisekiC[str.size()]-ruisekiC[a+1])*threes[ruisekiQ[str.size()]-ruisekiQ[a+1]]%MOD;
        if(ruisekiQ[str.size()] - ruisekiQ[a+1] != 0)insB+=(ruisekiQ[str.size()]-ruisekiQ[a+1])*threes[ruisekiQ[str.size()]-ruisekiQ[a+1]-1]%MOD;
        //cout<<ruisekiA[a]<<" "<<ruisekiC[str.size()]-ruisekiC[a+1]<<" "<<ruisekiQ[a]<<" "<<ruisekiQ[str.size()]-ruisekiQ[a+1]<<endl;

        //cout<<insA<<" "<<insB<<endl;
        ans += insA * insB%MOD;
    }
    ans %= MOD;
    COUT(ans);
    return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int             long long
#define endl            '\n'
#define ff              first
#define ss              second
#define ull        unsigned long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define si                 set<int>        
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,a,n)        for(int i=a;i<n;++i)
#define repd(i,a,n)        for(int i=a;i>n;--i)
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define Mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int Pow(int a,int b){int res=1;while(b>0){if(b&1)res*=a;a*=a;b/=2;}return res;}
int MPow(int a,int  b){int res=1;while(b>0){if(b&1)res=(res*a)%Mod;a=(a*a)%Mod;b/=2;}return res%Mod;}


void c_p_p()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
}

int32_t main()
{
    c_p_p();
    int k;
    cin>>k;
    int sum=0;
    rep(i,1,k+1)
    {
        rep(j,1,k+1)
        {
            rep(p,1,k+1)
            {
                int H=__gcd(p,j);
                sum+=__gcd(H,i);
            }
        }
    }
    cout<<sum;
    return 0;
}
    

Measured memory_bytes: 3660
#include<iostream>
#include<string.h>
#include<unordered_map>
#include<vector>
#include<algorithm>
using namespace std;

#define ld long double
#define ll long long int
#define pb push_back
#define mp make_pair
#define f(i,a,b) for(int i=a;i<b;i++)

struct hash_pair{
	template <class T1, class T2>
	size_t operator()(const pair<T1, T2>& p) const{
		auto hash1 = hash<T1>{}(p.first);
		auto hash2 = hash<T2>{}(p.second);
		return hash1 ^ hash2;
	}
};

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

	int n,maxi=0;
	cin>>n;
	vector<string> V;
	unordered_map<string,int> U;
	string S;
	for(int i=0;i<n;i++){
		cin>>S;
		if(U.find(S) == U.end())
			U[S] = 1;
		else
			U[S]++;
	}
	for(auto x: U){
		if(maxi < x.second)
			maxi = x.second;
	}
	for(auto x: U){
		if(maxi == x.second)
			V.push_back(x.first);
	}
	sort(V.begin(),V.end());
	for(auto s: V)
		cout<<s<<"\n";

	return 0;
}


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

//const int mxN = 1e5 + 10;
//int dp[mxN];

//int rec(vector<int>& v, int i, int n) {
	//if(i == (n-1)) {
		//return dp[n-1] = 0;
	//}
	//if(dp[i] != -1) return dp[i];
	//int ans = INT_MAX;
	//if(i + 1 <= n-1)
		//ans = min(ans, abs(v[i] - v[i+1]) + rec(v, i+1, n));
	//if(i + 2 <= n-1)
		//ans = min(ans, abs(v[i] - v[i+2]) + rec(v, i+2, n));
		
	//return dp[i] = ans;
//}

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	
	for(int i = 0; i < n; i++) {
		cin >> v[i];
	}
	
	vector<int> dp(n, INT_MAX);
	dp[0] = 0;
	for(int i = 1; i < n; i++) {
		for(int j = 1; j <= k; j++) {
			if(i - j < 0) break;
				dp[i] = min(dp[i], dp[i-j] + abs(v[i] - v[i-j]));
		}
	}
	
	cout << dp[n-1] << "\n";
}


Measured memory_bytes: 4036
defmodule Main do
  def main() do
    input = IO.gets("") |> String.trim() |> String.split() |> Enum.map(&(String.to_integer(&1)))
    n = input |> Enum.at(0)
    k = input |> Enum.at(1)
    num = get_inp(k)  |> List.flatten()|> Enum.uniq() |> Enum.count()
    IO.puts(n-num)
  end

  def get_inp(0, result), do: result
  def get_inp(num, result \\ []) do
    d = IO.gets("") |> String.trim() |> String.to_integer()
    input = IO.gets("") |> String.trim() |> String.split()|> Enum.map(&(String.to_integer(&1)))
    result = result ++ [input]
    get_inp(num-1, result)
    end
end

Measured memory_bytes: 31392
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <map>
#include <iomanip>
using namespace std;

typedef long long ll;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long long a, long long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long long a, long long b){
	return a / gcd(a,b) * b;
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int a, b, c;

int main(){
	cin >> a >> b >> c;

	if (a+b+c <= 21) cout << "win" << endl;
	else cout << "bust" << endl;

	return 0;
}

Measured memory_bytes: 256