akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
// #include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
// #define MOD 1000000007
#define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

int bitDP(int s,int v, vector<vector<int> > & GRAPH,  vector<vector<int> > & DP)
{
  if(s == 0)
  {
    if(v == 0){
      return 0;
    }
    else
    {return INF;
    }
  }

  if((s&(1<<v)) == 0)
  {
    return INF;
  }

  int &ret = DP[s][v];
  if(ret != 0) return ret;

  ret = INF;
  for (int u = 0; u < GRAPH.size(); u++)
  {
    chmin(ret,bitDP(s^(1<<v),u,GRAPH,DP) + GRAPH[u][v]);
  }
  return ret;
  
}
void solve(void)
{
  int v,e;
  cin>>v>>e;
  vector<vector<int> > GRAPH (v,vector<int>(v,INF)); 
  for (int i = 0; i < e; i++)
  {
    int s,t,d;
    cin>>s>>t>>d;
    GRAPH[s][t] = d;
  }
  vector<vector<int> > dp (1<<v,vector<int>(v,0));
  dp[0][0] = 0;

  int res = bitDP((1<<v) -1,0,GRAPH,dp);

  if(res!= INF)
  {
    cout<<res<<endl;
  }
  else
  {
    cout<<-1<<endl;
  }
  
  

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}



Measured memory_bytes: 7800
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    ll n , w; cin >> n >> w;

    vector<pair<ll,ll>> lst(n+1,make_pair(0,0));
    rep(i,n) cin >> lst.at(i+1).first >> lst.at(i+1).second;

    vector<vector<ll>> dp(1e5+1,vector<ll>(n+1,INF));
    dp.at(0).at(0) = 0;

    for(int j=1;j<=n;j++){
        for(int i=0;i<=1e5;i++){
            if(i-lst.at(j).second<0){
                dp.at(i).at(j) = min(dp.at(i).at(j-1),lst.at(j).first);
            }else{
                ll notincluded = dp.at(i).at(j-1);
                ll included = INF;
                included = dp.at(i-lst.at(j).second).at(j-1) + lst.at(j).first;
                dp.at(i).at(j) = min(notincluded,included);
            }
        }
    }
    ll ans = 0;
    for(int i=0;i<=1e5;i++){
        if(dp.at(i).at(n)<=w){
            ans = i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 82432
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N, M, Q;
    std::cin >> N >> M >> Q;

    boost::multi_array<int64_t, 2> mat(boost::extents[N][N]);
    for (decltype(M) i = 0; i < M; ++i) {
        int64_t l, r;
        std::cin >> l >> r;
        l--; r--;

        for (int y = 0; y <= l; ++y) {
            ++mat[y][r];
        }
        // ↓間に合わない
        #if 0
        for (int y = 0; y <= l; ++y) {
            for (int x = r; x < N; ++x) {
                ++mat[y][x];
            }
        }
        #endif
    }

    // いもす
    for (int y = 0; y < N; ++y) {
        for (int x = 1; x < N; ++x) {
            mat[y][x] += mat[y][x-1];
        }
    }

    for (decltype(Q) i = 0; i < Q; ++i) {
        int64_t p, q;
        std::cin >> p >> q;
        p--; q--;
        std::cout << mat[p][q] << std::endl;
    }

    return 0;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> vec;
  int current;
  int cnt = 0;
  string str;
  cin >> str;
  if(str[0] == '0') vec.push_back(0);
  rep(i, n){
    int num = str[i]-'0';
    if(i == 0){
      current = num;
      cnt++;
    }else{
      if(num == current) cnt++;
      else{
        current = num;
        vec.push_back(cnt);
        cnt = 1;
      }
      if(i == n-1) vec.push_back(cnt);
    }
  }
  if(str[n-1] == '0') vec.push_back(0);
  if(vec.size() <= k*2+1) cout << n << endl;
  else{
    int sum = 0;
    int biggest = 0;
    rep(i, k*2+1) sum += vec[i];
    rep(i, (vec.size()-(k*2+1))/2+1){
      biggest = max(biggest, sum);
      sum -= vec[i*2];
      sum -= vec[i*2+1];
      if(i != (vec.size()-(k*2+1))/2){
 		sum += vec[i*2+k*2+1];
      	sum += vec[i*2+k*2+2];
      }
    }
    cout << biggest << endl;
  }
  return 0;
}

Measured memory_bytes: 4092
import numpy

N, D = map(int, input().split())
X = [0] * N
Y = [0] * N
count = 0
for i in range(N):
    X[i], Y[i] = map(int, input().split())
    if numpy.sqrt(X[i]**2 + Y[i]**2) <= D:
        count += 1
print(count)

Measured memory_bytes: 42416
n, m = map(int, input().split())
p = [[] for i in range(n)]

for i in range(m):
    a, b = map(lambda x: int(x)-1, input().split())
    p[a].append(b)
    p[b].append(a)
ans = 0

# print(p)
def s(d, l):
    global ans
    # print(d,l)
    if d == n:
        ans += 1
        return
    for i in p[l[-1]]:
        if i in l:
            continue
        s(d+1, l+[i])
    return


s(1, [0])
print(ans)

Measured memory_bytes: 3064
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(N);
    vector<int> p(N);
    rep(i,N) cin >> p[i];
    int count = 0;
    rep(i,N){
        if((i+1)!=p[i]) count++;
    }
    cout << ((count<=2)? "YES": "NO") << nn;
    return 0;
}

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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

vector<int> edges_to[100001];

typedef struct Node{
    int parent;
    vector<int> child;
} Node;

void construct_ki(Node *ki, int now, int p){
    ki[now].parent = p;
    rep(i, edges_to[now].size()){
        int c = edges_to[now][i];
        if(c != p) {
            ki[now].child.push_back(c);
            construct_ki(ki, c, now);
        }
    }
}

int num_nodes(Node *ki, int now){
    if(ki[now].child.size() == 0) return 1;
    
    int acc = 0;
    rep(i, ki[now].child.size()) acc += num_nodes(ki, ki[now].child[i]);
    return acc + 1; //子の部分木の節点の合計+自分
}

int main(void){
    int N; cin >> N;
    Node ki[N+1];
    rep(i, N-1){
        int a, b; cin >> a >> b;
        edges_to[a].push_back(b);
        edges_to[b].push_back(a);
    }

    int root = 1;
    construct_ki(ki, 1, -1);

    //for(int i = 1; i <= N; i++) cout << ki[i].parent << " ";
    //cout << endl;
   
    int dist_from_n_to_root = 0;
    int op = N;
    while(ki[op].parent != 1) {
        dist_from_n_to_root++;
        op = ki[op].parent;
    }

    int snuke_start;
    op = N;
    dist_from_n_to_root >>= 1;
    rep(i, dist_from_n_to_root) op = ki[op].parent;
    snuke_start = op;

    //snuke_startを根とする部分木の節点数が
    //N % 2 = 1 -> N/2+1以上
    //N % 2 = 0 -> N/2以上
    //このときsnukeは勝利する
    int snuke_partial_tree = num_nodes(ki, snuke_start);

    //cout << snuke_partial_tree << endl;

    if((N % 2 == 1 && snuke_partial_tree >= N/2 + 1) || (N % 2 == 0 && snuke_partial_tree >= N/2)){
        cout << "Snuke" << endl;
    }
    else cout << "Fennec" << endl;

    return 0;
}

Measured memory_bytes: 21376
program name
    implicit none
    integer(4):: n, ans,i
    integer(4),allocatable:: a(:)

    read*, n
    allocate(a(n))
    read*, a(:)

    ans = a(1)

    do i=2,n
        ans = gcd(ans, a(i))
    end do

    print*, ans

contains

recursive function gcd(x,y) result(ret)
    integer(4):: x,y
    integer(4):: ret

    if (mod(x,y) == 0)  then
        ret = y
        return
    end if

    ret = gcd(y,mod(x,y))

end function

end program name

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll k; cin>>k;
  vll a(k);
  rep(i,k) cin>>a[i];
  
  ll min=2,max=2;
  rrep(i,k){
    max=max/a[i];
    min=(min+a[i]-1)/a[i];
    if(max<min){
      cout<<-1<<endl;
      return 0;
    }
    max=max*a[i]+a[i]-1;
    min=min*a[i];
    // cout<<min<<" "<<max<<endl;
  }
  cout<<min<<" "<<max<<endl;
}

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

int main() {
    string s;
    getline(cin, s);
    string ans;
    for (char i : s) {
        int code = (int)i;
        if (65 <= code && code <= 90) ans.push_back((char)(i + 32));
        else if (97 <= code && code <= 122) ans.push_back((char)(i - 32));
        else ans.push_back(i);
    }
    cout << ans << endl;
}



Measured memory_bytes: 3212
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int,int>
#define p64 pair<ll,ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream& operator<<(ostream& out, const pair<T,U>& p){
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename ...Args>
void print_container(const ContainerType<ValueType, Args...>& c){
	cout << "{ ";
	for(const auto& v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

const int N = 2e5 + 5;
int arr[N];

void solve()
{
	int n;
	cin >> n;
	for(int i = 0;i < n;i++) cin >> arr[i];
	multiset<int> M;
	int cnt = 0;
	for(int i = 0;i < n;i++){
		M.insert(arr[i]);
		if(*M.begin() >= arr[i]) cnt++;
	}
	cout << cnt << ln;
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	clock_t start,stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for(int tc = 1;tc < t + 1;tc++) solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    int n;
    cin >> n;
    cout << (n+1)/2 << endl;
}

Measured memory_bytes: 256
while True:
  n,x = map(int,input().split())
  if n+x==0:break
  ans = 0
  for i in range(1,n+1):
    for j in range(i+1,n):
      k = x-i-j
      if i<j<k<=n and i+j+k==x:ans+=1
  print(ans)


Measured memory_bytes: 5596
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#define Cin(T, x) T x; cin >> x
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) find(Range(c), x) != c.end()
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, vs, n, m) vector<vector<T>> vs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    Cin(ll, c);
    Cins2(ll, n, x, v);
    x.insert(x.begin(), 0);
    x.push_back(c);
    Cusum(ll, n, v, sv);

    ll ans = 0;

    vector<ll> dcf(n+1);
    {
        ll m = -1;
        For(f, n+1){
            ll d = sv[f] - sv[0] - x[f];
            if(d > m) m = d;
            dcf[f] = m;
        }
        // Couts(dcf);
    }
    for(int b = 1; b <= n+1; b ++){
        ll dc = dcf[b-1] + sv[n]-sv[b-1] - 2*(c-x[b]);
        // printf("%d %lld = %lld + %lld - %lld\n", b, dc, dcf[b-1], sv[n]-sv[b-1], 2*(c-x[b]));
        ans = max(ans, dc);
    }

    {
        ll m = -1;
        For(f, n+1){
            ll d = sv[f] - sv[0] - 2*x[f];
            if(d > m) m = d;
            dcf[f] = m;
        }
        // Couts(dcf);
    }
    for(int b = 1; b <= n+1; b ++){
        ll dc = dcf[b-1] + sv[n]-sv[b-1] - (c-x[b]);
        // printf("%d %lld = %lld + %lld - %lld\n", b, dc, dcf[b-1], sv[n]-sv[b-1], c-x[b]);
        ans = max(ans, dc);
    }
    Cout(ans);
}


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

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

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

	int pindex,qindex;
	int index=0;
	do
	{
		if (p==r)
		{
			pindex=index;
		}
		if (q==r)
		{
			qindex=index;
		}
		++index;
	}
	while (next_permutation(r.begin(),r.end()));
	cout << abs(pindex-qindex) << endl;
	
}

	






Measured memory_bytes: 3536
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
int main()
{
  int k; cin >> k;
  string s; cin >> s;
  if(k >= (int)s.size()) cout << s << "\n";
  else {
    rep(i,k) cout << s[i];
    cout << "..." << "\n";
  }
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
using ld = long double;
using ulli = unsigned long long int;
#define filein freopen ("in.txt", "r", stdin)
#define fileout freopen ("out.txt", "w", stdout)
#define dbg(x) cerr << #x << ": " << x << endl
#define all(v) ((v).begin()),((v).end()) 
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
void solve(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b;
}
int main(){
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}


Measured memory_bytes: 256
n = int(input())
check = []
l = []
li = list(map(int,input().split()))
for a in li:
    if a > 0:
        check.append(1)
        l.append(a)
    elif a < 0:
        check.append(-1)
        l.append(-a)
    else:
        check.append(0)
        l.append(a)
for i in range(n-1):
    if check[i] == -1:
        check[i] = 1
        check[i+1] *= -1

if check[-1] == -1:
    print(sum(l)-2*min(l))
else:
    print(sum(l))

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int p = 2019;

    vector<long long> val(p, 0);    /* あまりが0 - p-1になる数 */
    ll ten_ruijo_amari = 1;
    ll cur = 0;
    val[cur]++;

    REP(i, n) {
        cur = (cur + (s[n - 1 - i] - '0') * ten_ruijo_amari) % p;
        ten_ruijo_amari = (ten_ruijo_amari * 10) % p;
        val[cur]++;
    }

    ll ans = 0;
    REP(i, p) ans += val[i] * (val[i] - 1) / 2;

    cout << ans << endl;

    return 0;
}

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

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

  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  bool flag = true;
  int now = 1;
  int i;
  for(i = 0; ; ++i) {
    if(i == n) {
      flag = false;
      break;
    }
    if(now == 2) {
      break;
    }
    now = a[--now];
  }

  cout << (flag ? i : -1) << '\n';
  return 0;
}


Measured memory_bytes: 1276
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, M;
    string S;
    cin >> N >> M >> S;
    vv<int> graph(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    vector<int> cntA(N), cntB(N);
    rep(v, N) {
        for (int u : graph[v]) {
            if (S[v] == 'A') cntA[u]++;
            else cntB[u]++;
        }
    }

    queue<int> q;
    vector<bool> visited(N);
    rep(v, N) {
        if (cntA[v] == 0 || cntB[v] == 0) {
            q.push(v);
            visited[v] = true;
        }
    }

    while (!q.empty()) {
        int v = q.front();
        q.pop();

        for (int u : graph[v]) {
            if (visited[u]) continue;

            if (S[v] == 'A') cntA[u]--;
            else cntB[u]--;

            if (cntA[u] == 0 || cntB[u] == 0) {
                q.push(u);
                visited[u] = true;
            }
        }
    }

    rep(v, N) {
        if (!visited[v]) {
            write("Yes");
            return 0;
        }
    }
    write("No");
}

Measured memory_bytes: 12240
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef long long ll;

int main(void){
    ll n, k, t, u, v, l;
    cin >> n >> k >> t >> u >> v >> l;
    
    ll d[205];
    for (int i = 0; i < n; i++) cin >> d[i];
    
    ll vel[10010], fast = 0, idx = 0;
    for (int i = 0; i < l; i++) {
        if (idx < n && d[idx] == i) {
            fast = min((k + 1) * v * t, fast + v * t);
            idx++;
        }
        
        if (fast > 0) vel[i] = v;
        else vel[i] = u;
        fast = max(fast - 1, 0ll);
    }
    
    double ans = 0.0;
    for (int i = 0; i < l; i++) {
        ans += double(1) / double(vel[i]);
        //cout << i << " " << vel[i] << endl;
    }
    
    cout << setprecision(12) << ans << endl;
}



Measured memory_bytes: 3360
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll dp[100][2];
    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;
    rep(d, 50) {
        ll mask = 1LL<<(50-d-1);
        ll num = 0;
        rep(i, n) if (a[i] & mask) num++;

        ll cost0 = mask * num;
        ll cost1 = mask * (n - num);

        if (dp[d][1] != -1) chmax(dp[d+1][1], dp[d][1] + max(cost0, cost1));

        if (dp[d][0] != -1) if (k & mask) chmax(dp[d+1][1], dp[d][0] + cost0);

        if (dp[d][0] != -1) {
            if (k & mask) chmax(dp[d+1][0], dp[d][0] + cost1);
            else chmax(dp[d+1][0], dp[d][0] + cost0);
        }
    }
    ll ans = 0;
    chmax(ans, dp[50][0]);
    chmax(ans, dp[50][1]);
    cout << ans << endl;
}

Measured memory_bytes: 1024
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = [0 for i in range(n)]
b[0] += 1
i = 0
ans = 0
c = a[0]
while True:
    b[c-1] += 1
    i += 1
    if i == k:
        print(c)
        exit()
    if b[c-1] > 1:
        ans = c
        break
    c = a[c-1]
c = a[0]
j = 0
while True:
    j+=1
    if c == ans:
        break
    c = a[c-1]
if c == 1:
    j = 0
k -= j
k %= (i-j)
for i in range(k):
    c = a[c-1]
print(c)

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

int main()
{
    const ll m = 1e9+7;
    string s;
    cin >> s;
    int n = s.size();

    vector<vector<ll>> dp(n+1, vector<ll>(4, 0));
    dp[0][0] = 1;

    rep(i,n) {
        rep(j,4) dp[i+1][j] = s[i] == '?' ? (3*dp[i][j]) % m : dp[i][j];
        if(s[i] == 'A' || s[i] == '?') dp[i+1][1] = (dp[i+1][1] + dp[i][0]) % m;
        if(s[i] == 'B' || s[i] == '?') dp[i+1][2] = (dp[i+1][2] + dp[i][1]) % m;
        if(s[i] == 'C' || s[i] == '?') dp[i+1][3] = (dp[i+1][3] + dp[i][2]) % m;
    }

    cout << dp[n][3] << endl;
    return 0;
}

Measured memory_bytes: 7424
def f n,x
  res = 0
  while n>0
    res += n%x
    n /= x
  end
  res
end

n = gets.to_i
s = gets.to_i

if n==s
  p n+1
  exit
end

sqrt = Math.sqrt(n).to_i
sqrt.times{|i|
  if s==f(n,i+2)
    p i+2
    exit
  end
}

sqrt.times{|i|
  b = (n-s+(sqrt-i))/(sqrt-i)
  next if b<=1
  if s==f(n,b)
    p b
    exit
  end
}

p -1

Measured memory_bytes: 3836
#include <stdio.h>
int main(void){
    int n,s;
    s=0;
    scanf("%d",&n);
    int d[n];
    for(int i=0;i<n;i++){
        scanf("%d",d+i);
        s+=d[i];
    }
    s*=s;
    for(int i=0;i<n;i++){
        s-=d[i]*d[i];
    }
    printf("%d\n",s/2);
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
int main(){
  int x,a=0,i,j;std::cin>>x;
  if(x==1){a=1;}
  else{
    for(i=2;i<=std::sqrt(x);++i){
      j=2;
      while(std::pow(i,j)<=x){
        a=(std::pow(i,j)>a?std::pow(i,j):a);
        ++j;
      }
    }
  }
  std::cout<<a<<"\n";
}

Measured memory_bytes: 384
n = int(input())
a = input()
b = input()
ans = 1
i = 0
wari = 1000000007
if n == 1:
    print(3)
    exit()
elif n == 2:
    print(6)
    exit()
else:
    if a[i] == b[i]:
        ans *=3
        i +=1
        
    else:
        i +=2
        ans *=6
        
    while True:
        if i >= n:
            break
        if a[i-1] == b[i-1]:
            if a[i] == b[i]:
                ans*=2
                ans%=wari
                i+=1
            else:
                ans*=2
                ans%=wari
                i+=2
        else:
            if a[i] == b[i]:
                ans*=1
                ans%=wari
                i+=1
            else:
                ans*=3
                ans%=wari
                i+=2
    print(ans)

Measured memory_bytes: 9156
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    vector<int> solve(int n, int K, int c, string& s) {
        vector<int> dp(n + 1, 0);

        for (int i = n - 1; i >= 0; --i) {
            if (s[i] != 'x') {
                dp[i] = 1;
                if (i + c + 1 < n) {
                    dp[i] = max(dp[i], dp[i + c + 1] + 1);
                }
            }
            dp[i] = max(dp[i], dp[i + 1]);
        }
        // cout << dp[0] << endl;
        if (dp[0] != K) {
            return {};
        }
        // for (int i = 0; i < n; ++i) {
        //     cout << i << ":" << dp[i] << endl;
        // }

        vector<int> res;
        int L = -12345;
        int R = L;
        for (int i = 0; i < n; ++i) {
            if (s[i] == 'x') {
                continue;
            }
            int l = i;
            while (i + 1 < n && dp[i + 1] == dp[i]) {
                ++i;
            }
            int r = i;
            int cnt = 0;
            int NL = r;
            int NR = l;
            int cand = -1;
            for (int j = l; j <= r; ++j) {
                if (s[j] == 'x') {
                    continue;
                }
                if (L + c < j) {
                    ++cnt;
                    NL = min(NL, j);
                    NR = max(NR, j);
                }
                if (R + c < j) {
                    cand = j;
                }
            }
            if (cnt == 1 && cand >= 0) {
                res.push_back(cand);
            }
            L = NL;
            R = NR;
        }
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    Solution sol;
    auto res = sol.solve(n, k, c, s);
    for (auto r : res) {
        cout << (r + 1) << "\n";
    }
    return 0;
}

Measured memory_bytes: 2684
# Problem: https://atcoder.jp/contests/abc088/tasks/abc088_c
# Python 3rd Try

import sys
# from collections import defaultdict
# import heapq,copy
import pprint as pp
# from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


# Const
MAXSIZE = ( 1 << 31 ) -1
MINSIZE = -( 1 << 31) + 1
yes = "Yes"
no = "No"

def solver(line00,line01,line02,
           line10,line11,line12,
           line20,line21,line22):

    result = no
    a0 = 0
    b0 = line00
    b1 = line01 - a0
    b2 = line02 - a0
    a1 = line10 -line00
    a2 = line20 - line00
    if (( a1 + b1 ) == line11) and (( a1 + b2 ) == line12
    ) and (( a2 + b1 ) == line21) and (( a2 + b2 ) == line22):
        result = yes
    return result


if __name__ == "__main__":
    line00 , line01, line02 = MI()
    line10 , line11, line12 = MI()
    line20 , line21, line22 = MI()
    print("{}".format(solver(line00, line01, line02,
                             line10, line11, line12,
                             line20, line21, line22)))


Measured memory_bytes: 9928
from itertools import combinations


def main():
    N, K = list(map(int, input().split(' ')))
    if K > (N - 1) * (N - 2) // 2:
        print(-1)
        return
    # print M and graph
    adj_nodes = [[] for _ in range(N)]
    adj_nodes[0] = [n for n in range(1, N)]
    C = (N - 1) * (N - 2) // 2 - K
    c = 0
    for comb in combinations(range(1, N), 2):
        if c >= C:
            break
        u, v = comb
        adj_nodes[u].append(v)
        c += 1
    print(N - 1 + C)
    for u in range(N):
        for v in adj_nodes[u]:
            print('{} {}'.format(u + 1, v + 1))


if __name__ == '__main__':
    main()

Measured memory_bytes: 9232
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;

void sol(int x,string s,int c){
    if(s.size()==x){
        cout << s << endl;
        return;
    }else{
        rep(i,c+1){
            char ns='a'+i;
            if(i==c) sol(x,s+ns,c+1);
            else sol(x,s+ns,c);
        }
    }

}


signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N;
    cin>>N;

    sol(N,"a",1);




}


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

class Heap {
    vector<int> v;
    void maxHeapify(int i){
        int left,right,largest;
        left = 2 * (i + 1) - 1;
        right = 2 * (i + 1);
        largest = i;
        if (left < v.size() && v[left] > v[largest]){
            largest = left;
        }
        if (right < v.size() && v[right] > v[largest]){
            largest = right;
        }

        if (largest != i){
            swap(v[i],v[largest]);
            maxHeapify(largest);
        }
    }

public:
    Heap(const vector<int> &heap) : v(heap) {
        for (int i = (v.size() - 1) / 2; i >= 0; --i) maxHeapify(i);
    }

    void print(){
        for (auto item : v) cout << " "  << item;
        cout << endl;
    }

    int extract(){
        if (v.empty())return -1;
        int result = v.front();
        v.front() = v.back();
        v.pop_back();
        if (v.empty())return -1;
        maxHeapify(0);
        return result;
    }

    void insert(int value){
        v.push_back(value);
        int i = v.size() - 1;
        while(i > 0 && v[i] > v[(i-1)/ 2]){
            int p = (i - 1) / 2;
            swap(v[i],v[p]);
            i = p;
        }
    }
};


int main(){
    //freopen("in", "r", stdin);
    Heap h(vector<int>(0));
    for (;;) {
        int num;
        string command;
        cin >> command;
        if (command == "insert") {
            cin >> num;
            h.insert(num);
        } else if (command == "extract") {
            cout << h.extract() << endl;
        } else {
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 6952
#include <stdio.h>
#include <math.h>

int main(void)
{
	double x1, y1, x2, y2, distance;

	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

	printf("%f", sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)));

	return 0;
}


Measured memory_bytes: 2048
n = int(input())
pt = px = py = 0
ok = 1
for i in range(n):
    t, x, y = map(int, input().split())
    T = t - pt
    D = abs(x - px) + abs(y - py)
    if T < D or (T - D) % 2 == 1:
        ok = 0
        break
    pt = t; px = x; py = y
print("Yes"*ok or"No")


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

template <int MOD_> struct modnum {
	static constexpr int MOD = MOD_;
	static_assert(MOD_ > 0, "MOD must be positive");

private:
	using ll = long long;

	int v;

	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}

public:

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }

	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	friend modnum inv(const modnum& m) { return m.inv(); }
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}
	friend modnum neg(const modnum& m) { return m.neg(); }

	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}

	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}

	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};

template <typename T> T pow(T a, long long b) {
	assert(b >= 0);
	T r = 1; while (b) { if (b & 1) r *= a; b >>= 1; a *= a; } return r;
}

int main() {
	using namespace std;
	ios_base::sync_with_stdio(false), cin.tie(nullptr);

	int N, A; cin >> N >> A;

	using num = modnum<int(1e9)+7>;
	vector<num> fact(N+1);
	fact[0] = 1; for (int i = 1; i <= N; i++) fact[i] = fact[i-1] * num(i);
	vector<num> ifact(N+1);
	ifact[N] = inv(fact[N]); for (int i = N; i >= 1; i--) ifact[i-1] = ifact[i] * num(i);
	auto choose = [&](int n, int r) -> num {
		if (0 <= r && r <= n) return fact[n] * ifact[r] * ifact[n-r];
		else return num(0);
	};

	num ans = 0;
	for (int j = 0; j <= A; j++) {
		ans += choose(A, j) * num(j & 1 ? -1 : 1) * fact[N-1-j] * (A-j);
	}
	for (int j = 0; j <= A-2; j++) {
		for (int k = 0; j+k <= A-2; k++) {
			ans += fact[k] * num(j & 1 ? -1 : 1) * fact[N-1-(j+k+1)] * choose(A, j + k + 2) * num(j+1);
		}
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 81292
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << (n+1)/2 << endl;

    return 0;
}

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

using namespace std;

typedef long long LL;
typedef vector<int>    VI;
typedef vector<bool>   VB;
typedef vector<string> VS;

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#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++)
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int m;
VI ans;
string s;

int main(void) {
	cin >> m;
	rep (i, m) {
		string s;
		cin >> s;
		VS ans;
		REP (j, 1, s.size()) {
			string s1 = s.substr(0, j);
			string s2 = s.substr(j);
			ans.PB(s1 + s2);
			ans.PB(s2 + s1);
			string rs1 = s1, rs2 = s2;
			reverse(ALL(rs1));
			reverse(ALL(rs2));
			ans.PB(rs1 + s2);
			ans.PB(s2 + rs1);
			ans.PB(rs2 + s1);
			ans.PB(s1 + rs2);
			ans.PB(rs1 + rs2);
			ans.PB(rs2 + rs1);
		}
		set<string> temp(ALL(ans));
		ans = VS(ALL(temp));
		cout << ans.size() << endl;
	}
    return 0;
}

Measured memory_bytes: 3204
type node = {
        id:int;
        mutable stime:int;
        mutable etime:int;
        mutable nodes: node array
     }
;;

let new_node id = {id=id;stime=0;etime=0;nodes=[||]};;

let dfs graph =
  let total_time = ref 0 in
  let rec search nd time =
    if nd.stime > 0 then time
    else if nd.nodes == [||] then
      begin
         nd.stime <- time+1;nd.etime <- time+2;time+2
       end
    else
      begin
        nd.stime <- time+1;
        let last_time = ref (time+1) in
        for i = 0 to (Array.length nd.nodes)-1 do
          last_time := search nd.nodes.(i) !last_time
        done;
        nd.etime <- !last_time+1;!last_time+1
      end
  in
  for i = 0 to (Array.length graph)-1 do
    if graph.(i).stime == 0 then total_time := search graph.(i) !total_time
  done
;;

let () =
    let n = read_int () in
    let graph = Array.init n (fun x -> new_node (x+1)) in
    let rec read = function
        0 -> ()
      | i ->
            let (v,k) = Scanf.scanf "%d %d" (fun x y -> (x,y)) in
            if k <> 0 then
                graph.(v-1).nodes <- Array.init k (fun x ->
                         let child = Scanf.scanf " %d" (fun y -> y) in graph.(child-1))
            ;Scanf.scanf "\n" ()
            ;read (i-1)
    in
    read n;
    dfs graph;
    Array.iter (fun x -> Printf.printf "%d %d %d\n" x.id x.stime x.etime) graph
;;

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

int main() {
  int A, B, C, D;
  
  cin >>A>>B>>C>>D;
  
  if (A+B < C+D) {
    cout << "Right" << endl;
  }
  
  else if (A+B == C+D) {
    cout << "Balanced" << endl;
  }
  
  else {
    cout << "Left" << endl;
  }
}

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

int A[4],B[4],C[4];

int main(){
  cin >>A[0]>>B[0]>>A[1]>>B[1]>>A[2]>>B[2]>>A[3]>>B[3];
  for(int i = 0; i < 4; i++){
    if(A[i]==1){
      C[i]=6000*B[i];
    }else if(A[i]==2){
      C[i]=4000*B[i];
    }else if(A[i]==3){
      C[i]=3000*B[i];
    }else{
      C[i]=2000*B[i];
    }
  }
  cout <<C[0]<<endl<<C[1]<<endl<<C[2]<<endl<<C[3]<<endl;
}

Measured memory_bytes: 1160
import sys
def input():
	return sys.stdin.readline()[:-1]

n, k = map(int, input().split())
d = 31
z = [list(map(int, input().split())) for _ in range(n)]
used = [True for _ in range(n)]
dp = [[0 for _ in range(2)] for _ in range(d)]
dp[d-1][1] = sum([x[1] for x in z])
for i in range(d-2, -1, -1):
	if (k>>i) % 2 == 1:
		dp[i][1] = dp[i+1][1]
		tmp = 0
		for j in range(n):
			if used[j] == True and (z[j][0]>>i) % 2 == 0:
				tmp += z[j][1]
		if tmp == dp[i+1][1]:
			dp[i][1] = 0
			used = [False] * n
		dp[i][0] = max(tmp, dp[i+1][0])
	else:
		dp[i][1] = dp[i+1][1]
		for j in range(n):
			if used[j] == True and (z[j][0]>>i) % 2 == 1:
				used[j] = False
				dp[i][1] -= z[j][1]
		dp[i][0] = dp[i+1][0]
print(max(dp[0]))

Measured memory_bytes: 65884
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t;
    cin>>n>>x>>t;
    ll ans=ceil((float)n/x)*t;
    cout<<ans;
	return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <math.h>
#include <string.h>
int main (void){
        int A;
          scanf("%d",&A);
      if (A<1200) {
        printf("ABC\n");
      }else if (A<2800) {
      printf("ARC\n");
      }else{
        printf("AGC\n");
      }


        return 0;

}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
 
#include <bits/stdc++.h>
 
#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
//#define PI 3.141592653589
 
using namespace std;
        
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pld = pair <ld, ld>;
        
/* 
const ll MAX_MEM = 25e7;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/
        
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
        
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
        
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
        
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
        
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("lol.in", "r", stdin);
    //freopen("lol.out", "w", stdout);
}

signed main()
{
    Start();
    int s = 2200;
    vector <int> isp(s + 1, 1);
    isp[0] = isp[1] = 0;
    for (int i = 2; i <= s; ++i)
        if (isp[i])
            for (int j = i * i; j <= s; j += i)
                isp[j] = 0;
    vector <int> pr;
    for (int i = 0; i <= s; ++i)
        if (isp[i])
            pr.pb(i);
    int n;
    cin >> n;
    vector <int> a(n);
    cin >> a;
    vector <int> oth(n);
    map <int, int> hm, pir;
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        int cb = round(cbrt(a[i]));
        if (cb * cb * cb == a[i])
        {
            ans = 1;
            oth[i] = -1;
            continue;
        }
        int x = a[i], y = 1, z = 1, alp = 1;
        for (auto &p : pr)
        {
            int cur = 0;
            while (x % p == 0)
            {
                ++cur;
                x /= p;
                alp *= p;
            }
            cur %= 3;
            int tmp = cur;
            while (tmp--)
                z *= p;
            if (cur)
                cur = 3 - cur;
            while (cur--)
                y *= p;
        }
        x = a[i];
        x /= alp;
        int q = round(sqrt(x));
        if (q * q == x)
        {
            z *= q * q;
            y *= q;
        }
        else
        {
            z *= x;
            y *= x * x;
        }
        hm[z]++;
        pir[z] = y;
        pir[y] = z;
    }
    map <int, int> used;
    for (auto &i : hm)
    {
        if (used[i.first])
            continue;
        used[i.first] = used[pir[i.first]] = 1;
        ans += max(hm[i.first], hm[pir[i.first]]);
    }
    cout << ans;
    return 0;
}
 


Measured memory_bytes: 41216