akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
from re import split
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy
import re

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


l = I()
print((l / 3) ** 3)

Measured memory_bytes: 39664
#include <iostream>
#include <iomanip>

using namespace std;

int n;
double dp[3005][3005], sol;

int main()
{
    cin >> n;
    dp[0][0] = 1;
    for(int i=1; i<=n; i++)
    {
        double p;
        cin >> p;
        dp[i][0] = dp[i-1][0] * (1 - p);
        for(int j=1; j<=n; j++)
            dp[i][j] = dp[i-1][j] * (1 - p) + dp[i-1][j-1] * p;
    }
    for(int j=n/2+1; j<=n; j++)
        sol += dp[n][j];
    cout << setprecision(12) << fixed << sol << '\n';
    return 0;
}


Measured memory_bytes: 70656
#include <stdio.h>
#define M 1000
#define X 100000

int main(void){

    char S[X];
    int N,l,r,i,j,k=0;
    scanf("%d",&N);
    if(N>1000||N<1){
        printf("Wrong number.\n");
        return 0;
    }
    for(i=0;i<X;i++){
        S[i] = 'F';
    }
    for(i=0;i<N;i++){
        scanf("%d %d",&l,&r);
        if(l>r){
            printf("Wrong number.\n");
            return 0;
        }
        for(j=(l-1);j<=(r-1);j++){
            if(S[j]=='F'){
                S[j] = 'T';
            }else if(S[j]=='T'){
                printf("Duplicated.\n");
                return 0;
            }
        }
    }
    for(i=0;i<X;i++){
        if(S[i]=='T')k++;
    }
    printf("%d\n",k);

return 0;
}


Measured memory_bytes: 256
#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 <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
const int dx[4]={0,0,1,1};
const int dy[4]={0,1,0,1};
int main(void){
  double x[4],y[4];
  while(cin>>x[0]>>y[0]){
    FOR(i,1,4)cin>>x[i]>>y[i];
    double px,py;
    bool out=false;
    REP(r,4){
      px = x[0+dx[r]]; py = y[0+dy[r]];
      if(x[2]<=px&&px<=x[3]&&y[2]<=py&&py<=y[3])out = true;
    }
    REP(r,4){
      px = x[2+dx[r]]; py = y[2+dy[r]];
      if(x[0]<=px&&px<=x[1]&&y[0]<=py&&py<=y[1])out = true;
    }
    if(x[0]<=x[2]&&x[3]<=x[1]&&y[2]<=y[0]&&y[1]<=y[3])out=true;
    if(x[2]<=x[0]&&x[1]<=x[3]&&y[0]<=y[2]&&y[3]<=y[1])out=true;
    if(out)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int h, w;
  cin >> h >> w;
  vector<string> m(h);
  for (int i = 0; i < h; ++i) {
    cin >> m[i];
  }

  vector<vector<bool>> seen(h, vector<bool>(w, false));

  long long ans = 0;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; j++) {
      long long b_cnt, w_cnt;
      b_cnt = w_cnt = 0;
      stack<array<int, 3>> st;
      st.push({i, j, m[i][j] != '#'});
      while (!st.empty()) {
        auto t = st.top();
        int y = t[0], x = t[1], p = t[2];
        st.pop();

        if (y < 0 || y >= h || x < 0 || x >= w) {
          continue;
        }

        if (seen[y][x] || p == m[y][x]) {
          continue;
        }

        seen[y][x] = true;

        if (m[y][x] == '.') {
          w_cnt++;
        } else {
          b_cnt++;
        }

        st.push({y - 1, x, m[y][x]});
        st.push({y + 1, x, m[y][x]});
        st.push({y, x + 1, m[y][x]});
        st.push({y, x - 1, m[y][x]});
      }

      ans += b_cnt * w_cnt;
    }
  }

  cout << ans << '\n';
}


Measured memory_bytes: 8500
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s;
    cin >> s;
    //cout << s << endl;
    if (s == "Sunny")
    {
        cout << "Cloudy" << endl;
    }
    else if (s == "Cloudy")
    {
        cout << "Rainy" << endl;
    }
    else
    {
        cout << "Sunny" << endl;
    }
    return 0;
}

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

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    vector<ll> cost(4);
    for(int i = 0; i < 4; i++){
        cin >> cost[i];
    }
    ll n;
    cin >> n;
    ll t1 = n * 4 * cost[0];
    ll t2 = n * 2 * cost[1];
    ll t3 = n * cost[2];
    ll t4 = 0;
    if(n % 2 == 0){
        t4 = n / 2 * cost[3];
    }else{
        t4 = n / 2 * cost[3] + min({4 * cost[0], 2 * cost[1], cost[2]});
    }
    cout << min({t1, t2, t3, t4});
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

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

using ll = long long;
using pll = pair<ll, ll>;

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

    vector<pll> b(N); // first:min, second:balance 

    for (int i = 0; i < N; i++) {
        string S; cin >> S;
        for (const auto& ch : S) {
            if (ch == '(') {
                b[i].second++;
            } else {
                b[i].second--;
                b[i].first = min(b[i].first, b[i].second);
            }
        }
    }

    sort(b.begin(), b.end(), [](const pll& a, const pll& b) {
        bool sa = signbit(a.second), sb = signbit(b.second);
        if (sa == sb) {
            if (sa == 0) {
                return a.first > b.first;
            } else {
                return a.second - a.first > b.second - b.first;
            }
        }
        return sa < sb;
    });

    int s = 0;
    for (int i = 0; i < N; i++) {
        if (s + b[i].first < 0) {
            s = -1;
            break;
        }
        s += b[i].second;
    }
    cout << (s==0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 18688
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    double mot=0.0;
    rep(i, n){
        double a;
        cin >> a;
        mot += 1.0 / a;
    }
    cout << fixed << setprecision(6) << endl;
    cout << 1.0 / mot << endl;
    return 0;
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
int main(){
  ll a,b;
  cin>> a >> b;
  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  //cout << b << endl;

  map<ll, ll> x;

  //素因数分解
  r = 2;
  while(b >= r*r){
    if(b % r == 0){
      x.insert(make_pair(r, r));
      b /= r;
    }else{
      r++;
    }
  }
  x.insert(make_pair(b, b));
  x.insert(make_pair(1, 1));

  cout << x.size() << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int uq(int div,int mod){
  if(mod == 0){
    return div;
  }
  return uq(mod,(div % mod));
}

int main()
{
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  int sum = 0;
  int r = 1001001001;

  for(int i = 0; i <= max(x,y) * 2;){
    sum = 0;
    sum += i * c;
    //cout << sum << " ";
    if(x - i / 2 > 0){
      sum += (x - i / 2) * a;
    }
    //cout << sum << " ";
    if(y - i / 2 > 0){
      sum += (y - i / 2) * b;
    }
    //cout << sum << " ";
    r = min(r,sum);
    //cout << r << endl;
    i += 2;
  }

  cout << r << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long check(long long x)
{
    long long ans = 1e13;
    for(int i = 1 ; i <= x/i ; i++) {
        if(x%i != 0) continue;
        ans = min(ans,i+x/i);
    }
    return ans-2;
}

int main()
{
    long long n;
    cin >> n;
    
    cout << check(n) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
 
using namespace std;
typedef unsigned long long ll;
 
int main(){
    string s, t;
    cin >> s >> t;
 
    sort(ALL(s));
    sort(ALL(t), greater<int>());
 
    if (s<t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if(S.at(0) == '7' || S.at(1) == '7' || S.at(2) == '7')
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3628
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Node = Tuple!(long, "p", long, "dist");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto n = lread();
    long lim = 101; // 入力の制限より大きい最小の素数
    auto ary = new long[](lim);
    foreach (a; iota(1, n))
    {
        auto p_factor = prime_factorization(a + 1, lim);
        ary[] += p_factor[];
    }
    ary[] += 1;
    // ary.take(n).writeln();
    long gt_5, gt_3, gt_15, gt_25, gt_75;
    foreach (e; ary)
    {
        if (e >= 3)
            gt_3++;
        if (e >= 5)
            gt_5++;
        if (e >= 15)
            gt_15++;
        if (e >= 25)
            gt_25++;
        if (e >= 75)
            gt_75++;
    }
    long ans;
    ans += (gt_5 * (gt_5 - 1) / 2) * (gt_3 - 2);
    ans += (gt_15) * (gt_5 - 1);
    ans += (gt_25) * (gt_3 - 1);
    ans += (gt_75);
    ans.writeln();
}

auto prime_factorization(long a, long lim)
{
    auto p_factor = new long[](lim);
    foreach (i; iota(1, a))
    {
        while (a % (i + 1) == 0)
        {
            a /= (i + 1);
            p_factor[i]++;
        }
        if (a == 0)
            break;
    }
    return p_factor;
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 380
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	string s;ll n;cin >> s >> n;
	rep(i, s.size()) {
		if (s[i] != '1') {
			cout << s[i];
			return 0;
		}
		else if (i + 1 == n) break;
	}
	cout << 1 << endl;
}

Measured memory_bytes: 256
from bisect import bisect_right

N, K = map(int, input().split())
s = input()

t = []
abs_t = []

cur = s[0]
cnt = 0
for ss in s:
    if cur == ss:
        cnt += 1
    else:
        sgn = 1 if cur == '1' else -1
        # 逆立ちでないなら-1
        t.append(cnt * sgn)
        abs_t.append(cnt)

        cur = ss
        cnt = 1
sgn = 1 if cur == '1' else -1
# 逆立ちでないなら-1
t.append(cnt * sgn)
abs_t.append(cnt)

M = len(t)

sgn_cnt = [0]
for tt in t:
    sgn_cnt.append(sgn_cnt[-1] + (1 if tt < 0 else 0))
# 反転が必要な箇所数の累積和

c_abst = [0]
for att in abs_t:
    c_abst.append(c_abst[-1] + att)

# print(t, abs_t, c_abst, sgn_cnt)

ans = 0
for i in range(M):
    ok = bisect_right(sgn_cnt, (K + sgn_cnt[i]))
    ok -= 1
    # print(ok, i, K + sgn_cnt[i])
    # print(c_abst)
    ans = max(ans, c_abst[min(ok, M)] - c_abst[i])
print(ans)


Measured memory_bytes: 52356
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    while(true){
        int H,W;
        cin >> H >>W;
        if(H==0 && W==0)break;
        for(int y=0;y<H;y++){
            for(int x=0;x<W;x++){
                printf("#");
            }
            printf("\n");
        }
		printf("\n");
    }
    return 0;
}

Measured memory_bytes: 3096
N,M = map(int,input().split())
cnt_ac = 0
cnt_wa = 0

aced_state = [False for i in range(N+1)]
wa_state = [0 for i in range(N+1)]

for i in range(M):
    p,s = map(str,input().split())
    p = int(p)
    if aced_state[p] == True:
        continue
    else:
        if s == "AC":
            cnt_ac += 1
            cnt_wa += wa_state[p]
            aced_state[p] = True
        else:
            wa_state[p] += 1

print(cnt_ac,cnt_wa)


Measured memory_bytes: 4656
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
typedef pair<int, int> P;

template<typename T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return (a * b) / gcd(a, b);
}

int main()
{
    int N; cin >> N;
    string s, t; cin >> s >> t;

    int same = 0;
    for (int i = 0; i < N ; i++) {
        if (s.substr(i, N - i) == t.substr(0, N - i)) {
            same = N - i;
            break;
        }
    }
    int ans = N * 2 - same;
    cout << ans << endl;
}

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

int main(){
    int N;
    long long cnt = 0;
    vector<long long> rgb_cnt(3);
    string S;

    cin >> N;
    cin >> S;

    for(int i = 0; i < N; i++){
        switch (S[i]) {
        case 'R':
            rgb_cnt[0] += 1;
            break;
        case 'G':
            rgb_cnt[1] += 1;
            break;
        case 'B':
            rgb_cnt[2] += 1;
            break;
        default:
            break;
        }
    }

    cnt = rgb_cnt[0] * rgb_cnt[1] * rgb_cnt[2];

    for(int i = 0; i < N; i++){
        for(int j = 1; j <= (N - i - 1) / 2; j++){
            if(S[i] != S[i+j] && S[i+j] != S[i+2*j] && S[i+2*j] != S[i]){
                cnt--;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}

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

constexpr long long INF = (1ll << 60);
typedef vector<long long> vec;
typedef vector<vec> mat;

void warshall_floyd(mat &m) {
  const int n = m.size();
  for(int k = 0; k < n; ++k) {
    for(int i = 0; i < n; ++i) {
      for(int j = 0; j < n; ++j) {
	m[i][j] = min(m[i][j], m[i][k] + m[k][j]);
      }
    }
  }
}

long long calc_price(long long d, const vec &q, const vec &r) {
  if(d == INF) return INF;

  long long res = 0;
  long long prev = 0;

  for(int i = 0; i < q.size(); ++i) {
    if(d <= q[i]) {
      res += (d - prev) * r[i];
      break;
    }
    else {
      res += (q[i] - prev) * r[i];
      prev = q[i];
    }
  }
  
  return res;
}
 
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  for(int n, m, c, s, g; cin >> n >> m >> c >> s >> g && n;) {
    --s; --g;

    vector<mat> dist(c, mat(n, vec(n, INF)));
    for(int i = 0; i < m; ++i) {
      int x, y, d, c;
      cin >> x >> y >> d >> c;
      --x; --y; --c;
      dist[c][x][y] = dist[c][y][x] = min<long long>(dist[c][x][y], d);
    }

    for(auto &m : dist) warshall_floyd(m);

    mat cost(n, vec(n, INF));

    vector<int> p(c);
    for(auto &e : p) cin >> e;

    for(int k = 0; k < c; ++k) {
      vec q(p[k] - 1), r(p[k]);
      for(auto &e : q) cin >> e;
      for(auto &e : r) cin >> e;
      q.emplace_back(INF);

      for(int i = 0; i < n; ++i) {
	for(int j = 0; j < n; ++j) {
	  cost[i][j] = min(cost[i][j], calc_price(dist[k][i][j], q, r));
	}
      }
    }

    warshall_floyd(cost);
    
    cout << (cost[s][g] == INF ? -1ll : cost[s][g]) << endl;
  }
  
  return EXIT_SUCCESS;
}

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


#define int long long 

const int N = 2e5 + 7, mod = 1e9 + 7;

int POW(int a, int b, int mod) {
	a %= mod; int r = 1;
	for(int i = b; i > 0; i >>= 1) {
		if(i & 1) r = (r * a) % mod;
		a = (a * a) % mod;
	}
	return r;
}

int f[N];


int nCr(int n, int r) {
	if(n < r) return 0;
	return f[n] * POW(f[n - r] * f[r], mod - 2, mod) % mod;
}


int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	f[0] = 1;
	for(int i = 1; i < N; i++) {
		f[i] = (f[i - 1] * i) % mod;
	}

	int n, m; cin >> n >> m;
	if(n > m) swap(n, m);
	if(m - n > 1) {
		cout << 0 << endl;
	} else if(m > n) {
		cout << (f[n] * f[m]) % mod << endl;
	} else {
		cout << (2LL * f[n] * f[m]) % mod << endl;
	}
}

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

int main() {

    int data[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;

    cout << data[k-1] << endl;
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    i64 N;
    cin >> N;

    vector<i64> X(N),Y(N);
    rep(i,0,N) cin >> X[i] >> Y[i];

    rep(i,0,N) if(((X[i]+Y[i])%2+2)%2!=((X[0]+Y[0])%2+2)%2){
        cout << -1 << endl;
        return;
    }

    vector<i64> U(N),V(N);
    rep(i,0,N){
        U[i]=X[i]+Y[i];
        V[i]=X[i]-Y[i];
    }

    i64 m=32;
    vector<i64> d(m);
    d[0]=1;
    rep(i,1,m) d[i]=d[i-1]*2;
    reverse(begin(d),end(d));

    if((X[0]+Y[0])%2==0){
        d.push_back(1);
        ++m;
    }

    vector<string> ans(N);
    rep(i,0,N){
        vector<i64> s(m),t(m);
        i64 u=0,v=0;
        rep(j,0,m){
            i64 u1=u-d[j],u2=u+d[j];
            if(abs(U[i]-u1)<=abs(U[i]-u2)){
                u=u1;
                s[j]=-1;
            }else{
                u=u2;
                s[j]=1;
            }
        }
        rep(j,0,m){
            i64 v1=v-d[j],v2=v+d[j];
            if(abs(V[i]-v1)<=abs(V[i]-v2)){
                v=v1;
                t[j]=-1;
            }else{
                v=v2;
                t[j]=1;
            }
        }

        string tmp;
        rep(j,0,m){
            if(s[j]==-1 and t[j]==-1) tmp+='L';
            else if(s[j]==1 and t[j]==1) tmp+='R';
            else if(s[j]==-1 and t[j]==1) tmp+='D';
            else tmp+='U';
        }

        ans[i]=tmp;
    }

    cout << m << endl;
    rep(i,0,m){
        cout << d[i];
        if(i==m-1) cout << endl;
        else cout << " ";
    }

    rep(i,0,N) cout << ans[i] << endl;
}

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


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


// Union-Find
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};






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

    vector<int>ver(N,0);
    for(int i=0; i<M; i++){
        ver[a[i]-1]++;
        ver[b[i]-1]++;
    }

    int intersection4 = 0; // 4つ以上の頂点と隣接する頂点の数
    int intersection6 = 0; // 6
    bool ans = true;
    for(int i=0; i<N; i++){
        if(ver[i] % 2 != 0){
            ans = false;
        }
        if(ver[i] >= 4){
            intersection4++;
        }
        if(ver[i] >= 6){
            intersection6++;
        }
    }
    if(intersection4 < 2 && intersection6 == 0){
        ans = false;
    }



    // 以下乱雑コード
    if(intersection4 == 2 && intersection6 == 0){
        int p; // intersectionの番号
        auto itr = ver.begin();
        itr = find(itr, ver.end(), 4);
        p = itr - ver.begin() + 1;

        UnionFind tree(N);
        for(int i=0; i<M; i++){
            if(a[i]!=p && b[i]!=p){
                tree.unite(a[i]-1, b[i]-1);
            }
        }

        int cnt=1;
        for(int i=0;i<N;i++){
            if(!tree.same(0,i)){
                tree.unite(0, i);
                cnt++;
            }
        }
        if(cnt == 2){
            ans = false;
        }
    }




    if(ans){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define N 200005
using namespace std;
int n,a[N],o[N],e[N];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if (i%2==0) e[a[i]]++; else o[a[i]]++;
	}
	int o1=0,o2=0,e1=0,e2=0;
	for (int i=1;i<=100000;i++){
		if (o[i]>o[o1]) o2=o1,o1=i; else
		if (o[i]>o[o2]) o2=i;
		if (e[i]>e[e1]) e2=e1,e1=i; else
		if (e[i]>e[e2]) e2=i;
	}
	if (o1!=e1) printf("%d\n",n-o[o1]-e[e1]); else
	if (o1!=e2&&o[o1]+e[e2]>o[o2]+e[e1]) printf("%d\n",n-o[o1]-e[e2]); else printf("%d\n",n-o[o2]-e[e1]);
}

Measured memory_bytes: 1408
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if a*500+b*100+c*50 == X:
                ans += 1

print(ans)

Measured memory_bytes: 3060
N = input().replace(" ","")
N = int(N)
H = list(map(int,input().split(' ')))

flag = 0
for i in range(N-1):
    if H[N-i-2]-H[N-i-1]>1:
        flag = 1
        break;
    elif H[N-i-2]-H[N-i-1]==1:
        H[N-i-2] = H[N-i-2] - 1


if flag ==0:
    print("Yes")
else:
    print("No")


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

int main(){ 
  int N; cin >> N;
  map<int,int> mp;
  for(int i = 0; i < N; i++){ 
    int a; cin >> a;
    if( mp[a] > 0 ){ cout << "NO" << endl; return 0;}
    mp[a]++;
  }
  
  cout <<"YES" << endl;
  
  return 0;
} 
  

Measured memory_bytes: 9600
import sys
input = sys.stdin.readline


N=int(input())

ANS=[0]*(10**5+1)

for x in range(1,10**2+1):
    for y in range(1,10**2+1):
        for z in range(1,10**2+1):
            ANS[x*x+y*y+z*z+x*y+y*z+z*x]+=1

print(*ANS[1:N+1])


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

using namespace std;

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

    string s;
    getline(cin,s);

    int i=0;
    for(;s[i]!='\0';i++)
        if(s[i]==' ')
        break;

    cout<<"A"<<s[i+1]<<"C";
    return 0;
}


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

int n;
int ans = 0;
bool judge(int a){
	int tot = 0;
	while(a != 0){
		tot ++;
		a = a/10;
	}
	if(tot % 2 == 0) return false;
	else return true;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		if(judge(i)) ans ++;
	}
	printf("%d",ans);
	return 0;
}


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

int N, L;
int A[100100];
int memo[100100];

int f(int x) {
  if (memo[x] > 0) return memo[x];
  int t = 0;
  if (x > 0   && A[x-1] > A[x]) t = max(t, f(x-1));
  if (x < N-1 && A[x+1] > A[x]) t = max(t, f(x+1));
  return memo[x] = t + L - A[x];
}

int main() {
  cin >> N >> L;
  for (int i=0; i<N; i++) cin >> A[i];
  int ans = 0;
  for (int i=0; i<N; i++) ans = max(ans, f(i));
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 4924
#include<iostream>
#include<cassert>
using namespace std;
string s;
size_t cur=0;
int digit()
{
    assert(isdigit(s[cur]));
    int n=s[cur]-'0';
    cur=cur+1;
    return n;
};
int number()
{
    int n=digit();
    while(cur<s.size()&&isdigit(s[cur]))
        n=n*10+digit();
    return n;
};
double expression();
double factor()
{
    if(s[cur]!='(')
        return number();
    cur++;
    double n=expression();
    assert(s[cur]==')');
    cur++;
    return n;
};
double term()
{
    double a=factor();
    while(cur<s.size()&&(s[cur]=='*'||s[cur]=='/'))
    {
        char op=s[cur++];
        int b=factor();
        if(op=='*')
            a*=b;
        else
            a/=b;
    }
    return a;
};


int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cur=0;
        cin>>s;
        s.resize(s.size()-1);
        cout<<expression()<<endl;
    }
}

double expression()
{
    int a=term();
    while((cur<s.size())&&(s[cur]=='+'||s[cur]=='-'))
    {
        char op=s[cur++];
        int b=term();
        if(op=='+')
            a+=b;
        else
            a-=b;
    }
    return a;
}

Measured memory_bytes: 3256
#include<iostream>

using namespace std;

int main()
{
	int N,M,K;
	int *food;
	int ans = 0;

	cin >> N >> M;

	food = new int[M+1];

	for(int i=0;i<M+1;i++)food[i] = 0;

	for(int i=0;i<N;i++)
	{
		cin >> K;
		for(int i=0;i<K;i++)
		{
			int f;
			cin >> f;
			food[f]++;
		}
	}

	for(int i=1;i<M+1;i++)
	{
		if(food[i] == N)
		{
			ans++;
		}
	}

	cout << ans << endl;

	delete(food);

	return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

int main()
{
  int n;
  int h[100];
  cin >> n;
  REP(i,n) {
    cin >> h[i];
  }

  int result = 0;
  int m = -1;
  REP(i,n) {
    if (h[i] >= m) {
      result++;
      m = h[i];
    }
  }
  cout << result << endl;

}


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

int main(){
	int n;
	cin >> n;
	int a[n + 1];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	a[n] = 101;
	int ok = 0;
	int sum = 0;
	for(int i = 0; i < n; i++){
		if(a[i] == a[i + 1]){
			ok++;
		}
		if(ok > 0 && a[i] != a[i + 1]){
			sum += (ok + 1) / 2;
			ok = 0;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<queue>
using namespace std;


int head[400010];

struct node{
    int n_v;
    int next;
}edge[400010];



int main(){

    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF){
        int u ,v;
        int flag = 0;
        int k = 0;
        memset(head,-1,sizeof(head));
        for (int i = 0;i<m;i++){

            scanf("%d%d",&u,&v);
            edge[k].n_v = v;
            edge[k].next = head[u];
            head[u] = k++;
            edge[k].n_v = u;
            edge[k].next = head[v];
            head[v] = k++;


        }
        int vis[200010];
        int vs;
        memset(vis,0,sizeof(vis));
        for (int t = head[1];t!=-1;t = edge[t].next){

            vs = edge[t].n_v;
            vis[vs] = 1;

        }
         for (int t = head[n];t!=-1;t = edge[t].next){

            vs = edge[t].n_v;
            if(vis[vs] == 1 )flag = 1;

        }
        if(flag)puts("POSSIBLE");
        else puts("IMPOSSIBLE");
    }

}


Measured memory_bytes: 5632
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto r = readln.chomp.to!int;
  writeln(3 * r * r);
}


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

using namespace std;

int N,M;
int ab[2000][2];
int e[50][50];

bool search(int sp,int ep){
    e[sp][ep] = e[ep][sp] = 0;
    bool b[N];
    for(int i=0;i<N;i++) b[i] = false;
    queue<int> q;
    b[sp] = true;
    q.push(sp);
    while(!q.empty()){
        int p = q.front();
        q.pop();
        for(int i=0;i<N;i++){
            if(e[p][i] == 1){
                if(i == ep){
                    e[sp][ep] = e[ep][sp] = 1;
                    return false;
                }else{
                    if(!b[i]){
                        q.push(i);
                        b[i] = true;
                    }
                }
            }
        }
    }
    return true;
}

int main(){
    cin >> N >> M;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            e[i][j] = 0;
        }
    }
    for(int i=0;i<M;i++) cin >> ab[i][0] >> ab[i][1];
    for(int i=0;i<M;i++){
        e[ab[i][0]-1][ab[i][1]-1] = e[ab[i][1]-1][ab[i][0]-1] = 1;
    }
    int count = 0;
    for(int i=0;i<M;i++){
        if(search(ab[i][0]-1,ab[i][1]-1)) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
def convert_time_format(seconds:int) -> str:
    if seconds < 0:
        raise ValueError('Paramter seconds is less than 0.')
    if seconds > 86400:
        raise ValueError('Parameter seconds is larger than 86400')

    min = int(seconds / 60)
    sec = seconds % 60
    hour = int(min / 60)
    min = min % 60

    return '{0}:{1}:{2}'.format(hour, min, sec)

if __name__ == "__main__":
    seconds = input()
    print(convert_time_format(int(seconds)))



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

int main()
{
	int c[3][3];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> c[i][j];
		}
	}
	bool res = true;
	for (int i = 1; i < 3; i++) {
		for (int j = 1; j < 3; j++) {
			if (c[i - 1][j] - c[i - 1][j - 1] != c[i][j] - c[i][j - 1]) {
				res = false;
			}
		}
	}
	for (int j = 1; j < 3; j++) {
		for (int i = 1; i < 3; i++) {
			if (c[i - 1][j] - c[i - 1][j - 1] != c[i][j] - c[i][j - 1]) {
				res = false;
			}
		}
	}
	cout << (res ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long
#define lfl long double

lin n, a[100001];
int main(void)
{
    cin >> n;
    lin minAbs = -1;
    lin baseRes = 0;

    rep(i,n)
    {
        cin >> a[i];
        auto ab = abs(a[i]);
        if(minAbs < 0)
            minAbs = ab;
        else
            minAbs = min(minAbs, ab);

        baseRes += ab;
    }

    if(minAbs == 0)
    {
        cout << baseRes << endl;
        return 0;
    }

    rep(i,n-1)
    {
        if(a[i] < 0)
        {
            a[i+1] = - a[i+1];
        }
    }

    if(a[n-1] > 0)
    {
        cout << baseRes << endl;
        return 0;
    }
    
    lin res = baseRes - 2 * minAbs;

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1024
n,m=map(int,input().split())
A=list(map(int,input().split()))
seg0=[0,2,5,5,4,5,6,3,7,6]

import numpy as np

A.sort(reverse=1)
seg=[]
for i in range(m):
    seg.append(seg0[A[i]])

#print(seg)

keta=[-np.inf for i in range(n+1)]
keta[0]=0
for i in range(1,n+1):
    for j in range(m):
        if i-seg[j]>=0 :
            keta[i]=max(keta[i],keta[i-seg[j]]+1)

#print(keta)

ke=keta[n]

#print(ke)
#print(seg)
ans=0
while ke>1 :
    for j in range(m):
        #print(n-seg[j])
        #print(keta[n-seg[j]])
        if n-seg[j]>0 and keta[n]==keta[n-seg[j]]+1 :
            ans+=A[j]*10**(ke-1)
            n-=seg[j]
            #print(ans)
            break
    ke-=1

#print(n)
for i in range(m):
    #print(keta[n])
    if n==seg[i] :
        ans+=A[i]
        break

print(ans)


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

int main() {
    string S;
    cin >> S;
    
    int loses=0;
    for(int i=0;i<S.size();i++) {
        if(S[i]=='x') {
            loses++;
        }
    }
    
    if(loses < 8) cout << "YES" <<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int a,b,c,d;
  
  scanf("%d%d%d%d",&a,&b,&c,&d);
  
  int start,end;
  int ans;
  
  start=(a>=c)?a:c;
  end=(b>=d)?d:b;
  
  ans=end-start;
  
  if(ans>0)
  {
    printf("%d\n",ans);
  }
  else
  {
    printf("0\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto A = RD;
	auto B = RD;
	auto C = RD;

	writeln(A == B ? C : B == C ? A : B);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, std::string s){
    vector<vector<int>> idxes(3);
    string t = "RGB";
    for(int i = 0; i < n; ++i)
        idxes[t.find(s[i])].push_back(i);

    i64 ans = 0;
    for(auto r : idxes[0]){
        unordered_map<int,int> cnt;
        for(auto g : idxes[1]){
            if(((r + g) & 1) == 0 && s[(r + g) >> 1] == 'B')
                --ans;
            ++cnt[abs(r - g)];
        }
        int g_cnt = idxes[1].size();
        for(auto b : idxes[2]){
            int d = abs(r - b);
            if(((r + b) & 1) == 0 && s[(r + b) >> 1] == 'G')
                --ans;
            ans += g_cnt - cnt[d];
        }
    }
    cout << ans << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}

Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
inline void print() { cout << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
string reversed(string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    int n, k; cin >> n >> k;
    string s; cin >> s;
    chmin(k, 13);
    FOR(i, 0, k) {
        string u = s + reversed(s);
        FOR(j, 0, n + 1)chmin(s, u.substr(j, n));
        reverse(all(s));
    }
    print(reversed(s));
}


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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp make_pair
#define pb push_back

const long long MOD = 1000000007;
const long long INF = 1LL<<60;


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

    ll x,y,z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define viit(a) vector<int>::iterator a
#define IT iterater
#define REP(i,a,n) for(ll i=a;i<(n);i++)
#define FOR(i,a,n) for(ll i=a;i<=(n);i++)
#define V vector
#define RE return
#define B(s) s.back()
#define all(a) a.begin(),a.end()
#define ER1(a) a.erase(a.begin())
#define ER0(a) a.erase(a.end())
#define Fill(a,b) memset(a,b,sizeof(a))
#define SO(a) sort(all(a))
#define pb push_back
#define pii pair<int,int>
#define pause system("PAUSE")
#define cls system("CLS")
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    ll sum=0,n,k;
    cin>>n>>k;
    ll a[100001];
    REP(i,0,k)
    cin>>a[i],sum+=a[i];
    if(sum>n)cout<<-1;
    else cout<<n-sum;
    RE 0;
}


Measured memory_bytes: 3704
N,M,Q=map(int,input().split())
a=[0]*Q
b=[0]*Q
c=[0]*Q
d=[0]*Q
for i in range(Q):
  a[i],b[i],c[i],d[i] =map(int,input().split())

  
from copy import deepcopy

ans_list=[]
def dfs(x,M,N,ans):
  if len(ans)<=N-1:
    for j in range(x,M+1):
      tmp=deepcopy(ans)
      tmp.append(j)
      if len(tmp)==N:
        ans_list.append(tmp)
      else:
        dfs(j,M,N,tmp)
    
q=dfs(1,M,N,[])


f=0
for A in ans_list:
  cnt=0
  for i in range(Q):
    if A[b[i]-1]-A[a[i]-1]==c[i]:
      cnt += d[i]
  f=max(f,cnt)
  
print(f)

Measured memory_bytes: 106980
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {
    int N;
    cin >> N;
    vector<int> v(N+1, 0);
    int tmp;
    REP(i, N-1){
        cin >> tmp;
        v[tmp]++;
    }

    REP(i, N) cout << v[i + 1] << endl;
    return 0;
}


Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int x;
    cin >> x;
    if (x>=2000)
    {
        cout << 1 << endl;
    }
    else
    {
        // cout << "koko" << endl;
        int ue = x/100;
        int sita = x - ue * 100;
        // cout << ue << " " << sita << endl;
        if (ue * 5 >= sita)
        {
            cout << 1 << endl;
        }
        else
        {
            cout << 0 << endl;
        }
    }
    
    
    
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;

int main(){
    int N,K; cin >> N >> K ;
    if (K == 1){
        cout <<  0 << endl;
    }
    else{
        cout << N - K  << endl;
    }
}

Measured memory_bytes: 256
import sys
from collections import deque
from itertools import *


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


A, B, C, X, Y = LI()
avg = (A+B)/2
ans = 0
if avg > C:
    ans += C * min(X, Y) * 2
    if X > Y:
        if A > C * 2:
            ans += C * (X - Y) * 2
        else:
            ans += A * (X - Y)
    elif X < Y:
        if B > C * 2:
            ans += C * (Y - X) * 2
        else:
            ans += B * (Y - X)
    elif X == Y:
        pass
else:
    ans = A * X + B * Y
print(ans)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod=1e9+7;
const int N=1e5+10;
LL n;
int a[N];
LL f[N];
void init()
{
    f[0]=1;
    for(LL i=1;i<=100000;i++)
        f[i]=f[i-1]*i%mod;
}
 
int main()
{
    init();
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    LL ans=1;
    LL b=1;
    LL num=0;
    for(LL i=2;i<=n;i++)
    {
        if(b+2<=a[i])
            b=b+2;
        else
        {
            ans=ans*(i-num)%mod;
            num++;
        }
    }
    ans=ans*f[n-num]%mod;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = sc.nextLine().split("");

		long sum = 0;
		for(int i = 0;i < (1 << s.length - 1);i++) {
			String subStr = "";
			for(int j = 0;j < s.length;j++) {
				if((i >> j & 1) == 1) {
					subStr += s[j];
					sum += Long.parseLong(subStr);
					subStr = "";
				}
				else {
					subStr += s[j];
				}
			}

			sum += Long.parseLong(subStr);
		}

		System.out.println(sum);
    }
}

Measured memory_bytes: 23636
import sys
from collections import Counter as cc
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())


def main():
    mod = 10**9 + 7
    n = ii()
    a = li()
    t = [0]*(n)
    ans = 1
    for i in range(n):
        if a[i] == 0:
            tmp = 3
        else:
            tmp = t[a[i]-1]
        ans *= tmp-t[a[i]]
        ans %= mod
        t[a[i]] += 1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 21160
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define R register
using namespace std;
namespace chu_xuan{
    void swap(int &a,int &b){R int tmp=a;a=b,b=tmp;}
    void read(int &a) {a=0;int b=1,c=getchar(); while(c>'9'||c<'0'){if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();a*=b;}
    int In() {int a=0,b=1,c=getchar(); while(c>'9'||c<'0'){if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();return a*b;}
    int max(int a,int b){return a>b?a:b;}
    int min(int a,int b){return a>b?b:a;}
}using namespace chu_xuan;

const int N=10010,num[10]={0,2,5,5,4,5,6,3,7,6};
string dp[N];
char a[10];
int n,m;

void work(string &s,string s_)
{
    if(s=="LYYAKIOI") s=s_;
    else if(s.length()<s_.length()) s=s_;
    else if(s.length()==s_.length() && s<s_) s=s_;
}

int main()
{
    read(n);read(m);
    for(int i=1;i<=m;i++) cin>>a[i];
    for(int i=1;i<=n;i++) dp[i]="LYYAKIOI";
    for(int i=0;i<=n;i++)
    {
        if(dp[i]=="LYYAKIOI") continue;
        for(int j=1;j<=m;j++)
        {
            work(dp[i+num[a[j]-48]],dp[i]+a[j]);
        }
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 45056