akhauriyash/Code-Regression huggingface dataset:
f (x:xs) n =  (foldr1 (.) (replicate x (n :))) (f xs (n + 1))
f [] n = []

g w [] e = []
g w xs e = let row = if e then take w xs else reverse $ take w xs
               in row : g w (drop w xs) (not e)

concatWith ch xs = concat (map (++ ch) xs)
prettyPrint xss = concatWith "\n" $ map (concatWith " " . map show) xss

solver w xs = g w (f xs 1) True

main = do ln1 <- getLine
          ln2 <- getLine
          ln3 <- getLine
          let w = map read (words ln1) !! 1
              xs = map read (words ln3)
              ans = solver w xs
              in putStr (prettyPrint ans)

Measured memory_bytes: 2428
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
const ll MOD = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 200100;

int N,a,b;

vector<int> ask(int len, int fst, int lst, int off){
  
  vi ans;

  if (len == 1){
    ans.pb(fst+off);
    ans.pb(lst+off);
    return ans;
  }
  int H = (1<<(len-1));
  int fb=(H&fst)>0;
  int lb=(H&lst)>0;
  // cout<<"Ask "<<len<<' '<<fst<<' '<<lst<<' '<<off<<'\n';

  if (fb == lb && fb==1){
    vi A = ask(len-1, fst-H,lst-H,H);
    int j=A.back();A.pop_back();
    int k=A.back();
    vi B=ask(len-1,k-H,j-H,0);
    for (auto i:A)ans.pb(i);
    for (auto i:B)ans.pb(i);
    ans.pb(j);
  }
  else if (fb == lb && fb == 0){
    vi A = ask(len-1,fst,lst,0);
    int j=A.back();A.pop_back();
    int k=A.back();
    // cout<<j<<' '<<k<<'\n';
    // cout<<"Try "<<k<<' '<<j<<'\n';
    vi B=ask(len-1,k,j,H);
    for (auto i:A)ans.pb(i);
    for (auto i:B)ans.pb(i);
    ans.pb(j);
    // for (auto i :ans)cout<<i<<' ';
  }else{
    int nst = fst%H;
    int nen = lst%H;
    int tar=0;
    while (tar==nst||tar==nen||__builtin_popcount(tar)%2==__builtin_popcount(nst)%2)++tar;
    assert(tar<=H);
    // cout<<"Tar "<<tar<<'\n';
    if (fst>=H){
      vi A = ask(len-1,nst,tar,H);
      vi B = ask(len-1,tar,nen,0);
      for (auto i:A)ans.pb(i);
      for (auto i:B)ans.pb(i);
    }else{
      vi A = ask(len-1,nst,tar,0);
      vi B = ask(len-1,tar,nen,H);
      for (auto i:A)ans.pb(i);
      for (auto i:B)ans.pb(i);
    }
  }
  for (auto &i:ans)i+=off;
  // for (auto i:ans)cout<<i<<' ';cout<<'\n';
  return ans;
}

int main(){
  cin>>N>>a>>b;
  if ((__builtin_popcount(a)^__builtin_popcount(b))%2==0){
    cout<<"NO\n";
    return 0;
  }
  cout<<"YES\n";
  vi A = ask(N,a,b,0);
  for (int i=0;i<(SZ(A))-1;++i){
    if(__builtin_popcount(A[i]^A[i+1])!=1){
      // cout<<A[i]<<' '<<A[i+1]<<'\n';
      assert(0);
    }
  }
  for (auto x:A)cout<<x<<' ';
}

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

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

  int M = 1e9;

  for (int i = 0; i < N; i++) {
    int m;
    cin >> m;
    X -= m, M = min(M, m);
  }

  cout << X / M + N << "\n";
}

Measured memory_bytes: 256
#define TST 0
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cctype>
#include <bits/stdc++.h>

using namespace std;
// for loop
#define F(i, L, R) for(long i = L; i < R; i++)
#define FE(i, L, R) for(long i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(long i = L; i > R; i--)
#define FRE(i, L, R) for(long i = L; i >= R; i--)

// data types
#define Int long
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back
#define InputV(a, n) F(i,0,n){long l; cin >> l; a.pb(l);}

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)
#define printM(a, n, m) F(i, 0, n){ FE(j, 0, m) cout << a[i][j] << (i==m?'\n':' ');}

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

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

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

#define printMatrix(mat,n,m){ \
    F(i, 0, n){               \
        F(j, 0, m){           \
            cout << mat[i][j] << space;\
        }\
        cout << endl;\
    }\
}

int main() {
#if TST==1
    ifstream in ("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int a,b,c;
    long x,y;
    cin >> a >> b >> c >> x >> y;
    ll ans = 100000000000;
    long limit;
    if(x > y)
        limit = x;
    else
        limit = y;
    long anum,bnum,cnum;
    for(long i = limit; i >= 0;i--){
        cnum = 2*i;
        anum = x-i>0? x-i:0;
        bnum = y-i>0? y-i:0;
        ll money = anum * a + bnum * b + cnum*c;
        ans = min(ans, money);
    }

#if TST==1
#endif
    cout << ans << endl;
}



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

int N;
vector<int> A[100000];
int S;
vector<int> L;

bool see(int v, int par) {
  int count = 0;
  for(int w : A[v]) {
    if(w != par && (int)A[w].size() != 1) {
      ++count;
      if(!see(w, v)) return false;
    }
  }
  if(par >= 0 && count > 1) return false;
  else if(par < 0 && count > 2) return false;
  else {
    if(count == 0) S = v;
    return true;
  }
}

void go(int v, int par) {
  L.push_back(A[v].size() - 2);
  for(int w : A[v]) {
    if(w != par && (int)A[w].size() != 1) { go(w, v); return; }
  }
}

void make(const vector<int>& l, vector<int>& r) {
  int c = 0;
  r.push_back(++c);
  for(int i = 0; i < (int)l.size(); ++i) {
    int d = ++c;
    for(int j = 0; j < l[i]; ++j) { r.push_back(++c); }
    r.push_back(d);
  }
  r.push_back(++c);
}

int main() {
  cin >> N;
  for(int i = 0; i < N - 1; ++i) {
    int v, w; cin >> v >> w; --v; --w; A[v].push_back(w); A[w].push_back(v);
  }
  if(N == 2) {
    cout << "1 2" << endl;
  } else {
    bool ok = false;
    for(int v = 0; v < N; ++v) {
      if((int)A[v].size() != 1) { ok = see(v, -1); break; }
    }
    if(!ok) cout << -1 << endl;
    else {
      go(S, -1);
      vector<int> R1, R2;
      make(L, R1); reverse(L.begin(), L.end()); make(L, R2);
      vector<int> R = min(R1, R2);
      for(int i = 0; i < N; ++i) {
        cout << (i == 0 ? "" : " ") << R[i];
      }
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 12664
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
long long a[200005];
int main()
{
    long long n, sum=0, x=0, res;
    scanf("%lld", &n);
    for(int i=0; i<n; i++){
        scanf("%lld", &a[i]);
        sum += a[i];
    }
    res = abs(a[0]-(sum-a[0]));
    for(int i=0; i<n-1; i++){
        x += a[i];
        res = min(res, abs(x - (sum - x)));
    }
    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

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

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool is_prime(ll n) {
    if (n == 1) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}

/*------------------------------------------------------------------------*/

void solve();

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15);

    solve();
}

void solve() {
    ll n, m;
    std::cin >> n >> m;

    vstr a(n), b(m);
    for (ll i = 0; i < n; i++) std::cin >> a[i];
    for (ll i = 0; i < m; i++) std::cin >> b[i];

    for (ll i = 0; i < n - m + 1; i++) for (ll j = 0; j < n - m + 1; j++) {
        bool flg = true;
        for (ll k = 0; k < m; k++) for (ll l = 0; l < m; l++)
            if (a[i + k][j + l] != b[k][l]) { flg = false; goto aaaaa; }
    aaaaa:
        if (flg) { std::cout << "Yes" << '\n'; return; }
    }

    std::cout << "No" << '\n';
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define sh cin.tie(0); cin.sync_with_stdio(0); cout.tie(0);
#define FILE freopen("test.in", "r", stdin);
#define vprint(v) for (int ii = 0; ii < v.size(); ii++){cout << v[ii] << " ";}
#define debugv(v) if (v.size() != 0) {cout << "[ "; for (int __ = 0; __ < (int)(v.size()) - 1; __++){cout << v[__] << ", ";} cout << v[(int)(v.size()) - 1] << " ]" << endl;} else {cout << "[]" << endl;}
#define debug cout << "-----------------------------------------------" << endl;
#define print1(a) cout << "{ " << a << " }" << endl;
#define print2(a, b) cout << "{ " << a << ", " << b << " }" << endl;
#define print3(a, b, c) cout << "{ " << a << ", " << b << ", " << c << " }" << endl;
#define print4(a, b, c, d) cout << "{ " << a << ", " << b << ", " << c << ", " << d << " }" << endl;
using namespace std;
//#define int long long
const int INF = 1e9 + 228;
const int MAXN = 1e5 + 228;

signed main()
{
#ifdef LOCAL
    FILE;
#endif
    sh;
	int n, k;
	cin >> n >> k;
	vector<int> v;
	for (int i = 0; i < n; i++) {
		int aa;
		cin >> aa;
		v.pb(aa);
	}    
	double ans = 0;
	double sm = 0;
	for (int i = 0; i < k; i++) {
		sm += ((v[i] + 1) * (v[i] / 2) + (v[i] % 2) * ((v[i] / 2) + 1)) / (v[i] * 1.0);
	}
	ans = sm;
	for (int i = k; i < n; i++) {
		sm -= ((v[i - k] + 1) * (v[i - k] / 2) + (v[i - k] % 2) * ((v[i - k] / 2) + 1)) / (v[i - k] * 1.0);
		sm += ((v[i] + 1) * (v[i] / 2) + (v[i] % 2) * ((v[i] / 2) + 1)) / (v[i] * 1.0);
		ans = max(ans, sm);
	}
	cout << fixed << setprecision(7) << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<PII> re(n);
    int a, b;
    for(int i = 0; i < n; ++i){
        cin >> a >> b;
        re[i].first = a;
        re[i].second = b;
    }
    sort(re.begin(), re.end(),
            [&](PII q, PII p){
        if(q.second == p.second) return q.first < p.first;
        return q.second < p.second;
    });
    int qian = 0, hou = 0;
    for(auto& i:re){
        qian += i.first;
        hou = i.second > hou ? i.second : hou;
        if(qian > hou){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 1792
let () =
  let rec q () =
    let a = Array.init 10 (fun i -> Scanf.scanf "%d," (fun i -> i*2000)) in
    let (v1, v2) = Scanf.scanf "%d,%d " (fun v1 v2 -> (v1, v2)) in
    let l = Array.fold_left (+) 0 a in
    let t = l / (v1 + v2) in
    let rec doit i acc =
      if t*v1 <= acc+a.(i) then Printf.printf "%d\n" (i+1)
      else doit (i + 1) (acc+a.(i)) in
    doit 0 0;
    q() in
  try q() with _ -> ()

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

using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    string s;
    cin >> s;

    bool so=false;
    for(int i=a-1;i!=c;i++){
        if(so==true&&s[i]=='#'){
            cout << "No" << endl;
            return 0;
        }
        else if(so==false&&s[i]=='#'){
            so=true;
        }
        else{
            so=false;
        }
    }
    so=false;
    for(int i=b-1;i!=d;i++){
        if(so==true&&s[i]=='#'){
            cout << "No" << endl;
            return 0;
        }
        else if(so==false&&s[i]=='#'){
            so=true;
        }
        else{
            so=false;
        }
    }
    if(c<d){
        cout << "Yes" << endl;
        return 0;
    }
    int wakaru=0;
    int ans[n]={};
    rep(i,n){
        if(i==0){
            if(s[i]=='#'){
                ans[i]=2;
                ans[i+1]=1;
            }
        }
        else if(i==n-1){
            if(s[i]=='#'){
                ans[i-1]=1;
                ans[i]=2;
            }
        }
        else if(s[i]=='#'){
            ans[i-1]=1;
            ans[i]=2;
            ans[i+1]=1;
        }
    }
    for(int i=b-1;i!=d;i++){
        if(ans[i]==0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}



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

int main(){
    int n; cin >> n;
    vector<ll> s(n);
    rep(i,n) cin >> s[i];
    ll sum = 0;
    ll digit = 1;
    rep(i,60){
        ll even=0; 
        ll odd=0;
        for(int j=0;j<n;++j){
            if(s[j] & (1LL<<i)) odd++;
            else even++;
        }
        sum += ( odd*even)%MOD*digit%MOD;
        sum%=MOD;
        digit=(digit*2)%MOD;
    }
    cout << sum << endl;
}

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

int main() {
	string S;
	cin >> S;
	int N = S.size();
	bool flag = true;
	for(int i=0;i<=N/2;i++){
		if(S[i] != S[N-i-1]) flag = false;
	}
	for(int i=0;i<=(N-1)/4;i++){
		if(S[i] != S[(N-1)/2-i-1]) flag = false;
	}

	string S2 = S.substr((N+3)/2-1);
	int N2 = S2.size();
	for(int i=0;i<=N2/2;i++){
		if(S2[i] != S2[N2-i-1]) flag = false;
	}
	
	cout << (flag?"Yes":"No") << endl;
}

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

const int INF = 1e8;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    long long n, k;
    cin >> n >> k;
    if (n >= k) {
        cout << min(n - k * (n/k), k*(n/k+1) - n) << endl;
    }
    else {
        long long diff = k - n;
        cout << min(diff, n) << endl;
    }
}

Measured memory_bytes: 3660
#include<stdio.h>
#include<math.h>
int main(){
    int n, x;
    int a[10] = {};
    scanf("%d", &n);
    x = 0;
    
    for (int i=0; i<n; i++){
        scanf("%d", &a[i]);
        if (a[i]%2 == 0){
            x += 1;
        }
    }
    
    int ans = pow(3, n)-pow(2, x);
    printf("%d", ans);
    
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
main()
{
  int n, i, j, v;
  int a[1000];

  scanf("%d", &n);
  
  for(i=0; i<n; i++){
	scanf("%d", &a[i]);
  }
  for(i=1; i<n+1; i++){
	for(j=0; j<n; j++){
	  printf("%d", a[j]);
	  if(a[j+1] != '\0')
		printf(" ");
	  else printf("\n");
	}
	v = a[i];
	j = i-1;
	while(j >= 0 && a[j] > v){
	  a[j+1] = a[j];
	  j--;
	  a[j+1] = v;
	} 
  }
  return 0;
}

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

int main(){
  char s[11], t[11];
  scanf(" %s\n %s", s, t);
  int x = strlen(s);
  t[x]='\0';
  if(strcmp(s,t) == 0) {
     printf("Yes\n");
  }else {
     printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 1644
Tmp = []
Tmp = input().rstrip().split(' ')
 
Ans = []
 
nA = int(Tmp[0])
Ans.append(nA)
 
nB = int(Tmp[1])
Ans.append(nB)
  
nC = int(Tmp[2])
Ans.append(nC)
 
Ans.sort(reverse=True)
 
nAns = Ans[0]*10+Ans[1]+Ans[2]
print(nAns)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <functional>
#include <queue>
#include <tuple>

using namespace std;

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using ll = long long;
using vll = vector<ll>;
using pii = pair<int, int>;
using vb = vector<char>;
using vvb = vector<vb>;

#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define mp(a, b) make_pair(a,b)

#define fi first
#define sn second
#define decpii(p) p.fi--,p.sn--;


#ifdef LOCAL
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define dumpn(c) cerr << "> " << #c << " = " << (c) << ", ";
#else
#define dump(c) ;
#define dumpn(c) ;
#endif


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

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
    os << '[';
    rep(i, (int) a.size())os << (i ? " " : "") << a[i];
    return os << ']';
}


int dxf[] = {1, 0, -1, 0};
int dyf[] = {0, -1, 0, 1};

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 (b < a) {
        a = b;
        return true;
    }
    return false;
}

inline vi uni(vi &vec) {
    sort(vec.begin(), vec.end());
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

struct ____ {
    ____() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} ________;

bool solve() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    return (abs(a-c) <= d) || (abs(a-b) <= d && abs(b-c) <= d);
}

int main() {
    cout << (solve() ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin>>n;
	int num=n%10;
	if(num==2 || num==4 || num==5 || num==7 || num==9)
	 cout<<"hon";
	else if(num==0 || num==1 || num==6 || num==8)
	 cout<<"pon";
	else
	 cout<<"bon";
	return 0;
}

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

using namespace std;

int main()
{
	string str;
	cin >> str;

	const int n = str.size();
	stack<char> st;
	for (int i = 0; i < n; i++)
	{
		const char e = str[i];
		if(st.empty())
		{
			st.push(e);
			continue;
		}

	   char top = st.top();
	   if (e != top)
	   {
		   st.pop();
	   }
	   else
		   st.push(e);
	}

	cout << n - st.size() << endl;
	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;

//計算量はO(log max(a,b))
ll gcd(ll x,ll y){
  ll mindata,maxdata;
  mindata=min(x,y);
  maxdata=max(x,y);
  while(maxdata%mindata!=0){
    ll temp;
    temp=maxdata%mindata;
    maxdata=mindata;
    mindata=temp;
  }
  return mindata;
}

int main(){
    int count=0;
    ll A,B;
    cin>>A>>B;
    ll a=gcd(A,B);
    for(ll i=2;i<=1000000;i++){
        if(a%i==0){
            count++;
            while(a%i==0){
                a/=i;
            }
        }
    }
    if(a!=1) count++;
    count++;
    cout<<count<<endl;
}


Measured memory_bytes: 384
using System;

namespace ABC_063_A_Csharp_ver
{
    class Program
    {
        static void Main(string[] args)
        {
            var word = Console.ReadLine().Split(' ');
            int A = int.Parse(word[0]);
            int B = int.Parse(word[1]);
            if (A + B >= 10)
            {
                Console.WriteLine("error");
            }
            else
            {
                Console.WriteLine(A + B);
            }
            Console.ReadLine();
        }
    }
}


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

int main(){
    int N;
    cin >> N;
    vector<unsigned long long int> A(N);
    int i;
    unsigned long long int multi = 1;
    int zero = 0;
    for(i=0; i<N; i++){
        cin >> A.at(i);
        if(A.at(i) == 0){
            zero++;
        }
    }

    if(zero != 0){
        cout << 0 << endl;
        return 0;
    }

    for(i=0; i<N; i++){
        if(A.at(i) <= 1000000000000000000/multi){
            multi *= A.at(i);
        }else{
            cout << -1 << endl;
            return 0;
        }
    }
        
    cout << multi << endl;
    
}

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

public class Main {
  private static boolean solve(int h, int n, int[] as) {
    for (int a : as) {
      h -= a;
    }
    return h <= 0;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int h = reader.nextInt();
    int n = reader.nextInt();
    int[] as = reader.nextInt(n);
    out.println(solve(h, n, as) ? "Yes" : "No");
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 33656
h, w = gets.chop.split.map(&:to_i)

s = []

h.times do |i|
  s[i] = gets.chomp.chars
  s[i] << nil
end

s << Array.new(w) { nil }

move = [[-1, 0], [0, 1], [1, 0], [0, -1]]
max = 0


h.times do |i|
  w.times do |j|
    next if s[i][j] == '#'

    dist = Array.new(h) { Array.new(w) { -1 } }
    dist[i][j] = 0
    queue = [[i, j]]

    while queue.any?
      q = queue.shift
      x = q[0]
      y = q[1]


      move.each do |m|
        pro_x = x + m[0]
        pro_y = y + m[1]

        next if s[pro_x][pro_y].nil? || s[pro_x][pro_y] == '#'
        next if dist[pro_x][pro_y] != -1

        dist[pro_x][pro_y] = dist[x][y] + 1
        max = dist[pro_x][pro_y] if max < dist[pro_x][pro_y]

        queue.push([pro_x, pro_y])
      end
    end
  end
end

puts max


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

bool isSorted(vector<int> v){
    int N = v.size();
    for(int i=1; i<N; i++){
        if(v[i] <= v[i-1])
        return false;
    }
    return true;
}

int main(){
    int N;  cin >> N;
    vector<int> p(N+1,0);
    for(int i=1; i<=N; i++){
        cin >> p[i];
    }

    for(int i=1; i<=N; i++) for(int j=i; j<=N; j++){
        swap(p[i], p[j]);
        if(isSorted(p)){
            cout << "YES" << endl;
            return 0;
        }
        swap(p[i], p[j]);
    }
    cout << "NO" << endl;
}


Measured memory_bytes: 256
using System.Text;
using System;

public class hello
{
    public static void Main()
    {
        var sb = new StringBuilder();
        var INF = " 1000000001";
        var INF2 = 1000000001;
        Console.ReadLine().Trim();
        string[] line = (Console.ReadLine().Trim() + INF).Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        Console.ReadLine().Trim();
        line = (Console.ReadLine().Trim() + INF).Split(' ');
        var b = Array.ConvertAll(line, int.Parse);
        var p = 0; var q = 0;
        while (true)
        {
            if (a[p] == INF2 && b[q] == INF2) break;
            else if (a[p] == b[q]) { p++; q++; }
            else if (a[p] < b[q]) { sb.Append(string.Format("{0}\n", a[p++])); }
            else { sb.Append(string.Format("{0}\n", b[q++])); }
        }
        Console.Write(sb);
    }
}


Measured memory_bytes: 56180
class Dice:
    def __init__(self, lst):
        self.a = lst[0]
        self.b = lst[1]
        self.c = lst[2]
        self.d = lst[3]
        self.e = lst[4]
        self.f = lst[5]
        
    def roll(self, orders):
        for order in orders:
            if order=='W':
                tmp = self.a
                self.a = self.c
                self.c = self.f
                self.f = self.d
                self.d = tmp
            elif order=='E':
                tmp = self.a
                self.a = self.d
                self.d = self.f
                self.f = self.c
                self.c = tmp
            elif order=='S':
                tmp = self.a
                self.a = self.e
                self.e = self.f
                self.f = self.b
                self.b = tmp
            elif order=='N':
                tmp = self.a
                self.a = self.b
                self.b = self.f
                self.f = self.e
                self.e = tmp
#             print(self.a, self.b, self.c, self.d, self.e, self.f)
#         print(self.a)
       
            
import random
if __name__ == '__main__':
    lst = [int(x) for x in input().split()]
    q = int(input())
    questions = [[int(x) for x in input().split()] for _ in range(q)]
    
    dice = Dice(lst)    # 初期化
    direction = ['N', 'E', 'S', 'W']
    for question in questions:
        """ diceをランダムに回し、所望の状態になったら状態を出力
        """
        while True:
            dice.roll(random.choice(direction))
            if dice.a==question[0] and dice.b==question[1]:
                print(dice.c)
                break


Measured memory_bytes: 8192
#include <iostream>

int main() {
    std::string A, B, C;
    std::cin >> A >> B >> C;

    std::cout
            << (A.compare(A.length() - 1, 1, B, 0, 1) == 0 && B.compare(B.length() - 1, 1, C, 0, 1) == 0 ? "YES" : "NO")
            << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s;
	
	int ans=0;
	int cnt  = 0;
	cin >>s;
	rep(i, s.size()) {
		if ('R'== s[i]) {
			cnt++;
		} else {
			chmax(ans, cnt);
			cnt = 0;
		}
	//	last = s[i];
	}
	cout<<max(ans,cnt)<<endl;
}

Measured memory_bytes: 3552
using namespace std;

#include <iostream>
#include <string>
#include <vector>

int main(){
	int n, m;
	cin >> n >> m;
	string str;
	vector<int> ints(m);
	for (size_t i = 0; i < n; i++)
	{
		cin >> str;
		for (size_t j = 0; j < m; j++)
		{
			if (str[j] == 'c'){
				ints[j] = 0;
			}
			else if (!j){
				ints[j] = -1;
			}
			else{
				if (~ints[j - 1]){
					ints[j] = ints[j - 1] + 1;
				}
				else{
					ints[j] = -1;
				}
			}
		}
		for (size_t j = 0; j < m - 1; j++)
		{
			cout << ints[j] << " ";
		}
		cout << ints[m - 1] << "\n";
	}
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;

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

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back
#define pb push_back

int main(void){
  int n;
  vector<ll> h;
  cin >> n;
  h.resize(n);
  rep(i,n){
    cin >> h[i];
  }


  ll before = h[n-1];
  for(int i = n-1; i >= 0; --i){
    if(before>=h[i]){
      before = h[i];
    }else{
      if(before >= h[i]-1){
        before = h[i]-1;
      }else{
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810364364
#define PI 3.14159265358979
#define ERR 0.00000000000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int main(){
  LL i,ans=INF,K,N;
  scanf("%lld%lld",&K,&N);
  LL A[N];
  rep(i,N)scanf("%lld",&A[i]);
  rep(i,N-1)ans=MIN(ans,K-(A[i+1]-A[i]));
  ans=MIN(ans,K-(K+A[0]-A[N-1]));

  printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <map>
#include <queue>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define MP make_pair

typedef pair<int, int> PII;

int h, w, n;
char maps[1000][1001];
int memo[1000][1000];

int serach(int y, int x, int num) {
	queue<PII> Q;
	int res = 0;
	REP(i, h) REP(j, w) memo[i][j] = -1;

	Q.push(MP(y, x));
	memo[y][x] = 0;
	while (! Q.empty()) {
		int dx[] = {0,1,0,-1}, dy[] = {1,0,-1,0};
		PII q = Q.front(); Q.pop();
		if (maps[q.first][q.second] == num + '0') {res = memo[q.first][q.second]; break;}

		REP(i, 4) {
			int nx = q.second + dx[i], ny = q.first + dy[i];
			if (! (nx >= 0 && nx < w && ny >= 0 && ny < h)) continue;
			if (maps[ny][nx] == 'X' || memo[ny][nx] > -1) continue;
			memo[ny][nx] = memo[q.first][q.second] + 1;
			Q.push(MP(ny, nx));
		}
	}

	return res;
}

int main() {
	int ans = 0;
	cin >> h >> w >> n;
	REP(i, h) scanf("%s", maps[i]);

	REP(i, h) REP(j, w) {
		if (maps[i][j] == 'S') ans += serach(i, j, 1);
		if (maps[i][j] >= '1' && maps[i][j] < n + '0') ans += serach(i, j, (maps[i][j] + 1) - '0');
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6128
N=int(input())
l=[1,6,9,36,81,216,729,1296,6561,7776,46656,59049]
h=[None]*100001
h[0]=0
k=[0]
c=1
while None in h:
    t=[]
    for i in k:
        for j in l:
            if i+j>100000:
                break
            if h[i+j]==None:
                h[i+j]=c
                t.append(i+j)
    k=t
    c+=1
print(h[N])

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)

int N;

int main(){
	fast;
	
	cin>>N;
	ll ans = 1;
	vi vect;
	FOR(i,1,N){
		ll a;
		cin>>a;
		if (a == 0){
			cout<<0;
			return 0;
		}
		vect.pb(a);
	}
	aFOR(a,vect){
		if (ans > (ll)1e18 / a){
			cout<<-1;
			return 0;
		}
		ans *= a;
	}
	cout<<ans;
}



Measured memory_bytes: 4248
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N; cin >> N;
    vec a(N); readvec(a);

    vec count(4, 0);
    REP(i, N) count[a[i] % 4]++;
    if(count[2] == 0 && count[0] > 0 && count[0] + 1 == count[1] + count[3]) cout << "Yes";
    else if(count[0] >= count[1] + count[3]) cout << "Yes";
    else cout << "No";
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  unsigned int num;
  cin >> num;
  string str;
  cin >> str;
   if( num >= str.size()){
    cout << str  << endl;
  }
   else{
     string substr = str.substr(0,num);
     cout << substr << flush;
     cout << "..." << endl;
   }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define MOD 1000000007

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

    string s;
    int flag = 1;
    cin>>s;
    string s2;
    int q;
    cin>>q;
    while(q--){
        int t;
        cin>>t;
        
        if(t == 1){
            flag = !flag;
        
        }else{
            int f;
            char c;
            cin>>f>>c;
            f--;
            if(f^flag){
             s2.push_back(c);   
                
            }else{
                s.push_back(c);
            }   
        }
    }
    if(flag){
        reverse(s2.begin(),s2.end());
        cout<<s2<<s;
    }else{
        reverse(s.begin(),s.end());
        cout<<s<<s2;
    }
    
}

Measured memory_bytes: 980
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,i,k=0;
	cin>>N;
	string S;
	cin>>S;
	for(i=0;i<N-2;i++){
		if((S.at(i)=='A')&&(S.at(i+1)=='B')&&(S.at(i+2)=='C')){
			k++;
		}
	}
	cout<<k<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int N;
    int dp[1001][8];
    char TOBAN[1001];
    cin >> N;
    cin >> TOBAN;//TOBAN[0]～TOBAN[N-1]に一文字ずつ格納
    
    for(int i=1;i<=7;i++){
        dp[N][i]=1;
    }
    for(int day=1;day<N;day++){
        for(int i=1;i<=7;i++){
            dp[day][i]=0;
        }
    }
    for(int day=N-1;day>=1;day--){
        char next_toban=TOBAN[day];
        if(next_toban=='J'){
            dp[day][1]=dp[day+1][1]+dp[day+1][4]+dp[day+1][5]+dp[day+1][7];
            dp[day][2]=dp[day+1][4]+dp[day+1][7];
            dp[day][3]=dp[day+1][5]+dp[day+1][7];
            dp[day][4]=dp[day+1][1]+dp[day+1][4]+dp[day+1][5]+dp[day+1][7];
            dp[day][5]=dp[day+1][1]+dp[day+1][4]+dp[day+1][5]+dp[day+1][7];
            dp[day][6]=dp[day+1][4]+dp[day+1][5]+dp[day+1][7];
            dp[day][7]=dp[day+1][1]+dp[day+1][4]+dp[day+1][5]+dp[day+1][7];
        }
        else if(next_toban=='O'){
            dp[day][1]=dp[day+1][4]+dp[day+1][7];
            dp[day][2]=dp[day+1][2]+dp[day+1][4]+dp[day+1][6]+dp[day+1][7];
            dp[day][3]=dp[day+1][6]+dp[day+1][7];
            dp[day][4]=dp[day+1][2]+dp[day+1][4]+dp[day+1][6]+dp[day+1][7];
            dp[day][5]=dp[day+1][4]+dp[day+1][6]+dp[day+1][7];
            dp[day][6]=dp[day+1][2]+dp[day+1][4]+dp[day+1][6]+dp[day+1][7];
            dp[day][7]=dp[day+1][2]+dp[day+1][4]+dp[day+1][6]+dp[day+1][7];
        }
        else{
            dp[day][1]=dp[day+1][5]+dp[day+1][7];
            dp[day][2]=dp[day+1][6]+dp[day+1][7];
            dp[day][3]=dp[day+1][3]+dp[day+1][5]+dp[day+1][6]+dp[day+1][7];
            dp[day][4]=dp[day+1][5]+dp[day+1][6]+dp[day+1][7];
            dp[day][5]=dp[day+1][3]+dp[day+1][5]+dp[day+1][6]+dp[day+1][7];
            dp[day][6]=dp[day+1][3]+dp[day+1][5]+dp[day+1][6]+dp[day+1][7];
            dp[day][7]=dp[day+1][3]+dp[day+1][5]+dp[day+1][6]+dp[day+1][7];
        }
        for(int i=1;i<=7;i++){
            dp[day][i]=dp[day][i]%10007;
        }    
    }
    if(TOBAN[0]=='J'){
        cout << (dp[1][1]+dp[1][4]+dp[1][5]+dp[1][7])% 10007 << endl;
    }
    else if(TOBAN[0]=='O'){
        cout << (dp[1][4]+dp[1][7])% 10007 << endl;
    }
    else{
        cout << (dp[1][5]+dp[1][7])% 10007 << endl;
    }
}



Measured memory_bytes: 3112
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>
#include <cassert>

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

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int N; cin>>N;
    vector<int>h(N), dp(N+10, (int)1e9);
    for(int i=0;i<N;i++)cin>>h[i];

    dp[0]=0;

    for (int i = 0; i < N; i++) {
        for (int j = i+1; j <= i+2; j++) {
            if(j>=N)continue;
            dp[j]=min(dp[j], dp[i]+abs(h[i]-h[j]));
        }
    }

    cout<<dp[N-1]<<endl;


    return 0;
}

Measured memory_bytes: 1024
from numpy import *
f=bitwise_xor.reduce
N=int(input())
A=array(input().split(),int64)
X=f(A)
A=hstack((A,array([1<<i for i in range(60)if X&(1<<i)],int64)))
for k in range(60)[::-1]:
  b=1<<k
  j=A&b!=0
  i=where(j&(A<2*b))[0]
  if len(i):i=i[0];x=A[i];A[j]^=x;A[i]=x
r=f(A)
print(r+(r^X))

Measured memory_bytes: 29028
#!/usr/bin/env python
import logging
logging.basicConfig(level=logging.DEBUG)
logging.disable(logging.CRITICAL)

def main():
    N = int(input())
    H = list(map(int, input().split()))
    
    ans = 1
    for i in range(1, N):
        flag = 0
        for j in range(i):
            if H[i] < H[j]:
                flag += 1
            else:
                continue
        logging.debug('flag: {}'.format(flag))
        if flag == 0:
            ans += 1

    return ans

if __name__ == '__main__':
    print(main())



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

int main(void)
{
    int A, B, C;
    cin >> A >> B >> C;
    int eNum = 0;
    if (A == B) eNum++;
    if (B == C) eNum++;
    if (C == A) eNum++;
    if (eNum == 1) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() 
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a == 1) {
		cout << "YES" << endl;
		return 0;
	}
	for (int i = 1; i <= 110; i++)
	{
		if (a * i % b == c)
		{
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    cin>>k;
    string S="ACL";
    for (int i = 0; i < k-1; i++)
    {
        S+="ACL";
    }
    cout<<S<<endl;
    
    return 0;
}

Measured memory_bytes: 3624
import itertools


N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]

all = [i for i in range(1, M + 1)]

ans = 0
for A in itertools.combinations_with_replacement(all, N):
    point = 0
    for i in range(Q):
        ai, bi, ci, di = abcd[i]
        if A[bi - 1] - A[ai - 1] == ci:
            point += di
    ans = max(point, ans)

print(ans)


Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int D,G;
    cin >> D >> G;
    vector<P> vec(D);
    for(int i = 0;i < D;i++) {
        int A,B;
        cin >> A >> B;
        vec.at(i) = P(A,B);
    }
    int ret = Inf;
    for(int bit = 0;bit < (1 << D);bit++) {
        vector<int> solve;
        for(int i = 0;i < D;i++) {
            if(bit & (1 << i)) {
                solve.push_back(i);
            }
        }
        for(int bit2 = 0;bit2 < (1 << solve.size());bit2++) {
            vector<int> green;
            vector<int> Ngreen;
            for(int i = 0;i < solve.size();i++) {
                if(bit2 & (1 << i)) {
                    green.push_back(solve.at(i));
                }
                else {
                    Ngreen.push_back(solve.at(i));
                }
            }
            int cnt = G;
            int cnt2 = 0;
            for(int i = 0;i < green.size();i++) {
                cnt -= (green.at(i) + 1) * 100 * vec.at(green.at(i)).first + vec.at(green.at(i)).second;
                cnt2 += vec.at(green.at(i)).first;
            }
            sort(Ngreen.begin(),Ngreen.end());
            reverse(Ngreen.begin(),Ngreen.end());
            for(int i = 0;i < Ngreen.size();i++) {
                if(cnt <= 0) {
                    break;
                }
                else if((vec.at(Ngreen.at(i)).first - 1) * (Ngreen.at(i) + 1) * 100 >= cnt) {
                    cnt2 += (cnt + (Ngreen.at(i) + 1) * 100 - 1) / ((Ngreen.at(i) + 1) * 100);
                    cnt = 0;
                    break;
                }
                else {
                    cnt -= (vec.at(Ngreen.at(i)).first - 1) * (Ngreen.at(i) + 1) * 100;
                    cnt2 += (vec.at(Ngreen.at(i)).first - 1);
                }
            }
            if(cnt <= 0) {
                ret = min(ret,cnt2);
            }
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
"use strict";

const permutateWithRepetitions = (
  permutationOptions,
  permutationLength
) => {
  if (permutationLength === 1) {
    return permutationOptions.map(permutationOption => [permutationOption]);
  }

  const permutations = [];

  const smallerPermutations = permutateWithRepetitions(
    permutationOptions,
    permutationLength - 1
  );

  permutationOptions.forEach((currentOption) => {
    smallerPermutations.forEach((smallerPermutation) => {
      permutations.push([currentOption].concat(smallerPermutation));
    });
  });

  return permutations;
}

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const S = arg[1].split("").map(n=>parseInt(n));

    // 最大で1000通りしかありえないので全探索する
    const digits = [0,1,2,3,4,5,6,7,8,9];
    
    const combos = permutateWithRepetitions(digits, 3);
    
    let cnt = 0;
    
    for(let i=0; i<1000; i++) {
        let digit1 = combos[i][0];
        let digit2 = combos[i][1];
        let digit3 = combos[i][2];
        
        let flag1 = false;
        let flag2 = false;
        let flag3 = false;

        for(let j=0; j<N; j++) {
            if(S[j] === digit1 && flag1 !== true) {
                flag1 = true;
            } else if(S[j] === digit2 && flag1 && flag2 !== true) {
                flag2 = true;
            } else if(S[j] === digit3 && flag1 && flag2) {
                flag3 = true;
            }
        }
        
        
        if(flag1 && flag2 && flag3) {
            cnt++;
        }
    }
    
    console.log(cnt);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 20296
#include<stdio.h>
#include<string.h>
int main()
{
	char s[30];
	scanf("%s",s);
	int i,j;
	for(i=0;i<strlen(s)-1;i++)
	  for(j=i+1;j<strlen(s);j++)
	    if(s[i]==s[j])
	    {
	    	printf("no\n");
	    	return 0;
	    }
    printf("yes\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include <math.h>
using namespace std;

int main() {
    int n;
    int a;
    int b;
    cin >> n >> a >> b;
    while (true) {
        if (a + 1 <= n && a  + 1 != b) {
            ++a;
        } else if (a + 1 == b || a + 1 == n) {
            if (a - 1 >= 0) {
                --a;
            } else {
                cout << "Borys" << endl;
                return 0;
            }
        }
        if (b - 1 >= 0 && b - 1 != a) {
            --b;
        } else {
            if (b + 1 <= n) {
                ++b;
            } else {
                cout << "Alice" << endl;
                return 0;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 256